@declaro/data 2.0.0-beta.120 → 2.0.0-beta.121

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.
Files changed (31) hide show
  1. package/dist/browser/index.js +14 -14
  2. package/dist/browser/index.js.map +7 -7
  3. package/dist/node/index.cjs +150 -41
  4. package/dist/node/index.cjs.map +7 -7
  5. package/dist/node/index.js +150 -41
  6. package/dist/node/index.js.map +7 -7
  7. package/dist/ts/application/model-controller.d.ts +22 -1
  8. package/dist/ts/application/model-controller.d.ts.map +1 -1
  9. package/dist/ts/domain/events/event-types.d.ts +10 -1
  10. package/dist/ts/domain/events/event-types.d.ts.map +1 -1
  11. package/dist/ts/domain/interfaces/repository.d.ts +26 -0
  12. package/dist/ts/domain/interfaces/repository.d.ts.map +1 -1
  13. package/dist/ts/domain/services/model-service.d.ts +19 -1
  14. package/dist/ts/domain/services/model-service.d.ts.map +1 -1
  15. package/dist/ts/domain/services/read-only-model-service.d.ts +19 -0
  16. package/dist/ts/domain/services/read-only-model-service.d.ts.map +1 -1
  17. package/dist/ts/test/mock/repositories/mock-memory-repository.d.ts +21 -3
  18. package/dist/ts/test/mock/repositories/mock-memory-repository.d.ts.map +1 -1
  19. package/dist/ts/test/mock/repositories/mock-memory-repository.trash.test.d.ts +2 -0
  20. package/dist/ts/test/mock/repositories/mock-memory-repository.trash.test.d.ts.map +1 -0
  21. package/package.json +5 -5
  22. package/src/application/model-controller.test.ts +191 -0
  23. package/src/application/model-controller.ts +44 -1
  24. package/src/domain/events/event-types.ts +9 -0
  25. package/src/domain/interfaces/repository.ts +29 -0
  26. package/src/domain/services/model-service.test.ts +307 -0
  27. package/src/domain/services/model-service.ts +88 -1
  28. package/src/domain/services/read-only-model-service.test.ts +396 -0
  29. package/src/domain/services/read-only-model-service.ts +23 -3
  30. package/src/test/mock/repositories/mock-memory-repository.trash.test.ts +736 -0
  31. package/src/test/mock/repositories/mock-memory-repository.ts +146 -46
@@ -1,7 +1,7 @@
1
1
  import type { AuthValidator } from '@declaro/auth';
2
2
  import { type AnyModelSchema } from '@declaro/core';
3
3
  import type { ModelService, ICreateOptions, IUpdateOptions } from '../domain/services/model-service';
4
- import type { InferDetail, InferInput, InferLookup, InferSummary } from '../shared/utils/schema-inference';
4
+ import type { InferDetail, InferFilters, InferInput, InferLookup, InferSummary } from '../shared/utils/schema-inference';
5
5
  import { ReadOnlyModelController } from './read-only-model-controller';
