Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -790,3 +790,129 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter architectura ci:publish

## DDD

lint-ddd:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 10
run_install: true

- name: Building workspace dependencies
run: |
pnpm --filter testing-ground ci:build
pnpm --filter ts-predicate ci:build
pnpm --filter toolbox ci:build

- name: Package dependencies installation
run: pnpm install --filter ddd

- name: Lint with ESlint
run: pnpm --filter ddd ci:lint

typescript-syntax-check-ddd:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 10
run_install: true

- name: Building workspace dependencies
run: |
pnpm --filter testing-ground ci:build
pnpm --filter ts-predicate ci:build
pnpm --filter toolbox ci:build

- name: Package dependencies installation
run: pnpm install --filter ddd

- name: Check TypeScript syntax
run: pnpm --filter ddd ci:ts:check

test-ddd:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 10
run_install: true

- uses: actions/setup-node@v4
with:
node-version: "22.x"

- name: Building workspace dependencies
run: |
pnpm --filter testing-ground ci:build
pnpm --filter ts-predicate ci:build
pnpm --filter toolbox ci:build

- name: Package dependencies installation
run: pnpm install --filter ddd

- name: Test with Node Test runner
run: pnpm --filter ddd ci:test:unit

publish-ddd:
if: ${{ github.ref == 'refs/heads/main' && ! failure() && ! cancelled() && github.event_name == 'push' }}
needs:
[
spell-check-global,
lint-ddd,
typescript-syntax-check-ddd,
test-ddd,
]
runs-on: ubuntu-latest
environment: npm
steps:
- name: Check out repository code
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"

- name: PNPM installation
uses: pnpm/action-setup@v4
id: pnpm-install
with:
version: 10
run_install: true

- name: Building workspace dependencies
run: |
pnpm --filter testing-ground ci:build
pnpm --filter ts-predicate ci:build
pnpm --filter toolbox ci:build

- name: Package dependencies installation
run: pnpm install --filter ddd

- name: Package build
run: pnpm --filter ddd ci:build

- name: Publish package
id: package-version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm --filter ddd ci:publish
21 changes: 21 additions & 0 deletions packages/ddd/.c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"src": "./src",
"exclude": [
"mock",
"test"
],
"extension": [
".mts"
],
"reporter": [
"html"
],
"report-dir": "./coverage",
"skip-full": true,
"check-coverage": true,
"all": true,
"statements": 100,
"branches": 100,
"functions": 100,
"lines": 100
}
10 changes: 10 additions & 0 deletions packages/ddd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/node_modules/**
build
temp/logs/*.log
yarn.lock
package-lock.json
nodemon.json
yarn-error.log
.vscode/
**/database/**
coverage/
16 changes: 16 additions & 0 deletions packages/ddd/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extension": [
"mts"
],
"node-option": [
"loader=tsx"
],
"spec": [
"test/**/*.spec.mts"
],
"timeout": 5000,
"parallel": true,
"checkLeaks": true,
"diff": true,
"forbidPending": true
}
21 changes: 21 additions & 0 deletions packages/ddd/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 VitruviusLabs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions packages/ddd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DDD

TODO
3 changes: 3 additions & 0 deletions packages/ddd/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import configurations from "../../eslint.config.mjs";

