@dbos-inc/dbos-sdk 2.2.10-preview.g90e74a1e32 → 2.3.9-preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/.husky/pre-commit +1 -0
  2. package/.prettierignore +3 -0
  3. package/.prettierrc +9 -0
  4. package/CODE_OF_CONDUCT.md +24 -18
  5. package/CONTRIBUTING.md +12 -10
  6. package/README.md +2 -2
  7. package/compose.yaml +17 -17
  8. package/dbos-config.schema.json +4 -13
  9. package/dist/schemas/user_db_schema.d.ts.map +1 -1
  10. package/dist/schemas/user_db_schema.js.map +1 -1
  11. package/dist/src/context.d.ts +12 -12
  12. package/dist/src/context.d.ts.map +1 -1
  13. package/dist/src/context.js +9 -9
  14. package/dist/src/context.js.map +1 -1
  15. package/dist/src/data_validation.d.ts +1 -1
  16. package/dist/src/data_validation.d.ts.map +1 -1
  17. package/dist/src/data_validation.js +14 -8
  18. package/dist/src/data_validation.js.map +1 -1
  19. package/dist/src/dbos-executor.d.ts +4 -3
  20. package/dist/src/dbos-executor.d.ts.map +1 -1
  21. package/dist/src/dbos-executor.js +152 -141
  22. package/dist/src/dbos-executor.js.map +1 -1
  23. package/dist/src/dbos-runtime/cli.d.ts +3 -3
  24. package/dist/src/dbos-runtime/cli.d.ts.map +1 -1
  25. package/dist/src/dbos-runtime/cli.js +80 -39
  26. package/dist/src/dbos-runtime/cli.js.map +1 -1
  27. package/dist/src/dbos-runtime/cloudutils/authentication.d.ts +1 -1
  28. package/dist/src/dbos-runtime/cloudutils/authentication.d.ts.map +1 -1
  29. package/dist/src/dbos-runtime/cloudutils/authentication.js +14 -14
  30. package/dist/src/dbos-runtime/cloudutils/authentication.js.map +1 -1
  31. package/dist/src/dbos-runtime/cloudutils/cloudutils.d.ts +2 -2
  32. package/dist/src/dbos-runtime/cloudutils/cloudutils.d.ts.map +1 -1
  33. package/dist/src/dbos-runtime/cloudutils/cloudutils.js +32 -32
  34. package/dist/src/dbos-runtime/cloudutils/cloudutils.js.map +1 -1
  35. package/dist/src/dbos-runtime/cloudutils/databases.d.ts +2 -2
  36. package/dist/src/dbos-runtime/cloudutils/databases.d.ts.map +1 -1
  37. package/dist/src/dbos-runtime/cloudutils/databases.js +25 -21
  38. package/dist/src/dbos-runtime/cloudutils/databases.js.map +1 -1
  39. package/dist/src/dbos-runtime/commands.d.ts +1 -1
  40. package/dist/src/dbos-runtime/commands.js +9 -9
  41. package/dist/src/dbos-runtime/config.d.ts +7 -7
  42. package/dist/src/dbos-runtime/config.d.ts.map +1 -1
  43. package/dist/src/dbos-runtime/config.js +39 -23
  44. package/dist/src/dbos-runtime/config.js.map +1 -1
  45. package/dist/src/dbos-runtime/configure.d.ts.map +1 -1
  46. package/dist/src/dbos-runtime/configure.js.map +1 -1
  47. package/dist/src/dbos-runtime/db_connection.d.ts.map +1 -1
  48. package/dist/src/dbos-runtime/db_connection.js +2 -2
  49. package/dist/src/dbos-runtime/db_connection.js.map +1 -1
  50. package/dist/src/dbos-runtime/db_wizard.d.ts +1 -1
  51. package/dist/src/dbos-runtime/db_wizard.d.ts.map +1 -1
  52. package/dist/src/dbos-runtime/db_wizard.js +18 -18
  53. package/dist/src/dbos-runtime/db_wizard.js.map +1 -1
  54. package/dist/src/dbos-runtime/debug.d.ts +3 -3
  55. package/dist/src/dbos-runtime/debug.d.ts.map +1 -1
  56. package/dist/src/dbos-runtime/debug.js +7 -12
  57. package/dist/src/dbos-runtime/debug.js.map +1 -1
  58. package/dist/src/dbos-runtime/migrate.d.ts +2 -2
  59. package/dist/src/dbos-runtime/migrate.d.ts.map +1 -1
  60. package/dist/src/dbos-runtime/migrate.js +14 -10
  61. package/dist/src/dbos-runtime/migrate.js.map +1 -1
  62. package/dist/src/dbos-runtime/reset.d.ts +2 -2
  63. package/dist/src/dbos-runtime/reset.js +2 -2
  64. package/dist/src/dbos-runtime/reset.js.map +1 -1
  65. package/dist/src/dbos-runtime/runtime.d.ts.map +1 -1
  66. package/dist/src/dbos-runtime/runtime.js +4 -4
  67. package/dist/src/dbos-runtime/runtime.js.map +1 -1
  68. package/dist/src/dbos-runtime/workflow_management.d.ts +5 -4
  69. package/dist/src/dbos-runtime/workflow_management.d.ts.map +1 -1
  70. package/dist/src/dbos-runtime/workflow_management.js +34 -14
  71. package/dist/src/dbos-runtime/workflow_management.js.map +1 -1
  72. package/dist/src/dbos.d.ts +23 -23
  73. package/dist/src/dbos.d.ts.map +1 -1
  74. package/dist/src/dbos.js +59 -59
  75. package/dist/src/dbos.js.map +1 -1
  76. package/dist/src/debugpoint.d.ts.map +1 -1
  77. package/dist/src/debugpoint.js +4 -4
  78. package/dist/src/debugpoint.js.map +1 -1
  79. package/dist/src/decorators.d.ts +8 -8
  80. package/dist/src/decorators.d.ts.map +1 -1
  81. package/dist/src/decorators.js +36 -33
  82. package/dist/src/decorators.js.map +1 -1
  83. package/dist/src/error.d.ts.map +1 -1
  84. package/dist/src/error.js +6 -5
  85. package/dist/src/error.js.map +1 -1
  86. package/dist/src/eventreceiver.d.ts +1 -1
  87. package/dist/src/eventreceiver.d.ts.map +1 -1
  88. package/dist/src/httpServer/handler.d.ts +8 -8
  89. package/dist/src/httpServer/handler.d.ts.map +1 -1
  90. package/dist/src/httpServer/handler.js.map +1 -1
  91. package/dist/src/httpServer/handlerTypes.d.ts.map +1 -1
  92. package/dist/src/httpServer/handlerTypes.js.map +1 -1
  93. package/dist/src/httpServer/middleware.d.ts +9 -9
  94. package/dist/src/httpServer/middleware.d.ts.map +1 -1
  95. package/dist/src/httpServer/middleware.js +6 -6
  96. package/dist/src/httpServer/middleware.js.map +1 -1
  97. package/dist/src/httpServer/server.d.ts +2 -2
  98. package/dist/src/httpServer/server.d.ts.map +1 -1
  99. package/dist/src/httpServer/server.js +27 -33
  100. package/dist/src/httpServer/server.js.map +1 -1
  101. package/dist/src/index.d.ts +16 -16
  102. package/dist/src/index.d.ts.map +1 -1
  103. package/dist/src/index.js.map +1 -1
  104. package/dist/src/kafka/kafka.d.ts.map +1 -1
  105. package/dist/src/kafka/kafka.js +2 -2
  106. package/dist/src/kafka/kafka.js.map +1 -1
  107. package/dist/src/procedure.d.ts +6 -6
  108. package/dist/src/procedure.d.ts.map +1 -1
  109. package/dist/src/procedure.js.map +1 -1
  110. package/dist/src/scheduler/crontab.d.ts.map +1 -1
  111. package/dist/src/scheduler/crontab.js +54 -33
  112. package/dist/src/scheduler/crontab.js.map +1 -1
  113. package/dist/src/scheduler/scheduler.d.ts +3 -3
  114. package/dist/src/scheduler/scheduler.d.ts.map +1 -1
  115. package/dist/src/scheduler/scheduler.js +7 -7
  116. package/dist/src/scheduler/scheduler.js.map +1 -1
  117. package/dist/src/step.d.ts +4 -4
  118. package/dist/src/step.d.ts.map +1 -1
  119. package/dist/src/step.js.map +1 -1
  120. package/dist/src/system_database.d.ts +20 -13
  121. package/dist/src/system_database.d.ts.map +1 -1
  122. package/dist/src/system_database.js +168 -60
  123. package/dist/src/system_database.js.map +1 -1
  124. package/dist/src/telemetry/collector.d.ts +3 -3
  125. package/dist/src/telemetry/exporters.d.ts +1 -1
  126. package/dist/src/telemetry/exporters.js.map +1 -1
  127. package/dist/src/telemetry/index.d.ts +5 -5
  128. package/dist/src/telemetry/logs.d.ts +4 -4
  129. package/dist/src/telemetry/logs.d.ts.map +1 -1
  130. package/dist/src/telemetry/logs.js +18 -18
  131. package/dist/src/telemetry/logs.js.map +1 -1
  132. package/dist/src/telemetry/traces.d.ts +3 -3
  133. package/dist/src/telemetry/traces.js +7 -7
  134. package/dist/src/testing/testing_runtime.d.ts +11 -11
  135. package/dist/src/testing/testing_runtime.d.ts.map +1 -1
  136. package/dist/src/testing/testing_runtime.js +15 -8
  137. package/dist/src/testing/testing_runtime.js.map +1 -1
  138. package/dist/src/transaction.d.ts +6 -6
  139. package/dist/src/transaction.d.ts.map +1 -1
  140. package/dist/src/transaction.js +4 -4
  141. package/dist/src/transaction.js.map +1 -1
  142. package/dist/src/user_database.d.ts +4 -4
  143. package/dist/src/user_database.d.ts.map +1 -1
  144. package/dist/src/user_database.js +45 -45
  145. package/dist/src/user_database.js.map +1 -1
  146. package/dist/src/utils.d.ts.map +1 -1
  147. package/dist/src/utils.js +6 -12
  148. package/dist/src/utils.js.map +1 -1
  149. package/dist/src/wfqueue.d.ts +1 -1
  150. package/dist/src/wfqueue.d.ts.map +1 -1
  151. package/dist/src/wfqueue.js +8 -8
  152. package/dist/src/wfqueue.js.map +1 -1
  153. package/dist/src/workflow.d.ts +22 -10
  154. package/dist/src/workflow.d.ts.map +1 -1
  155. package/dist/src/workflow.js +19 -18
  156. package/dist/src/workflow.js.map +1 -1
  157. package/dist/tsconfig.build.tsbuildinfo +1 -1
  158. package/eslint.config.js +29 -27
  159. package/migrations/20240123182943_schema.js +7 -8
  160. package/migrations/20240123183021_tables.js +52 -48
  161. package/migrations/20240123183025_indexes.js +11 -14
  162. package/migrations/20240123183030_triggers.js +7 -8
  163. package/migrations/20240124015239_status_timestamp.js +12 -18
  164. package/migrations/20240201213211_replica_identity.js +8 -11
  165. package/migrations/20240205223925_foreign_keys.js +40 -18
  166. package/migrations/20240207192338_executor_id_index.js +8 -10
  167. package/migrations/20240430090000_tables.js +8 -10
  168. package/migrations/20240516004341_application_version.js +10 -12
  169. package/migrations/20240517000000_status_class_config.js +10 -14
  170. package/migrations/20240621000000_workflow_tries.js +8 -12
  171. package/migrations/20240924000000_workflowqueue.js +32 -23
  172. package/migrations/20241009150000_event_dispatch_kv.js +12 -14
  173. package/migrations/20252101000000_workflow_queues_executor_id.js +7 -9
  174. package/package.json +9 -2
  175. package/src/dbos-runtime/cloudutils/README.md +1 -1
