@venizia/ignis-kernel 0.4.0 → 0.4.2
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/dist/cjs/base/applications/abstract.js +2 -2
- package/dist/cjs/base/applications/abstract.js.map +1 -1
- package/dist/cjs/base/applications/artifact-group.js +1 -1
- package/dist/cjs/base/applications/artifact-group.js.map +1 -1
- package/dist/cjs/base/applications/artifact-index.js +11 -11
- package/dist/cjs/base/applications/artifact-index.js.map +1 -1
- package/dist/cjs/base/applications/boot-sequence.js +1 -1
- package/dist/cjs/base/applications/boot-sequence.js.map +1 -1
- package/dist/cjs/base/applications/cors.d.ts +13 -0
- package/dist/cjs/base/applications/cors.d.ts.map +1 -0
- package/dist/cjs/base/applications/cors.js +43 -0
- package/dist/cjs/base/applications/cors.js.map +1 -0
- package/dist/cjs/base/applications/deprecations.d.ts +10 -0
- package/dist/cjs/base/applications/deprecations.d.ts.map +1 -0
- package/dist/cjs/base/applications/deprecations.js +23 -0
- package/dist/cjs/base/applications/deprecations.js.map +1 -0
- package/dist/cjs/base/applications/rest.d.ts.map +1 -1
- package/dist/cjs/base/applications/rest.js +11 -5
- package/dist/cjs/base/applications/rest.js.map +1 -1
- package/dist/cjs/base/auth/authenticate/common/codecs.js +2 -2
- package/dist/cjs/base/auth/authenticate/common/codecs.js.map +1 -1
- package/dist/cjs/base/auth/authenticate/providers/authentication.provider.js +1 -1
- package/dist/cjs/base/auth/authenticate/providers/authentication.provider.js.map +1 -1
- package/dist/cjs/base/auth/authenticate/strategies/strategy-registry.js +1 -1
- package/dist/cjs/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
- package/dist/cjs/base/auth/authorize/builders/grant.builder.js +12 -12
- package/dist/cjs/base/auth/authorize/builders/grant.builder.js.map +1 -1
- package/dist/cjs/base/auth/authorize/builders/permission.builder.js +1 -1
- package/dist/cjs/base/auth/authorize/builders/permission.builder.js.map +1 -1
- package/dist/cjs/base/auth/authorize/builders/policy.builder.js +1 -1
- package/dist/cjs/base/auth/authorize/builders/policy.builder.js.map +1 -1
- package/dist/cjs/base/auth/authorize/common/constants/authorization.d.ts.map +1 -1
- package/dist/cjs/base/auth/authorize/common/constants/authorization.js +2 -2
- package/dist/cjs/base/auth/authorize/common/constants/authorization.js.map +1 -1
- package/dist/cjs/base/auth/authorize/enforcers/enforcer-registry.js +1 -1
- package/dist/cjs/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
- package/dist/cjs/base/auth/authorize/providers/authorization.provider.js +3 -3
- package/dist/cjs/base/auth/authorize/providers/authorization.provider.js.map +1 -1
- package/dist/cjs/base/controllers/factory/authorize-guard.d.ts +19 -0
- package/dist/cjs/base/controllers/factory/authorize-guard.d.ts.map +1 -0
- package/dist/cjs/base/controllers/factory/authorize-guard.js +60 -0
- package/dist/cjs/base/controllers/factory/authorize-guard.js.map +1 -0
- package/dist/cjs/base/controllers/factory/controller.d.ts +2 -2
- package/dist/cjs/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/cjs/base/controllers/factory/controller.js +9 -0
- package/dist/cjs/base/controllers/factory/controller.js.map +1 -1
- package/dist/cjs/base/controllers/factory/crud/abstract.d.ts +1 -1
- package/dist/cjs/base/controllers/factory/crud/abstract.d.ts.map +1 -1
- package/dist/cjs/base/controllers/factory/crud/abstract.js.map +1 -1
- package/dist/cjs/base/controllers/factory/definition.js +1 -1
- package/dist/cjs/base/controllers/factory/definition.js.map +1 -1
- package/dist/cjs/base/controllers/rest/extras.js +5 -5
- package/dist/cjs/base/controllers/rest/extras.js.map +1 -1
- package/dist/cjs/base/metadata/injectable.js +1 -1
- package/dist/cjs/base/metadata/injectable.js.map +1 -1
- package/dist/cjs/base/metadata/model-settings.d.ts +21 -0
- package/dist/cjs/base/metadata/model-settings.d.ts.map +1 -0
- package/dist/cjs/base/metadata/model-settings.js +77 -0
- package/dist/cjs/base/metadata/model-settings.js.map +1 -0
- package/dist/cjs/base/metadata/persistents.d.ts +1 -1
- package/dist/cjs/base/metadata/persistents.d.ts.map +1 -1
- package/dist/cjs/base/metadata/persistents.js +24 -12
- package/dist/cjs/base/metadata/persistents.js.map +1 -1
- package/dist/cjs/base/metadata/routes/controller.js +1 -1
- package/dist/cjs/base/metadata/routes/controller.js.map +1 -1
- package/dist/cjs/base/middlewares/app-error/app-error.middleware.js +3 -3
- package/dist/cjs/base/middlewares/app-error/app-error.middleware.js.map +1 -1
- package/dist/cjs/base/middlewares/app-error/zod.handler.js +2 -2
- package/dist/cjs/base/middlewares/app-error/zod.handler.js.map +1 -1
- package/dist/cjs/base/middlewares/form-body/form-body.middleware.js +2 -2
- package/dist/cjs/base/middlewares/form-body/form-body.middleware.js.map +1 -1
- package/dist/cjs/base/middlewares/not-found/not-found.middleware.js.map +1 -1
- package/dist/cjs/base/models/common/utilities.js +1 -1
- package/dist/cjs/base/models/common/utilities.js.map +1 -1
- package/dist/cjs/base/repositories/common/constants.d.ts +18 -1
- package/dist/cjs/base/repositories/common/constants.d.ts.map +1 -1
- package/dist/cjs/base/repositories/common/constants.js +22 -2
- package/dist/cjs/base/repositories/common/constants.js.map +1 -1
- package/dist/cjs/base/repositories/common/types/contracts.d.ts +17 -17
- package/dist/cjs/base/repositories/common/types/contracts.d.ts.map +1 -1
- package/dist/cjs/base/repositories/common/types/contracts.js.map +1 -1
- package/dist/cjs/base/repositories/core/abstract.d.ts +18 -18
- package/dist/cjs/base/repositories/core/abstract.d.ts.map +1 -1
- package/dist/cjs/base/repositories/core/abstract.js +8 -7
- package/dist/cjs/base/repositories/core/abstract.js.map +1 -1
- package/dist/cjs/helpers/inversion/common/types/model.d.ts +94 -22
- package/dist/cjs/helpers/inversion/common/types/model.d.ts.map +1 -1
- package/dist/cjs/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/cjs/helpers/inversion/mixins/model.mixin.js +1 -1
- package/dist/cjs/helpers/inversion/mixins/model.mixin.js.map +1 -1
- package/dist/cjs/helpers/inversion/mixins/repository.mixin.js +1 -1
- package/dist/cjs/helpers/inversion/mixins/repository.mixin.js.map +1 -1
- package/dist/cjs/repository.d.ts +1 -1
- package/dist/cjs/repository.d.ts.map +1 -1
- package/dist/cjs/repository.js.map +1 -1
- package/dist/esm/base/applications/abstract.js +2 -2
- package/dist/esm/base/applications/abstract.js.map +1 -1
- package/dist/esm/base/applications/artifact-group.js +1 -1
- package/dist/esm/base/applications/artifact-group.js.map +1 -1
- package/dist/esm/base/applications/artifact-index.js +11 -11
- package/dist/esm/base/applications/artifact-index.js.map +1 -1
- package/dist/esm/base/applications/boot-sequence.js +1 -1
- package/dist/esm/base/applications/boot-sequence.js.map +1 -1
- package/dist/esm/base/applications/cors.d.ts +13 -0
- package/dist/esm/base/applications/cors.d.ts.map +1 -0
- package/dist/esm/base/applications/cors.js +39 -0
- package/dist/esm/base/applications/cors.js.map +1 -0
- package/dist/esm/base/applications/deprecations.d.ts +10 -0
- package/dist/esm/base/applications/deprecations.d.ts.map +1 -0
- package/dist/esm/base/applications/deprecations.js +19 -0
- package/dist/esm/base/applications/deprecations.js.map +1 -0
- package/dist/esm/base/applications/rest.d.ts.map +1 -1
- package/dist/esm/base/applications/rest.js +11 -5
- 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/providers/authentication.provider.js +1 -1
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.js.map +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/builders/grant.builder.js +12 -12
- package/dist/esm/base/auth/authorize/builders/grant.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/builders/permission.builder.js +1 -1
- package/dist/esm/base/auth/authorize/builders/permission.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/builders/policy.builder.js +1 -1
- package/dist/esm/base/auth/authorize/builders/policy.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/authorization.js +2 -2
- package/dist/esm/base/auth/authorize/common/constants/authorization.js.map +1 -1
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js +1 -1
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js +3 -3
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js.map +1 -1
- package/dist/esm/base/controllers/factory/authorize-guard.d.ts +19 -0
- package/dist/esm/base/controllers/factory/authorize-guard.d.ts.map +1 -0
- package/dist/esm/base/controllers/factory/authorize-guard.js +56 -0
- package/dist/esm/base/controllers/factory/authorize-guard.js.map +1 -0
- package/dist/esm/base/controllers/factory/controller.d.ts +2 -2
- package/dist/esm/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/controller.js +9 -0
- package/dist/esm/base/controllers/factory/controller.js.map +1 -1
- package/dist/esm/base/controllers/factory/crud/abstract.d.ts +1 -1
- package/dist/esm/base/controllers/factory/crud/abstract.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/crud/abstract.js.map +1 -1
- package/dist/esm/base/controllers/factory/definition.js +1 -1
- package/dist/esm/base/controllers/factory/definition.js.map +1 -1
- package/dist/esm/base/controllers/rest/extras.js +5 -5
- package/dist/esm/base/controllers/rest/extras.js.map +1 -1
- package/dist/esm/base/metadata/injectable.js +1 -1
- package/dist/esm/base/metadata/injectable.js.map +1 -1
- package/dist/esm/base/metadata/model-settings.d.ts +21 -0
- package/dist/esm/base/metadata/model-settings.d.ts.map +1 -0
- package/dist/esm/base/metadata/model-settings.js +73 -0
- package/dist/esm/base/metadata/model-settings.js.map +1 -0
- package/dist/esm/base/metadata/persistents.d.ts +1 -1
- package/dist/esm/base/metadata/persistents.d.ts.map +1 -1
- package/dist/esm/base/metadata/persistents.js +24 -12
- package/dist/esm/base/metadata/persistents.js.map +1 -1
- package/dist/esm/base/metadata/routes/controller.js +1 -1
- package/dist/esm/base/metadata/routes/controller.js.map +1 -1
- package/dist/esm/base/middlewares/app-error/app-error.middleware.js +3 -3
- package/dist/esm/base/middlewares/app-error/app-error.middleware.js.map +1 -1
- package/dist/esm/base/middlewares/app-error/zod.handler.js +2 -2
- package/dist/esm/base/middlewares/app-error/zod.handler.js.map +1 -1
- package/dist/esm/base/middlewares/form-body/form-body.middleware.js +2 -2
- package/dist/esm/base/middlewares/form-body/form-body.middleware.js.map +1 -1
- package/dist/esm/base/middlewares/not-found/not-found.middleware.js.map +1 -1
- package/dist/esm/base/models/common/utilities.js +1 -1
- package/dist/esm/base/models/common/utilities.js.map +1 -1
- package/dist/esm/base/repositories/common/constants.d.ts +18 -1
- package/dist/esm/base/repositories/common/constants.d.ts.map +1 -1
- package/dist/esm/base/repositories/common/constants.js +20 -1
- package/dist/esm/base/repositories/common/constants.js.map +1 -1
- package/dist/esm/base/repositories/common/types/contracts.d.ts +17 -17
- package/dist/esm/base/repositories/common/types/contracts.d.ts.map +1 -1
- package/dist/esm/base/repositories/common/types/contracts.js.map +1 -1
- package/dist/esm/base/repositories/core/abstract.d.ts +18 -18
- package/dist/esm/base/repositories/core/abstract.d.ts.map +1 -1
- package/dist/esm/base/repositories/core/abstract.js +8 -7
- package/dist/esm/base/repositories/core/abstract.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.d.ts +94 -22
- package/dist/esm/helpers/inversion/common/types/model.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/esm/helpers/inversion/mixins/model.mixin.js +1 -1
- package/dist/esm/helpers/inversion/mixins/model.mixin.js.map +1 -1
- package/dist/esm/helpers/inversion/mixins/repository.mixin.js +1 -1
- package/dist/esm/helpers/inversion/mixins/repository.mixin.js.map +1 -1
- package/dist/esm/repository.d.ts +1 -1
- package/dist/esm/repository.d.ts.map +1 -1
- package/dist/esm/repository.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AbstractDataSource } from '../../../datasources';
|
|
2
2
|
import type { AbstractEntity, IdType } from '../../../models';
|
|
3
|
-
import type { TFilter, TWhere } from '@venizia/ignis-filter';
|
|
3
|
+
import type { TByIdFilter, TFields, TFilter, TRow, TWhere } from '@venizia/ignis-filter';
|
|
4
4
|
import type { TNullable } from '@venizia/ignis-helpers/common';
|
|
5
5
|
import type { IExtraOptions, TFindOneOptions, TFindOptions, TFindRangeOptions } from './options';
|
|
6
6
|
import type { TCount, TDataWithRange } from './results';
|
|
@@ -23,23 +23,23 @@ export interface IReadableRepository<TDataObject extends object = object, ExtraO
|
|
|
23
23
|
where: TWhere<TDataObject>;
|
|
24
24
|
options?: ExtraOptions;
|
|
25
25
|
}): Promise<boolean>;
|
|
26
|
-
find<R = TDataObject>(opts: {
|
|
27
|
-
filter: TFilter<TDataObject>;
|
|
28
|
-
options: TFindRangeOptions<ExtraOptions, R
|
|
29
|
-
}): Promise<TDataWithRange<R
|
|
30
|
-
find<R = TDataObject>(opts: {
|
|
31
|
-
filter: TFilter<TDataObject>;
|
|
32
|
-
options?: TFindOptions<ExtraOptions, R
|
|
33
|
-
}): Promise<Array<R
|
|
34
|
-
findOne<R = TDataObject>(opts: {
|
|
35
|
-
filter: TFilter<TDataObject>;
|
|
36
|
-
options?: TFindOneOptions<ExtraOptions, R
|
|
37
|
-
}): Promise<TNullable<R
|
|
38
|
-
findById<R = TDataObject>(opts: {
|
|
26
|
+
find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
27
|
+
filter: TFilter<TDataObject, F>;
|
|
28
|
+
options: TFindRangeOptions<ExtraOptions, TRow<TDataObject, R, F>>;
|
|
29
|
+
}): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;
|
|
30
|
+
find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
31
|
+
filter: TFilter<TDataObject, F>;
|
|
32
|
+
options?: TFindOptions<ExtraOptions, TRow<TDataObject, R, F>>;
|
|
33
|
+
}): Promise<Array<TRow<TDataObject, R, F>>>;
|
|
34
|
+
findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
35
|
+
filter: TFilter<TDataObject, F>;
|
|
36
|
+
options?: TFindOneOptions<ExtraOptions, TRow<TDataObject, R, F>>;
|
|
37
|
+
}): Promise<TNullable<TRow<TDataObject, R, F>>>;
|
|
38
|
+
findById<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
39
39
|
id: IdType;
|
|
40
|
-
filter?:
|
|
41
|
-
options?: TFindOneOptions<ExtraOptions, R
|
|
42
|
-
}): Promise<TNullable<R
|
|
40
|
+
filter?: TByIdFilter<TDataObject, F>;
|
|
41
|
+
options?: TFindOneOptions<ExtraOptions, TRow<TDataObject, R, F>>;
|
|
42
|
+
}): Promise<TNullable<TRow<TDataObject, R, F>>>;
|
|
43
43
|
}
|
|
44
44
|
/** Interface for create operations. */
|
|
45
45
|
export interface ICreatableRepository<TDataObject extends object = object, TPersistObject extends object = TDataObject, ExtraOptions extends IExtraOptions = IExtraOptions> extends IRepository {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/contracts.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,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7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3,"file":"contracts.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/contracts.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { TFilter, TWhere } from '@venizia/ignis-filter';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { IExtraOptions, TFindOneOptions, TFindOptions, TFindRangeOptions } from './options';\nimport type { TCount, TDataWithRange } from './results';\n\n/**\n * Base repository interface shared by every engine - engine-specific accessors (postgres's\n * `getEntitySchema()`/`getConnector()`) stay on the connector's own repository tier.\n */\nexport interface IRepository {\n dataSource: AbstractDataSource;\n entity: AbstractEntity;\n getEntity(): AbstractEntity;\n}\n\n/** Interface for read-only repository operations. `TDataObject` is the row/document shape itself. */\nexport interface IReadableRepository<\n TDataObject extends object = object,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n> extends IRepository {\n count(opts: { where: TWhere<TDataObject>; options?: ExtraOptions }): Promise<TCount>;\n existsWith(opts: { where: TWhere<TDataObject>; options?: ExtraOptions }): Promise<boolean>;\n\n find<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<ExtraOptions, R
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../../../../src/base/repositories/common/types/contracts.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractDataSource } from '@/base/datasources';\nimport type { AbstractEntity, IdType } from '@/base/models';\nimport type { TByIdFilter, TFields, TFilter, TRow, TWhere } from '@venizia/ignis-filter';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\nimport type { IExtraOptions, TFindOneOptions, TFindOptions, TFindRangeOptions } from './options';\nimport type { TCount, TDataWithRange } from './results';\n\n/**\n * Base repository interface shared by every engine - engine-specific accessors (postgres's\n * `getEntitySchema()`/`getConnector()`) stay on the connector's own repository tier.\n */\nexport interface IRepository {\n dataSource: AbstractDataSource;\n entity: AbstractEntity;\n getEntity(): AbstractEntity;\n}\n\n/** Interface for read-only repository operations. `TDataObject` is the row/document shape itself. */\nexport interface IReadableRepository<\n TDataObject extends object = object,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n> extends IRepository {\n count(opts: { where: TWhere<TDataObject>; options?: ExtraOptions }): Promise<TCount>;\n existsWith(opts: { where: TWhere<TDataObject>; options?: ExtraOptions }): Promise<boolean>;\n\n find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options: TFindRangeOptions<ExtraOptions, TRow<TDataObject, R, F>>;\n }): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;\n\n find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOptions<ExtraOptions, TRow<TDataObject, R, F>>;\n }): Promise<Array<TRow<TDataObject, R, F>>>;\n\n findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n filter: TFilter<TDataObject, F>;\n options?: TFindOneOptions<ExtraOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n\n findById<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {\n id: IdType;\n filter?: TByIdFilter<TDataObject, F>;\n options?: TFindOneOptions<ExtraOptions, TRow<TDataObject, R, F>>;\n }): Promise<TNullable<TRow<TDataObject, R, F>>>;\n}\n\n/** Interface for create operations. */\nexport interface ICreatableRepository<\n TDataObject extends object = object,\n TPersistObject extends object = TDataObject,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n> extends IRepository {\n create(opts: {\n data: TPersistObject;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n create<R = TDataObject>(opts: {\n data: TPersistObject;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n createAll(opts: {\n data: Array<TPersistObject>;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n createAll<R = TDataObject>(opts: {\n data: Array<TPersistObject>;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: Array<R> }>;\n}\n\n/** Interface for update operations. */\nexport interface IUpdatableRepository<\n TDataObject extends object = object,\n TPersistObject extends object = TDataObject,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n> extends IRepository {\n updateById(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n updateById<R = TDataObject>(opts: {\n id: IdType;\n data: Partial<TPersistObject>;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n updateAll(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n updateAll<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: ExtraOptions & { 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: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n /** Alias for updateAll. */\n updateBy<R = TDataObject>(opts: {\n data: Partial<TPersistObject>;\n where: TWhere<TDataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n}\n\n/** Interface for delete operations. */\nexport interface IDeletableRepository<\n TDataObject extends object = object,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n> extends IRepository {\n deleteById(opts: {\n id: IdType;\n options: ExtraOptions & { shouldReturn: false };\n }): Promise<TCount & { data: undefined | null }>;\n\n deleteById<R = TDataObject>(opts: {\n id: IdType;\n options?: ExtraOptions & { shouldReturn?: true };\n }): Promise<TCount & { data: R }>;\n\n deleteAll(opts: {\n where?: TWhere<TDataObject>;\n options: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n deleteAll<R = TDataObject>(opts: {\n where?: TWhere<TDataObject>;\n options?: ExtraOptions & { 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: ExtraOptions & { shouldReturn: false; force?: boolean };\n }): Promise<TCount & { data: undefined | null }>;\n\n /** Alias for deleteAll. */\n deleteBy<R = TDataObject>(opts: {\n where?: TWhere<TDataObject>;\n options?: ExtraOptions & { shouldReturn?: true; force?: boolean };\n }): Promise<TCount & { data: Array<R> | null }>;\n}\n\n/** Interface for full CRUD repository operations - reads plus create, update, and delete. */\nexport interface IPersistableRepository<\n TDataObject extends object = object,\n TPersistObject extends object = TDataObject,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n>\n extends\n IReadableRepository<TDataObject, ExtraOptions>,\n ICreatableRepository<TDataObject, TPersistObject, ExtraOptions>,\n IUpdatableRepository<TDataObject, TPersistObject, ExtraOptions>,\n IDeletableRepository<TDataObject, ExtraOptions> {}\n\n/**\n * Alias for IPersistableRepository - the name both DefaultRelationalRepository and\n * DefaultSearchRepository satisfy.\n */\nexport interface ICrudRepository<\n TDataObject extends object = object,\n TPersistObject extends object = TDataObject,\n ExtraOptions extends IExtraOptions = IExtraOptions,\n> extends IPersistableRepository<TDataObject, TPersistObject, ExtraOptions> {}\n"]}
|
|
@@ -4,7 +4,7 @@ import type { IModelMetadata } from '../../../helpers/inversion';
|
|
|
4
4
|
import type { TClass, TNullable } from '@venizia/ignis-helpers/common';
|
|
5
5
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
6
6
|
import type { IExtraOptions, IPersistableRepository, IWithReadRetry, TCount, TDataWithRange, TFindOneOptions, TFindOptions, TFindRangeOptions, TRepositoryOperationScope } from '../common';
|
|
7
|
-
import type { TFilter, TWhere } from '@venizia/ignis-filter';
|
|
7
|
+
import type { TByIdFilter, TFields, TFilter, TRow, TWhere } from '@venizia/ignis-filter';
|
|
8
8
|
/**
|
|
9
9
|
* Engine-neutral repository plumbing - lazy dataSource/entity resolution, class-keyed `@model`
|
|
10
10
|
* settings, operation scope. `TOptions` defaults to `IExtraOptions` so connectors can narrow it
|
|
@@ -42,7 +42,7 @@ export declare abstract class AbstractRepository<TDataObject extends object, TPe
|
|
|
42
42
|
*/
|
|
43
43
|
protected get modelSettings(): IModelMetadata['settings'];
|
|
44
44
|
protected get hiddenFields(): string[];
|
|
45
|
-
/** Default where from @model settings.
|
|
45
|
+
/** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */
|
|
46
46
|
protected get defaultWhere(): TWhere | undefined;
|
|
47
47
|
protected get defaultLimit(): number | undefined;
|
|
48
48
|
/** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */
|
|
@@ -122,23 +122,23 @@ export declare abstract class AbstractRepository<TDataObject extends object, TPe
|
|
|
122
122
|
where: TWhere<TDataObject>;
|
|
123
123
|
options?: TOptions;
|
|
124
124
|
}): Promise<boolean>;
|
|
125
|
-
abstract find<R = TDataObject>(opts: {
|
|
126
|
-
filter: TFilter<TDataObject>;
|
|
127
|
-
options: TFindRangeOptions<TOptions, R
|
|
128
|
-
}): Promise<TDataWithRange<R
|
|
129
|
-
abstract find<R = TDataObject>(opts: {
|
|
130
|
-
filter: TFilter<TDataObject>;
|
|
131
|
-
options?: TFindOptions<TOptions, R
|
|
132
|
-
}): Promise<R
|
|
133
|
-
abstract findOne<R = TDataObject>(opts: {
|
|
134
|
-
filter: TFilter<TDataObject>;
|
|
135
|
-
options?: TFindOneOptions<TOptions, R
|
|
136
|
-
}): Promise<TNullable<R
|
|
137
|
-
abstract findById<R = TDataObject>(opts: {
|
|
125
|
+
abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
126
|
+
filter: TFilter<TDataObject, F>;
|
|
127
|
+
options: TFindRangeOptions<TOptions, TRow<TDataObject, R, F>>;
|
|
128
|
+
}): Promise<TDataWithRange<TRow<TDataObject, R, F>>>;
|
|
129
|
+
abstract find<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
130
|
+
filter: TFilter<TDataObject, F>;
|
|
131
|
+
options?: TFindOptions<TOptions, TRow<TDataObject, R, F>>;
|
|
132
|
+
}): Promise<Array<TRow<TDataObject, R, F>>>;
|
|
133
|
+
abstract findOne<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
134
|
+
filter: TFilter<TDataObject, F>;
|
|
135
|
+
options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;
|
|
136
|
+
}): Promise<TNullable<TRow<TDataObject, R, F>>>;
|
|
137
|
+
abstract findById<R = unknown, const F extends TFields<TDataObject> = TFields<TDataObject>>(opts: {
|
|
138
138
|
id: IdType;
|
|
139
|
-
filter?:
|
|
140
|
-
options?: TFindOneOptions<TOptions, R
|
|
141
|
-
}): Promise<TNullable<R
|
|
139
|
+
filter?: TByIdFilter<TDataObject, F>;
|
|
140
|
+
options?: TFindOneOptions<TOptions, TRow<TDataObject, R, F>>;
|
|
141
|
+
}): Promise<TNullable<TRow<TDataObject, R, F>>>;
|
|
142
142
|
abstract create(opts: {
|
|
143
143
|
data: TPersistObject;
|
|
144
144
|
options: TOptions & {
|
|
@@ -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,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AAC;QAC5B,OAAO,CAAC,EAAE,QAAQ,GAAG;YAAE,YAAY,CAAC,EAAE,IAAI,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;KAC/D,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;IAE/C,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE;QACb,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3B,OAAO,EAAE,QAAQ,GAAG;YAAE,YAAY,EAAE,KAAK,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;KAC9D,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;KAAE,CAAC;IAChD,QAAQ,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,EAAE;QAC9B,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,QAAQ,GAAG;YAAE,YAAY,CAAC,EAAE,IAAI,CAAC;YAAC,KAAK,CAAC,EAAE,OAAO,CAAA;SAAE,CAAC;KAC/D,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;CAahD"}
|
|
@@ -75,16 +75,16 @@ class AbstractRepository extends core_1.BaseHelper {
|
|
|
75
75
|
get hiddenFields() {
|
|
76
76
|
return this.modelSettings?.hiddenProperties ?? [];
|
|
77
77
|
}
|
|
78
|
-
/** Default where from @model settings.
|
|
78
|
+
/** Default where from @model settings.query.filter.where, AND-merged into every query unless skipped. */
|
|
79
79
|
get defaultWhere() {
|
|
80
|
-
return this.modelSettings?.
|
|
80
|
+
return this.modelSettings?.query?.filter?.where;
|
|
81
81
|
}
|
|
82
82
|
get defaultLimit() {
|
|
83
|
-
return this.modelSettings?.
|
|
83
|
+
return this.modelSettings?.query?.limit?.default;
|
|
84
84
|
}
|
|
85
85
|
/** Largest `limit` a caller may ask for, when the model declares one; undefined leaves the tier's own default in force. */
|
|
86
86
|
get maxLimit() {
|
|
87
|
-
return this.modelSettings?.
|
|
87
|
+
return this.modelSettings?.query?.limit?.max;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* Both bounds, in one place, for every tier.
|
|
@@ -225,7 +225,8 @@ class AbstractRepository extends core_1.BaseHelper {
|
|
|
225
225
|
return this.executeReadWithRetry({
|
|
226
226
|
operation: 'find',
|
|
227
227
|
options: opts.options,
|
|
228
|
-
defaultUntil: result => result.length > 0,
|
|
228
|
+
defaultUntil: (result) => result.length > 0,
|
|
229
|
+
// `R` is named here, so the row is `R`; TypeScript cannot resolve `TRow` for an unresolved `R`.
|
|
229
230
|
execution: () => this.find({ filter: opts.filter, options }),
|
|
230
231
|
});
|
|
231
232
|
}
|
|
@@ -235,7 +236,7 @@ class AbstractRepository extends core_1.BaseHelper {
|
|
|
235
236
|
return this.executeReadWithRetry({
|
|
236
237
|
operation: 'find',
|
|
237
238
|
options: opts.options,
|
|
238
|
-
defaultUntil: result => result.data.length > 0,
|
|
239
|
+
defaultUntil: (result) => result.data.length > 0,
|
|
239
240
|
execution: () => this.find({ filter: opts.filter, options }),
|
|
240
241
|
});
|
|
241
242
|
}
|
|
@@ -245,7 +246,7 @@ class AbstractRepository extends core_1.BaseHelper {
|
|
|
245
246
|
return this.executeReadWithRetry({
|
|
246
247
|
operation: 'findOne',
|
|
247
248
|
options: opts.options,
|
|
248
|
-
defaultUntil: result => result !== null && result !== undefined,
|
|
249
|
+
defaultUntil: (result) => result !== null && result !== undefined,
|
|
249
250
|
execution: () => this.findOne({ filter: opts.filter, options }),
|
|
250
251
|
});
|
|
251
252
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../../src/base/repositories/core/abstract.ts"],"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,SAAS;YACpB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;YAC/D,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAkFD,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;AAhdD,gDAgdC","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 { TFilter, TInclusion, TWhere } 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.defaultFilter.where, AND-merged into every query unless skipped. */\n protected get defaultWhere(): TWhere | undefined {\n return this.modelSettings?.defaultFilter?.where;\n }\n\n protected get defaultLimit(): number | undefined {\n return this.modelSettings?.defaultLimit;\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?.maxLimit;\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 execution: () => this.find<R>({ filter: opts.filter, options }),\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: () => this.find<R>({ filter: opts.filter, options }),\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 }),\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 = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options: TFindRangeOptions<TOptions, R>;\n }): Promise<TDataWithRange<R>>;\n\n abstract find<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options?: TFindOptions<TOptions, R>;\n }): Promise<R[]>;\n\n abstract findOne<R = TDataObject>(opts: {\n filter: TFilter<TDataObject>;\n options?: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>>;\n\n abstract findById<R = TDataObject>(opts: {\n id: IdType;\n filter?: Omit<TFilter<TDataObject>, 'where'>;\n options?: TFindOneOptions<TOptions, R>;\n }): Promise<TNullable<R>>;\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,mDAAuD;AAEvD,sDAAmE;AACnE,0DAA6D;AAC7D,sDAAoG;AAYpG,sGAAsG;AACtG,sFAAsF;AACtF,mDAI6B;AAU7B;;;;GAIG;AACH,MAAsB,kBAKpB,SAAQ,iBAAU;IAiBlB,YACE,UAA+B,EAC/B,IAIC;QAED,MAAM,SAAS,GACb,IAAI,EAAE,KAAK;YACX,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/F,KAAK,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAlB9B;;;WAGG;QACK,mBAAc,GAAsC,IAAI,CAAC;QAgB/D,IAAI,CAAC,eAAe,GAAG,IAAI,EAAE,cAAc,IAAI,qCAAyB,CAAC,SAAS,CAAC;QAEnF,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAChC,CAAC;QAED,IAAI,IAAI,EAAE,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,GAAG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AQ,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;AArdD,gDAqdC","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,5 +1,5 @@
|
|
|
1
1
|
import type { AbstractEntity } from '../../../../base/models';
|
|
2
|
-
import type { ScopeFilters, TFilter, TScopeFilterMissingBehavior, TWhere } from '../../../../base/repositories';
|
|
2
|
+
import type { ScopeFilters, TFilter, TScopeFilterMissingBehavior, TScopeWriteGuard, TWhere } from '../../../../base/repositories';
|
|
3
3
|
import type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';
|
|
4
4
|
import type { IArtifactRegistrationOptions } from './artifact';
|
|
5
5
|
export interface IModelAuthorizeSettings {
|
|
@@ -8,12 +8,38 @@ export interface IModelAuthorizeSettings {
|
|
|
8
8
|
/** Extensible - consumers can add any extra authorization metadata. */
|
|
9
9
|
[extra: string | symbol]: any;
|
|
10
10
|
}
|
|
11
|
+
/** What a restricted caller may write to the scope columns (`@model` settings.access.write). */
|
|
12
|
+
export interface IModelAccessWriteSettings {
|
|
13
|
+
/**
|
|
14
|
+
* What a create, createAll or an update payload that names a scope column does when its value
|
|
15
|
+
* disagrees with the resolved scope. `reject` (default) refuses the write and writes nothing - for
|
|
16
|
+
* `createAll` not even the valid rows. `assign` also fills a scope column that is ABSENT from a
|
|
17
|
+
* created row, when the scope is a single equality; a value that is present and disagrees is
|
|
18
|
+
* still refused.
|
|
19
|
+
*
|
|
20
|
+
* The scope's columns and allowed values are read from the resolved `where` (equality, `eq`, `inq`
|
|
21
|
+
* and arrays, `and`, and an `or` over one column). Any other shape cannot be checked, and the write
|
|
22
|
+
* is refused with its own message - never skipped. `ScopeFilters.UNRESTRICTED` bypasses the guard
|
|
23
|
+
* too, which is the deliberate way to write across scopes (system scope, an admin role).
|
|
24
|
+
*
|
|
25
|
+
* Not checked: an update that does not name the scope column (the row was already selected through
|
|
26
|
+
* the scoped `where`), and raw statements that bypass the repository.
|
|
27
|
+
*/
|
|
28
|
+
mode?: TScopeWriteGuard;
|
|
29
|
+
/**
|
|
30
|
+
* `true` lets a restricted caller write `null` to a scope column, or leave it out on create: the
|
|
31
|
+
* row has no owner and is shared. Default `false`, so `null` is refused like any other value
|
|
32
|
+
* outside the scope, even when the resolved scope has a `null` branch (that branch lets the caller
|
|
33
|
+
* READ shared rows, a separate permission). Reads are scoped as before.
|
|
34
|
+
*/
|
|
35
|
+
sharedRows?: boolean;
|
|
36
|
+
}
|
|
11
37
|
/**
|
|
12
|
-
* Row
|
|
13
|
-
*
|
|
14
|
-
*
|
|
38
|
+
* Row access for `@model` settings.access - resolved per query, so it can depend on the current
|
|
39
|
+
* request (tenant, org, membership). Framework-internal escape hatches aside, nothing short of
|
|
40
|
+
* removing this setting from the model turns scoping off.
|
|
15
41
|
*/
|
|
16
|
-
export interface
|
|
42
|
+
export interface IModelAccessSettings {
|
|
17
43
|
/**
|
|
18
44
|
* Returns the scope `where`; `ScopeFilters.UNRESTRICTED` to apply no scope for THIS call (an
|
|
19
45
|
* internal operator, a caller the application has decided sees everything); or null/undefined
|
|
@@ -27,41 +53,87 @@ export interface IScopeFilterSettings {
|
|
|
27
53
|
* per MODEL - it cannot express a per-USER bypass; use `ScopeFilters.UNRESTRICTED` for that.
|
|
28
54
|
*/
|
|
29
55
|
onMissing?: TScopeFilterMissingBehavior;
|
|
56
|
+
/**
|
|
57
|
+
* The property names the write guard checks. Optional: with none declared the guard checks every
|
|
58
|
+
* column the resolved scope constrains. When declared, each name must exist on the model (checked
|
|
59
|
+
* at boot), and a resolved scope that constrains any other column is refused as unverifiable.
|
|
60
|
+
*/
|
|
61
|
+
columns?: string[];
|
|
62
|
+
/** What a restricted caller may write to the scope columns. See {@link IModelAccessWriteSettings}. */
|
|
63
|
+
write?: IModelAccessWriteSettings;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The old, flat shape of {@link IModelAccessSettings}.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Use `settings.access` (`writeGuard` is `access.write.mode`, `sharedRows` is
|
|
69
|
+
* `access.write.sharedRows`). Removed in 0.4.3.
|
|
70
|
+
*/
|
|
71
|
+
export interface IScopeFilterSettings {
|
|
72
|
+
resolve: () => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;
|
|
73
|
+
onMissing?: TScopeFilterMissingBehavior;
|
|
74
|
+
writeGuard?: TScopeWriteGuard;
|
|
75
|
+
sharedRows?: boolean;
|
|
76
|
+
columns?: string[];
|
|
77
|
+
}
|
|
78
|
+
/** What a query runs with when it names nothing (`@model` settings.query). */
|
|
79
|
+
export interface IModelQuerySettings {
|
|
80
|
+
/** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */
|
|
81
|
+
filter?: TFilter;
|
|
82
|
+
limit?: {
|
|
83
|
+
/** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */
|
|
84
|
+
default?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to
|
|
87
|
+
* DEFAULT_MAX_LIMIT (1000).
|
|
88
|
+
*
|
|
89
|
+
* Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so
|
|
90
|
+
* that reaching it means the caller is doing something unusual, and raising it is how a model
|
|
91
|
+
* says so deliberately.
|
|
92
|
+
*/
|
|
93
|
+
max?: number;
|
|
94
|
+
};
|
|
30
95
|
}
|
|
31
96
|
export interface IModelSettings {
|
|
32
97
|
/** Properties excluded from all query results at SQL level. */
|
|
33
98
|
hiddenProperties?: string[];
|
|
34
|
-
/** Default filter
|
|
35
|
-
|
|
99
|
+
/** Default filter and limits of a query: `filter`, `limit.default`, `limit.max`. */
|
|
100
|
+
query?: IModelQuerySettings;
|
|
36
101
|
/**
|
|
37
|
-
* Row
|
|
38
|
-
* NOT removable by `shouldSkipDefaultFilter
|
|
39
|
-
*
|
|
40
|
-
*
|
|
102
|
+
* Row access: the scope ANDed into every read and write whose scope is expressible as a filter
|
|
103
|
+
* clause, NOT removable by `shouldSkipDefaultFilter`, and the guard that holds writes to it.
|
|
104
|
+
* Ownership resolved per row or through a polymorphic reference is NOT expressible here - that
|
|
105
|
+
* check is still the application's to perform.
|
|
41
106
|
*
|
|
42
107
|
* Relational repositories only - a search-backed model (Typesense, Meilisearch) never reads
|
|
43
108
|
* this setting, so mirroring a scoped entity into a search index needs its own query-time scope.
|
|
44
109
|
*/
|
|
110
|
+
access?: IModelAccessSettings;
|
|
111
|
+
/** Authorization settings for this model (principal name, etc.). */
|
|
112
|
+
authorize?: IModelAuthorizeSettings;
|
|
113
|
+
/** @deprecated Use `query.filter`. Removed in 0.4.3. */
|
|
114
|
+
defaultFilter?: TFilter;
|
|
115
|
+
/** @deprecated Use `access`. Removed in 0.4.3. */
|
|
45
116
|
scopeFilter?: IScopeFilterSettings;
|
|
46
|
-
/**
|
|
117
|
+
/** @deprecated Use `query.limit.default`. Removed in 0.4.3. */
|
|
47
118
|
defaultLimit?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to
|
|
50
|
-
* DEFAULT_MAX_LIMIT (1000).
|
|
51
|
-
*
|
|
52
|
-
* Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so
|
|
53
|
-
* that reaching it means the caller is doing something unusual, and raising it is how a model
|
|
54
|
-
* says so deliberately.
|
|
55
|
-
*/
|
|
119
|
+
/** @deprecated Use `query.limit.max`. Removed in 0.4.3. */
|
|
56
120
|
maxLimit?: number;
|
|
57
|
-
|
|
58
|
-
|
|
121
|
+
}
|
|
122
|
+
/** One deprecated settings key a model still uses, and the key that replaces it. */
|
|
123
|
+
export interface IDeprecatedModelSetting {
|
|
124
|
+
/** The old key, written as the model wrote it: `defaultFilter`, `scopeFilter.writeGuard`. */
|
|
125
|
+
key: string;
|
|
126
|
+
/** The key that replaces it: `query.filter`, `access.write.mode`. */
|
|
127
|
+
use: string;
|
|
59
128
|
}
|
|
60
129
|
export interface IModelMetadata extends IArtifactRegistrationOptions {
|
|
61
130
|
type: 'entity' | 'view';
|
|
62
131
|
tableName?: string;
|
|
63
132
|
skipMigrate?: boolean;
|
|
133
|
+
/** As the `@model` decorator stores it: normalised to the new keys; the deprecated keys are gone. */
|
|
64
134
|
settings?: IModelSettings;
|
|
135
|
+
/** Set by the decorator, read by the boot warning; not for application code. */
|
|
136
|
+
deprecatedSettings?: IDeprecatedModelSetting[];
|
|
65
137
|
}
|
|
66
138
|
export interface IEntityStatics {
|
|
67
139
|
schema?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EACP,2BAA2B,EAC3B,MAAM,EACP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,EAAE,MAAM,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC;IAEpE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EACV,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