export default configurations;
52 changes: 52 additions & 0 deletions packages/ddd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@vitruvius-labs/ddd",
"version": "0.1.0",
"description": "",
"author": {
"name": "VitruviusLabs"
},
"contributors": [
"Nicolas \"SmashingQuasar\" Lebacq <contact@vitruvius-labs.com>",
"Benjamin Blum <benjamin.blum.98@gmail.com>"
],
"license": "MIT",
"private": false,
"type": "module",
"files": [
"./build/**/*"
],
"exports": {
".": {
"import": "./build/esm/_index.mjs",
"types": "./build/types/_index.d.mts"
}
},
"scripts": {
"boot": "pnpm run build && ./docker/scripts/boot.sh && docker logs -f vitruvius",
"clean": "rm -rf reports coverage build dist lib .eslintcache",
"compile": "tsc -p tsconfig.build.json",
"build": "pnpm clean && pnpm compile",
"eslint:check": "eslint",
"eslint:fix": "eslint --fix",
"test:unit": "tsx --test **/*.spec.mts",
"test:unit:only": "tsx --test --test-only **/*.spec.mts",
"test:unit:stryker": "pnpm test:unit",
"test:mutation": "stryker run",
"node:coverage": "NODE_V8_COVERAGE=./reports/node-coverage tsx --experimental-test-coverage --test **/*.spec.mts",
"c8:coverage": "c8 --exclude mock --exclude test tsx --test-reporter spec --test **/*.spec.mts",
"ts:check": "tsc -p tsconfig.json --noEmit",
"spell:check": "cspell -c ../../.vscode/cspell.json .",
"ci:lint": "pnpm eslint:check",
"ci:ts:check": "pnpm ts:check",
"ci:spell:check": "pnpm spell:check",
"ci:test:unit": "pnpm test:unit",
"ci:full": "pnpm ci:lint && pnpm ci:ts:check && pnpm ci:spell:check && pnpm ci:test:unit",
"ci:publish": "pnpm publish --access public --no-git-checks",
"ci:publish:dry": "pnpm publish --access public --dry-run --no-git-checks",
"ci:build": "pnpm build"
},
"dependencies": {
"@vitruvius-labs/ts-predicate": "workspace:^",
"@vitruvius-labs/toolbox": "workspace:^"
}
}
2 changes: 2 additions & 0 deletions packages/ddd/src/_index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./base/_index.mjs";
export * from "./blank-record/_index.mjs";
2 changes: 2 additions & 0 deletions packages/ddd/src/base/_index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./auxiliary/_index.mjs";
export * from "./primary/_index.mjs";
4 changes: 4 additions & 0 deletions packages/ddd/src/base/auxiliary/_index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./meta-property/_index.mjs";
export * from "./property-definition/_index.mjs";
export * from "./property/_index.mjs";
export * from "./type-definition/_index.mjs";
3 changes: 3 additions & 0 deletions packages/ddd/src/base/auxiliary/meta-property/_index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type * from "./definition/_index.mjs";
export * from "./base-meta-property.mjs";
export * from "./predefined-meta-property.mjs";
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { BasePropertyDefinition } from "../property-definition/base-property-definition.mjs";
import type { BaseProperty } from "../property/base-property.mjs";
import type { BasePropertyInstantiationInterface } from "../property/definition/interface/base-property-instantiation.interface.mjs";
import type { BaseTypeDefinition } from "../type-definition/base-type-definition.mjs";

abstract class BaseMetaProperty<T, PD extends BasePropertyDefinition<T>, P extends BaseProperty<T, PD> = BaseProperty<T, PD>>
{
public abstract getPropertyDefinition(): Promise<BasePropertyDefinition<T>>;

protected abstract createProperty(parameters: BasePropertyInstantiationInterface<T, PD>): P;

public async createNewProperty(value: T): Promise<P>
{
// @ts-expect-error -- We have to assume this is the correct definition
const definition: PD = await this.getPropertyDefinition();

const property: P = this.createProperty({
definition: definition,
value: value,
existing: false,
});

return property;
}

public async createExistingProperty(value: unknown): Promise<P>
{
// @ts-expect-error -- We have to assume this is the correct definition
const property_definition: PD = await this.getPropertyDefinition();

const type_definition: BaseTypeDefinition<T> = property_definition.getTypeDefinition();

const normalized_value: T = await this.normalize(value, type_definition);

await type_definition.verify(normalized_value);

const property: P = this.createProperty({
definition: property_definition,
value: normalized_value,
existing: true,
});

return property;
}

// eslint-disable-next-line @ts/class-methods-use-this, @ts/require-await
public async normalize(value: unknown, type_definition: BaseTypeDefinition<T>): Promise<T>
{
type_definition.assertType(value);

return value;
}
}

export { BaseMetaProperty };
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type * from "./type/_index.mjs";
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type * from "./base-meta-property.type.mjs";
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { BaseMetaProperty } from "../../base-meta-property.mjs";
import type { BasePropertyType } from "../../../property/definition/type/base-property.type.mjs";
import type { BasePropertyDefinitionType } from "../../../property-definition/definition/type/base-property-definition.type.mjs";

type BaseMetaPropertyType = BaseMetaProperty<unknown, BasePropertyDefinitionType, BasePropertyType>;

export type { BaseMetaPropertyType };
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { BasePropertyDefinition } from "../property-definition/base-property-definition.mjs";
import type { BaseProperty } from "../property/base-property.mjs";
import { BaseMetaProperty } from "./base-meta-property.mjs";

abstract class PredefinedMetaProperty<T, PD extends BasePropertyDefinition<T>, P extends BaseProperty<T, PD> = BaseProperty<T, PD>> extends BaseMetaProperty<T, PD, P>
{
protected abstract getInitialValue(): Promise<T>;

public async createPredefinedProperty(): Promise<P>
{
// @ts-expect-error -- We have to assume this is the correct definition
const definition: PD = await this.getPropertyDefinition();

const property: P = this.createProperty({
definition: definition,
value: await this.getInitialValue(),
existing: false,
});

return property;
}
}

export { PredefinedMetaProperty };
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type * from "./definition/_index.mjs";
export * from "./base-property-definition-instantiation-interface.mjs";
export * from "./base-property-definition.mjs";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { BaseTypeDefinition } from "../type-definition/base-type-definition.mjs";

interface BasePropertyDefinitionInstantiationInterface<T>
{
identifier: string;
typeDefinition: BaseTypeDefinition<T>;
}

export type { BasePropertyDefinitionInstantiationInterface };
Loading
Loading