@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.
- package/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
- package/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
- package/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
- package/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
- package/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
- package/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
- package/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
- package/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
- package/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/register-app.js +1 -2
- package/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
- package/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/update-app.js +1 -2
- package/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
- package/dist/packages/dbos-cloud/cli.js +0 -12
- package/dist/packages/dbos-cloud/cli.js.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
- package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.js +44 -3
- package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
- package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/login.js +3 -4
- package/dist/packages/dbos-cloud/login.js.map +1 -1
- package/dist/packages/dbos-cloud/register.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/register.js +1 -2
- package/dist/packages/dbos-cloud/register.js.map +1 -1
- package/dist/packages/dbos-cloud/userdb.d.ts +0 -2
- package/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/userdb.js +4 -177
- package/dist/packages/dbos-cloud/userdb.js.map +1 -1
- package/dist/src/context.d.ts +1 -0
- package/dist/src/context.d.ts.map +1 -1
- package/dist/src/dbos-runtime/cli.d.ts.map +1 -1
- package/dist/src/dbos-runtime/cli.js +14 -0
- package/dist/src/dbos-runtime/cli.js.map +1 -1
- package/dist/src/dbos-runtime/migrate.d.ts +3 -0
- package/dist/src/dbos-runtime/migrate.d.ts.map +1 -0
- package/dist/src/dbos-runtime/migrate.js +175 -0
- package/dist/src/dbos-runtime/migrate.js.map +1 -0
- package/dist/src/httpServer/server.d.ts +2 -1
- package/dist/src/httpServer/server.d.ts.map +1 -1
- package/dist/src/system_database.d.ts +2 -0
- package/dist/src/system_database.d.ts.map +1 -1
- package/dist/src/system_database.js +26 -11
- package/dist/src/system_database.js.map +1 -1
- package/dist/src/testing/testing_runtime.d.ts +2 -1
- package/dist/src/testing/testing_runtime.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +20 -4
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/examples/hello/start_postgres_docker.sh +1 -1
- package/migrations/20240123182943_schema.js +8 -0
- package/migrations/20240123183021_tables.js +48 -0
- package/migrations/20240123183025_indexes.js +14 -0
- package/migrations/20240123183030_triggers.js +39 -0
- package/package.json +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js +1 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/delete-app.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js +5 -7
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js +1 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/get-app-logs.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js +1 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js +1 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/register-app.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js +1 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/applications/update-app.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/cli.js +0 -12
- package/packages/dbos-cloud/dist/packages/dbos-cloud/cli.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts +7 -0
- package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js +44 -3
- package/packages/dbos-cloud/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/login.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js +3 -4
- package/packages/dbos-cloud/dist/packages/dbos-cloud/login.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/register.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js +1 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/register.js.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts +0 -2
- package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js +4 -177
- package/packages/dbos-cloud/dist/packages/dbos-cloud/userdb.js.map +1 -1
- package/packages/dbos-cloud/dist/src/utils.d.ts +1 -1
- package/packages/dbos-cloud/dist/src/utils.d.ts.map +1 -1
- package/packages/dbos-cloud/dist/src/utils.js +20 -4
- package/packages/dbos-cloud/dist/src/utils.js.map +1 -1
- package/packages/dbos-cloud/package.json +1 -1
- package/packages/dbos-openapi/package.json +1 -1
- package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts +0 -34
- package/packages/dbos-cloud/dist/schemas/system_db_schema.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/schemas/system_db_schema.js +0 -77
- package/packages/dbos-cloud/dist/schemas/system_db_schema.js.map +0 -1
- package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts +0 -11
- package/packages/dbos-cloud/dist/schemas/user_db_schema.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/schemas/user_db_schema.js +0 -16
- package/packages/dbos-cloud/dist/schemas/user_db_schema.js.map +0 -1
- package/packages/dbos-cloud/dist/src/communicator.d.ts +0 -25
- package/packages/dbos-cloud/dist/src/communicator.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/communicator.js +0 -26
- package/packages/dbos-cloud/dist/src/communicator.js.map +0 -1
- package/packages/dbos-cloud/dist/src/context.d.ts +0 -64
- package/packages/dbos-cloud/dist/src/context.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/context.js +0 -96
- package/packages/dbos-cloud/dist/src/context.js.map +0 -1
- package/packages/dbos-cloud/dist/src/data_validation.d.ts +0 -3
- package/packages/dbos-cloud/dist/src/data_validation.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/data_validation.js +0 -168
- package/packages/dbos-cloud/dist/src/data_validation.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-executor.d.ts +0 -102
- package/packages/dbos-cloud/dist/src/dbos-executor.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-executor.js +0 -631
- package/packages/dbos-cloud/dist/src/dbos-executor.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts +0 -3
- package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js +0 -13
- package/packages/dbos-cloud/dist/src/dbos-runtime/applicationVersion.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts +0 -8
- package/packages/dbos-cloud/dist/src/dbos-runtime/cli.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js +0 -47
- package/packages/dbos-cloud/dist/src/dbos-runtime/cli.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts +0 -29
- package/packages/dbos-cloud/dist/src/dbos-runtime/config.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/config.js +0 -111
- package/packages/dbos-cloud/dist/src/dbos-runtime/config.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts +0 -4
- package/packages/dbos-cloud/dist/src/dbos-runtime/debug.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js +0 -21
- package/packages/dbos-cloud/dist/src/dbos-runtime/debug.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts +0 -7
- package/packages/dbos-cloud/dist/src/dbos-runtime/init.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/init.js +0 -51
- package/packages/dbos-cloud/dist/src/dbos-runtime/init.js.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts +0 -28
- package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js +0 -95
- package/packages/dbos-cloud/dist/src/dbos-runtime/runtime.js.map +0 -1
- package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts +0 -38
- package/packages/dbos-cloud/dist/src/debugger/debug_workflow.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js +0 -211
- package/packages/dbos-cloud/dist/src/debugger/debug_workflow.js.map +0 -1
- package/packages/dbos-cloud/dist/src/decorators.d.ts +0 -118
- package/packages/dbos-cloud/dist/src/decorators.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/decorators.js +0 -467
- package/packages/dbos-cloud/dist/src/decorators.js.map +0 -1
- package/packages/dbos-cloud/dist/src/error.d.ts +0 -47
- package/packages/dbos-cloud/dist/src/error.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/error.js +0 -171
- package/packages/dbos-cloud/dist/src/error.js.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts +0 -54
- package/packages/dbos-cloud/dist/src/httpServer/handler.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/handler.js +0 -175
- package/packages/dbos-cloud/dist/src/httpServer/handler.js.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts +0 -11
- package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js +0 -19
- package/packages/dbos-cloud/dist/src/httpServer/handlerTypes.js.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts +0 -56
- package/packages/dbos-cloud/dist/src/httpServer/middleware.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/middleware.js +0 -57
- package/packages/dbos-cloud/dist/src/httpServer/middleware.js.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/server.d.ts +0 -45
- package/packages/dbos-cloud/dist/src/httpServer/server.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/httpServer/server.js +0 -253
- package/packages/dbos-cloud/dist/src/httpServer/server.js.map +0 -1
- package/packages/dbos-cloud/dist/src/system_database.d.ts +0 -89
- package/packages/dbos-cloud/dist/src/system_database.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/system_database.js +0 -447
- package/packages/dbos-cloud/dist/src/system_database.js.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts +0 -16
- package/packages/dbos-cloud/dist/src/telemetry/collector.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/collector.js +0 -65
- package/packages/dbos-cloud/dist/src/telemetry/collector.js.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts +0 -15
- package/packages/dbos-cloud/dist/src/telemetry/exporters.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/exporters.js +0 -59
- package/packages/dbos-cloud/dist/src/telemetry/exporters.js.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/index.d.ts +0 -11
- package/packages/dbos-cloud/dist/src/telemetry/index.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/index.js +0 -19
- package/packages/dbos-cloud/dist/src/telemetry/index.js.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts +0 -47
- package/packages/dbos-cloud/dist/src/telemetry/logs.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/logs.js +0 -195
- package/packages/dbos-cloud/dist/src/telemetry/logs.js.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts +0 -14
- package/packages/dbos-cloud/dist/src/telemetry/traces.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/telemetry/traces.js +0 -52
- package/packages/dbos-cloud/dist/src/telemetry/traces.js.map +0 -1
- package/packages/dbos-cloud/dist/src/transaction.d.ts +0 -29
- package/packages/dbos-cloud/dist/src/transaction.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/transaction.js +0 -27
- package/packages/dbos-cloud/dist/src/transaction.js.map +0 -1
- package/packages/dbos-cloud/dist/src/user_database.d.ts +0 -132
- package/packages/dbos-cloud/dist/src/user_database.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/user_database.js +0 -332
- package/packages/dbos-cloud/dist/src/user_database.js.map +0 -1
- package/packages/dbos-cloud/dist/src/workflow.d.ts +0 -195
- package/packages/dbos-cloud/dist/src/workflow.d.ts.map +0 -1
- package/packages/dbos-cloud/dist/src/workflow.js +0 -498
- package/packages/dbos-cloud/dist/src/workflow.js.map +0 -1
@@ -1,96 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.InitContext = exports.DBOSContextImpl = void 0;
|
4
|
-
const logs_1 = require("./telemetry/logs");
|
5
|
-
const lodash_1 = require("lodash");
|
6
|
-
const error_1 = require("./error");
|
7
|
-
class DBOSContextImpl {
|
8
|
-
operationName;
|
9
|
-
span;
|
10
|
-
request = {}; // Raw incoming HTTP request.
|
11
|
-
authenticatedUser = ""; // The user that has been authenticated
|
12
|
-
authenticatedRoles = []; // All roles the user has according to authentication
|
13
|
-
assumedRole = ""; // Role in use - that user has and provided authorization to current function
|
14
|
-
workflowUUID = ""; // Workflow UUID. Empty for HandlerContexts.
|
15
|
-
executorID = "local"; // Executor ID. Gathered from request headers and "local" otherwise
|
16
|
-
logger; // Wrapper around the global logger for this context.
|
17
|
-
constructor(operationName, span, logger, parentCtx) {
|
18
|
-
this.operationName = operationName;
|
19
|
-
this.span = span;
|
20
|
-
if (parentCtx) {
|
21
|
-
this.request = parentCtx.request;
|
22
|
-
this.authenticatedUser = parentCtx.authenticatedUser;
|
23
|
-
this.authenticatedRoles = parentCtx.authenticatedRoles;
|
24
|
-
this.assumedRole = parentCtx.assumedRole;
|
25
|
-
this.workflowUUID = parentCtx.workflowUUID;
|
26
|
-
this.executorID = parentCtx.executorID;
|
27
|
-
}
|
28
|
-
this.logger = new logs_1.Logger(logger, this);
|
29
|
-
}
|
30
|
-
/*** Application configuration ***/
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
32
|
-
applicationConfig;
|
33
|
-
getConfig(key, defaultValue) {
|
34
|
-
// If there is no application config at all, or the key is missing, return the default value or undefined.
|
35
|
-
if (!this.applicationConfig || !(0, lodash_1.has)(this.applicationConfig, key)) {
|
36
|
-
if (defaultValue) {
|
37
|
-
return defaultValue;
|
38
|
-
}
|
39
|
-
return undefined;
|
40
|
-
}
|
41
|
-
// If the key is found and the default value is provided, check whether the value is of the same type.
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
43
|
-
const value = (0, lodash_1.get)(this.applicationConfig, key);
|
44
|
-
if (defaultValue && typeof value !== typeof defaultValue) {
|
45
|
-
throw new error_1.DBOSConfigKeyTypeError(key, typeof defaultValue, typeof value);
|
46
|
-
}
|
47
|
-
return value;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
exports.DBOSContextImpl = DBOSContextImpl;
|
51
|
-
/**
|
52
|
-
* TODO : move logger and application, getConfig to a BaseContext which is at the root of all contexts
|
53
|
-
*/
|
54
|
-
class InitContext {
|
55
|
-
dbosExec;
|
56
|
-
logger;
|
57
|
-
// All private Not exposed
|
58
|
-
userDatabase;
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
60
|
-
application;
|
61
|
-
constructor(dbosExec) {
|
62
|
-
this.dbosExec = dbosExec;
|
63
|
-
this.logger = dbosExec.logger;
|
64
|
-
this.userDatabase = dbosExec.userDatabase;
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
66
|
-
this.application = dbosExec.config.application;
|
67
|
-
}
|
68
|
-
createUserSchema() {
|
69
|
-
return this.userDatabase.createSchema();
|
70
|
-
}
|
71
|
-
dropUserSchema() {
|
72
|
-
return this.userDatabase.dropSchema();
|
73
|
-
}
|
74
|
-
queryUserDB(sql, ...params) {
|
75
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
76
|
-
return this.userDatabase.query(sql, ...params);
|
77
|
-
}
|
78
|
-
getConfig(key, defaultValue) {
|
79
|
-
// If there is no application config at all, or the key is missing, return the default value or undefined.
|
80
|
-
if (!this.application || !(0, lodash_1.has)(this.application, key)) {
|
81
|
-
if (defaultValue) {
|
82
|
-
return defaultValue;
|
83
|
-
}
|
84
|
-
return undefined;
|
85
|
-
}
|
86
|
-
// If the key is found and the default value is provided, check whether the value is of the same type.
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
88
|
-
const value = (0, lodash_1.get)(this.dbosExec.config.application, key);
|
89
|
-
if (defaultValue && typeof value !== typeof defaultValue) {
|
90
|
-
throw new error_1.DBOSConfigKeyTypeError(key, typeof defaultValue, typeof value);
|
91
|
-
}
|
92
|
-
return value;
|
93
|
-
}
|
94
|
-
}
|
95
|
-
exports.InitContext = InitContext;
|
96
|
-
//# sourceMappingURL=context.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/context.ts"],"names":[],"mappings":";;;AACA,2CAAgF;AAChF,mCAAkC;AAKlC,mCAAiD;AA8BjD,MAAa,eAAe;IASL;IAAgC;IARrD,OAAO,GAAgB,EAAE,CAAC,CAAU,6BAA6B;IACjE,iBAAiB,GAAW,EAAE,CAAC,CAAK,uCAAuC;IAC3E,kBAAkB,GAAa,EAAE,CAAC,CAAE,qDAAqD;IACzF,WAAW,GAAW,EAAE,CAAC,CAAW,6EAA6E;IACjH,YAAY,GAAW,EAAE,CAAC,CAAU,4CAA4C;IAChF,UAAU,GAAW,OAAO,CAAC,CAAO,mEAAmE;IAC9F,MAAM,CAAa,CAAM,qDAAqD;IAEvF,YAAqB,aAAqB,EAAW,IAAU,EAAE,MAAc,E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CAAC;QAED,OAAO,KAAU,CAAC;IACpB,CAAC;CACF;AAjDD,kCAiDC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"data_validation.d.ts","sourceRoot":"","sources":["../../../../src/data_validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAsB,MAAM,cAAc,CAAC;AAI1E,wBAAgB,kBAAkB,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,IAAI,QA4KrG"}
|
@@ -1,168 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.validateMethodArgs = void 0;
|
4
|
-
const decorators_1 = require("./decorators");
|
5
|
-
const error_1 = require("./error");
|
6
|
-
function validateMethodArgs(methReg, args) {
|
7
|
-
let opCtx = undefined;
|
8
|
-
const validationError = (msg) => {
|
9
|
-
const err = new error_1.DBOSDataValidationError(msg);
|
10
|
-
opCtx?.span.addEvent("DataValidationError", { message: err.message });
|
11
|
-
return err;
|
12
|
-
};
|
13
|
-
// Input validation
|
14
|
-
methReg.args.forEach((argDescriptor, idx) => {
|
15
|
-
if (idx === 0) {
|
16
|
-
// Context, may find a more robust way.
|
17
|
-
opCtx = args[idx];
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
// Do we have an arg at all
|
21
|
-
if (idx >= args.length) {
|
22
|
-
if (argDescriptor.required === decorators_1.ArgRequiredOptions.REQUIRED ||
|
23
|
-
argDescriptor.required === decorators_1.ArgRequiredOptions.DEFAULT && methReg.defaults?.defaultArgRequired === decorators_1.ArgRequiredOptions.REQUIRED) {
|
24
|
-
throw validationError(`Insufficient number of arguments calling ${methReg.name} - ${args.length}/${methReg.args.length}`);
|
25
|
-
}
|
26
|
-
return;
|
27
|
-
}
|
28
|
-
let argValue = args[idx];
|
29
|
-
// So... there is such a thing as "undefined", and another thing called "null"
|
30
|
-
// We will fold this to "undefined" for our APIs. It's just a rule of ours.
|
31
|
-
if (argValue === null) {
|
32
|
-
argValue = undefined;
|
33
|
-
args[idx] = undefined;
|
34
|
-
}
|
35
|
-
if (argValue === undefined && (argDescriptor.required === decorators_1.ArgRequiredOptions.REQUIRED ||
|
36
|
-
(argDescriptor.required === decorators_1.ArgRequiredOptions.DEFAULT && methReg.defaults?.defaultArgRequired === decorators_1.ArgRequiredOptions.REQUIRED))) {
|
37
|
-
throw validationError(`Missing required argument ${argDescriptor.name} of ${methReg.name}`);
|
38
|
-
}
|
39
|
-
if (argValue === undefined) {
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
if (argValue instanceof String) {
|
43
|
-
argValue = argValue.toString();
|
44
|
-
args[idx] = argValue;
|
45
|
-
}
|
46
|
-
if (argValue instanceof Boolean) {
|
47
|
-
argValue = argValue.valueOf();
|
48
|
-
args[idx] = argValue;
|
49
|
-
}
|
50
|
-
if (argValue instanceof Number) {
|
51
|
-
argValue = argValue.valueOf();
|
52
|
-
args[idx] = argValue;
|
53
|
-
}
|
54
|
-
if (argValue instanceof BigInt) { // ES2020+
|
55
|
-
argValue = argValue.valueOf();
|
56
|
-
args[idx] = argValue;
|
57
|
-
}
|
58
|
-
// Maybe look into https://www.npmjs.com/package/validator
|
59
|
-
// We could support emails and other validations too with something like that...
|
60
|
-
if (argDescriptor.dataType.dataType === 'text' || argDescriptor.dataType.dataType === 'varchar') {
|
61
|
-
if ((typeof argValue !== 'string')) {
|
62
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and should be a string`);
|
63
|
-
}
|
64
|
-
if (argDescriptor.dataType.length > 0) {
|
65
|
-
if (argValue.length > argDescriptor.dataType.length) {
|
66
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' with maximum length ${argDescriptor.dataType.length} but has length ${argValue.length}`);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
if (argDescriptor.dataType.dataType === 'boolean') {
|
71
|
-
if (typeof argValue !== 'boolean') {
|
72
|
-
if (typeof argValue == 'number') {
|
73
|
-
if (argValue === 0 || argValue === 1) {
|
74
|
-
argValue = (argValue != 0 ? true : false);
|
75
|
-
args[idx] = argValue;
|
76
|
-
}
|
77
|
-
else {
|
78
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and may be a number (0 or 1) convertible to boolean, but was ${argValue}.`);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
else if (typeof argValue == 'string') {
|
82
|
-
if (argValue.toLowerCase() === 't' || argValue.toLowerCase() === 'true' || argValue === '1') {
|
83
|
-
argValue = true;
|
84
|
-
args[idx] = argValue;
|
85
|
-
}
|
86
|
-
else if (argValue.toLowerCase() === 'f' || argValue.toLowerCase() === 'false' || argValue === '0') {
|
87
|
-
argValue = false;
|
88
|
-
args[idx] = argValue;
|
89
|
-
}
|
90
|
-
else {
|
91
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and may be a string convertible to boolean, but was ${argValue}.`);
|
92
|
-
}
|
93
|
-
}
|
94
|
-
else {
|
95
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and should be a boolean`);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
}
|
99
|
-
if (argDescriptor.dataType.dataType === 'decimal') {
|
100
|
-
// Range check precision and scale... wishing there was a bigdecimal
|
101
|
-
// Floats don't really permit us to check the scale.
|
102
|
-
if (typeof argValue !== 'number') {
|
103
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and should be a number`);
|
104
|
-
}
|
105
|
-
let prec = argDescriptor.dataType.precision;
|
106
|
-
if (prec > 0) {
|
107
|
-
if (argDescriptor.dataType.scale > 0) {
|
108
|
-
prec = prec - argDescriptor.dataType.scale;
|
109
|
-
}
|
110
|
-
if (Math.abs(argValue) >= Math.exp(prec)) {
|
111
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is out of range for type '${argDescriptor.dataType.formatAsString()}`);
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
115
|
-
if (argDescriptor.dataType.dataType === 'double' || argDescriptor.dataType.dataType === 'integer') {
|
116
|
-
if (typeof argValue !== 'number') {
|
117
|
-
if (typeof argValue === 'string') {
|
118
|
-
const n = parseFloat(argValue);
|
119
|
-
if (isNaN(n)) {
|
120
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and should be a number`);
|
121
|
-
}
|
122
|
-
argValue = n;
|
123
|
-
args[idx] = argValue;
|
124
|
-
}
|
125
|
-
else if (typeof argValue === 'bigint') {
|
126
|
-
// Hum, maybe we should allow bigint as a type, number won't even do 64-bit.
|
127
|
-
argValue = Number(argValue).valueOf();
|
128
|
-
args[idx] = argValue;
|
129
|
-
}
|
130
|
-
else {
|
131
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' and should be a number`);
|
132
|
-
}
|
133
|
-
}
|
134
|
-
if (argDescriptor.dataType.dataType === 'integer') {
|
135
|
-
if (!Number.isInteger(argValue)) {
|
136
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' but has a fractional part`);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
if (argDescriptor.dataType.dataType === 'timestamp') {
|
141
|
-
if (!(argValue instanceof Date)) {
|
142
|
-
if (typeof argValue == 'string') {
|
143
|
-
const d = Date.parse(argValue);
|
144
|
-
if (isNaN(d)) {
|
145
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' but is a string that will not parse as Date`);
|
146
|
-
}
|
147
|
-
argValue = new Date(d);
|
148
|
-
args[idx] = argValue;
|
149
|
-
}
|
150
|
-
else {
|
151
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' but is not a date or time`);
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}
|
155
|
-
if (argDescriptor.dataType.dataType === 'uuid') {
|
156
|
-
// This validation is loose. A tighter one would be:
|
157
|
-
// /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/
|
158
|
-
// That matches UUID version 1-5.
|
159
|
-
if (!/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(String(argValue))) {
|
160
|
-
throw validationError(`Argument ${argDescriptor.name} of ${methReg.name} is marked as type '${argDescriptor.dataType.dataType}' but is not a valid UUID`);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
// JSON can be anything. We can validate it against a schema at some later version...
|
164
|
-
});
|
165
|
-
return args;
|
166
|
-
}
|
167
|
-
exports.validateMethodArgs = validateMethodArgs;
|
168
|
-
//# sourceMappingURL=data_validation.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"data_validation.js","sourceRoot":"","sources":["../../../../src/data_validation.ts"],"names":[],"mappings":";;;AAAA,6CAA0E;AAE1E,mCAAkD;AAElD,SAAgB,kBAAkB,CAAyB,OAA+B,EAAE,IAAU;IAElG,IAAI,KAAK,GAAiC,SAAS,CAAC;IAEpD,MAAM,eAAe,GAAG,CAAC,GAAU,EAAE,EAAE;QACnC,MAAM,GAAG,GAAG,IAAI,+BAAuB,CAAC,GAAG,CAAC,CAAC;QAC7C,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC,CAAA;IAED,mBAAmB;I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102 +0,0 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
import { Workflow, WorkflowConfig, WorkflowHandle, WorkflowParams, BufferedResult } from './workflow';
|
3
|
-
import { Transaction, TransactionConfig } from './transaction';
|
4
|
-
import { CommunicatorConfig, Communicator } from './communicator';
|
5
|
-
import { TelemetryCollector } from './telemetry/collector';
|
6
|
-
import { Tracer } from './telemetry/traces';
|
7
|
-
import { GlobalLogger as Logger } from './telemetry/logs';
|
8
|
-
import { TelemetryConfig } from './telemetry';
|
9
|
-
import { PoolConfig } from 'pg';
|
10
|
-
import { SystemDatabase } from './system_database';
|
11
|
-
import { UserDatabase, UserDatabaseName } from './user_database';
|
12
|
-
import { MethodRegistrationBase } from './decorators';
|
13
|
-
export interface DBOSNull {
|
14
|
-
}
|
15
|
-
export declare const dbosNull: DBOSNull;
|
16
|
-
export declare const DBOSExecutorIDHeader = "dbos-executor-id";
|
17
|
-
export interface DBOSConfig {
|
18
|
-
readonly poolConfig: PoolConfig;
|
19
|
-
readonly userDbclient?: UserDatabaseName;
|
20
|
-
readonly telemetry?: TelemetryConfig;
|
21
|
-
readonly system_database: string;
|
22
|
-
readonly observability_database?: string;
|
23
|
-
readonly application?: any;
|
24
|
-
readonly dbClientMetadata?: any;
|
25
|
-
readonly debugProxy?: string;
|
26
|
-
}
|
27
|
-
interface WorkflowInfo {
|
28
|
-
workflow: Workflow<any, any>;
|
29
|
-
config: WorkflowConfig;
|
30
|
-
}
|
31
|
-
interface TransactionInfo {
|
32
|
-
transaction: Transaction<any, any>;
|
33
|
-
config: TransactionConfig;
|
34
|
-
}
|
35
|
-
interface CommunicatorInfo {
|
36
|
-
communicator: Communicator<any, any>;
|
37
|
-
config: CommunicatorConfig;
|
38
|
-
}
|
39
|
-
export declare const OperationType: {
|
40
|
-
readonly HANDLER: "handler";
|
41
|
-
readonly WORKFLOW: "workflow";
|
42
|
-
readonly TRANSACTION: "transaction";
|
43
|
-
readonly COMMUNICATOR: "communicator";
|
44
|
-
};
|
45
|
-
export declare class DBOSExecutor {
|
46
|
-
#private;
|
47
|
-
readonly config: DBOSConfig;
|
48
|
-
initialized: boolean;
|
49
|
-
userDatabase: UserDatabase;
|
50
|
-
readonly systemDatabase: SystemDatabase;
|
51
|
-
static readonly tempWorkflowName = "temp_workflow";
|
52
|
-
readonly workflowInfoMap: Map<string, WorkflowInfo>;
|
53
|
-
readonly transactionInfoMap: Map<string, TransactionInfo>;
|
54
|
-
readonly communicatorInfoMap: Map<string, CommunicatorInfo>;
|
55
|
-
readonly registeredOperations: Array<MethodRegistrationBase>;
|
56
|
-
readonly pendingWorkflowMap: Map<string, Promise<unknown>>;
|
57
|
-
readonly workflowResultBuffer: Map<string, Map<number, BufferedResult>>;
|
58
|
-
readonly telemetryCollector: TelemetryCollector;
|
59
|
-
readonly flushBufferIntervalMs: number;
|
60
|
-
readonly flushBufferID: NodeJS.Timeout;
|
61
|
-
static readonly defaultNotificationTimeoutSec = 60;
|
62
|
-
readonly debugMode: boolean;
|
63
|
-
static systemDBSchemaName: string;
|
64
|
-
readonly logger: Logger;
|
65
|
-
readonly tracer: Tracer;
|
66
|
-
entities: Function[];
|
67
|
-
constructor(config: DBOSConfig, systemDatabase?: SystemDatabase);
|
68
|
-
configureDbClient(): void;
|
69
|
-
init(...classes: object[]): Promise<void>;
|
70
|
-
destroy(): Promise<void>;
|
71
|
-
workflow<T extends any[], R>(wf: Workflow<T, R>, params: WorkflowParams, ...args: T): Promise<WorkflowHandle<R>>;
|
72
|
-
internalWorkflow<T extends any[], R>(wf: Workflow<T, R>, params: WorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
73
|
-
/**
|
74
|
-
* DEBUG MODE workflow execution, skipping all the recording
|
75
|
-
*/
|
76
|
-
debugWorkflow<T extends any[], R>(wf: Workflow<T, R>, params: WorkflowParams, callerUUID?: string, callerFunctionID?: number, ...args: T): Promise<WorkflowHandle<R>>;
|
77
|
-
transaction<T extends any[], R>(txn: Transaction<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
78
|
-
external<T extends any[], R>(commFn: Communicator<T, R>, params: WorkflowParams, ...args: T): Promise<R>;
|
79
|
-
send<T extends NonNullable<any>>(destinationUUID: string, message: T, topic?: string, idempotencyKey?: string): Promise<void>;
|
80
|
-
/**
|
81
|
-
* Wait for a workflow to emit an event, then return its value.
|
82
|
-
*/
|
83
|
-
getEvent<T extends NonNullable<any>>(workflowUUID: string, key: string, timeoutSeconds?: number): Promise<T | null>;
|
84
|
-
/**
|
85
|
-
* Retrieve a handle for a workflow UUID.
|
86
|
-
*/
|
87
|
-
retrieveWorkflow<R>(workflowUUID: string): WorkflowHandle<R>;
|
88
|
-
/**
|
89
|
-
* A recovery process that by default runs during executor init time.
|
90
|
-
* It runs to completion all pending workflows that were executing when the previous executor failed.
|
91
|
-
*/
|
92
|
-
recoverPendingWorkflows(executorIDs?: string[]): Promise<WorkflowHandle<any>[]>;
|
93
|
-
executeWorkflowUUID(workflowUUID: string): Promise<WorkflowHandle<unknown>>;
|
94
|
-
/**
|
95
|
-
* Periodically flush the workflow output buffer to the system database.
|
96
|
-
*/
|
97
|
-
flushWorkflowBuffers(): Promise<void>;
|
98
|
-
flushWorkflowResultBuffer(): Promise<void>;
|
99
|
-
logRegisteredHTTPUrls(): void;
|
100
|
-
}
|
101
|
-
export {};
|
102
|
-
//# sourceMappingURL=dbos-executor.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"dbos-executor.d.ts","sourceRoot":"","sources":["../../../../src/dbos-executor.ts"],"names":[],"mappings":";AAQA,OAAO,EAEL,QAAQ,EACR,cAAc,EAEd,cAAc,EACd,cAAc,EAKd,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,kBAAkB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