@decaf-ts/core 0.12.1 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +140 -1
  2. package/dist/core.cjs +1 -1
  3. package/dist/core.cjs.map +1 -1
  4. package/dist/core.js +1 -1
  5. package/dist/core.js.map +1 -1
  6. package/lib/esm/index.d.ts +2 -1
  7. package/lib/esm/index.js +2 -2
  8. package/lib/esm/index.js.map +1 -1
  9. package/lib/esm/migrations/Migration.d.ts +1 -1
  10. package/lib/esm/migrations/MigrationService.d.ts +45 -2
  11. package/lib/esm/migrations/MigrationService.js +436 -97
  12. package/lib/esm/migrations/MigrationService.js.map +1 -1
  13. package/lib/esm/migrations/MigrationTaskBuilder.d.ts +10 -0
  14. package/lib/esm/migrations/MigrationTaskBuilder.js +21 -0
  15. package/lib/esm/migrations/MigrationTaskBuilder.js.map +1 -0
  16. package/lib/esm/migrations/MigrationTasks.js +10 -4
  17. package/lib/esm/migrations/MigrationTasks.js.map +1 -1
  18. package/lib/esm/migrations/MigrationVersioning.d.ts +7 -0
  19. package/lib/esm/migrations/MigrationVersioning.js +2 -0
  20. package/lib/esm/migrations/MigrationVersioning.js.map +1 -0
  21. package/lib/esm/migrations/SemverMigrationVersioning.d.ts +10 -0
  22. package/lib/esm/migrations/SemverMigrationVersioning.js +43 -0
  23. package/lib/esm/migrations/SemverMigrationVersioning.js.map +1 -0
  24. package/lib/esm/migrations/StandardMigrationVersioning.d.ts +12 -0
  25. package/lib/esm/migrations/StandardMigrationVersioning.js +27 -0
  26. package/lib/esm/migrations/StandardMigrationVersioning.js.map +1 -0
  27. package/lib/esm/migrations/decorators.d.ts +5 -0
  28. package/lib/esm/migrations/decorators.js +42 -11
  29. package/lib/esm/migrations/decorators.js.map +1 -1
  30. package/lib/esm/migrations/index.d.ts +3 -0
  31. package/lib/esm/migrations/index.js +3 -0
  32. package/lib/esm/migrations/index.js.map +1 -1
  33. package/lib/esm/migrations/types.d.ts +25 -2
  34. package/lib/esm/persistence/Adapter.d.ts +1 -1
  35. package/lib/esm/persistence/constants.js +6 -1
  36. package/lib/esm/persistence/constants.js.map +1 -1
  37. package/lib/esm/query/Paginator.js +16 -5
  38. package/lib/esm/query/Paginator.js.map +1 -1
  39. package/lib/esm/query/constants.d.ts +1 -0
  40. package/lib/esm/query/constants.js +1 -0
  41. package/lib/esm/query/constants.js.map +1 -1
  42. package/lib/esm/query/decorators.js +1 -1
  43. package/lib/esm/query/decorators.js.map +1 -1
  44. package/lib/esm/repository/Repository.d.ts +1 -0
  45. package/lib/esm/repository/Repository.js +51 -0
  46. package/lib/esm/repository/Repository.js.map +1 -1
  47. package/lib/esm/services/ModelService.d.ts +1 -0
  48. package/lib/esm/services/ModelService.js +4 -0
  49. package/lib/esm/services/ModelService.js.map +1 -1
  50. package/lib/esm/tasks/TaskService.d.ts +1 -0
  51. package/lib/esm/tasks/TaskService.js +4 -0
  52. package/lib/esm/tasks/TaskService.js.map +1 -1
  53. package/lib/index.cjs +2 -2
  54. package/lib/index.d.ts +2 -1
  55. package/lib/index.js.map +1 -1
  56. package/lib/migrations/Migration.d.ts +1 -1
  57. package/lib/migrations/MigrationService.cjs +436 -97
  58. package/lib/migrations/MigrationService.d.ts +45 -2
  59. package/lib/migrations/MigrationService.js.map +1 -1
  60. package/lib/migrations/MigrationTaskBuilder.cjs +25 -0
  61. package/lib/migrations/MigrationTaskBuilder.d.ts +10 -0
  62. package/lib/migrations/MigrationTaskBuilder.js.map +1 -0
  63. package/lib/migrations/MigrationTasks.cjs +10 -4
  64. package/lib/migrations/MigrationTasks.js.map +1 -1
  65. package/lib/migrations/MigrationVersioning.cjs +3 -0
  66. package/lib/migrations/MigrationVersioning.d.ts +7 -0
  67. package/lib/migrations/MigrationVersioning.js.map +1 -0
  68. package/lib/migrations/SemverMigrationVersioning.cjs +80 -0
  69. package/lib/migrations/SemverMigrationVersioning.d.ts +10 -0
  70. package/lib/migrations/SemverMigrationVersioning.js.map +1 -0
  71. package/lib/migrations/StandardMigrationVersioning.cjs +31 -0
  72. package/lib/migrations/StandardMigrationVersioning.d.ts +12 -0
  73. package/lib/migrations/StandardMigrationVersioning.js.map +1 -0
  74. package/lib/migrations/decorators.cjs +42 -11
  75. package/lib/migrations/decorators.d.ts +5 -0
  76. package/lib/migrations/decorators.js.map +1 -1
  77. package/lib/migrations/index.cjs +3 -0
  78. package/lib/migrations/index.d.ts +3 -0
  79. package/lib/migrations/index.js.map +1 -1
  80. package/lib/migrations/types.d.ts +25 -2
  81. package/lib/persistence/Adapter.d.ts +1 -1
  82. package/lib/persistence/constants.cjs +6 -1
  83. package/lib/persistence/constants.js.map +1 -1
  84. package/lib/query/Paginator.cjs +16 -5
  85. package/lib/query/Paginator.js.map +1 -1
  86. package/lib/query/constants.cjs +1 -0
  87. package/lib/query/constants.d.ts +1 -0
  88. package/lib/query/constants.js.map +1 -1
  89. package/lib/query/decorators.cjs +1 -1
  90. package/lib/query/decorators.js.map +1 -1
  91. package/lib/repository/Repository.cjs +51 -0
  92. package/lib/repository/Repository.d.ts +1 -0
  93. package/lib/repository/Repository.js.map +1 -1
  94. package/lib/services/ModelService.cjs +4 -0
  95. package/lib/services/ModelService.d.ts +1 -0
  96. package/lib/services/ModelService.js.map +1 -1
  97. package/lib/tasks/TaskService.cjs +4 -0
  98. package/lib/tasks/TaskService.d.ts +1 -0
  99. package/lib/tasks/TaskService.js.map +1 -1
  100. package/package.json +9 -1
