@nxgt/shared-mongo 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +15 -0
  2. package/dist/audit/audit.model.d.ts +209 -0
  3. package/dist/audit/audit.model.d.ts.map +1 -0
  4. package/dist/audit/audit.service.d.ts +17 -0
  5. package/dist/audit/audit.service.d.ts.map +1 -0
  6. package/dist/audit/audit.types.d.ts +29 -0
  7. package/dist/audit/audit.types.d.ts.map +1 -0
  8. package/dist/audit/audit.utils.d.ts +50 -0
  9. package/dist/audit/audit.utils.d.ts.map +1 -0
  10. package/dist/audit/index.d.ts +5 -0
  11. package/dist/audit/index.d.ts.map +1 -0
  12. package/dist/filters/filter.utils.d.ts +112 -0
  13. package/dist/filters/filter.utils.d.ts.map +1 -0
  14. package/dist/filters/index.d.ts +16 -0
  15. package/dist/filters/index.d.ts.map +1 -0
  16. package/dist/filters/index.js +199 -0
  17. package/dist/filters/index.js.map +10 -0
  18. package/dist/index.d.ts +14 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +1847 -0
  21. package/dist/index.js.map +70 -0
  22. package/dist/integrity/index.d.ts +3 -0
  23. package/dist/integrity/index.d.ts.map +1 -0
  24. package/dist/integrity/integrity.registry.d.ts +38 -0
  25. package/dist/integrity/integrity.registry.d.ts.map +1 -0
  26. package/dist/integrity/integrity.types.d.ts +26 -0
  27. package/dist/integrity/integrity.types.d.ts.map +1 -0
  28. package/dist/migrations/cli.d.ts +28 -0
  29. package/dist/migrations/cli.d.ts.map +1 -0
  30. package/dist/migrations/disconnect.d.ts +8 -0
  31. package/dist/migrations/disconnect.d.ts.map +1 -0
  32. package/dist/migrations/index.d.ts +6 -0
  33. package/dist/migrations/index.d.ts.map +1 -0
  34. package/dist/migrations/migrate.d.ts +47 -0
  35. package/dist/migrations/migrate.d.ts.map +1 -0
  36. package/dist/migrations/migration.model.d.ts +7 -0
  37. package/dist/migrations/migration.model.d.ts.map +1 -0
  38. package/dist/migrations/migration.runner.d.ts +47 -0
  39. package/dist/migrations/migration.runner.d.ts.map +1 -0
  40. package/dist/migrations/migration.types.d.ts +48 -0
  41. package/dist/migrations/migration.types.d.ts.map +1 -0
  42. package/dist/migrations/migration.utils.d.ts +40 -0
  43. package/dist/migrations/migration.utils.d.ts.map +1 -0
  44. package/dist/models/index.d.ts +3 -0
  45. package/dist/models/index.d.ts.map +1 -0
  46. package/dist/models/pagination.d.ts +34 -0
  47. package/dist/models/pagination.d.ts.map +1 -0
  48. package/dist/models/postal-address.model.d.ts +64 -0
  49. package/dist/models/postal-address.model.d.ts.map +1 -0
  50. package/dist/mongoose.d.ts +3 -0
  51. package/dist/mongoose.d.ts.map +1 -0
  52. package/dist/plugins/consts.d.ts +6 -0
  53. package/dist/plugins/consts.d.ts.map +1 -0
  54. package/dist/plugins/errors.d.ts +3 -0
  55. package/dist/plugins/errors.d.ts.map +1 -0
  56. package/dist/plugins/index.d.ts +15 -0
  57. package/dist/plugins/index.d.ts.map +1 -0
  58. package/dist/plugins/pagination/index.d.ts +4 -0
  59. package/dist/plugins/pagination/index.d.ts.map +1 -0
  60. package/dist/plugins/pagination/types.d.ts +61 -0
  61. package/dist/plugins/pagination/types.d.ts.map +1 -0
  62. package/dist/plugins/pagination/utils.d.ts +24 -0
  63. package/dist/plugins/pagination/utils.d.ts.map +1 -0
  64. package/dist/plugins/shared/index.d.ts +3 -0
  65. package/dist/plugins/shared/index.d.ts.map +1 -0
  66. package/dist/plugins/shared/shared.d.ts +3 -0
  67. package/dist/plugins/shared/shared.d.ts.map +1 -0
  68. package/dist/plugins/soft-delete/index.d.ts +3 -0
  69. package/dist/plugins/soft-delete/index.d.ts.map +1 -0
  70. package/dist/plugins/soft-delete/soft-delete.d.ts +3 -0
  71. package/dist/plugins/soft-delete/soft-delete.d.ts.map +1 -0
  72. package/dist/services/crud.service.d.ts +88 -0
  73. package/dist/services/crud.service.d.ts.map +1 -0
  74. package/dist/services/index.d.ts +2 -0
  75. package/dist/services/index.d.ts.map +1 -0
  76. package/dist/types/index.d.ts +4 -0
  77. package/dist/types/index.d.ts.map +1 -0
  78. package/dist/types/pagination.d.ts +72 -0
  79. package/dist/types/shared.d.ts +49 -0
  80. package/dist/types/soft-delete.d.ts +627 -0
  81. package/dist/utils/clear-database.d.ts +24 -0
  82. package/dist/utils/clear-database.d.ts.map +1 -0
  83. package/dist/utils/error.utils.d.ts +4 -0
  84. package/dist/utils/error.utils.d.ts.map +1 -0
  85. package/dist/utils/filter.utils.d.ts +40 -0
  86. package/dist/utils/filter.utils.d.ts.map +1 -0
  87. package/dist/utils/helpers.d.ts +72 -0
  88. package/dist/utils/helpers.d.ts.map +1 -0
  89. package/dist/utils/index.d.ts +12 -0
  90. package/dist/utils/index.d.ts.map +1 -0
  91. package/dist/utils/mappers.d.ts +4 -0
  92. package/dist/utils/mappers.d.ts.map +1 -0
  93. package/dist/utils/models.d.ts +3 -0
  94. package/dist/utils/models.d.ts.map +1 -0
  95. package/dist/utils/mongo-utils.d.ts +45 -0
  96. package/dist/utils/mongo-utils.d.ts.map +1 -0
  97. package/dist/utils/object-id.utils.d.ts +16 -0
  98. package/dist/utils/object-id.utils.d.ts.map +1 -0
  99. package/dist/utils/pagination.utils.d.ts +6 -0
  100. package/dist/utils/pagination.utils.d.ts.map +1 -0
  101. package/dist/utils/schema.d.ts +2 -0
  102. package/dist/utils/schema.d.ts.map +1 -0
  103. package/dist/utils/sort.utils.d.ts +12 -0
  104. package/dist/utils/sort.utils.d.ts.map +1 -0
  105. package/dist/validation/index.d.ts +2 -0
  106. package/dist/validation/index.d.ts.map +1 -0
  107. package/dist/validation/validation.types.d.ts +36 -0
  108. package/dist/validation/validation.types.d.ts.map +1 -0
  109. package/dist/validation/validation.utils.d.ts +6 -0
  110. package/dist/validation/validation.utils.d.ts.map +1 -0
  111. package/dist/validation/validators/email.validator.d.ts +8 -0
  112. package/dist/validation/validators/email.validator.d.ts.map +1 -0
  113. package/dist/validation/validators/future.validator.d.ts +8 -0
  114. package/dist/validation/validators/future.validator.d.ts.map +1 -0
  115. package/dist/validation/validators/guid.validator.d.ts +6 -0
  116. package/dist/validation/validators/guid.validator.d.ts.map +1 -0
  117. package/dist/validation/validators/index.d.ts +30 -0
  118. package/dist/validation/validators/index.d.ts.map +1 -0
  119. package/dist/validation/validators/ip.validator.d.ts +6 -0
  120. package/dist/validation/validators/ip.validator.d.ts.map +1 -0
  121. package/dist/validation/validators/ipv4.validator.d.ts +6 -0
  122. package/dist/validation/validators/ipv4.validator.d.ts.map +1 -0
  123. package/dist/validation/validators/ipv6.validator.d.ts +6 -0
  124. package/dist/validation/validators/ipv6.validator.d.ts.map +1 -0
  125. package/dist/validation/validators/mac.validator.d.ts +6 -0
  126. package/dist/validation/validators/mac.validator.d.ts.map +1 -0
  127. package/dist/validation/validators/max-length.validator.d.ts +6 -0
  128. package/dist/validation/validators/max-length.validator.d.ts.map +1 -0
  129. package/dist/validation/validators/max.validator.d.ts +6 -0
  130. package/dist/validation/validators/max.validator.d.ts.map +1 -0
  131. package/dist/validation/validators/min-length.validator.d.ts +6 -0
  132. package/dist/validation/validators/min-length.validator.d.ts.map +1 -0
  133. package/dist/validation/validators/min.validator.d.ts +6 -0
  134. package/dist/validation/validators/min.validator.d.ts.map +1 -0
  135. package/dist/validation/validators/negative.validator.d.ts +6 -0
  136. package/dist/validation/validators/negative.validator.d.ts.map +1 -0
  137. package/dist/validation/validators/not-blank.validator.d.ts +6 -0
  138. package/dist/validation/validators/not-blank.validator.d.ts.map +1 -0
  139. package/dist/validation/validators/not-empty.validator.d.ts +6 -0
  140. package/dist/validation/validators/not-empty.validator.d.ts.map +1 -0
  141. package/dist/validation/validators/object-id.validator.d.ts +6 -0
  142. package/dist/validation/validators/object-id.validator.d.ts.map +1 -0
  143. package/dist/validation/validators/past.validator.d.ts +8 -0
  144. package/dist/validation/validators/past.validator.d.ts.map +1 -0
  145. package/dist/validation/validators/pattern.validator.d.ts +6 -0
  146. package/dist/validation/validators/pattern.validator.d.ts.map +1 -0
  147. package/dist/validation/validators/phone.validator.d.ts +6 -0
  148. package/dist/validation/validators/phone.validator.d.ts.map +1 -0
  149. package/dist/validation/validators/positive.validator.d.ts +6 -0
  150. package/dist/validation/validators/positive.validator.d.ts.map +1 -0
  151. package/dist/validation/validators/range.validator.d.ts +6 -0
  152. package/dist/validation/validators/range.validator.d.ts.map +1 -0
  153. package/dist/validation/validators/required.validator.d.ts +6 -0
  154. package/dist/validation/validators/required.validator.d.ts.map +1 -0
  155. package/dist/validation/validators/size.validator.d.ts +6 -0
  156. package/dist/validation/validators/size.validator.d.ts.map +1 -0
  157. package/dist/validation/validators/ssn.validator.d.ts +6 -0
  158. package/dist/validation/validators/ssn.validator.d.ts.map +1 -0
  159. package/dist/validation/validators/street.validator.d.ts +6 -0
  160. package/dist/validation/validators/street.validator.d.ts.map +1 -0
  161. package/dist/validation/validators/time.validator.d.ts +6 -0
  162. package/dist/validation/validators/time.validator.d.ts.map +1 -0
  163. package/dist/validation/validators/url.validator.d.ts +8 -0
  164. package/dist/validation/validators/url.validator.d.ts.map +1 -0
  165. package/dist/validation/validators/uuid.validator.d.ts +6 -0
  166. package/dist/validation/validators/uuid.validator.d.ts.map +1 -0
  167. package/dist/validation/validators/zip-code.validator.d.ts +6 -0
  168. package/dist/validation/validators/zip-code.validator.d.ts.map +1 -0
  169. package/package.json +68 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/migrations/migrate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAItE,MAAM,WAAW,cAAc;IAC9B,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,EAAE,CAAC,EAAE,YAAY,CAAC;IAClB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,kFAAkF;IAClF,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B;AAgBD;;;;;GAKG;AACH,wBAAsB,OAAO,CAC5B,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,YAAS,EACrD,OAAO,EAAE,cAAc,GACrB,OAAO,CAAC,IAAI,CAAC,CAyBf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAC1C,OAAO,EAAE,cAAc,EACvB,EAAE,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,CAAC,CAYZ"}
