@dbos-inc/dbos-sdk 0.7.18-preview

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/dbos-config.schema.json +121 -0
  4. package/dbos-test-config.yaml +16 -0
  5. package/dist/schemas/system_db_schema.d.ts +34 -0
  6. package/dist/schemas/system_db_schema.d.ts.map +1 -0
  7. package/dist/schemas/system_db_schema.js +75 -0
  8. package/dist/schemas/system_db_schema.js.map +1 -0
  9. package/dist/schemas/user_db_schema.d.ts +11 -0
  10. package/dist/schemas/user_db_schema.d.ts.map +1 -0
  11. package/dist/schemas/user_db_schema.js +16 -0
  12. package/dist/schemas/user_db_schema.js.map +1 -0
  13. package/dist/src/cloud-cli/applications/configure.d.ts +2 -0
  14. package/dist/src/cloud-cli/applications/configure.d.ts.map +1 -0
  15. package/dist/src/cloud-cli/applications/configure.js +57 -0
  16. package/dist/src/cloud-cli/applications/configure.js.map +1 -0
  17. package/dist/src/cloud-cli/applications/delete-app.d.ts +2 -0
  18. package/dist/src/cloud-cli/applications/delete-app.d.ts.map +1 -0
  19. package/dist/src/cloud-cli/applications/delete-app.js +36 -0
  20. package/dist/src/cloud-cli/applications/delete-app.js.map +1 -0
  21. package/dist/src/cloud-cli/applications/deploy-app-code.d.ts +2 -0
  22. package/dist/src/cloud-cli/applications/deploy-app-code.d.ts.map +1 -0
  23. package/dist/src/cloud-cli/applications/deploy-app-code.js +64 -0
  24. package/dist/src/cloud-cli/applications/deploy-app-code.js.map +1 -0
  25. package/dist/src/cloud-cli/applications/get-app-logs.d.ts +2 -0
  26. package/dist/src/cloud-cli/applications/get-app-logs.d.ts.map +1 -0
  27. package/dist/src/cloud-cli/applications/get-app-logs.js +37 -0
  28. package/dist/src/cloud-cli/applications/get-app-logs.js.map +1 -0
  29. package/dist/src/cloud-cli/applications/index.d.ts +8 -0
  30. package/dist/src/cloud-cli/applications/index.d.ts.map +1 -0
  31. package/dist/src/cloud-cli/applications/index.js +18 -0
  32. package/dist/src/cloud-cli/applications/index.js.map +1 -0
  33. package/dist/src/cloud-cli/applications/list-apps.d.ts +2 -0
  34. package/dist/src/cloud-cli/applications/list-apps.d.ts.map +1 -0
  35. package/dist/src/cloud-cli/applications/list-apps.js +45 -0
  36. package/dist/src/cloud-cli/applications/list-apps.js.map +1 -0
  37. package/dist/src/cloud-cli/applications/register-app.d.ts +2 -0
  38. package/dist/src/cloud-cli/applications/register-app.d.ts.map +1 -0
  39. package/dist/src/cloud-cli/applications/register-app.js +41 -0
  40. package/dist/src/cloud-cli/applications/register-app.js.map +1 -0
  41. package/dist/src/cloud-cli/applications/types.d.ts +7 -0
  42. package/dist/src/cloud-cli/applications/types.d.ts.map +1 -0
  43. package/dist/src/cloud-cli/applications/types.js +3 -0
  44. package/dist/src/cloud-cli/applications/types.js.map +1 -0
  45. package/dist/src/cloud-cli/applications/update-app.d.ts +2 -0
  46. package/dist/src/cloud-cli/applications/update-app.d.ts.map +1 -0
  47. package/dist/src/cloud-cli/applications/update-app.js +42 -0
  48. package/dist/src/cloud-cli/applications/update-app.js.map +1 -0
  49. package/dist/src/cloud-cli/cli.d.ts +3 -0
  50. package/dist/src/cloud-cli/cli.d.ts.map +1 -0
  51. package/dist/src/cloud-cli/cli.js +148 -0
  52. package/dist/src/cloud-cli/cli.js.map +1 -0
  53. package/dist/src/cloud-cli/login.d.ts +7 -0
  54. package/dist/src/cloud-cli/login.d.ts.map +1 -0
  55. package/dist/src/cloud-cli/login.js +40 -0
  56. package/dist/src/cloud-cli/login.js.map +1 -0
  57. package/dist/src/cloud-cli/register.d.ts +2 -0
  58. package/dist/src/cloud-cli/register.d.ts.map +1 -0
  59. package/dist/src/cloud-cli/register.js +35 -0
  60. package/dist/src/cloud-cli/register.js.map +1 -0
  61. package/dist/src/cloud-cli/userdb.d.ts +4 -0
  62. package/dist/src/cloud-cli/userdb.d.ts.map +1 -0
  63. package/dist/src/cloud-cli/userdb.js +149 -0
  64. package/dist/src/cloud-cli/userdb.js.map +1 -0
  65. package/dist/src/cloud-cli/utils.d.ts +3 -0
  66. package/dist/src/cloud-cli/utils.d.ts.map +1 -0
  67. package/dist/src/cloud-cli/utils.js +17 -0
  68. package/dist/src/cloud-cli/utils.js.map +1 -0
  69. package/dist/src/communicator.d.ts +24 -0
  70. package/dist/src/communicator.d.ts.map +1 -0
  71. package/dist/src/communicator.js +26 -0
  72. package/dist/src/communicator.js.map +1 -0
  73. package/dist/src/context.d.ts +60 -0
  74. package/dist/src/context.d.ts.map +1 -0
  75. package/dist/src/context.js +94 -0
  76. package/dist/src/context.js.map +1 -0
  77. package/dist/src/data_validation.d.ts +3 -0
  78. package/dist/src/data_validation.d.ts.map +1 -0
  79. package/dist/src/data_validation.js +168 -0
  80. package/dist/src/data_validation.js.map +1 -0
  81. package/dist/src/dbos-executor.d.ts +79 -0
  82. package/dist/src/dbos-executor.d.ts.map +1 -0
  83. package/dist/src/dbos-executor.js +408 -0
  84. package/dist/src/dbos-executor.js.map +1 -0
  85. package/dist/src/dbos-runtime/TypeParser.d.ts +33 -0
  86. package/dist/src/dbos-runtime/TypeParser.d.ts.map +1 -0
  87. package/dist/src/dbos-runtime/TypeParser.js +104 -0
  88. package/dist/src/dbos-runtime/TypeParser.js.map +1 -0
  89. package/dist/src/dbos-runtime/applicationVersion.d.ts +3 -0
  90. package/dist/src/dbos-runtime/applicationVersion.d.ts.map +1 -0
  91. package/dist/src/dbos-runtime/applicationVersion.js +13 -0
  92. package/dist/src/dbos-runtime/applicationVersion.js.map +1 -0
  93. package/dist/src/dbos-runtime/cli.d.ts +8 -0
  94. package/dist/src/dbos-runtime/cli.d.ts.map +1 -0
  95. package/dist/src/dbos-runtime/cli.js +52 -0
  96. package/dist/src/dbos-runtime/cli.js.map +1 -0
  97. package/dist/src/dbos-runtime/config.d.ts +28 -0
  98. package/dist/src/dbos-runtime/config.d.ts.map +1 -0
  99. package/dist/src/dbos-runtime/config.js +111 -0
  100. package/dist/src/dbos-runtime/config.js.map +1 -0
  101. package/dist/src/dbos-runtime/init.d.ts +7 -0
  102. package/dist/src/dbos-runtime/init.d.ts.map +1 -0
  103. package/dist/src/dbos-runtime/init.js +51 -0
  104. package/dist/src/dbos-runtime/init.js.map +1 -0
  105. package/dist/src/dbos-runtime/openApi.d.ts +35 -0
  106. package/dist/src/dbos-runtime/openApi.d.ts.map +1 -0
  107. package/dist/src/dbos-runtime/openApi.js +595 -0
  108. package/dist/src/dbos-runtime/openApi.js.map +1 -0
  109. package/dist/src/dbos-runtime/runtime.d.ts +28 -0
  110. package/dist/src/dbos-runtime/runtime.d.ts.map +1 -0
  111. package/dist/src/dbos-runtime/runtime.js +96 -0
  112. package/dist/src/dbos-runtime/runtime.js.map +1 -0
  113. package/dist/src/dbos-runtime/tsDiagUtil.d.ts +16 -0
  114. package/dist/src/dbos-runtime/tsDiagUtil.d.ts.map +1 -0
  115. package/dist/src/dbos-runtime/tsDiagUtil.js +72 -0
  116. package/dist/src/dbos-runtime/tsDiagUtil.js.map +1 -0
  117. package/dist/src/decorators.d.ts +118 -0
  118. package/dist/src/decorators.d.ts.map +1 -0
  119. package/dist/src/decorators.js +467 -0
  120. package/dist/src/decorators.js.map +1 -0
  121. package/dist/src/error.d.ts +44 -0
  122. package/dist/src/error.d.ts.map +1 -0
  123. package/dist/src/error.js +164 -0
  124. package/dist/src/error.js.map +1 -0
  125. package/dist/src/httpServer/handler.d.ts +62 -0
  126. package/dist/src/httpServer/handler.d.ts.map +1 -0
  127. package/dist/src/httpServer/handler.js +168 -0
  128. package/dist/src/httpServer/handler.js.map +1 -0
  129. package/dist/src/httpServer/middleware.d.ts +56 -0
  130. package/dist/src/httpServer/middleware.d.ts.map +1 -0
  131. package/dist/src/httpServer/middleware.js +57 -0
  132. package/dist/src/httpServer/middleware.js.map +1 -0
  133. package/dist/src/httpServer/server.d.ts +40 -0
  134. package/dist/src/httpServer/server.d.ts.map +1 -0
  135. package/dist/src/httpServer/server.js +231 -0
  136. package/dist/src/httpServer/server.js.map +1 -0
  137. package/dist/src/index.d.ts +12 -0
  138. package/dist/src/index.d.ts.map +1 -0
  139. package/dist/src/index.js +75 -0
  140. package/dist/src/index.js.map +1 -0
  141. package/dist/src/provenance/provenance_daemon.d.ts +34 -0
  142. package/dist/src/provenance/provenance_daemon.d.ts.map +1 -0
  143. package/dist/src/provenance/provenance_daemon.js +86 -0
  144. package/dist/src/provenance/provenance_daemon.js.map +1 -0
  145. package/dist/src/system_database.d.ts +69 -0
  146. package/dist/src/system_database.d.ts.map +1 -0
  147. package/dist/src/system_database.js +384 -0
  148. package/dist/src/system_database.js.map +1 -0
  149. package/dist/src/telemetry/collector.d.ts +17 -0
  150. package/dist/src/telemetry/collector.d.ts.map +1 -0
  151. package/dist/src/telemetry/collector.js +77 -0
  152. package/dist/src/telemetry/collector.js.map +1 -0
  153. package/dist/src/telemetry/exporters.d.ts +29 -0
  154. package/dist/src/telemetry/exporters.d.ts.map +1 -0
  155. package/dist/src/telemetry/exporters.js +186 -0
  156. package/dist/src/telemetry/exporters.js.map +1 -0
  157. package/dist/src/telemetry/index.d.ts +7 -0
  158. package/dist/src/telemetry/index.d.ts.map +1 -0
  159. package/dist/src/telemetry/index.js +3 -0
  160. package/dist/src/telemetry/index.js.map +1 -0
  161. package/dist/src/telemetry/logs.d.ts +25 -0
  162. package/dist/src/telemetry/logs.d.ts.map +1 -0
  163. package/dist/src/telemetry/logs.js +91 -0
  164. package/dist/src/telemetry/logs.js.map +1 -0
  165. package/dist/src/telemetry/signals.d.ts +30 -0
  166. package/dist/src/telemetry/signals.d.ts.map +1 -0
  167. package/dist/src/telemetry/signals.js +11 -0
  168. package/dist/src/telemetry/signals.js.map +1 -0
  169. package/dist/src/telemetry/traces.d.ts +17 -0
  170. package/dist/src/telemetry/traces.d.ts.map +1 -0
  171. package/dist/src/telemetry/traces.js +76 -0
  172. package/dist/src/telemetry/traces.js.map +1 -0
  173. package/dist/src/testing/testing_runtime.d.ts +76 -0
  174. package/dist/src/testing/testing_runtime.d.ts.map +1 -0
  175. package/dist/src/testing/testing_runtime.js +147 -0
  176. package/dist/src/testing/testing_runtime.js.map +1 -0
  177. package/dist/src/transaction.d.ts +28 -0
  178. package/dist/src/transaction.d.ts.map +1 -0
  179. package/dist/src/transaction.js +27 -0
  180. package/dist/src/transaction.js.map +1 -0
  181. package/dist/src/user_database.d.ts +132 -0
  182. package/dist/src/user_database.d.ts.map +1 -0
  183. package/dist/src/user_database.js +324 -0
  184. package/dist/src/user_database.js.map +1 -0
  185. package/dist/src/utils.d.ts +6 -0
  186. package/dist/src/utils.d.ts.map +1 -0
  187. package/dist/src/utils.js +35 -0
  188. package/dist/src/utils.js.map +1 -0
  189. package/dist/src/workflow.d.ts +179 -0
  190. package/dist/src/workflow.d.ts.map +1 -0
  191. package/dist/src/workflow.js +446 -0
  192. package/dist/src/workflow.js.map +1 -0
  193. package/examples/hello/README.md +41 -0
  194. package/examples/hello/dbos-config.yaml +15 -0
  195. package/examples/hello/jest.config.js +8 -0
  196. package/examples/hello/knexfile.ts +23 -0
  197. package/examples/hello/migrations/create_dbos_hello_tables.ts +12 -0
  198. package/examples/hello/package.json +21 -0
  199. package/examples/hello/src/operations.test.ts +38 -0
  200. package/examples/hello/src/operations.ts +21 -0
  201. package/examples/hello/start_postgres_docker.sh +23 -0
  202. package/examples/hello/tsconfig.json +24 -0
  203. package/package.json +78 -0
