@dbos-inc/dbos-sdk 3.6.3-preview → 3.6.7-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/src/{httpServer/server.d.ts → adminserver.d.ts} +30 -53
- package/dist/src/adminserver.d.ts.map +1 -0
- package/dist/src/adminserver.js +559 -0
- package/dist/src/adminserver.js.map +1 -0
- package/dist/src/{dbos-runtime → cli}/cli.d.ts +1 -1
- package/dist/src/cli/cli.d.ts.map +1 -0
- package/dist/src/{dbos-runtime → cli}/cli.js +44 -25
- package/dist/src/cli/cli.js.map +1 -0
- package/dist/src/cli/commands.d.ts.map +1 -0
- package/dist/src/cli/commands.js.map +1 -0
- package/dist/src/cli/docker_pg_helper.d.ts.map +1 -0
- package/dist/src/cli/docker_pg_helper.js.map +1 -0
- package/dist/src/cli/migrate.d.ts +3 -0
- package/dist/src/cli/migrate.d.ts.map +1 -0
- package/dist/src/{dbos-runtime → cli}/migrate.js +1 -29
- package/dist/src/cli/migrate.js.map +1 -0
- package/dist/src/client.d.ts +2 -4
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +6 -19
- package/dist/src/client.js.map +1 -1
- package/dist/src/conductor/conductor.js +1 -1
- package/dist/src/conductor/conductor.js.map +1 -1
- package/dist/src/{dbos-runtime/config.d.ts → config.d.ts} +2 -13
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/{dbos-runtime/config.js → config.js} +12 -72
- package/dist/src/config.js.map +1 -0
- package/dist/src/context.d.ts +0 -4
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/context.js.map +1 -1
- package/dist/src/datasource.js +1 -1
- package/dist/src/datasource.js.map +1 -1
- package/dist/src/dbos-executor.d.ts +2 -28
- package/dist/src/dbos-executor.d.ts.map +1 -1
- package/dist/src/dbos-executor.js +14 -765
- package/dist/src/dbos-executor.js.map +1 -1
- package/dist/src/dbos.d.ts +3 -180
- package/dist/src/dbos.d.ts.map +1 -1
- package/dist/src/dbos.js +10 -385
- package/dist/src/dbos.js.map +1 -1
- package/dist/src/decorators.d.ts +3 -21
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +12 -46
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/error.d.ts +0 -11
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +1 -21
- package/dist/src/error.js.map +1 -1
- package/dist/src/index.d.ts +4 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -43
- package/dist/src/index.js.map +1 -1
- package/dist/src/system_database.d.ts +0 -2
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js +147 -121
- package/dist/src/system_database.js.map +1 -1
- package/dist/src/utils.d.ts +0 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +18 -20
- package/dist/src/utils.js.map +1 -1
- package/dist/src/wfqueue.d.ts +0 -2
- package/dist/src/wfqueue.d.ts.map +1 -1
- package/dist/src/wfqueue.js.map +1 -1
- package/dist/src/workflow.d.ts +0 -8
- package/dist/src/workflow.d.ts.map +1 -1
- package/dist/src/workflow.js.map +1 -1
- package/dist/src/{dbos-runtime/workflow_management.d.ts → workflow_management.d.ts} +4 -6
- package/dist/src/workflow_management.d.ts.map +1 -0
- package/dist/src/{dbos-runtime/workflow_management.js → workflow_management.js} +5 -26
- package/dist/src/workflow_management.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -25
- package/dist/schemas/user_db_schema.d.ts +0 -15
- package/dist/schemas/user_db_schema.d.ts.map +0 -1
- package/dist/schemas/user_db_schema.js +0 -33
- package/dist/schemas/user_db_schema.js.map +0 -1
- package/dist/src/dbos-runtime/cli.d.ts.map +0 -1
- package/dist/src/dbos-runtime/cli.js.map +0 -1
- package/dist/src/dbos-runtime/commands.d.ts.map +0 -1
- package/dist/src/dbos-runtime/commands.js.map +0 -1
- package/dist/src/dbos-runtime/config.d.ts.map +0 -1
- package/dist/src/dbos-runtime/config.js.map +0 -1
- package/dist/src/dbos-runtime/docker_pg_helper.d.ts.map +0 -1
- package/dist/src/dbos-runtime/docker_pg_helper.js.map +0 -1
- package/dist/src/dbos-runtime/migrate.d.ts +0 -3
- package/dist/src/dbos-runtime/migrate.d.ts.map +0 -1
- package/dist/src/dbos-runtime/migrate.js.map +0 -1
- package/dist/src/dbos-runtime/workflow_management.d.ts.map +0 -1
- package/dist/src/dbos-runtime/workflow_management.js.map +0 -1
- package/dist/src/httpServer/handler.d.ts +0 -13
- package/dist/src/httpServer/handler.d.ts.map +0 -1
- package/dist/src/httpServer/handler.js +0 -25
- package/dist/src/httpServer/handler.js.map +0 -1
- package/dist/src/httpServer/handlerTypes.d.ts +0 -14
- package/dist/src/httpServer/handlerTypes.d.ts.map +0 -1
- package/dist/src/httpServer/handlerTypes.js +0 -22
- package/dist/src/httpServer/handlerTypes.js.map +0 -1
- package/dist/src/httpServer/middleware.d.ts +0 -74
- package/dist/src/httpServer/middleware.d.ts.map +0 -1
- package/dist/src/httpServer/middleware.js +0 -108
- package/dist/src/httpServer/middleware.js.map +0 -1
- package/dist/src/httpServer/server.d.ts.map +0 -1
- package/dist/src/httpServer/server.js +0 -737
- package/dist/src/httpServer/server.js.map +0 -1
- package/dist/src/paramdecorators.d.ts +0 -39
- package/dist/src/paramdecorators.d.ts.map +0 -1
- package/dist/src/paramdecorators.js +0 -365
- package/dist/src/paramdecorators.js.map +0 -1
- package/dist/src/procedure.d.ts +0 -18
- package/dist/src/procedure.d.ts.map +0 -1
- package/dist/src/procedure.js +0 -3
- package/dist/src/procedure.js.map +0 -1
- package/dist/src/transaction.d.ts +0 -19
- package/dist/src/transaction.d.ts.map +0 -1
- package/dist/src/transaction.js +0 -11
- package/dist/src/transaction.js.map +0 -1
- package/dist/src/user_database.d.ts +0 -176
- package/dist/src/user_database.d.ts.map +0 -1
- package/dist/src/user_database.js +0 -540
- package/dist/src/user_database.js.map +0 -1
- /package/dist/src/{dbos-runtime → cli}/commands.d.ts +0 -0
- /package/dist/src/{dbos-runtime → cli}/commands.js +0 -0
- /package/dist/src/{dbos-runtime → cli}/docker_pg_helper.d.ts +0 -0
- /package/dist/src/{dbos-runtime → cli}/docker_pg_helper.js +0 -0
package/dist/src/dbos.js
CHANGED
@@ -3,39 +3,25 @@ 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.
|
6
|
+
exports.DBOS = exports.runInternalStep = exports.getExecutor = void 0;
|
7
7
|
const context_1 = require("./context");
|
8
8
|
const dbos_executor_1 = require("./dbos-executor");
|
9
9
|
const traces_1 = require("./telemetry/traces");
|
10
10
|
const workflow_1 = require("./workflow");
|
11
11
|
const logs_1 = require("./telemetry/logs");
|
12
12
|
const error_1 = require("./error");
|
13
|
-
const config_1 = require("./
|
13
|
+
const config_1 = require("./config");
|
14
14
|
const scheduler_1 = require("./scheduler/scheduler");
|
15
15
|
const decorators_1 = require("./decorators");
|
16
16
|
const utils_1 = require("./utils");
|
17
|
-
const
|
18
|
-
const user_database_1 = require("./user_database");
|
17
|
+
const adminserver_1 = require("./adminserver");
|
19
18
|
const node_crypto_1 = require("node:crypto");
|
20
|
-
const _1 = require(".");
|
21
|
-
const _2 = require(".");
|
22
|
-
const handlerTypes_1 = require("./httpServer/handlerTypes");
|
23
19
|
const conductor_1 = require("./conductor/conductor");
|
24
20
|
const system_database_1 = require("./system_database");
|
25
21
|
const wfqueue_1 = require("./wfqueue");
|
26
22
|
const authdecorators_1 = require("./authdecorators");
|
27
23
|
const node_assert_1 = __importDefault(require("node:assert"));
|
28
24
|
const api_1 = require("@opentelemetry/api");
|
29
|
-
function httpApiDec(verb, url) {
|
30
|
-
return function apidec(target, propertyKey, inDescriptor) {
|
31
|
-
const { descriptor, registration } = (0, decorators_1.wrapDBOSFunctionAndRegisterDec)(target, propertyKey, inDescriptor);
|
32
|
-
const handlerRegistration = registration;
|
33
|
-
handlerRegistration.apiURL = url;
|
34
|
-
handlerRegistration.apiType = verb;
|
35
|
-
(0, _1.requestArgValidation)(registration);
|
36
|
-
return descriptor;
|
37
|
-
};
|
38
|
-
}
|
39
25
|
function getExecutor() {
|
40
26
|
if (!dbos_executor_1.DBOSExecutor.globalInstance) {
|
41
27
|
throw new error_1.DBOSExecutorNotInitializedError();
|
@@ -64,7 +50,6 @@ class DBOS {
|
|
64
50
|
// Lifecycle
|
65
51
|
///////
|
66
52
|
static adminServer = undefined;
|
67
|
-
static appServer = undefined;
|
68
53
|
static conductor = undefined;
|
69
54
|
/**
|
70
55
|
* Set configuration of `DBOS` prior to `launch`
|
@@ -74,26 +59,6 @@ class DBOS {
|
|
74
59
|
(0, node_assert_1.default)(!DBOS.isInitialized(), 'Cannot call DBOS.setConfig after DBOS.launch');
|
75
60
|
DBOS.#dbosConfig = config;
|
76
61
|
}
|
77
|
-
/**
|
78
|
-
* Use ORMEntities to set up database schema.
|
79
|
-
* Only relevant for TypeORM, and for testing purposes only, not production
|
80
|
-
* @deprecated - use data source packages such as `@dbos-inc/typeorm-datasource`
|
81
|
-
*/
|
82
|
-
static async createUserSchema() {
|
83
|
-
return dbos_executor_1.DBOSExecutor.globalInstance?.createUserSchema();
|
84
|
-
}
|
85
|
-
/**
|
86
|
-
* Use ORMEntities to drop database schema.
|
87
|
-
* Only relevant for TypeORM, and for testing purposes only, not production
|
88
|
-
* @deprecated - use data source packages such as `@dbos-inc/typeorm-datasource`
|
89
|
-
*/
|
90
|
-
static async dropUserSchema() {
|
91
|
-
return dbos_executor_1.DBOSExecutor.globalInstance?.dropUserSchema();
|
92
|
-
}
|
93
|
-
// Load files with DBOS classes (running their decorators)
|
94
|
-
static async loadClasses(dbosEntrypointFiles) {
|
95
|
-
return await dbos_executor_1.DBOSExecutor.loadClasses(dbosEntrypointFiles);
|
96
|
-
}
|
97
62
|
/**
|
98
63
|
* Check if DBOS has been `launch`ed (and not `shutdown`)
|
99
64
|
* @returns `true` if DBOS has been launched, or `false` otherwise
|
@@ -133,8 +98,6 @@ class DBOS {
|
|
133
98
|
if (process.env.DBOS__CLOUD === 'true') {
|
134
99
|
[internalConfig, runtimeConfig] = (0, config_1.overwriteConfigForDBOSCloud)(internalConfig, runtimeConfig, configFile);
|
135
100
|
}
|
136
|
-
DBOS.#port = runtimeConfig.port;
|
137
|
-
DBOS.#userDbClient = internalConfig.userDbClient;
|
138
101
|
dbos_executor_1.DBOSExecutor.createDebouncerWorkflow();
|
139
102
|
dbos_executor_1.DBOSExecutor.createInternalQueue();
|
140
103
|
dbos_executor_1.DBOSExecutor.globalInstance = new dbos_executor_1.DBOSExecutor(internalConfig, { debugMode });
|
@@ -166,9 +129,9 @@ class DBOS {
|
|
166
129
|
// Start the DBOS admin server
|
167
130
|
const logger = DBOS.logger;
|
168
131
|
if (runtimeConfig.runAdminServer) {
|
169
|
-
const adminApp =
|
132
|
+
const adminApp = adminserver_1.DBOSAdminServer.setupAdminApp(executor);
|
170
133
|
try {
|
171
|
-
await
|
134
|
+
await adminserver_1.DBOSAdminServer.checkPortAvailabilityIPv4Ipv6(runtimeConfig.admin_port, logger);
|
172
135
|
// Wrap the listen call in a promise to properly catch errors
|
173
136
|
DBOS.adminServer = await new Promise((resolve, reject) => {
|
174
137
|
const server = adminApp.listen(runtimeConfig?.admin_port, () => {
|
@@ -195,7 +158,6 @@ class DBOS {
|
|
195
158
|
static logRegisteredEndpoints() {
|
196
159
|
if (!dbos_executor_1.DBOSExecutor.globalInstance)
|
197
160
|
return;
|
198
|
-
dbos_executor_1.DBOSExecutor.globalInstance.logRegisteredHTTPUrls();
|
199
161
|
wfqueue_1.wfQueueRunner.logRegisteredEndpoints(dbos_executor_1.DBOSExecutor.globalInstance);
|
200
162
|
for (const lcl of (0, decorators_1.getLifecycleListeners)()) {
|
201
163
|
lcl.logRegisteredEndpoints?.();
|
@@ -208,11 +170,6 @@ class DBOS {
|
|
208
170
|
* Stops workflow processing and disconnects from databases
|
209
171
|
*/
|
210
172
|
static async shutdown() {
|
211
|
-
// Stop the app server
|
212
|
-
if (DBOS.appServer) {
|
213
|
-
DBOS.appServer.close();
|
214
|
-
DBOS.appServer = undefined;
|
215
|
-
}
|
216
173
|
// Stop the admin server
|
217
174
|
if (DBOS.adminServer) {
|
218
175
|
DBOS.adminServer.close();
|
@@ -254,60 +211,10 @@ class DBOS {
|
|
254
211
|
static get #executor() {
|
255
212
|
return getExecutor();
|
256
213
|
}
|
257
|
-
/**
|
258
|
-
* Creates a node.js HTTP handler for all entrypoints registered with `@DBOS.getApi`
|
259
|
-
* and other decorators. The handler can be retrieved with `DBOS.getHTTPHandlersCallback()`.
|
260
|
-
* This method does not start listening for requests. For that, call `DBOS.launchAppHTTPServer()`.
|
261
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
262
|
-
*/
|
263
|
-
static setUpHandlerCallback() {
|
264
|
-
if (!dbos_executor_1.DBOSExecutor.globalInstance) {
|
265
|
-
throw new error_1.DBOSExecutorNotInitializedError();
|
266
|
-
}
|
267
|
-
// Create the DBOS HTTP server
|
268
|
-
// This may be a no-op if there are no registered endpoints
|
269
|
-
const server = new server_1.DBOSHttpServer(dbos_executor_1.DBOSExecutor.globalInstance);
|
270
|
-
return server;
|
271
|
-
}
|
272
|
-
/**
|
273
|
-
* Creates a node.js HTTP handler for all entrypoints registered with `@DBOS.getApi`
|
274
|
-
* and other decorators. This method also starts listening for requests, on the port
|
275
|
-
* specified in the `DBOSRuntimeConfig`.
|
276
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
277
|
-
*/
|
278
|
-
static async launchAppHTTPServer() {
|
279
|
-
const server = DBOS.setUpHandlerCallback();
|
280
|
-
if (DBOS.#port) {
|
281
|
-
// This will not listen if there's no decorated endpoint
|
282
|
-
DBOS.appServer = await server.appListen(DBOS.#port);
|
283
|
-
}
|
284
|
-
}
|
285
|
-
/**
|
286
|
-
* Retrieves the HTTP handlers callback for DBOS HTTP.
|
287
|
-
* (This is the one that handles the @DBOS.getApi, etc., methods.)
|
288
|
-
* Useful for testing purposes, or to combine the DBOS service with other
|
289
|
-
* node.js HTTP server frameworks.
|
290
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
291
|
-
*/
|
292
|
-
static getHTTPHandlersCallback() {
|
293
|
-
if (!server_1.DBOSHttpServer.instance) {
|
294
|
-
return undefined;
|
295
|
-
}
|
296
|
-
return server_1.DBOSHttpServer.instance.app.callback();
|
297
|
-
}
|
298
|
-
/** For unit testing of admin server (do not call) */
|
299
|
-
static getAdminCallback() {
|
300
|
-
if (!server_1.DBOSHttpServer.instance) {
|
301
|
-
return undefined;
|
302
|
-
}
|
303
|
-
return server_1.DBOSHttpServer.instance.adminApp.callback();
|
304
|
-
}
|
305
214
|
//////
|
306
215
|
// Globals
|
307
216
|
//////
|
308
217
|
static #dbosConfig;
|
309
|
-
static #port;
|
310
|
-
static #userDbClient;
|
311
218
|
//////
|
312
219
|
// Context
|
313
220
|
//////
|
@@ -350,23 +257,6 @@ class DBOS {
|
|
350
257
|
throw new error_1.DBOSError('`DBOS.request` accessed from outside of HTTP requests');
|
351
258
|
return r;
|
352
259
|
}
|
353
|
-
/**
|
354
|
-
* Get the current Koa context (within `@DBOS.getApi` et al)
|
355
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
356
|
-
*/
|
357
|
-
static getKoaContext() {
|
358
|
-
return (0, context_1.getCurrentContextStore)()?.koaContext;
|
359
|
-
}
|
360
|
-
/**
|
361
|
-
* Get the current Koa context (within `@DBOS.getApi` et al)
|
362
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
363
|
-
*/
|
364
|
-
static get koaContext() {
|
365
|
-
const r = DBOS.getKoaContext();
|
366
|
-
if (!r)
|
367
|
-
throw new error_1.DBOSError('`DBOS.koaContext` accessed from outside koa request');
|
368
|
-
return r;
|
369
|
-
}
|
370
260
|
/** Get the current application version */
|
371
261
|
static get applicationVersion() {
|
372
262
|
return utils_1.globalParams.appVersion;
|
@@ -406,10 +296,6 @@ class DBOS {
|
|
406
296
|
static isInTransaction() {
|
407
297
|
return (0, context_1.getCurrentContextStore)()?.curTxFunctionId !== undefined;
|
408
298
|
}
|
409
|
-
/** @returns true if called from within a stored procedure, false otherwise */
|
410
|
-
static isInStoredProc() {
|
411
|
-
return (0, context_1.getCurrentContextStore)()?.isInStoredProc ?? false;
|
412
|
-
}
|
413
299
|
/** @returns true if called from within a step, false otherwise */
|
414
300
|
static isInStep() {
|
415
301
|
return (0, context_1.getCurrentContextStore)()?.curStepFunctionId !== undefined;
|
@@ -427,111 +313,7 @@ class DBOS {
|
|
427
313
|
* a step, transaction, or procedure, or false otherwise
|
428
314
|
*/
|
429
315
|
static isInWorkflow() {
|
430
|
-
return DBOS.isWithinWorkflow() && !DBOS.isInTransaction() && !DBOS.isInStep()
|
431
|
-
}
|
432
|
-
// sql session (various forms)
|
433
|
-
/**
|
434
|
-
* @returns the current SQL client; only allowed within `@DBOS.transaction` functions
|
435
|
-
* @deprecated - use data source packages such as:
|
436
|
-
* `@dbos-inc/drizzle-datasource`
|
437
|
-
* `@dbos-inc/knex-datasource`
|
438
|
-
* `@dbos-inc/node-pg-datasource`
|
439
|
-
* `@dbos-inc/postgres-datasource`
|
440
|
-
* `@dbos-inc/prisma-datasource`
|
441
|
-
* `@dbos-inc/typeorm-datasource`
|
442
|
-
*/
|
443
|
-
static get sqlClient() {
|
444
|
-
const c = (0, context_1.getCurrentContextStore)()?.sqlClient;
|
445
|
-
if (!DBOS.isInTransaction() || !c)
|
446
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError('Invalid use of `DBOS.sqlClient` outside of a `transaction`');
|
447
|
-
return c;
|
448
|
-
}
|
449
|
-
/**
|
450
|
-
* @returns the current PG SQL client;
|
451
|
-
* only allowed within `@DBOS.transaction` functions when a `PGNODE` user database is in use
|
452
|
-
* @deprecated - use data source packages such as `@dbos-inc/node-pg-datasource`
|
453
|
-
*/
|
454
|
-
static get pgClient() {
|
455
|
-
if (!DBOS.isInStoredProc() && DBOS.#userDbClient !== user_database_1.UserDatabaseName.PGNODE) {
|
456
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.pgClient' but client is configured with type '${DBOS.#userDbClient}'`);
|
457
|
-
}
|
458
|
-
return DBOS.sqlClient;
|
459
|
-
}
|
460
|
-
/**
|
461
|
-
* @returns the current Knex SQL client;
|
462
|
-
* only allowed within `@DBOS.transaction` functions when a `KNEX` user database is in use
|
463
|
-
* @deprecated - use `@dbos-inc/knex-datasource` package
|
464
|
-
*/
|
465
|
-
static get knexClient() {
|
466
|
-
if (DBOS.isInStoredProc()) {
|
467
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.knexClient' from within a stored procedure`);
|
468
|
-
}
|
469
|
-
if (DBOS.#userDbClient !== user_database_1.UserDatabaseName.KNEX) {
|
470
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.knexClient' but client is configured with type '${DBOS.#userDbClient}'`);
|
471
|
-
}
|
472
|
-
return DBOS.sqlClient;
|
473
|
-
}
|
474
|
-
/**
|
475
|
-
* @returns the current Prisma SQL client;
|
476
|
-
* only allowed within `@DBOS.transaction` functions when a `PRISMA` user database is in use
|
477
|
-
* @deprecated - use `@dbos-inc/prisma-datasource` package
|
478
|
-
*/
|
479
|
-
static get prismaClient() {
|
480
|
-
if (DBOS.isInStoredProc()) {
|
481
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.prismaClient' from within a stored procedure`);
|
482
|
-
}
|
483
|
-
if (DBOS.#userDbClient !== user_database_1.UserDatabaseName.PRISMA) {
|
484
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.prismaClient' but client is configured with type '${DBOS.#userDbClient}'`);
|
485
|
-
}
|
486
|
-
return DBOS.sqlClient;
|
487
|
-
}
|
488
|
-
/**
|
489
|
-
* @returns the current TypeORM SQL client;
|
490
|
-
* only allowed within `@DBOS.transaction` functions when the `TYPEORM` user database is in use
|
491
|
-
* @deprecated - use `@dbos-inc/typeorm-datasource` package
|
492
|
-
*/
|
493
|
-
static get typeORMClient() {
|
494
|
-
if (DBOS.isInStoredProc()) {
|
495
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.typeORMClient' from within a stored procedure`);
|
496
|
-
}
|
497
|
-
if (DBOS.#userDbClient !== user_database_1.UserDatabaseName.TYPEORM) {
|
498
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.typeORMClient' but client is configured with type '${DBOS.#userDbClient}'`);
|
499
|
-
}
|
500
|
-
return DBOS.sqlClient;
|
501
|
-
}
|
502
|
-
/**
|
503
|
-
* @returns the current Drizzle SQL client;
|
504
|
-
* only allowed within `@DBOS.transaction` functions when the `DRIZZLE` user database is in use
|
505
|
-
* @deprecated - use `@dbos-inc/drizzle-datasource` package
|
506
|
-
*/
|
507
|
-
static get drizzleClient() {
|
508
|
-
if (DBOS.isInStoredProc()) {
|
509
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.drizzleClient' from within a stored procedure`);
|
510
|
-
}
|
511
|
-
if (DBOS.#userDbClient !== user_database_1.UserDatabaseName.DRIZZLE) {
|
512
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError(`Requested 'DBOS.drizzleClient' but client is configured with type '${DBOS.#userDbClient}'`);
|
513
|
-
}
|
514
|
-
return DBOS.sqlClient;
|
515
|
-
}
|
516
|
-
/**
|
517
|
-
* Query the current application database
|
518
|
-
* @param sql - parameterized SQL statement (string) to execute
|
519
|
-
* @param params - parameter values for `sql`
|
520
|
-
* @template T - Type for the returned records
|
521
|
-
* @returns Array of records returned by the SQL statement
|
522
|
-
* @deprecated - use data source packages such as:
|
523
|
-
* `@dbos-inc/drizzle-datasource`
|
524
|
-
* `@dbos-inc/knex-datasource`
|
525
|
-
* `@dbos-inc/node-pg-datasource`
|
526
|
-
* `@dbos-inc/postgres-datasource`
|
527
|
-
* `@dbos-inc/prisma-datasource`
|
528
|
-
* `@dbos-inc/typeorm-datasource`
|
529
|
-
*/
|
530
|
-
static async queryUserDB(sql, params) {
|
531
|
-
if (DBOS.isWithinWorkflow() && !DBOS.isInStep()) {
|
532
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError('Invalid call to `queryUserDB` inside a `workflow`, without being in a `step`');
|
533
|
-
}
|
534
|
-
return DBOS.#executor.queryUserDB(sql, params);
|
316
|
+
return DBOS.isWithinWorkflow() && !DBOS.isInTransaction() && !DBOS.isInStep();
|
535
317
|
}
|
536
318
|
//////
|
537
319
|
// Access to system DB, for event receivers etc.
|
@@ -634,19 +416,6 @@ class DBOS {
|
|
634
416
|
}
|
635
417
|
return DBOS.#executor.retrieveWorkflow(workflowID);
|
636
418
|
}
|
637
|
-
/**
|
638
|
-
* Query the system database for all workflows matching the provided predicate
|
639
|
-
* @param input - `GetWorkflowsInput` predicate for filtering returned workflows
|
640
|
-
* @returns `GetWorkflowsOutput` listing the workflow IDs of matching workflows
|
641
|
-
* @deprecated Use `DBOS.listWorkflows` instead
|
642
|
-
*/
|
643
|
-
static async getWorkflows(input) {
|
644
|
-
(0, decorators_1.ensureDBOSIsLaunched)('getWorkflows');
|
645
|
-
return await runInternalStep(async () => {
|
646
|
-
const wfs = await DBOS.#executor.listWorkflows(input);
|
647
|
-
return { workflowUUIDs: wfs.map((wf) => wf.workflowID) };
|
648
|
-
}, 'DBOS.getWorkflows');
|
649
|
-
}
|
650
419
|
/**
|
651
420
|
* Query the system database for all workflows matching the provided predicate
|
652
421
|
* @param input - `GetWorkflowsInput` predicate for filtering returned workflows
|
@@ -837,7 +606,6 @@ class DBOS {
|
|
837
606
|
return DBOS.#withTopContext({ operationCaller: callerName }, callback);
|
838
607
|
}
|
839
608
|
/**
|
840
|
-
* @deprecated
|
841
609
|
* Use queue named `queueName` for any workflows started within the `callback`.
|
842
610
|
* @param queueName - Name of queue upon which all workflows called or started within `callback` will be run
|
843
611
|
* @param callback - Function to run, which would call or start workflows
|
@@ -902,7 +670,7 @@ class DBOS {
|
|
902
670
|
static startWorkflow(target, params) {
|
903
671
|
(0, decorators_1.ensureDBOSIsLaunched)('workflows');
|
904
672
|
const instance = typeof target === 'function' ? null : target;
|
905
|
-
if (instance && typeof instance !== 'function' && !(instance instanceof
|
673
|
+
if (instance && typeof instance !== 'function' && !(instance instanceof decorators_1.ConfiguredInstance)) {
|
906
674
|
throw new error_1.DBOSInvalidWorkflowTransitionError('Attempt to call `startWorkflow` on an object that is not a `ConfiguredInstance`');
|
907
675
|
}
|
908
676
|
const regOps = (0, decorators_1.getRegisteredOperations)(target);
|
@@ -1168,7 +936,7 @@ class DBOS {
|
|
1168
936
|
const queueName = params.queueName ?? ppctx?.queueAssignedForWorkflows;
|
1169
937
|
const timeoutMS = params.timeoutMS ?? ppctx?.workflowTimeoutMS;
|
1170
938
|
const instance = $this === undefined || typeof $this === 'function' ? undefined : $this;
|
1171
|
-
if (instance && !(instance instanceof
|
939
|
+
if (instance && !(instance instanceof decorators_1.ConfiguredInstance)) {
|
1172
940
|
throw new error_1.DBOSInvalidWorkflowTransitionError('Attempt to call a `workflow` function on an object that is not a `ConfiguredInstance`');
|
1173
941
|
}
|
1174
942
|
// If this is called from within a workflow, this is a child workflow,
|
@@ -1206,10 +974,6 @@ class DBOS {
|
|
1206
974
|
const func = regOP.registeredFunction;
|
1207
975
|
return dbos_executor_1.DBOSExecutor.globalInstance.internalWorkflow(func, wfParams, workflowID, funcNum, ...args);
|
1208
976
|
}
|
1209
|
-
if (regOP.txnConfig) {
|
1210
|
-
const func = regOP.registeredFunction;
|
1211
|
-
return dbos_executor_1.DBOSExecutor.globalInstance.startTransactionTempWF(func, wfParams, workflowID, funcNum, ...args);
|
1212
|
-
}
|
1213
977
|
if (regOP.stepConfig) {
|
1214
978
|
const func = regOP.registeredFunction;
|
1215
979
|
return dbos_executor_1.DBOSExecutor.globalInstance.startStepTempWF(func, wfParams, workflowID, funcNum, ...args);
|
@@ -1236,95 +1000,6 @@ class DBOS {
|
|
1236
1000
|
});
|
1237
1001
|
return invoker;
|
1238
1002
|
}
|
1239
|
-
/**
|
1240
|
-
* Decorator designating a method as a DBOS transaction, making SQL clients available.
|
1241
|
-
* A durable execution checkpoint will be applied to to the underlying database transaction
|
1242
|
-
* @see `DBOS.sqlClient`
|
1243
|
-
* @param config - Configuration information for the transaction, particularly its isolation mode
|
1244
|
-
* @deprecated - use data source packages such as:
|
1245
|
-
* `@dbos-inc/drizzle-datasource`
|
1246
|
-
* `@dbos-inc/knex-datasource`
|
1247
|
-
* `@dbos-inc/node-pg-datasource`
|
1248
|
-
* `@dbos-inc/postgres-datasource`
|
1249
|
-
* `@dbos-inc/prisma-datasource`
|
1250
|
-
* `@dbos-inc/typeorm-datasource`
|
1251
|
-
*/
|
1252
|
-
static transaction(config = {}) {
|
1253
|
-
function decorator(target, propertyKey, inDescriptor) {
|
1254
|
-
const { descriptor, registration } = (0, decorators_1.wrapDBOSFunctionAndRegisterByUniqueNameDec)(target, propertyKey, inDescriptor);
|
1255
|
-
registration.setTxnConfig(config);
|
1256
|
-
const invokeWrapper = async function (...rawArgs) {
|
1257
|
-
(0, decorators_1.ensureDBOSIsLaunched)('transactions');
|
1258
|
-
let inst = undefined;
|
1259
|
-
if (this === undefined || typeof this === 'function') {
|
1260
|
-
// This is static
|
1261
|
-
}
|
1262
|
-
else {
|
1263
|
-
inst = this;
|
1264
|
-
if (!(inst instanceof _2.ConfiguredInstance)) {
|
1265
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError('Attempt to call a `transaction` function on an object that is not a `ConfiguredInstance`');
|
1266
|
-
}
|
1267
|
-
}
|
1268
|
-
if (DBOS.isWithinWorkflow()) {
|
1269
|
-
if (DBOS.isInTransaction()) {
|
1270
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError('Invalid call to a `transaction` function from within a `transaction`');
|
1271
|
-
}
|
1272
|
-
if (DBOS.isInStep()) {
|
1273
|
-
throw new error_1.DBOSInvalidWorkflowTransitionError('Invalid call to a `transaction` function from within a `step`');
|
1274
|
-
}
|
1275
|
-
return await dbos_executor_1.DBOSExecutor.globalInstance.callTransactionFunction(registration.registeredFunction, inst ?? null, ...rawArgs);
|
1276
|
-
}
|
1277
|
-
const wfId = (0, context_1.getNextWFID)(undefined);
|
1278
|
-
const wfParams = {
|
1279
|
-
configuredInstance: inst,
|
1280
|
-
workflowUUID: wfId,
|
1281
|
-
};
|
1282
|
-
return await DBOS.#executor.runTransactionTempWF(registration.registeredFunction, wfParams, ...rawArgs);
|
1283
|
-
};
|
1284
|
-
descriptor.value = invokeWrapper;
|
1285
|
-
registration.wrappedFunction = invokeWrapper;
|
1286
|
-
(0, decorators_1.registerFunctionWrapper)(invokeWrapper, registration);
|
1287
|
-
Object.defineProperty(invokeWrapper, 'name', {
|
1288
|
-
value: registration.name,
|
1289
|
-
});
|
1290
|
-
return descriptor;
|
1291
|
-
}
|
1292
|
-
return decorator;
|
1293
|
-
}
|
1294
|
-
/**
|
1295
|
-
* Decorator designating a method as a DBOS stored procedure.
|
1296
|
-
* Within the procedure, `DBOS.sqlClient` is available for database operations.
|
1297
|
-
* A durable execution checkpoint will be applied to to the underlying database transaction
|
1298
|
-
* @param config - Configuration information for the stored procedure, particularly its execution mode
|
1299
|
-
*/
|
1300
|
-
static storedProcedure(config = {}) {
|
1301
|
-
function decorator(target, propertyKey, inDescriptor) {
|
1302
|
-
const { descriptor, registration } = (0, decorators_1.wrapDBOSFunctionAndRegisterByUniqueNameDec)(target, propertyKey, inDescriptor);
|
1303
|
-
registration.setProcConfig(config);
|
1304
|
-
const invokeWrapper = async function (...rawArgs) {
|
1305
|
-
(0, decorators_1.ensureDBOSIsLaunched)('stored procedures');
|
1306
|
-
if (typeof this !== 'function') {
|
1307
|
-
throw new Error('Stored procedures must be static');
|
1308
|
-
}
|
1309
|
-
if (DBOS.isWithinWorkflow()) {
|
1310
|
-
return await dbos_executor_1.DBOSExecutor.globalInstance.callProcedureFunction(registration.registeredFunction, ...rawArgs);
|
1311
|
-
}
|
1312
|
-
const wfId = (0, context_1.getNextWFID)(undefined);
|
1313
|
-
const wfParams = {
|
1314
|
-
workflowUUID: wfId,
|
1315
|
-
};
|
1316
|
-
return await DBOS.#executor.runProcedureTempWF(registration.registeredFunction, wfParams, ...rawArgs);
|
1317
|
-
};
|
1318
|
-
descriptor.value = invokeWrapper;
|
1319
|
-
registration.wrappedFunction = invokeWrapper;
|
1320
|
-
(0, decorators_1.registerFunctionWrapper)(invokeWrapper, registration);
|
1321
|
-
Object.defineProperty(invokeWrapper, 'name', {
|
1322
|
-
value: registration.name,
|
1323
|
-
});
|
1324
|
-
return descriptor;
|
1325
|
-
}
|
1326
|
-
return decorator;
|
1327
|
-
}
|
1328
1003
|
/**
|
1329
1004
|
* Decorator designating a method as a DBOS step.
|
1330
1005
|
* A durable checkpoint will be made after the step completes
|
@@ -1345,7 +1020,7 @@ class DBOS {
|
|
1345
1020
|
}
|
1346
1021
|
else {
|
1347
1022
|
inst = this;
|
1348
|
-
if (!(inst instanceof
|
1023
|
+
if (!(inst instanceof decorators_1.ConfiguredInstance)) {
|
1349
1024
|
throw new error_1.DBOSInvalidWorkflowTransitionError('Attempt to call a `step` function on an object that is not a `ConfiguredInstance`');
|
1350
1025
|
}
|
1351
1026
|
}
|
@@ -1447,41 +1122,6 @@ class DBOS {
|
|
1447
1122
|
}
|
1448
1123
|
(0, utils_1.registerSerializationRecipe)(serReg);
|
1449
1124
|
}
|
1450
|
-
/**
|
1451
|
-
* Decorator indicating that the method is the target of HTTP GET operations for `url`
|
1452
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
1453
|
-
*/
|
1454
|
-
static getApi(url) {
|
1455
|
-
return httpApiDec(handlerTypes_1.APITypes.GET, url);
|
1456
|
-
}
|
1457
|
-
/**
|
1458
|
-
* Decorator indicating that the method is the target of HTTP POST operations for `url`
|
1459
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
1460
|
-
*/
|
1461
|
-
static postApi(url) {
|
1462
|
-
return httpApiDec(handlerTypes_1.APITypes.POST, url);
|
1463
|
-
}
|
1464
|
-
/**
|
1465
|
-
* Decorator indicating that the method is the target of HTTP PUT operations for `url`
|
1466
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
1467
|
-
*/
|
1468
|
-
static putApi(url) {
|
1469
|
-
return httpApiDec(handlerTypes_1.APITypes.PUT, url);
|
1470
|
-
}
|
1471
|
-
/**
|
1472
|
-
* Decorator indicating that the method is the target of HTTP PATCH operations for `url`
|
1473
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
1474
|
-
*/
|
1475
|
-
static patchApi(url) {
|
1476
|
-
return httpApiDec(handlerTypes_1.APITypes.PATCH, url);
|
1477
|
-
}
|
1478
|
-
/**
|
1479
|
-
* Decorator indicating that the method is the target of HTTP DELETE operations for `url`
|
1480
|
-
* @deprecated - use `@dbos-inc/koa-serve`
|
1481
|
-
*/
|
1482
|
-
static deleteApi(url) {
|
1483
|
-
return httpApiDec(handlerTypes_1.APITypes.DELETE, url);
|
1484
|
-
}
|
1485
1125
|
/**
|
1486
1126
|
* Decorate a class with the default list of required roles.
|
1487
1127
|
* This class-level default can be overridden on a per-function basis with `requiredRole`.
|
@@ -1542,7 +1182,7 @@ class DBOS {
|
|
1542
1182
|
* Register information to be associated with a DBOS function
|
1543
1183
|
*/
|
1544
1184
|
static associateParamWithInfo(external, func, target) {
|
1545
|
-
return (0, decorators_1.associateParameterWithExternal)(external, target.ctorOrProto, target.className, target.name ?? func
|
1185
|
+
return (0, decorators_1.associateParameterWithExternal)(external, target.ctorOrProto, target.className, target.name ?? func?.name ?? '<unknown>', func, target.param);
|
1546
1186
|
}
|
1547
1187
|
/** Get registrations */
|
1548
1188
|
static getAssociatedInfo(external, cls, funcName) {
|
@@ -1550,19 +1190,4 @@ class DBOS {
|
|
1550
1190
|
}
|
1551
1191
|
}
|
1552
1192
|
exports.DBOS = DBOS;
|
1553
|
-
/** @deprecated */
|
1554
|
-
class InitContext {
|
1555
|
-
createUserSchema() {
|
1556
|
-
DBOS.logger.warn('Schema synchronization is deprecated and unsafe for production use. Please use migrations instead: https://typeorm.io/migrations');
|
1557
|
-
return DBOS.createUserSchema();
|
1558
|
-
}
|
1559
|
-
dropUserSchema() {
|
1560
|
-
DBOS.logger.warn('Schema synchronization is deprecated and unsafe for production use. Please use migrations instead: https://typeorm.io/migrations');
|
1561
|
-
return DBOS.dropUserSchema();
|
1562
|
-
}
|
1563
|
-
queryUserDB(sql, ...params) {
|
1564
|
-
return DBOS.queryUserDB(sql, params);
|
1565
|
-
}
|
1566
|
-
}
|
1567
|
-
exports.InitContext = InitContext;
|
1568
1193
|
//# sourceMappingURL=dbos.js.map
|