Compare commits

...

1 Commits
main ... loom

Author SHA1 Message Date
7766235e54 [loom] Add basic domain models 2024-09-04 19:21:45 -03:00
17 changed files with 201 additions and 0 deletions

3
apps/loom/README.md Normal file
View 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

View 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"
}
}

View 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[];
}

View 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;
}

View 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;

View 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;
}

View File

View File

@ -0,0 +1,6 @@
import { Entity } from "@ulthar/fabric-core";
export interface Permission extends Entity {
name: string;
description: string;
}

View File

@ -0,0 +1,6 @@
export interface Project {
name: string;
description: string;
tags: string[];
environmentTypes: string[];
}

View 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;

View 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;
}

View 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[];
}

View File

@ -0,0 +1,5 @@
import { Entity } from "@ulthar/fabric-core";
export interface UserType extends Entity {
name: string;
}

View File

@ -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
>;

View 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"
]
}

View File

@ -0,0 +1,4 @@
{
"extends": "../../../tsconfig.json",
"exclude": ["dist", "node_modules"]
}

View File

@ -0,0 +1,10 @@
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
coverage: {
exclude: ["**/index.ts"],
},
passWithNoTests: true,
},
});