@forklaunch/core 0.18.15 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/mappers/index.d.mts +5 -3
- package/lib/mappers/index.d.ts +5 -3
- package/lib/mappers/index.js +2 -2
- package/lib/mappers/index.js.map +1 -1
- package/lib/mappers/index.mjs +2 -2
- package/lib/mappers/index.mjs.map +1 -1
- package/lib/persistence/index.d.mts +1 -40
- package/lib/persistence/index.d.ts +1 -40
- package/lib/persistence/index.js +0 -97
- package/lib/persistence/index.js.map +1 -1
- package/lib/persistence/index.mjs +0 -74
- package/lib/persistence/index.mjs.map +1 -1
- package/package.json +7 -7
package/lib/mappers/index.d.mts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { Prettify } from '@forklaunch/common';
|
|
2
2
|
import { AnySchemaValidator, IdiomaticSchema, Schema } from '@forklaunch/validator';
|
|
3
|
-
import {
|
|
3
|
+
import { EntitySchema } from '@mikro-orm/core';
|
|
4
4
|
|
|
5
5
|
declare function requestMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
6
6
|
schemaValidator: SV;
|
|
7
7
|
schema: DomainSchema;
|
|
8
|
-
entity:
|
|
8
|
+
entity: EntitySchema<Entity>;
|
|
9
9
|
mapperDefinition: {
|
|
10
10
|
toEntity: (dto: Schema<DomainSchema, SV>, ...args: AdditionalArgs) => Promise<Entity>;
|
|
11
11
|
};
|
|
12
12
|
}): {
|
|
13
|
+
entity: EntitySchema<Entity>;
|
|
13
14
|
schema: DomainSchema;
|
|
14
15
|
} & typeof mapperDefinition;
|
|
15
16
|
declare function responseMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
16
17
|
schemaValidator: SV;
|
|
17
18
|
schema: DomainSchema;
|
|
18
|
-
entity:
|
|
19
|
+
entity: EntitySchema<Entity>;
|
|
19
20
|
mapperDefinition: {
|
|
20
21
|
toDto: (entity: Entity, ...args: AdditionalArgs) => Promise<Schema<DomainSchema, SV>>;
|
|
21
22
|
};
|
|
22
23
|
}): Prettify<{
|
|
24
|
+
entity: EntitySchema<Entity>;
|
|
23
25
|
schema: DomainSchema;
|
|
24
26
|
} & typeof mapperDefinition>;
|
|
25
27
|
|
package/lib/mappers/index.d.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { Prettify } from '@forklaunch/common';
|
|
2
2
|
import { AnySchemaValidator, IdiomaticSchema, Schema } from '@forklaunch/validator';
|
|
3
|
-
import {
|
|
3
|
+
import { EntitySchema } from '@mikro-orm/core';
|
|
4
4
|
|
|
5
5
|
declare function requestMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
6
6
|
schemaValidator: SV;
|
|
7
7
|
schema: DomainSchema;
|
|
8
|
-
entity:
|
|
8
|
+
entity: EntitySchema<Entity>;
|
|
9
9
|
mapperDefinition: {
|
|
10
10
|
toEntity: (dto: Schema<DomainSchema, SV>, ...args: AdditionalArgs) => Promise<Entity>;
|
|
11
11
|
};
|
|
12
12
|
}): {
|
|
13
|
+
entity: EntitySchema<Entity>;
|
|
13
14
|
schema: DomainSchema;
|
|
14
15
|
} & typeof mapperDefinition;
|
|
15
16
|
declare function responseMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
16
17
|
schemaValidator: SV;
|
|
17
18
|
schema: DomainSchema;
|
|
18
|
-
entity:
|
|
19
|
+
entity: EntitySchema<Entity>;
|
|
19
20
|
mapperDefinition: {
|
|
20
21
|
toDto: (entity: Entity, ...args: AdditionalArgs) => Promise<Schema<DomainSchema, SV>>;
|
|
21
22
|
};
|
|
22
23
|
}): Prettify<{
|
|
24
|
+
entity: EntitySchema<Entity>;
|
|
23
25
|
schema: DomainSchema;
|
|
24
26
|
} & typeof mapperDefinition>;
|
|
25
27
|
|
package/lib/mappers/index.js
CHANGED
|
@@ -31,13 +31,13 @@ var import_validator = require("@forklaunch/validator");
|
|
|
31
31
|
function requestMapper({
|
|
32
32
|
schemaValidator,
|
|
33
33
|
schema,
|
|
34
|
-
// eslint-disable-next-line
|
|
35
34
|
entity,
|
|
36
35
|
mapperDefinition
|
|
37
36
|
}) {
|
|
38
37
|
const sv = schemaValidator;
|
|
39
38
|
return {
|
|
40
39
|
...mapperDefinition,
|
|
40
|
+
entity,
|
|
41
41
|
schema,
|
|
42
42
|
toEntity: async (dto, ...args) => {
|
|
43
43
|
const parsedSchema = sv.parse(sv.schemify(schema), dto);
|
|
@@ -54,13 +54,13 @@ function requestMapper({
|
|
|
54
54
|
function responseMapper({
|
|
55
55
|
schemaValidator,
|
|
56
56
|
schema,
|
|
57
|
-
// eslint-disable-next-line
|
|
58
57
|
entity,
|
|
59
58
|
mapperDefinition
|
|
60
59
|
}) {
|
|
61
60
|
const sv = schemaValidator;
|
|
62
61
|
return {
|
|
63
62
|
...mapperDefinition,
|
|
63
|
+
entity,
|
|
64
64
|
schema,
|
|
65
65
|
toDto: async (entity2, ...args) => {
|
|
66
66
|
const domain = await mapperDefinition.toDto(entity2, ...args);
|
package/lib/mappers/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mappers/index.ts","../../src/mappers/mapper.ts","../../src/mappers/guards/isSchemaResolutionFunction.ts","../../src/mappers/mapServiceSchemas.ts"],"sourcesContent":["export * from './mapper';\nexport * from './mapServiceSchemas';\n","import { Prettify } from '@forklaunch/common';\nimport {\n AnySchemaValidator,\n IdiomaticSchema,\n prettyPrintParseErrors,\n Schema,\n SchemaValidator\n} from '@forklaunch/validator';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/mappers/index.ts","../../src/mappers/mapper.ts","../../src/mappers/guards/isSchemaResolutionFunction.ts","../../src/mappers/mapServiceSchemas.ts"],"sourcesContent":["export * from './mapper';\nexport * from './mapServiceSchemas';\n","import { Prettify } from '@forklaunch/common';\nimport {\n AnySchemaValidator,\n IdiomaticSchema,\n prettyPrintParseErrors,\n Schema,\n SchemaValidator\n} from '@forklaunch/validator';\nimport { EntitySchema } from '@mikro-orm/core';\n\nexport function requestMapper<\n SV extends AnySchemaValidator,\n DomainSchema extends IdiomaticSchema<SV>,\n Entity,\n AdditionalArgs extends unknown[] = []\n>({\n schemaValidator,\n schema,\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: EntitySchema<Entity>;\n mapperDefinition: {\n toEntity: (\n dto: Schema<DomainSchema, SV>,\n ...args: AdditionalArgs\n ) => Promise<Entity>;\n };\n}): {\n entity: EntitySchema<Entity>;\n schema: DomainSchema;\n} & typeof mapperDefinition {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\n entity,\n schema,\n\n toEntity: async (\n dto: Schema<DomainSchema, SV>,\n ...args: AdditionalArgs\n ) => {\n const parsedSchema = sv.parse(sv.schemify(schema), dto);\n if (!parsedSchema.ok) {\n throw new Error(prettyPrintParseErrors(parsedSchema.errors, 'DTO'));\n }\n return mapperDefinition.toEntity(\n dto as Schema<DomainSchema, SV>,\n ...(args as AdditionalArgs)\n );\n }\n };\n}\n\nexport function responseMapper<\n SV extends AnySchemaValidator,\n DomainSchema extends IdiomaticSchema<SV>,\n Entity,\n AdditionalArgs extends unknown[] = []\n>({\n schemaValidator,\n schema,\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: EntitySchema<Entity>;\n mapperDefinition: {\n toDto: (\n entity: Entity,\n ...args: AdditionalArgs\n ) => Promise<Schema<DomainSchema, SV>>;\n };\n}): Prettify<\n {\n entity: EntitySchema<Entity>;\n schema: DomainSchema;\n } & typeof mapperDefinition\n> {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\n entity,\n schema,\n\n toDto: async (entity: Entity, ...args: AdditionalArgs) => {\n const domain = await mapperDefinition.toDto(entity, ...args);\n const parsedSchema = sv.parse(sv.schemify(schema), domain);\n if (!parsedSchema.ok) {\n throw new Error(prettyPrintParseErrors(parsedSchema.errors, 'DTO'));\n }\n return domain;\n }\n };\n}\n","import { SchemaResolutionFunction } from '../types/schemaResolution.types';\n\n/**\n * Type guard to determine if a value is a SchemaResolutionFunction.\n *\n * @template Args - The type of the options object expected by the schema resolution function.\n * @param {unknown} value - The value to check.\n * @returns {value is SchemaResolutionFunction<Args>} True if the value is a function (assumed to be a SchemaResolutionFunction), false otherwise.\n */\nexport function isSchemaResolutionFunction<\n Args extends Record<string, unknown>\n>(value: unknown): value is SchemaResolutionFunction<Args> {\n return typeof value === 'function';\n}\n","import { AnySchemaValidator, IdiomaticSchema } from '@forklaunch/validator';\nimport { isSchemaResolutionFunction } from './guards/isSchemaResolutionFunction';\nimport { SchemaResolutionFunction } from './types/schemaResolution.types';\n\n/**\n * Maps a set of service schema factories or pre-instantiated schemas to their resolved schemas using the provided arguments.\n *\n * This utility allows you to provide an object whose values are either:\n * - Schema factory functions (SchemaResolutionFunction) that accept an options object (Args) and return a schema or schema group.\n * - Already-instantiated schemas (IdiomaticSchema).\n *\n * Each factory function will be called with the provided `args` object, and the result will be included in the returned mapping.\n * If a value is already a schema (not a function), it is returned as-is.\n *\n * @template SV - The schema validator type.\n * @template T - An object whose values are either schema factory functions or instantiated schemas.\n * @template Args - The type of the options object passed to each factory function (e.g., { validator, uuidId, ... }).\n *\n * @param {T} schemas - An object mapping schema names to either factory functions (SchemaResolutionFunction) or instantiated schemas (IdiomaticSchema).\n * @param {Args} args - The options object to be passed to each schema factory function.\n * @returns {{ [K in keyof T]: T[K] extends SchemaResolutionFunction<Args> ? ReturnType<T[K]> : T[K] }} An object mapping each schema name to its resolved schema.\n *\n * @example\n * const schemas = {\n * UserSchemas: (opts) => createUserSchemas(opts),\n * ProductSchemas: (opts) => createProductSchemas(opts),\n * AlreadyInstantiated: someSchemaObject\n * };\n * const mapped = mapServiceSchemas(schemas, { validator: myValidator });\n * // mapped.UserSchemas and mapped.ProductSchemas are instantiated, mapped.AlreadyInstantiated is passed through\n */\nexport function mapServiceSchemas<\n SV extends AnySchemaValidator,\n T extends Record<\n string,\n SchemaResolutionFunction<Args> | IdiomaticSchema<SV>\n >,\n Args extends Record<string, unknown>\n>(\n schemas: T,\n args: Args\n): {\n [K in keyof T]: T[K] extends SchemaResolutionFunction<Args>\n ? ReturnType<T[K]>\n : T[K];\n} {\n return Object.fromEntries(\n Object.entries(schemas).map(([key, value]) => [\n key,\n isSchemaResolutionFunction(value) ? value(args) : value\n ])\n ) as {\n [K in keyof T]: T[K] extends SchemaResolutionFunction<Args>\n ? ReturnType<T[K]>\n : T[K];\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,uBAMO;AAGA,SAAS,cAKd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAa4B;AAC1B,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IAEA,UAAU,OACR,QACG,SACA;AACH,YAAM,eAAe,GAAG,MAAM,GAAG,SAAS,MAAM,GAAG,GAAG;AACtD,UAAI,CAAC,aAAa,IAAI;AACpB,cAAM,IAAI,UAAM,yCAAuB,aAAa,QAAQ,KAAK,CAAC;AAAA,MACpE;AACA,aAAO,iBAAiB;AAAA,QACtB;AAAA,QACA,GAAI;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,eAKd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAeE;AACA,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IAEA,OAAO,OAAOA,YAAmB,SAAyB;AACxD,YAAM,SAAS,MAAM,iBAAiB,MAAMA,SAAQ,GAAG,IAAI;AAC3D,YAAM,eAAe,GAAG,MAAM,GAAG,SAAS,MAAM,GAAG,MAAM;AACzD,UAAI,CAAC,aAAa,IAAI;AACpB,cAAM,IAAI,UAAM,yCAAuB,aAAa,QAAQ,KAAK,CAAC;AAAA,MACpE;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;ACxFO,SAAS,2BAEd,OAAyD;AACzD,SAAO,OAAO,UAAU;AAC1B;;;ACkBO,SAAS,kBAQd,SACA,MAKA;AACA,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,MAC5C;AAAA,MACA,2BAA2B,KAAK,IAAI,MAAM,IAAI,IAAI;AAAA,IACpD,CAAC;AAAA,EACH;AAKF;","names":["entity"]}
|
package/lib/mappers/index.mjs
CHANGED
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
function requestMapper({
|
|
6
6
|
schemaValidator,
|
|
7
7
|
schema,
|
|
8
|
-
// eslint-disable-next-line
|
|
9
8
|
entity,
|
|
10
9
|
mapperDefinition
|
|
11
10
|
}) {
|
|
12
11
|
const sv = schemaValidator;
|
|
13
12
|
return {
|
|
14
13
|
...mapperDefinition,
|
|
14
|
+
entity,
|
|
15
15
|
schema,
|
|
16
16
|
toEntity: async (dto, ...args) => {
|
|
17
17
|
const parsedSchema = sv.parse(sv.schemify(schema), dto);
|
|
@@ -28,13 +28,13 @@ function requestMapper({
|
|
|
28
28
|
function responseMapper({
|
|
29
29
|
schemaValidator,
|
|
30
30
|
schema,
|
|
31
|
-
// eslint-disable-next-line
|
|
32
31
|
entity,
|
|
33
32
|
mapperDefinition
|
|
34
33
|
}) {
|
|
35
34
|
const sv = schemaValidator;
|
|
36
35
|
return {
|
|
37
36
|
...mapperDefinition,
|
|
37
|
+
entity,
|
|
38
38
|
schema,
|
|
39
39
|
toDto: async (entity2, ...args) => {
|
|
40
40
|
const domain = await mapperDefinition.toDto(entity2, ...args);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mappers/mapper.ts","../../src/mappers/guards/isSchemaResolutionFunction.ts","../../src/mappers/mapServiceSchemas.ts"],"sourcesContent":["import { Prettify } from '@forklaunch/common';\nimport {\n AnySchemaValidator,\n IdiomaticSchema,\n prettyPrintParseErrors,\n Schema,\n SchemaValidator\n} from '@forklaunch/validator';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/mappers/mapper.ts","../../src/mappers/guards/isSchemaResolutionFunction.ts","../../src/mappers/mapServiceSchemas.ts"],"sourcesContent":["import { Prettify } from '@forklaunch/common';\nimport {\n AnySchemaValidator,\n IdiomaticSchema,\n prettyPrintParseErrors,\n Schema,\n SchemaValidator\n} from '@forklaunch/validator';\nimport { EntitySchema } from '@mikro-orm/core';\n\nexport function requestMapper<\n SV extends AnySchemaValidator,\n DomainSchema extends IdiomaticSchema<SV>,\n Entity,\n AdditionalArgs extends unknown[] = []\n>({\n schemaValidator,\n schema,\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: EntitySchema<Entity>;\n mapperDefinition: {\n toEntity: (\n dto: Schema<DomainSchema, SV>,\n ...args: AdditionalArgs\n ) => Promise<Entity>;\n };\n}): {\n entity: EntitySchema<Entity>;\n schema: DomainSchema;\n} & typeof mapperDefinition {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\n entity,\n schema,\n\n toEntity: async (\n dto: Schema<DomainSchema, SV>,\n ...args: AdditionalArgs\n ) => {\n const parsedSchema = sv.parse(sv.schemify(schema), dto);\n if (!parsedSchema.ok) {\n throw new Error(prettyPrintParseErrors(parsedSchema.errors, 'DTO'));\n }\n return mapperDefinition.toEntity(\n dto as Schema<DomainSchema, SV>,\n ...(args as AdditionalArgs)\n );\n }\n };\n}\n\nexport function responseMapper<\n SV extends AnySchemaValidator,\n DomainSchema extends IdiomaticSchema<SV>,\n Entity,\n AdditionalArgs extends unknown[] = []\n>({\n schemaValidator,\n schema,\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: EntitySchema<Entity>;\n mapperDefinition: {\n toDto: (\n entity: Entity,\n ...args: AdditionalArgs\n ) => Promise<Schema<DomainSchema, SV>>;\n };\n}): Prettify<\n {\n entity: EntitySchema<Entity>;\n schema: DomainSchema;\n } & typeof mapperDefinition\n> {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\n entity,\n schema,\n\n toDto: async (entity: Entity, ...args: AdditionalArgs) => {\n const domain = await mapperDefinition.toDto(entity, ...args);\n const parsedSchema = sv.parse(sv.schemify(schema), domain);\n if (!parsedSchema.ok) {\n throw new Error(prettyPrintParseErrors(parsedSchema.errors, 'DTO'));\n }\n return domain;\n }\n };\n}\n","import { SchemaResolutionFunction } from '../types/schemaResolution.types';\n\n/**\n * Type guard to determine if a value is a SchemaResolutionFunction.\n *\n * @template Args - The type of the options object expected by the schema resolution function.\n * @param {unknown} value - The value to check.\n * @returns {value is SchemaResolutionFunction<Args>} True if the value is a function (assumed to be a SchemaResolutionFunction), false otherwise.\n */\nexport function isSchemaResolutionFunction<\n Args extends Record<string, unknown>\n>(value: unknown): value is SchemaResolutionFunction<Args> {\n return typeof value === 'function';\n}\n","import { AnySchemaValidator, IdiomaticSchema } from '@forklaunch/validator';\nimport { isSchemaResolutionFunction } from './guards/isSchemaResolutionFunction';\nimport { SchemaResolutionFunction } from './types/schemaResolution.types';\n\n/**\n * Maps a set of service schema factories or pre-instantiated schemas to their resolved schemas using the provided arguments.\n *\n * This utility allows you to provide an object whose values are either:\n * - Schema factory functions (SchemaResolutionFunction) that accept an options object (Args) and return a schema or schema group.\n * - Already-instantiated schemas (IdiomaticSchema).\n *\n * Each factory function will be called with the provided `args` object, and the result will be included in the returned mapping.\n * If a value is already a schema (not a function), it is returned as-is.\n *\n * @template SV - The schema validator type.\n * @template T - An object whose values are either schema factory functions or instantiated schemas.\n * @template Args - The type of the options object passed to each factory function (e.g., { validator, uuidId, ... }).\n *\n * @param {T} schemas - An object mapping schema names to either factory functions (SchemaResolutionFunction) or instantiated schemas (IdiomaticSchema).\n * @param {Args} args - The options object to be passed to each schema factory function.\n * @returns {{ [K in keyof T]: T[K] extends SchemaResolutionFunction<Args> ? ReturnType<T[K]> : T[K] }} An object mapping each schema name to its resolved schema.\n *\n * @example\n * const schemas = {\n * UserSchemas: (opts) => createUserSchemas(opts),\n * ProductSchemas: (opts) => createProductSchemas(opts),\n * AlreadyInstantiated: someSchemaObject\n * };\n * const mapped = mapServiceSchemas(schemas, { validator: myValidator });\n * // mapped.UserSchemas and mapped.ProductSchemas are instantiated, mapped.AlreadyInstantiated is passed through\n */\nexport function mapServiceSchemas<\n SV extends AnySchemaValidator,\n T extends Record<\n string,\n SchemaResolutionFunction<Args> | IdiomaticSchema<SV>\n >,\n Args extends Record<string, unknown>\n>(\n schemas: T,\n args: Args\n): {\n [K in keyof T]: T[K] extends SchemaResolutionFunction<Args>\n ? ReturnType<T[K]>\n : T[K];\n} {\n return Object.fromEntries(\n Object.entries(schemas).map(([key, value]) => [\n key,\n isSchemaResolutionFunction(value) ? value(args) : value\n ])\n ) as {\n [K in keyof T]: T[K] extends SchemaResolutionFunction<Args>\n ? ReturnType<T[K]>\n : T[K];\n };\n}\n"],"mappings":";AACA;AAAA,EAGE;AAAA,OAGK;AAGA,SAAS,cAKd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAa4B;AAC1B,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IAEA,UAAU,OACR,QACG,SACA;AACH,YAAM,eAAe,GAAG,MAAM,GAAG,SAAS,MAAM,GAAG,GAAG;AACtD,UAAI,CAAC,aAAa,IAAI;AACpB,cAAM,IAAI,MAAM,uBAAuB,aAAa,QAAQ,KAAK,CAAC;AAAA,MACpE;AACA,aAAO,iBAAiB;AAAA,QACtB;AAAA,QACA,GAAI;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,eAKd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAeE;AACA,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IAEA,OAAO,OAAOA,YAAmB,SAAyB;AACxD,YAAM,SAAS,MAAM,iBAAiB,MAAMA,SAAQ,GAAG,IAAI;AAC3D,YAAM,eAAe,GAAG,MAAM,GAAG,SAAS,MAAM,GAAG,MAAM;AACzD,UAAI,CAAC,aAAa,IAAI;AACpB,cAAM,IAAI,MAAM,uBAAuB,aAAa,QAAQ,KAAK,CAAC;AAAA,MACpE;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;;;ACxFO,SAAS,2BAEd,OAAyD;AACzD,SAAO,OAAO,UAAU;AAC1B;;;ACkBO,SAAS,kBAQd,SACA,MAKA;AACA,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,MAC5C;AAAA,MACA,2BAA2B,KAAK,IAAI,MAAM,IAAI,IAAI;AAAA,IACpD,CAAC;AAAA,EACH;AAKF;","names":["entity"]}
|
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
import { BaseEntity as BaseEntity$1, Constructor, RequiredEntityData, EntityManager, EntityData, EntityDTO } from '@mikro-orm/core';
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
* BaseEntity class extending MikroORM's BaseEntity to provide
|
|
5
|
-
* convenience static methods for entity creation, updating, and reading.
|
|
6
|
-
*/
|
|
7
|
-
declare class BaseEntity extends BaseEntity$1 {
|
|
8
|
-
/**
|
|
9
|
-
* Create a new entity instance with the given data.
|
|
10
|
-
*
|
|
11
|
-
* @template T - Entity type extending BaseEntity
|
|
12
|
-
* @param this - The constructor of the entity
|
|
13
|
-
* @param data - Data required to create the entity
|
|
14
|
-
* @param em - Optional MikroORM EntityManager. If passed, this will call em.create()
|
|
15
|
-
* @returns A promise resolving to the created entity
|
|
16
|
-
*/
|
|
17
|
-
static create<T extends BaseEntity>(this: Constructor<T>, data: RequiredEntityData<T>, em?: EntityManager, ...constructorArgs: ConstructorParameters<Constructor<T>>): Promise<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Update an existing entity instance with the given data.
|
|
20
|
-
*
|
|
21
|
-
* @template T - Entity type extending BaseEntity
|
|
22
|
-
* @param this - The constructor of the entity
|
|
23
|
-
* @param data - Partial data to update the entity. Must include 'id' field to identify the entity.
|
|
24
|
-
* @param em - Optional MikroORM EntityManager. If passed, fetches existing entity and applies partial update
|
|
25
|
-
* @returns A promise resolving to the updated entity
|
|
26
|
-
* @throws Error if entity with given id is not found (when em is provided)
|
|
27
|
-
*/
|
|
28
|
-
static update<T extends BaseEntity>(this: Constructor<T>, data: EntityData<T> & {
|
|
29
|
-
id: unknown;
|
|
30
|
-
}, em?: EntityManager, ...constructorArgs: ConstructorParameters<Constructor<T>>): Promise<T>;
|
|
31
|
-
/**
|
|
32
|
-
* Reads the entity, initializing it if necessary, and returns its DTO representation.
|
|
33
|
-
*
|
|
34
|
-
* @param em - Optional MikroORM EntityManager for initialization. If passed, entity will synchronize with database
|
|
35
|
-
* @returns A promise resolving to the entity's DTO (plain object representation)
|
|
36
|
-
* @throws Error if the entity is not initialized and no EntityManager is provided
|
|
37
|
-
*/
|
|
38
|
-
read(em?: EntityManager): Promise<EntityDTO<this>>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { BaseEntity };
|
|
2
|
+
export { }
|
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
import { BaseEntity as BaseEntity$1, Constructor, RequiredEntityData, EntityManager, EntityData, EntityDTO } from '@mikro-orm/core';
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
* BaseEntity class extending MikroORM's BaseEntity to provide
|
|
5
|
-
* convenience static methods for entity creation, updating, and reading.
|
|
6
|
-
*/
|
|
7
|
-
declare class BaseEntity extends BaseEntity$1 {
|
|
8
|
-
/**
|
|
9
|
-
* Create a new entity instance with the given data.
|
|
10
|
-
*
|
|
11
|
-
* @template T - Entity type extending BaseEntity
|
|
12
|
-
* @param this - The constructor of the entity
|
|
13
|
-
* @param data - Data required to create the entity
|
|
14
|
-
* @param em - Optional MikroORM EntityManager. If passed, this will call em.create()
|
|
15
|
-
* @returns A promise resolving to the created entity
|
|
16
|
-
*/
|
|
17
|
-
static create<T extends BaseEntity>(this: Constructor<T>, data: RequiredEntityData<T>, em?: EntityManager, ...constructorArgs: ConstructorParameters<Constructor<T>>): Promise<T>;
|
|
18
|
-
/**
|
|
19
|
-
* Update an existing entity instance with the given data.
|
|
20
|
-
*
|
|
21
|
-
* @template T - Entity type extending BaseEntity
|
|
22
|
-
* @param this - The constructor of the entity
|
|
23
|
-
* @param data - Partial data to update the entity. Must include 'id' field to identify the entity.
|
|
24
|
-
* @param em - Optional MikroORM EntityManager. If passed, fetches existing entity and applies partial update
|
|
25
|
-
* @returns A promise resolving to the updated entity
|
|
26
|
-
* @throws Error if entity with given id is not found (when em is provided)
|
|
27
|
-
*/
|
|
28
|
-
static update<T extends BaseEntity>(this: Constructor<T>, data: EntityData<T> & {
|
|
29
|
-
id: unknown;
|
|
30
|
-
}, em?: EntityManager, ...constructorArgs: ConstructorParameters<Constructor<T>>): Promise<T>;
|
|
31
|
-
/**
|
|
32
|
-
* Reads the entity, initializing it if necessary, and returns its DTO representation.
|
|
33
|
-
*
|
|
34
|
-
* @param em - Optional MikroORM EntityManager for initialization. If passed, entity will synchronize with database
|
|
35
|
-
* @returns A promise resolving to the entity's DTO (plain object representation)
|
|
36
|
-
* @throws Error if the entity is not initialized and no EntityManager is provided
|
|
37
|
-
*/
|
|
38
|
-
read(em?: EntityManager): Promise<EntityDTO<this>>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { BaseEntity };
|
|
2
|
+
export { }
|
package/lib/persistence/index.js
CHANGED
|
@@ -1,99 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/persistence/index.ts
|
|
21
|
-
var persistence_exports = {};
|
|
22
|
-
__export(persistence_exports, {
|
|
23
|
-
BaseEntity: () => BaseEntity
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(persistence_exports);
|
|
26
|
-
|
|
27
|
-
// src/persistence/base.entity.ts
|
|
28
|
-
var import_core = require("@mikro-orm/core");
|
|
29
|
-
var BaseEntity = class extends import_core.BaseEntity {
|
|
30
|
-
/**
|
|
31
|
-
* Create a new entity instance with the given data.
|
|
32
|
-
*
|
|
33
|
-
* @template T - Entity type extending BaseEntity
|
|
34
|
-
* @param this - The constructor of the entity
|
|
35
|
-
* @param data - Data required to create the entity
|
|
36
|
-
* @param em - Optional MikroORM EntityManager. If passed, this will call em.create()
|
|
37
|
-
* @returns A promise resolving to the created entity
|
|
38
|
-
*/
|
|
39
|
-
static async create(data, em, ...constructorArgs) {
|
|
40
|
-
const instance = new this(...constructorArgs);
|
|
41
|
-
if (em) {
|
|
42
|
-
return em.create(this, data);
|
|
43
|
-
} else {
|
|
44
|
-
Object.assign(instance, {
|
|
45
|
-
...data,
|
|
46
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
47
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
return instance;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Update an existing entity instance with the given data.
|
|
54
|
-
*
|
|
55
|
-
* @template T - Entity type extending BaseEntity
|
|
56
|
-
* @param this - The constructor of the entity
|
|
57
|
-
* @param data - Partial data to update the entity. Must include 'id' field to identify the entity.
|
|
58
|
-
* @param em - Optional MikroORM EntityManager. If passed, fetches existing entity and applies partial update
|
|
59
|
-
* @returns A promise resolving to the updated entity
|
|
60
|
-
* @throws Error if entity with given id is not found (when em is provided)
|
|
61
|
-
*/
|
|
62
|
-
static async update(data, em, ...constructorArgs) {
|
|
63
|
-
const instance = new this(...constructorArgs);
|
|
64
|
-
if (em) {
|
|
65
|
-
const existingEntity = await em.findOneOrFail(this, { id: data.id });
|
|
66
|
-
const { id, ...updateData } = data;
|
|
67
|
-
void id;
|
|
68
|
-
em.assign(existingEntity, {
|
|
69
|
-
...updateData,
|
|
70
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
71
|
-
});
|
|
72
|
-
return existingEntity;
|
|
73
|
-
} else {
|
|
74
|
-
Object.assign(instance, {
|
|
75
|
-
...data,
|
|
76
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return instance;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Reads the entity, initializing it if necessary, and returns its DTO representation.
|
|
83
|
-
*
|
|
84
|
-
* @param em - Optional MikroORM EntityManager for initialization. If passed, entity will synchronize with database
|
|
85
|
-
* @returns A promise resolving to the entity's DTO (plain object representation)
|
|
86
|
-
* @throws Error if the entity is not initialized and no EntityManager is provided
|
|
87
|
-
*/
|
|
88
|
-
async read(em) {
|
|
89
|
-
if (em && !this.isInitialized()) {
|
|
90
|
-
await this.init({ em });
|
|
91
|
-
}
|
|
92
|
-
return (0, import_core.wrap)(this).toPOJO();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
-
0 && (module.exports = {
|
|
97
|
-
BaseEntity
|
|
98
|
-
});
|
|
99
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,75 +1 @@
|
|
|
1
|
-
// src/persistence/base.entity.ts
|
|
2
|
-
import {
|
|
3
|
-
BaseEntity as MikroORMBaseEntity,
|
|
4
|
-
wrap
|
|
5
|
-
} from "@mikro-orm/core";
|
|
6
|
-
var BaseEntity = class extends MikroORMBaseEntity {
|
|
7
|
-
/**
|
|
8
|
-
* Create a new entity instance with the given data.
|
|
9
|
-
*
|
|
10
|
-
* @template T - Entity type extending BaseEntity
|
|
11
|
-
* @param this - The constructor of the entity
|
|
12
|
-
* @param data - Data required to create the entity
|
|
13
|
-
* @param em - Optional MikroORM EntityManager. If passed, this will call em.create()
|
|
14
|
-
* @returns A promise resolving to the created entity
|
|
15
|
-
*/
|
|
16
|
-
static async create(data, em, ...constructorArgs) {
|
|
17
|
-
const instance = new this(...constructorArgs);
|
|
18
|
-
if (em) {
|
|
19
|
-
return em.create(this, data);
|
|
20
|
-
} else {
|
|
21
|
-
Object.assign(instance, {
|
|
22
|
-
...data,
|
|
23
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
24
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return instance;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Update an existing entity instance with the given data.
|
|
31
|
-
*
|
|
32
|
-
* @template T - Entity type extending BaseEntity
|
|
33
|
-
* @param this - The constructor of the entity
|
|
34
|
-
* @param data - Partial data to update the entity. Must include 'id' field to identify the entity.
|
|
35
|
-
* @param em - Optional MikroORM EntityManager. If passed, fetches existing entity and applies partial update
|
|
36
|
-
* @returns A promise resolving to the updated entity
|
|
37
|
-
* @throws Error if entity with given id is not found (when em is provided)
|
|
38
|
-
*/
|
|
39
|
-
static async update(data, em, ...constructorArgs) {
|
|
40
|
-
const instance = new this(...constructorArgs);
|
|
41
|
-
if (em) {
|
|
42
|
-
const existingEntity = await em.findOneOrFail(this, { id: data.id });
|
|
43
|
-
const { id, ...updateData } = data;
|
|
44
|
-
void id;
|
|
45
|
-
em.assign(existingEntity, {
|
|
46
|
-
...updateData,
|
|
47
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
48
|
-
});
|
|
49
|
-
return existingEntity;
|
|
50
|
-
} else {
|
|
51
|
-
Object.assign(instance, {
|
|
52
|
-
...data,
|
|
53
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return instance;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Reads the entity, initializing it if necessary, and returns its DTO representation.
|
|
60
|
-
*
|
|
61
|
-
* @param em - Optional MikroORM EntityManager for initialization. If passed, entity will synchronize with database
|
|
62
|
-
* @returns A promise resolving to the entity's DTO (plain object representation)
|
|
63
|
-
* @throws Error if the entity is not initialized and no EntityManager is provided
|
|
64
|
-
*/
|
|
65
|
-
async read(em) {
|
|
66
|
-
if (em && !this.isInitialized()) {
|
|
67
|
-
await this.init({ em });
|
|
68
|
-
}
|
|
69
|
-
return wrap(this).toPOJO();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
export {
|
|
73
|
-
BaseEntity
|
|
74
|
-
};
|
|
75
1
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "forklaunch-js core package. Contains useful building blocks.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@asyncapi/parser": "^3.6.0",
|
|
80
80
|
"@forklaunch/opentelemetry-instrumentation-hyper-express": "0.0.5",
|
|
81
|
-
"@mikro-orm/core": "
|
|
82
|
-
"@mikro-orm/mongodb": "
|
|
81
|
+
"@mikro-orm/core": "7.0.2",
|
|
82
|
+
"@mikro-orm/mongodb": "7.0.2",
|
|
83
83
|
"@opentelemetry/api": "^1.9.0",
|
|
84
84
|
"@opentelemetry/api-logs": "^0.213.0",
|
|
85
85
|
"@opentelemetry/exporter-logs-otlp-http": "^0.213.0",
|
|
@@ -105,17 +105,17 @@
|
|
|
105
105
|
"redis": "^5.11.0",
|
|
106
106
|
"uuid": "^13.0.0",
|
|
107
107
|
"zod": "^4.3.6",
|
|
108
|
-
"@forklaunch/
|
|
109
|
-
"@forklaunch/
|
|
108
|
+
"@forklaunch/common": "0.7.0",
|
|
109
|
+
"@forklaunch/validator": "0.11.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@eslint/js": "^10.0.1",
|
|
113
|
-
"@scalar/express-api-reference": "^0.9.
|
|
113
|
+
"@scalar/express-api-reference": "^0.9.3",
|
|
114
114
|
"@types/cors": "^2.8.19",
|
|
115
115
|
"@types/jest": "^30.0.0",
|
|
116
116
|
"@types/qs": "^6.15.0",
|
|
117
117
|
"@types/uuid": "^11.0.0",
|
|
118
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
118
|
+
"@typescript/native-preview": "7.0.0-dev.20260314.1",
|
|
119
119
|
"globals": "^17.4.0",
|
|
120
120
|
"jest": "^30.3.0",
|
|
121
121
|
"jose": "6.1.3",
|