@@ -0,0 +1,7 @@
1
+ import type { HydratedDocument, Model } from 'mongoose';
2
+ import type { MigrationRecord } from './migration.types';
3
+ export type MigrationDocument = HydratedDocument<MigrationRecord>;
4
+ type MigrationModel = Model<MigrationDocument>;
5
+ export declare const MigrationModel: MigrationModel;
6
+ export {};
7
+ //# sourceMappingURL=migration.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.model.d.ts","sourceRoot":"","sources":["../../src/migrations/migration.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,mBAAmB,CAAC;AAE1E,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;AAElE,KAAK,cAAc,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAqC/C,eAAO,MAAM,cAAc,gBAG1B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { MigrationListEntry, MigrationRunnerOptions, RunDownOptions, RunUpOptions } from './migration.types';
2
+ /**
3
+ * `MigrationRunner` manages the full lifecycle of database migrations:
4
+ *
5
+ * - `up()` — run all pending migrations, or a specific one by name
6
+ * - `down()` — rollback the last batch, or a specific migration by name
7
+ * - `list()` — return every known migration with its current status
8
+ * - `create()` — generate a new migration file
9
+ *
10
+ * A `Mutex` ensures that concurrent invocations within the same process are
11
+ * serialised; for multi-process safety you should use an external lock
12
+ * (e.g. a MongoDB distributed lock) in front of the runner.
13
+ */
14
+ export declare class MigrationRunner {
15
+ private readonly migrationsDir;
16
+ private readonly connection;
17
+ constructor(options: MigrationRunnerOptions);
18
+ /**
19
+ * Run all pending migrations in ascending timestamp order.
20
+ */
21
+ up(options?: RunUpOptions): Promise<void>;
22
+ /**
23
+ * Rollback the last batch of migrations in descending timestamp order.
24
+ */
25
+ down(options?: RunDownOptions): Promise<void>;
26
+ /**
27
+ * Creates a new migration file.
28
+ */
29
+ create(options: {
30
+ name: string;
31
+ }): Promise<string>;
32
+ /**
33
+ * Returns every migration file found in `migrationsDir` combined with its
34
+ * persisted status from the database.
35
+ */
36
+ list(): Promise<MigrationListEntry[]>;
37
+ private runPendingUp;
38
+ private runSpecificUp;
39
+ private executeMigrationUp;
40
+ private runLastBatchDown;
41
+ private runSpecificDown;
42
+ private executeMigrationDown;
43
+ private fetchExecutedNames;
44
+ private fetchLastBatch;
45
+ private nextBatchNumber;
46
+ }
47
+ //# sourceMappingURL=migration.runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.runner.d.ts","sourceRoot":"","sources":["../../src/migrations/migration.runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEX,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,MAAM,mBAAmB,CAAC;AAa3B;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;gBAEtD,OAAO,EAAE,sBAAsB;IAO3C;;OAEG;IACG,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAY/C;;OAEG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnD;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IASxD;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;YA2B7B,YAAY;YA2BZ,aAAa;YAmBb,kBAAkB;YAyDlB,gBAAgB;YAgChB,eAAe;YAoBf,oBAAoB;YAoCpB,kBAAkB;YAOlB,cAAc;YASd,eAAe;CAI7B"}
@@ -0,0 +1,48 @@
1
+ import type { ClientSession, Connection } from 'mongoose';
2
+ export interface MigrationDefinition {
3
+ /** Kebab-case filename without extension, e.g. `20260421120000-add-user-indexes` */
4
+ name: string;
5
+ /** Absolute path to the migration file */
6
+ filePath: string;
7
+ up(db: Connection, session?: ClientSession): Promise<void>;
8
+ down?(db: Connection, session?: ClientSession): Promise<void>;
9
+ }
10
+ export type MigrationStatus = 'up' | 'failed';
11
+ export interface MigrationRecord {
12
+ /** Kebab-case filename without extension */
13
+ name: string;
14
+ /** Incremented each time `up()` is called; migrations in the same run share a batch number */
15
+ batch: number;
16
+ status: MigrationStatus;
17
+ executedAt: Date;
18
+ /** Execution time in milliseconds */
19
+ duration: number;
20
+ /** Present only when `status` is `failed` */
21
+ error?: string;
22
+ }
23
+ export interface MigrationRunnerOptions {
24
+ /** Absolute path to the directory that contains migration files */
25
+ migrationsDir: string;
26
+ /** An already-connected Mongoose connection */
27
+ connection: Connection;
28
+ }
29
+ export interface RunUpOptions {
30
+ /** When provided, only this migration is executed (by name, regardless of prior status) */
31
+ name?: string;
32
+ /** When true, only logs what would happen without executing anything */
33
+ dryRun?: boolean;
34
+ }
35
+ export interface RunDownOptions {
36
+ /** When provided, only this specific migration is rolled back */
37
+ name?: string;
38
+ /** When true, only logs what would happen without executing anything */
39
+ dryRun?: boolean;
40
+ }
41
+ export type MigrationListStatus = 'pending' | MigrationStatus;
42
+ export interface MigrationListEntry {
43
+ name: string;
44
+ status: MigrationListStatus;
45
+ batch?: number;
46
+ executedAt?: Date;
47
+ }
48
+ //# sourceMappingURL=migration.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.types.d.ts","sourceRoot":"","sources":["../../src/migrations/migration.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAI1D,MAAM,WAAW,mBAAmB;IACnC,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,IAAI,CAAC,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9D;AAID,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE9C,MAAM,WAAW,eAAe;IAC/B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,EAAE,IAAI,CAAC;IACjB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAID,MAAM,WAAW,sBAAsB;IACtC,mEAAmE;IACnE,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,UAAU,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC5B,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC9B,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAID,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,eAAe,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,IAAI,CAAC;CAClB"}
@@ -0,0 +1,40 @@
1
+ import { type Logger } from '@nxgt/shared-logging';
2
+ import type { MigrationDefinition } from './migration.types';
3
+ export declare const logger: Logger;
4
+ export declare function isMigrationFile(filename: string): boolean;
5
+ /**
6
+ * Extracts the migration name (filename without extension).
7
+ * e.g. `20260421120000-add-user-indexes.ts` → `20260421120000-add-user-indexes`
8
+ */
9
+ export declare function migrationName(filename: string): string;
10
+ /**
11
+ * Extracts the timestamp prefix from a migration name.
12
+ * e.g. `20260421120000-add-user-indexes` → `20260421120000`
13
+ * e.g. `123-abc` → `123`
14
+ */
15
+ export declare function migrationTimestamp(name: string): string;
16
+ /**
17
+ * Sorts migration definitions in ascending timestamp order (oldest first).
18
+ * Numerical comparison of the prefix.
19
+ */
20
+ export declare function sortMigrationsAsc(migrations: MigrationDefinition[]): MigrationDefinition[];
21
+ /**
22
+ * Sorts migration definitions in descending timestamp order (newest first).
23
+ */
24
+ export declare function sortMigrationsDesc(migrations: MigrationDefinition[]): MigrationDefinition[];
25
+ /**
26
+ * Creates a new migration file with a 14-digit timestamp prefix and a boilerplate template.
27
+ */
28
+ export declare function createMigrationFile(migrationsDir: string, description: string): Promise<string>;
29
+ /**
30
+ * Reads all valid migration files from `migrationsDir`, dynamically imports
31
+ * each one, and returns an array of `MigrationDefinition` objects sorted in
32
+ * ascending timestamp order (ready for `up()`).
33
+ *
34
+ * Only files matching the `<14-digit-timestamp>-<kebab-description>.ts` pattern
35
+ * are considered. All other files (helpers, fixtures, etc.) are silently skipped.
36
+ *
37
+ * @throws {Error} If a migration file does not export an `up` function.
38
+ */
39
+ export declare function loadMigrationFiles(migrationsDir: string): Promise<MigrationDefinition[]>;
40
+ //# sourceMappingURL=migration.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.utils.d.ts","sourceRoot":"","sources":["../../src/migrations/migration.utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,eAAO,MAAM,MAAM,EAAE,MAA6C,CAAC;AAgBnE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,mBAAmB,EAAE,GAC/B,mBAAmB,EAAE,CAQvB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,UAAU,EAAE,mBAAmB,EAAE,GAC/B,mBAAmB,EAAE,CAQvB;AAID;;GAEG;AACH,wBAAsB,mBAAmB,CACxC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAqCjB;AAID;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CACvC,aAAa,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAiChC"}
@@ -0,0 +1,3 @@
1
+ export * from './pagination';
2
+ export * from './postal-address.model';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,34 @@
1
+ export interface SimplePaginationOptions {
2
+ limit?: number | null;
3
+ skip?: number | null;
4
+ filter?: object | null;
5
+ }
6
+ export interface PaginationOptions {
7
+ first?: number | null;
8
+ last?: number | null;
9
+ before?: string | null;
10
+ after?: string | null;
11
+ filter?: object | null;
12
+ extraFilter?: any | null;
13
+ }
14
+ export interface NestedPaginationOptions {
15
+ first?: number | null;
16
+ last?: number | null;
17
+ before?: string | null;
18
+ after?: string | null;
19
+ }
20
+ export interface IPageInfo {
21
+ startCursor?: string | null;
22
+ endCursor?: string | null;
23
+ hasNextPage: boolean;
24
+ }
25
+ export interface IEdge<T> {
26
+ node: T;
27
+ cursor: string;
28
+ }
29
+ export interface IConnection<T> {
30
+ edges: IEdge<T>[];
31
+ pageInfo: IPageInfo;
32
+ totalCount: number;
33
+ }
34
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/models/pagination.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACvC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,64 @@
1
+ import { Schema } from 'mongoose';
2
+ export type PostalAddress = {
3
+ street?: string;
4
+ locality?: string;
5
+ region?: string;
6
+ postalCode?: string;
7
+ country?: string;
8
+ };
9
+ export declare const PostalAddressSchema: Schema<PostalAddress, import("mongoose").Model<PostalAddress, any, any, any, any, any, PostalAddress>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, PostalAddress, import("mongoose").Document<unknown, {}, PostalAddress, {
10
+ id: string;
11
+ }, import("mongoose").DefaultSchemaOptions> & Omit<PostalAddress & {
12
+ _id: import("mongoose").Types.ObjectId;
13
+ } & {
14
+ __v: number;
15
+ }, "id"> & import("mongoose").HydratedDocumentOverrides<{
16
+ id: string;
17
+ }>, {
18
+ street?: import("mongoose").SchemaDefinitionProperty<string | undefined, PostalAddress, import("mongoose").Document<unknown, {}, PostalAddress, {
19
+ id: string;
20
+ }, import("mongoose").DefaultSchemaOptions> & Omit<PostalAddress & {
21
+ _id: import("mongoose").Types.ObjectId;
22
+ } & {
23
+ __v: number;
24
+ }, "id"> & import("mongoose").HydratedDocumentOverrides<{
25
+ id: string;
26
+ }>> | undefined;
27
+ locality?: import("mongoose").SchemaDefinitionProperty<string | undefined, PostalAddress, import("mongoose").Document<unknown, {}, PostalAddress, {
28
+ id: string;
29
+ }, import("mongoose").DefaultSchemaOptions> & Omit<PostalAddress & {
30
+ _id: import("mongoose").Types.ObjectId;
31
+ } & {
32
+ __v: number;
33
+ }, "id"> & import("mongoose").HydratedDocumentOverrides<{
34
+ id: string;
35
+ }>> | undefined;
36
+ region?: import("mongoose").SchemaDefinitionProperty<string | undefined, PostalAddress, import("mongoose").Document<unknown, {}, PostalAddress, {
37
+ id: string;
38
+ }, import("mongoose").DefaultSchemaOptions> & Omit<PostalAddress & {
39
+ _id: import("mongoose").Types.ObjectId;
40
+ } & {
41
+ __v: number;
42
+ }, "id"> & import("mongoose").HydratedDocumentOverrides<{
43
+ id: string;
44
+ }>> | undefined;
45
+ postalCode?: import("mongoose").SchemaDefinitionProperty<string | undefined, PostalAddress, import("mongoose").Document<unknown, {}, PostalAddress, {
46
+ id: string;
47
+ }, import("mongoose").DefaultSchemaOptions> & Omit<PostalAddress & {
48
+ _id: import("mongoose").Types.ObjectId;
49
+ } & {
50
+ __v: number;
51
+ }, "id"> & import("mongoose").HydratedDocumentOverrides<{
52
+ id: string;
53
+ }>> | undefined;
54
+ country?: import("mongoose").SchemaDefinitionProperty<string | undefined, PostalAddress, import("mongoose").Document<unknown, {}, PostalAddress, {
55
+ id: string;
56
+ }, import("mongoose").DefaultSchemaOptions> & Omit<PostalAddress & {
57
+ _id: import("mongoose").Types.ObjectId;
58
+ } & {
59
+ __v: number;
60
+ }, "id"> & import("mongoose").HydratedDocumentOverrides<{
61
+ id: string;
62
+ }>> | undefined;
63
+ }, PostalAddress>;
64
+ //# sourceMappingURL=postal-address.model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postal-address.model.d.ts","sourceRoot":"","sources":["../../src/models/postal-address.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,MAAM,MAAM,aAAa,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAS/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import mongoose from 'mongoose';
2
+ export { mongoose };
3
+ //# sourceMappingURL=mongoose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoose.d.ts","sourceRoot":"","sources":["../src/mongoose.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const PLUGIN_OPTIONS: {
2
+ autopopulate: {
3
+ maxDepth: number;
4
+ };
5
+ };
6
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/plugins/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;CAE1B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Schema } from 'mongoose';
2
+ export declare const errors: (schema: Schema) => void;
3
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/plugins/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,eAAO,MAAM,MAAM,GAAI,QAAQ,MAAM,SA8BpC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Schema } from 'mongoose';
2
+ import autopopulate from 'mongoose-autopopulate';
3
+ import leanVirtuals from 'mongoose-lean-virtuals';
4
+ import { shared } from './shared';
5
+ export declare const MONGOOSE_PLUGINS: {
6
+ shared: typeof shared;
7
+ errors: (schema: Schema) => void;
8
+ pagination: (schema: Schema) => void;
9
+ leanVirtuals: typeof leanVirtuals;
10
+ autopopulate: typeof autopopulate;
11
+ };
12
+ export declare function applyPlugins(schema: Schema, plugins: any[]): void;
13
+ export * from './consts';
14
+ export * from './pagination/types';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC;AAEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAI1D;AAED,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Schema } from 'mongoose';
2
+ export declare const pagination: (schema: Schema) => void;
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,SAExC,CAAC;AACF,cAAc,SAAS,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { PopulateOptions } from 'mongoose';
2
+ /**
3
+ * Offset pagination — page and size.
4
+ *
5
+ * The cursor/Relay shapes live in `../../models/pagination.ts` and own the
6
+ * plain names (`PaginationOptions`, `NestedPaginationOptions`), because that is
7
+ * what `Model.paginate` answers and what every consumer of it passes. These
8
+ * carry the `Offset` prefix so both can be exported from one package; they had
9
+ * the plain names in sellix-monorepo, where nothing called them.
10
+ */
11
+ export declare class OffsetPaginationOptions {
12
+ filter?: object;
13
+ sort?: object;
14
+ page?: number;
15
+ size?: number;
16
+ }
17
+ export declare class NestedOffsetPaginationOptions {
18
+ page?: number;
19
+ size?: number;
20
+ }
21
+ export interface OffsetPageInfo {
22
+ page: number;
23
+ size: number;
24
+ totalPages: number;
25
+ nbOfElements: number;
26
+ totalElements: number;
27
+ hasNextPage: boolean;
28
+ hasPreviousPage: boolean;
29
+ }
30
+ export interface IPaginatedType<T> {
31
+ data: T[];
32
+ metadata: OffsetPageInfo;
33
+ }
34
+ export type PaginateOffsetOptions = OffsetPaginationOptions & {
35
+ deleted?: 'Deleted' | 'WidthDeleted';
36
+ } & {
37
+ populate?: string | PopulateOptions | (string | PopulateOptions)[];
38
+ };
39
+ export declare class CursorPaginationOptions {
40
+ filter?: object;
41
+ first?: number;
42
+ last?: number;
43
+ after?: string;
44
+ before?: string;
45
+ }
46
+ export interface CursorPageInfo {
47
+ startCursor: string | null;
48
+ endCursor: string | null;
49
+ hasNextPage: boolean;
50
+ totalElements: number;
51
+ }
52
+ export interface ICursorPaginatedType<T> {
53
+ data: T[];
54
+ metadata: CursorPageInfo;
55
+ }
56
+ export type CursorPaginateOptions = CursorPaginationOptions & {
57
+ deleted?: 'Deleted' | 'WidthDeleted';
58
+ } & {
59
+ populate?: string | PopulateOptions | (string | PopulateOptions)[];
60
+ };
61
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/plugins/pagination/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD;;;;;;;;GAQG;AACH,qBAAa,uBAAuB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,6BAA6B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,GAAG;IAC7D,OAAO,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;CACrC,GAAG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,CAAC;CACnE,CAAC;AAEF,qBAAa,uBAAuB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACtC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,GAAG;IAC7D,OAAO,CAAC,EAAE,SAAS,GAAG,cAAc,CAAC;CACrC,GAAG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,CAAC;CACnE,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { HydratedDocument, Schema } from 'mongoose';
2
+ import type { IConnection, PaginationOptions } from '../../models/pagination';
3
+ /**
4
+ * Both repositories put a `paginate` static on every schema, and they meant
5
+ * different things by it: sellix-monorepo answered `{data, metadata}` from a
6
+ * page and a size, nxgt-federation answered a Relay `{edges, pageInfo,
7
+ * totalCount}` from a cursor.
8
+ *
9
+ * `paginate` keeps federation's meaning because federation calls it from
10
+ * dozens of services and sellix-monorepo called it from none — its offset
11
+ * variants were dead code there. They survive under explicit names rather than
12
+ * being deleted, since a cursor connection cannot express "page 7 of 12".
13
+ *
14
+ * paginate cursor, Relay connection
15
+ * paginateList cursor, over a list already in memory
16
+ * paginateOffset page/size, {data, metadata}
17
+ * paginateListOffset page/size, over a list already in memory
18
+ * cursorPaginate cursor, {data, metadata} — sellix's third shape
19
+ */
20
+ export declare function applyPagination(schema: Schema): void;
21
+ export declare function paginateListData<T extends HydratedDocument<{
22
+ id: string;
23
+ }>>(list: T[], options: PaginationOptions): IConnection<T>;
24
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/plugins/pagination/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,gBAAgB,EAAe,MAAM,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,KAAK,EACX,WAAW,EAGX,iBAAiB,EACjB,MAAM,yBAAyB,CAAC;AASjC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,QAwM7C;AAuBD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,EAC1E,IAAI,EAAE,CAAC,EAAE,EACT,OAAO,EAAE,iBAAiB,GACxB,WAAW,CAAC,CAAC,CAAC,CA4ChB"}
@@ -0,0 +1,3 @@
1
+ import type { Schema } from 'mongoose';
2
+ export declare function shared(schema: Schema): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,QAEpC"}
@@ -0,0 +1,3 @@
1
+ import type { Schema } from 'mongoose';
2
+ export declare function applySharedOperations(schema: Schema): void;
3
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/plugins/shared/shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,QAyEnD"}
@@ -0,0 +1,3 @@
1
+ import type { Schema } from 'mongoose';
2
+ export declare function softDelete(schema: Schema): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/soft-delete/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,QAGxC"}
@@ -0,0 +1,3 @@
1
+ import { type Schema } from 'mongoose';
2
+ export declare function applySoftDeleteOperations(schema: Schema): void;
3
+ //# sourceMappingURL=soft-delete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"soft-delete.d.ts","sourceRoot":"","sources":["../../../src/plugins/soft-delete/soft-delete.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAE9C,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,QAqHvD"}
@@ -0,0 +1,88 @@
1
+ import type { Principal } from '@nxgt/shared';
2
+ import type { Mutex } from 'async-mutex';
3
+ import type { HydratedDocument, Model, QueryFilter } from 'mongoose';
4
+ type InferDocType<D extends HydratedDocument<any>> = D extends HydratedDocument<infer T> ? T : D;
5
+ export declare abstract class MongoCrudService<D extends HydratedDocument<any>, CInput = any, UInput = any> {
6
+ readonly principal?: (Principal | null) | undefined;
7
+ protected abstract model: Model<D>;
8
+ /**
9
+ * Additional models to watch in the change stream (e.g. child models
10
+ * that are cascade-deleted alongside the parent).
11
+ */
12
+ protected extraModels: Model<any>[];
13
+ protected abstract mutex: Mutex;
14
+ constructor(principal?: (Principal | null) | undefined);
15
+ protected get changesOptions(): {
16
+ models: (Model<any, {}, {}, {}, any, any, any> | Model<D, {}, {}, {}, import("mongoose").IfAny<D, any, import("mongoose").Document<unknown, {}, D, {}, import("mongoose").DefaultSchemaOptions> & import("mongoose").Require_id<D> & {
17
+ __v: number;
18
+ } & import("mongoose").AddDefaultId<D, {}, import("mongoose").DefaultSchemaOptions>>, any, D>)[];
19
+ author: string;
20
+ mutex: Mutex;
21
+ };
22
+ find(filter?: QueryFilter<D>): Promise<D[]>;
23
+ /**
24
+ * Fetches one document by id.
25
+ *
26
+ * Overriding this to point at another model is fine — that is what the
27
+ * hierarchical services do, and `update()` reads through
28
+ * `findWritableById()` precisely so a read-only view can be used here.
29
+ * Overriding it to reshape the result is not: `create()` returns what
30
+ * this hands back, so anything but a hydrated document breaks writes on
31
+ * that service. Strip or map fields at the serialization boundary
32
+ * instead.
33
+ */
34
+ findById(id: string): Promise<D>;
35
+ create(input: CInput): Promise<D>;
36
+ /**
37
+ * The document `update()` mutates and saves.
38
+ *
39
+ * Deliberately not `findById()`: a service is free to point that at a
40
+ * *view* (`HierarchicalDirectoryModel`, `HierarchicalTypologyModel`) to
41
+ * get materialised `ancestors`, and Mongo refuses to save a document
42
+ * loaded from one — "Namespace x.y is a view, not a collection". Writes
43
+ * therefore go through `this.model`, which is the collection by
44
+ * definition. For a service whose `findById` override only changes the
45
+ * not-found message, this loads exactly the same document.
46
+ */
47
+ protected findWritableById(id: string): Promise<D>;
48
+ update(id: string, input: UInput): Promise<D>;
49
+ /**
50
+ * Deletion flow:
51
+ * 1. `beforeDeleteMany` hook — custom pre-checks (outside transaction)
52
+ * 2. `validateDeletion` — all integrity blockers in parallel (outside transaction)
53
+ * 3. `runWithChangesListening`:
54
+ * a. `runCascades` — registered cascade handlers (inside transaction)
55
+ * b. `model.deleteMany` — parent documents deleted (inside transaction)
56
+ */
57
+ deleteMany(ids: string[]): Promise<void>;
58
+ delete(id: string): Promise<void>;
59
+ /**
60
+ * Override to customize the data passed to `model.create()`.
61
+ * Default: spread input as-is.
62
+ */
63
+ protected buildCreateData(input: CInput): Promise<Partial<InferDocType<D>>> | Partial<InferDocType<D>>;
64
+ /**
65
+ * Override to customize the fields applied to the document during update.
66
+ * Default: spread input as-is.
67
+ */
68
+ protected buildUpdateData(_doc: D, input: UInput): Promise<Partial<InferDocType<D>>> | Partial<InferDocType<D>>;
69
+ /**
70
+ * Called before integrity validation and the deletion transaction.
71
+ * Override to add pre-delete checks (e.g. status guards).
72
+ */
73
+ protected beforeDeleteMany(_ids: string[]): Promise<void>;
74
+ /**
75
+ * Called inside the create transaction, before `model.create()`.
76
+ * Override to add pre-create guards (e.g. uniqueness or status checks).
77
+ * The raw input is passed in case the check depends on it.
78
+ */
79
+ protected beforeCreate(_input: CInput): Promise<void>;
80
+ /**
81
+ * Called inside the update transaction, after `findById`, before
82
+ * `buildUpdateData`. Override to add pre-update guards (e.g. status locks).
83
+ * Receives the already-fetched document — no extra DB round-trip needed.
84
+ */
85
+ protected beforeUpdate(_doc: D, _input: UInput): Promise<void>;
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=crud.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crud.service.d.ts","sourceRoot":"","sources":["../../src/services/crud.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIrE,KAAK,YAAY,CAAC,CAAC,SAAS,gBAAgB,CAAC,GAAG,CAAC,IAChD,CAAC,SAAS,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7C,8BAAsB,gBAAgB,CACrC,CAAC,SAAS,gBAAgB,CAAC,GAAG,CAAC,EAC/B,MAAM,GAAG,GAAG,EACZ,MAAM,GAAG,GAAG;IAYA,QAAQ,CAAC,SAAS,CAAC,GAAE,SAAS,GAAG,IAAI;IAVjD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnC;;;OAGG;IACH,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAM;IAEzC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;gBAEX,SAAS,CAAC,GAAE,SAAS,GAAG,IAAI,aAAA;IAEjD,SAAS,KAAK,cAAc;;;;;;MAM3B;IAIK,IAAI,CAAC,MAAM,GAAE,WAAW,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAIrD;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAYhC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAgBvC;;;;;;;;;;OAUG;cACa,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAUlD,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAyBnD;;;;;;;OAOG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvC;;;OAGG;IACH,SAAS,CAAC,eAAe,CACxB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAI/D;;;OAGG;IACH,SAAS,CAAC,eAAe,CACxB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAI/D;;;OAGG;cACa,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAE/D;;;;OAIG;cACa,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE3D;;;;OAIG;cACa,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CACpE"}
@@ -0,0 +1,2 @@
1
+ export * from './crud.service';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import './pagination.d.ts';
2
+ import './shared.d.ts';
3
+ import './soft-delete.d.ts';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,oBAAoB,CAAC"}