Skip to content

Commit

Permalink
feat(refs): support direct declarations of Refs
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed Dec 2, 2024
1 parent 4cdcb6f commit 7c1ba72
Show file tree
Hide file tree
Showing 31 changed files with 1,220 additions and 140 deletions.
164 changes: 96 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
"postinstall": "[ -d .git ] && npx husky install || exit 0"
},
"dependencies": {
"@ehmpathy/error-fns": "1.3.1",
"@ehmpathy/error-fns": "1.3.7",
"@oclif/core": "3.26.6",
"@oclif/plugin-help": "6.0.22",
"chalk": "2.4.2",
"change-case": "4.1.1",
"domain-objects": "0.22.1",
"domain-objects-metadata": "0.7.4",
"domain-objects-metadata": "0.7.5",
"fast-glob": "3.2.2",
"joi": "17.4.0",
"lodash.omit": "4.5.0",
Expand Down
12 changes: 12 additions & 0 deletions src/domain/objects/SqlSchemaReferenceMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import { DomainObjectReferenceMetadata } from 'domain-objects-metadata';
import Joi from 'joi';

export enum SqlSchemaReferenceMethod {
/**
* .what = when a domain literal is directly nested in another domain object
*/
DIRECT_BY_NESTING = 'DIRECT_BY_NESTING',

/**
* .what = when a domain object is explicitly referenced, via Ref<>, in another domain object
*/
DIRECT_BY_DECLARATION = 'DIRECT_BY_DECLARATION',

/**
* .what = when a domain object is implicitly referenced, via uuid, in another domain object
*/
IMPLICIT_BY_UUID = 'IMPLICIT_BY_UUID',
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { DomainEntity, Ref } from 'domain-objects';
import { Carriage } from './Carriage';

/**
* .what = cargo which has been allocated to a carriage at a given point in time
*/
export interface CarriageCargo {
id?: number;
uuid?: string;

/**
* the itinerary during which it is allocated
*/
itineraryUuid: string; // todo: ref to an itinerary once we declare it

/**
* the carriage it has been allocated to
*/
carriageRef: Ref<typeof Carriage>;

/**
* the slot that it has been allocated to on the carriage
*/
slot: number;

/**
* the cargo that has been allocated
*/
cargoExid: null | string;
}
export class CarriageCargo extends DomainEntity<CarriageCargo> implements CarriageCargo {
public static primary = ['uuid'] as const;
public static unique = ['itineraryUuid', 'carriageRef', 'slot'] as const;
public static updatable = ['cargoExid'];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './AsyncTaskPredictStationCongestion'
export * from './CarriageCargo';
export * from './Carriage';
export * from './Certificate';
export * from './Engineer';
Expand Down
Loading

0 comments on commit 7c1ba72

Please sign in to comment.