@dbos-inc/dbos-sdk 0.8.45-preview.g56ba028de5 → 0.8.46-preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. package/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
  2. package/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
  3. package/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
  4. package/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
  5. package/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
  6. package/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
  7. package/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
  8. package/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
  9. package/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
  10. package/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
  11. package/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
  12. package/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
  13. package/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
  14. package/dist/packages/dbos-cloud/applications/register-app.js +1 -2
  15. package/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
  16. package/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
  17. package/dist/packages/dbos-cloud/applications/update-app.js +1 -2
  18. package/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
  19. package/dist/packages/dbos-cloud/cli.js +0 -12
  20. package/dist/packages/dbos-cloud/cli.js.map +1 -1
  21. package/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
  22. package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
  23. package/dist/packages/dbos-cloud/cloudutils.js +44 -3
  24. package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
  25. package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
  26. package/dist/packages/dbos-cloud/login.js +3 -4
  27. package/dist/packages/dbos-cloud/login.js.map +1 -1
  28. package/dist/packages/dbos-cloud/register.d.ts.map +1 -1
  29. package/dist/packages/dbos-cloud/register.js +1 -2
  30. package/dist/packages/dbos-cloud/register.js.map +1 -1
  31. package/dist/packages/dbos-cloud/userdb.d.ts +0 -2
  32. package/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
  33. package/dist/packages/dbos-cloud/userdb.js +4 -177
  34. package/dist/packages/dbos-cloud/userdb.js.map +1 -1
  35. package/dist/src/context.d.ts +1 -0
  36. package/dist/src/context.d.ts.map +1 -1
  37. package/dist/src/dbos-runtime/cli.d.ts.map +1 -1
  38. package/dist/src/dbos-runtime/cli.js +14 -0
  39. package/dist/src/dbos-runtime/cli.js.map +1 -1
  40. package/dist/src/dbos-runtime/migrate.d.ts +3 -0
  41. package/dist/src/dbos-runtime/migrate.d.ts.map +1 -0
  42. package/dist/src/dbos-runtime/migrate.js +175 -0
  43. package/dist/src/dbos-runtime/migrate.js.map +1 -0
  44. package/dist/src/httpServer/server.d.ts +2 -1
  45. package/dist/src/httpServer/server.d.ts.map +1 -1
  46. package/dist/src/system_database.d.ts +2 -0
  47. package/dist/src/system_database.d.ts.map +1 -1
  48. package/dist/src/system_database.js +26 -11
  49. package/dist/src/system_database.js.map +1 -1
  50. package/dist/src/testing/testing_runtime.d.ts +2 -1
  51. package/dist/src/testing/testing_runtime.d.ts.map +1 -1
  52. package/dist/src/utils.d.ts +1 -1
  53. package/dist/src/utils.d.ts.map +1 -1
  54. package/dist/src/utils.js +20 -4
  55. package/dist/src/utils.js.map +1 -1
  56. package/dist/tsconfig.build.tsbuildinfo +1 -1
  57. package/examples/hello/start_postgres_docker.sh +1 -1
  58. package/migrations/20240123182943_schema.js +8 -0
  59. package/migrations/20240123183021_tables.js +48 -0
  60. package/migrations/20240123183025_indexes.js +14 -0
  61. package/migrations/20240123183030_triggers.js +39 -0
  62. package/package.json +1 -1
  63. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
  64. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
  65. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
  66. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
  67. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
  68. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
  69. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
  70. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
  71. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
  72. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
  73. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
  74. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
  75. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
  76. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js +1 -2
  77. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
  78. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
  79. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js +1 -2
  80. package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
  81. package/packages/dbos-cloud/dist/packages/dbos-cloud/cli.js +0 -12
  82. package/packages/dbos-cloud/dist/packages/dbos-cloud/cli.js.map +1 -1
  83. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
  84. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
  85. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js +44 -3
  86. package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
  87. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.d.ts.map +1 -1
  88. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js +3 -4
  89. package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js.map +1 -1
  90. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.d.ts.map +1 -1
  91. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js +1 -2
  92. package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js.map +1 -1
  93. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts +0 -2
  94. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
  95. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js +4 -177
  96. package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js.map +1 -1
  97. package/packages/dbos-cloud/dist/src/utils.d.ts +1 -1
  98. package/packages/dbos-cloud/dist/src/utils.d.ts.map +1 -1
  99. package/packages/dbos-cloud/dist/src/utils.js +20 -4
  100. package/packages/dbos-cloud/dist/src/utils.js.map +1 -1
  101. package/packages/dbos-cloud/package.json +1 -1
  102. package/packages/dbos-openapi/package.json +1 -1
  103. package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts +0 -34
  104. package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts.map +0 -1
  105. package/packages/dbos-cloud/dist/schemas/system_db_schema.js +0 -77
  106. package/packages/dbos-cloud/dist/schemas/system_db_schema.js.map +0 -1
  107. package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts +0 -11
  108. package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts.map +0 -1
  109. package/packages/dbos-cloud/dist/schemas/user_db_schema.js +0 -16
  110. package/packages/dbos-cloud/dist/schemas/user_db_schema.js.map +0 -1
  111. package/packages/dbos-cloud/dist/src/communicator.d.ts +0 -25
  112. package/packages/dbos-cloud/dist/src/communicator.d.ts.map +0 -1
  113. package/packages/dbos-cloud/dist/src/communicator.js +0 -26
  114. package/packages/dbos-cloud/dist/src/communicator.js.map +0 -1
  115. package/packages/dbos-cloud/dist/src/context.d.ts +0 -64
  116. package/packages/dbos-cloud/dist/src/context.d.ts.map +0 -1
  117. package/packages/dbos-cloud/dist/src/context.js +0 -96
  118. package/packages/dbos-cloud/dist/src/context.js.map +0 -1
  119. package/packages/dbos-cloud/dist/src/data_validation.d.ts +0 -3
  120. package/packages/dbos-cloud/dist/src/data_validation.d.ts.map +0 -1
  121. package/packages/dbos-cloud/dist/src/data_validation.js +0 -168
  122. package/packages/dbos-cloud/dist/src/data_validation.js.map +0 -1
  123. package/packages/dbos-cloud/dist/src/dbos-executor.d.ts +0 -102
  124. package/packages/dbos-cloud/dist/src/dbos-executor.d.ts.map +0 -1
  125. package/packages/dbos-cloud/dist/src/dbos-executor.js +0 -631
  126. package/packages/dbos-cloud/dist/src/dbos-executor.js.map +0 -1
  127. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts +0 -3
  128. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts.map +0 -1
  129. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js +0 -13
  130. package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js.map +0 -1
  131. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts +0 -8
  132. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts.map +0 -1
  133. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js +0 -47
  134. package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js.map +0 -1
  135. package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts +0 -29
  136. package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts.map +0 -1
  137. package/packages/dbos-cloud/dist/src/dbos-runtime/config.js +0 -111
  138. package/packages/dbos-cloud/dist/src/dbos-runtime/config.js.map +0 -1
  139. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts +0 -4
  140. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts.map +0 -1
  141. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js +0 -21
  142. package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js.map +0 -1
  143. package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts +0 -7
  144. package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts.map +0 -1
  145. package/packages/dbos-cloud/dist/src/dbos-runtime/init.js +0 -51
  146. package/packages/dbos-cloud/dist/src/dbos-runtime/init.js.map +0 -1
  147. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts +0 -28
  148. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts.map +0 -1
  149. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js +0 -95
  150. package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js.map +0 -1
  151. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts +0 -38
  152. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts.map +0 -1
  153. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js +0 -211
  154. package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js.map +0 -1
  155. package/packages/dbos-cloud/dist/src/decorators.d.ts +0 -118
  156. package/packages/dbos-cloud/dist/src/decorators.d.ts.map +0 -1
  157. package/packages/dbos-cloud/dist/src/decorators.js +0 -467
  158. package/packages/dbos-cloud/dist/src/decorators.js.map +0 -1
  159. package/packages/dbos-cloud/dist/src/error.d.ts +0 -47
  160. package/packages/dbos-cloud/dist/src/error.d.ts.map +0 -1
  161. package/packages/dbos-cloud/dist/src/error.js +0 -171
  162. package/packages/dbos-cloud/dist/src/error.js.map +0 -1
  163. package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts +0 -54
  164. package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts.map +0 -1
  165. package/packages/dbos-cloud/dist/src/httpServer/handler.js +0 -175
  166. package/packages/dbos-cloud/dist/src/httpServer/handler.js.map +0 -1
  167. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts +0 -11
  168. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts.map +0 -1
  169. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js +0 -19
  170. package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js.map +0 -1
  171. package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts +0 -56
  172. package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts.map +0 -1
  173. package/packages/dbos-cloud/dist/src/httpServer/middleware.js +0 -57
  174. package/packages/dbos-cloud/dist/src/httpServer/middleware.js.map +0 -1
  175. package/packages/dbos-cloud/dist/src/httpServer/server.d.ts +0 -45
  176. package/packages/dbos-cloud/dist/src/httpServer/server.d.ts.map +0 -1
  177. package/packages/dbos-cloud/dist/src/httpServer/server.js +0 -253
  178. package/packages/dbos-cloud/dist/src/httpServer/server.js.map +0 -1
  179. package/packages/dbos-cloud/dist/src/system_database.d.ts +0 -89
  180. package/packages/dbos-cloud/dist/src/system_database.d.ts.map +0 -1
  181. package/packages/dbos-cloud/dist/src/system_database.js +0 -447
  182. package/packages/dbos-cloud/dist/src/system_database.js.map +0 -1
  183. package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts +0 -16
  184. package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts.map +0 -1
  185. package/packages/dbos-cloud/dist/src/telemetry/collector.js +0 -65
  186. package/packages/dbos-cloud/dist/src/telemetry/collector.js.map +0 -1
  187. package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts +0 -15
  188. package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts.map +0 -1
  189. package/packages/dbos-cloud/dist/src/telemetry/exporters.js +0 -59
  190. package/packages/dbos-cloud/dist/src/telemetry/exporters.js.map +0 -1
  191. package/packages/dbos-cloud/dist/src/telemetry/index.d.ts +0 -11
  192. package/packages/dbos-cloud/dist/src/telemetry/index.d.ts.map +0 -1
  193. package/packages/dbos-cloud/dist/src/telemetry/index.js +0 -19
  194. package/packages/dbos-cloud/dist/src/telemetry/index.js.map +0 -1
  195. package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts +0 -47
  196. package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts.map +0 -1
  197. package/packages/dbos-cloud/dist/src/telemetry/logs.js +0 -195
  198. package/packages/dbos-cloud/dist/src/telemetry/logs.js.map +0 -1
  199. package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts +0 -14
  200. package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts.map +0 -1
  201. package/packages/dbos-cloud/dist/src/telemetry/traces.js +0 -52
  202. package/packages/dbos-cloud/dist/src/telemetry/traces.js.map +0 -1
  203. package/packages/dbos-cloud/dist/src/transaction.d.ts +0 -29
  204. package/packages/dbos-cloud/dist/src/transaction.d.ts.map +0 -1
  205. package/packages/dbos-cloud/dist/src/transaction.js +0 -27
  206. package/packages/dbos-cloud/dist/src/transaction.js.map +0 -1
  207. package/packages/dbos-cloud/dist/src/user_database.d.ts +0 -132
  208. package/packages/dbos-cloud/dist/src/user_database.d.ts.map +0 -1
  209. package/packages/dbos-cloud/dist/src/user_database.js +0 -332
  210. package/packages/dbos-cloud/dist/src/user_database.js.map +0 -1
  211. package/packages/dbos-cloud/dist/src/workflow.d.ts +0 -195
  212. package/packages/dbos-cloud/dist/src/workflow.d.ts.map +0 -1
  213. package/packages/dbos-cloud/dist/src/workflow.js +0 -498
  214. package/packages/dbos-cloud/dist/src/workflow.js.map +0 -1
