@venizia/ignis-kernel 0.4.6 → 0.4.7-1
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/LICENSE.md +1 -4
- package/dist/esm/base/applications/artifact-group.d.ts.map +1 -1
- package/dist/esm/base/applications/artifact-group.js +4 -1
- package/dist/esm/base/applications/artifact-group.js.map +1 -1
- package/dist/esm/base/applications/artifact-index.d.ts.map +1 -1
- package/dist/esm/base/applications/artifact-index.js +2 -1
- package/dist/esm/base/applications/artifact-index.js.map +1 -1
- package/dist/esm/base/applications/cors.d.ts +12 -10
- package/dist/esm/base/applications/cors.d.ts.map +1 -1
- package/dist/esm/base/applications/cors.js +37 -35
- package/dist/esm/base/applications/cors.js.map +1 -1
- package/dist/esm/base/applications/rest.js +11 -11
- package/dist/esm/base/applications/rest.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/codecs.js +2 -2
- package/dist/esm/base/auth/authenticate/common/codecs.js.map +1 -1
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.d.ts +1 -1
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js +1 -1
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/authorization.provider.d.ts.map +1 -1
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js +14 -11
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/request-domain.d.ts +14 -11
- package/dist/esm/base/auth/authorize/providers/request-domain.d.ts.map +1 -1
- package/dist/esm/base/auth/authorize/providers/request-domain.js +42 -39
- package/dist/esm/base/auth/authorize/providers/request-domain.js.map +1 -1
- package/dist/esm/base/auth/base/abstract-auth-registry.js +2 -2
- package/dist/esm/base/auth/base/abstract-auth-registry.js.map +1 -1
- package/dist/esm/base/auth/models/requests/change-password.schema.js +3 -3
- package/dist/esm/base/auth/models/requests/change-password.schema.js.map +1 -1
- package/dist/esm/base/auth/models/requests/sign-in.schema.js +5 -5
- package/dist/esm/base/auth/models/requests/sign-in.schema.js.map +1 -1
- package/dist/esm/base/components/controller/rest/rest.component.js +2 -2
- package/dist/esm/base/components/controller/rest/rest.component.js.map +1 -1
- package/dist/esm/base/controllers/common/index.d.ts +0 -1
- package/dist/esm/base/controllers/common/index.d.ts.map +1 -1
- package/dist/esm/base/controllers/common/index.js +0 -1
- package/dist/esm/base/controllers/common/index.js.map +1 -1
- package/dist/esm/base/controllers/common/schema-builders.d.ts +0 -5
- package/dist/esm/base/controllers/common/schema-builders.d.ts.map +1 -1
- package/dist/esm/base/controllers/common/schema-builders.js +0 -14
- package/dist/esm/base/controllers/common/schema-builders.js.map +1 -1
- package/dist/esm/base/controllers/context.d.ts +7 -2
- package/dist/esm/base/controllers/context.d.ts.map +1 -1
- package/dist/esm/base/controllers/context.js +7 -4
- package/dist/esm/base/controllers/context.js.map +1 -1
- package/dist/esm/base/controllers/factory/controller.d.ts +33 -1
- package/dist/esm/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/controller.js +90 -6
- package/dist/esm/base/controllers/factory/controller.js.map +1 -1
- package/dist/esm/base/controllers/factory/crud/persistable.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/crud/persistable.js +40 -25
- package/dist/esm/base/controllers/factory/crud/persistable.js.map +1 -1
- package/dist/esm/base/controllers/factory/crud/readable.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/crud/readable.js +4 -3
- package/dist/esm/base/controllers/factory/crud/readable.js.map +1 -1
- package/dist/esm/base/controllers/factory/definition.d.ts +1 -8
- package/dist/esm/base/controllers/factory/definition.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/definition.js +17 -24
- package/dist/esm/base/controllers/factory/definition.js.map +1 -1
- package/dist/esm/base/controllers/factory/index.d.ts +0 -1
- package/dist/esm/base/controllers/factory/index.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/index.js +0 -1
- package/dist/esm/base/controllers/factory/index.js.map +1 -1
- package/dist/esm/base/controllers/rest/abstract.d.ts.map +1 -1
- package/dist/esm/base/controllers/rest/abstract.js +6 -6
- package/dist/esm/base/controllers/rest/abstract.js.map +1 -1
- package/dist/esm/base/controllers/rest/base.d.ts +0 -5
- package/dist/esm/base/controllers/rest/base.d.ts.map +1 -1
- package/dist/esm/base/controllers/rest/base.js +14 -14
- package/dist/esm/base/controllers/rest/base.js.map +1 -1
- package/dist/esm/base/datasources/abstract.js +2 -2
- package/dist/esm/base/datasources/abstract.js.map +1 -1
- package/dist/esm/base/events/event-bus.js +4 -4
- package/dist/esm/base/events/event-bus.js.map +1 -1
- package/dist/esm/base/metadata/injectable.d.ts +7 -4
- package/dist/esm/base/metadata/injectable.d.ts.map +1 -1
- package/dist/esm/base/metadata/injectable.js +26 -23
- package/dist/esm/base/metadata/injectable.js.map +1 -1
- package/dist/esm/base/metadata/model-metadata.d.ts +27 -13
- package/dist/esm/base/metadata/model-metadata.d.ts.map +1 -1
- package/dist/esm/base/metadata/model-metadata.js +56 -26
- package/dist/esm/base/metadata/model-metadata.js.map +1 -1
- package/dist/esm/base/metadata/persistents.d.ts.map +1 -1
- package/dist/esm/base/metadata/persistents.js +21 -13
- package/dist/esm/base/metadata/persistents.js.map +1 -1
- package/dist/esm/base/metadata/routes/controller.d.ts.map +1 -1
- package/dist/esm/base/metadata/routes/controller.js +5 -2
- package/dist/esm/base/metadata/routes/controller.js.map +1 -1
- package/dist/esm/base/middlewares/app-error/app-error.middleware.js +7 -7
- package/dist/esm/base/middlewares/app-error/app-error.middleware.js.map +1 -1
- package/dist/esm/base/middlewares/app-error/database.handler.d.ts +14 -12
- package/dist/esm/base/middlewares/app-error/database.handler.d.ts.map +1 -1
- package/dist/esm/base/middlewares/app-error/database.handler.js +37 -35
- package/dist/esm/base/middlewares/app-error/database.handler.js.map +1 -1
- package/dist/esm/base/middlewares/app-error/zod.handler.d.ts +28 -23
- package/dist/esm/base/middlewares/app-error/zod.handler.d.ts.map +1 -1
- package/dist/esm/base/middlewares/app-error/zod.handler.js +56 -53
- package/dist/esm/base/middlewares/app-error/zod.handler.js.map +1 -1
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts +6 -4
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts.map +1 -1
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js +14 -12
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -1
- package/dist/esm/base/middlewares/form-body/form-body.middleware.d.ts +15 -11
- package/dist/esm/base/middlewares/form-body/form-body.middleware.d.ts.map +1 -1
- package/dist/esm/base/middlewares/form-body/form-body.middleware.js +25 -21
- package/dist/esm/base/middlewares/form-body/form-body.middleware.js.map +1 -1
- package/dist/esm/base/models/common/schemas.d.ts +184 -105
- package/dist/esm/base/models/common/schemas.d.ts.map +1 -1
- package/dist/esm/base/models/common/schemas.js +105 -54
- package/dist/esm/base/models/common/schemas.js.map +1 -1
- package/dist/esm/base/models/common/utilities.d.ts +10 -5
- package/dist/esm/base/models/common/utilities.d.ts.map +1 -1
- package/dist/esm/base/models/common/utilities.js +22 -16
- package/dist/esm/base/models/common/utilities.js.map +1 -1
- package/dist/esm/base/repositories/common/types/results.d.ts +15 -7
- package/dist/esm/base/repositories/common/types/results.d.ts.map +1 -1
- package/dist/esm/base/repositories/common/types/results.js +16 -7
- package/dist/esm/base/repositories/common/types/results.js.map +1 -1
- package/dist/esm/base/repositories/core/abstract.d.ts.map +1 -1
- package/dist/esm/base/repositories/core/abstract.js +5 -3
- package/dist/esm/base/repositories/core/abstract.js.map +1 -1
- package/dist/esm/base/repositories/query-schemas/index.d.ts +1 -1
- package/dist/esm/base/repositories/query-schemas/index.d.ts.map +1 -1
- package/dist/esm/base/repositories/query-schemas/index.js +3 -3
- package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
- package/dist/esm/helpers/inversion/common/relation-builder.js.map +1 -1
- package/dist/esm/helpers/inversion/index.d.ts +1 -1
- package/dist/esm/helpers/inversion/index.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/index.js +1 -1
- package/dist/esm/helpers/inversion/index.js.map +1 -1
- package/dist/esm/helpers/inversion/mixins/repository.mixin.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/mixins/repository.mixin.js +5 -5
- package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
- package/dist/esm/metadata.d.ts +1 -1
- package/dist/esm/metadata.d.ts.map +1 -1
- package/dist/esm/metadata.js +1 -1
- package/dist/esm/metadata.js.map +1 -1
- package/dist/esm/repository.d.ts +2 -2
- package/dist/esm/repository.d.ts.map +1 -1
- package/dist/esm/repository.js +2 -2
- package/dist/esm/repository.js.map +1 -1
- package/dist/esm/utilities/index.d.ts +1 -1
- package/dist/esm/utilities/index.d.ts.map +1 -1
- package/dist/esm/utilities/index.js +1 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/not-supported.utility.d.ts +11 -0
- package/dist/esm/utilities/not-supported.utility.d.ts.map +1 -0
- package/dist/esm/utilities/not-supported.utility.js +19 -0
- package/dist/esm/utilities/not-supported.utility.js.map +1 -0
- package/package.json +6 -7
- package/dist/esm/base/controllers/common/html-response.d.ts +0 -70
- package/dist/esm/base/controllers/common/html-response.d.ts.map +0 -1
- package/dist/esm/base/controllers/common/html-response.js +0 -30
- package/dist/esm/base/controllers/common/html-response.js.map +0 -1
- package/dist/esm/base/controllers/factory/authorize-guard.d.ts +0 -19
- package/dist/esm/base/controllers/factory/authorize-guard.d.ts.map +0 -1
- package/dist/esm/base/controllers/factory/authorize-guard.js +0 -56
- package/dist/esm/base/controllers/factory/authorize-guard.js.map +0 -1
- package/dist/esm/base/controllers/factory/helper.d.ts +0 -2
- package/dist/esm/base/controllers/factory/helper.d.ts.map +0 -1
- package/dist/esm/base/controllers/factory/helper.js +0 -2
- package/dist/esm/base/controllers/factory/helper.js.map +0 -1
- package/dist/esm/base/controllers/factory/repository-injection.d.ts +0 -14
- package/dist/esm/base/controllers/factory/repository-injection.d.ts.map +0 -1
- package/dist/esm/base/controllers/factory/repository-injection.js +0 -27
- package/dist/esm/base/controllers/factory/repository-injection.js.map +0 -1
- package/dist/esm/base/metadata/model-settings.d.ts +0 -11
- package/dist/esm/base/metadata/model-settings.d.ts.map +0 -1
- package/dist/esm/base/metadata/model-settings.js +0 -30
- package/dist/esm/base/metadata/model-settings.js.map +0 -1
- package/dist/esm/utilities/error.utility.d.ts +0 -8
- package/dist/esm/utilities/error.utility.d.ts.map +0 -1
- package/dist/esm/utilities/error.utility.js +0 -14
- package/dist/esm/utilities/error.utility.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../src/base/models/common/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;iBA6BpB,CAAC;AAEL,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzD,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../../src/base/models/common/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;iBA6BpB,CAAC;AAEL,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEzD,sFAAsF;AACtF,qBAAa,cAAc;IACzB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,aAAa,CAA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QACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;;;;;;;;;IAQD,8FAA8F;IAC9F,MAAM,CAAC,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASrB,MAAM,CAAC,YAAY,CACjB,aAAa,SAAS,CAAC,CAAC,OAAO,EAC/B,YAAY,SAAS,gBAAgB,GAAG,SAAS,GAAG,SAAS,EAC7D,IAAI,EAAE,iBAAiB,CAAC,aAAa,EAAE,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBvD"}
|
|
@@ -35,62 +35,113 @@ export const ErrorSchema = z
|
|
|
35
35
|
details: { url: 'http://localhost:3000/categories', path: '/categories' },
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
/** OpenAPI schema builders for the parts of a route that every controller repeats. */
|
|
39
|
+
export class OpenApiSchemas {
|
|
40
|
+
static idParams(opts) {
|
|
41
|
+
const { idType = 'number' } = opts ?? {};
|
|
42
|
+
switch (idType) {
|
|
43
|
+
case 'number': {
|
|
44
|
+
return z.object({
|
|
45
|
+
id: z.number().openapi({
|
|
46
|
+
param: {
|
|
47
|
+
name: 'id',
|
|
48
|
+
in: 'path',
|
|
49
|
+
description: 'The unique id of the resource',
|
|
50
|
+
},
|
|
51
|
+
examples: [1, 2, 3],
|
|
52
|
+
}),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
case 'string': {
|
|
56
|
+
return z.object({
|
|
57
|
+
id: z.string().openapi({
|
|
58
|
+
param: {
|
|
59
|
+
name: 'id',
|
|
60
|
+
in: 'path',
|
|
61
|
+
description: 'The unique id of the resource',
|
|
62
|
+
},
|
|
63
|
+
examples: ['4651e634-a530-4484-9b09-9616a28f35e3', 'some_unique_id'],
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
default: {
|
|
68
|
+
throw getError({
|
|
69
|
+
message: `[OpenApiSchemas.idParams] Invalid input idType | valid: [string | number] | idType: ${idType}`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
52
72
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}),
|
|
63
|
-
});
|
|
73
|
+
}
|
|
74
|
+
static requiredString(opts) {
|
|
75
|
+
const { min, max, fixed } = opts ?? {};
|
|
76
|
+
let rs = z.string().nonempty();
|
|
77
|
+
if (min) {
|
|
78
|
+
rs = rs.min(min);
|
|
79
|
+
}
|
|
80
|
+
if (max) {
|
|
81
|
+
rs = rs.max(max);
|
|
64
82
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
message: `[idParamsSchema] Invalid input idType | valid: [string | number] | idType: ${idType}`,
|
|
68
|
-
});
|
|
83
|
+
if (fixed) {
|
|
84
|
+
rs = rs.length(fixed);
|
|
69
85
|
}
|
|
86
|
+
return rs;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** OpenAPI response builders: the JSON and HTML bodies of a route, and the error bodies every route shares. */
|
|
90
|
+
export class OpenApiResponses {
|
|
91
|
+
/** Creates HTML content configuration for OpenAPI documentation. */
|
|
92
|
+
static htmlContent(opts) {
|
|
93
|
+
const { description } = opts;
|
|
94
|
+
return {
|
|
95
|
+
description,
|
|
96
|
+
content: {
|
|
97
|
+
'text/html': {
|
|
98
|
+
schema: z.string().openapi({
|
|
99
|
+
description: 'HTML content',
|
|
100
|
+
example: '<!DOCTYPE html><html><head><title>Page</title></head><body>...</body></html>',
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
required: opts?.required ?? false,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** Creates HTML response configuration for OpenAPI documentation. */
|
|
108
|
+
static htmlResponse(opts) {
|
|
109
|
+
return {
|
|
110
|
+
[HTTP.ResultCodes.RS_2.Ok]: OpenApiResponses.htmlContent({
|
|
111
|
+
description: opts.description,
|
|
112
|
+
required: opts.required,
|
|
113
|
+
}),
|
|
114
|
+
...OpenApiResponses.errorResponses(),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
static jsonContent(opts) {
|
|
118
|
+
return {
|
|
119
|
+
description: opts.description,
|
|
120
|
+
content: { 'application/json': { schema: opts.schema } },
|
|
121
|
+
required: opts.required,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** The JSON error body of a route, under `4XX` and `5XX` - the range keys OpenAPI accepts. */
|
|
125
|
+
static errorResponses() {
|
|
126
|
+
const errorResponse = OpenApiResponses.jsonContent({
|
|
127
|
+
description: 'Error Response',
|
|
128
|
+
schema: ErrorSchema,
|
|
129
|
+
});
|
|
130
|
+
return { '4XX': errorResponse, '5XX': errorResponse };
|
|
131
|
+
}
|
|
132
|
+
static jsonResponse(opts) {
|
|
133
|
+
const baseResponse = OpenApiResponses.jsonContent({
|
|
134
|
+
required: opts.required,
|
|
135
|
+
description: opts.description ?? 'Success Response',
|
|
136
|
+
schema: opts.schema,
|
|
137
|
+
});
|
|
138
|
+
const successResponse = opts.headers
|
|
139
|
+
? { ...baseResponse, headers: opts.headers }
|
|
140
|
+
: baseResponse;
|
|
141
|
+
return {
|
|
142
|
+
[HTTP.ResultCodes.RS_2.Ok]: successResponse,
|
|
143
|
+
...OpenApiResponses.errorResponses(),
|
|
144
|
+
};
|
|
70
145
|
}
|
|
71
|
-
}
|
|
72
|
-
export const jsonContent = (opts) => {
|
|
73
|
-
return {
|
|
74
|
-
description: opts.description,
|
|
75
|
-
content: { 'application/json': { schema: opts.schema } },
|
|
76
|
-
required: opts.required,
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
/** The JSON error body of a route, under `4XX` and `5XX` - the range keys OpenAPI accepts. */
|
|
80
|
-
export const errorResponses = () => {
|
|
81
|
-
const errorResponse = jsonContent({ description: 'Error Response', schema: ErrorSchema });
|
|
82
|
-
return { '4XX': errorResponse, '5XX': errorResponse };
|
|
83
|
-
};
|
|
84
|
-
export const jsonResponse = (opts) => {
|
|
85
|
-
const baseResponse = jsonContent({
|
|
86
|
-
required: opts.required,
|
|
87
|
-
description: opts.description ?? 'Success Response',
|
|
88
|
-
schema: opts.schema,
|
|
89
|
-
});
|
|
90
|
-
const successResponse = opts.headers ? { ...baseResponse, headers: opts.headers } : baseResponse;
|
|
91
|
-
return {
|
|
92
|
-
[HTTP.ResultCodes.RS_2.Ok]: successResponse,
|
|
93
|
-
...errorResponses(),
|
|
94
|
-
};
|
|
95
|
-
};
|
|
146
|
+
}
|
|
96
147
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../../src/base/models/common/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAGvD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACzB,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,CAAC;SACV,MAAM,CAAC;QACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,C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EH,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,YAAY,CAGjB,IAAoD;QACpD,MAAM,YAAY,GAAG,gBAAgB,CAAC,WAAW,CAAC;YAChD,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,kBAAkB;YACnD,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO;YAClC,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE;YAC5C,CAAC,CAAC,YAAY,CAAC;QAEjB,OAAO;YACL,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,eAAe;YAC3C,GAAG,gBAAgB,CAAC,cAAc,EAAE;SACrC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { z } from '@hono/zod-openapi';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport type { TIdSchemaType } from './constants';\n\n/**\n * The error RESPONSE for OpenAPI docs - here, beside the REST layer that already needs `@hono/zod-openapi`.\n * Named, so every route's `4XX` and `5XX` reference one `ErrorResponse` component.\n */\nexport const ErrorSchema = z\n .object({\n statusCode: z.number().optional(),\n message: z.string(),\n normalized: z\n .object({\n text: z.string(),\n code: z.string(),\n args: z.record(z.string(), z.any()),\n })\n .optional(),\n extra: z.record(z.string(), z.any()).optional(),\n requestId: z.string().optional(),\n details: z.record(z.string(), z.any()).optional(),\n })\n .openapi('ErrorResponse', {\n description: 'Error Schema',\n example: {\n statusCode: HTTP.ResultCodes.RS_4.Conflict,\n message: 'A category named %{name} already exists.',\n normalized: {\n text: 'A category named %{name} already exists.',\n code: 'server.commerce.category.create.duplicate_name',\n args: { name: 'Ticket' },\n },\n extra: { categoryId: 42 },\n requestId: 'abc-123-def',\n details: { url: 'http://localhost:3000/categories', path: '/categories' },\n },\n });\n\nexport type TErrorResponse = z.infer<typeof ErrorSchema>;\n\n/** OpenAPI schema builders for the parts of a route that every controller repeats. */\nexport class OpenApiSchemas {\n static idParams(opts?: { idType: TIdSchemaType }) {\n const { idType = 'number' } = opts ?? {};\n\n switch (idType) {\n case 'number': {\n return z.object({\n id: z.number().openapi({\n param: {\n name: 'id',\n in: 'path',\n description: 'The unique id of the resource',\n },\n examples: [1, 2, 3],\n }),\n });\n }\n case 'string': {\n return z.object({\n id: z.string().openapi({\n param: {\n name: 'id',\n in: 'path',\n description: 'The unique id of the resource',\n },\n examples: ['4651e634-a530-4484-9b09-9616a28f35e3', 'some_unique_id'],\n }),\n });\n }\n default: {\n throw getError({\n message: `[OpenApiSchemas.idParams] Invalid input idType | valid: [string | number] | idType: ${idType}`,\n });\n }\n }\n }\n\n static requiredString(opts?: { min?: number; max?: number; fixed?: number }) {\n const { min, max, fixed } = opts ?? {};\n let rs = z.string().nonempty();\n\n if (min) {\n rs = rs.min(min);\n }\n\n if (max) {\n rs = rs.max(max);\n }\n\n if (fixed) {\n rs = rs.length(fixed);\n }\n\n return rs;\n }\n}\n\n/** OpenAPI Header Object format */\ntype THeaderObject = {\n description?: string;\n schema: { type: string; examples?: Array<string> };\n};\n\n/** Map of header names to Header Objects */\ntype TResponseHeaders = Record<string, THeaderObject>;\n\ntype TJsonResponseOpts<T extends z.ZodType, H extends TResponseHeaders | undefined> = {\n schema: T;\n description?: string;\n required?: boolean;\n headers?: H;\n};\n\n/** OpenAPI response builders: the JSON and HTML bodies of a route, and the error bodies every route shares. */\nexport class OpenApiResponses {\n /** Creates HTML content configuration for OpenAPI documentation. */\n static htmlContent(opts: { description: string; required?: boolean }) {\n const { description } = opts;\n\n return {\n description,\n content: {\n 'text/html': {\n schema: z.string().openapi({\n description: 'HTML content',\n example: '<!DOCTYPE html><html><head><title>Page</title></head><body>...</body></html>',\n }),\n },\n },\n required: opts?.required ?? false,\n };\n }\n\n /** Creates HTML response configuration for OpenAPI documentation. */\n static htmlResponse(opts: { description: string; required?: boolean }) {\n return {\n [HTTP.ResultCodes.RS_2.Ok]: OpenApiResponses.htmlContent({\n description: opts.description,\n required: opts.required,\n }),\n ...OpenApiResponses.errorResponses(),\n };\n }\n\n static jsonContent<T extends z.ZodType>(opts: {\n schema: T;\n description: string;\n required?: boolean;\n }) {\n return {\n description: opts.description,\n content: { 'application/json': { schema: opts.schema } },\n required: opts.required,\n };\n }\n\n /** The JSON error body of a route, under `4XX` and `5XX` - the range keys OpenAPI accepts. */\n static errorResponses() {\n const errorResponse = OpenApiResponses.jsonContent({\n description: 'Error Response',\n schema: ErrorSchema,\n });\n\n return { '4XX': errorResponse, '5XX': errorResponse };\n }\n\n static jsonResponse<\n ContentSchema extends z.ZodType,\n HeaderSchema extends TResponseHeaders | undefined = undefined,\n >(opts: TJsonResponseOpts<ContentSchema, HeaderSchema>) {\n const baseResponse = OpenApiResponses.jsonContent({\n required: opts.required,\n description: opts.description ?? 'Success Response',\n schema: opts.schema,\n });\n\n const successResponse = opts.headers\n ? { ...baseResponse, headers: opts.headers }\n : baseResponse;\n\n return {\n [HTTP.ResultCodes.RS_2.Ok]: successResponse,\n ...OpenApiResponses.errorResponses(),\n };\n }\n}\n"]}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
2
|
import type { TEntityId } from './types/index.js';
|
|
3
|
-
/** The only way into `TEntityId`. Rejects an empty string - an id that is `''` collapses a `where` to no condition. */
|
|
4
|
-
export declare const toEntityId: (opts: {
|
|
5
|
-
value: string;
|
|
6
|
-
}) => TEntityId;
|
|
7
3
|
type TSnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<TSnakeToCamelCase<U>>}` : S;
|
|
8
4
|
type TCamelCaseKeys<T extends z.ZodRawShape> = {
|
|
9
5
|
[K in keyof T as K extends string ? TSnakeToCamelCase<K> : K]: T[K] extends z.ZodType<infer U> ? z.ZodType<U> : T[K];
|
|
10
6
|
};
|
|
11
|
-
|
|
7
|
+
/** Conversions into the model types. */
|
|
8
|
+
export declare class ModelUtility {
|
|
9
|
+
/** The only way into `TEntityId`. Rejects an empty string - an id that is `''` collapses a `where` to no condition. */
|
|
10
|
+
static toEntityId(opts: {
|
|
11
|
+
value: string;
|
|
12
|
+
}): TEntityId;
|
|
13
|
+
static snakeToCamel<T extends z.ZodRawShape>(opts: {
|
|
14
|
+
shape: T;
|
|
15
|
+
}): z.ZodPipe<z.ZodPipe<z.ZodObject<{ -readonly [P in keyof T]: T[P]; }, z.core.$strip>, z.ZodTransform<any, z.core.$InferObjectOutput<{ -readonly [P in keyof T]: T[P]; }, {}>>>, z.ZodObject<TCamelCaseKeys<T> extends infer T_1 ? { -readonly [P_1 in keyof T_1]: T_1[P_1]; } : never, z.core.$strip>>;
|
|
16
|
+
}
|
|
12
17
|
export {};
|
|
13
18
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../src/base/models/common/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../src/base/models/common/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,CAAC,EAAE,GACxE,GAAG,CAAC,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,GACzC,CAAC,CAAC;AAEN,KAAK,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,IAAI;KAC5C,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAC1F,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GACZ,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AAEF,wCAAwC;AACxC,qBAAa,YAAY;IACvB,uHAAuH;IACvH,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS;IAUrD,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,CAAA;KAAE;CAahE"}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
-
import { getError,
|
|
3
|
-
/**
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { getError, ParseUtility } from '@venizia/ignis-helpers/core';
|
|
3
|
+
/** Conversions into the model types. */
|
|
4
|
+
export class ModelUtility {
|
|
5
|
+
/** The only way into `TEntityId`. Rejects an empty string - an id that is `''` collapses a `where` to no condition. */
|
|
6
|
+
static toEntityId(opts) {
|
|
7
|
+
if (opts.value.length === 0) {
|
|
8
|
+
throw getError({
|
|
9
|
+
message: '[ModelUtility.toEntityId] Refusing an empty string as an entity id',
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return opts.value;
|
|
7
13
|
}
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
14
|
+
static snakeToCamel(opts) {
|
|
15
|
+
const { shape } = opts;
|
|
16
|
+
const camelShape = Object.fromEntries(Object.entries(shape).map(([key, value]) => {
|
|
17
|
+
return [ParseUtility.toCamel({ input: key }), value];
|
|
18
|
+
}));
|
|
19
|
+
return z
|
|
20
|
+
.object(shape)
|
|
21
|
+
.transform((data) => ParseUtility.keysToCamel({ source: data }))
|
|
22
|
+
.pipe(z.object(camelShape));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
19
25
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../../src/base/models/common/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../../src/base/models/common/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAarE,wCAAwC;AACxC,MAAM,OAAO,YAAY;IACvB,uHAAuH;IACvH,MAAM,CAAC,UAAU,CAAC,IAAuB;QACvC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oEAAoE;aAC9E,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,KAAkB,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,YAAY,CAA0B,IAAkB;QAC7D,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACvB,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CACnC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACzC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC,CAAC,CACkB,CAAC;QAEvB,OAAO,CAAC;aACL,MAAM,CAAC,KAAK,CAAC;aACb,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aAC/D,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["import { z } from '@hono/zod-openapi';\nimport { getError, ParseUtility } from '@venizia/ignis-helpers/core';\nimport type { TEntityId } from './types';\n\ntype TSnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}`\n ? `${T}${Capitalize<TSnakeToCamelCase<U>>}`\n : S;\n\ntype TCamelCaseKeys<T extends z.ZodRawShape> = {\n [K in keyof T as K extends string ? TSnakeToCamelCase<K> : K]: T[K] extends z.ZodType<infer U>\n ? z.ZodType<U>\n : T[K];\n};\n\n/** Conversions into the model types. */\nexport class ModelUtility {\n /** The only way into `TEntityId`. Rejects an empty string - an id that is `''` collapses a `where` to no condition. */\n static toEntityId(opts: { value: string }): TEntityId {\n if (opts.value.length === 0) {\n throw getError({\n message: '[ModelUtility.toEntityId] Refusing an empty string as an entity id',\n });\n }\n\n return opts.value as TEntityId;\n }\n\n static snakeToCamel<T extends z.ZodRawShape>(opts: { shape: T }) {\n const { shape } = opts;\n const camelShape = Object.fromEntries(\n Object.entries(shape).map(([key, value]) => {\n return [ParseUtility.toCamel({ input: key }), value];\n }),\n ) as TCamelCaseKeys<T>;\n\n return z\n .object(shape)\n .transform((data) => ParseUtility.keysToCamel({ source: data }))\n .pipe(z.object(camelShape));\n }\n}\n"]}
|
|
@@ -8,13 +8,21 @@ export type TDataRange = {
|
|
|
8
8
|
end: number;
|
|
9
9
|
total: number;
|
|
10
10
|
};
|
|
11
|
-
/** Content-Range
|
|
12
|
-
export declare
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
/** The `Content-Range` of a page: building the range from a result, and writing it as a header value. */
|
|
12
|
+
export declare class DataRangeUtility {
|
|
13
|
+
/** Content-Range envelope with an inclusive `end` - an empty page collapses `end` onto `start`. */
|
|
14
|
+
static buildDataRange(opts: {
|
|
15
|
+
skip?: number;
|
|
16
|
+
offset?: number;
|
|
17
|
+
dataLength: number;
|
|
18
|
+
total: number;
|
|
19
|
+
}): TDataRange;
|
|
20
|
+
/** `Content-Range` of a page: inclusive `end`, and `records * /<total>` (no space) when the page is empty. Exported so a route that writes the header itself uses the one formatter. */
|
|
21
|
+
static toContentRange(opts: {
|
|
22
|
+
range: TDataRange;
|
|
23
|
+
count: number;
|
|
24
|
+
}): string;
|
|
25
|
+
}
|
|
18
26
|
/** The `shouldQueryRange: true` result envelope; `extra` carries what a list answered beside its rows - see `x-request-extra`. */
|
|
19
27
|
export type TDataWithRange<R> = {
|
|
20
28
|
data: Array<R>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/results.ts"],"names":[],"mappings":"AAAA,uLAAuL;AACvL,MAAM,MAAM,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,mGAAmG;
|
|
1
|
+
{"version":3,"file":"results.d.ts","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/results.ts"],"names":[],"mappings":"AAAA,uLAAuL;AACvL,MAAM,MAAM,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,yGAAyG;AACzG,qBAAa,gBAAgB;IAC3B,mGAAmG;IACnG,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,UAAU;IAOd,wLAAwL;IACxL,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;CAK1E;AAED,kIAAkI;AAClI,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACf,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
/** Content-Range
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/** The `Content-Range` of a page: building the range from a result, and writing it as a header value. */
|
|
2
|
+
export class DataRangeUtility {
|
|
3
|
+
/** Content-Range envelope with an inclusive `end` - an empty page collapses `end` onto `start`. */
|
|
4
|
+
static buildDataRange(opts) {
|
|
5
|
+
const { skip, offset, dataLength, total } = opts;
|
|
6
|
+
const start = skip ?? offset ?? 0;
|
|
7
|
+
const end = dataLength > 0 ? start + dataLength - 1 : start;
|
|
8
|
+
return { start, end, total };
|
|
9
|
+
}
|
|
10
|
+
/** `Content-Range` of a page: inclusive `end`, and `records * /<total>` (no space) when the page is empty. Exported so a route that writes the header itself uses the one formatter. */
|
|
11
|
+
static toContentRange(opts) {
|
|
12
|
+
const { range, count } = opts;
|
|
13
|
+
const { start, end, total } = range;
|
|
14
|
+
return count > 0 ? `records ${start}-${end}/${total}` : `records */${total}`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
//# sourceMappingURL=results.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/results.ts"],"names":[],"mappings":"AAUA,
|
|
1
|
+
{"version":3,"file":"results.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/results.ts"],"names":[],"mappings":"AAUA,yGAAyG;AACzG,MAAM,OAAO,gBAAgB;IAC3B,mGAAmG;IACnG,MAAM,CAAC,cAAc,CAAC,IAKrB;QACC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,IAAI,MAAM,IAAI,CAAC,CAAC;QAClC,MAAM,GAAG,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5D,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,wLAAwL;IACxL,MAAM,CAAC,cAAc,CAAC,IAA0C;QAC9D,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;QACpC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,EAAE,CAAC;IAC/E,CAAC;CACF","sourcesContent":["/** The count envelope. Spelled out rather than inferred from `CountSchema`, which lives in `result-schemas.ts` - inferring it here would put zod on every path that needs the TYPE. */\nexport type TCount = { count: number };\n\n/** Data range information for paginated queries. Follows HTTP Content-Range standard. */\nexport type TDataRange = {\n start: number;\n end: number;\n total: number;\n};\n\n/** The `Content-Range` of a page: building the range from a result, and writing it as a header value. */\nexport class DataRangeUtility {\n /** Content-Range envelope with an inclusive `end` - an empty page collapses `end` onto `start`. */\n static buildDataRange(opts: {\n skip?: number;\n offset?: number;\n dataLength: number;\n total: number;\n }): TDataRange {\n const { skip, offset, dataLength, total } = opts;\n const start = skip ?? offset ?? 0;\n const end = dataLength > 0 ? start + dataLength - 1 : start;\n return { start, end, total };\n }\n\n /** `Content-Range` of a page: inclusive `end`, and `records * /<total>` (no space) when the page is empty. Exported so a route that writes the header itself uses the one formatter. */\n static toContentRange(opts: { range: TDataRange; count: number }): string {\n const { range, count } = opts;\n const { start, end, total } = range;\n return count > 0 ? `records ${start}-${end}/${total}` : `records */${total}`;\n }\n}\n\n/** The `shouldQueryRange: true` result envelope; `extra` carries what a list answered beside its rows - see `x-request-extra`. */\nexport type TDataWithRange<R> = {\n data: Array<R>;\n range: TDataRange;\n extra?: Record<string, unknown>;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAY,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,cAAc,EACd,MAA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}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MetadataRegistry } from '../../../helpers/inversion/index.js';
|
|
2
2
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
3
|
-
import {
|
|
3
|
+
import { ResolverUtility } from '@venizia/ignis-helpers/common';
|
|
4
4
|
import { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';
|
|
5
5
|
// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is
|
|
6
6
|
// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.
|
|
@@ -163,9 +163,11 @@ export class AbstractRepository extends BaseHelper {
|
|
|
163
163
|
message: `[${this.constructor.name}] Cannot resolve entity. Either pass entityClass in constructor or use @repository decorator with model option.`,
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
// resolveValue() erases to the resolved value's structural type, not this class-or-resolver
|
|
166
|
+
// ResolverUtility.resolveValue() erases to the resolved value's structural type, not this class-or-resolver
|
|
167
167
|
// union's member - the `@repository` decorator guarantees a class constructor here.
|
|
168
|
-
const ModelClass = resolveValue({
|
|
168
|
+
const ModelClass = ResolverUtility.resolveValue({
|
|
169
|
+
value: binding.model,
|
|
170
|
+
});
|
|
169
171
|
return new ModelClass();
|
|
170
172
|
}
|
|
171
173
|
/** Rejects a verb the current operation scope does not permit. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAYpG,sGAAsG;AACtG,sFAAsF;A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AS,EAAE,SAAS;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;YACjE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAA0B;SAC5F,CAAC,CAAC;IACL,CAAC;IAqFD,QAAQ,CAAkB,IAIzB;QACC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEtC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IA+BD,QAAQ,CAAkB,IAGzB;QACC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEhC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { MetadataRegistry } from '@/helpers/inversion';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { resolveValue } from '@venizia/ignis-helpers/common';\nimport { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';\nimport type {\n IExtraOptions,\n IPersistableRepository,\n IWithReadRetry,\n TCount,\n TDataWithRange,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TRepositoryOperationScope,\n} from '../common';\n// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is\n// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.\nimport {\n DEFAULT_MAX_LIMIT,\n RepositoryErrorCodes,\n RepositoryOperationScopes,\n} from '../common/constants';\nimport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TWhere,\n} from '@venizia/ignis-filter';\n\n/**\n * Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`\n * settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it\n * while staying assignable to this base.\n */\nexport abstract class AbstractRepository<\n TDataObject extends object,\n TPersistObject extends object = TDataObject,\n TOptions extends IExtraOptions = IExtraOptions,\n>\n extends BaseHelper\n implements IPersistableRepository<TDataObject, TPersistObject, TOptions>\n{\n protected _operationScope: TRepositoryOperationScope;\n\n /** Lazy-resolved on first access if not provided in constructor. */\n protected _dataSource?: AbstractDataSource;\n\n /** Lazy-resolved from @repository metadata on first access. */\n protected _entity?: AbstractEntity;\n\n /**\n * Memoized @model settings for `this.entity`'s class. `null` means not yet resolved - `undefined`\n * is itself a valid resolved value: the model declares no settings.\n */\n private _modelSettings: IModelMetadata['settings'] | null = null;\n\n constructor(\n dataSource?: AbstractDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<AbstractEntity>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n const scopeName =\n opts?.scope ??\n (opts?.entityClass?.name ? [opts.entityClass.name, 'Repository'].join('') : new.target.name);\n\n super({ scope: scopeName });\n\n this._operationScope = opts?.operationScope ?? RepositoryOperationScopes.READ_ONLY;\n\n if (dataSource) {\n this._dataSource = dataSource;\n }\n\n if (opts?.entityClass) {\n this._entity = new opts.entityClass();\n }\n }\n\n get dataSource(): AbstractDataSource {\n if (!this._dataSource) {\n throw getError({\n message: `[${this.constructor.name}] DataSource not available. Use @repository({ model: YourModel, dataSource: YourDataSource }) or pass dataSource in constructor.`,\n });\n }\n\n return this._dataSource;\n }\n\n set dataSource(value: AbstractDataSource) {\n this._dataSource = value;\n }\n\n /** Auto-resolves from @repository metadata if not explicitly set. */\n get entity(): AbstractEntity {\n this._entity ??= this.resolveEntity();\n return this._entity;\n }\n\n set entity(value: AbstractEntity) {\n this._entity = value;\n }\n\n get operationScope(): TRepositoryOperationScope {\n return this._operationScope;\n }\n\n setDataSource(opts: { dataSource: AbstractDataSource }): void {\n this._dataSource = opts.dataSource;\n }\n\n getEntity(): AbstractEntity {\n return this.entity;\n }\n\n /**\n * Resolved `@model` settings for `this.entity`'s class, keyed by Reflect target - not by\n * `entity.name`, which can diverge from the `@model` registry key.\n */\n protected get modelSettings(): IModelMetadata['settings'] {\n if (this._modelSettings !== null) {\n return this._modelSettings;\n }\n\n this._modelSettings = MetadataRegistry.getInstance().getModelMetadata({\n target: this.entity.constructor,\n })?.settings;\n\n return this._modelSettings;\n }\n\n protected get hiddenFields(): string[] {\n return this.modelSettings?.hiddenProperties ?? [];\n }\n\n /** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */\n protected get defaultWhere(): TWhere | undefined {\n return this.modelSettings?.query?.filter?.where;\n }\n\n protected get defaultLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.default;\n }\n\n /** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */\n protected get maxLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.max;\n }\n\n /**\n * Both bounds, in one place, for every tier.\n *\n * The upper bound is the point: `@model({ settings: { maxLimit } })` is public and validated at\n * decoration time, but the relational tier read it nowhere, so `maxLimit: 2` still issued\n * `LIMIT 50000000`.\n *\n * The lower bound matters just as much and is easy to miss: a NEGATIVE limit is not a smaller\n * page. Drizzle renders the LIMIT clause only when the value is `>= 0`, so a negative one removes\n * the clause and returns the whole table. The wire schema now rejects it too, but a server-side\n * caller reaches this method without passing through the schema at all.\n */\n protected assertLimitWithinCeiling(opts: { limit?: number; scope?: string }): void {\n const { limit, scope = 'find' } = opts;\n\n if (limit === undefined) {\n return;\n }\n\n // The shape check first, because it needs no metadata at all.\n if (!Number.isInteger(limit) || limit < 0) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' | Expected a non-negative integer | Got: ${limit}`,\n });\n }\n\n // `maxLimit` reaches `modelSettings`, which resolves the entity - and THAT throws for a\n // repository with no `@repository` model binding. Such a repository is a misconfiguration this\n // method has no business reporting, and the caller path that used to reach `getDefaultLimit()`\n // never touched it either, because `??` short-circuits when a limit is given. So the ceiling is\n // consulted only when the binding that makes it resolvable is actually present.\n const hasModelBinding = Boolean(\n MetadataRegistry.getInstance().getRepositoryBinding({ target: this.constructor })?.model,\n );\n const ceiling = (hasModelBinding ? this.maxLimit : undefined) ?? DEFAULT_MAX_LIMIT;\n\n if (limit > ceiling) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Requested page exceeds this model's limit | requested: ${limit} | maximum: ${ceiling} | raise it with @model settings.maxLimit if larger pages are genuinely needed`,\n });\n }\n }\n\n /**\n * The whole filter, relations included. Checking only the top-level `limit` left the identical\n * defect reachable one level down: a relation scope's negative limit drops Drizzle's LIMIT clause\n * for that relation and loads the entire related table.\n *\n * A relation's limit gets the SHAPE check only, not a ceiling. The ceiling belongs to the\n * relation's own model, which this repository cannot resolve - claiming otherwise would enforce\n * the parent's `maxLimit` on a different entity.\n */\n protected assertFilterLimits(opts: { filter?: TFilter; scope?: string }): void {\n const { filter, scope = 'find' } = opts;\n\n if (!filter) {\n return;\n }\n\n this.assertLimitWithinCeiling({ limit: filter.limit, scope });\n\n const walk = (inclusions: TInclusion[] | undefined, path: string): void => {\n const inclusionsList = inclusions ?? [];\n for (const inclusion of inclusionsList) {\n const relationScope = inclusion.scope;\n if (!relationScope) {\n continue;\n }\n\n const relationPath = `${path}.${inclusion.relation}`;\n const relationLimit = relationScope.limit;\n\n if (\n relationLimit !== undefined &&\n (!Number.isInteger(relationLimit) || relationLimit < 0)\n ) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' on relation scope | relation: ${relationPath} | Expected a non-negative integer | Got: ${relationLimit}`,\n });\n }\n\n walk(relationScope.include, relationPath);\n }\n };\n\n walk(filter.include, scope);\n }\n\n /** Resolves the entity instance from @repository metadata on first access. */\n protected resolveEntity(): AbstractEntity {\n const registry = MetadataRegistry.getInstance();\n const binding = registry.getRepositoryBinding({ target: this.constructor });\n\n if (!binding?.model) {\n throw getError({\n message: `[${this.constructor.name}] Cannot resolve entity. Either pass entityClass in constructor or use @repository decorator with model option.`,\n });\n }\n\n // resolveValue() erases to the resolved value's structural type, not this class-or-resolver\n // union's member - the `@repository` decorator guarantees a class constructor here.\n const ModelClass = resolveValue({ value: binding.model }) as TClass<AbstractEntity>;\n return new ModelClass();\n }\n\n /** Rejects a verb the current operation scope does not permit. */\n protected denyOperation(opts: { methodName: string }): never {\n throw getError({\n messageCode: RepositoryErrorCodes.OPERATION_NOT_ALLOWED,\n message: `[${opts.methodName}] Repository operation is NOT ALLOWED | scope: ${this.operationScope}`,\n });\n }\n\n /**\n * Shared retry orchestration for read verbs. Inside a transaction retry is skipped - the pool\n * routes transactions to the primary, so there is no replica lag to wait out.\n */\n protected executeReadWithRetry<TResult>(opts: {\n operation: string;\n options: IExtraOptions & IWithReadRetry<TResult>;\n defaultUntil: (result: TResult) => boolean;\n execution: () => Promise<TResult>;\n }): Promise<TResult> {\n const { operation, options, defaultUntil, execution } = opts;\n\n if (!options.retry) {\n return execution();\n }\n\n if (options.transaction) {\n this.logger.for(operation).debug('Read retry skipped inside transaction');\n return execution();\n }\n\n const { maxAttempts, maxTotalMs, signal, backoff, until } = options.retry;\n\n return RetryHelper.executeWithRetryUntil<TResult>({\n operation: [this.constructor.name, operation].join('.'),\n execution,\n until: until ?? defaultUntil,\n maxAttempts,\n maxTotalMs,\n signal,\n backoff: backoff ?? {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: 50,\n maxDelayMs: 500,\n jitter: RetryJitterModes.EQUAL,\n },\n logger: this.logger,\n });\n }\n\n /**\n * A copy of `options` without `retry`, so re-entering a read verb takes its non-retry path - this\n * is what keeps the retry recursion single-depth. Copy-then-delete rather than a rest-destructure\n * (lint rejects the unused rest sibling) or `lodash/omit` (its `Omit<>` return type is not\n * assignable back to `TOptions`).\n */\n private omitReadRetry<TReadOptions extends { retry?: unknown }>(\n options: TReadOptions,\n ): TReadOptions {\n const rest = { ...options };\n delete rest.retry;\n return rest;\n }\n\n /** `find`, re-executed until the retry predicate holds - connectors dispatch here from `find` when `options.retry` is set. */\n protected findUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOptions<TOptions, R>;\n }): Promise<Array<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<Array<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.length > 0,\n // `R` is named here, so the row is `R`; TypeScript cannot resolve `TRow` for an unresolved `R`.\n execution: () => this.find<R>({ filter: opts.filter, options }) as Promise<Array<R>>,\n });\n }\n\n /** `find` with the range envelope, re-executed until the retry predicate holds - split from `findUntil` so each result shape is checked against its own `find` overload. */\n protected findRangeUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<TOptions, R>;\n }): Promise<TDataWithRange<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TDataWithRange<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.data.length > 0,\n execution: () =>\n this.find<R>({ filter: opts.filter, options }) as unknown as Promise<TDataWithRange<R>>,\n });\n }\n\n /** `findOne`, re-executed until the retry predicate holds - also serves `findById` via its findOne delegation. */\n protected findOneUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TNullable<R>>({\n operation: 'findOne',\n options: opts.options,\n defaultUntil: (result) => result !== null && result !== undefined,\n execution: () => this.findOne<R>({ filter: opts.filter, options }) as Promise<TNullable<R>>,\n });\n }\n\n abstract count(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<TCount>;\n\n abstract existsWith(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<boolean>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options: TFindRangeOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<Array<TRow<TDataObject, R, F>>>;\n\n abstract findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract findById<\n R = unknown,\n const F extends TFields<TDataObject> = TFields<TDataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract create(opts: {\n data: TPersistObject;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract create<R = TDataObject>(opts: {\n data: TPersistObject;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract createAll(opts: {\n data: Array<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract createAll<R = TDataObject>(opts: {\n data: Array<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract updateById(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateById<R = TDataObject>(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract updateAll(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateAll<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n /** Alias for updateAll. */\n updateBy(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { data, where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.updateAll({ data, where, options: { ...options, shouldReturn: false } });\n }\n\n return this.updateAll<R>({ data, where, options });\n }\n\n abstract deleteById(opts: {\n id: IdType;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteById<R = TDataObject>(opts: {\n id: IdType;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract deleteAll(opts: {\n where?: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteAll<R = TDataObject>(opts: {\n where?: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n /** Alias for deleteAll. */\n deleteBy(opts: {\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.deleteAll({ where, options: { ...options, shouldReturn: false } });\n }\n\n return this.deleteAll<R>({ where, options });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAYpG,sGAAsG;AACtG,sFAAsF;AACtF,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAU7B;;;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MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;YACjE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAA0B;SAC5F,CAAC,CAAC;IACL,CAAC;IAqFD,QAAQ,CAAkB,IAIzB;QACC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEtC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACvF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IA+BD,QAAQ,CAAkB,IAGzB;QACC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEhC,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,IAAI,CAAC,SAAS,CAAI,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { IModelMetadata } from '@/helpers/inversion';\nimport { MetadataRegistry } from '@/helpers/inversion';\nimport type { TClass, TNullable } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ResolverUtility } from '@venizia/ignis-helpers/common';\nimport { RetryBackoffStrategies, RetryHelper, RetryJitterModes } from '@venizia/ignis-helpers/core';\nimport type {\n IExtraOptions,\n IPersistableRepository,\n IWithReadRetry,\n TCount,\n TDataWithRange,\n TFindOneOptions,\n TFindOptions,\n TFindRangeOptions,\n TRepositoryOperationScope,\n} from '../common';\n// The file, not the `../common` barrel: the barrel re-exports the OpenAPI schemas, and this module is\n// on the `./repository` entry, which must load without `@hono/zod-openapi` installed.\nimport {\n DEFAULT_MAX_LIMIT,\n RepositoryErrorCodes,\n RepositoryOperationScopes,\n} from '../common/constants';\nimport type {\n TByIdFilter,\n TFields,\n TFilter,\n TInclusion,\n TRow,\n TWhere,\n} from '@venizia/ignis-filter';\n\n/**\n * Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`\n * settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it\n * while staying assignable to this base.\n */\nexport abstract class AbstractRepository<\n TDataObject extends object,\n TPersistObject extends object = TDataObject,\n TOptions extends IExtraOptions = IExtraOptions,\n>\n extends BaseHelper\n implements IPersistableRepository<TDataObject, TPersistObject, TOptions>\n{\n protected _operationScope: TRepositoryOperationScope;\n\n /** Lazy-resolved on first access if not provided in constructor. */\n protected _dataSource?: AbstractDataSource;\n\n /** Lazy-resolved from @repository metadata on first access. */\n protected _entity?: AbstractEntity;\n\n /**\n * Memoized @model settings for `this.entity`'s class. `null` means not yet resolved - `undefined`\n * is itself a valid resolved value: the model declares no settings.\n */\n private _modelSettings: IModelMetadata['settings'] | null = null;\n\n constructor(\n dataSource?: AbstractDataSource,\n opts?: {\n scope?: string;\n entityClass?: TClass<AbstractEntity>;\n operationScope?: TRepositoryOperationScope;\n },\n ) {\n const scopeName =\n opts?.scope ??\n (opts?.entityClass?.name ? [opts.entityClass.name, 'Repository'].join('') : new.target.name);\n\n super({ scope: scopeName });\n\n this._operationScope = opts?.operationScope ?? RepositoryOperationScopes.READ_ONLY;\n\n if (dataSource) {\n this._dataSource = dataSource;\n }\n\n if (opts?.entityClass) {\n this._entity = new opts.entityClass();\n }\n }\n\n get dataSource(): AbstractDataSource {\n if (!this._dataSource) {\n throw getError({\n message: `[${this.constructor.name}] DataSource not available. Use @repository({ model: YourModel, dataSource: YourDataSource }) or pass dataSource in constructor.`,\n });\n }\n\n return this._dataSource;\n }\n\n set dataSource(value: AbstractDataSource) {\n this._dataSource = value;\n }\n\n /** Auto-resolves from @repository metadata if not explicitly set. */\n get entity(): AbstractEntity {\n this._entity ??= this.resolveEntity();\n return this._entity;\n }\n\n set entity(value: AbstractEntity) {\n this._entity = value;\n }\n\n get operationScope(): TRepositoryOperationScope {\n return this._operationScope;\n }\n\n setDataSource(opts: { dataSource: AbstractDataSource }): void {\n this._dataSource = opts.dataSource;\n }\n\n getEntity(): AbstractEntity {\n return this.entity;\n }\n\n /**\n * Resolved `@model` settings for `this.entity`'s class, keyed by Reflect target - not by\n * `entity.name`, which can diverge from the `@model` registry key.\n */\n protected get modelSettings(): IModelMetadata['settings'] {\n if (this._modelSettings !== null) {\n return this._modelSettings;\n }\n\n this._modelSettings = MetadataRegistry.getInstance().getModelMetadata({\n target: this.entity.constructor,\n })?.settings;\n\n return this._modelSettings;\n }\n\n protected get hiddenFields(): string[] {\n return this.modelSettings?.hiddenProperties ?? [];\n }\n\n /** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */\n protected get defaultWhere(): TWhere | undefined {\n return this.modelSettings?.query?.filter?.where;\n }\n\n protected get defaultLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.default;\n }\n\n /** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */\n protected get maxLimit(): number | undefined {\n return this.modelSettings?.query?.limit?.max;\n }\n\n /**\n * Both bounds, in one place, for every tier.\n *\n * The upper bound is the point: `@model({ settings: { maxLimit } })` is public and validated at\n * decoration time, but the relational tier read it nowhere, so `maxLimit: 2` still issued\n * `LIMIT 50000000`.\n *\n * The lower bound matters just as much and is easy to miss: a NEGATIVE limit is not a smaller\n * page. Drizzle renders the LIMIT clause only when the value is `>= 0`, so a negative one removes\n * the clause and returns the whole table. The wire schema now rejects it too, but a server-side\n * caller reaches this method without passing through the schema at all.\n */\n protected assertLimitWithinCeiling(opts: { limit?: number; scope?: string }): void {\n const { limit, scope = 'find' } = opts;\n\n if (limit === undefined) {\n return;\n }\n\n // The shape check first, because it needs no metadata at all.\n if (!Number.isInteger(limit) || limit < 0) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' | Expected a non-negative integer | Got: ${limit}`,\n });\n }\n\n // `maxLimit` reaches `modelSettings`, which resolves the entity - and THAT throws for a\n // repository with no `@repository` model binding. Such a repository is a misconfiguration this\n // method has no business reporting, and the caller path that used to reach `getDefaultLimit()`\n // never touched it either, because `??` short-circuits when a limit is given. So the ceiling is\n // consulted only when the binding that makes it resolvable is actually present.\n const hasModelBinding = Boolean(\n MetadataRegistry.getInstance().getRepositoryBinding({ target: this.constructor })?.model,\n );\n const ceiling = (hasModelBinding ? this.maxLimit : undefined) ?? DEFAULT_MAX_LIMIT;\n\n if (limit > ceiling) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Requested page exceeds this model's limit | requested: ${limit} | maximum: ${ceiling} | raise it with @model settings.maxLimit if larger pages are genuinely needed`,\n });\n }\n }\n\n /**\n * The whole filter, relations included. Checking only the top-level `limit` left the identical\n * defect reachable one level down: a relation scope's negative limit drops Drizzle's LIMIT clause\n * for that relation and loads the entire related table.\n *\n * A relation's limit gets the SHAPE check only, not a ceiling. The ceiling belongs to the\n * relation's own model, which this repository cannot resolve - claiming otherwise would enforce\n * the parent's `maxLimit` on a different entity.\n */\n protected assertFilterLimits(opts: { filter?: TFilter; scope?: string }): void {\n const { filter, scope = 'find' } = opts;\n\n if (!filter) {\n return;\n }\n\n this.assertLimitWithinCeiling({ limit: filter.limit, scope });\n\n const walk = (inclusions: TInclusion[] | undefined, path: string): void => {\n const inclusionsList = inclusions ?? [];\n for (const inclusion of inclusionsList) {\n const relationScope = inclusion.scope;\n if (!relationScope) {\n continue;\n }\n\n const relationPath = `${path}.${inclusion.relation}`;\n const relationLimit = relationScope.limit;\n\n if (\n relationLimit !== undefined &&\n (!Number.isInteger(relationLimit) || relationLimit < 0)\n ) {\n throw getError({\n message: `[${this.constructor.name}][${scope}] Invalid 'limit' on relation scope | relation: ${relationPath} | Expected a non-negative integer | Got: ${relationLimit}`,\n });\n }\n\n walk(relationScope.include, relationPath);\n }\n };\n\n walk(filter.include, scope);\n }\n\n /** Resolves the entity instance from @repository metadata on first access. */\n protected resolveEntity(): AbstractEntity {\n const registry = MetadataRegistry.getInstance();\n const binding = registry.getRepositoryBinding({ target: this.constructor });\n\n if (!binding?.model) {\n throw getError({\n message: `[${this.constructor.name}] Cannot resolve entity. Either pass entityClass in constructor or use @repository decorator with model option.`,\n });\n }\n\n // ResolverUtility.resolveValue() erases to the resolved value's structural type, not this class-or-resolver\n // union's member - the `@repository` decorator guarantees a class constructor here.\n const ModelClass = ResolverUtility.resolveValue({\n value: binding.model,\n }) as TClass<AbstractEntity>;\n return new ModelClass();\n }\n\n /** Rejects a verb the current operation scope does not permit. */\n protected denyOperation(opts: { methodName: string }): never {\n throw getError({\n messageCode: RepositoryErrorCodes.OPERATION_NOT_ALLOWED,\n message: `[${opts.methodName}] Repository operation is NOT ALLOWED | scope: ${this.operationScope}`,\n });\n }\n\n /**\n * Shared retry orchestration for read verbs. Inside a transaction retry is skipped - the pool\n * routes transactions to the primary, so there is no replica lag to wait out.\n */\n protected executeReadWithRetry<TResult>(opts: {\n operation: string;\n options: IExtraOptions & IWithReadRetry<TResult>;\n defaultUntil: (result: TResult) => boolean;\n execution: () => Promise<TResult>;\n }): Promise<TResult> {\n const { operation, options, defaultUntil, execution } = opts;\n\n if (!options.retry) {\n return execution();\n }\n\n if (options.transaction) {\n this.logger.for(operation).debug('Read retry skipped inside transaction');\n return execution();\n }\n\n const { maxAttempts, maxTotalMs, signal, backoff, until } = options.retry;\n\n return RetryHelper.executeWithRetryUntil<TResult>({\n operation: [this.constructor.name, operation].join('.'),\n execution,\n until: until ?? defaultUntil,\n maxAttempts,\n maxTotalMs,\n signal,\n backoff: backoff ?? {\n strategy: RetryBackoffStrategies.EXPONENTIAL,\n initialDelayMs: 50,\n maxDelayMs: 500,\n jitter: RetryJitterModes.EQUAL,\n },\n logger: this.logger,\n });\n }\n\n /**\n * A copy of `options` without `retry`, so re-entering a read verb takes its non-retry path - this\n * is what keeps the retry recursion single-depth. Copy-then-delete rather than a rest-destructure\n * (lint rejects the unused rest sibling) or `lodash/omit` (its `Omit<>` return type is not\n * assignable back to `TOptions`).\n */\n private omitReadRetry<TReadOptions extends { retry?: unknown }>(\n options: TReadOptions,\n ): TReadOptions {\n const rest = { ...options };\n delete rest.retry;\n return rest;\n }\n\n /** `find`, re-executed until the retry predicate holds - connectors dispatch here from `find` when `options.retry` is set. */\n protected findUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOptions<TOptions, R>;\n }): Promise<Array<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<Array<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.length > 0,\n // `R` is named here, so the row is `R`; TypeScript cannot resolve `TRow` for an unresolved `R`.\n execution: () => this.find<R>({ filter: opts.filter, options }) as Promise<Array<R>>,\n });\n }\n\n /** `find` with the range envelope, re-executed until the retry predicate holds - split from `findUntil` so each result shape is checked against its own `find` overload. */\n protected findRangeUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<TOptions, R>;\n }): Promise<TDataWithRange<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TDataWithRange<R>>({\n operation: 'find',\n options: opts.options,\n defaultUntil: (result) => result.data.length > 0,\n execution: () =>\n this.find<R>({ filter: opts.filter, options }) as unknown as Promise<TDataWithRange<R>>,\n });\n }\n\n /** `findOne`, re-executed until the retry predicate holds - also serves `findById` via its findOne delegation. */\n protected findOneUntil<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>> {\n const options = this.omitReadRetry(opts.options);\n\n return this.executeReadWithRetry<TNullable<R>>({\n operation: 'findOne',\n options: opts.options,\n defaultUntil: (result) => result !== null && result !== undefined,\n execution: () => this.findOne<R>({ filter: opts.filter, options }) as Promise<TNullable<R>>,\n });\n }\n\n abstract count(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<TCount>;\n\n abstract existsWith(opts: { where: TWhere<TDataObject>; options?: TOptions }): Promise<boolean>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options: TFindRangeOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;\n\n abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<Array<TRow<TDataObject, R, F>>>;\n\n abstract findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract findById<\n R = unknown,\n const F extends TFields<TDataObject> = TFields<TDataObject>,\n >(opts: {\n id: IdType;\n filter?: TByIdFilter<TDataObject, F>;\n options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n abstract create(opts: {\n data: TPersistObject;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract create<R = TDataObject>(opts: {\n data: TPersistObject;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract createAll(opts: {\n data: Array<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract createAll<R = TDataObject>(opts: {\n data: Array<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n\n abstract updateById(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateById<R = TDataObject>(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract updateAll(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract updateAll<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n /** Alias for updateAll. */\n updateBy(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { data, where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.updateAll({ data, where, options: { ...options, shouldReturn: false } });\n }\n\n return this.updateAll<R>({ data, where, options });\n }\n\n abstract deleteById(opts: {\n id: IdType;\n options: TOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteById<R = TDataObject>(opts: {\n id: IdType;\n options?: TOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n abstract deleteAll(opts: {\n where?: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n abstract deleteAll<R = TDataObject>(opts: {\n where?: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n\n /** Alias for deleteAll. */\n deleteBy(opts: {\n where: TWhere<TDataObject>;\n options: TOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n deleteBy<R = TDataObject>(opts: {\n where: TWhere<TDataObject>;\n options?: TOptions & { shouldReturn?: boolean; force?: boolean };\n }): Promise<TCount & { data: TNullable<Array<R>> }> {\n const { where, options } = opts;\n\n if (options?.shouldReturn === false) {\n return this.deleteAll({ where, options: { ...options, shouldReturn: false } });\n }\n\n return this.deleteAll<R>({ where, options });\n }\n}\n"]}
|