package/eslint.config.js CHANGED
@@ -1,43 +1,45 @@
1
- const { FlatCompat } = require("@eslint/eslintrc");
2
- const typescriptEslint = require("typescript-eslint");
3
- const typescriptEslintPlugin = require("@typescript-eslint/eslint-plugin");
4
- const typescriptEslintParser = require("@typescript-eslint/parser");
5
- const globals = require("globals");
6
- const js = require("@eslint/js");
1
+ const { FlatCompat } = require('@eslint/eslintrc');
2
+ const typescriptEslint = require('typescript-eslint');
3
+ const typescriptEslintPlugin = require('@typescript-eslint/eslint-plugin');
4
+ const typescriptEslintParser = require('@typescript-eslint/parser');
5
+ const globals = require('globals');
6
+ const js = require('@eslint/js');
7
7
 
8
8
  const compat = new FlatCompat({
9
- baseDirectory: __dirname,
10
- recommendedConfig: js.configs.recommended
9
+ baseDirectory: __dirname,
10
+ recommendedConfig: js.configs.recommended,
11
11
  });
12
12
 
13
13
  module.exports = typescriptEslint.config(
14
14
  {
15
- ignores: [
16
- "**/dist/",
17
- "**/migrations/*",
18
- "packages/create/templates/"
19
- ]
15
+ ignores: ['**/dist/', '**/migrations/*', 'packages/create/templates/'],
20
16
  },
21
17
 
22
18
  {
23
- files: ["**/*.ts"],
19
+ files: ['**/*.ts'],
24
20
 
25
- extends: compat.extends("plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-type-checked"),
26
- plugins: { "@typescript-eslint": typescriptEslintPlugin },
21
+ extends: compat.extends(
22
+ 'plugin:@typescript-eslint/recommended',
23
+ 'plugin:@typescript-eslint/recommended-type-checked',
24
+ ),
25
+ plugins: { '@typescript-eslint': typescriptEslintPlugin },
27
26
 
28
27
  languageOptions: {
29
- parser: typescriptEslintParser,
30
- parserOptions: { project: "./tsconfig.json" },
31
- globals: { ...globals.node }
28
+ parser: typescriptEslintParser,
29
+ parserOptions: { project: './tsconfig.json' },
30
+ globals: { ...globals.node },
32
31
  },
33
32
 
34
33
  rules: {
35
- "eqeqeq": "error",
36
- "@typescript-eslint/indent": "off",
37
- "@typescript-eslint/unbound-method": ["error", { ignoreStatic: true }],
38
- "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrors: "none" }],
39
- "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
40
- "@typescript-eslint/no-floating-promises": "error"
41
- }
42
- }
34
+ eqeqeq: 'error',
35
+ '@typescript-eslint/indent': 'off',
36
+ '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
37
+ '@typescript-eslint/no-unused-vars': [
38
+ 'error',
39
+ { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrors: 'none' },
40
+ ],
41
+ '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
42
+ '@typescript-eslint/no-floating-promises': 'error',
43
+ },
44
+ },
43
45
  );
