[loom] Add basic domain models
This commit is contained in:
parent
b164c7d97f
commit
7766235e54
3
apps/loom/README.md
Normal file
3
apps/loom/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Loom
|
||||
|
||||
Loom is the design tool for the `Fabric` framework. It is a web-based tool that allows you to create and manage and design every part of your systems
|
||||
22
apps/loom/domain/package.json
Normal file
22
apps/loom/domain/package.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@loom/domain",
|
||||
"type": "module",
|
||||
"module": "dist/index.js",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"private": true,
|
||||
"packageManager": "yarn@4.1.1",
|
||||
"devDependencies": {
|
||||
"typescript": "^5.5.4",
|
||||
"vitest": "^2.0.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ulthar/fabric-core": "workspace:^"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vitest",
|
||||
"build": "tsc -p tsconfig.build.json"
|
||||
}
|
||||
}
|
||||
9
apps/loom/domain/src/entities/app.ts
Normal file
9
apps/loom/domain/src/entities/app.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Entity, SemVer } from "@ulthar/fabric-core";
|
||||
import { EnvironmentVariable } from "./environment.js";
|
||||
|
||||
export interface App extends Entity {
|
||||
title: string;
|
||||
version: SemVer;
|
||||
description: string;
|
||||
environment: EnvironmentVariable[];
|
||||
}
|
||||
13
apps/loom/domain/src/entities/apps/web-app.ts
Normal file
13
apps/loom/domain/src/entities/apps/web-app.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { App } from "../app.js";
|
||||
|
||||
export const WebFramework = {
|
||||
EXPRESS: "EXPRESS",
|
||||
REACT: "REACT",
|
||||
VUE: "VUE",
|
||||
SVELTE: "SVELTE",
|
||||
} as const;
|
||||
export type WebFramework = (typeof WebFramework)[keyof typeof WebFramework];
|
||||
|
||||
export interface SSRWebApp extends App {
|
||||
framework: WebFramework;
|
||||
}
|
||||
13
apps/loom/domain/src/entities/defaults.ts
Normal file
13
apps/loom/domain/src/entities/defaults.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export const DefaultEnvironmentType = {
|
||||
DEVELOPMENT: "DEVELOPMENT",
|
||||
DEMO: "DEMO",
|
||||
STAGING: "STAGING",
|
||||
PRODUCTION: "PRODUCTION",
|
||||
};
|
||||
export type DefaultEnvironmentType = keyof typeof DefaultEnvironmentType;
|
||||
|
||||
export const DefaultUserType = {
|
||||
ADMIN: "ADMIN",
|
||||
REGULAR: "REGULAR",
|
||||
};
|
||||
export type DefaultUserType = keyof typeof DefaultUserType;
|
||||
12
apps/loom/domain/src/entities/environment.ts
Normal file
12
apps/loom/domain/src/entities/environment.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { ValueSchema } from "./schema.js";
|
||||
|
||||
export interface Environment {
|
||||
name: string;
|
||||
variables: EnvironmentVariable[];
|
||||
}
|
||||
|
||||
export interface EnvironmentVariable extends ValueSchema {
|
||||
name: string;
|
||||
description: string;
|
||||
isSecret: boolean;
|
||||
}
|
||||
0
apps/loom/domain/src/entities/index.ts
Normal file
0
apps/loom/domain/src/entities/index.ts
Normal file
6
apps/loom/domain/src/entities/permission.ts
Normal file
6
apps/loom/domain/src/entities/permission.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Entity } from "@ulthar/fabric-core";
|
||||
|
||||
export interface Permission extends Entity {
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
6
apps/loom/domain/src/entities/project.ts
Normal file
6
apps/loom/domain/src/entities/project.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface Project {
|
||||
name: string;
|
||||
description: string;
|
||||
tags: string[];
|
||||
environmentTypes: string[];
|
||||
}
|
||||
36
apps/loom/domain/src/entities/schema.ts
Normal file
36
apps/loom/domain/src/entities/schema.ts
Normal file
@ -0,0 +1,36 @@
|
||||
export interface ObjectSchema {
|
||||
name: string;
|
||||
description: string;
|
||||
optional: boolean;
|
||||
fields: (ArraySchema | ValueSchema | ObjectSchema)[];
|
||||
}
|
||||
|
||||
export interface ArraySchema {
|
||||
name: string;
|
||||
description: string;
|
||||
type: "ARRAY";
|
||||
itemSchema: ObjectSchema | ValueSchema;
|
||||
}
|
||||
|
||||
export interface ValueSchema {
|
||||
name: string;
|
||||
description: string;
|
||||
optional: boolean;
|
||||
type: ValueType;
|
||||
}
|
||||
|
||||
export const ValueType = {
|
||||
STRING: "STRING",
|
||||
EMAIL: "EMAIL",
|
||||
NUMBER: "NUMBER",
|
||||
BOOLEAN: "BOOLEAN",
|
||||
URL: "URL",
|
||||
} as const;
|
||||
export type ValueType = keyof typeof ValueType;
|
||||
|
||||
export const FieldType = {
|
||||
ARRAY: "ARRAY",
|
||||
OBJECT: "OBJECT",
|
||||
...ValueType,
|
||||
} as const;
|
||||
export type FieldType = keyof typeof FieldType;
|
||||
17
apps/loom/domain/src/entities/use-case.ts
Normal file
17
apps/loom/domain/src/entities/use-case.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { ObjectSchema } from "./schema.js";
|
||||
|
||||
export const UseCaseType = {
|
||||
QUERY: "QUERY",
|
||||
COMMAND: "COMMAND",
|
||||
} as const;
|
||||
export type UseCaseType = (typeof UseCaseType)[keyof typeof UseCaseType];
|
||||
|
||||
export interface UseCase {
|
||||
name: string;
|
||||
type: UseCaseType;
|
||||
description: string;
|
||||
requiredPermissions: string[];
|
||||
optionalPermissions: string[];
|
||||
payloadSchema: ObjectSchema;
|
||||
responseSchema: ObjectSchema;
|
||||
}
|
||||
9
apps/loom/domain/src/entities/user-story.ts
Normal file
9
apps/loom/domain/src/entities/user-story.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { DefaultUserType } from "./defaults.js";
|
||||
import { UseCase } from "./use-case.js";
|
||||
|
||||
export interface UserStory {
|
||||
name: string;
|
||||
description: string;
|
||||
userTypes: DefaultUserType | string;
|
||||
useCases: UseCase[];
|
||||
}
|
||||
5
apps/loom/domain/src/entities/user-type.ts
Normal file
5
apps/loom/domain/src/entities/user-type.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { Entity } from "@ulthar/fabric-core";
|
||||
|
||||
export interface UserType extends Entity {
|
||||
name: string;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
import { UnexpectedError, UseCaseDefinition } from "@ulthar/fabric-core";
|
||||
|
||||
export interface InitProjectRequestModel {
|
||||
title: string;
|
||||
description?: string;
|
||||
}
|
||||
export type InitProjectErrors = UnexpectedError;
|
||||
|
||||
export const initProjectUseCase = {
|
||||
name: "initProject",
|
||||
isAuthRequired: true,
|
||||
useCase: (async () => {
|
||||
return {};
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
}) as any,
|
||||
} as const satisfies UseCaseDefinition<
|
||||
void,
|
||||
InitProjectRequestModel,
|
||||
void,
|
||||
InitProjectErrors
|
||||
>;
|
||||
15
apps/loom/domain/tsconfig.build.json
Normal file
15
apps/loom/domain/tsconfig.build.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false,
|
||||
"outDir": "dist"
|
||||
},
|
||||
"exclude": [
|
||||
"src/**/*.spec.ts",
|
||||
"dist",
|
||||
"node_modules",
|
||||
"coverage",
|
||||
"vitest.config.ts"
|
||||
]
|
||||
}
|
||||
4
apps/loom/domain/tsconfig.json
Normal file
4
apps/loom/domain/tsconfig.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
||||
10
apps/loom/domain/vitest.config.ts
Normal file
10
apps/loom/domain/vitest.config.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
coverage: {
|
||||
exclude: ["**/index.ts"],
|
||||
},
|
||||
passWithNoTests: true,
|
||||
},
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user