@orchestr-sh/orchestr 1.5.11 → 1.6.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 (161) hide show
  1. package/README.md +199 -0
  2. package/dist/Console/Command.d.ts +59 -0
  3. package/dist/Console/Command.d.ts.map +1 -0
  4. package/dist/Console/Command.js +68 -0
  5. package/dist/Console/Command.js.map +1 -0
  6. package/dist/Console/Commands/MakeMigrationCommand.d.ts +15 -0
  7. package/dist/Console/Commands/MakeMigrationCommand.d.ts.map +1 -0
  8. package/dist/Console/Commands/MakeMigrationCommand.js +41 -0
  9. package/dist/Console/Commands/MakeMigrationCommand.js.map +1 -0
  10. package/dist/Console/Commands/MakeSeederCommand.d.ts +23 -0
  11. package/dist/Console/Commands/MakeSeederCommand.d.ts.map +1 -0
  12. package/dist/Console/Commands/MakeSeederCommand.js +109 -0
  13. package/dist/Console/Commands/MakeSeederCommand.js.map +1 -0
  14. package/dist/Console/Commands/MigrateCommand.d.ts +15 -0
  15. package/dist/Console/Commands/MigrateCommand.d.ts.map +1 -0
  16. package/dist/Console/Commands/MigrateCommand.js +48 -0
  17. package/dist/Console/Commands/MigrateCommand.js.map +1 -0
  18. package/dist/Console/Commands/MigrateFreshCommand.d.ts +15 -0
  19. package/dist/Console/Commands/MigrateFreshCommand.d.ts.map +1 -0
  20. package/dist/Console/Commands/MigrateFreshCommand.js +54 -0
  21. package/dist/Console/Commands/MigrateFreshCommand.js.map +1 -0
  22. package/dist/Console/Commands/MigrateRefreshCommand.d.ts +15 -0
  23. package/dist/Console/Commands/MigrateRefreshCommand.d.ts.map +1 -0
  24. package/dist/Console/Commands/MigrateRefreshCommand.js +52 -0
  25. package/dist/Console/Commands/MigrateRefreshCommand.js.map +1 -0
  26. package/dist/Console/Commands/MigrateResetCommand.d.ts +15 -0
  27. package/dist/Console/Commands/MigrateResetCommand.d.ts.map +1 -0
  28. package/dist/Console/Commands/MigrateResetCommand.js +46 -0
  29. package/dist/Console/Commands/MigrateResetCommand.js.map +1 -0
  30. package/dist/Console/Commands/MigrateRollbackCommand.d.ts +15 -0
  31. package/dist/Console/Commands/MigrateRollbackCommand.d.ts.map +1 -0
  32. package/dist/Console/Commands/MigrateRollbackCommand.js +49 -0
  33. package/dist/Console/Commands/MigrateRollbackCommand.js.map +1 -0
  34. package/dist/Console/Commands/MigrateStatusCommand.d.ts +15 -0
  35. package/dist/Console/Commands/MigrateStatusCommand.d.ts.map +1 -0
  36. package/dist/Console/Commands/MigrateStatusCommand.js +58 -0
  37. package/dist/Console/Commands/MigrateStatusCommand.js.map +1 -0
  38. package/dist/Console/Commands/SeedCommand.d.ts +15 -0
  39. package/dist/Console/Commands/SeedCommand.d.ts.map +1 -0
  40. package/dist/Console/Commands/SeedCommand.js +44 -0
  41. package/dist/Console/Commands/SeedCommand.js.map +1 -0
  42. package/dist/Console/ConsoleKernel.d.ts +45 -0
  43. package/dist/Console/ConsoleKernel.d.ts.map +1 -0
  44. package/dist/Console/ConsoleKernel.js +109 -0
  45. package/dist/Console/ConsoleKernel.js.map +1 -0
  46. package/dist/Console/orchestr.d.ts +8 -0
  47. package/dist/Console/orchestr.d.ts.map +1 -0
  48. package/dist/Console/orchestr.js +45 -0
  49. package/dist/Console/orchestr.js.map +1 -0
  50. package/dist/Container/Container.js.map +1 -1
  51. package/dist/Database/Connection.d.ts.map +1 -1
  52. package/dist/Database/Connection.js.map +1 -1
  53. package/dist/Database/Ensemble/Concerns/HasDynamicRelations.d.ts.map +1 -1
  54. package/dist/Database/Ensemble/Concerns/HasDynamicRelations.js +43 -12
  55. package/dist/Database/Ensemble/Concerns/HasDynamicRelations.js.map +1 -1
  56. package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts.map +1 -1
  57. package/dist/Database/Ensemble/Concerns/HasRelationships.js +2 -5
  58. package/dist/Database/Ensemble/Concerns/HasRelationships.js.map +1 -1
  59. package/dist/Database/Ensemble/Ensemble.d.ts.map +1 -1
  60. package/dist/Database/Ensemble/Ensemble.js +15 -11
  61. package/dist/Database/Ensemble/Ensemble.js.map +1 -1
  62. package/dist/Database/Ensemble/EnsembleBuilder.d.ts.map +1 -1
  63. package/dist/Database/Ensemble/EnsembleBuilder.js.map +1 -1
  64. package/dist/Database/Ensemble/Relations/BelongsTo.d.ts.map +1 -1
  65. package/dist/Database/Ensemble/Relations/BelongsTo.js.map +1 -1
  66. package/dist/Database/Ensemble/Relations/BelongsToMany.d.ts.map +1 -1
  67. package/dist/Database/Ensemble/Relations/BelongsToMany.js +1 -4
  68. package/dist/Database/Ensemble/Relations/BelongsToMany.js.map +1 -1
  69. package/dist/Database/Ensemble/Relations/HasMany.d.ts.map +1 -1
  70. package/dist/Database/Ensemble/Relations/HasMany.js.map +1 -1
  71. package/dist/Database/Ensemble/Relations/HasOne.d.ts.map +1 -1
  72. package/dist/Database/Ensemble/Relations/HasOne.js.map +1 -1
  73. package/dist/Database/Ensemble/Relations/MorphMany.d.ts.map +1 -1
  74. package/dist/Database/Ensemble/Relations/MorphMany.js +2 -6
  75. package/dist/Database/Ensemble/Relations/MorphMany.js.map +1 -1
  76. package/dist/Database/Ensemble/Relations/MorphOne.d.ts.map +1 -1
  77. package/dist/Database/Ensemble/Relations/MorphOne.js +2 -6
  78. package/dist/Database/Ensemble/Relations/MorphOne.js.map +1 -1
  79. package/dist/Database/Ensemble/Relations/MorphTo.d.ts.map +1 -1
  80. package/dist/Database/Ensemble/Relations/MorphTo.js +5 -11
  81. package/dist/Database/Ensemble/Relations/MorphTo.js.map +1 -1
  82. package/dist/Database/Ensemble/Relations/MorphToMany.d.ts.map +1 -1
  83. package/dist/Database/Ensemble/Relations/MorphToMany.js +1 -3
  84. package/dist/Database/Ensemble/Relations/MorphToMany.js.map +1 -1
  85. package/dist/Database/Ensemble/Relations/MorphedByMany.d.ts.map +1 -1
  86. package/dist/Database/Ensemble/Relations/MorphedByMany.js.map +1 -1
  87. package/dist/Database/Ensemble/Relations/Relation.d.ts.map +1 -1
  88. package/dist/Database/Ensemble/Relations/Relation.js +4 -2
  89. package/dist/Database/Ensemble/Relations/Relation.js.map +1 -1
  90. package/dist/Database/Migrations/Blueprint.d.ts +166 -0
  91. package/dist/Database/Migrations/Blueprint.d.ts.map +1 -0
  92. package/dist/Database/Migrations/Blueprint.js +318 -0
  93. package/dist/Database/Migrations/Blueprint.js.map +1 -0
  94. package/dist/Database/Migrations/ColumnDefinition.d.ts +62 -0
  95. package/dist/Database/Migrations/ColumnDefinition.d.ts.map +1 -0
  96. package/dist/Database/Migrations/ColumnDefinition.js +95 -0
  97. package/dist/Database/Migrations/ColumnDefinition.js.map +1 -0
  98. package/dist/Database/Migrations/ForeignKeyDefinition.d.ts +32 -0
  99. package/dist/Database/Migrations/ForeignKeyDefinition.d.ts.map +1 -0
  100. package/dist/Database/Migrations/ForeignKeyDefinition.js +50 -0
  101. package/dist/Database/Migrations/ForeignKeyDefinition.js.map +1 -0
  102. package/dist/Database/Migrations/Migration.d.ts +17 -0
  103. package/dist/Database/Migrations/Migration.d.ts.map +1 -0
  104. package/dist/Database/Migrations/Migration.js +12 -0
  105. package/dist/Database/Migrations/Migration.js.map +1 -0
  106. package/dist/Database/Migrations/MigrationCreator.d.ts +42 -0
  107. package/dist/Database/Migrations/MigrationCreator.d.ts.map +1 -0
  108. package/dist/Database/Migrations/MigrationCreator.js +184 -0
  109. package/dist/Database/Migrations/MigrationCreator.js.map +1 -0
  110. package/dist/Database/Migrations/MigrationRepository.d.ts +65 -0
  111. package/dist/Database/Migrations/MigrationRepository.d.ts.map +1 -0
  112. package/dist/Database/Migrations/MigrationRepository.js +120 -0
  113. package/dist/Database/Migrations/MigrationRepository.js.map +1 -0
  114. package/dist/Database/Migrations/Migrator.d.ts +84 -0
  115. package/dist/Database/Migrations/Migrator.d.ts.map +1 -0
  116. package/dist/Database/Migrations/Migrator.js +239 -0
  117. package/dist/Database/Migrations/Migrator.js.map +1 -0
  118. package/dist/Database/Migrations/SchemaBuilder.d.ts +136 -0
  119. package/dist/Database/Migrations/SchemaBuilder.d.ts.map +1 -0
  120. package/dist/Database/Migrations/SchemaBuilder.js +505 -0
  121. package/dist/Database/Migrations/SchemaBuilder.js.map +1 -0
  122. package/dist/Database/Query/Builder.d.ts.map +1 -1
  123. package/dist/Database/Query/Builder.js +5 -4
  124. package/dist/Database/Query/Builder.js.map +1 -1
  125. package/dist/Database/Seeders/Seeder.d.ts +29 -0
  126. package/dist/Database/Seeders/Seeder.d.ts.map +1 -0
  127. package/dist/Database/Seeders/Seeder.js +41 -0
  128. package/dist/Database/Seeders/Seeder.js.map +1 -0
  129. package/dist/Database/Seeders/SeederRunner.d.ts +41 -0
  130. package/dist/Database/Seeders/SeederRunner.d.ts.map +1 -0
  131. package/dist/Database/Seeders/SeederRunner.js +134 -0
  132. package/dist/Database/Seeders/SeederRunner.js.map +1 -0
  133. package/dist/Facades/DB.d.ts.map +1 -1
  134. package/dist/Facades/DB.js.map +1 -1
  135. package/dist/Facades/Route.js +1 -1
  136. package/dist/Foundation/Application.js +3 -3
  137. package/dist/Foundation/Application.js.map +1 -1
  138. package/dist/Foundation/Config/Config.js +1 -1
  139. package/dist/Foundation/Config/Config.js.map +1 -1
  140. package/dist/Foundation/Http/FormRequest.d.ts.map +1 -1
  141. package/dist/Foundation/Http/FormRequest.js +2 -2
  142. package/dist/Foundation/Http/FormRequest.js.map +1 -1
  143. package/dist/Foundation/Http/Kernel.d.ts.map +1 -1
  144. package/dist/Foundation/Http/Kernel.js +1 -1
  145. package/dist/Foundation/Http/Kernel.js.map +1 -1
  146. package/dist/Foundation/Http/Validator.d.ts.map +1 -1
  147. package/dist/Foundation/Http/Validator.js +27 -22
  148. package/dist/Foundation/Http/Validator.js.map +1 -1
  149. package/dist/Routing/Request.js +1 -1
  150. package/dist/Routing/Request.js.map +1 -1
  151. package/dist/Routing/Route.js +1 -1
  152. package/dist/Routing/Route.js.map +1 -1
  153. package/dist/Routing/Router.d.ts.map +1 -1
  154. package/dist/Routing/Router.js +5 -6
  155. package/dist/Routing/Router.js.map +1 -1
  156. package/dist/Support/Facade.js +2 -2
  157. package/dist/index.d.ts +28 -4
  158. package/dist/index.d.ts.map +1 -1
  159. package/dist/index.js +48 -0
  160. package/dist/index.js.map +1 -1
  161. package/package.json +34 -10
