@ductape/sdk 0.0.4-v5 → 0.0.4-v51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api/services/appApi.service.d.ts +48 -2
- package/dist/api/services/appApi.service.js +101 -2
- package/dist/api/services/appApi.service.js.map +1 -1
- package/dist/api/services/pricingApi.service.d.ts +10 -0
- package/dist/api/services/pricingApi.service.js +34 -0
- package/dist/api/services/pricingApi.service.js.map +1 -0
- package/dist/api/services/processorApi.service.d.ts +12 -2
- package/dist/api/services/processorApi.service.js +12 -2
- package/dist/api/services/processorApi.service.js.map +1 -1
- package/dist/api/services/productsApi.service.d.ts +40 -1
- package/dist/api/services/productsApi.service.js +105 -1
- package/dist/api/services/productsApi.service.js.map +1 -1
- package/dist/api/services/userApi.service.js +1 -0
- package/dist/api/services/userApi.service.js.map +1 -1
- package/dist/api/services/workspaceApi.service.js +1 -0
- package/dist/api/services/workspaceApi.service.js.map +1 -1
- package/dist/api/services/workspaceSecretsApi.service.d.ts +75 -0
- package/dist/api/services/workspaceSecretsApi.service.js +62 -0
- package/dist/api/services/workspaceSecretsApi.service.js.map +1 -0
- package/dist/api/urls.d.ts +6 -1
- package/dist/api/urls.js +12 -2
- package/dist/api/urls.js.map +1 -1
- package/dist/api/utils/cache.utils.d.ts +1 -1
- package/dist/api/utils/cache.utils.js +10 -4
- package/dist/api/utils/cache.utils.js.map +1 -1
- package/dist/api/utils/strings.utils.d.ts +2 -0
- package/dist/api/utils/strings.utils.js +14 -0
- package/dist/api/utils/strings.utils.js.map +1 -1
- package/dist/apps/services/app.service.d.ts +51 -33
- package/dist/apps/services/app.service.js +488 -244
- package/dist/apps/services/app.service.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appAction.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js +21 -2
- package/dist/apps/validators/joi-validators/create.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js +2 -15
- package/dist/apps/validators/joi-validators/create.appWebhook.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js +11 -1
- package/dist/apps/validators/joi-validators/update.appAction.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.d.ts +1 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js +34 -1
- package/dist/apps/validators/joi-validators/update.appActionResponse.validator.js.map +1 -1
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.d.ts +1 -2
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js +2 -14
- package/dist/apps/validators/joi-validators/update.appWebhook.validator.js.map +1 -1
- package/dist/clients/pricing.client.d.ts +3 -0
- package/dist/clients/pricing.client.js +33 -0
- package/dist/clients/pricing.client.js.map +1 -0
- package/dist/database/adapters/base.adapter.d.ts +176 -0
- package/dist/database/adapters/base.adapter.js +31 -0
- package/dist/database/adapters/base.adapter.js.map +1 -0
- package/dist/database/adapters/dynamodb.adapter.d.ts +91 -0
- package/dist/database/adapters/dynamodb.adapter.js +1608 -0
- package/dist/database/adapters/dynamodb.adapter.js.map +1 -0
- package/dist/database/adapters/mongodb.adapter.d.ts +71 -0
- package/dist/database/adapters/mongodb.adapter.js +1072 -0
- package/dist/database/adapters/mongodb.adapter.js.map +1 -0
- package/dist/database/adapters/mysql.adapter.d.ts +146 -0
- package/dist/database/adapters/mysql.adapter.js +1492 -0
- package/dist/database/adapters/mysql.adapter.js.map +1 -0
- package/dist/database/adapters/postgresql.adapter.d.ts +147 -0
- package/dist/database/adapters/postgresql.adapter.js +1603 -0
- package/dist/database/adapters/postgresql.adapter.js.map +1 -0
- package/dist/database/database.service.d.ts +232 -0
- package/dist/database/database.service.js +802 -0
- package/dist/database/database.service.js.map +1 -0
- package/dist/database/index.d.ts +18 -0
- package/dist/database/index.js +98 -0
- package/dist/database/index.js.map +1 -0
- package/dist/database/types/aggregation.types.d.ts +261 -0
- package/dist/database/types/aggregation.types.js +21 -0
- package/dist/database/types/aggregation.types.js.map +1 -0
- package/dist/database/types/connection.types.d.ts +132 -0
- package/dist/database/types/connection.types.js +6 -0
- package/dist/database/types/connection.types.js.map +1 -0
- package/dist/database/types/database.types.d.ts +175 -0
- package/dist/database/types/database.types.js +75 -0
- package/dist/database/types/database.types.js.map +1 -0
- package/dist/database/types/index.d.ts +12 -0
- package/dist/database/types/index.js +37 -0
- package/dist/database/types/index.js.map +1 -0
- package/dist/database/types/index.types.d.ts +220 -0
- package/dist/database/types/index.types.js +27 -0
- package/dist/database/types/index.types.js.map +1 -0
- package/dist/database/types/migration.types.d.ts +205 -0
- package/dist/database/types/migration.types.js +44 -0
- package/dist/database/types/migration.types.js.map +1 -0
- package/dist/database/types/query.types.d.ts +305 -0
- package/dist/database/types/query.types.js +57 -0
- package/dist/database/types/query.types.js.map +1 -0
- package/dist/database/types/result.types.d.ts +220 -0
- package/dist/database/types/result.types.js +6 -0
- package/dist/database/types/result.types.js.map +1 -0
- package/dist/database/types/schema.types.d.ts +190 -0
- package/dist/database/types/schema.types.js +69 -0
- package/dist/database/types/schema.types.js.map +1 -0
- package/dist/database/utils/helpers.d.ts +66 -0
- package/dist/database/utils/helpers.js +501 -0
- package/dist/database/utils/helpers.js.map +1 -0
- package/dist/database/utils/migration.utils.d.ts +151 -0
- package/dist/database/utils/migration.utils.js +476 -0
- package/dist/database/utils/migration.utils.js.map +1 -0
- package/dist/database/utils/transaction.d.ts +64 -0
- package/dist/database/utils/transaction.js +130 -0
- package/dist/database/utils/transaction.js.map +1 -0
- package/dist/database/validators/connection.validator.d.ts +20 -0
- package/dist/database/validators/connection.validator.js +267 -0
- package/dist/database/validators/connection.validator.js.map +1 -0
- package/dist/database/validators/query.validator.d.ts +31 -0
- package/dist/database/validators/query.validator.js +305 -0
- package/dist/database/validators/query.validator.js.map +1 -0
- package/dist/database/validators/schema.validator.d.ts +31 -0
- package/dist/database/validators/schema.validator.js +334 -0
- package/dist/database/validators/schema.validator.js.map +1 -0
- package/dist/graph/adapters/arangodb.adapter.d.ts +80 -0
- package/dist/graph/adapters/arangodb.adapter.js +1393 -0
- package/dist/graph/adapters/arangodb.adapter.js.map +1 -0
- package/dist/graph/adapters/base.adapter.d.ts +228 -0
- package/dist/graph/adapters/base.adapter.js +38 -0
- package/dist/graph/adapters/base.adapter.js.map +1 -0
- package/dist/graph/adapters/index.d.ts +10 -0
- package/dist/graph/adapters/index.js +23 -0
- package/dist/graph/adapters/index.js.map +1 -0
- package/dist/graph/adapters/memgraph.adapter.d.ts +85 -0
- package/dist/graph/adapters/memgraph.adapter.js +1491 -0
- package/dist/graph/adapters/memgraph.adapter.js.map +1 -0
- package/dist/graph/adapters/neo4j.adapter.d.ts +88 -0
- package/dist/graph/adapters/neo4j.adapter.js +1861 -0
- package/dist/graph/adapters/neo4j.adapter.js.map +1 -0
- package/dist/graph/adapters/neptune.adapter.d.ts +87 -0
- package/dist/graph/adapters/neptune.adapter.js +1430 -0
- package/dist/graph/adapters/neptune.adapter.js.map +1 -0
- package/dist/graph/graph.service.d.ts +278 -0
- package/dist/graph/graph.service.js +687 -0
- package/dist/graph/graph.service.js.map +1 -0
- package/dist/graph/index.d.ts +11 -0
- package/dist/graph/index.js +42 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/types/connection.types.d.ts +158 -0
- package/dist/graph/types/connection.types.js +43 -0
- package/dist/graph/types/connection.types.js.map +1 -0
- package/dist/graph/types/graph.types.d.ts +144 -0
- package/dist/graph/types/graph.types.js +84 -0
- package/dist/graph/types/graph.types.js.map +1 -0
- package/dist/graph/types/index.d.ts +11 -0
- package/dist/graph/types/index.js +35 -0
- package/dist/graph/types/index.js.map +1 -0
- package/dist/graph/types/node.types.d.ts +193 -0
- package/dist/graph/types/node.types.js +49 -0
- package/dist/graph/types/node.types.js.map +1 -0
- package/dist/graph/types/path.types.d.ts +224 -0
- package/dist/graph/types/path.types.js +38 -0
- package/dist/graph/types/path.types.js.map +1 -0
- package/dist/graph/types/query.types.d.ts +247 -0
- package/dist/graph/types/query.types.js +23 -0
- package/dist/graph/types/query.types.js.map +1 -0
- package/dist/graph/types/relationship.types.d.ts +224 -0
- package/dist/graph/types/relationship.types.js +35 -0
- package/dist/graph/types/relationship.types.js.map +1 -0
- package/dist/graph/types/result.types.d.ts +237 -0
- package/dist/graph/types/result.types.js +7 -0
- package/dist/graph/types/result.types.js.map +1 -0
- package/dist/graph/validators/index.d.ts +81 -0
- package/dist/graph/validators/index.js +243 -0
- package/dist/graph/validators/index.js.map +1 -0
- package/dist/imports/imports.service.d.ts +3 -3
- package/dist/imports/imports.service.js +7 -7
- package/dist/imports/imports.service.js.map +1 -1
- package/dist/imports/imports.types.d.ts +8 -0
- package/dist/imports/repos/postmanV21.repo.d.ts +1 -1
- package/dist/imports/repos/postmanV21.repo.js +29 -2
- package/dist/imports/repos/postmanV21.repo.js.map +1 -1
- package/dist/index.d.ts +1244 -150
- package/dist/index.js +1309 -209
- package/dist/index.js.map +1 -1
- package/dist/inputs/inputs.service.js +2 -2
- package/dist/inputs/inputs.service.js.map +1 -1
- package/dist/inputs/utils/inputs.utils.create.js +1 -1
- package/dist/inputs/utils/inputs.utils.create.js.map +1 -1
- package/dist/logs/logs.types.d.ts +5 -0
- package/dist/logs/logs.types.js +1 -0
- package/dist/logs/logs.types.js.map +1 -1
- package/dist/parsers/index.d.ts +3 -0
- package/dist/parsers/index.js +27 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pipelines/postman.pipelines.d.ts +15 -0
- package/dist/parsers/pipelines/postman.pipelines.js +103 -0
- package/dist/parsers/pipelines/postman.pipelines.js.map +1 -0
- package/dist/parsers/types/postman.types.d.ts +200 -0
- package/dist/parsers/types/postman.types.js +3 -0
- package/dist/parsers/types/postman.types.js.map +1 -0
- package/dist/parsers/utils/postman.utils.d.ts +12 -0
- package/dist/parsers/utils/postman.utils.js +116 -0
- package/dist/parsers/utils/postman.utils.js.map +1 -0
- package/dist/parsers/validators/postman-auth.validators.d.ts +10 -0
- package/dist/parsers/validators/postman-auth.validators.js +127 -0
- package/dist/parsers/validators/postman-auth.validators.js.map +1 -0
- package/dist/parsers/validators/postman-request.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-request.validators.js +139 -0
- package/dist/parsers/validators/postman-request.validators.js.map +1 -0
- package/dist/parsers/validators/postman-response.validators.d.ts +13 -0
- package/dist/parsers/validators/postman-response.validators.js +150 -0
- package/dist/parsers/validators/postman-response.validators.js.map +1 -0
- package/dist/parsers/validators/postman-variable.validators.d.ts +14 -0
- package/dist/parsers/validators/postman-variable.validators.js +163 -0
- package/dist/parsers/validators/postman-variable.validators.js.map +1 -0
- package/dist/pricing/pricing.repo.d.ts +0 -0
- package/dist/pricing/pricing.repo.js +1 -0
- package/dist/pricing/pricing.repo.js.map +1 -0
- package/dist/pricing/pricing.service.d.ts +24 -0
- package/dist/pricing/pricing.service.js +51 -0
- package/dist/pricing/pricing.service.js.map +1 -0
- package/dist/pricing/pricing.types.d.ts +76 -0
- package/dist/pricing/pricing.types.js +21 -0
- package/dist/pricing/pricing.types.js.map +1 -0
- package/dist/pricing/utils/string.utils.d.ts +1 -0
- package/dist/pricing/utils/string.utils.js +9 -0
- package/dist/pricing/utils/string.utils.js.map +1 -0
- package/dist/processor/repos/sms.repo.d.ts +4 -4
- package/dist/processor/repos/sms.repo.js +23 -10
- package/dist/processor/repos/sms.repo.js.map +1 -1
- package/dist/processor/services/messagebrokers/kafka.service.js +0 -2
- package/dist/processor/services/messagebrokers/kafka.service.js.map +1 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.d.ts +9 -1
- package/dist/processor/services/messagebrokers/rabbitmq.service.js +40 -11
- package/dist/processor/services/messagebrokers/rabbitmq.service.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +38 -10
- package/dist/processor/services/processor.service.js +533 -248
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/processor/services/request.service.d.ts +36 -0
- package/dist/processor/services/request.service.js +304 -0
- package/dist/processor/services/request.service.js.map +1 -0
- package/dist/processor/types/request.types.d.ts +14 -0
- package/dist/processor/types/request.types.js +3 -0
- package/dist/processor/types/request.types.js.map +1 -0
- package/dist/processor/utils/processor.utils.d.ts +3 -0
- package/dist/processor/utils/processor.utils.js +84 -22
- package/dist/processor/utils/processor.utils.js.map +1 -1
- package/dist/processor/utils/request.utils.d.ts +20 -0
- package/dist/processor/utils/request.utils.js +113 -0
- package/dist/processor/utils/request.utils.js.map +1 -0
- package/dist/products/services/products.service.d.ts +114 -77
- package/dist/products/services/products.service.js +805 -362
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/products/services/utils/crypt.utils.d.ts +1 -0
- package/dist/products/services/utils/crypt.utils.js +17 -0
- package/dist/products/services/utils/crypt.utils.js.map +1 -0
- package/dist/products/services/utils/functions.utils.d.ts +13 -0
- package/dist/products/services/utils/functions.utils.js +289 -0
- package/dist/products/services/utils/functions.utils.js.map +1 -0
- package/dist/products/services/utils/objects.utils.d.ts +13 -0
- package/dist/products/services/utils/objects.utils.js +89 -0
- package/dist/products/services/utils/objects.utils.js.map +1 -0
- package/dist/products/services/utils/string.utils.d.ts +12 -0
- package/dist/products/services/utils/string.utils.js +168 -0
- package/dist/products/services/utils/string.utils.js.map +1 -0
- package/dist/products/utils/string.utils.d.ts +1 -1
- package/dist/products/utils/string.utils.js +14 -2
- package/dist/products/utils/string.utils.js.map +1 -1
- package/dist/products/validators/index.d.ts +4 -1
- package/dist/products/validators/index.js +7 -1
- package/dist/products/validators/index.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.d.ts +15 -4
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js +501 -109
- package/dist/products/validators/joi-validators/create.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productEnv.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productGraph.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js +82 -0
- package/dist/products/validators/joi-validators/create.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.d.ts +14 -0
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js +696 -0
- package/dist/products/validators/joi-validators/create.productGraphAction.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.d.ts +4 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js +58 -0
- package/dist/products/validators/joi-validators/create.productHealthcheck.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js +9 -4
- package/dist/products/validators/joi-validators/create.productMessageBrokers.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.productNotification.validator.js +5 -2
- package/dist/products/validators/joi-validators/create.productNotification.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/create.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/create.userAuth.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.dataValue.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.dataValue.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.d.ts +6 -0
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js +28 -26
- package/dist/products/validators/joi-validators/update.productDatabaseAction.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productEnv.validator.js +3 -0
- package/dist/products/validators/joi-validators/update.productEnv.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.productGraph.validator.d.ts +3 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js +87 -0
- package/dist/products/validators/joi-validators/update.productGraph.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.d.ts +7 -0
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js +72 -0
- package/dist/products/validators/joi-validators/update.productGraphAction.validator.js.map +1 -0
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.productMessageBrokerTopic.validator.js.map +1 -1
- package/dist/products/validators/joi-validators/update.userAuth.validator.js +1 -0
- package/dist/products/validators/joi-validators/update.userAuth.validator.js.map +1 -1
- package/dist/test/test.health.d.ts +1 -0
- package/dist/test/test.health.js +49 -0
- package/dist/test/test.health.js.map +1 -0
- package/dist/test/test.import.js +51 -4
- package/dist/test/test.import.js.map +1 -1
- package/dist/test/test.imports.js +22 -7
- package/dist/test/test.imports.js.map +1 -1
- package/dist/test/test.notifiers.d.ts +1 -0
- package/dist/test/test.notifiers.js +85 -0
- package/dist/test/test.notifiers.js.map +1 -0
- package/dist/test/test.processor.js +30 -115
- package/dist/test/test.processor.js.map +1 -1
- package/dist/test/test.products.d.ts +1 -0
- package/dist/test/test.products.js +49 -0
- package/dist/test/test.products.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/appBuilder.types.d.ts +5 -12
- package/dist/types/enums.d.ts +4 -1
- package/dist/types/enums.js +3 -0
- package/dist/types/enums.js.map +1 -1
- package/dist/types/index.types.d.ts +4 -0
- package/dist/types/pricing.types.d.ts +4 -0
- package/dist/types/pricing.types.js +3 -0
- package/dist/types/pricing.types.js.map +1 -0
- package/dist/types/processor.types.d.ts +67 -11
- package/dist/types/processor.types.js.map +1 -1
- package/dist/types/productsBuilder.types.d.ts +132 -14
- package/dist/types/productsBuilder.types.js +69 -4
- package/dist/types/productsBuilder.types.js.map +1 -1
- package/dist/types/request-tracker.interface.d.ts +0 -0
- package/dist/types/request-tracker.interface.js +1 -0
- package/dist/types/request-tracker.interface.js.map +1 -0
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +5 -0
- package/dist/utils/constants.js.map +1 -0
- package/package.json +17 -3
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration Utilities
|
|
3
|
+
* Helper functions for creating and managing database migrations
|
|
4
|
+
*/
|
|
5
|
+
import { IMigrationDefinition, IMigrationOperation } from '../types/migration.types';
|
|
6
|
+
import { ITableSchema, IColumnDefinition } from '../types/schema.types';
|
|
7
|
+
/**
|
|
8
|
+
* Generate a migration tag from a name
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateMigrationTag(name: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a migration timestamp
|
|
13
|
+
*/
|
|
14
|
+
export declare function generateMigrationTimestamp(): number;
|
|
15
|
+
/**
|
|
16
|
+
* Create a migration definition
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMigration(name: string, up: IMigrationOperation[], down: IMigrationOperation[], tag?: string): IMigrationDefinition;
|
|
19
|
+
/**
|
|
20
|
+
* Create a table creation migration operation
|
|
21
|
+
*/
|
|
22
|
+
export declare function createTable(schema: ITableSchema): IMigrationOperation;
|
|
23
|
+
/**
|
|
24
|
+
* Create a table drop migration operation
|
|
25
|
+
*/
|
|
26
|
+
export declare function dropTable(tableName: string): IMigrationOperation;
|
|
27
|
+
/**
|
|
28
|
+
* Create an add column migration operation
|
|
29
|
+
*/
|
|
30
|
+
export declare function addColumn(tableName: string, column: IColumnDefinition): IMigrationOperation;
|
|
31
|
+
/**
|
|
32
|
+
* Create a drop column migration operation
|
|
33
|
+
*/
|
|
34
|
+
export declare function dropColumn(tableName: string, columnName: string): IMigrationOperation;
|
|
35
|
+
/**
|
|
36
|
+
* Create a modify column migration operation
|
|
37
|
+
*/
|
|
38
|
+
export declare function modifyColumn(tableName: string, column: IColumnDefinition): IMigrationOperation;
|
|
39
|
+
/**
|
|
40
|
+
* Create a rename column migration operation
|
|
41
|
+
*/
|
|
42
|
+
export declare function renameColumn(tableName: string, oldName: string, newName: string): IMigrationOperation;
|
|
43
|
+
/**
|
|
44
|
+
* Create an add index migration operation
|
|
45
|
+
*/
|
|
46
|
+
export declare function addIndex(tableName: string, indexName: string, columns: string[], unique?: boolean): IMigrationOperation;
|
|
47
|
+
/**
|
|
48
|
+
* Create a drop index migration operation
|
|
49
|
+
*/
|
|
50
|
+
export declare function dropIndex(indexName: string): IMigrationOperation;
|
|
51
|
+
/**
|
|
52
|
+
* Create an add constraint migration operation
|
|
53
|
+
*/
|
|
54
|
+
export declare function addConstraint(tableName: string, constraintName: string, definition: string): IMigrationOperation;
|
|
55
|
+
/**
|
|
56
|
+
* Create a drop constraint migration operation
|
|
57
|
+
*/
|
|
58
|
+
export declare function dropConstraint(tableName: string, constraintName: string): IMigrationOperation;
|
|
59
|
+
/**
|
|
60
|
+
* Create a raw SQL migration operation
|
|
61
|
+
*/
|
|
62
|
+
export declare function rawSql(sql: string): IMigrationOperation;
|
|
63
|
+
/**
|
|
64
|
+
* Create a complete migration with automatic rollback for common operations
|
|
65
|
+
*/
|
|
66
|
+
export declare function createTableMigration(name: string, schema: ITableSchema, tag?: string): IMigrationDefinition;
|
|
67
|
+
/**
|
|
68
|
+
* Create a migration to add a column with automatic rollback
|
|
69
|
+
*/
|
|
70
|
+
export declare function addColumnMigration(name: string, tableName: string, column: IColumnDefinition, tag?: string): IMigrationDefinition;
|
|
71
|
+
/**
|
|
72
|
+
* Create a migration to add an index with automatic rollback
|
|
73
|
+
*/
|
|
74
|
+
export declare function addIndexMigration(name: string, tableName: string, indexName: string, columns: string[], unique?: boolean, tag?: string): IMigrationDefinition;
|
|
75
|
+
/**
|
|
76
|
+
* Schema helper for common column types
|
|
77
|
+
*/
|
|
78
|
+
export declare const SchemaHelpers: {
|
|
79
|
+
/**
|
|
80
|
+
* Create a primary key column (auto-increment integer)
|
|
81
|
+
*/
|
|
82
|
+
id(name?: string): IColumnDefinition;
|
|
83
|
+
/**
|
|
84
|
+
* Create a UUID primary key column
|
|
85
|
+
*/
|
|
86
|
+
uuid(name?: string): IColumnDefinition;
|
|
87
|
+
/**
|
|
88
|
+
* Create a string column
|
|
89
|
+
*/
|
|
90
|
+
string(name: string, length?: number, nullable?: boolean): IColumnDefinition;
|
|
91
|
+
/**
|
|
92
|
+
* Create a text column
|
|
93
|
+
*/
|
|
94
|
+
text(name: string, nullable?: boolean): IColumnDefinition;
|
|
95
|
+
/**
|
|
96
|
+
* Create an integer column
|
|
97
|
+
*/
|
|
98
|
+
integer(name: string, nullable?: boolean): IColumnDefinition;
|
|
99
|
+
/**
|
|
100
|
+
* Create a bigint column
|
|
101
|
+
*/
|
|
102
|
+
bigint(name: string, nullable?: boolean): IColumnDefinition;
|
|
103
|
+
/**
|
|
104
|
+
* Create a decimal column
|
|
105
|
+
*/
|
|
106
|
+
decimal(name: string, precision?: number, scale?: number, nullable?: boolean): IColumnDefinition;
|
|
107
|
+
/**
|
|
108
|
+
* Create a boolean column
|
|
109
|
+
*/
|
|
110
|
+
boolean(name: string, defaultValue?: boolean, nullable?: boolean): IColumnDefinition;
|
|
111
|
+
/**
|
|
112
|
+
* Create a date column
|
|
113
|
+
*/
|
|
114
|
+
date(name: string, nullable?: boolean): IColumnDefinition;
|
|
115
|
+
/**
|
|
116
|
+
* Create a datetime column
|
|
117
|
+
*/
|
|
118
|
+
datetime(name: string, nullable?: boolean): IColumnDefinition;
|
|
119
|
+
/**
|
|
120
|
+
* Create a timestamp column
|
|
121
|
+
*/
|
|
122
|
+
timestamp(name: string, nullable?: boolean): IColumnDefinition;
|
|
123
|
+
/**
|
|
124
|
+
* Create a JSON column
|
|
125
|
+
*/
|
|
126
|
+
json(name: string, nullable?: boolean): IColumnDefinition;
|
|
127
|
+
/**
|
|
128
|
+
* Create a JSONB column (PostgreSQL)
|
|
129
|
+
*/
|
|
130
|
+
jsonb(name: string, nullable?: boolean): IColumnDefinition;
|
|
131
|
+
/**
|
|
132
|
+
* Create timestamps columns (created_at, updated_at)
|
|
133
|
+
*/
|
|
134
|
+
timestamps(): IColumnDefinition[];
|
|
135
|
+
/**
|
|
136
|
+
* Create a soft delete column (deleted_at)
|
|
137
|
+
*/
|
|
138
|
+
softDelete(): IColumnDefinition;
|
|
139
|
+
/**
|
|
140
|
+
* Create a foreign key column
|
|
141
|
+
*/
|
|
142
|
+
foreignKey(name: string, referencedTable: string, referencedColumn?: string, nullable?: boolean): IColumnDefinition;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Generate TypeScript migration file content
|
|
146
|
+
*/
|
|
147
|
+
export declare function generateMigrationFileContent(migration: IMigrationDefinition): string;
|
|
148
|
+
/**
|
|
149
|
+
* Generate a simple migration template
|
|
150
|
+
*/
|
|
151
|
+
export declare function generateMigrationTemplate(name: string): string;
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Migration Utilities
|
|
4
|
+
* Helper functions for creating and managing database migrations
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SchemaHelpers = void 0;
|
|
8
|
+
exports.generateMigrationTag = generateMigrationTag;
|
|
9
|
+
exports.generateMigrationTimestamp = generateMigrationTimestamp;
|
|
10
|
+
exports.createMigration = createMigration;
|
|
11
|
+
exports.createTable = createTable;
|
|
12
|
+
exports.dropTable = dropTable;
|
|
13
|
+
exports.addColumn = addColumn;
|
|
14
|
+
exports.dropColumn = dropColumn;
|
|
15
|
+
exports.modifyColumn = modifyColumn;
|
|
16
|
+
exports.renameColumn = renameColumn;
|
|
17
|
+
exports.addIndex = addIndex;
|
|
18
|
+
exports.dropIndex = dropIndex;
|
|
19
|
+
exports.addConstraint = addConstraint;
|
|
20
|
+
exports.dropConstraint = dropConstraint;
|
|
21
|
+
exports.rawSql = rawSql;
|
|
22
|
+
exports.createTableMigration = createTableMigration;
|
|
23
|
+
exports.addColumnMigration = addColumnMigration;
|
|
24
|
+
exports.addIndexMigration = addIndexMigration;
|
|
25
|
+
exports.generateMigrationFileContent = generateMigrationFileContent;
|
|
26
|
+
exports.generateMigrationTemplate = generateMigrationTemplate;
|
|
27
|
+
const migration_types_1 = require("../types/migration.types");
|
|
28
|
+
const schema_types_1 = require("../types/schema.types");
|
|
29
|
+
/**
|
|
30
|
+
* Generate a migration tag from a name
|
|
31
|
+
*/
|
|
32
|
+
function generateMigrationTag(name) {
|
|
33
|
+
const timestamp = Date.now();
|
|
34
|
+
const sanitizedName = name.toLowerCase().replace(/[^a-z0-9]+/g, '_');
|
|
35
|
+
return `${timestamp}_${sanitizedName}`;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate a migration timestamp
|
|
39
|
+
*/
|
|
40
|
+
function generateMigrationTimestamp() {
|
|
41
|
+
return Date.now();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a migration definition
|
|
45
|
+
*/
|
|
46
|
+
function createMigration(name, up, down, tag) {
|
|
47
|
+
return {
|
|
48
|
+
tag: tag || generateMigrationTag(name),
|
|
49
|
+
name,
|
|
50
|
+
description: `Migration: ${name}`,
|
|
51
|
+
up,
|
|
52
|
+
down,
|
|
53
|
+
createdAt: new Date(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a table creation migration operation
|
|
58
|
+
*/
|
|
59
|
+
function createTable(schema) {
|
|
60
|
+
return {
|
|
61
|
+
type: migration_types_1.MigrationOperationType.CREATE_TABLE,
|
|
62
|
+
params: { schema },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a table drop migration operation
|
|
67
|
+
*/
|
|
68
|
+
function dropTable(tableName) {
|
|
69
|
+
return {
|
|
70
|
+
type: migration_types_1.MigrationOperationType.DROP_TABLE,
|
|
71
|
+
table: tableName,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create an add column migration operation
|
|
76
|
+
*/
|
|
77
|
+
function addColumn(tableName, column) {
|
|
78
|
+
return {
|
|
79
|
+
type: migration_types_1.MigrationOperationType.ADD_COLUMN,
|
|
80
|
+
table: tableName,
|
|
81
|
+
params: { column },
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a drop column migration operation
|
|
86
|
+
*/
|
|
87
|
+
function dropColumn(tableName, columnName) {
|
|
88
|
+
return {
|
|
89
|
+
type: migration_types_1.MigrationOperationType.DROP_COLUMN,
|
|
90
|
+
table: tableName,
|
|
91
|
+
params: { columnName },
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a modify column migration operation
|
|
96
|
+
*/
|
|
97
|
+
function modifyColumn(tableName, column) {
|
|
98
|
+
return {
|
|
99
|
+
type: migration_types_1.MigrationOperationType.MODIFY_COLUMN,
|
|
100
|
+
table: tableName,
|
|
101
|
+
params: { column },
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a rename column migration operation
|
|
106
|
+
*/
|
|
107
|
+
function renameColumn(tableName, oldName, newName) {
|
|
108
|
+
return {
|
|
109
|
+
type: migration_types_1.MigrationOperationType.RENAME_COLUMN,
|
|
110
|
+
table: tableName,
|
|
111
|
+
params: { oldName, newName },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create an add index migration operation
|
|
116
|
+
*/
|
|
117
|
+
function addIndex(tableName, indexName, columns, unique = false) {
|
|
118
|
+
return {
|
|
119
|
+
type: migration_types_1.MigrationOperationType.ADD_INDEX,
|
|
120
|
+
table: tableName,
|
|
121
|
+
params: { indexName, columns, unique },
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create a drop index migration operation
|
|
126
|
+
*/
|
|
127
|
+
function dropIndex(indexName) {
|
|
128
|
+
return {
|
|
129
|
+
type: migration_types_1.MigrationOperationType.DROP_INDEX,
|
|
130
|
+
params: { indexName },
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create an add constraint migration operation
|
|
135
|
+
*/
|
|
136
|
+
function addConstraint(tableName, constraintName, definition) {
|
|
137
|
+
return {
|
|
138
|
+
type: migration_types_1.MigrationOperationType.ADD_CONSTRAINT,
|
|
139
|
+
table: tableName,
|
|
140
|
+
params: { constraintName, definition },
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create a drop constraint migration operation
|
|
145
|
+
*/
|
|
146
|
+
function dropConstraint(tableName, constraintName) {
|
|
147
|
+
return {
|
|
148
|
+
type: migration_types_1.MigrationOperationType.DROP_CONSTRAINT,
|
|
149
|
+
table: tableName,
|
|
150
|
+
params: { constraintName },
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Create a raw SQL migration operation
|
|
155
|
+
*/
|
|
156
|
+
function rawSql(sql) {
|
|
157
|
+
return {
|
|
158
|
+
type: migration_types_1.MigrationOperationType.RAW_SQL,
|
|
159
|
+
sql,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Create a complete migration with automatic rollback for common operations
|
|
164
|
+
*/
|
|
165
|
+
function createTableMigration(name, schema, tag) {
|
|
166
|
+
return createMigration(name, [createTable(schema)], [dropTable(schema.name)], tag);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Create a migration to add a column with automatic rollback
|
|
170
|
+
*/
|
|
171
|
+
function addColumnMigration(name, tableName, column, tag) {
|
|
172
|
+
return createMigration(name, [addColumn(tableName, column)], [dropColumn(tableName, column.name)], tag);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Create a migration to add an index with automatic rollback
|
|
176
|
+
*/
|
|
177
|
+
function addIndexMigration(name, tableName, indexName, columns, unique = false, tag) {
|
|
178
|
+
return createMigration(name, [addIndex(tableName, indexName, columns, unique)], [dropIndex(indexName)], tag);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Schema helper for common column types
|
|
182
|
+
*/
|
|
183
|
+
exports.SchemaHelpers = {
|
|
184
|
+
/**
|
|
185
|
+
* Create a primary key column (auto-increment integer)
|
|
186
|
+
*/
|
|
187
|
+
id(name = 'id') {
|
|
188
|
+
return {
|
|
189
|
+
name,
|
|
190
|
+
type: schema_types_1.ColumnType.INTEGER,
|
|
191
|
+
primaryKey: true,
|
|
192
|
+
autoIncrement: true,
|
|
193
|
+
nullable: false,
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Create a UUID primary key column
|
|
198
|
+
*/
|
|
199
|
+
uuid(name = 'id') {
|
|
200
|
+
return {
|
|
201
|
+
name,
|
|
202
|
+
type: schema_types_1.ColumnType.UUID,
|
|
203
|
+
primaryKey: true,
|
|
204
|
+
nullable: false,
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* Create a string column
|
|
209
|
+
*/
|
|
210
|
+
string(name, length = 255, nullable = true) {
|
|
211
|
+
return {
|
|
212
|
+
name,
|
|
213
|
+
type: schema_types_1.ColumnType.STRING,
|
|
214
|
+
length,
|
|
215
|
+
nullable,
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
/**
|
|
219
|
+
* Create a text column
|
|
220
|
+
*/
|
|
221
|
+
text(name, nullable = true) {
|
|
222
|
+
return {
|
|
223
|
+
name,
|
|
224
|
+
type: schema_types_1.ColumnType.TEXT,
|
|
225
|
+
nullable,
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
/**
|
|
229
|
+
* Create an integer column
|
|
230
|
+
*/
|
|
231
|
+
integer(name, nullable = true) {
|
|
232
|
+
return {
|
|
233
|
+
name,
|
|
234
|
+
type: schema_types_1.ColumnType.INTEGER,
|
|
235
|
+
nullable,
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
/**
|
|
239
|
+
* Create a bigint column
|
|
240
|
+
*/
|
|
241
|
+
bigint(name, nullable = true) {
|
|
242
|
+
return {
|
|
243
|
+
name,
|
|
244
|
+
type: schema_types_1.ColumnType.BIGINT,
|
|
245
|
+
nullable,
|
|
246
|
+
};
|
|
247
|
+
},
|
|
248
|
+
/**
|
|
249
|
+
* Create a decimal column
|
|
250
|
+
*/
|
|
251
|
+
decimal(name, precision = 10, scale = 2, nullable = true) {
|
|
252
|
+
return {
|
|
253
|
+
name,
|
|
254
|
+
type: schema_types_1.ColumnType.DECIMAL,
|
|
255
|
+
precision,
|
|
256
|
+
scale,
|
|
257
|
+
nullable,
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
/**
|
|
261
|
+
* Create a boolean column
|
|
262
|
+
*/
|
|
263
|
+
boolean(name, defaultValue, nullable = true) {
|
|
264
|
+
return {
|
|
265
|
+
name,
|
|
266
|
+
type: schema_types_1.ColumnType.BOOLEAN,
|
|
267
|
+
defaultValue,
|
|
268
|
+
nullable,
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
/**
|
|
272
|
+
* Create a date column
|
|
273
|
+
*/
|
|
274
|
+
date(name, nullable = true) {
|
|
275
|
+
return {
|
|
276
|
+
name,
|
|
277
|
+
type: schema_types_1.ColumnType.DATE,
|
|
278
|
+
nullable,
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
/**
|
|
282
|
+
* Create a datetime column
|
|
283
|
+
*/
|
|
284
|
+
datetime(name, nullable = true) {
|
|
285
|
+
return {
|
|
286
|
+
name,
|
|
287
|
+
type: schema_types_1.ColumnType.DATETIME,
|
|
288
|
+
nullable,
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
/**
|
|
292
|
+
* Create a timestamp column
|
|
293
|
+
*/
|
|
294
|
+
timestamp(name, nullable = true) {
|
|
295
|
+
return {
|
|
296
|
+
name,
|
|
297
|
+
type: schema_types_1.ColumnType.TIMESTAMP,
|
|
298
|
+
nullable,
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* Create a JSON column
|
|
303
|
+
*/
|
|
304
|
+
json(name, nullable = true) {
|
|
305
|
+
return {
|
|
306
|
+
name,
|
|
307
|
+
type: schema_types_1.ColumnType.JSON,
|
|
308
|
+
nullable,
|
|
309
|
+
};
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* Create a JSONB column (PostgreSQL)
|
|
313
|
+
*/
|
|
314
|
+
jsonb(name, nullable = true) {
|
|
315
|
+
return {
|
|
316
|
+
name,
|
|
317
|
+
type: schema_types_1.ColumnType.JSONB,
|
|
318
|
+
nullable,
|
|
319
|
+
};
|
|
320
|
+
},
|
|
321
|
+
/**
|
|
322
|
+
* Create timestamps columns (created_at, updated_at)
|
|
323
|
+
*/
|
|
324
|
+
timestamps() {
|
|
325
|
+
return [
|
|
326
|
+
{
|
|
327
|
+
name: 'created_at',
|
|
328
|
+
type: schema_types_1.ColumnType.TIMESTAMP,
|
|
329
|
+
nullable: false,
|
|
330
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'updated_at',
|
|
334
|
+
type: schema_types_1.ColumnType.TIMESTAMP,
|
|
335
|
+
nullable: false,
|
|
336
|
+
defaultValue: 'CURRENT_TIMESTAMP',
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
},
|
|
340
|
+
/**
|
|
341
|
+
* Create a soft delete column (deleted_at)
|
|
342
|
+
*/
|
|
343
|
+
softDelete() {
|
|
344
|
+
return {
|
|
345
|
+
name: 'deleted_at',
|
|
346
|
+
type: schema_types_1.ColumnType.TIMESTAMP,
|
|
347
|
+
nullable: true,
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
/**
|
|
351
|
+
* Create a foreign key column
|
|
352
|
+
*/
|
|
353
|
+
foreignKey(name, referencedTable, referencedColumn = 'id', nullable = true) {
|
|
354
|
+
return {
|
|
355
|
+
name,
|
|
356
|
+
type: schema_types_1.ColumnType.INTEGER,
|
|
357
|
+
nullable,
|
|
358
|
+
comment: `Foreign key to ${referencedTable}.${referencedColumn}`,
|
|
359
|
+
};
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Generate TypeScript migration file content
|
|
364
|
+
*/
|
|
365
|
+
function generateMigrationFileContent(migration) {
|
|
366
|
+
const upOperations = JSON.stringify(migration.up, null, 2);
|
|
367
|
+
const downOperations = JSON.stringify(migration.down, null, 2);
|
|
368
|
+
const createdAtStr = migration.createdAt instanceof Date
|
|
369
|
+
? migration.createdAt.toISOString()
|
|
370
|
+
: migration.createdAt;
|
|
371
|
+
return `/**
|
|
372
|
+
* Migration: ${migration.name}
|
|
373
|
+
* Tag: ${migration.tag}
|
|
374
|
+
* Created: ${createdAtStr}
|
|
375
|
+
*/
|
|
376
|
+
|
|
377
|
+
import { IMigrationDefinition } from '@ductape/sdk';
|
|
378
|
+
|
|
379
|
+
export const migration: IMigrationDefinition = {
|
|
380
|
+
tag: '${migration.tag}',
|
|
381
|
+
name: '${migration.name}',
|
|
382
|
+
description: '${migration.description || migration.name}',
|
|
383
|
+
up: ${upOperations},
|
|
384
|
+
down: ${downOperations},
|
|
385
|
+
createdAt: new Date('${createdAtStr}'),
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
export default migration;
|
|
389
|
+
`;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Generate a simple migration template
|
|
393
|
+
*/
|
|
394
|
+
function generateMigrationTemplate(name) {
|
|
395
|
+
const tag = generateMigrationTag(name);
|
|
396
|
+
const timestamp = new Date().toISOString();
|
|
397
|
+
return `/**
|
|
398
|
+
* Migration: ${name}
|
|
399
|
+
* Tag: ${tag}
|
|
400
|
+
* Created: ${timestamp}
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
import {
|
|
404
|
+
IMigrationDefinition,
|
|
405
|
+
createMigration,
|
|
406
|
+
createTable,
|
|
407
|
+
dropTable,
|
|
408
|
+
addColumn,
|
|
409
|
+
dropColumn,
|
|
410
|
+
addIndex,
|
|
411
|
+
dropIndex,
|
|
412
|
+
SchemaHelpers,
|
|
413
|
+
ColumnType,
|
|
414
|
+
} from '@ductape/sdk';
|
|
415
|
+
|
|
416
|
+
// Define your migration as a simple JSON object
|
|
417
|
+
export const migration: IMigrationDefinition = {
|
|
418
|
+
tag: '${tag}',
|
|
419
|
+
name: '${name}',
|
|
420
|
+
description: 'Description of what this migration does',
|
|
421
|
+
|
|
422
|
+
// Up migration - operations to apply
|
|
423
|
+
up: [
|
|
424
|
+
// Example: Create a table
|
|
425
|
+
// {
|
|
426
|
+
// type: 'create_table',
|
|
427
|
+
// params: {
|
|
428
|
+
// schema: {
|
|
429
|
+
// name: 'users',
|
|
430
|
+
// columns: [
|
|
431
|
+
// { name: 'id', type: ColumnType.INTEGER, primaryKey: true, autoIncrement: true },
|
|
432
|
+
// { name: 'email', type: ColumnType.STRING, length: 255, nullable: false, unique: true },
|
|
433
|
+
// { name: 'name', type: ColumnType.STRING, length: 255 },
|
|
434
|
+
// { name: 'created_at', type: ColumnType.TIMESTAMP, nullable: false, defaultValue: 'CURRENT_TIMESTAMP' },
|
|
435
|
+
// ],
|
|
436
|
+
// },
|
|
437
|
+
// },
|
|
438
|
+
// },
|
|
439
|
+
|
|
440
|
+
// Example: Add a column
|
|
441
|
+
// {
|
|
442
|
+
// type: 'add_column',
|
|
443
|
+
// table: 'users',
|
|
444
|
+
// params: {
|
|
445
|
+
// column: { name: 'phone', type: ColumnType.STRING, length: 20 },
|
|
446
|
+
// },
|
|
447
|
+
// },
|
|
448
|
+
|
|
449
|
+
// Example: Add an index
|
|
450
|
+
// {
|
|
451
|
+
// type: 'add_index',
|
|
452
|
+
// table: 'users',
|
|
453
|
+
// params: {
|
|
454
|
+
// indexName: 'idx_users_email',
|
|
455
|
+
// columns: ['email'],
|
|
456
|
+
// unique: true,
|
|
457
|
+
// },
|
|
458
|
+
// },
|
|
459
|
+
],
|
|
460
|
+
|
|
461
|
+
// Down migration - operations to rollback
|
|
462
|
+
down: [
|
|
463
|
+
// Example: Drop the table
|
|
464
|
+
// {
|
|
465
|
+
// type: 'drop_table',
|
|
466
|
+
// table: 'users',
|
|
467
|
+
// },
|
|
468
|
+
],
|
|
469
|
+
|
|
470
|
+
createdAt: new Date('${timestamp}'),
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
export default migration;
|
|
474
|
+
`;
|
|
475
|
+
}
|
|
476
|
+
//# sourceMappingURL=migration.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.utils.js","sourceRoot":"","sources":["../../../src/database/utils/migration.utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,oDAIC;AAKD,gEAEC;AAKD,0CAcC;AAKD,kCAKC;AAKD,8BAKC;AAKD,8BAMC;AAKD,gCAMC;AAKD,oCAMC;AAKD,oCAMC;AAKD,4BAMC;AAKD,8BAKC;AAKD,sCAUC;AAKD,wCAMC;AAKD,wBAKC;AAKD,oDAEC;AAKD,gDAOC;AAKD,8CASC;AA2MD,oEA2BC;AAKD,8DAkFC;AAhgBD,8DAIkC;AAClC,wDAAoF;AAGpF;;GAEG;AACH,SAAgB,oBAAoB,CAAC,IAAY;IAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IACrE,OAAO,GAAG,SAAS,IAAI,aAAa,EAAE,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAC7B,IAAY,EACZ,EAAyB,EACzB,IAA2B,EAC3B,GAAY;IAEZ,OAAO;QACL,GAAG,EAAE,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC;QACtC,IAAI;QACJ,WAAW,EAAE,cAAc,IAAI,EAAE;QACjC,EAAE;QACF,IAAI;QACJ,SAAS,EAAE,IAAI,IAAI,EAA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AAY,IAAI;QACtD,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE;QACnC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;IAExB,OAAO;gBACO,SAAS,CAAC,IAAI;UACpB,SAAS,CAAC,GAAG;cACT,YAAY;;;;;;UAMhB,SAAS,CAAC,GAAG;WACZ,SAAS,CAAC,IAAI;kBACP,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI;QACjD,YAAY;UACV,cAAc;yBACC,YAAY;;;;CAIpC,CAAC;AACF,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,IAAY;IACpD,MAAM,GAAG,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE3C,OAAO;gBACO,IAAI;UACV,GAAG;cACC,SAAS;;;;;;;;;;;;;;;;;;UAkBb,GAAG;WACF,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAmDU,SAAS;;;;CAIjC,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction implementation
|
|
3
|
+
* Provides a stable interface for database transactions
|
|
4
|
+
*/
|
|
5
|
+
import { ITransaction, ISavepoint, IConnection, TransactionStatus, TransactionIsolationLevel } from '../types/database.types';
|
|
6
|
+
import { BaseDatabaseAdapter } from '../adapters/base.adapter';
|
|
7
|
+
/**
|
|
8
|
+
* Savepoint implementation
|
|
9
|
+
*/
|
|
10
|
+
export declare class Savepoint implements ISavepoint {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly transaction: ITransaction;
|
|
13
|
+
readonly createdAt: Date;
|
|
14
|
+
private adapter;
|
|
15
|
+
constructor(name: string, transaction: ITransaction, adapter: BaseDatabaseAdapter);
|
|
16
|
+
rollback(): Promise<void>;
|
|
17
|
+
release(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Transaction implementation
|
|
21
|
+
*/
|
|
22
|
+
export declare class Transaction implements ITransaction {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly connection: IConnection;
|
|
25
|
+
status: TransactionStatus;
|
|
26
|
+
readonly isolationLevel?: TransactionIsolationLevel;
|
|
27
|
+
readonly parent?: ITransaction;
|
|
28
|
+
readonly createdAt: Date;
|
|
29
|
+
readonly native: any;
|
|
30
|
+
private adapter;
|
|
31
|
+
private savepoints;
|
|
32
|
+
private savepointCounter;
|
|
33
|
+
constructor(id: string, connection: IConnection, native: any, adapter: BaseDatabaseAdapter, options?: {
|
|
34
|
+
isolationLevel?: TransactionIsolationLevel;
|
|
35
|
+
parent?: ITransaction;
|
|
36
|
+
});
|
|
37
|
+
commit(): Promise<void>;
|
|
38
|
+
rollback(): Promise<void>;
|
|
39
|
+
savepoint(name?: string): Promise<ISavepoint>;
|
|
40
|
+
isActive(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get a savepoint by name
|
|
43
|
+
*/
|
|
44
|
+
getSavepoint(name: string): ISavepoint | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get all savepoints
|
|
47
|
+
*/
|
|
48
|
+
getSavepoints(): ISavepoint[];
|
|
49
|
+
/**
|
|
50
|
+
* Remove a savepoint from tracking (after rollback or release)
|
|
51
|
+
*/
|
|
52
|
+
removeSavepoint(name: string): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Transaction factory
|
|
56
|
+
* Creates transaction instances
|
|
57
|
+
*/
|
|
58
|
+
export declare class TransactionFactory {
|
|
59
|
+
private static idCounter;
|
|
60
|
+
static create(connection: IConnection, native: any, adapter: BaseDatabaseAdapter, options?: {
|
|
61
|
+
isolationLevel?: TransactionIsolationLevel;
|
|
62
|
+
parent?: ITransaction;
|
|
63
|
+
}): ITransaction;
|
|
64
|
+
}
|