@forklaunch/core 0.16.0 → 0.17.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/{apiDefinition.types-BYizofKE.d.mts → apiDefinition.types--RSi8f6C.d.mts} +9 -5
- package/lib/{apiDefinition.types-BYizofKE.d.ts → apiDefinition.types--RSi8f6C.d.ts} +9 -5
- package/lib/http/index.d.mts +112 -7
- package/lib/http/index.d.ts +112 -7
- package/lib/http/index.js +787 -647
- package/lib/http/index.js.map +1 -1
- package/lib/http/index.mjs +759 -624
- package/lib/http/index.mjs.map +1 -1
- package/lib/mappers/index.d.mts +14 -4
- package/lib/mappers/index.d.ts +14 -4
- package/lib/mappers/index.js +20 -8
- package/lib/mappers/index.js.map +1 -1
- package/lib/mappers/index.mjs +20 -8
- package/lib/mappers/index.mjs.map +1 -1
- package/lib/ws/index.d.mts +1 -1
- package/lib/ws/index.d.ts +1 -1
- package/package.json +33 -33
package/lib/mappers/index.d.mts
CHANGED
|
@@ -2,13 +2,23 @@ import { Prettify } from '@forklaunch/common';
|
|
|
2
2
|
import { AnySchemaValidator, IdiomaticSchema, Schema } from '@forklaunch/validator';
|
|
3
3
|
import { Constructor } from '@mikro-orm/core';
|
|
4
4
|
|
|
5
|
-
declare function requestMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>(schemaValidator
|
|
6
|
-
|
|
5
|
+
declare function requestMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
6
|
+
schemaValidator: SV;
|
|
7
|
+
schema: DomainSchema;
|
|
8
|
+
entity: Constructor<Entity>;
|
|
9
|
+
mapperDefinition: {
|
|
10
|
+
toEntity: (dto: Schema<DomainSchema, SV>, ...args: AdditionalArgs) => Promise<Entity>;
|
|
11
|
+
};
|
|
7
12
|
}): {
|
|
8
13
|
schema: DomainSchema;
|
|
9
14
|
} & typeof mapperDefinition;
|
|
10
|
-
declare function responseMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>(schemaValidator
|
|
11
|
-
|
|
15
|
+
declare function responseMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
16
|
+
schemaValidator: SV;
|
|
17
|
+
schema: DomainSchema;
|
|
18
|
+
entity: Constructor<Entity>;
|
|
19
|
+
mapperDefinition: {
|
|
20
|
+
toDto: (entity: Entity, ...args: AdditionalArgs) => Promise<Schema<DomainSchema, SV>>;
|
|
21
|
+
};
|
|
12
22
|
}): Prettify<{
|
|
13
23
|
schema: DomainSchema;
|
|
14
24
|
} & typeof mapperDefinition>;
|
package/lib/mappers/index.d.ts
CHANGED
|
@@ -2,13 +2,23 @@ import { Prettify } from '@forklaunch/common';
|
|
|
2
2
|
import { AnySchemaValidator, IdiomaticSchema, Schema } from '@forklaunch/validator';
|
|
3
3
|
import { Constructor } from '@mikro-orm/core';
|
|
4
4
|
|
|
5
|
-
declare function requestMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>(schemaValidator
|
|
6
|
-
|
|
5
|
+
declare function requestMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
6
|
+
schemaValidator: SV;
|
|
7
|
+
schema: DomainSchema;
|
|
8
|
+
entity: Constructor<Entity>;
|
|
9
|
+
mapperDefinition: {
|
|
10
|
+
toEntity: (dto: Schema<DomainSchema, SV>, ...args: AdditionalArgs) => Promise<Entity>;
|
|
11
|
+
};
|
|
7
12
|
}): {
|
|
8
13
|
schema: DomainSchema;
|
|
9
14
|
} & typeof mapperDefinition;
|
|
10
|
-
declare function responseMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>(schemaValidator
|
|
11
|
-
|
|
15
|
+
declare function responseMapper<SV extends AnySchemaValidator, DomainSchema extends IdiomaticSchema<SV>, Entity, AdditionalArgs extends unknown[] = []>({ schemaValidator, schema, entity, mapperDefinition }: {
|
|
16
|
+
schemaValidator: SV;
|
|
17
|
+
schema: DomainSchema;
|
|
18
|
+
entity: Constructor<Entity>;
|
|
19
|
+
mapperDefinition: {
|
|
20
|
+
toDto: (entity: Entity, ...args: AdditionalArgs) => Promise<Schema<DomainSchema, SV>>;
|
|
21
|
+
};
|
|
12
22
|
}): Prettify<{
|
|
13
23
|
schema: DomainSchema;
|
|
14
24
|
} & typeof mapperDefinition>;
|
package/lib/mappers/index.js
CHANGED
|
@@ -28,13 +28,19 @@ module.exports = __toCommonJS(mappers_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/mappers/mapper.ts
|
|
30
30
|
var import_validator = require("@forklaunch/validator");
|
|
31
|
-
function requestMapper(
|
|
31
|
+
function requestMapper({
|
|
32
|
+
schemaValidator,
|
|
33
|
+
schema,
|
|
34
|
+
// eslint-disable-next-line
|
|
35
|
+
entity,
|
|
36
|
+
mapperDefinition
|
|
37
|
+
}) {
|
|
32
38
|
const sv = schemaValidator;
|
|
33
39
|
return {
|
|
34
40
|
...mapperDefinition,
|
|
35
|
-
schema
|
|
41
|
+
schema,
|
|
36
42
|
toEntity: async (dto, ...args) => {
|
|
37
|
-
const parsedSchema = sv.parse(sv.schemify(
|
|
43
|
+
const parsedSchema = sv.parse(sv.schemify(schema), dto);
|
|
38
44
|
if (!parsedSchema.ok) {
|
|
39
45
|
throw new Error((0, import_validator.prettyPrintParseErrors)(parsedSchema.errors, "DTO"));
|
|
40
46
|
}
|
|
@@ -45,14 +51,20 @@ function requestMapper(schemaValidator, domainSchema, _entityConstructor, mapper
|
|
|
45
51
|
}
|
|
46
52
|
};
|
|
47
53
|
}
|
|
48
|
-
function responseMapper(
|
|
54
|
+
function responseMapper({
|
|
55
|
+
schemaValidator,
|
|
56
|
+
schema,
|
|
57
|
+
// eslint-disable-next-line
|
|
58
|
+
entity,
|
|
59
|
+
mapperDefinition
|
|
60
|
+
}) {
|
|
49
61
|
const sv = schemaValidator;
|
|
50
62
|
return {
|
|
51
63
|
...mapperDefinition,
|
|
52
|
-
schema
|
|
53
|
-
toDto: async (
|
|
54
|
-
const domain = await mapperDefinition.toDto(
|
|
55
|
-
const parsedSchema = sv.parse(sv.schemify(
|
|
64
|
+
schema,
|
|
65
|
+
toDto: async (entity2, ...args) => {
|
|
66
|
+
const domain = await mapperDefinition.toDto(entity2, ...args);
|
|
67
|
+
const parsedSchema = sv.parse(sv.schemify(schema), domain);
|
|
56
68
|
if (!parsedSchema.ok) {
|
|
57
69
|
throw new Error((0, import_validator.prettyPrintParseErrors)(parsedSchema.errors, "DTO"));
|
|
58
70
|
}
|
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 { Constructor } 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: SV
|
|
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 { Constructor } 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 // eslint-disable-next-line\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: Constructor<Entity>;\n mapperDefinition: {\n toEntity: (\n dto: Schema<DomainSchema, SV>,\n ...args: AdditionalArgs\n ) => Promise<Entity>;\n };\n}): {\n schema: DomainSchema;\n} & typeof mapperDefinition {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\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 // eslint-disable-next-line\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: Constructor<Entity>;\n mapperDefinition: {\n toDto: (\n entity: Entity,\n ...args: AdditionalArgs\n ) => Promise<Schema<DomainSchema, SV>>;\n };\n}): Prettify<\n {\n schema: DomainSchema;\n } & typeof mapperDefinition\n> {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\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;AAAA,EAEA;AAAA,EACA;AACF,GAY4B;AAC1B,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;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;AAAA,EAEA;AAAA,EACA;AACF,GAcE;AACA,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;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;;;ACtFO,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
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
import {
|
|
3
3
|
prettyPrintParseErrors
|
|
4
4
|
} from "@forklaunch/validator";
|
|
5
|
-
function requestMapper(
|
|
5
|
+
function requestMapper({
|
|
6
|
+
schemaValidator,
|
|
7
|
+
schema,
|
|
8
|
+
// eslint-disable-next-line
|
|
9
|
+
entity,
|
|
10
|
+
mapperDefinition
|
|
11
|
+
}) {
|
|
6
12
|
const sv = schemaValidator;
|
|
7
13
|
return {
|
|
8
14
|
...mapperDefinition,
|
|
9
|
-
schema
|
|
15
|
+
schema,
|
|
10
16
|
toEntity: async (dto, ...args) => {
|
|
11
|
-
const parsedSchema = sv.parse(sv.schemify(
|
|
17
|
+
const parsedSchema = sv.parse(sv.schemify(schema), dto);
|
|
12
18
|
if (!parsedSchema.ok) {
|
|
13
19
|
throw new Error(prettyPrintParseErrors(parsedSchema.errors, "DTO"));
|
|
14
20
|
}
|
|
@@ -19,14 +25,20 @@ function requestMapper(schemaValidator, domainSchema, _entityConstructor, mapper
|
|
|
19
25
|
}
|
|
20
26
|
};
|
|
21
27
|
}
|
|
22
|
-
function responseMapper(
|
|
28
|
+
function responseMapper({
|
|
29
|
+
schemaValidator,
|
|
30
|
+
schema,
|
|
31
|
+
// eslint-disable-next-line
|
|
32
|
+
entity,
|
|
33
|
+
mapperDefinition
|
|
34
|
+
}) {
|
|
23
35
|
const sv = schemaValidator;
|
|
24
36
|
return {
|
|
25
37
|
...mapperDefinition,
|
|
26
|
-
schema
|
|
27
|
-
toDto: async (
|
|
28
|
-
const domain = await mapperDefinition.toDto(
|
|
29
|
-
const parsedSchema = sv.parse(sv.schemify(
|
|
38
|
+
schema,
|
|
39
|
+
toDto: async (entity2, ...args) => {
|
|
40
|
+
const domain = await mapperDefinition.toDto(entity2, ...args);
|
|
41
|
+
const parsedSchema = sv.parse(sv.schemify(schema), domain);
|
|
30
42
|
if (!parsedSchema.ok) {
|
|
31
43
|
throw new Error(prettyPrintParseErrors(parsedSchema.errors, "DTO"));
|
|
32
44
|
}
|
|
@@ -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 { Constructor } 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: SV
|
|
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 { Constructor } 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 // eslint-disable-next-line\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: Constructor<Entity>;\n mapperDefinition: {\n toEntity: (\n dto: Schema<DomainSchema, SV>,\n ...args: AdditionalArgs\n ) => Promise<Entity>;\n };\n}): {\n schema: DomainSchema;\n} & typeof mapperDefinition {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\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 // eslint-disable-next-line\n entity,\n mapperDefinition\n}: {\n schemaValidator: SV;\n schema: DomainSchema;\n entity: Constructor<Entity>;\n mapperDefinition: {\n toDto: (\n entity: Entity,\n ...args: AdditionalArgs\n ) => Promise<Schema<DomainSchema, SV>>;\n };\n}): Prettify<\n {\n schema: DomainSchema;\n } & typeof mapperDefinition\n> {\n const sv = schemaValidator as SchemaValidator;\n return {\n ...mapperDefinition,\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;AAAA,EAEA;AAAA,EACA;AACF,GAY4B;AAC1B,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;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;AAAA,EAEA;AAAA,EACA;AACF,GAcE;AACA,QAAM,KAAK;AACX,SAAO;AAAA,IACL,GAAG;AAAA,IACH;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;;;ACtFO,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/ws/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncAPIObject } from '@asyncapi/parser/esm/spec-types/v3';
|
|
2
2
|
import { AnySchemaValidator, IdiomaticSchema, SchemaValidator } from '@forklaunch/validator';
|
|
3
|
-
import { S as StringOnlyObject } from '../apiDefinition.types
|
|
3
|
+
import { S as StringOnlyObject } from '../apiDefinition.types--RSi8f6C.mjs';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import '@opentelemetry/api';
|
|
6
6
|
import 'jose';
|
package/lib/ws/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncAPIObject } from '@asyncapi/parser/esm/spec-types/v3';
|
|
2
2
|
import { AnySchemaValidator, IdiomaticSchema, SchemaValidator } from '@forklaunch/validator';
|
|
3
|
-
import { S as StringOnlyObject } from '../apiDefinition.types
|
|
3
|
+
import { S as StringOnlyObject } from '../apiDefinition.types--RSi8f6C.js';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import '@opentelemetry/api';
|
|
6
6
|
import 'jose';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.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": {
|
|
@@ -79,54 +79,54 @@
|
|
|
79
79
|
"@asyncapi/parser": "^3.4.0",
|
|
80
80
|
"@forklaunch/fastmcp-fork": "^1.0.5",
|
|
81
81
|
"@forklaunch/opentelemetry-instrumentation-hyper-express": "0.0.5",
|
|
82
|
-
"@mikro-orm/core": "^6.
|
|
83
|
-
"@mikro-orm/mongodb": "^6.
|
|
82
|
+
"@mikro-orm/core": "^6.6.4",
|
|
83
|
+
"@mikro-orm/mongodb": "^6.6.4",
|
|
84
84
|
"@opentelemetry/api": "^1.9.0",
|
|
85
|
-
"@opentelemetry/api-logs": "^0.
|
|
86
|
-
"@opentelemetry/exporter-logs-otlp-http": "^0.
|
|
87
|
-
"@opentelemetry/exporter-metrics-otlp-http": "^0.
|
|
88
|
-
"@opentelemetry/exporter-prometheus": "^0.
|
|
89
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
90
|
-
"@opentelemetry/instrumentation-express": "^0.
|
|
91
|
-
"@opentelemetry/instrumentation-http": "^0.
|
|
92
|
-
"@opentelemetry/resources": "^2.
|
|
93
|
-
"@opentelemetry/sdk-logs": "^0.
|
|
94
|
-
"@opentelemetry/sdk-metrics": "^2.
|
|
95
|
-
"@opentelemetry/sdk-node": "^0.
|
|
96
|
-
"@opentelemetry/sdk-trace-node": "^2.
|
|
97
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
85
|
+
"@opentelemetry/api-logs": "^0.210.0",
|
|
86
|
+
"@opentelemetry/exporter-logs-otlp-http": "^0.210.0",
|
|
87
|
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.210.0",
|
|
88
|
+
"@opentelemetry/exporter-prometheus": "^0.210.0",
|
|
89
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.210.0",
|
|
90
|
+
"@opentelemetry/instrumentation-express": "^0.58.0",
|
|
91
|
+
"@opentelemetry/instrumentation-http": "^0.210.0",
|
|
92
|
+
"@opentelemetry/resources": "^2.4.0",
|
|
93
|
+
"@opentelemetry/sdk-logs": "^0.210.0",
|
|
94
|
+
"@opentelemetry/sdk-metrics": "^2.4.0",
|
|
95
|
+
"@opentelemetry/sdk-node": "^0.210.0",
|
|
96
|
+
"@opentelemetry/sdk-trace-node": "^2.4.0",
|
|
97
|
+
"@opentelemetry/semantic-conventions": "^1.39.0",
|
|
98
98
|
"cors": "^2.8.5",
|
|
99
99
|
"dotenv": "^17.2.3",
|
|
100
|
-
"jose": "6.1.
|
|
100
|
+
"jose": "6.1.3",
|
|
101
101
|
"openapi3-ts": "^4.5.0",
|
|
102
|
-
"pino": "^10.
|
|
102
|
+
"pino": "^10.2.0",
|
|
103
103
|
"pino-http": "^11.0.0",
|
|
104
|
-
"pino-pretty": "^13.1.
|
|
105
|
-
"redis": "^5.
|
|
104
|
+
"pino-pretty": "^13.1.3",
|
|
105
|
+
"redis": "^5.10.0",
|
|
106
106
|
"uuid": "^13.0.0",
|
|
107
|
-
"zod": "^4.
|
|
108
|
-
"@forklaunch/common": "0.6.
|
|
109
|
-
"@forklaunch/validator": "0.10.
|
|
107
|
+
"zod": "^4.3.5",
|
|
108
|
+
"@forklaunch/common": "0.6.24",
|
|
109
|
+
"@forklaunch/validator": "0.10.24"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@eslint/js": "^9.
|
|
113
|
-
"@scalar/express-api-reference": "^0.8.
|
|
112
|
+
"@eslint/js": "^9.39.2",
|
|
113
|
+
"@scalar/express-api-reference": "^0.8.34",
|
|
114
114
|
"@types/cors": "^2.8.19",
|
|
115
115
|
"@types/jest": "^30.0.0",
|
|
116
116
|
"@types/qs": "^6.14.0",
|
|
117
117
|
"@types/uuid": "^11.0.0",
|
|
118
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
119
|
-
"globals": "^
|
|
118
|
+
"@typescript/native-preview": "7.0.0-dev.20260118.1",
|
|
119
|
+
"globals": "^17.0.0",
|
|
120
120
|
"jest": "^30.2.0",
|
|
121
121
|
"jose": "5.10.0",
|
|
122
|
-
"prettier": "^3.
|
|
123
|
-
"testcontainers": "^11.
|
|
124
|
-
"ts-jest": "^29.4.
|
|
122
|
+
"prettier": "^3.8.0",
|
|
123
|
+
"testcontainers": "^11.11.0",
|
|
124
|
+
"ts-jest": "^29.4.6",
|
|
125
125
|
"ts-node": "^10.9.2",
|
|
126
|
-
"tsup": "^8.5.
|
|
127
|
-
"typedoc": "^0.28.
|
|
126
|
+
"tsup": "^8.5.1",
|
|
127
|
+
"typedoc": "^0.28.16",
|
|
128
128
|
"typescript": "^5.9.3",
|
|
129
|
-
"typescript-eslint": "^8.
|
|
129
|
+
"typescript-eslint": "^8.53.0"
|
|
130
130
|
},
|
|
131
131
|
"scripts": {
|
|
132
132
|
"build": "tsgo --noEmit && tsup ./src/cache/index.ts ./src/controllers/index.ts ./src/mappers/index.ts ./src/objectstore/index.ts ./src/persistence/index.ts ./src/http/index.ts ./src/services/index.ts ./src/environment/index.ts ./src/ws/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean --sourcemap",
|