@@ -0,0 +1,32 @@
1
+ /**
2
+ * ForeignKeyDefinition
3
+ *
4
+ * Represents a foreign key constraint in a migration
5
+ */
6
+ import { ForeignKeyDefinition as IForeignKeyDefinition } from '../Contracts/Schema';
7
+ export declare class ForeignKeyDefinition implements IForeignKeyDefinition {
8
+ columns: string[];
9
+ referencedColumns?: string[];
10
+ referencedTable?: string;
11
+ onDeleteAction?: 'cascade' | 'set null' | 'restrict' | 'no action';
12
+ onUpdateAction?: 'cascade' | 'set null' | 'restrict' | 'no action';
13
+ name?: string;
14
+ constructor(columns: string | string[], name?: string);
15
+ /**
16
+ * Specify the referenced column(s)
17
+ */
18
+ references(columns: string | string[]): this;
19
+ /**
20
+ * Specify the referenced table
21
+ */
22
+ on(table: string): this;
23
+ /**
24
+ * Set the ON DELETE action
25
+ */
26
+ onDelete(action: 'cascade' | 'set null' | 'restrict' | 'no action'): this;
27
+ /**
28
+ * Set the ON UPDATE action
29
+ */
30
+ onUpdate(action: 'cascade' | 'set null' | 'restrict' | 'no action'): this;
31
+ }
32
+ //# sourceMappingURL=ForeignKeyDefinition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForeignKeyDefinition.d.ts","sourceRoot":"","sources":["../../../src/Database/Migrations/ForeignKeyDefinition.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEpF,qBAAa,oBAAqB,YAAW,qBAAqB;IACzD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IACnE,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;IAKrD;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI;IAK5C;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKvB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI;IAKzE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI;CAI1E"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * ForeignKeyDefinition
4
+ *
5
+ * Represents a foreign key constraint in a migration
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ForeignKeyDefinition = void 0;
9
+ class ForeignKeyDefinition {
10
+ columns;
11
+ referencedColumns;
12
+ referencedTable;
13
+ onDeleteAction;
14
+ onUpdateAction;
15
+ name;
16
+ constructor(columns, name) {
17
+ this.columns = Array.isArray(columns) ? columns : [columns];
18
+ this.name = name;
19
+ }
20
+ /**
21
+ * Specify the referenced column(s)
22
+ */
23
+ references(columns) {
24
+ this.referencedColumns = Array.isArray(columns) ? columns : [columns];
25
+ return this;
26
+ }
27
+ /**
28
+ * Specify the referenced table
29
+ */
30
+ on(table) {
31
+ this.referencedTable = table;
32
+ return this;
33
+ }
34
+ /**
35
+ * Set the ON DELETE action
36
+ */
37
+ onDelete(action) {
38
+ this.onDeleteAction = action;
39
+ return this;
40
+ }
41
+ /**
42
+ * Set the ON UPDATE action
43
+ */
44
+ onUpdate(action) {
45
+ this.onUpdateAction = action;
46
+ return this;
47
+ }
48
+ }
49
+ exports.ForeignKeyDefinition = ForeignKeyDefinition;
50
+ //# sourceMappingURL=ForeignKeyDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForeignKeyDefinition.js","sourceRoot":"","sources":["../../../src/Database/Migrations/ForeignKeyDefinition.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,MAAa,oBAAoB;IACxB,OAAO,CAAW;IAClB,iBAAiB,CAAY;IAC7B,eAAe,CAAU;IACzB,cAAc,CAAqD;IACnE,cAAc,CAAqD;IACnE,IAAI,CAAU;IAErB,YAAY,OAA0B,EAAE,IAAa;QACnD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,OAA0B;QACnC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,EAAE,CAAC,KAAa;QACd,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,MAAyD;QAChE,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,MAAyD;QAChE,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5CD,oDA4CC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Migration
3
+ *
4
+ * Base class for all database migrations
5
+ */
6
+ import { Schema } from '../Contracts/Schema';
7
+ export declare abstract class Migration {
8
+ /**
9
+ * Run the migrations
10
+ */
11
+ abstract up(schema: Schema): Promise<void>;
12
+ /**
13
+ * Reverse the migrations
14
+ */
15
+ abstract down(schema: Schema): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=Migration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration.d.ts","sourceRoot":"","sources":["../../../src/Database/Migrations/Migration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,8BAAsB,SAAS;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC7C"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * Migration
4
+ *
5
+ * Base class for all database migrations
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Migration = void 0;
9
+ class Migration {
10
+ }
11
+ exports.Migration = Migration;
12
+ //# sourceMappingURL=Migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration.js","sourceRoot":"","sources":["../../../src/Database/Migrations/Migration.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH,MAAsB,SAAS;CAU9B;AAVD,8BAUC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * MigrationCreator
3
+ *
4
+ * Creates new migration files from stubs
5
+ */
6
+ export declare class MigrationCreator {
7
+ protected customStubPath?: string | undefined;
8
+ constructor(customStubPath?: string | undefined);
9
+ /**
10
+ * Create a new migration file
11
+ */
12
+ create(name: string, migrationPath: string, table?: string, create?: boolean): Promise<string>;
13
+ /**
14
+ * Get the migration stub
15
+ */
16
+ protected getStub(table?: string, create?: boolean): string;
17
+ /**
18
+ * Get the blank migration stub
19
+ */
20
+ protected getBlankStub(): string;
21
+ /**
22
+ * Get the create table stub
23
+ */
24
+ protected getCreateStub(): string;
25
+ /**
26
+ * Get the update table stub
27
+ */
28
+ protected getUpdateStub(): string;
29
+ /**
30
+ * Populate the stub with table name
31
+ */
32
+ protected populateStub(stub: string, table?: string): string;
33
+ /**
34
+ * Get the date prefix for the migration
35
+ */
36
+ protected getDatePrefix(): string;
37
+ /**
38
+ * Ensure the migration directory exists
39
+ */
40
+ protected ensureMigrationDirectoryExists(path: string): void;
41
+ }
42
+ //# sourceMappingURL=MigrationCreator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationCreator.d.ts","sourceRoot":"","sources":["../../../src/Database/Migrations/MigrationCreator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,qBAAa,gBAAgB;IACf,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM;gBAAvB,cAAc,CAAC,EAAE,MAAM,YAAA;IAE7C;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAc3G;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,GAAE,OAAe,GAAG,MAAM;IAYlE;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,MAAM;IAsBhC;;OAEG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IAyBjC;;OAEG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IA0BjC;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAQ5D;;OAEG;IACH,SAAS,CAAC,aAAa,IAAI,MAAM;IAajC;;OAEG;IACH,SAAS,CAAC,8BAA8B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAK7D"}
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ /**
3
+ * MigrationCreator
4
+ *
5
+ * Creates new migration files from stubs
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.MigrationCreator = void 0;
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ class MigrationCreator {
45
+ customStubPath;
46
+ constructor(customStubPath) {
47
+ this.customStubPath = customStubPath;
48
+ }
49
+ /**
50
+ * Create a new migration file
51
+ */
52
+ async create(name, migrationPath, table, create = false) {
53
+ this.ensureMigrationDirectoryExists(migrationPath);
54
+ const fileName = this.getDatePrefix() + '_' + name + '.ts';
55
+ const filePath = path.join(migrationPath, fileName);
56
+ const stub = this.getStub(table, create);
57
+ const populated = this.populateStub(stub, table);
58
+ fs.writeFileSync(filePath, populated);
59
+ return filePath;
60
+ }
61
+ /**
62
+ * Get the migration stub
63
+ */
64
+ getStub(table, create = false) {
65
+ if (table && create) {
66
+ return this.getCreateStub();
67
+ }
68
+ if (table) {
69
+ return this.getUpdateStub();
70
+ }
71
+ return this.getBlankStub();
72
+ }
73
+ /**
74
+ * Get the blank migration stub
75
+ */
76
+ getBlankStub() {
77
+ return `import { Migration } from '@orchestr-sh/orchestr';
78
+ import { Schema } from '@orchestr-sh/orchestr';
79
+
80
+ export default class extends Migration {
81
+ /**
82
+ * Run the migrations
83
+ */
84
+ async up(schema: Schema): Promise<void> {
85
+ //
86
+ }
87
+
88
+ /**
89
+ * Reverse the migrations
90
+ */
91
+ async down(schema: Schema): Promise<void> {
92
+ //
93
+ }
94
+ }
95
+ `;
96
+ }
97
+ /**
98
+ * Get the create table stub
99
+ */
100
+ getCreateStub() {
101
+ return `import { Migration } from '@orchestr-sh/orchestr';
102
+ import { Schema } from '@orchestr-sh/orchestr';
103
+
104
+ export default class extends Migration {
105
+ /**
106
+ * Run the migrations
107
+ */
108
+ async up(schema: Schema): Promise<void> {
109
+ await schema.create('{{table}}', (table) => {
110
+ table.id();
111
+ table.timestamps();
112
+ });
113
+ }
114
+
115
+ /**
116
+ * Reverse the migrations
117
+ */
118
+ async down(schema: Schema): Promise<void> {
119
+ await schema.dropIfExists('{{table}}');
120
+ }
121
+ }
122
+ `;
123
+ }
124
+ /**
125
+ * Get the update table stub
126
+ */
127
+ getUpdateStub() {
128
+ return `import { Migration } from '@orchestr-sh/orchestr';
129
+ import { Schema } from '@orchestr-sh/orchestr';
130
+
131
+ export default class extends Migration {
132
+ /**
133
+ * Run the migrations
134
+ */
135
+ async up(schema: Schema): Promise<void> {
136
+ await schema.table('{{table}}', (table) => {
137
+ //
138
+ });
139
+ }
140
+
141
+ /**
142
+ * Reverse the migrations
143
+ */
144
+ async down(schema: Schema): Promise<void> {
145
+ await schema.table('{{table}}', (table) => {
146
+ //
147
+ });
148
+ }
149
+ }
150
+ `;
151
+ }
152
+ /**
153
+ * Populate the stub with table name
154
+ */
155
+ populateStub(stub, table) {
156
+ if (table) {
157
+ return stub.replace(/\{\{table\}\}/g, table);
158
+ }
159
+ return stub;
160
+ }
161
+ /**
162
+ * Get the date prefix for the migration
163
+ */
164
+ getDatePrefix() {
165
+ const now = new Date();
166
+ const year = now.getFullYear();
167
+ const month = String(now.getMonth() + 1).padStart(2, '0');
168
+ const day = String(now.getDate()).padStart(2, '0');
169
+ const hour = String(now.getHours()).padStart(2, '0');
170
+ const minute = String(now.getMinutes()).padStart(2, '0');
171
+ const second = String(now.getSeconds()).padStart(2, '0');
172
+ return `${year}_${month}_${day}_${hour}${minute}${second}`;
173
+ }
174
+ /**
175
+ * Ensure the migration directory exists
176
+ */
177
+ ensureMigrationDirectoryExists(path) {
178
+ if (!fs.existsSync(path)) {
179
+ fs.mkdirSync(path, { recursive: true });
180
+ }
181
+ }
182
+ }
183
+ exports.MigrationCreator = MigrationCreator;
184
+ //# sourceMappingURL=MigrationCreator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationCreator.js","sourceRoot":"","sources":["../../../src/Database/Migrations/MigrationCreator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAE7B,MAAa,gBAAgB;IACL;IAAtB,YAAsB,cAAuB;QAAvB,mBAAc,GAAd,cAAc,CAAS;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,aAAqB,EAAE,KAAc,EAAE,SAAkB,KAAK;QACvF,IAAI,CAAC,8BAA8B,CAAC,aAAa,CAAC,CAAC;QAEnD,MAAM,QAAQ,GA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,GAAG,CAAC,WAAW,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACnD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACzD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAEzD,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACO,8BAA8B,CAAC,IAAY;QACnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AAxJD,4CAwJC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * MigrationRepository
3
+ *
4
+ * Manages the migrations table that tracks which migrations have been run
5
+ */
6
+ import { Connection } from '../Connection';
7
+ export interface MigrationData {
8
+ id?: number;
9
+ migration: string;
10
+ batch: number;
11
+ }
12
+ export declare class MigrationRepository {
13
+ protected connection: Connection;
14
+ protected table: string;
15
+ constructor(connection: Connection);
16
+ /**
17
+ * Get the migrations that have been run
18
+ */
19
+ getRan(): Promise<string[]>;
20
+ /**
21
+ * Get the list of migrations
22
+ */
23
+ getMigrations(steps?: number): Promise<MigrationData[]>;
24
+ /**
25
+ * Get the last migration batch
26
+ */
27
+ getLast(): Promise<MigrationData[]>;
28
+ /**
29
+ * Get the migrations for a batch
30
+ */
31
+ getMigrationBatches(): Promise<Record<string, number>>;
32
+ /**
33
+ * Log that a migration was run
34
+ */
35
+ log(file: string, batch: number): Promise<void>;
36
+ /**
37
+ * Remove a migration from the log
38
+ */
39
+ delete(migration: MigrationData): Promise<void>;
40
+ /**
41
+ * Get the next migration batch number
42
+ */
43
+ getNextBatchNumber(): Promise<number>;
44
+ /**
45
+ * Get the last migration batch number
46
+ */
47
+ getLastBatchNumber(): Promise<number>;
48
+ /**
49
+ * Create the migration repository table
50
+ */
51
+ createRepository(): Promise<void>;
52
+ /**
53
+ * Determine if the migration repository exists
54
+ */
55
+ repositoryExists(): Promise<boolean>;
56
+ /**
57
+ * Delete the migration repository
58
+ */
59
+ deleteRepository(): Promise<void>;
60
+ /**
61
+ * Set the information source to gather data
62
+ */
63
+ setSource(name: string): void;
64
+ }
65
+ //# sourceMappingURL=MigrationRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationRepository.d.ts","sourceRoot":"","sources":["../../../src/Database/Migrations/MigrationRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAmB;IAGlB,SAAS,CAAC,UAAU,EAAE,UAAU;IAF5C,SAAS,CAAC,KAAK,EAAE,MAAM,CAAgB;gBAEjB,UAAU,EAAE,UAAU;IAE5C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAMjC;;OAEG;IACG,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAU7D;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAUzC;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAW5D;;OAEG;IACG,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrD;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAI3C;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC;IAM3C;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAYvC;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;IAS1C;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAG9B"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * MigrationRepository
4
+ *
5
+ * Manages the migrations table that tracks which migrations have been run
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.MigrationRepository = void 0;
9
+ class MigrationRepository {
10
+ connection;
11
+ table = 'migrations';
12
+ constructor(connection) {
13
+ this.connection = connection;
14
+ }
15
+ /**
16
+ * Get the migrations that have been run
17
+ */
18
+ async getRan() {
19
+ const results = await this.connection.table(this.table).orderBy('batch', 'asc').orderBy('migration', 'asc').get();
20
+ return results.map((row) => row.migration);
21
+ }
22
+ /**
23
+ * Get the list of migrations
24
+ */
25
+ async getMigrations(steps) {
26
+ const query = this.connection.table(this.table).orderBy('batch', 'desc').orderBy('migration', 'desc');
27
+ if (steps !== undefined && steps > 0) {
28
+ query.limit(steps);
29
+ }
30
+ return await query.get();
31
+ }
32
+ /**
33
+ * Get the last migration batch
34
+ */
35
+ async getLast() {
36
+ const batch = await this.getLastBatchNumber();
37
+ if (batch === 0) {
38
+ return [];
39
+ }
40
+ return await this.connection.table(this.table).where('batch', batch).orderBy('migration', 'desc').get();
41
+ }
42
+ /**
43
+ * Get the migrations for a batch
44
+ */
45
+ async getMigrationBatches() {
46
+ const results = await this.connection.table(this.table).orderBy('batch', 'asc').orderBy('migration', 'asc').get();
47
+ const batches = {};
48
+ results.forEach((row) => {
49
+ batches[row.migration] = row.batch;
50
+ });
51
+ return batches;
52
+ }
53
+ /**
54
+ * Log that a migration was run
55
+ */
56
+ async log(file, batch) {
57
+ await this.connection.table(this.table).insert({
58
+ migration: file,
59
+ batch,
60
+ });
61
+ }
62
+ /**
63
+ * Remove a migration from the log
64
+ */
65
+ async delete(migration) {
66
+ await this.connection.table(this.table).where('migration', migration.migration).delete();
67
+ }
68
+ /**
69
+ * Get the next migration batch number
70
+ */
71
+ async getNextBatchNumber() {
72
+ return (await this.getLastBatchNumber()) + 1;
73
+ }
74
+ /**
75
+ * Get the last migration batch number
76
+ */
77
+ async getLastBatchNumber() {
78
+ const result = await this.connection.table(this.table).max('batch');
79
+ return result !== null ? Number(result) : 0;
80
+ }
81
+ /**
82
+ * Create the migration repository table
83
+ */
84
+ async createRepository() {
85
+ const schema = this.connection.getAdapter();
86
+ await this.connection.query(`
87
+ CREATE TABLE IF NOT EXISTS ${this.table} (
88
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
89
+ migration VARCHAR(255) NOT NULL,
90
+ batch INTEGER NOT NULL
91
+ )
92
+ `);
93
+ }
94
+ /**
95
+ * Determine if the migration repository exists
96
+ */
97
+ async repositoryExists() {
98
+ try {
99
+ await this.connection.table(this.table).limit(1).get();
100
+ return true;
101
+ }
102
+ catch (error) {
103
+ return false;
104
+ }
105
+ }
106
+ /**
107
+ * Delete the migration repository
108
+ */
109
+ async deleteRepository() {
110
+ await this.connection.query(`DROP TABLE IF EXISTS ${this.table}`);
111
+ }
112
+ /**
113
+ * Set the information source to gather data
114
+ */
115
+ setSource(name) {
116
+ // Reserved for future use with different connections
117
+ }
118
+ }
119
+ exports.MigrationRepository = MigrationRepository;
120
+ //# sourceMappingURL=MigrationRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationRepository.js","sourceRoot":"","sources":["../../../src/Database/Migrations/MigrationRepository.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAUH,MAAa,mBAAmB;IAGR;IAFZ,KAAK,GAAW,YAAY,CAAC;IAEvC,YAAsB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEhD;;OAEG;IACH,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QAElH,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,KAAc;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAEtG,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACrC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,OAAO,MAAM,KAAK,CAAC,GAAG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+ *
4
+ * Handles running and rolling back migrations
5
+ */
6
+ import { Connection } from '../Connection';
7
+ import { MigrationRepository } from './MigrationRepository';
8
+ import { Migration } from './Migration';
9
+ import { SchemaBuilder } from './SchemaBuilder';
10
+ export interface MigrationOptions {
11
+ step?: number;
12
+ pretend?: boolean;
13
+ }
14
+ export declare class Migrator {
15
+ protected connection: Connection;
16
+ protected paths: string[];
17
+ protected repository: MigrationRepository;
18
+ protected schema: SchemaBuilder;
19
+ constructor(connection: Connection, paths: string[]);
20
+ /**
21
+ * Run the pending migrations
22
+ */
23
+ run(options?: MigrationOptions): Promise<string[]>;
24
+ /**
25
+ * Run a single migration up
26
+ */
27
+ protected runUp(file: string, batch: number, pretend: boolean): Promise<void>;
28
+ /**
29
+ * Rollback the last migration batch
30
+ */
31
+ rollback(options?: MigrationOptions): Promise<string[]>;
32
+ /**
33
+ * Run a single migration down
34
+ */
35
+ protected runDown(file: string, pretend: boolean): Promise<void>;
36
+ /**
37
+ * Reset all migrations
38
+ */
39
+ reset(): Promise<string[]>;
40
+ /**
41
+ * Refresh the database (reset and re-run all migrations)
42
+ */
43
+ refresh(): Promise<{
44
+ rolledBack: string[];
45
+ ran: string[];
46
+ }>;
47
+ /**
48
+ * Get migrations for rollback
49
+ */
50
+ protected getMigrationsForRollback(options: MigrationOptions): Promise<any[]>;
51
+ /**
52
+ * Resolve a migration instance from a file
53
+ */
54
+ protected resolveMigration(file: string): Promise<Migration>;
55
+ /**
56
+ * Find a migration file in the paths
57
+ */
58
+ protected findMigrationFile(file: string): Promise<string | null>;
59
+ /**
60
+ * Get all migration files
61
+ */
62
+ getMigrationFiles(): Promise<string[]>;
63
+ /**
64
+ * Get the ran migrations
65
+ */
66
+ getRan(): Promise<string[]>;
67
+ /**
68
+ * Get migrations with their batch numbers
69
+ */
70
+ getMigrationBatches(): Promise<Record<string, number>>;
71
+ /**
72
+ * Get the migration repository
73
+ */
74
+ getRepository(): MigrationRepository;
75
+ /**
76
+ * Set the migration paths
77
+ */
78
+ setPaths(paths: string[]): void;
79
+ /**
80
+ * Get the migration paths
81
+ */
82
+ getPaths(): string[];
83
+ }
84
+ //# sourceMappingURL=Migrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migrator.d.ts","sourceRoot":"","sources":["../../../src/Database/Migrations/Migrator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,QAAQ;IAKjB,SAAS,CAAC,UAAU,EAAE,UAAU;IAChC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE;IAL3B,SAAS,CAAC,UAAU,EAAE,mBAAmB,CAAC;IAC1C,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;gBAGpB,UAAU,EAAE,UAAU,EACtB,KAAK,EAAE,MAAM,EAAE;IAM3B;;OAEG;IACG,GAAG,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyB5D;;OAEG;cACa,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnF;;OAEG;IACG,QAAQ,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiBjE;;OAEG;cACa,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAYtE;;OAEG;IACG,KAAK,IAAI,OAAO,CAA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