6
6
  export declare class ModelController<TSchema extends AnyModelSchema> extends ReadOnlyModelController<TSchema> {
7
7
  protected readonly service: ModelService<TSchema>;
@@ -25,5 +25,26 @@ export declare class ModelController<TSchema extends AnyModelSchema> extends Rea
25
25
  * @returns Array of upserted records.
26
26
  */
27
27
  bulkUpsert(inputs: InferInput<TSchema>[], options?: ICreateOptions | IUpdateOptions): Promise<InferDetail<TSchema>[]>;
28
+ /**
29
+ * Permanently deletes a specific entity from the trash.
30
+ * Requires 'permanently-delete-from-trash', 'permanently-delete', or 'empty-trash' permission.
31
+ * @param lookup The lookup object containing entity identifiers
32
+ * @returns The permanently deleted entity summary
33
+ */
34
+ permanentlyDeleteFromTrash(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
35
+ /**
36
+ * Permanently deletes an entity without moving it to trash first.
37
+ * Requires 'permanently-delete' permission.
38
+ * @param lookup The lookup object containing entity identifiers
39
+ * @returns The permanently deleted entity summary
40
+ */
41
+ permanentlyDelete(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
42
+ /**
43
+ * Empties the trash by permanently deleting entities that have been marked as removed.
44
+ * Requires 'empty-trash' permission.
45
+ * @param filters Optional filters to apply when selecting entities to delete
46
+ * @returns The count of entities permanently deleted
47
+ */
48
+ emptyTrash(filters?: InferFilters<TSchema>): Promise<number>;
28
49
  }
29
50
  //# sourceMappingURL=model-controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-controller.d.ts","sourceRoot":"","sources":["../../../src/application/model-controller.ts"],"names":[],"mappings":"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OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAU3E;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAalH;;;;;OAKG;IACG,UAAU,CACZ,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,EAC7B,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,GAC1C,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IAalC;;;;;OAKG;IACG,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAW9F;;;;;OAKG;IACG,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAOrF;;;;;OAKG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAMrE"}
@@ -20,6 +20,15 @@ export declare enum ModelMutationAction {
20
20
  AfterRemove = "afterRemove",
21
21
  Restore = "restore",
22
22
  BeforeRestore = "beforeRestore",
23
- AfterRestore = "afterRestore"
23
+ AfterRestore = "afterRestore",
24
+ EmptyTrash = "emptyTrash",
25
+ BeforeEmptyTrash = "beforeEmptyTrash",
26
+ AfterEmptyTrash = "afterEmptyTrash",
27
+ PermanentlyDeleteFromTrash = "permanentlyDeleteFromTrash",
28
+ BeforePermanentlyDeleteFromTrash = "beforePermanentlyDeleteFromTrash",
29
+ AfterPermanentlyDeleteFromTrash = "afterPermanentlyDeleteFromTrash",
30
+ PermanentlyDelete = "permanentlyDelete",
31
+ BeforePermanentlyDelete = "beforePermanentlyDelete",
32
+ AfterPermanentlyDelete = "afterPermanentlyDelete"
24
33
  }
25
34
  //# sourceMappingURL=event-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../../src/domain/events/event-types.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACvB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC5B;AAED,oBAAY,mBAAmB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;CAChC"}
1
+ {"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../../src/domain/events/event-types.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IACvB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC5B;AAED,oBAAY,mBAAmB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,OAAO,YAAY;IACnB,aAAa,kBAAkB;IAC/B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,0BAA0B,+BAA+B;IACzD,gCAAgC,qCAAqC;IACrE,+BAA+B,oCAAoC;IACnE,iBAAiB,sBAAsB;IACvC,uBAAuB,4BAA4B;IACnD,sBAAsB,2BAA2B;CACpD"}
@@ -80,5 +80,31 @@ export interface IRepository<TSchema extends AnyModelSchema> {
80
80
  * @returns A promise resolving to the count of matching elements.
81
81
  */
82
82
  count(search: InferFilters<TSchema>, options?: ISearchOptions<TSchema>): Promise<number>;
83
+ /**
84
+ * Permanently deletes all items from trash, optionally filtered by the provided criteria.
85
+ * Items deleted via this method cannot be restored.
86
+ *
87
+ * @param filters - Optional filters to apply when selecting items to delete from trash.
88
+ * @returns A promise resolving to the count of permanently deleted items.
89
+ */
90
+ emptyTrash(filters?: InferFilters<TSchema>): Promise<number>;
91
+ /**
92
+ * Permanently deletes a specific item from trash based on the provided lookup.
93
+ * The item must exist in trash (previously removed). Items deleted via this method cannot be restored.
94
+ *
95
+ * @param lookup - The lookup criteria for the item to permanently delete from trash.
96
+ * @returns A promise resolving to the permanently deleted item summary.
97
+ * @throws Error if the item is not found in trash.
98
+ */
99
+ permanentlyDeleteFromTrash(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
100
+ /**
101
+ * Permanently deletes an item based on the provided lookup, regardless of whether it is active or in trash.
102
+ * Items deleted via this method cannot be restored.
103
+ *
104
+ * @param lookup - The lookup criteria for the item to permanently delete.
105
+ * @returns A promise resolving to the permanently deleted item summary.
106
+ * @throws Error if the item is not found in either active data or trash.
107
+ */
108
+ permanentlyDelete(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
83
109
  }
84
110
  //# sourceMappingURL=repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../../src/domain/interfaces/repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,KAAK,EACR,WAAW,EACX,YA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AAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;IAE5G;;;;;;;;OAQG;IACH,UAAU,CACN,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,EAC7B,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,GAC1C,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IAElC;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAExF;;;;;;OAMG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE5D;;;;;;;OAOG;IACH,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;IAExF;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;CAClF"}
@@ -1,5 +1,5 @@
1
1
  import type { ActionDescriptor, AnyModelSchema } from '@declaro/core';
2
- import type { InferDetail, InferInput, InferLookup, InferSummary } from '../../shared/utils/schema-inference';
2
+ import type { InferDetail, InferFilters, InferInput, InferLookup, InferSummary } from '../../shared/utils/schema-inference';
3
3
  import type { IModelServiceArgs } from './model-service-args';
4
4
  import { ReadOnlyModelService, type ILoadOptions } from './read-only-model-service';
5
5
  import type { IActionOptions } from './base-model-service';
@@ -50,5 +50,23 @@ export declare class ModelService<TSchema extends AnyModelSchema> extends ReadOn
50
50
  * @returns Array of upserted records.
51
51
  */
52
52
  bulkUpsert(inputs: InferInput<TSchema>[], options?: ICreateOptions | IUpdateOptions): Promise<InferDetail<TSchema>[]>;
53
+ /**
54
+ * Permanently deletes all items from trash, optionally filtered by the provided criteria.
55
+ * @param filters Optional filters to apply when selecting items to delete from trash.
56
+ * @returns The count of permanently deleted items.
57
+ */
58
+ emptyTrash(filters?: InferFilters<TSchema>): Promise<number>;
59
+ /**
60
+ * Permanently deletes a specific item from trash based on the provided lookup.
61
+ * @param lookup The lookup criteria for the item to permanently delete from trash.
62
+ * @returns The permanently deleted item summary.
63
+ */
64
+ permanentlyDeleteFromTrash(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
65
+ /**
66
+ * Permanently deletes an item based on the provided lookup, regardless of whether it is active or in trash.
67
+ * @param lookup The lookup criteria for the item to permanently delete.
68
+ * @returns The permanently deleted item summary.
69
+ */
70
+ permanentlyDelete(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
53
71
  }
54
72
  //# sourceMappingURL=model-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-service.d.ts","sourceRoot":"","sources":["../../../../src/domain/services/model-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAA;AACxF,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAA;AAG7G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,WAAW,cAAe,SAAQ,cAAc;CAAG;AACzD,MAAM,WAAW,cAAe,SAAQ,cAAc;CAAG;AAEzD,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,cAAc;IAC/D,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC/B,UAAU,EAAE,gBAAgB,CAAA;CAC/B;AAED,qBA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AAY,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAsB7F,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IA2B3F,MAAM,CACR,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAC5B,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAC1B,OAAO,CAAC,EAAE,cAAc,GACzB,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IA6BhC;;;;;OAKG;IACG,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IA0DlH;;;;;OAKG;IACG,UAAU,CACZ,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,EAC7B,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,GAC1C,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IA0HlC;;;;OAIG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAsBlE;;;;OAIG;IACG,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAsB9F;;;;OAIG;IACG,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;CAqBxF"}
@@ -2,11 +2,30 @@ import type { AnyModelSchema } from '@declaro/core';
2
2
  import type { InferDetail, InferFilters, InferLookup, InferSearchResults, InferSort } from '../../shared/utils/schema-inference';
3
3
  import { BaseModelService, type IActionOptions } from './base-model-service';
4
4
  import type { IPaginationInput } from '../models/pagination';
5
+ /**
6
+ * Options for loading records.
7
+ */
5
8
  export interface ILoadOptions extends IActionOptions {
9
+ /**
10
+ * If true, only removed (soft-deleted) records will be returned.
11
+ */
12
+ removedOnly?: boolean;
13
+ /**
14
+ * If true, both removed and non-removed records will be returned.
15
+ */
16
+ includeRemoved?: boolean;
6
17
  }
7
18
  export interface ISearchOptions<TSchema extends AnyModelSchema> extends IActionOptions {
8
19
  pagination?: IPaginationInput;
9
20
  sort?: InferSort<TSchema>;
21
+ /**
22
+ * If true, only removed (soft-deleted) records will be returned.
23
+ */
24
+ removedOnly?: boolean;
25
+ /**
26
+ * If true, both removed and non-removed records will be returned.
27
+ */
28
+ includeRemoved?: boolean;
10
29
  }
11
30
  export declare class ReadOnlyModelService<TSchema extends AnyModelSchema> extends BaseModelService<TSchema> {
12
31
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"read-only-model-service.d.ts","sourceRoot":"","sources":["../../../../src/domain/services/read-only-model-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,eAAe,CAAA;AAC1D,OAAO,KAAK,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,SAAS,EACZ,MAAM,qCAAqC,CAAA;AAG5C,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,MAAM,WAAW,YAAa,SAAQ,cAAc;CAAG;AACvD,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,cAAc,CAAE,SAAQ,cAAc;IAClF,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;CAC5B;AAED,qBAAa,oBAAoB,CAAC,OAAO,SAAS,cAAc,CAAE,SAAQ,gBAAgB,CAAC,OAAO,CAAC;IAC/F;;;;;;OAMG;IACG,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAIlF;;;;;;;OAOG;IACG,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAIpF;;;;;OAKG;IACG,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAqB/F;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IAqBxG;;;;;OAKG;IACG,MAAM,CACR,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAClC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAyBvC;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBlG"}
1
+ {"version":3,"file":"read-only-model-service.d.ts","sourceRoot":"","sources":["../../../../src/domain/services/read-only-model-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,eAAe,CAAA;AAC1D,OAAO,KAAK,EACR,WAAW,EACX,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,SAAS,EACZ,MAAM,qCAAqC,CAAA;AAG5C,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAA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O,CAAC,CAAC;IAyBvC;;;;OAIG;IACG,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAqBlG"}
@@ -1,7 +1,7 @@
1
1
  import type { AnyModelSchema, IModelEntityMetadata } from '@declaro/core';
2
2
  import type { IRepository } from '../../../domain/interfaces/repository';
3
3
  import type { InferDetail, InferFilters, InferInput, InferLookup, InferSearchResults, InferSummary } from '../../../shared/utils/schema-inference';
4
- import type { ISearchOptions } from '../../../domain/services/read-only-model-service';
4
+ import type { ILoadOptions, ISearchOptions } from '../../../domain/services/read-only-model-service';
5
5
  import type { ICreateOptions, IUpdateOptions } from '../../../domain/services/model-service';
6
6
  export interface IMockMemoryRepositoryArgs<TSchema extends AnyModelSchema> {
7
7
  schema: TSchema;
@@ -16,7 +16,21 @@ export declare class MockMemoryRepository<TSchema extends AnyModelSchema> implem
16
16
  protected entityMetadata: IModelEntityMetadata;
17
17
  protected nextId: number;
18
18
  constructor(args: IMockMemoryRepositoryArgs<TSchema>);
19
- load(input: InferLookup<TSchema>): Promise<InferDetail<TSchema> | null>;
19
+ private findOne;
20
+ /**
21
+ * Find an item and return both the item and its key
22
+ * @param lookup - The lookup criteria
23
+ * @param map - The map to search in
24
+ * @returns Object containing the item and its key, or undefined if not found
25
+ */
26
+ private findOneWithKey;
27
+ /**
28
+ * Loads a single item by lookup criteria.
29
+ * @param input - The lookup criteria.
30
+ * @param options - Optional load options including removedOnly and includeRemoved.
31
+ * @returns The found item or null if not found.
32
+ */
33
+ load(input: InferLookup<TSchema>, options?: ILoadOptions): Promise<InferDetail<TSchema> | null>;
20
34
  loadMany(inputs: InferLookup<TSchema>[]): Promise<InferDetail<TSchema>[]>;
21
35
  search(input: InferFilters<TSchema>, options?: ISearchOptions<TSchema>): Promise<InferSearchResults<TSchema>>;
22
36
  remove(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
@@ -26,12 +40,16 @@ export declare class MockMemoryRepository<TSchema extends AnyModelSchema> implem
26
40
  count(search: InferFilters<TSchema>, options?: ISearchOptions<TSchema> | undefined): Promise<number>;
27
41
  upsert(input: InferInput<TSchema>, options?: ICreateOptions | IUpdateOptions): Promise<InferDetail<TSchema>>;
28
42
  bulkUpsert(inputs: InferInput<TSchema>[], options?: ICreateOptions | IUpdateOptions): Promise<InferDetail<TSchema>[]>;
43
+ permanentlyDelete(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
44
+ permanentlyDeleteFromTrash(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>;
45
+ emptyTrash(filters?: InferFilters<TSchema>): Promise<number>;
29
46
  /**
30
47
  * Apply filtering logic to all items based on the provided search criteria
31
48
  * @param input - The search/filter criteria
49
+ * @param options - Optional search options including removedOnly and includeRemoved
32
50
  * @returns Filtered array of items
33
51
  */
34
- protected applyFilters(input: InferFilters<TSchema>): InferDetail<TSchema>[];
52
+ protected applyFilters(input: InferFilters<TSchema>, options?: ISearchOptions<TSchema>): InferDetail<TSchema>[];
35
53
  /**
36
54
  * Assign input data to existing data using the provided assign function or default Object.assign
37
55
  * @param existingData - The existing data to merge with
@@ -1 +1 @@
1
- {"version":3,"file":"mock-memory-repository.d.ts","sourceRoot":"","sources":["../../../../../src/test/mock/repositories/mock-memory-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAqB,MAAM,eAAe,CAAA;AAC5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AAExE,OAAO,KAAK,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,YAAY,EACf,MAAM,wCAAwC,CAAA;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAA;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wCAAw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c,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAkB5G,UAAU,CACZ,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,EAC7B,OAAO,CAAC,EAAE,cAAc,GAAG,cAAc,GAC1C,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;IAI5B,iBAAiB,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAqB/E,0BAA0B,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAcxF,UAAU,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BlE;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,EAAE;IAwB/G;;;;;OAKG;IACH,SAAS,CAAC,WAAW,CAAC,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC;cAS3F,kBAAkB;CAcrC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mock-memory-repository.trash.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-memory-repository.trash.test.d.ts","sourceRoot":"","sources":["../../../../../src/test/mock/repositories/mock-memory-repository.trash.test.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@declaro/data",
3
- "version": "2.0.0-beta.120",
3
+ "version": "2.0.0-beta.121",
4
4
  "description": "A data-mapper framework for managing application data across integrated systems.",
5
5
  "main": "dist/node/index.cjs",
6
6
  "module": "dist/node/index.js",
@@ -22,9 +22,9 @@
22
22
  "@declaro/zod": "^2.0.0-beta.51"
23
23
  },
24
24
  "devDependencies": {
25
- "@declaro/auth": "^2.0.0-beta.120",
26
- "@declaro/core": "^2.0.0-beta.120",
27
- "@declaro/zod": "^2.0.0-beta.120",
25
+ "@declaro/auth": "^2.0.0-beta.121",
26
+ "@declaro/core": "^2.0.0-beta.121",
27
+ "@declaro/zod": "^2.0.0-beta.121",
28
28
  "crypto-browserify": "^3.12.1",
29
29
  "typescript": "^5.8.3",
30
30
  "uuid": "^11.1.0",
@@ -43,5 +43,5 @@
43
43
  "require": "./dist/node/index.cjs",
44
44
  "browser": "./dist/browser/index.js"
45
45
  },
46
- "gitHead": "eb2611cf4dfbe1f3770eb6d9cd87264f98ae8e76"
46
+ "gitHead": "0901d02d5fb769186830bb104aca0c5b98080f4f"
47
47
  }
@@ -500,4 +500,195 @@ describe('ModelController', () => {
500
500
  await expect(controller.bulkUpsert([input])).rejects.toThrow(PermissionError)
501
501
  })
502
502
  })
503
+
504
+ describe('Trash Functionality', () => {
505
+ let permanentlyDeleteValidator: AuthValidator
506
+ let permanentlyDeleteFromTrashValidator: AuthValidator
507
+ let emptyTrashValidator: AuthValidator
508
+
509
+ beforeEach(() => {
510
+ permanentlyDeleteValidator = new AuthValidator(
511
+ getMockAuthSession({
512
+ claims: ['books::book.permanently-delete:all'],
513
+ }),
514
+ null,
515
+ authService,
516
+ )
517
+ permanentlyDeleteFromTrashValidator = new AuthValidator(
518
+ getMockAuthSession({
519
+ claims: ['books::book.permanently-delete-from-trash:all'],
520
+ }),
521
+ null,
522
+ authService,
523
+ )
524
+ emptyTrashValidator = new AuthValidator(
525
+ getMockAuthSession({
526
+ claims: ['books::book.empty-trash:all'],
527
+ }),
528
+ null,
529
+ authService,
530
+ )
531
+ })
532
+
533
+ describe('permanentlyDelete', () => {
534
+ it('should permanently delete a record if permissions are valid', async () => {
535
+ const controller = new ModelController(service, permanentlyDeleteValidator)
536
+
537
+ const input = { id: 42, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
538
+ await repository.create(input)
539
+
540
+ const deletedRecord = await controller.permanentlyDelete({ id: 42 })
541
+
542
+ expect(deletedRecord).toEqual(input)
543
+ })
544
+
545
+ it('should throw PermissionError if permissions are invalid', async () => {
546
+ const controller = new ModelController(service, invalidAuthValidator)
547
+
548
+ await expect(controller.permanentlyDelete({ id: 42 })).rejects.toThrow(PermissionError)
549
+ })
550
+
551
+ it('should allow permanentlyDelete with specific permanently-delete permission', async () => {
552
+ const controller = new ModelController(service, permanentlyDeleteValidator)
553
+
554
+ const input = { id: 42, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
555
+ await repository.create(input)
556
+
557
+ const deletedRecord = await controller.permanentlyDelete({ id: 42 })
558
+
559
+ expect(deletedRecord).toEqual(input)
560
+ })
561
+ })
562
+
563
+ describe('permanentlyDeleteFromTrash', () => {
564
+ it('should permanently delete from trash if permissions are valid', async () => {
565
+ const controller = new ModelController(service, permanentlyDeleteFromTrashValidator)
566
+
567
+ const input = { id: 42, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
568
+ await repository.create(input)
569
+ await repository.remove({ id: 42 })
570
+
571
+ const deletedRecord = await controller.permanentlyDeleteFromTrash({ id: 42 })
572
+
573
+ expect(deletedRecord).toEqual(input)
574
+ })
575
+
576
+ it('should throw PermissionError if permissions are invalid', async () => {
577
+ const controller = new ModelController(service, invalidAuthValidator)
578
+
579
+ await expect(controller.permanentlyDeleteFromTrash({ id: 42 })).rejects.toThrow(PermissionError)
580
+ })
581
+
582
+ it('should allow with permanently-delete-from-trash permission', async () => {
583
+ const controller = new ModelController(service, permanentlyDeleteFromTrashValidator)
584
+
585
+ const input = { id: 42, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
586
+ await repository.create(input)
587
+ await repository.remove({ id: 42 })
588
+
589
+ const deletedRecord = await controller.permanentlyDeleteFromTrash({ id: 42 })
590
+
591
+ expect(deletedRecord).toEqual(input)
592
+ })
593
+
594
+ it('should allow with permanently-delete permission', async () => {
595
+ const controller = new ModelController(service, permanentlyDeleteValidator)
596
+
597
+ const input = { id: 42, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
598
+ await repository.create(input)
599
+ await repository.remove({ id: 42 })
600
+
601
+ const deletedRecord = await controller.permanentlyDeleteFromTrash({ id: 42 })
602
+
603
+ expect(deletedRecord).toEqual(input)
604
+ })
605
+
606
+ it('should allow with empty-trash permission', async () => {
607
+ const controller = new ModelController(service, emptyTrashValidator)
608
+
609
+ const input = { id: 42, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
610
+ await repository.create(input)
611
+ await repository.remove({ id: 42 })
612
+
613
+ const deletedRecord = await controller.permanentlyDeleteFromTrash({ id: 42 })
614
+
615
+ expect(deletedRecord).toEqual(input)
616
+ })
617
+ })
618
+
619
+ describe('emptyTrash', () => {
620
+ it('should empty trash if permissions are valid', async () => {
621
+ const controller = new ModelController(service, emptyTrashValidator)
622
+
623
+ const input1 = { id: 1, title: 'Test Book 1', author: 'Author Name', publishedDate: new Date() }
624
+ const input2 = { id: 2, title: 'Test Book 2', author: 'Author Name', publishedDate: new Date() }
625
+ await repository.create(input1)
626
+ await repository.create(input2)
627
+ await repository.remove({ id: 1 })
628
+ await repository.remove({ id: 2 })
629
+
630
+ const count = await controller.emptyTrash()
631
+
632
+ expect(count).toBe(2)
633
+ })
634
+
635
+ it('should throw PermissionError if permissions are invalid', async () => {
636
+ const controller = new ModelController(service, invalidAuthValidator)
637
+
638
+ await expect(controller.emptyTrash()).rejects.toThrow(PermissionError)
639
+ })
640
+
641
+ it('should empty trash with filters if permissions are valid', async () => {
642
+ const repositoryWithFilter = new MockMemoryRepository({
643
+ schema: mockSchema,
644
+ filter: (data, filters) => {
645
+ if (filters.text) {
646
+ return data.title.toLowerCase().includes(filters.text.toLowerCase())
647
+ }
648
+ return true
649
+ },
650
+ })
651
+
652
+ const serviceWithFilter = new ModelService({
653
+ repository: repositoryWithFilter,
654
+ emitter: new EventManager(),
655
+ namespace,
656
+ schema: mockSchema,
657
+ })
658
+
659
+ const controller = new ModelController(serviceWithFilter, emptyTrashValidator)
660
+
661
+ await repositoryWithFilter.create({
662
+ id: 1,
663
+ title: 'Test Book 1',
664
+ author: 'Author Name',
665
+ publishedDate: new Date(),
666
+ })
667
+ await repositoryWithFilter.create({
668
+ id: 2,
669
+ title: 'Other Book 2',
670
+ author: 'Author Name',
671
+ publishedDate: new Date(),
672
+ })
673
+ await repositoryWithFilter.remove({ id: 1 })
674
+ await repositoryWithFilter.remove({ id: 2 })
675
+
676
+ const count = await controller.emptyTrash({ text: 'Test' })
677
+
678
+ expect(count).toBe(1)
679
+ })
680
+
681
+ it('should allow emptyTrash with specific empty-trash permission', async () => {
682
+ const controller = new ModelController(service, emptyTrashValidator)
683
+
684
+ const input = { id: 1, title: 'Test Book', author: 'Author Name', publishedDate: new Date() }
685
+ await repository.create(input)
686
+ await repository.remove({ id: 1 })
687
+
688
+ const count = await controller.emptyTrash()
689
+
690
+ expect(count).toBe(1)
691
+ })
692
+ })
693
+ })
503
694
  })
@@ -1,7 +1,7 @@
1
1
  import type { AuthValidator } from '@declaro/auth'
2
2
  import { PermissionValidator, type AnyModelSchema } from '@declaro/core'
3
3
  import type { ModelService, ICreateOptions, IUpdateOptions } from '../domain/services/model-service'
4
- import type { InferDetail, InferInput, InferLookup, InferSummary } from '../shared/utils/schema-inference'
4
+ import type { InferDetail, InferFilters, InferInput, InferLookup, InferSummary } from '../shared/utils/schema-inference'
5
5
  import { ReadOnlyModelController } from './read-only-model-controller'
6
6
 
7
7
  export class ModelController<TSchema extends AnyModelSchema> extends ReadOnlyModelController<TSchema> {
@@ -89,4 +89,47 @@ export class ModelController<TSchema extends AnyModelSchema> extends ReadOnlyMod
89
89
  )
90
90
  return this.service.bulkUpsert(inputs, options)
91
91
  }
92
+
93
+ /**
94
+ * Permanently deletes a specific entity from the trash.
95
+ * Requires 'permanently-delete-from-trash', 'permanently-delete', or 'empty-trash' permission.
96
+ * @param lookup The lookup object containing entity identifiers
97
+ * @returns The permanently deleted entity summary
98
+ */
99
+ async permanentlyDeleteFromTrash(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>> {
100
+ this.authValidator.validatePermissions((v) =>
101
+ v.someOf([
102
+ this.service.getDescriptor('permanently-delete-from-trash', '*').toString(),
103
+ this.service.getDescriptor('permanently-delete', '*').toString(),
104
+ this.service.getDescriptor('empty-trash', '*').toString(),
105
+ ]),
106
+ )
107
+ return this.service.permanentlyDeleteFromTrash(lookup)
108
+ }
109
+
110
+ /**
111
+ * Permanently deletes an entity without moving it to trash first.
112
+ * Requires 'permanently-delete' permission.
113
+ * @param lookup The lookup object containing entity identifiers
114
+ * @returns The permanently deleted entity summary
115
+ */
116
+ async permanentlyDelete(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>> {
117
+ this.authValidator.validatePermissions((v) =>
118
+ v.someOf([this.service.getDescriptor('permanently-delete', '*').toString()]),
119
+ )
120
+ return this.service.permanentlyDelete(lookup)
121
+ }
122
+
123
+ /**
124
+ * Empties the trash by permanently deleting entities that have been marked as removed.
125
+ * Requires 'empty-trash' permission.
126
+ * @param filters Optional filters to apply when selecting entities to delete
127
+ * @returns The count of entities permanently deleted
128
+ */
129
+ async emptyTrash(filters?: InferFilters<TSchema>): Promise<number> {
130
+ this.authValidator.validatePermissions((v) =>
131
+ v.someOf([this.service.getDescriptor('empty-trash', '*').toString()]),
132
+ )
133
+ return this.service.emptyTrash(filters)
134
+ }
92
135
  }
@@ -22,4 +22,13 @@ export enum ModelMutationAction {
22
22
  Restore = 'restore',
23
23
  BeforeRestore = 'beforeRestore',
24
24
  AfterRestore = 'afterRestore',
25
+ EmptyTrash = 'emptyTrash',
26
+ BeforeEmptyTrash = 'beforeEmptyTrash',
27
+ AfterEmptyTrash = 'afterEmptyTrash',
28
+ PermanentlyDeleteFromTrash = 'permanentlyDeleteFromTrash',
29
+ BeforePermanentlyDeleteFromTrash = 'beforePermanentlyDeleteFromTrash',
30
+ AfterPermanentlyDeleteFromTrash = 'afterPermanentlyDeleteFromTrash',
31
+ PermanentlyDelete = 'permanentlyDelete',
32
+ BeforePermanentlyDelete = 'beforePermanentlyDelete',
33
+ AfterPermanentlyDelete = 'afterPermanentlyDelete',
25
34
  }
@@ -104,4 +104,33 @@ export interface IRepository<TSchema extends AnyModelSchema> {
104
104
  * @returns A promise resolving to the count of matching elements.
105
105
  */
106
106
  count(search: InferFilters<TSchema>, options?: ISearchOptions<TSchema>): Promise<number>
107
+
108
+ /**
109
+ * Permanently deletes all items from trash, optionally filtered by the provided criteria.
110
+ * Items deleted via this method cannot be restored.
111
+ *
112
+ * @param filters - Optional filters to apply when selecting items to delete from trash.
113
+ * @returns A promise resolving to the count of permanently deleted items.
114
+ */
115
+ emptyTrash(filters?: InferFilters<TSchema>): Promise<number>
116
+
117
+ /**
118
+ * Permanently deletes a specific item from trash based on the provided lookup.
119
+ * The item must exist in trash (previously removed). Items deleted via this method cannot be restored.
120
+ *
121
+ * @param lookup - The lookup criteria for the item to permanently delete from trash.
122
+ * @returns A promise resolving to the permanently deleted item summary.
123
+ * @throws Error if the item is not found in trash.
124
+ */
125
+ permanentlyDeleteFromTrash(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>
126
+
127
+ /**
128
+ * Permanently deletes an item based on the provided lookup, regardless of whether it is active or in trash.
129
+ * Items deleted via this method cannot be restored.
130
+ *
131
+ * @param lookup - The lookup criteria for the item to permanently delete.
132
+ * @returns A promise resolving to the permanently deleted item summary.
133
+ * @throws Error if the item is not found in either active data or trash.
134
+ */
135
+ permanentlyDelete(lookup: InferLookup<TSchema>): Promise<InferSummary<TSchema>>
107
136
  }