@@ -1,8 +1,7 @@
1
- exports.up = function(knex) {
2
- return knex.raw('CREATE SCHEMA IF NOT EXISTS dbos');
3
- };
4
-
5
- exports.down = function(knex) {
6
- return knex.raw('DROP SCHEMA IF EXISTS dbos');
7
- };
8
-
1
+ exports.up = function (knex) {
2
+ return knex.raw('CREATE SCHEMA IF NOT EXISTS dbos');
3
+ };
4
+
5
+ exports.down = function (knex) {
6
+ return knex.raw('DROP SCHEMA IF EXISTS dbos');
7
+ };
@@ -1,48 +1,52 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .createTable('operation_outputs', function(table) {
4
- table.text('workflow_uuid').notNullable();
5
- table.integer('function_id').notNullable();
6
- table.text('output');
7
- table.text('error');
8
- table.primary(['workflow_uuid', 'function_id']);
9
- })
10
- .createTable('workflow_inputs', function(table) {
11
- table.text('workflow_uuid').primary().notNullable();
12
- table.text('inputs').notNullable();
13
- })
14
- .createTable('workflow_status', function(table) {
15
- table.text('workflow_uuid').primary();
16
- table.text('status');
17
- table.text('name');
18
- table.text('authenticated_user');
19
- table.text('assumed_role');
20
- table.text('authenticated_roles');
21
- table.text('request');
22
- table.text('output');
23
- table.text('error');
24
- table.text('executor_id');
25
- })
26
- .createTable('notifications', function(table) {
27
- table.text('destination_uuid').notNullable();
28
- table.text('topic');
29
- table.text('message').notNullable();
30
- table.bigInteger('created_at_epoch_ms').notNullable().defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
31
- })
32
- .createTable('workflow_events', function(table) {
33
- table.text('workflow_uuid').notNullable();
34
- table.text('key').notNullable();
35
- table.text('value').notNullable();
36
- table.primary(['workflow_uuid', 'key']);
37
- });
38
- };
39
-
40
- exports.down = function(knex) {
41
- return knex.schema.withSchema('dbos')
42
- .dropTableIfExists('operation_outputs')
43
- .dropTableIfExists('workflow_inputs')
44
- .dropTableIfExists('workflow_status')
45
- .dropTableIfExists('notifications')
46
- .dropTableIfExists('workflow_events');
47
- };
48
-
1
+ exports.up = function (knex) {
2
+ return knex.schema
3
+ .withSchema('dbos')
4
+ .createTable('operation_outputs', function (table) {
5
+ table.text('workflow_uuid').notNullable();
6
+ table.integer('function_id').notNullable();
7
+ table.text('output');
8
+ table.text('error');
9
+ table.primary(['workflow_uuid', 'function_id']);
10
+ })
11
+ .createTable('workflow_inputs', function (table) {
12
+ table.text('workflow_uuid').primary().notNullable();
13
+ table.text('inputs').notNullable();
14
+ })
15
+ .createTable('workflow_status', function (table) {
16
+ table.text('workflow_uuid').primary();
17
+ table.text('status');
18
+ table.text('name');
19
+ table.text('authenticated_user');
20
+ table.text('assumed_role');
21
+ table.text('authenticated_roles');
22
+ table.text('request');
23
+ table.text('output');
24
+ table.text('error');
25
+ table.text('executor_id');
26
+ })
27
+ .createTable('notifications', function (table) {
28
+ table.text('destination_uuid').notNullable();
29
+ table.text('topic');
30
+ table.text('message').notNullable();
31
+ table
32
+ .bigInteger('created_at_epoch_ms')
33
+ .notNullable()
34
+ .defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
35
+ })
36
+ .createTable('workflow_events', function (table) {
37
+ table.text('workflow_uuid').notNullable();
38
+ table.text('key').notNullable();
39
+ table.text('value').notNullable();
40
+ table.primary(['workflow_uuid', 'key']);
41
+ });
42
+ };
43
+
44
+ exports.down = function (knex) {
45
+ return knex.schema
46
+ .withSchema('dbos')
47
+ .dropTableIfExists('operation_outputs')
48
+ .dropTableIfExists('workflow_inputs')
49
+ .dropTableIfExists('workflow_status')
50
+ .dropTableIfExists('notifications')
51
+ .dropTableIfExists('workflow_events');
52
+ };
@@ -1,14 +1,11 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .table('notifications', function(table) {
4
- table.index(['destination_uuid', 'topic'], 'idx_workflow_topic');
5
- });
6
- };
7
-
8
- exports.down = function(knex) {
9
- return knex.schema.withSchema('dbos')
10
- .table('notifications', function(table) {
11
- table.dropIndex(['destination_uuid', 'topic'], 'idx_workflow_topic');
12
- });
13
- };
14
-
1
+ exports.up = function (knex) {
2
+ return knex.schema.withSchema('dbos').table('notifications', function (table) {
3
+ table.index(['destination_uuid', 'topic'], 'idx_workflow_topic');
4
+ });
5
+ };
6
+
7
+ exports.down = function (knex) {
8
+ return knex.schema.withSchema('dbos').table('notifications', function (table) {
9
+ table.dropIndex(['destination_uuid', 'topic'], 'idx_workflow_topic');
10
+ });
11
+ };
@@ -1,5 +1,5 @@
1
- exports.up = function(knex) {
2
- return knex.raw(`
1
+ exports.up = function (knex) {
2
+ return knex.raw(`
3
3
  CREATE OR REPLACE FUNCTION dbos.notifications_function() RETURNS TRIGGER AS $$
4
4
  DECLARE
5
5
  payload text := NEW.destination_uuid || '::' || NEW.topic;
@@ -26,14 +26,13 @@ exports.up = function(knex) {
26
26
  AFTER INSERT ON dbos.workflow_events
27
27
  FOR EACH ROW EXECUTE FUNCTION dbos.workflow_events_function();
28
28
  `);
29
- };
30
-
31
- exports.down = function(knex) {
32
- return knex.raw(`
29
+ };
30
+
31
+ exports.down = function (knex) {
32
+ return knex.raw(`
33
33
  DROP TRIGGER IF EXISTS dbos_notifications_trigger ON dbos.notifications;
34
34
  DROP FUNCTION IF EXISTS dbos.notifications_function;
35
35
  DROP TRIGGER IF EXISTS dbos_workflow_events_trigger ON dbos.workflow_events;
36
36
  DROP FUNCTION IF EXISTS dbos.workflow_events_function;
37
37
  `);
38
- };
39
-
38
+ };
@@ -1,22 +1,16 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .table('workflow_status', function(table) {
4
- // Add CREATED_AT column with default value as current epoch time in milliseconds
5
- table.bigInteger('created_at')
6
- .notNullable()
7
- .defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
1
+ exports.up = function (knex) {
2
+ return knex.schema.withSchema('dbos').table('workflow_status', function (table) {
3
+ // Add CREATED_AT column with default value as current epoch time in milliseconds
4
+ table.bigInteger('created_at').notNullable().defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
8
5
 
9
- // Add UPDATED_AT column with default value as current epoch time in milliseconds
10
- table.bigInteger('updated_at')
11
- .notNullable()
12
- .defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
13
- });
6
+ // Add UPDATED_AT column with default value as current epoch time in milliseconds
7
+ table.bigInteger('updated_at').notNullable().defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
8
+ });
14
9
  };
15
10
 
16
- exports.down = function(knex) {
17
- return knex.schema.withSchema('dbos')
18
- .table('workflow_status', function(table) {
19
- table.dropColumn('created_at');
20
- table.dropColumn('updated_at');
21
- });
11
+ exports.down = function (knex) {
12
+ return knex.schema.withSchema('dbos').table('workflow_status', function (table) {
13
+ table.dropColumn('created_at');
14
+ table.dropColumn('updated_at');
15
+ });
22
16
  };
@@ -1,15 +1,12 @@
1
- exports.up = async function(knex) {
1
+ exports.up = async function (knex) {
2
2
  await knex.raw('create extension if not exists "uuid-ossp"');
3
- return knex.schema.withSchema('dbos')
4
- .table('notifications', function(table) {
5
- table.text('message_uuid').primary().defaultTo(knex.raw('uuid_generate_v4()'));
6
- })
7
-
3
+ return knex.schema.withSchema('dbos').table('notifications', function (table) {
4
+ table.text('message_uuid').primary().defaultTo(knex.raw('uuid_generate_v4()'));
5
+ });
8
6
  };
9
7
 
10
- exports.down = function(knex) {
11
- return knex.schema.withSchema('dbos')
12
- .table('notifications', function(table) {
13
- table.dropColumn('message_uuid');
14
- });
8
+ exports.down = function (knex) {
9
+ return knex.schema.withSchema('dbos').table('notifications', function (table) {
10
+ table.dropColumn('message_uuid');
11
+ });
15
12
  };
@@ -2,22 +2,43 @@
2
2
  * @param { import("knex").Knex } knex
3
3
  * @returns { Promise<void> }
4
4
  */
5
- exports.up = function(knex) {
6
- return knex.schema.withSchema('dbos')
7
- .alterTable('workflow_status', function(table) {
5
+ exports.up = function (knex) {
6
+ return knex.schema
7
+ .withSchema('dbos')
8
+ .alterTable('workflow_status', function (table) {
8
9
  table.index('created_at');
9
10
  })
10
- .alterTable('operation_outputs', function(table) {
11
- table.foreign('workflow_uuid').references('workflow_uuid').inTable('dbos.workflow_status').onDelete('CASCADE').onUpdate('CASCADE');
11
+ .alterTable('operation_outputs', function (table) {
12
+ table
13
+ .foreign('workflow_uuid')
14
+ .references('workflow_uuid')
15
+ .inTable('dbos.workflow_status')
16
+ .onDelete('CASCADE')
17
+ .onUpdate('CASCADE');
12
18
  })
13
- .alterTable('workflow_inputs', function(table) {
14
- table.foreign('workflow_uuid').references('workflow_uuid').inTable('dbos.workflow_status').onDelete('CASCADE').onUpdate('CASCADE');
19
+ .alterTable('workflow_inputs', function (table) {
20
+ table
21
+ .foreign('workflow_uuid')
22
+ .references('workflow_uuid')
23
+ .inTable('dbos.workflow_status')
24
+ .onDelete('CASCADE')
25
+ .onUpdate('CASCADE');
15
26
  })
16
- .alterTable('notifications', function(table) {
17
- table.foreign('destination_uuid').references('workflow_uuid').inTable('dbos.workflow_status').onDelete('CASCADE').onUpdate('CASCADE');
27
+ .alterTable('notifications', function (table) {
28
+ table
29
+ .foreign('destination_uuid')
30
+ .references('workflow_uuid')
31
+ .inTable('dbos.workflow_status')
32
+ .onDelete('CASCADE')
33
+ .onUpdate('CASCADE');
18
34
  })
19
- .alterTable('workflow_events', function(table) {
20
- table.foreign('workflow_uuid').references('workflow_uuid').inTable('dbos.workflow_status').onDelete('CASCADE').onUpdate('CASCADE');
35
+ .alterTable('workflow_events', function (table) {
36
+ table
37
+ .foreign('workflow_uuid')
38
+ .references('workflow_uuid')
39
+ .inTable('dbos.workflow_status')
40
+ .onDelete('CASCADE')
41
+ .onUpdate('CASCADE');
21
42
  });
22
43
  };
23
44
 
@@ -25,21 +46,22 @@ exports.up = function(knex) {
25
46
  * @param { import("knex").Knex } knex
26
47
  * @returns { Promise<void> }
27
48
  */
28
- exports.down = function(knex) {
29
- return knex.schema.withSchema('dbos')
30
- .alterTable('workflow_status', function(table) {
49
+ exports.down = function (knex) {
50
+ return knex.schema
51
+ .withSchema('dbos')
52
+ .alterTable('workflow_status', function (table) {
31
53
  table.dropIndex('created_at');
32
54
  })
33
- .alterTable('operation_outputs', function(table) {
55
+ .alterTable('operation_outputs', function (table) {
34
56
  table.dropForeign('workflow_uuid');
35
57
  })
36
- .alterTable('workflow_inputs', function(table) {
58
+ .alterTable('workflow_inputs', function (table) {
37
59
  table.dropForeign('workflow_uuid');
38
60
  })
39
- .alterTable('notifications', function(table) {
61
+ .alterTable('notifications', function (table) {
40
62
  table.dropForeign('destination_uuid');
41
63
  })
42
- .alterTable('workflow_events', function(table) {
64
+ .alterTable('workflow_events', function (table) {
43
65
  table.dropForeign('workflow_uuid');
44
66
  });
45
67
  };
@@ -2,20 +2,18 @@
2
2
  * @param { import("knex").Knex } knex
3
3
  * @returns { Promise<void> }
4
4
  */
5
- exports.up = function(knex) {
6
- return knex.schema.withSchema('dbos')
7
- .alterTable('workflow_status', function(table) {
8
- table.index('executor_id');
9
- });
5
+ exports.up = function (knex) {
6
+ return knex.schema.withSchema('dbos').alterTable('workflow_status', function (table) {
7
+ table.index('executor_id');
8
+ });
10
9
  };
11
10
 
12
11
  /**
13
12
  * @param { import("knex").Knex } knex
14
13
  * @returns { Promise<void> }
15
14
  */
16
- exports.down = function(knex) {
17
- return knex.schema.withSchema('dbos')
18
- .alterTable('workflow_status', function(table) {
19
- table.dropIndex('executor_id');
20
- });
15
+ exports.down = function (knex) {
16
+ return knex.schema.withSchema('dbos').alterTable('workflow_status', function (table) {
17
+ table.dropIndex('executor_id');
18
+ });
21
19
  };
@@ -1,13 +1,11 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .createTable('scheduler_state', function(table) {
4
- table.text('workflow_fn_name').notNullable();
5
- table.bigInteger('last_run_time').notNullable();
6
- table.primary(['workflow_fn_name']);
7
- })
1
+ exports.up = function (knex) {
2
+ return knex.schema.withSchema('dbos').createTable('scheduler_state', function (table) {
3
+ table.text('workflow_fn_name').notNullable();
4
+ table.bigInteger('last_run_time').notNullable();
5
+ table.primary(['workflow_fn_name']);
6
+ });
8
7
  };
9
8
 
10
- exports.down = function(knex) {
11
- return knex.schema.withSchema('dbos')
12
- .dropTableIfExists('scheduler_state');
9
+ exports.down = function (knex) {
10
+ return knex.schema.withSchema('dbos').dropTableIfExists('scheduler_state');
13
11
  };
@@ -2,22 +2,20 @@
2
2
  * @param { import("knex").Knex } knex
3
3
  * @returns { Promise<void> }
4
4
  */
5
- exports.up = function(knex) {
6
- return knex.schema.withSchema('dbos')
7
- .alterTable('workflow_status', function(table) {
8
- table.text('application_version');
9
- table.text('application_id');
10
- })
5
+ exports.up = function (knex) {
6
+ return knex.schema.withSchema('dbos').alterTable('workflow_status', function (table) {
7
+ table.text('application_version');
8
+ table.text('application_id');
9
+ });
11
10
  };
12
11
 
13
12
  /**
14
13
  * @param { import("knex").Knex } knex
15
14
  * @returns { Promise<void> }
16
15
  */
17
- exports.down = function(knex) {
18
- return knex.schema.withSchema('dbos')
19
- .alterTable('workflow_status', function(table) {
20
- table.dropColumn('application_version');
21
- table.dropColumn('application_id');
22
- })
16
+ exports.down = function (knex) {
17
+ return knex.schema.withSchema('dbos').alterTable('workflow_status', function (table) {
18
+ table.dropColumn('application_version');
19
+ table.dropColumn('application_id');
20
+ });
23
21
  };
@@ -1,18 +1,14 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .table('workflow_status', function(table) {
4
- table.string('class_name')
5
- .defaultTo(null);
1
+ exports.up = function (knex) {
2
+ return knex.schema.withSchema('dbos').table('workflow_status', function (table) {
3
+ table.string('class_name').defaultTo(null);
6
4
 
7
- table.string('config_name')
8
- .defaultTo(null);
9
- });
5
+ table.string('config_name').defaultTo(null);
6
+ });
10
7
  };
11
8
 
12
- exports.down = function(knex) {
13
- return knex.schema.withSchema('dbos')
14
- .table('workflow_status', function(table) {
15
- table.dropColumn('class_name');
16
- table.dropColumn('config_name');
17
- });
9
+ exports.down = function (knex) {
10
+ return knex.schema.withSchema('dbos').table('workflow_status', function (table) {
11
+ table.dropColumn('class_name');
12
+ table.dropColumn('config_name');
13
+ });
18
14
  };
@@ -1,15 +1,11 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .table('workflow_status', function(table) {
4
-
5
- table.bigInteger('recovery_attempts')
6
- .defaultTo(0);
7
- });
1
+ exports.up = function (knex) {
2
+ return knex.schema.withSchema('dbos').table('workflow_status', function (table) {
3
+ table.bigInteger('recovery_attempts').defaultTo(0);
4
+ });
8
5
  };
9
6
 
10
- exports.down = function(knex) {
11
- return knex.schema.withSchema('dbos')
12
- .table('workflow_status', function(table) {
13
- table.dropColumn('recovery_attempts');
14
- });
7
+ exports.down = function (knex) {
8
+ return knex.schema.withSchema('dbos').table('workflow_status', function (table) {
9
+ table.dropColumn('recovery_attempts');
10
+ });
15
11
  };
@@ -1,24 +1,33 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .table('workflow_status', function(table) {
4
- table.text('queue_name')
5
- .defaultTo(null);
6
- })
7
- .createTable('workflow_queue', function(table) {
8
- table.text('queue_name').notNullable();
9
- table.text('workflow_uuid').notNullable();
10
- table.bigInteger('created_at_epoch_ms').notNullable().defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
11
- table.bigInteger('started_at_epoch_ms');
12
- table.bigInteger('completed_at_epoch_ms');
13
- table.primary(['workflow_uuid']);
14
- table.foreign('workflow_uuid').references('workflow_uuid').inTable('dbos.workflow_status').onDelete('CASCADE').onUpdate('CASCADE');
15
- })
16
- };
17
-
18
- exports.down = function(knex) {
19
- return knex.schema.withSchema('dbos')
20
- .table('workflow_status', function(table) {
21
- table.dropColumn('queue_name');
22
- })
23
- .dropTableIfExists('workflow_queue');
1
+ exports.up = function (knex) {
2
+ return knex.schema
3
+ .withSchema('dbos')
4
+ .table('workflow_status', function (table) {
5
+ table.text('queue_name').defaultTo(null);
6
+ })
7
+ .createTable('workflow_queue', function (table) {
8
+ table.text('queue_name').notNullable();
9
+ table.text('workflow_uuid').notNullable();
10
+ table
11
+ .bigInteger('created_at_epoch_ms')
12
+ .notNullable()
13
+ .defaultTo(knex.raw('(EXTRACT(EPOCH FROM now())*1000)::bigint'));
14
+ table.bigInteger('started_at_epoch_ms');
15
+ table.bigInteger('completed_at_epoch_ms');
16
+ table.primary(['workflow_uuid']);
17
+ table
18
+ .foreign('workflow_uuid')
19
+ .references('workflow_uuid')
20
+ .inTable('dbos.workflow_status')
21
+ .onDelete('CASCADE')
22
+ .onUpdate('CASCADE');
23
+ });
24
+ };
25
+
26
+ exports.down = function (knex) {
27
+ return knex.schema
28
+ .withSchema('dbos')
29
+ .table('workflow_status', function (table) {
30
+ table.dropColumn('queue_name');
31
+ })
32
+ .dropTableIfExists('workflow_queue');
24
33
  };
@@ -1,17 +1,15 @@
1
- exports.up = function(knex) {
2
- return knex.schema.withSchema('dbos')
3
- .createTable('event_dispatch_kv', function(table) {
4
- table.text('service_name').notNullable();
5
- table.text('workflow_fn_name').notNullable();
6
- table.text('key').notNullable();
7
- table.text('value');
8
- table.decimal('update_seq', 38, 0);
9
- table.decimal('update_time', 38, 15);
10
- table.primary(['service_name','workflow_fn_name','key']);
11
- })
1
+ exports.up = function (knex) {
2
+ return knex.schema.withSchema('dbos').createTable('event_dispatch_kv', function (table) {
3
+ table.text('service_name').notNullable();
4
+ table.text('workflow_fn_name').notNullable();
5
+ table.text('key').notNullable();
6
+ table.text('value');
7
+ table.decimal('update_seq', 38, 0);
8
+ table.decimal('update_time', 38, 15);
9
+ table.primary(['service_name', 'workflow_fn_name', 'key']);
10
+ });
12
11
  };
13
12
 
14
- exports.down = function(knex) {
15
- return knex.schema.withSchema('dbos')
16
- .dropTableIfExists('event_dispatch_kv');
13
+ exports.down = function (knex) {
14
+ return knex.schema.withSchema('dbos').dropTableIfExists('event_dispatch_kv');
17
15
  };