@@ -15,6 +15,7 @@ export * from "./query";
15
15
  export * from "./services";
16
16
  export * from "./tasks";
17
17
  export * from "./utils";
18
+ export * from "./migrations";
18
19
  export * from "./persistence";
19
20
  /**
20
21
  * @description Stores the current package version
@@ -22,7 +23,7 @@ export * from "./persistence";
22
23
  * @const VERSION
23
24
  * @memberOf module:core
24
25
  */
25
- export declare const VERSION = "0.12.1";
26
+ export declare const VERSION = "0.13.0";
26
27
  /**
27
28
  * @description Stores the current package version
28
29
  * @summary A constant representing the version of the core package
package/lib/esm/index.js CHANGED
@@ -23,7 +23,7 @@ export * from "./tasks/index.js";
23
23
  export * from "./utils/index.js";
24
24
  // commented out
25
25
  // export * from "./ram";
26
- // export * from "./migrations";
26
+ export * from "./migrations/index.js";
27
27
  //left to last on purpose
28
28
  export * from "./persistence/index.js";
29
29
  /**
@@ -32,7 +32,7 @@ export * from "./persistence/index.js";
32
32
  * @const VERSION
33
33
  * @memberOf module:core
34
34
  */
35
- export const VERSION = "0.12.1";
35
+ export const VERSION = "0.13.0";
36
36
  /**
37
37
  * @description Stores the current package version
38
38
  * @summary A constant representing the version of the core package
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,oCAAiC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,kFAAkF;AAClF,WAAW,CAAC,WAAW,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;AAEnD,4BAA4B;AAC5B,qCAA4B;AAC5B,sCAA6B;AAE7B,gCAAuB;AACvB,oCAA2B;AAC3B,sCAA6B;AAC7B,iCAAwB;AACxB,iCAAwB;AACxB,oCAA2B;AAC3B,iCAAwB;AACxB,iCAAwB;AAExB,gBAAgB;AAChB,yBAAyB;AACzB,gCAAgC;AAEhC,yBAAyB;AACzB,uCAA8B;AAE9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,mBAAmB,EAAE,oCAAiC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,kFAAkF;AAClF,WAAW,CAAC,WAAW,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAC;AAEnD,4BAA4B;AAC5B,qCAA4B;AAC5B,sCAA6B;AAE7B,gCAAuB;AACvB,oCAA2B;AAC3B,sCAA6B;AAC7B,iCAAwB;AACxB,iCAAwB;AACxB,oCAA2B;AAC3B,iCAAwB;AACxB,iCAAwB;AAExB,gBAAgB;AAChB,yBAAyB;AACzB,sCAA6B;AAE7B,yBAAyB;AACzB,uCAA8B;AAE9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;AAE1C,QAAQ,CAAC,eAAe,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
@@ -7,7 +7,7 @@ export declare abstract class AbsMigration<A extends Adapter<any, any, any, any>
7
7
  private _precedence?;
8
8
  transaction: boolean;
9
9
  get reference(): string;
10
- get precedence(): Migration<any, any, void>;
10
+ get precedence(): string | Migration<any, any, void>;
11
11
  protected constructor();
12
12
  protected get adapter(): A;
13
13
  protected abstract getQueryRunner(conn: ConnectionForAdapter<A>): QUERYRUNNER;
@@ -1,20 +1,63 @@
1
- import { Migration, MigrationConfig } from "./types";
1
+ import { Migration, MigrationConfig, PersistenceMigrationConfig } from "./types";
2
2
  import { ClientBasedService } from "../services/services";
3
3
  import { Adapter } from "../persistence/Adapter";
4
4
  import { ContextOf } from "../persistence/types";
5
5
  import { ContextualArgs, MaybeContextualArg } from "../utils/ContextualLoggedClass";
6
+ import { TaskModel } from "../tasks/models/TaskModel";
7
+ import { MigrationVersioning } from "./MigrationVersioning";
8
+ type ResolvedMigration = {
9
+ migration: Migration<any, any>;
10
+ flavour: string;
11
+ reference: string;
12
+ version: string;
13
+ };
14
+ type VersionTask = {
15
+ version: string;
16
+ task: TaskModel;
17
+ };
6
18
  export declare class MigrationService<PERSIST extends boolean, A extends Adapter<any, any, any, any> = any, R = void> extends ClientBasedService<PERSIST extends boolean ? A : void, MigrationConfig<PERSIST>> implements Migration<any, A, R> {
19
+ protected versioning: MigrationVersioning;
20
+ protected queuedTaskChain: Array<{
21
+ id: string;
22
+ version: string;
23
+ }>;
7
24
  flavour?: string;
8
25
  readonly reference: string;
9
26
  readonly precedence: Migration<any, any> | Migration<any, any>[] | null;
10
27
  transaction: boolean;
11
28
  constructor();
29
+ static migrateAdapters<AD extends Adapter<any, any, any, any> = Adapter<any, any, any, any>>(adapters: AD[], cfg?: PersistenceMigrationConfig<AD>, ...args: MaybeContextualArg<ContextOf<AD>>): Promise<MigrationService<true, AD>[]>;
12
30
  initialize(...args: MaybeContextualArg<ContextOf<A>>): Promise<{
13
31
  config: MigrationConfig<PERSIST>;
14
32
  client: PERSIST extends boolean ? A : void;
15
33
  }>;
16
34
  down(qr: any, adapter: any, ...args: ContextualArgs<ContextOf<any>>): Promise<void>;
17
- protected sort(migrations: Migration<any, any>[]): Migration<any, any, void>[];
35
+ protected normalizeVersion(raw: string, precedenceHint?: string): string;
36
+ protected extractPrecedenceTokens(migration: Migration<any, any>): string[];
37
+ protected referencesMigration(candidate: Migration<any, any>, target: ResolvedMigration): boolean;
38
+ protected precedenceHint(migration: Migration<any, any>): string | undefined;
39
+ protected compareByPrecedence(migration1: ResolvedMigration, migration2: ResolvedMigration): number;
40
+ protected sort(migrations: ResolvedMigration[]): ResolvedMigration[];
41
+ protected resolveMigration(migration: Migration<any, any>): ResolvedMigration;
42
+ protected shouldIncludeMigration(migration: ResolvedMigration, targetFlavour?: string, includeGeneric?: boolean): boolean;
43
+ protected collectMigrations(targetFlavour?: string, includeGeneric?: boolean): ResolvedMigration[];
44
+ protected buildExecutionPlan(options?: {
45
+ fromVersion?: string;
46
+ toVersion?: string;
47
+ targetFlavour?: string;
48
+ includeGeneric?: boolean;
49
+ }): ResolvedMigration[];
50
+ protected executeMigration(migration: ResolvedMigration, ...args: ContextualArgs<ContextOf<any>>): Promise<void>;
51
+ protected buildMigrationTaskForPlan(plan: ResolvedMigration[], ...args: ContextualArgs<ContextOf<any>>): TaskModel;
52
+ protected buildMigrationTasksForPlan(plan: ResolvedMigration[], ...args: ContextualArgs<ContextOf<any>>): VersionTask[];
53
+ createMigrationTask(targetVersion?: string, fromVersion?: string, ...args: ContextualArgs<ContextOf<any>>): TaskModel;
54
+ createMigrationTasks(targetVersion?: string, fromVersion?: string, ...args: ContextualArgs<ContextOf<any>>): VersionTask[];
55
+ protected migrationTaskIdsFromContext(taskKey: string, args: ContextualArgs<ContextOf<any>>): string[];
18
56
  migrate(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
57
+ migrateNormally(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
58
+ migrateViaTasks(qr?: any, adapter?: any, ...args: MaybeContextualArg<ContextOf<any>>): Promise<R>;
59
+ track(taskIds?: string[] | string, ...args: MaybeContextualArg<ContextOf<any>>): Promise<void>;
60
+ retry(taskIds?: string[] | string, ...args: MaybeContextualArg<ContextOf<any>>): Promise<void>;
19
61
  up(qr: any, adapter: any, ...args: ContextualArgs<ContextOf<any>>): Promise<void>;
20
62
  }
63
+ export {};