@@ -3,19 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getUserDBInfo = exports.rollbackMigration = exports.migrate = exports.getUserDb = exports.deleteUserDb = exports.createUserDb = void 0;
6
+ exports.getUserDBInfo = exports.getUserDb = exports.deleteUserDb = exports.createUserDb = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const logs_1 = require("../../src/telemetry/logs");
9
8
  const cloudutils_1 = require("./cloudutils");
10
9
  const utils_1 = require("../../src/utils");
11
- const config_1 = require("../../src/dbos-runtime/config");
12
- const child_process_1 = require("child_process");
13
- const user_database_1 = require("../../src/user_database");
14
- const pg_1 = require("pg");
15
- const system_db_schema_1 = require("../../schemas/system_db_schema");
16
- const user_db_schema_1 = require("../../schemas/user_db_schema");
17
10
  async function createUserDb(host, dbName, adminName, adminPassword, sync) {
18
- const logger = new logs_1.GlobalLogger();
11
+ const logger = (0, cloudutils_1.getLogger)();
19
12
  const userCredentials = (0, cloudutils_1.getCloudCredentials)();
20
13
  const bearerToken = "Bearer " + userCredentials.token;
21
14
  try {
@@ -47,7 +40,7 @@ async function createUserDb(host, dbName, adminName, adminPassword, sync) {
47
40
  }
48
41
  exports.createUserDb = createUserDb;
49
42
  async function deleteUserDb(host, dbName) {
50
- const logger = new logs_1.GlobalLogger();
43
+ const logger = (0, cloudutils_1.getLogger)();
51
44
  const userCredentials = (0, cloudutils_1.getCloudCredentials)();
52
45
  const bearerToken = "Bearer " + userCredentials.token;
53
46
  try {
@@ -70,7 +63,7 @@ async function deleteUserDb(host, dbName) {
70
63
  }
71
64
  exports.deleteUserDb = deleteUserDb;
72
65
  async function getUserDb(host, dbName) {
73
- const logger = new logs_1.GlobalLogger();
66
+ const logger = (0, cloudutils_1.getLogger)();
74
67
  try {
75
68
  const userDBInfo = await getUserDBInfo(host, dbName);
76
69
  logger.info(userDBInfo);
@@ -85,118 +78,6 @@ async function getUserDb(host, dbName) {
85
78
  }
86
79
  }
87
80
  exports.getUserDb = getUserDb;
88
- async function migrate() {
89
- const logger = new logs_1.GlobalLogger();
90
- // Read the configuration YAML file
91
- const configFile = (0, config_1.loadConfigFile)(config_1.dbosConfigFilePath);
92
- if (!configFile) {
93
- logger.error(`Failed to parse ${config_1.dbosConfigFilePath}`);
94
- return 1;
95
- }
96
- const userDBName = configFile.database.user_database;
97
- logger.info(`Creating database ${userDBName} if it does not already exist`);
98
- const createDB = `createdb -h ${configFile.database.hostname} -p ${configFile.database.port} ${userDBName} -U ${configFile.database.username} -ew ${userDBName}`;
99
- try {
100
- process.env.PGPASSWORD = configFile.database.password;
101
- const createDBOutput = (0, child_process_1.execSync)(createDB, { env: process.env }).toString();
102
- if (createDBOutput.includes(`database "${userDBName}" already exists`)) {
103
- logger.info(`Database ${userDBName} already exists`);
104
- }
105
- else {
106
- logger.info(createDBOutput);
107
- }
108
- }
109
- catch (e) {
110
- if (e instanceof Error) {
111
- if (e.message.includes(`database "${userDBName}" already exists`)) {
112
- logger.info(`Database ${userDBName} already exists`);
113
- }
114
- else {
115
- logger.error(`Error creating database: ${e.message}`);
116
- return 1;
117
- }
118
- }
119
- else {
120
- logger.error(e);
121
- return 1;
122
- }
123
- }
124
- const dbType = configFile.database.user_dbclient || user_database_1.UserDatabaseName.KNEX;
125
- const migrationScript = `node_modules/.bin/${dbType}`;
126
- const migrationCommands = configFile.database.migrate;
127
- try {
128
- migrationCommands?.forEach((cmd) => {
129
- const command = `node ${migrationScript} ${cmd}`;
130
- logger.info(`Executing migration command: ${command}`);
131
- const migrateCommandOutput = (0, child_process_1.execSync)(command).toString();
132
- logger.info(migrateCommandOutput);
133
- });
134
- }
135
- catch (e) {
136
- logger.error("Error running migration");
137
- if (e instanceof Error) {
138
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
139
- const stderr = e.stderr;
140
- if (stderr && Buffer.isBuffer(stderr) && stderr.length > 0) {
141
- logger.error(`Standard Error: ${stderr.toString().trim()}`);
142
- }
143
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
144
- const stdout = e.stdout;
145
- if (stdout && Buffer.isBuffer(stdout) && stdout.length > 0) {
146
- logger.error(`Standard Output: ${stdout.toString().trim()}`);
147
- }
148
- if (e.message) {
149
- logger.error(e.message);
150
- }
151
- }
152
- else {
153
- logger.error(e);
154
- }
155
- return 1;
156
- }
157
- logger.info("Creating DBOS tables and system database.");
158
- try {
159
- await createDBOSTables(configFile);
160
- }
161
- catch (e) {
162
- if (e instanceof Error) {
163
- logger.error(`Error creating DBOS system database: ${e.message}`);
164
- }
165
- else {
166
- logger.error(e);
167
- }
168
- return 1;
169
- }
170
- return 0;
171
- }
172
- exports.migrate = migrate;
173
- function rollbackMigration() {
174
- const logger = new logs_1.GlobalLogger();
175
- // read the yaml file
176
- const configFile = (0, config_1.loadConfigFile)(config_1.dbosConfigFilePath);
177
- if (!configFile) {
178
- logger.error(`failed to parse ${config_1.dbosConfigFilePath}`);
179
- return 1;
180
- }
181
- let dbType = configFile.database.user_dbclient;
182
- if (dbType == undefined) {
183
- dbType = "knex";
184
- }
185
- const rollbackcommands = configFile.database.rollback;
186
- try {
187
- rollbackcommands?.forEach((cmd) => {
188
- const command = "npx " + dbType + " " + cmd;
189
- logger.info("Executing " + command);
190
- (0, child_process_1.execSync)(command);
191
- });
192
- }
193
- catch (e) {
194
- logger.error("Error rolling back migration. ");
195
- return 1;
196
- }
197
- return 0;
198
- }
199
- exports.rollbackMigration = rollbackMigration;
200
81
  async function getUserDBInfo(host, dbName) {
201
82
  const userCredentials = (0, cloudutils_1.getCloudCredentials)();
202
83
  const bearerToken = "Bearer " + userCredentials.token;
@@ -209,58 +90,4 @@ async function getUserDBInfo(host, dbName) {
209
90
  return res.data;
210
91
  }
211
92
  exports.getUserDBInfo = getUserDBInfo;
212
- // Create DBOS system DB and tables.
213
- // TODO: replace this with knex to manage schema.
214
- async function createDBOSTables(configFile) {
215
- const logger = new logs_1.GlobalLogger();
216
- const userPoolConfig = {
217
- host: configFile.database.hostname,
218
- port: configFile.database.port,
219
- user: configFile.database.username,
220
- password: configFile.database.password,
221
- connectionTimeoutMillis: configFile.database.connectionTimeoutMillis || 3000,
222
- database: configFile.database.user_database,
223
- };
224
- if (configFile.database.ssl_ca) {
225
- userPoolConfig.ssl = { ca: [(0, utils_1.readFileSync)(configFile.database.ssl_ca)], rejectUnauthorized: true };
226
- }
227
- const systemPoolConfig = { ...userPoolConfig };
228
- systemPoolConfig.database = `${userPoolConfig.database}_dbos_sys`;
229
- const pgUserClient = new pg_1.Client(userPoolConfig);
230
- await pgUserClient.connect();
231
- // Create DBOS table/schema in user DB.
232
- const schemaExists = await pgUserClient.query(`SELECT EXISTS (SELECT FROM information_schema.schemata WHERE schema_name = 'dbos')`);
233
- if (!schemaExists.rows[0].exists) {
234
- await pgUserClient.query(user_db_schema_1.createUserDBSchema);
235
- await pgUserClient.query(user_db_schema_1.userDBSchema);
236
- }
237
- // Create the DBOS system database.
238
- const dbExists = await pgUserClient.query(`SELECT EXISTS (SELECT FROM pg_database WHERE datname = '${systemPoolConfig.database}')`);
239
- if (!dbExists.rows[0].exists) {
240
- await pgUserClient.query(`CREATE DATABASE ${systemPoolConfig.database}`);
241
- }
242
- // Load the DBOS system schema.
243
- const pgSystemClient = new pg_1.Client(systemPoolConfig);
244
- await pgSystemClient.connect();
245
- try {
246
- const tableExists = await pgSystemClient.query(`SELECT EXISTS (SELECT FROM information_schema.schemata WHERE schema_name = 'dbos')`);
247
- if (!tableExists.rows[0].exists) {
248
- await pgSystemClient.query(system_db_schema_1.systemDBSchema);
249
- }
250
- }
251
- catch (e) {
252
- const tableExists = await pgSystemClient.query(`SELECT EXISTS (SELECT FROM information_schema.tables WHERE table_schema = 'dbos' AND table_name = 'operation_outputs')`);
253
- if (tableExists.rows[0].exists) {
254
- // If the table has been created by someone else. Ignore the error.
255
- logger.warn(`System tables creation failed, may conflict with concurrent tasks: ${e.message}`);
256
- }
257
- else {
258
- throw e;
259
- }
260
- }
261
- finally {
262
- await pgSystemClient.end();
263
- await pgUserClient.end();
264
- }
265
- }
266
93
  //# sourceMappingURL=userdb.js.map
@@ -1 +1 @@
1
- {"version":3,"file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AAG,CAAC,IAAsB,CAAC;AACpC,CAAC;AAZD,sCAYC"}
@@ -2,5 +2,5 @@
2
2
  export declare function readFileSync(path: string, encoding?: BufferEncoding): string | Buffer;
3
3
  export declare const sleep: (ms: number) => Promise<unknown>;
4
4
  export type ValuesOf<T> = T[keyof T];
5
- export declare function createDirectory(path: string): string | undefined;
5
+ export declare function findPackageRoot(start: string | string[]): string;
6
6
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":";AAQA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,GAAG,MAAM,CAa7F;AAED,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAA0C,CAAC;AAE3E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGrC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":";AASA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,GAAG,MAAM,CAa7F;AAED,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAA0C,CAAC;AAE3E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGrC,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAoBhE"}
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createDirectory = exports.sleep = exports.readFileSync = void 0;
6
+ exports.findPackageRoot = exports.sleep = exports.readFileSync = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
8
9
  /*
9
10
  * Use the node.js `fs` module to read the content of a file
10
11
  * Handles cases where:
@@ -28,8 +29,23 @@ function readFileSync(path, encoding = "utf8") {
28
29
  exports.readFileSync = readFileSync;
29
30
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
30
31
  exports.sleep = sleep;
31
- function createDirectory(path) {
32
- return fs_1.default.mkdirSync(path, { recursive: true });
32
+ // Adapated and translated from from: https://github.com/junosuarez/find-root
33
+ function findPackageRoot(start) {
34
+ if (typeof start === 'string') {
35
+ if (!start.endsWith(path_1.default.sep)) {
36
+ start += path_1.default.sep;
37
+ }
38
+ start = start.split(path_1.default.sep);
39
+ }
40
+ if (start.length === 0) {
41
+ throw new Error('package.json not found in path');
42
+ }
43
+ start.pop();
44
+ const dir = start.join(path_1.default.sep);
45
+ if (fs_1.default.existsSync(path_1.default.join(dir, 'package.json'))) {
46
+ return dir;
47
+ }
48
+ return findPackageRoot(start);
33
49
  }
34
- exports.createDirectory = createDirectory;
50
+ exports.findPackageRoot = findPackageRoot;
35
51
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB;;;;;IAKI;AACJ,SAAgB,YAAY,CAAC,IAAY,EAAE,WAA2B,MAAM;IAC1E,wBAAwB;IACxB,YAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAmC,EAAE,KAAe,EAAE,EAAE;QACrE,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;QACxE,CAAC;aAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CA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,QAAQ,EAAE,CAAE,CAAC;IACjE,OAAO,WAAW,CAAC;AACrB,CAAC;AAbD,oCAaC;AAEM,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAA9D,QAAA,KAAK,SAAyD;AAI3E,6EAA6E;AAC7E,SAAgB,eAAe,CAAC,KAAwB;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,KAAK,IAAI,cAAI,CAAC,GAAG,CAAC;QACtB,CAAC;QACD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,GAAG,EAAE,CAAC;IACZ,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC;IAEjC,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;QAChD,OAAO,GAAG,CAAC;IACf,CAAC;IAED,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AApBD,0CAoBC"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbos-inc/dbos-cloud",
3
- "version": "0.8.45-preview.g56ba028de5",
3
+ "version": "0.8.46-preview",
4
4
  "description": "Tool for performing application deployment to DBOS cloud",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbos-inc/dbos-openapi",
3
- "version": "0.8.45-preview.g56ba028de5",
3
+ "version": "0.8.46-preview",
4
4
  "description": "Tool for integrating DBOS functions via OpenAPI",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,34 +0,0 @@
1
- export interface workflow_status {
2
- workflow_uuid: string;
3
- status: string;
4
- name: string;
5
- authenticated_user: string;
6
- output: string;
7
- error: string;
8
- assumed_role: string;
9
- authenticated_roles: string;
10
- request: string;
11
- executor_id: string;
12
- }
13
- export interface notifications {
14
- destination_uuid: string;
15
- topic: string;
16
- message: string;
17
- }
18
- export interface workflow_events {
19
- workflow_uuid: string;
20
- key: string;
21
- value: string;
22
- }
23
- export interface operation_outputs {
24
- workflow_uuid: string;
25
- function_id: number;
26
- output: string;
27
- error: string;
28
- }
29
- export interface workflow_inputs {
30
- workflow_uuid: string;
31
- inputs: string;
32
- }
33
- export declare const systemDBSchema = "\n CREATE SCHEMA IF NOT EXISTS dbos;\n\n CREATE TABLE IF NOT EXISTS dbos.operation_outputs (\n workflow_uuid TEXT NOT NULL,\n function_id INT NOT NULL,\n output TEXT,\n error TEXT,\n PRIMARY KEY (workflow_uuid, function_id)\n );\n\n CREATE TABLE IF NOT EXISTS dbos.workflow_inputs (\n workflow_uuid TEXT PRIMARY KEY NOT NULL,\n inputs TEXT NOT NULL\n );\n\n CREATE TABLE IF NOT EXISTS dbos.workflow_status (\n workflow_uuid TEXT PRIMARY KEY,\n status TEXT,\n name TEXT,\n authenticated_user TEXT,\n assumed_role TEXT,\n authenticated_roles TEXT,\n request TEXT,\n output TEXT,\n error TEXT,\n executor_id TEXT\n );\n\n CREATE TABLE IF NOT EXISTS dbos.notifications (\n destination_uuid TEXT NOT NULL,\n topic TEXT,\n message TEXT NOT NULL,\n created_at_epoch_ms BIGINT NOT NULL DEFAULT (EXTRACT(EPOCH FROM now())*1000)::bigint\n );\n\n CREATE TABLE IF NOT EXISTS dbos.workflow_events (\n workflow_uuid TEXT NOT NULL,\n key TEXT NOT NULL,\n value TEXT NOT NULL,\n PRIMARY KEY (workflow_uuid, key)\n );\n\n CREATE INDEX IF NOT EXISTS idx_workflow_topic ON dbos.notifications (destination_uuid, topic);\n\n CREATE OR REPLACE FUNCTION dbos.notifications_function() RETURNS TRIGGER AS $$\n DECLARE\n payload text := NEW.destination_uuid || '::' || NEW.topic;\n BEGIN\n -- Publish a notification for all keys\n PERFORM pg_notify('dbos_notifications_channel', payload);\n RETURN NEW;\n END;\n $$ LANGUAGE plpgsql;\n\n CREATE OR REPLACE TRIGGER dbos_notifications_trigger\n AFTER INSERT ON dbos.notifications\n FOR EACH ROW EXECUTE FUNCTION dbos.notifications_function();\n\n CREATE OR REPLACE FUNCTION dbos.workflow_events_function() RETURNS TRIGGER AS $$\n DECLARE\n payload text := NEW.workflow_uuid || '::' || NEW.key;\n BEGIN\n -- Publish a notification for all keys\n PERFORM pg_notify('dbos_workflow_events_channel', payload);\n RETURN NEW;\n END;\n $$ LANGUAGE plpgsql;\n\n CREATE OR REPLACE TRIGGER dbos_workflow_events_trigger\n AFTER INSERT ON dbos.workflow_events\n FOR EACH ROW EXECUTE FUNCTION dbos.workflow_events_function();\n";
34
- //# sourceMappingURL=system_db_schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"system_db_schema.d.ts","sourceRoot":"","sources":["../../../../schemas/system_db_schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,orEAwE1B,CAAC"}
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.systemDBSchema = void 0;
4
- exports.systemDBSchema = `
5
- CREATE SCHEMA IF NOT EXISTS dbos;
6
-
7
- CREATE TABLE IF NOT EXISTS dbos.operation_outputs (
8
- workflow_uuid TEXT NOT NULL,
9
- function_id INT NOT NULL,
10
- output TEXT,
11
- error TEXT,
12
- PRIMARY KEY (workflow_uuid, function_id)
13
- );
14
-
15
- CREATE TABLE IF NOT EXISTS dbos.workflow_inputs (
16
- workflow_uuid TEXT PRIMARY KEY NOT NULL,
17
- inputs TEXT NOT NULL
18
- );
19
-
20
- CREATE TABLE IF NOT EXISTS dbos.workflow_status (
21
- workflow_uuid TEXT PRIMARY KEY,
22
- status TEXT,
23
- name TEXT,
24
- authenticated_user TEXT,
25
- assumed_role TEXT,
26
- authenticated_roles TEXT,
27
- request TEXT,
28
- output TEXT,
29
- error TEXT,
30
- executor_id TEXT
31
- );
32
-
33
- CREATE TABLE IF NOT EXISTS dbos.notifications (
34
- destination_uuid TEXT NOT NULL,
35
- topic TEXT,
36
- message TEXT NOT NULL,
37
- created_at_epoch_ms BIGINT NOT NULL DEFAULT (EXTRACT(EPOCH FROM now())*1000)::bigint
38
- );
39
-
40
- CREATE TABLE IF NOT EXISTS dbos.workflow_events (
41
- workflow_uuid TEXT NOT NULL,
42
- key TEXT NOT NULL,
43
- value TEXT NOT NULL,
44
- PRIMARY KEY (workflow_uuid, key)
45
- );
46
-
47
- CREATE INDEX IF NOT EXISTS idx_workflow_topic ON dbos.notifications (destination_uuid, topic);
48
-
49
- CREATE OR REPLACE FUNCTION dbos.notifications_function() RETURNS TRIGGER AS $$
50
- DECLARE
51
- payload text := NEW.destination_uuid || '::' || NEW.topic;
52
- BEGIN
53
- -- Publish a notification for all keys
54
- PERFORM pg_notify('dbos_notifications_channel', payload);
55
- RETURN NEW;
56
- END;
57
- $$ LANGUAGE plpgsql;
58
-
59
- CREATE OR REPLACE TRIGGER dbos_notifications_trigger
60
- AFTER INSERT ON dbos.notifications
61
- FOR EACH ROW EXECUTE FUNCTION dbos.notifications_function();
62
-
63
- CREATE OR REPLACE FUNCTION dbos.workflow_events_function() RETURNS TRIGGER AS $$
64
- DECLARE
65
- payload text := NEW.workflow_uuid || '::' || NEW.key;
66
- BEGIN
67
- -- Publish a notification for all keys
68
- PERFORM pg_notify('dbos_workflow_events_channel', payload);
69
- RETURN NEW;
70
- END;
71
- $$ LANGUAGE plpgsql;
72
-
73
- CREATE OR REPLACE TRIGGER dbos_workflow_events_trigger
74
- AFTER INSERT ON dbos.workflow_events
75
- FOR EACH ROW EXECUTE FUNCTION dbos.workflow_events_function();
76
- `;
77
- //# sourceMappingURL=system_db_schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"system_db_schema.js","sourceRoot":"","sources":["../../../../schemas/system_db_schema.ts"],"names":[],"mappings":";;;AAqCa,QAAA,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwE7B,CAAC"}
@@ -1,11 +0,0 @@
1
- export interface transaction_outputs {
2
- workflow_uuid: string;
3
- function_id: number;
4
- output: string;
5
- error: string;
6
- txn_id: string;
7
- txn_snapshot: string;
8
- }
9
- export declare const createUserDBSchema = "CREATE SCHEMA IF NOT EXISTS dbos;";
10
- export declare const userDBSchema = "\n CREATE TABLE IF NOT EXISTS dbos.transaction_outputs (\n workflow_uuid TEXT NOT NULL,\n function_id INT NOT NULL,\n output TEXT,\n error TEXT,\n txn_id TEXT,\n txn_snapshot TEXT NOT NULL,\n PRIMARY KEY (workflow_uuid, function_id)\n );\n";
11
- //# sourceMappingURL=user_db_schema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user_db_schema.d.ts","sourceRoot":"","sources":["../../../../schemas/user_db_schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AAEtE,eAAO,MAAM,YAAY,2QAUxB,CAAC"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.userDBSchema = exports.createUserDBSchema = void 0;
4
- exports.createUserDBSchema = `CREATE SCHEMA IF NOT EXISTS dbos;`;
5
- exports.userDBSchema = `
6
- CREATE TABLE IF NOT EXISTS dbos.transaction_outputs (
7
- workflow_uuid TEXT NOT NULL,
8
- function_id INT NOT NULL,
9
- output TEXT,
10
- error TEXT,
11
- txn_id TEXT,
12
- txn_snapshot TEXT NOT NULL,
13
- PRIMARY KEY (workflow_uuid, function_id)
14
- );
15
- `;
16
- //# sourceMappingURL=user_db_schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user_db_schema.js","sourceRoot":"","sources":["../../../../schemas/user_db_schema.ts"],"names":[],"mappings":";;;AASa,QAAA,kBAAkB,GAAG,mCAAmC,CAAC;AAEzD,QAAA,YAAY,GAAG;;;;;;;;;;CAU3B,CAAC"}
@@ -1,25 +0,0 @@
1
- import { Span } from "@opentelemetry/sdk-trace-base";
2
- import { GlobalLogger as Logger } from "./telemetry/logs";
3
- import { WorkflowContextImpl } from "./workflow";
4
- import { DBOSContext, DBOSContextImpl } from "./context";
5
- import { WorkflowContextDebug } from "./debugger/debug_workflow";
6
- export type Communicator<T extends any[], R> = (ctxt: CommunicatorContext, ...args: T) => Promise<R>;
7
- export interface CommunicatorConfig {
8
- retriesAllowed?: boolean;
9
- intervalSeconds?: number;
10
- maxAttempts?: number;
11
- backoffRate?: number;
12
- }
13
- export interface CommunicatorContext extends DBOSContext {
14
- readonly retriesAllowed: boolean;
15
- readonly maxAttempts: number;
16
- }
17
- export declare class CommunicatorContextImpl extends DBOSContextImpl implements CommunicatorContext {
18
- readonly functionID: number;
19
- readonly retriesAllowed: boolean;
20
- readonly intervalSeconds: number;
21
- readonly maxAttempts: number;
22
- readonly backoffRate: number;
23
- constructor(workflowContext: WorkflowContextImpl | WorkflowContextDebug, functionID: number, span: Span, logger: Logger, params: CommunicatorConfig, commName: string);
24
- }
25
- //# sourceMappingURL=communicator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"communicator.d.ts","sourceRoot":"","sources":["../../../../src/communicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,mBAAmB,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAErG,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IAEtD,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,uBAAwB,SAAQ,eAAgB,YAAW,mBAAmB;IACzF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAGjB,eAAe,EAAE,mBAAmB,GAAG,oBAAoB,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM;CAYtK"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommunicatorContextImpl = void 0;
4
- const context_1 = require("./context");
5
- class CommunicatorContextImpl extends context_1.DBOSContextImpl {
6
- functionID;
7
- retriesAllowed;
8
- intervalSeconds;
9
- maxAttempts;
10
- backoffRate;
11
- // TODO: Validate the parameters.
12
- constructor(workflowContext, functionID, span, logger, params, commName) {
13
- super(commName, span, logger, workflowContext);
14
- this.functionID = functionID;
15
- this.retriesAllowed = params.retriesAllowed ?? true;
16
- this.intervalSeconds = params.intervalSeconds ?? 1;
17
- this.maxAttempts = params.maxAttempts ?? 3;
18
- this.backoffRate = params.backoffRate ?? 2;
19
- if (workflowContext.applicationConfig) {
20
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
21
- this.applicationConfig = workflowContext.applicationConfig;
22
- }
23
- }
24
- }
25
- exports.CommunicatorContextImpl = CommunicatorContextImpl;
26
- //# sourceMappingURL=communicator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"communicator.js","sourceRoot":"","sources":["../../../../src/communicator.ts"],"names":[],"mappings":";;;AAGA,uCAAyD;AAmBzD,MAAa,uBAAwB,SAAQ,yBAAe;IACjD,UAAU,CAAS;IACnB,cAAc,CAAU;IACxB,eAAe,CAAS;IACxB,WAAW,CAAS;IACpB,WAAW,CAAS;IAE7B,iCAAiC;IACjC,YAAY,eAA2D,EAAE,UAAkB,EAAE,IAAU,EAAE,MAAc,EAAE,MAA0B,EAAE,QAAgB;QACnK,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QACpD,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;QAC3C,IAAI,eAAe,CAAC,iBAAiB,EAAE,CAAC;YACtC,mEAAmE;YACnE,IAAI,CAAC,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AApBD,0DAoBC"}
@@ -1,64 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node/http" />
4
- /// <reference types="@koa/bodyparser/dist/body-parser" />
5
- import { Span } from "@opentelemetry/sdk-trace-base";
6
- import { GlobalLogger as Logger, Logger as DBOSLogger } from "./telemetry/logs";
7
- import { IncomingHttpHeaders } from "http";
8
- import { ParsedUrlQuery } from "querystring";
9
- import { DBOSExecutor } from "./dbos-executor";
10
- export interface HTTPRequest {
11
- readonly headers?: IncomingHttpHeaders;
12
- readonly rawHeaders?: string[];
13
- readonly params?: unknown;
14
- readonly body?: unknown;
15
- readonly rawBody?: string;
16
- readonly query?: ParsedUrlQuery;
17
- readonly querystring?: string;
18
- readonly url?: string;
19
- readonly ip?: string;
20
- readonly requestID?: string;
21
- }
22
- export interface DBOSContext {
23
- readonly request: HTTPRequest;
24
- readonly workflowUUID: string;
25
- readonly authenticatedUser: string;
26
- readonly authenticatedRoles: string[];
27
- readonly assumedRole: string;
28
- readonly logger: DBOSLogger;
29
- readonly span: Span;
30
- getConfig<T>(key: string): T | undefined;
31
- getConfig<T>(key: string, defaultValue: T): T;
32
- }
33
- export declare class DBOSContextImpl implements DBOSContext {
34
- readonly operationName: string;
35
- readonly span: Span;
36
- request: HTTPRequest;
37
- authenticatedUser: string;
38
- authenticatedRoles: string[];
39
- assumedRole: string;
40
- workflowUUID: string;
41
- executorID: string;
42
- readonly logger: DBOSLogger;
43
- constructor(operationName: string, span: Span, logger: Logger, parentCtx?: DBOSContextImpl);
44
- /*** Application configuration ***/
45
- applicationConfig?: any;
46
- getConfig<T>(key: string): T | undefined;
47
- getConfig<T>(key: string, defaultValue: T): T;
48
- }
49
- /**
50
- * TODO : move logger and application, getConfig to a BaseContext which is at the root of all contexts
51
- */
52
- export declare class InitContext {
53
- readonly dbosExec: DBOSExecutor;
54
- readonly logger: Logger;
55
- private userDatabase;
56
- private application;
57
- constructor(dbosExec: DBOSExecutor);
58
- createUserSchema(): Promise<void>;
59
- dropUserSchema(): Promise<void>;
60
- queryUserDB<R>(sql: string, ...params: unknown[]): Promise<R[]>;
61
- getConfig<T>(key: string): T | undefined;
62
- getConfig<T>(key: string, defaultValue: T): T;
63
- }
64
- //# sourceMappingURL=context.d.ts.map
@@ -1 +0,0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