@@ -0,0 +1,324 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KnexUserDatabase = exports.TypeORMDatabase = exports.PrismaUserDatabase = exports.PGNodeUserDatabase = exports.UserDatabaseName = void 0;
4
+ /* eslint-disable @typescript-eslint/no-explicit-any */
5
+ const pg_1 = require("pg");
6
+ const user_db_schema_1 = require("../schemas/user_db_schema");
7
+ const transaction_1 = require("./transaction");
8
+ exports.UserDatabaseName = {
9
+ PGNODE: "pg-node",
10
+ PRISMA: "prisma",
11
+ TYPEORM: "typeorm",
12
+ KNEX: "knex",
13
+ };
14
+ /**
15
+ * node-postgres user data access interface
16
+ */
17
+ class PGNodeUserDatabase {
18
+ poolConfig;
19
+ pool;
20
+ constructor(poolConfig) {
21
+ this.poolConfig = poolConfig;
22
+ this.pool = new pg_1.Pool(poolConfig);
23
+ }
24
+ async init() {
25
+ await this.pool.query(user_db_schema_1.createUserDBSchema);
26
+ await this.pool.query(user_db_schema_1.userDBSchema);
27
+ }
28
+ async destroy() {
29
+ await this.pool.end();
30
+ }
31
+ getName() {
32
+ return exports.UserDatabaseName.PGNODE;
33
+ }
34
+ async transaction(txn, config, ...args) {
35
+ const client = await this.pool.connect();
36
+ try {
37
+ const readOnly = config.readOnly ?? false;
38
+ const isolationLevel = config.isolationLevel ?? transaction_1.IsolationLevel.Serializable;
39
+ await client.query(`BEGIN ISOLATION LEVEL ${isolationLevel}`);
40
+ if (readOnly) {
41
+ await client.query(`SET TRANSACTION READ ONLY`);
42
+ }
43
+ const result = await txn(client, ...args);
44
+ await client.query(`COMMIT`);
45
+ return result;
46
+ }
47
+ catch (err) {
48
+ await client.query(`ROLLBACK`);
49
+ throw err;
50
+ }
51
+ finally {
52
+ client.release();
53
+ }
54
+ }
55
+ async queryFunction(func, ...args) {
56
+ const client = await this.pool.connect();
57
+ try {
58
+ return func(client, ...args);
59
+ }
60
+ finally {
61
+ client.release();
62
+ }
63
+ }
64
+ async query(sql, ...params) {
65
+ return this.pool.query(sql, params).then((value) => {
66
+ return value.rows;
67
+ });
68
+ }
69
+ async queryWithClient(client, sql, ...params) {
70
+ const pgClient = client;
71
+ return pgClient.query(sql, params).then((value) => {
72
+ return value.rows;
73
+ });
74
+ }
75
+ getPostgresErrorCode(error) {
76
+ const dbErr = error;
77
+ return dbErr.code ? dbErr.code : null;
78
+ }
79
+ isRetriableTransactionError(error) {
80
+ if (!(error instanceof pg_1.DatabaseError)) {
81
+ return false;
82
+ }
83
+ return this.getPostgresErrorCode(error) === "40001";
84
+ }
85
+ isKeyConflictError(error) {
86
+ if (!(error instanceof pg_1.DatabaseError)) {
87
+ return false;
88
+ }
89
+ const pge = this.getPostgresErrorCode(error);
90
+ return pge === "23505";
91
+ }
92
+ // eslint-disable-next-line @typescript-eslint/require-await
93
+ async createSchema() {
94
+ throw new Error("createSchema() is not supported in PG user database.");
95
+ }
96
+ // eslint-disable-next-line @typescript-eslint/require-await
97
+ async dropSchema() {
98
+ throw new Error("dropSchema() is not supported in PG user database.");
99
+ }
100
+ }
101
+ exports.PGNodeUserDatabase = PGNodeUserDatabase;
102
+ const PrismaIsolationLevel = {
103
+ ReadUncommitted: "ReadUncommitted",
104
+ ReadCommitted: "ReadCommitted",
105
+ RepeatableRead: "RepeatableRead",
106
+ Serializable: "Serializable",
107
+ };
108
+ class PrismaUserDatabase {
109
+ prisma;
110
+ constructor(prisma) {
111
+ this.prisma = prisma;
112
+ }
113
+ async init() {
114
+ await this.prisma.$queryRawUnsafe(user_db_schema_1.createUserDBSchema);
115
+ await this.prisma.$queryRawUnsafe(user_db_schema_1.userDBSchema);
116
+ }
117
+ async destroy() {
118
+ await this.prisma.$disconnect();
119
+ }
120
+ getName() {
121
+ return exports.UserDatabaseName.PRISMA;
122
+ }
123
+ async transaction(transaction, config, ...args) {
124
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
125
+ let isolationLevel;
126
+ if (config.isolationLevel === transaction_1.IsolationLevel.ReadUncommitted) {
127
+ isolationLevel = PrismaIsolationLevel.ReadUncommitted;
128
+ }
129
+ else if (config.isolationLevel === transaction_1.IsolationLevel.ReadCommitted) {
130
+ isolationLevel = PrismaIsolationLevel.ReadCommitted;
131
+ }
132
+ else if (config.isolationLevel === transaction_1.IsolationLevel.RepeatableRead) {
133
+ isolationLevel = PrismaIsolationLevel.RepeatableRead;
134
+ }
135
+ else {
136
+ isolationLevel = PrismaIsolationLevel.Serializable;
137
+ }
138
+ const result = await this.prisma.$transaction(async (tx) => {
139
+ return await transaction(tx, ...args);
140
+ }, { isolationLevel: isolationLevel });
141
+ return result;
142
+ }
143
+ async queryFunction(func, ...args) {
144
+ return func(this.prisma, ...args);
145
+ }
146
+ async query(sql, ...params) {
147
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
148
+ return this.prisma.$queryRawUnsafe(sql, ...params);
149
+ }
150
+ async queryWithClient(client, sql, ...params) {
151
+ const prismaClient = client;
152
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
153
+ return prismaClient.$queryRawUnsafe(sql, ...params);
154
+ }
155
+ getPostgresErrorCode(error) {
156
+ const dbErr = error;
157
+ return dbErr.meta ? dbErr.meta.code : null;
158
+ }
159
+ isRetriableTransactionError(error) {
160
+ return this.getPostgresErrorCode(error) === "40001";
161
+ }
162
+ isKeyConflictError(error) {
163
+ const pge = this.getPostgresErrorCode(error);
164
+ return pge === "23505";
165
+ }
166
+ // eslint-disable-next-line @typescript-eslint/require-await
167
+ async createSchema() {
168
+ throw new Error("createSchema() is not supported in Prisma user database.");
169
+ }
170
+ // eslint-disable-next-line @typescript-eslint/require-await
171
+ async dropSchema() {
172
+ throw new Error("dropSchema() is not supported in Prisma user database.");
173
+ }
174
+ }
175
+ exports.PrismaUserDatabase = PrismaUserDatabase;
176
+ /**
177
+ * TypeORM user data access interface
178
+ */
179
+ class TypeORMDatabase {
180
+ ds;
181
+ dataSource;
182
+ constructor(ds) {
183
+ this.ds = ds;
184
+ this.dataSource = ds;
185
+ }
186
+ async init() {
187
+ if (!this.dataSource.isInitialized) {
188
+ await this.dataSource.initialize();
189
+ }
190
+ await this.dataSource.query(user_db_schema_1.createUserDBSchema);
191
+ await this.dataSource.query(user_db_schema_1.userDBSchema);
192
+ }
193
+ async destroy() {
194
+ if (this.dataSource.isInitialized) {
195
+ await this.dataSource.destroy();
196
+ }
197
+ }
198
+ getName() {
199
+ return exports.UserDatabaseName.TYPEORM;
200
+ }
201
+ async transaction(txn, config, ...args) {
202
+ const isolationLevel = config.isolationLevel ?? transaction_1.IsolationLevel.Serializable;
203
+ return this.dataSource.manager.transaction(isolationLevel, async (transactionEntityManager) => {
204
+ const result = await txn(transactionEntityManager, ...args);
205
+ return result;
206
+ });
207
+ }
208
+ async queryFunction(func, ...args) {
209
+ return func(this.dataSource.manager, ...args);
210
+ }
211
+ async query(sql, ...params) {
212
+ return this.dataSource.manager.query(sql, params).then((value) => {
213
+ return value;
214
+ });
215
+ }
216
+ async queryWithClient(client, sql, ...params) {
217
+ const tClient = client;
218
+ return tClient.query(sql, params).then((value) => {
219
+ return value;
220
+ });
221
+ }
222
+ getPostgresErrorCode(error) {
223
+ const typeormErr = error;
224
+ if (typeormErr.driverError) {
225
+ const dbErr = typeormErr.driverError;
226
+ return dbErr.code ? dbErr.code : null;
227
+ }
228
+ else {
229
+ return null;
230
+ }
231
+ }
232
+ isRetriableTransactionError(error) {
233
+ return this.getPostgresErrorCode(error) === "40001";
234
+ }
235
+ isKeyConflictError(error) {
236
+ const pge = this.getPostgresErrorCode(error);
237
+ return pge === "23505";
238
+ }
239
+ async createSchema() {
240
+ return this.dataSource.synchronize();
241
+ }
242
+ async dropSchema() {
243
+ return this.dataSource.dropDatabase();
244
+ }
245
+ }
246
+ exports.TypeORMDatabase = TypeORMDatabase;
247
+ /**
248
+ * Knex user data access interface
249
+ */
250
+ class KnexUserDatabase {
251
+ knex;
252
+ constructor(knex) {
253
+ this.knex = knex;
254
+ }
255
+ async init() {
256
+ await this.knex.raw(user_db_schema_1.createUserDBSchema);
257
+ await this.knex.raw(user_db_schema_1.userDBSchema);
258
+ }
259
+ async destroy() {
260
+ await this.knex.destroy();
261
+ }
262
+ getName() {
263
+ return exports.UserDatabaseName.KNEX;
264
+ }
265
+ async transaction(transactionFunction, config, ...args) {
266
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
267
+ let isolationLevel;
268
+ if (config.isolationLevel === transaction_1.IsolationLevel.ReadUncommitted) {
269
+ isolationLevel = "read uncommitted";
270
+ }
271
+ else if (config.isolationLevel === transaction_1.IsolationLevel.ReadCommitted) {
272
+ isolationLevel = "read committed";
273
+ }
274
+ else if (config.isolationLevel === transaction_1.IsolationLevel.RepeatableRead) {
275
+ isolationLevel = "repeatable read";
276
+ }
277
+ else {
278
+ isolationLevel = "serializable";
279
+ }
280
+ const result = await this.knex.transaction(async (transactionClient) => {
281
+ return await transactionFunction(transactionClient, ...args);
282
+ }, { isolationLevel: isolationLevel, readOnly: config.readOnly ?? false });
283
+ return result;
284
+ }
285
+ async queryFunction(func, ...args) {
286
+ const result = await this.knex.transaction(async (transactionClient) => {
287
+ return await func(transactionClient, ...args);
288
+ }, { isolationLevel: "read committed", readOnly: true });
289
+ return result;
290
+ }
291
+ async query(sql, ...params) {
292
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
293
+ return this.queryWithClient(this.knex, sql, ...params);
294
+ }
295
+ async queryWithClient(client, sql, ...uparams) {
296
+ const knexSql = sql.replace(/\$\d+/g, '?'); // Replace $1, $2... with ?
297
+ let params = uparams;
298
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
299
+ params = params.map(i => i === undefined ? null : i); // Set undefined parameters to null.
300
+ const rows = await client.raw(knexSql, params);
301
+ return rows.rows;
302
+ }
303
+ getPostgresErrorCode(error) {
304
+ const dbErr = error;
305
+ return dbErr.code ? dbErr.code : null;
306
+ }
307
+ isRetriableTransactionError(error) {
308
+ return this.getPostgresErrorCode(error) === "40001";
309
+ }
310
+ isKeyConflictError(error) {
311
+ const pge = this.getPostgresErrorCode(error);
312
+ return pge === "23505";
313
+ }
314
+ // eslint-disable-next-line @typescript-eslint/require-await
315
+ async createSchema() {
316
+ throw new Error("createSchema() is not supported in Knex user database.");
317
+ }
318
+ // eslint-disable-next-line @typescript-eslint/require-await
319
+ async dropSchema() {
320
+ throw new Error("dropSchema() is not supported in Knex user database.");
321
+ }
322
+ }
323
+ exports.KnexUserDatabase = KnexUserDatabase;
324
+ //# sourceMappingURL=user_database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user_database.js","sourceRoot":"","sources":["../../src/user_database.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AACv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2B;QACvE,IAAI,MAAM,GAAG,OAAgB,CAAC;QAC9B,+DAA+D;QAC/D,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oCAAoC;QAC1F,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAI,OAAO,EAAE,MAAM,CAAkB,CAAC;QACnE,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,oBAAoB,CAAC,KAAc;QACjC,MAAM,KAAK,GAAoB,KAAwB,CAAC;QACxD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAED,2BAA2B,CAAC,KAAc;QACxC,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC;IACtD,CAAC;IAED,kBAAkB,CAAC,KAAc;QAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,GAAG,KAAK,OAAO,CAAC;IACzB,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,4DAA4D;IAC5D,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;CACF;AApFD,4CAoFC"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ export declare function readFileSync(path: string, encoding?: BufferEncoding): string | Buffer;
3
+ export declare const sleep: (ms: number) => Promise<unknown>;
4
+ export type ValuesOf<T> = T[keyof T];
5
+ export declare function createDirectory(path: string): string | undefined;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createDirectory = exports.sleep = exports.readFileSync = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ /*
9
+ * Use the node.js `fs` module to read the content of a file
10
+ * Handles cases where:
11
+ * - the file does not exist
12
+ * - the file is not a valid file
13
+ **/
14
+ function readFileSync(path, encoding = "utf8") {
15
+ // First, check the file
16
+ fs_1.default.stat(path, (error, stats) => {
17
+ if (error) {
18
+ throw new Error(`checking on ${path}. ${error.code}: ${error.errno}`);
19
+ }
20
+ else if (!stats.isFile()) {
21
+ throw new Error(`config file ${path} is not a file`);
22
+ }
23
+ });
24
+ // Then, read its content
25
+ const fileContent = fs_1.default.readFileSync(path, { encoding });
26
+ return fileContent;
27
+ }
28
+ exports.readFileSync = readFileSync;
29
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
30
+ exports.sleep = sleep;
31
+ function createDirectory(path) {
32
+ return fs_1.default.mkdirSync(path, { recursive: true });
33
+ }
34
+ exports.createDirectory = createDirectory;
35
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +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;YACT,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;SACvE;aAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,eAAe,IAAI,gBAAgB,CAAC,CAAC;SACtD;IACH,CAAC,CAAC,CAAC;IAEH,yBAAyB;IACzB,MAAM,WAAW,GAAW,YAAE,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,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;AAK3E,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,YAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,0CAEC"}
@@ -0,0 +1,179 @@
1
+ import { DBOSExecutor } from "./dbos-executor";
2
+ import { Transaction, TransactionContext } from "./transaction";
3
+ import { Communicator, CommunicatorContext } from "./communicator";
4
+ import { SystemDatabase } from "./system_database";
5
+ import { UserDatabaseClient } from "./user_database";
6
+ import { HTTPRequest, DBOSContext, DBOSContextImpl } from './context';
7
+ export type Workflow<T extends any[], R> = (ctxt: WorkflowContext, ...args: T) => Promise<R>;
8
+ export type TailParameters<T extends (arg: any, args: any[]) => any> = T extends (arg: any, ...args: infer P) => any ? P : never;
9
+ type TxFunc = (ctxt: TransactionContext<any>, ...args: any[]) => Promise<any>;
10
+ type CommFunc = (ctxt: CommunicatorContext, ...args: any[]) => Promise<any>;
11
+ export type WFInvokeFuncs<T> = {
12
+ [P in keyof T as T[P] extends TxFunc | CommFunc ? P : never]: T[P] extends TxFunc | CommFunc ? (...args: TailParameters<T[P]>) => ReturnType<T[P]> : never;
13
+ };
14
+ export interface WorkflowParams {
15
+ workflowUUID?: string;
16
+ parentCtx?: DBOSContextImpl;
17
+ }
18
+ export interface WorkflowConfig {
19
+ }
20
+ export interface WorkflowStatus {
21
+ readonly status: string;
22
+ readonly workflowName: string;
23
+ readonly authenticatedUser: string;
24
+ readonly assumedRole: string;
25
+ readonly authenticatedRoles: string[];
26
+ readonly request: HTTPRequest;
27
+ }
28
+ export interface PgTransactionId {
29
+ txid: string;
30
+ }
31
+ interface BufferedResult {
32
+ output: unknown;
33
+ txn_snapshot: string;
34
+ }
35
+ export declare const StatusString: {
36
+ readonly PENDING: "PENDING";
37
+ readonly SUCCESS: "SUCCESS";
38
+ readonly ERROR: "ERROR";
39
+ };
40
+ export interface WorkflowContext extends DBOSContext {
41
+ invoke<T extends object>(targetClass: T): WFInvokeFuncs<T>;
42
+ childWorkflow<T extends any[], R>(wf: Workflow<T, R>, ...args: T): Promise<WorkflowHandle<R>>;
43
+ send<T extends NonNullable<any>>(destinationUUID: string, message: T, topic?: string): Promise<void>;
44
+ recv<T extends NonNullable<any>>(topic?: string, timeoutSeconds?: number): Promise<T | null>;
45
+ setEvent<T extends NonNullable<any>>(key: string, value: T): Promise<void>;
46
+ getEvent<T extends NonNullable<any>>(workflowUUID: string, key: string, timeoutSeconds?: number): Promise<T | null>;
47
+ retrieveWorkflow<R>(workflowUUID: string): WorkflowHandle<R>;
48
+ }
49
+ export declare class WorkflowContextImpl extends DBOSContextImpl implements WorkflowContext {
50
+ #private;
51
+ readonly workflowConfig: WorkflowConfig;
52
+ functionID: number;
53
+ readonly resultBuffer: Map<number, BufferedResult>;
54
+ readonly isTempWorkflow: boolean;
55
+ constructor(wfe: DBOSExecutor, parentCtx: DBOSContextImpl | undefined, workflowUUID: string, workflowConfig: WorkflowConfig, workflowName: string);
56
+ functionIDGetIncrement(): number;
57
+ /**
58
+ * Check if an operation has already executed in a workflow.
59
+ * If it previously executed succesfully, return its output.
60
+ * If it previously executed and threw an error, throw that error.
61
+ * Otherwise, return DBOSNull.
62
+ * Also return the transaction snapshot information of this current transaction.
63
+ */
64
+ checkExecution<R>(client: UserDatabaseClient, funcID: number): Promise<BufferedResult>;
65
+ /**
66
+ * Write all entries in the workflow result buffer to the database.
67
+ * If it encounters a primary key error, this indicates a concurrent execution with the same UUID, so throw an DBOSError.
68
+ */
69
+ flushResultBuffer(client: UserDatabaseClient): Promise<void>;
70
+ /**
71
+ * Buffer a placeholder value to guard an operation against concurrent executions with the same UUID.
72
+ */
73
+ guardOperation(funcID: number, txnSnapshot: string): void;
74
+ /**
75
+ * Write a guarded operation's output to the database.
76
+ */
77
+ recordGuardedOutput<R>(client: UserDatabaseClient, funcID: number, output: R): Promise<string>;
78
+ /**
79
+ * Record an error in a guarded operation to the database.
80
+ */
81
+ recordGuardedError(client: UserDatabaseClient, funcID: number, err: Error): Promise<void>;
82
+ /**
83
+ * Invoke another workflow as its child workflow and return a workflow handle.
84
+ * The child workflow is guaranteed to be executed exactly once, even if the workflow is retried with the same UUID.
85
+ * We pass in itself as a parent context adn assign the child workflow with a derministic UUID "this.workflowUUID-functionID", which appends a function ID to its own UUID.
86
+ */
87
+ childWorkflow<T extends any[], R>(wf: Workflow<T, R>, ...args: T): Promise<WorkflowHandle<R>>;
88
+ /**
89
+ * Execute a transactional function.
90
+ * The transaction is guaranteed to execute exactly once, even if the workflow is retried with the same UUID.
91
+ * If the transaction encounters a Postgres serialization error, retry it.
92
+ * If it encounters any other error, throw it.
93
+ */
94
+ transaction<T extends any[], R>(txn: Transaction<T, R>, ...args: T): Promise<R>;
95
+ /**
96
+ * Execute a communicator function.
97
+ * If it encounters any error, retry according to its configured retry policy until the maximum number of attempts is reached, then throw an DBOSError.
98
+ * The communicator may execute many times, but once it is complete, it will not re-execute.
99
+ */
100
+ external<T extends any[], R>(commFn: Communicator<T, R>, ...args: T): Promise<R>;
101
+ /**
102
+ * Send a message to a workflow identified by a UUID.
103
+ * The message can optionally be tagged with a topic.
104
+ */
105
+ send<T extends NonNullable<any>>(destinationUUID: string, message: T, topic?: string): Promise<void>;
106
+ /**
107
+ * Consume and return the oldest unconsumed message sent to your UUID.
108
+ * If a topic is specified, retrieve the oldest message tagged with that topic.
109
+ * Otherwise, retrieve the oldest message with no topic.
110
+ */
111
+ recv<T extends NonNullable<any>>(topic?: string, timeoutSeconds?: number): Promise<T | null>;
112
+ /**
113
+ * Emit a workflow event, represented as a key-value pair.
114
+ * Events are immutable once set.
115
+ */
116
+ setEvent<T extends NonNullable<any>>(key: string, value: T): Promise<void>;
117
+ /**
118
+ * Generate a proxy object for the provided class that wraps direct calls (i.e. OpClass.someMethod(param))
119
+ * to use WorkflowContext.Transaction(OpClass.someMethod, param);
120
+ */
121
+ invoke<T extends object>(object: T): WFInvokeFuncs<T>;
122
+ /**
123
+ * Wait for a workflow to emit an event, then return its value.
124
+ */
125
+ getEvent<T extends NonNullable<any>>(targetUUID: string, key: string, timeoutSeconds?: number): Promise<T | null>;
126
+ /**
127
+ * Retrieve a handle for a workflow UUID.
128
+ */
129
+ retrieveWorkflow<R>(targetUUID: string): WorkflowHandle<R>;
130
+ }
131
+ /**
132
+ * Object representing an active or completed workflow execution, identified by the workflow UUID.
133
+ * Allows retrieval of information about the workflow.
134
+ */
135
+ export interface WorkflowHandle<R> {
136
+ /**
137
+ * Retrieve the workflow's status.
138
+ * Statuses are updated asynchronously.
139
+ */
140
+ getStatus(): Promise<WorkflowStatus | null>;
141
+ /**
142
+ * Await workflow completion and return its result.
143
+ */
144
+ getResult(): Promise<R>;
145
+ /**
146
+ * Return the workflow's UUID.
147
+ */
148
+ getWorkflowUUID(): string;
149
+ }
150
+ /**
151
+ * The handle returned when invoking a workflow with DBOSExecutor.workflow
152
+ */
153
+ export declare class InvokedHandle<R> implements WorkflowHandle<R> {
154
+ readonly systemDatabase: SystemDatabase;
155
+ readonly workflowPromise: Promise<R>;
156
+ readonly workflowUUID: string;
157
+ readonly workflowName: string;
158
+ readonly callerUUID?: string | undefined;
159
+ readonly callerFunctionID?: number | undefined;
160
+ constructor(systemDatabase: SystemDatabase, workflowPromise: Promise<R>, workflowUUID: string, workflowName: string, callerUUID?: string | undefined, callerFunctionID?: number | undefined);
161
+ getWorkflowUUID(): string;
162
+ getStatus(): Promise<WorkflowStatus | null>;
163
+ getResult(): Promise<R>;
164
+ }
165
+ /**
166
+ * The handle returned when retrieving a workflow with DBOSExecutor.retrieve
167
+ */
168
+ export declare class RetrievedHandle<R> implements WorkflowHandle<R> {
169
+ readonly systemDatabase: SystemDatabase;
170
+ readonly workflowUUID: string;
171
+ readonly callerUUID?: string | undefined;
172
+ readonly callerFunctionID?: number | undefined;
173
+ constructor(systemDatabase: SystemDatabase, workflowUUID: string, callerUUID?: string | undefined, callerFunctionID?: number | undefined);
174
+ getWorkflowUUID(): string;
175
+ getStatus(): Promise<WorkflowStatus | null>;
176
+ getResult(): Promise<R>;
177
+ }
178
+ export {};
179
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAsB,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAkB,WAAW,EAAE,kBAAkB,EAA0B,MAAM,eAAe,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAA2B,MAAM,gBAAgB,CAAC;AAI5F,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAA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