@forklaunch/internal 0.0.3 → 0.0.5
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/index.d.mts +12 -13
- package/lib/index.d.ts +12 -13
- package/lib/index.js +4 -4
- package/lib/index.mjs +3 -3
- package/package.json +3 -3
package/lib/index.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import { AnySchemaValidator, IdiomaticSchema, Schema, UnboxedObjectSchema } from
|
|
|
2
2
|
import { TypeboxSchemaValidator } from '@forklaunch/validator/typebox';
|
|
3
3
|
import { ZodSchemaValidator } from '@forklaunch/validator/zod';
|
|
4
4
|
import { InstanceTypeRecord } from '@forklaunch/common';
|
|
5
|
-
import { EntityManager } from '@mikro-orm/core';
|
|
6
5
|
|
|
7
6
|
declare class IdentityRequestMapper<T, SchemaValidator extends AnySchemaValidator> {
|
|
8
7
|
dto: T;
|
|
@@ -41,7 +40,7 @@ declare function serviceSchemaResolver<Options extends Record<string, unknown>,
|
|
|
41
40
|
validator: SchemaValidator;
|
|
42
41
|
}) => SchemasByValidator<SchemaValidator, (options: Options) => TypeBoxSchemas, (options: Options) => ZodSchemas>;
|
|
43
42
|
|
|
44
|
-
type
|
|
43
|
+
type InternalMapper<Mapper extends Record<string, {
|
|
45
44
|
dto: unknown;
|
|
46
45
|
_Entity: unknown;
|
|
47
46
|
serializeEntityToDto: unknown;
|
|
@@ -50,22 +49,22 @@ type InternalDtoMapper<DtoMapper extends Record<string, {
|
|
|
50
49
|
_Entity: unknown;
|
|
51
50
|
deserializeDtoToEntity: unknown;
|
|
52
51
|
}>> = {
|
|
53
|
-
[K in keyof
|
|
52
|
+
[K in keyof Mapper]: Mapper[K] extends {
|
|
54
53
|
dto: unknown;
|
|
55
54
|
_Entity: unknown;
|
|
56
55
|
serializeEntityToDto: unknown;
|
|
57
56
|
} ? {
|
|
58
|
-
serializeEntityToDto:
|
|
59
|
-
} :
|
|
57
|
+
serializeEntityToDto: Mapper[K]['serializeEntityToDto'];
|
|
58
|
+
} : Mapper[K] extends {
|
|
60
59
|
dto: unknown;
|
|
61
60
|
_Entity: unknown;
|
|
62
61
|
deserializeDtoToEntity: unknown;
|
|
63
62
|
} ? {
|
|
64
|
-
deserializeDtoToEntity:
|
|
63
|
+
deserializeDtoToEntity: Mapper[K]['deserializeDtoToEntity'];
|
|
65
64
|
} : never;
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
declare function
|
|
67
|
+
declare function transformIntoInternalMapper<SchemaValidator extends AnySchemaValidator, Mapper extends Record<string, new (schemaValidator: SchemaValidator) => {
|
|
69
68
|
dto: unknown;
|
|
70
69
|
_Entity: unknown;
|
|
71
70
|
serializeEntityToDto: unknown;
|
|
@@ -73,15 +72,15 @@ declare function transformIntoInternalDtoMapper<SchemaValidator extends AnySchem
|
|
|
73
72
|
dto: unknown;
|
|
74
73
|
_Entity: unknown;
|
|
75
74
|
deserializeDtoToEntity: unknown;
|
|
76
|
-
}>>(mappers:
|
|
75
|
+
}>>(mappers: Mapper, schemaValidator: SchemaValidator): InternalMapper<InstanceTypeRecord<Mapper>>;
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
78
|
* Type representing a schema validator object for an entity mapper.
|
|
80
79
|
*
|
|
81
80
|
* @template SV - A type that extends AnySchemaValidator.
|
|
82
|
-
* @typedef {SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>}
|
|
81
|
+
* @typedef {SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>} MapperSchemaValidatorObject
|
|
83
82
|
*/
|
|
84
|
-
type
|
|
83
|
+
type MapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>;
|
|
85
84
|
/**
|
|
86
85
|
* Type representing a response DTO mapper for an entity mapper.
|
|
87
86
|
*
|
|
@@ -89,7 +88,7 @@ type DtoMapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidS
|
|
|
89
88
|
* @template Dto - The type of the DTO object.
|
|
90
89
|
* @template Entity - The type of the entity object.
|
|
91
90
|
*/
|
|
92
|
-
type
|
|
91
|
+
type ResponseMapperConstructor<SchemaValidator extends AnySchemaValidator, Dto, Entity, SerializeEntityToDto extends (schemaValidator: SchemaValidator, entity: Entity, ...additionalArgs: never[]) => Promise<Dto> = (schemaValidator: SchemaValidator, entity: Entity, ...additionalArgs: never[]) => Promise<Dto>> = new (schemaValidator: SchemaValidator) => {
|
|
93
92
|
dto: Dto;
|
|
94
93
|
_Entity: Entity;
|
|
95
94
|
serializeEntityToDto: SerializeEntityToDto;
|
|
@@ -101,10 +100,10 @@ type ResponseDtoMapperConstructor<SchemaValidator extends AnySchemaValidator, Dt
|
|
|
101
100
|
* @template Dto - The type of the DTO object.
|
|
102
101
|
* @template Entity - The type of the entity object.
|
|
103
102
|
*/
|
|
104
|
-
type
|
|
103
|
+
type RequestMapperConstructor<SchemaValidator extends AnySchemaValidator, Dto, Entity, DeserializeDtoToEntity extends (dto: Dto, ...additionalArgs: never[]) => Promise<Entity> = (dto: Dto, ...additionalArgs: never[]) => Promise<Entity>> = new (schemaValidator: SchemaValidator) => {
|
|
105
104
|
dto: Dto;
|
|
106
105
|
_Entity: Entity;
|
|
107
106
|
deserializeDtoToEntity: DeserializeDtoToEntity;
|
|
108
107
|
};
|
|
109
108
|
|
|
110
|
-
export {
|
|
109
|
+
export { DummyEnum, IdentityRequestMapper, IdentityResponseMapper, type InternalMapper, type MapperSchemaValidatorObject, type RequestMapperConstructor, type ResponseMapperConstructor, type SchemasByValidator, serviceSchemaResolver, testSchemaEquality, transformIntoInternalMapper };
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { AnySchemaValidator, IdiomaticSchema, Schema, UnboxedObjectSchema } from
|
|
|
2
2
|
import { TypeboxSchemaValidator } from '@forklaunch/validator/typebox';
|
|
3
3
|
import { ZodSchemaValidator } from '@forklaunch/validator/zod';
|
|
4
4
|
import { InstanceTypeRecord } from '@forklaunch/common';
|
|
5
|
-
import { EntityManager } from '@mikro-orm/core';
|
|
6
5
|
|
|
7
6
|
declare class IdentityRequestMapper<T, SchemaValidator extends AnySchemaValidator> {
|
|
8
7
|
dto: T;
|
|
@@ -41,7 +40,7 @@ declare function serviceSchemaResolver<Options extends Record<string, unknown>,
|
|
|
41
40
|
validator: SchemaValidator;
|
|
42
41
|
}) => SchemasByValidator<SchemaValidator, (options: Options) => TypeBoxSchemas, (options: Options) => ZodSchemas>;
|
|
43
42
|
|
|
44
|
-
type
|
|
43
|
+
type InternalMapper<Mapper extends Record<string, {
|
|
45
44
|
dto: unknown;
|
|
46
45
|
_Entity: unknown;
|
|
47
46
|
serializeEntityToDto: unknown;
|
|
@@ -50,22 +49,22 @@ type InternalDtoMapper<DtoMapper extends Record<string, {
|
|
|
50
49
|
_Entity: unknown;
|
|
51
50
|
deserializeDtoToEntity: unknown;
|
|
52
51
|
}>> = {
|
|
53
|
-
[K in keyof
|
|
52
|
+
[K in keyof Mapper]: Mapper[K] extends {
|
|
54
53
|
dto: unknown;
|
|
55
54
|
_Entity: unknown;
|
|
56
55
|
serializeEntityToDto: unknown;
|
|
57
56
|
} ? {
|
|
58
|
-
serializeEntityToDto:
|
|
59
|
-
} :
|
|
57
|
+
serializeEntityToDto: Mapper[K]['serializeEntityToDto'];
|
|
58
|
+
} : Mapper[K] extends {
|
|
60
59
|
dto: unknown;
|
|
61
60
|
_Entity: unknown;
|
|
62
61
|
deserializeDtoToEntity: unknown;
|
|
63
62
|
} ? {
|
|
64
|
-
deserializeDtoToEntity:
|
|
63
|
+
deserializeDtoToEntity: Mapper[K]['deserializeDtoToEntity'];
|
|
65
64
|
} : never;
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
declare function
|
|
67
|
+
declare function transformIntoInternalMapper<SchemaValidator extends AnySchemaValidator, Mapper extends Record<string, new (schemaValidator: SchemaValidator) => {
|
|
69
68
|
dto: unknown;
|
|
70
69
|
_Entity: unknown;
|
|
71
70
|
serializeEntityToDto: unknown;
|
|
@@ -73,15 +72,15 @@ declare function transformIntoInternalDtoMapper<SchemaValidator extends AnySchem
|
|
|
73
72
|
dto: unknown;
|
|
74
73
|
_Entity: unknown;
|
|
75
74
|
deserializeDtoToEntity: unknown;
|
|
76
|
-
}>>(mappers:
|
|
75
|
+
}>>(mappers: Mapper, schemaValidator: SchemaValidator): InternalMapper<InstanceTypeRecord<Mapper>>;
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
78
|
* Type representing a schema validator object for an entity mapper.
|
|
80
79
|
*
|
|
81
80
|
* @template SV - A type that extends AnySchemaValidator.
|
|
82
|
-
* @typedef {SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>}
|
|
81
|
+
* @typedef {SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>} MapperSchemaValidatorObject
|
|
83
82
|
*/
|
|
84
|
-
type
|
|
83
|
+
type MapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidSchemaObject'] | UnboxedObjectSchema<SV>;
|
|
85
84
|
/**
|
|
86
85
|
* Type representing a response DTO mapper for an entity mapper.
|
|
87
86
|
*
|
|
@@ -89,7 +88,7 @@ type DtoMapperSchemaValidatorObject<SV extends AnySchemaValidator> = SV['_ValidS
|
|
|
89
88
|
* @template Dto - The type of the DTO object.
|
|
90
89
|
* @template Entity - The type of the entity object.
|
|
91
90
|
*/
|
|
92
|
-
type
|
|
91
|
+
type ResponseMapperConstructor<SchemaValidator extends AnySchemaValidator, Dto, Entity, SerializeEntityToDto extends (schemaValidator: SchemaValidator, entity: Entity, ...additionalArgs: never[]) => Promise<Dto> = (schemaValidator: SchemaValidator, entity: Entity, ...additionalArgs: never[]) => Promise<Dto>> = new (schemaValidator: SchemaValidator) => {
|
|
93
92
|
dto: Dto;
|
|
94
93
|
_Entity: Entity;
|
|
95
94
|
serializeEntityToDto: SerializeEntityToDto;
|
|
@@ -101,10 +100,10 @@ type ResponseDtoMapperConstructor<SchemaValidator extends AnySchemaValidator, Dt
|
|
|
101
100
|
* @template Dto - The type of the DTO object.
|
|
102
101
|
* @template Entity - The type of the entity object.
|
|
103
102
|
*/
|
|
104
|
-
type
|
|
103
|
+
type RequestMapperConstructor<SchemaValidator extends AnySchemaValidator, Dto, Entity, DeserializeDtoToEntity extends (dto: Dto, ...additionalArgs: never[]) => Promise<Entity> = (dto: Dto, ...additionalArgs: never[]) => Promise<Entity>> = new (schemaValidator: SchemaValidator) => {
|
|
105
104
|
dto: Dto;
|
|
106
105
|
_Entity: Entity;
|
|
107
106
|
deserializeDtoToEntity: DeserializeDtoToEntity;
|
|
108
107
|
};
|
|
109
108
|
|
|
110
|
-
export {
|
|
109
|
+
export { DummyEnum, IdentityRequestMapper, IdentityResponseMapper, type InternalMapper, type MapperSchemaValidatorObject, type RequestMapperConstructor, type ResponseMapperConstructor, type SchemasByValidator, serviceSchemaResolver, testSchemaEquality, transformIntoInternalMapper };
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
IdentityResponseMapper: () => IdentityResponseMapper,
|
|
26
26
|
serviceSchemaResolver: () => serviceSchemaResolver,
|
|
27
27
|
testSchemaEquality: () => testSchemaEquality,
|
|
28
|
-
|
|
28
|
+
transformIntoInternalMapper: () => transformIntoInternalMapper
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(index_exports);
|
|
31
31
|
|
|
@@ -87,8 +87,8 @@ function serviceSchemaResolver(TypeBoxSchemas, ZodSchemas) {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
// src/
|
|
91
|
-
function
|
|
90
|
+
// src/transformIntoInternalMapper.ts
|
|
91
|
+
function transformIntoInternalMapper(mappers, schemaValidator) {
|
|
92
92
|
return Object.fromEntries(
|
|
93
93
|
Object.entries(mappers).map(([key, value]) => [
|
|
94
94
|
key,
|
|
@@ -103,5 +103,5 @@ function transformIntoInternalDtoMapper(mappers, schemaValidator) {
|
|
|
103
103
|
IdentityResponseMapper,
|
|
104
104
|
serviceSchemaResolver,
|
|
105
105
|
testSchemaEquality,
|
|
106
|
-
|
|
106
|
+
transformIntoInternalMapper
|
|
107
107
|
});
|
package/lib/index.mjs
CHANGED
|
@@ -60,8 +60,8 @@ function serviceSchemaResolver(TypeBoxSchemas, ZodSchemas) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// src/
|
|
64
|
-
function
|
|
63
|
+
// src/transformIntoInternalMapper.ts
|
|
64
|
+
function transformIntoInternalMapper(mappers, schemaValidator) {
|
|
65
65
|
return Object.fromEntries(
|
|
66
66
|
Object.entries(mappers).map(([key, value]) => [
|
|
67
67
|
key,
|
|
@@ -75,5 +75,5 @@ export {
|
|
|
75
75
|
IdentityResponseMapper,
|
|
76
76
|
serviceSchemaResolver,
|
|
77
77
|
testSchemaEquality,
|
|
78
|
-
|
|
78
|
+
transformIntoInternalMapper
|
|
79
79
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/internal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Internal package for utilities and other internal code.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@mikro-orm/core": "^6.4.16",
|
|
32
|
-
"@forklaunch/common": "0.3.
|
|
33
|
-
"@forklaunch/validator": "0.6.
|
|
32
|
+
"@forklaunch/common": "0.3.14",
|
|
33
|
+
"@forklaunch/validator": "0.6.16"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@eslint/js": "^9.29.0",
|