@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.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dbos-config.schema.json +121 -0
- package/dbos-test-config.yaml +16 -0
- package/dist/schemas/system_db_schema.d.ts +34 -0
- package/dist/schemas/system_db_schema.d.ts.map +1 -0
- package/dist/schemas/system_db_schema.js +75 -0
- package/dist/schemas/system_db_schema.js.map +1 -0
- package/dist/schemas/user_db_schema.d.ts +11 -0
- package/dist/schemas/user_db_schema.d.ts.map +1 -0
- package/dist/schemas/user_db_schema.js +16 -0
- package/dist/schemas/user_db_schema.js.map +1 -0
- package/dist/src/cloud-cli/applications/configure.d.ts +2 -0
- package/dist/src/cloud-cli/applications/configure.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/configure.js +57 -0
- package/dist/src/cloud-cli/applications/configure.js.map +1 -0
- package/dist/src/cloud-cli/applications/delete-app.d.ts +2 -0
- package/dist/src/cloud-cli/applications/delete-app.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/delete-app.js +36 -0
- package/dist/src/cloud-cli/applications/delete-app.js.map +1 -0
- package/dist/src/cloud-cli/applications/deploy-app-code.d.ts +2 -0
- package/dist/src/cloud-cli/applications/deploy-app-code.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/deploy-app-code.js +64 -0
- package/dist/src/cloud-cli/applications/deploy-app-code.js.map +1 -0
- package/dist/src/cloud-cli/applications/get-app-logs.d.ts +2 -0
- package/dist/src/cloud-cli/applications/get-app-logs.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/get-app-logs.js +37 -0
- package/dist/src/cloud-cli/applications/get-app-logs.js.map +1 -0
- package/dist/src/cloud-cli/applications/index.d.ts +8 -0
- package/dist/src/cloud-cli/applications/index.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/index.js +18 -0
- package/dist/src/cloud-cli/applications/index.js.map +1 -0
- package/dist/src/cloud-cli/applications/list-apps.d.ts +2 -0
- package/dist/src/cloud-cli/applications/list-apps.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/list-apps.js +45 -0
- package/dist/src/cloud-cli/applications/list-apps.js.map +1 -0
- package/dist/src/cloud-cli/applications/register-app.d.ts +2 -0
- package/dist/src/cloud-cli/applications/register-app.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/register-app.js +41 -0
- package/dist/src/cloud-cli/applications/register-app.js.map +1 -0
- package/dist/src/cloud-cli/applications/types.d.ts +7 -0
- package/dist/src/cloud-cli/applications/types.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/types.js +3 -0
- package/dist/src/cloud-cli/applications/types.js.map +1 -0
- package/dist/src/cloud-cli/applications/update-app.d.ts +2 -0
- package/dist/src/cloud-cli/applications/update-app.d.ts.map +1 -0
- package/dist/src/cloud-cli/applications/update-app.js +42 -0
- package/dist/src/cloud-cli/applications/update-app.js.map +1 -0
- package/dist/src/cloud-cli/cli.d.ts +3 -0
- package/dist/src/cloud-cli/cli.d.ts.map +1 -0
- package/dist/src/cloud-cli/cli.js +148 -0
- package/dist/src/cloud-cli/cli.js.map +1 -0
- package/dist/src/cloud-cli/login.d.ts +7 -0
- package/dist/src/cloud-cli/login.d.ts.map +1 -0
- package/dist/src/cloud-cli/login.js +40 -0
- package/dist/src/cloud-cli/login.js.map +1 -0
- package/dist/src/cloud-cli/register.d.ts +2 -0
- package/dist/src/cloud-cli/register.d.ts.map +1 -0
- package/dist/src/cloud-cli/register.js +35 -0
- package/dist/src/cloud-cli/register.js.map +1 -0
- package/dist/src/cloud-cli/userdb.d.ts +4 -0
- package/dist/src/cloud-cli/userdb.d.ts.map +1 -0
- package/dist/src/cloud-cli/userdb.js +149 -0
- package/dist/src/cloud-cli/userdb.js.map +1 -0
- package/dist/src/cloud-cli/utils.d.ts +3 -0
- package/dist/src/cloud-cli/utils.d.ts.map +1 -0
- package/dist/src/cloud-cli/utils.js +17 -0
- package/dist/src/cloud-cli/utils.js.map +1 -0
- package/dist/src/communicator.d.ts +24 -0
- package/dist/src/communicator.d.ts.map +1 -0
- package/dist/src/communicator.js +26 -0
- package/dist/src/communicator.js.map +1 -0
- package/dist/src/context.d.ts +60 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +94 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/data_validation.d.ts +3 -0
- package/dist/src/data_validation.d.ts.map +1 -0
- package/dist/src/data_validation.js +168 -0
- package/dist/src/data_validation.js.map +1 -0
- package/dist/src/dbos-executor.d.ts +79 -0
- package/dist/src/dbos-executor.d.ts.map +1 -0
- package/dist/src/dbos-executor.js +408 -0
- package/dist/src/dbos-executor.js.map +1 -0
- package/dist/src/dbos-runtime/TypeParser.d.ts +33 -0
- package/dist/src/dbos-runtime/TypeParser.d.ts.map +1 -0
- package/dist/src/dbos-runtime/TypeParser.js +104 -0
- package/dist/src/dbos-runtime/TypeParser.js.map +1 -0
- package/dist/src/dbos-runtime/applicationVersion.d.ts +3 -0
- package/dist/src/dbos-runtime/applicationVersion.d.ts.map +1 -0
- package/dist/src/dbos-runtime/applicationVersion.js +13 -0
- package/dist/src/dbos-runtime/applicationVersion.js.map +1 -0
- package/dist/src/dbos-runtime/cli.d.ts +8 -0
- package/dist/src/dbos-runtime/cli.d.ts.map +1 -0
- package/dist/src/dbos-runtime/cli.js +52 -0
- package/dist/src/dbos-runtime/cli.js.map +1 -0
- package/dist/src/dbos-runtime/config.d.ts +28 -0
- package/dist/src/dbos-runtime/config.d.ts.map +1 -0
- package/dist/src/dbos-runtime/config.js +111 -0
- package/dist/src/dbos-runtime/config.js.map +1 -0
- package/dist/src/dbos-runtime/init.d.ts +7 -0
- package/dist/src/dbos-runtime/init.d.ts.map +1 -0
- package/dist/src/dbos-runtime/init.js +51 -0
- package/dist/src/dbos-runtime/init.js.map +1 -0
- package/dist/src/dbos-runtime/openApi.d.ts +35 -0
- package/dist/src/dbos-runtime/openApi.d.ts.map +1 -0
- package/dist/src/dbos-runtime/openApi.js +595 -0
- package/dist/src/dbos-runtime/openApi.js.map +1 -0
- package/dist/src/dbos-runtime/runtime.d.ts +28 -0
- package/dist/src/dbos-runtime/runtime.d.ts.map +1 -0
- package/dist/src/dbos-runtime/runtime.js +96 -0
- package/dist/src/dbos-runtime/runtime.js.map +1 -0
- package/dist/src/dbos-runtime/tsDiagUtil.d.ts +16 -0
- package/dist/src/dbos-runtime/tsDiagUtil.d.ts.map +1 -0
- package/dist/src/dbos-runtime/tsDiagUtil.js +72 -0
- package/dist/src/dbos-runtime/tsDiagUtil.js.map +1 -0
- package/dist/src/decorators.d.ts +118 -0
- package/dist/src/decorators.d.ts.map +1 -0
- package/dist/src/decorators.js +467 -0
- package/dist/src/decorators.js.map +1 -0
- package/dist/src/error.d.ts +44 -0
- package/dist/src/error.d.ts.map +1 -0
- package/dist/src/error.js +164 -0
- package/dist/src/error.js.map +1 -0
- package/dist/src/httpServer/handler.d.ts +62 -0
- package/dist/src/httpServer/handler.d.ts.map +1 -0
- package/dist/src/httpServer/handler.js +168 -0
- package/dist/src/httpServer/handler.js.map +1 -0
- package/dist/src/httpServer/middleware.d.ts +56 -0
- package/dist/src/httpServer/middleware.d.ts.map +1 -0
- package/dist/src/httpServer/middleware.js +57 -0
- package/dist/src/httpServer/middleware.js.map +1 -0
- package/dist/src/httpServer/server.d.ts +40 -0
- package/dist/src/httpServer/server.d.ts.map +1 -0
- package/dist/src/httpServer/server.js +231 -0
- package/dist/src/httpServer/server.js.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +75 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/provenance/provenance_daemon.d.ts +34 -0
- package/dist/src/provenance/provenance_daemon.d.ts.map +1 -0
- package/dist/src/provenance/provenance_daemon.js +86 -0
- package/dist/src/provenance/provenance_daemon.js.map +1 -0
- package/dist/src/system_database.d.ts +69 -0
- package/dist/src/system_database.d.ts.map +1 -0
- package/dist/src/system_database.js +384 -0
- package/dist/src/system_database.js.map +1 -0
- package/dist/src/telemetry/collector.d.ts +17 -0
- package/dist/src/telemetry/collector.d.ts.map +1 -0
- package/dist/src/telemetry/collector.js +77 -0
- package/dist/src/telemetry/collector.js.map +1 -0
- package/dist/src/telemetry/exporters.d.ts +29 -0
- package/dist/src/telemetry/exporters.d.ts.map +1 -0
- package/dist/src/telemetry/exporters.js +186 -0
- package/dist/src/telemetry/exporters.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +7 -0
- package/dist/src/telemetry/index.d.ts.map +1 -0
- package/dist/src/telemetry/index.js +3 -0
- package/dist/src/telemetry/index.js.map +1 -0
- package/dist/src/telemetry/logs.d.ts +25 -0
- package/dist/src/telemetry/logs.d.ts.map +1 -0
- package/dist/src/telemetry/logs.js +91 -0
- package/dist/src/telemetry/logs.js.map +1 -0
- package/dist/src/telemetry/signals.d.ts +30 -0
- package/dist/src/telemetry/signals.d.ts.map +1 -0
- package/dist/src/telemetry/signals.js +11 -0
- package/dist/src/telemetry/signals.js.map +1 -0
- package/dist/src/telemetry/traces.d.ts +17 -0
- package/dist/src/telemetry/traces.d.ts.map +1 -0
- package/dist/src/telemetry/traces.js +76 -0
- package/dist/src/telemetry/traces.js.map +1 -0
- package/dist/src/testing/testing_runtime.d.ts +76 -0
- package/dist/src/testing/testing_runtime.d.ts.map +1 -0
- package/dist/src/testing/testing_runtime.js +147 -0
- package/dist/src/testing/testing_runtime.js.map +1 -0
- package/dist/src/transaction.d.ts +28 -0
- package/dist/src/transaction.d.ts.map +1 -0
- package/dist/src/transaction.js +27 -0
- package/dist/src/transaction.js.map +1 -0
- package/dist/src/user_database.d.ts +132 -0
- package/dist/src/user_database.d.ts.map +1 -0
- package/dist/src/user_database.js +324 -0
- package/dist/src/user_database.js.map +1 -0
- package/dist/src/utils.d.ts +6 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +35 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/workflow.d.ts +179 -0
- package/dist/src/workflow.d.ts.map +1 -0
- package/dist/src/workflow.js +446 -0
- package/dist/src/workflow.js.map +1 -0
- package/examples/hello/README.md +41 -0
- package/examples/hello/dbos-config.yaml +15 -0
- package/examples/hello/jest.config.js +8 -0
- package/examples/hello/knexfile.ts +23 -0
- package/examples/hello/migrations/create_dbos_hello_tables.ts +12 -0
- package/examples/hello/package.json +21 -0
- package/examples/hello/src/operations.test.ts +38 -0
- package/examples/hello/src/operations.ts +21 -0
- package/examples/hello/start_postgres_docker.sh +23 -0
- package/examples/hello/tsconfig.json +24 -0
- package/package.json +78 -0
@@ -0,0 +1,408 @@
|
|
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.DBOSExecutor = exports.dbosNull = void 0;
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
8
|
+
const error_1 = require("./error");
|
9
|
+
const workflow_1 = require("./workflow");
|
10
|
+
const exporters_1 = require("./telemetry/exporters");
|
11
|
+
const collector_1 = require("./telemetry/collector");
|
12
|
+
const traces_1 = require("./telemetry/traces");
|
13
|
+
const logs_1 = require("./telemetry/logs");
|
14
|
+
const system_database_1 = require("./system_database");
|
15
|
+
const uuid_1 = require("uuid");
|
16
|
+
const user_database_1 = require("./user_database");
|
17
|
+
const decorators_1 = require("./decorators");
|
18
|
+
const api_1 = require("@opentelemetry/api");
|
19
|
+
const knex_1 = __importDefault(require("knex"));
|
20
|
+
const context_1 = require("./context");
|
21
|
+
exports.dbosNull = {};
|
22
|
+
class DBOSExecutor {
|
23
|
+
config;
|
24
|
+
initialized;
|
25
|
+
// User Database
|
26
|
+
userDatabase = null;
|
27
|
+
// System Database
|
28
|
+
systemDatabase;
|
29
|
+
// Temporary workflows are created by calling transaction/send/recv directly from the executor class
|
30
|
+
tempWorkflowName = "temp_workflow";
|
31
|
+
workflowInfoMap = new Map([
|
32
|
+
// We initialize the map with an entry for temporary workflows.
|
33
|
+
[
|
34
|
+
this.tempWorkflowName,
|
35
|
+
{
|
36
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
37
|
+
workflow: async () => this.logger.error("UNREACHABLE: Indirect invoke of temp workflow"),
|
38
|
+
config: {},
|
39
|
+
},
|
40
|
+
],
|
41
|
+
]);
|
42
|
+
transactionConfigMap = new Map();
|
43
|
+
communicatorConfigMap = new Map();
|
44
|
+
topicConfigMap = new Map();
|
45
|
+
registeredOperations = [];
|
46
|
+
initialEpochTimeMs;
|
47
|
+
pendingWorkflowMap = new Map(); // Map from workflowUUID to workflow promise.
|
48
|
+
telemetryCollector;
|
49
|
+
flushBufferIntervalMs = 1000;
|
50
|
+
flushBufferID;
|
51
|
+
static defaultNotificationTimeoutSec = 60;
|
52
|
+
logger;
|
53
|
+
tracer;
|
54
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
55
|
+
entities = [];
|
56
|
+
/* WORKFLOW EXECUTOR LIFE CYCLE MANAGEMENT */
|
57
|
+
constructor(config, systemDatabase) {
|
58
|
+
this.config = config;
|
59
|
+
this.logger = (0, logs_1.createGlobalLogger)(this.config.telemetry?.logs);
|
60
|
+
if (systemDatabase) {
|
61
|
+
this.logger.debug("Using provided system database"); // XXX print the name or something
|
62
|
+
this.systemDatabase = systemDatabase;
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
this.logger.debug("Using Postgres system database");
|
66
|
+
this.systemDatabase = new system_database_1.PostgresSystemDatabase(this.config.poolConfig, this.config.system_database, this.logger);
|
67
|
+
}
|
68
|
+
this.flushBufferID = setInterval(() => {
|
69
|
+
void this.flushWorkflowStatusBuffer();
|
70
|
+
}, this.flushBufferIntervalMs);
|
71
|
+
this.logger.debug('Started workflow status buffer worker');
|
72
|
+
// Add Jaeger exporter if tracing is enabled
|
73
|
+
const telemetryExporters = [];
|
74
|
+
if (this.config.telemetry?.traces?.enabled) {
|
75
|
+
telemetryExporters.push(new exporters_1.JaegerExporter(this.config.telemetry?.traces?.endpoint));
|
76
|
+
this.logger.debug("Loaded Jaeger Telemetry Exporter");
|
77
|
+
}
|
78
|
+
this.telemetryCollector = new collector_1.TelemetryCollector(telemetryExporters);
|
79
|
+
this.tracer = new traces_1.Tracer(this.telemetryCollector);
|
80
|
+
this.initialized = false;
|
81
|
+
this.initialEpochTimeMs = Date.now();
|
82
|
+
}
|
83
|
+
configureDbClient() {
|
84
|
+
const userDbClient = this.config.userDbclient;
|
85
|
+
if (userDbClient === user_database_1.UserDatabaseName.PRISMA) {
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
87
|
+
const { PrismaClient } = require('@prisma/client');
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
89
|
+
this.userDatabase = new user_database_1.PrismaUserDatabase(new PrismaClient());
|
90
|
+
this.logger.debug("Loaded Prisma user database");
|
91
|
+
}
|
92
|
+
else if (userDbClient === user_database_1.UserDatabaseName.TYPEORM) {
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
94
|
+
const DataSourceExports = require('typeorm');
|
95
|
+
try {
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
97
|
+
this.userDatabase = new user_database_1.TypeORMDatabase(new DataSourceExports.DataSource({
|
98
|
+
type: "postgres",
|
99
|
+
host: this.config.poolConfig.host,
|
100
|
+
port: this.config.poolConfig.port,
|
101
|
+
username: this.config.poolConfig.user,
|
102
|
+
password: this.config.poolConfig.password,
|
103
|
+
database: this.config.poolConfig.database,
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
105
|
+
entities: this.entities
|
106
|
+
}));
|
107
|
+
}
|
108
|
+
catch (s) {
|
109
|
+
this.logger.error("Error loading TypeORM user database");
|
110
|
+
}
|
111
|
+
this.logger.debug("Loaded TypeORM user database");
|
112
|
+
}
|
113
|
+
else if (userDbClient === user_database_1.UserDatabaseName.KNEX) {
|
114
|
+
const knexConfig = {
|
115
|
+
client: 'postgres',
|
116
|
+
connection: {
|
117
|
+
host: this.config.poolConfig.host,
|
118
|
+
port: this.config.poolConfig.port,
|
119
|
+
user: this.config.poolConfig.user,
|
120
|
+
password: this.config.poolConfig.password,
|
121
|
+
database: this.config.poolConfig.database,
|
122
|
+
ssl: this.config.poolConfig.ssl,
|
123
|
+
}
|
124
|
+
};
|
125
|
+
this.userDatabase = new user_database_1.KnexUserDatabase((0, knex_1.default)(knexConfig));
|
126
|
+
this.logger.debug("Loaded Knex user database");
|
127
|
+
}
|
128
|
+
else {
|
129
|
+
this.userDatabase = new user_database_1.PGNodeUserDatabase(this.config.poolConfig);
|
130
|
+
this.logger.debug("Loaded Postgres user database");
|
131
|
+
}
|
132
|
+
}
|
133
|
+
#registerClass(cls) {
|
134
|
+
const registeredClassOperations = (0, decorators_1.getRegisteredOperations)(cls);
|
135
|
+
this.registeredOperations.push(...registeredClassOperations);
|
136
|
+
for (const ro of registeredClassOperations) {
|
137
|
+
if (ro.workflowConfig) {
|
138
|
+
const wf = ro.registeredFunction;
|
139
|
+
this.#registerWorkflow(wf, ro.workflowConfig);
|
140
|
+
this.logger.debug(`Registered workflow ${ro.name}`);
|
141
|
+
}
|
142
|
+
else if (ro.txnConfig) {
|
143
|
+
const tx = ro.registeredFunction;
|
144
|
+
this.#registerTransaction(tx, ro.txnConfig);
|
145
|
+
this.logger.debug(`Registered transaction ${ro.name}`);
|
146
|
+
}
|
147
|
+
else if (ro.commConfig) {
|
148
|
+
const comm = ro.registeredFunction;
|
149
|
+
this.#registerCommunicator(comm, ro.commConfig);
|
150
|
+
this.logger.debug(`Registered communicator ${ro.name}`);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
}
|
154
|
+
async init(...classes) {
|
155
|
+
if (this.initialized) {
|
156
|
+
this.logger.error("Workflow executor already initialized!");
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
try {
|
160
|
+
for (const cls of classes) {
|
161
|
+
const reg = (0, decorators_1.getOrCreateClassRegistration)(cls);
|
162
|
+
if (reg.ormEntities.length > 0) {
|
163
|
+
this.entities = this.entities.concat(reg.ormEntities);
|
164
|
+
this.logger.debug(`Loaded ${reg.ormEntities.length} ORM entities`);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
this.configureDbClient();
|
168
|
+
if (!this.userDatabase) {
|
169
|
+
this.logger.error("No user database configured!");
|
170
|
+
throw new error_1.DBOSInitializationError("No user database configured!");
|
171
|
+
}
|
172
|
+
for (const cls of classes) {
|
173
|
+
this.#registerClass(cls);
|
174
|
+
}
|
175
|
+
await this.telemetryCollector.init(this.registeredOperations);
|
176
|
+
await this.userDatabase.init();
|
177
|
+
await this.systemDatabase.init();
|
178
|
+
}
|
179
|
+
catch (err) {
|
180
|
+
if (err instanceof Error) {
|
181
|
+
this.logger.error(`failed to initialize workflow executor: ${err.message}`, err, err.stack);
|
182
|
+
throw new error_1.DBOSInitializationError(err.message);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
await this.recoverPendingWorkflows();
|
186
|
+
this.initialized = true;
|
187
|
+
for (const v of this.registeredOperations) {
|
188
|
+
const m = v;
|
189
|
+
if (m.init === true) {
|
190
|
+
this.logger.debug("Executing init method: " + m.name);
|
191
|
+
await m.origFunction(new context_1.InitContext(this));
|
192
|
+
}
|
193
|
+
}
|
194
|
+
this.logger.info("Workflow executor initialized");
|
195
|
+
}
|
196
|
+
async destroy() {
|
197
|
+
if (this.pendingWorkflowMap.size > 0) {
|
198
|
+
this.logger.info("Waiting for pending workflows to finish.");
|
199
|
+
await Promise.allSettled(this.pendingWorkflowMap.values());
|
200
|
+
}
|
201
|
+
clearInterval(this.flushBufferID);
|
202
|
+
await this.flushWorkflowStatusBuffer();
|
203
|
+
await this.systemDatabase.destroy();
|
204
|
+
await this.userDatabase.destroy();
|
205
|
+
await this.telemetryCollector.destroy();
|
206
|
+
}
|
207
|
+
/* WORKFLOW OPERATIONS */
|
208
|
+
#registerWorkflow(wf, config = {}) {
|
209
|
+
if (wf.name === this.tempWorkflowName || this.workflowInfoMap.has(wf.name)) {
|
210
|
+
throw new error_1.DBOSError(`Repeated workflow name: ${wf.name}`);
|
211
|
+
}
|
212
|
+
const workflowInfo = {
|
213
|
+
workflow: wf,
|
214
|
+
config: config,
|
215
|
+
};
|
216
|
+
this.workflowInfoMap.set(wf.name, workflowInfo);
|
217
|
+
}
|
218
|
+
#registerTransaction(txn, params = {}) {
|
219
|
+
if (this.transactionConfigMap.has(txn.name)) {
|
220
|
+
throw new error_1.DBOSError(`Repeated Transaction name: ${txn.name}`);
|
221
|
+
}
|
222
|
+
this.transactionConfigMap.set(txn.name, params);
|
223
|
+
}
|
224
|
+
#registerCommunicator(comm, params = {}) {
|
225
|
+
if (this.communicatorConfigMap.has(comm.name)) {
|
226
|
+
throw new error_1.DBOSError(`Repeated Commmunicator name: ${comm.name}`);
|
227
|
+
}
|
228
|
+
this.communicatorConfigMap.set(comm.name, params);
|
229
|
+
}
|
230
|
+
async workflow(wf, params, ...args) {
|
231
|
+
return this.internalWorkflow(wf, params, undefined, undefined, ...args);
|
232
|
+
}
|
233
|
+
// If callerUUID and functionID are set, it means the workflow is invoked from within a workflow.
|
234
|
+
async internalWorkflow(wf, params, callerUUID, callerFunctionID, ...args) {
|
235
|
+
const workflowUUID = params.workflowUUID ? params.workflowUUID : this.#generateUUID();
|
236
|
+
const wInfo = this.workflowInfoMap.get(wf.name);
|
237
|
+
if (wInfo === undefined) {
|
238
|
+
throw new error_1.DBOSNotRegisteredError(wf.name);
|
239
|
+
}
|
240
|
+
const wConfig = wInfo.config;
|
241
|
+
const wCtxt = new workflow_1.WorkflowContextImpl(this, params.parentCtx, workflowUUID, wConfig, wf.name);
|
242
|
+
wCtxt.span.setAttributes({ args: JSON.stringify(args) }); // TODO enforce skipLogging & request for hashing
|
243
|
+
// Synchronously set the workflow's status to PENDING and record workflow inputs. Not needed for temporary workflows.
|
244
|
+
if (!wCtxt.isTempWorkflow) {
|
245
|
+
args = await this.systemDatabase.initWorkflowStatus(workflowUUID, wf.name, wCtxt.authenticatedUser, wCtxt.assumedRole, wCtxt.authenticatedRoles, wCtxt.request, args);
|
246
|
+
}
|
247
|
+
const runWorkflow = async () => {
|
248
|
+
// Check if the workflow previously ran.
|
249
|
+
const previousOutput = await this.systemDatabase.checkWorkflowOutput(workflowUUID);
|
250
|
+
if (previousOutput !== exports.dbosNull) {
|
251
|
+
wCtxt.span.setAttribute("cached", true);
|
252
|
+
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
253
|
+
this.tracer.endSpan(wCtxt.span);
|
254
|
+
return previousOutput;
|
255
|
+
}
|
256
|
+
let result;
|
257
|
+
// Execute the workflow.
|
258
|
+
try {
|
259
|
+
result = await wf(wCtxt, ...args);
|
260
|
+
this.systemDatabase.bufferWorkflowOutput(workflowUUID, result);
|
261
|
+
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
262
|
+
}
|
263
|
+
catch (err) {
|
264
|
+
if (err instanceof error_1.DBOSWorkflowConflictUUIDError) {
|
265
|
+
// Retrieve the handle and wait for the result.
|
266
|
+
const retrievedHandle = this.retrieveWorkflow(workflowUUID);
|
267
|
+
result = await retrievedHandle.getResult();
|
268
|
+
wCtxt.span.setAttribute("cached", true);
|
269
|
+
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.OK });
|
270
|
+
}
|
271
|
+
else {
|
272
|
+
// Record the error.
|
273
|
+
const e = err;
|
274
|
+
this.logger.error(e);
|
275
|
+
await this.systemDatabase.recordWorkflowError(workflowUUID, e);
|
276
|
+
// TODO: Log errors, but not in the tests when they're expected.
|
277
|
+
wCtxt.span.setStatus({ code: api_1.SpanStatusCode.ERROR, message: e.message });
|
278
|
+
throw err;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
finally {
|
282
|
+
this.tracer.endSpan(wCtxt.span);
|
283
|
+
}
|
284
|
+
return result;
|
285
|
+
};
|
286
|
+
const workflowPromise = runWorkflow();
|
287
|
+
// Need to await for the workflow and capture errors.
|
288
|
+
const awaitWorkflowPromise = workflowPromise
|
289
|
+
.catch((error) => {
|
290
|
+
this.logger.debug("Captured error in awaitWorkflowPromise: " + error);
|
291
|
+
})
|
292
|
+
.finally(() => {
|
293
|
+
// Remove itself from pending workflow map.
|
294
|
+
this.pendingWorkflowMap.delete(workflowUUID);
|
295
|
+
});
|
296
|
+
this.pendingWorkflowMap.set(workflowUUID, awaitWorkflowPromise);
|
297
|
+
// Return the normal handle that doesn't capture errors.
|
298
|
+
return new workflow_1.InvokedHandle(this.systemDatabase, workflowPromise, workflowUUID, wf.name, callerUUID, callerFunctionID);
|
299
|
+
}
|
300
|
+
async transaction(txn, params, ...args) {
|
301
|
+
// Create a workflow and call transaction.
|
302
|
+
const temp_workflow = async (ctxt, ...args) => {
|
303
|
+
const ctxtImpl = ctxt;
|
304
|
+
return await ctxtImpl.transaction(txn, ...args);
|
305
|
+
};
|
306
|
+
return (await this.workflow(temp_workflow, params, ...args)).getResult();
|
307
|
+
}
|
308
|
+
async external(commFn, params, ...args) {
|
309
|
+
// Create a workflow and call external.
|
310
|
+
const temp_workflow = async (ctxt, ...args) => {
|
311
|
+
const ctxtImpl = ctxt;
|
312
|
+
return await ctxtImpl.external(commFn, ...args);
|
313
|
+
};
|
314
|
+
return (await this.workflow(temp_workflow, params, ...args)).getResult();
|
315
|
+
}
|
316
|
+
async send(destinationUUID, message, topic, idempotencyKey) {
|
317
|
+
// Create a workflow and call send.
|
318
|
+
const temp_workflow = async (ctxt, destinationUUID, message, topic) => {
|
319
|
+
return await ctxt.send(destinationUUID, message, topic);
|
320
|
+
};
|
321
|
+
const workflowUUID = idempotencyKey ? destinationUUID + idempotencyKey : undefined;
|
322
|
+
return (await this.workflow(temp_workflow, { workflowUUID: workflowUUID }, destinationUUID, message, topic)).getResult();
|
323
|
+
}
|
324
|
+
/**
|
325
|
+
* Wait for a workflow to emit an event, then return its value.
|
326
|
+
*/
|
327
|
+
async getEvent(workflowUUID, key, timeoutSeconds = DBOSExecutor.defaultNotificationTimeoutSec) {
|
328
|
+
return this.systemDatabase.getEvent(workflowUUID, key, timeoutSeconds);
|
329
|
+
}
|
330
|
+
/**
|
331
|
+
* Retrieve a handle for a workflow UUID.
|
332
|
+
*/
|
333
|
+
retrieveWorkflow(workflowUUID) {
|
334
|
+
return new workflow_1.RetrievedHandle(this.systemDatabase, workflowUUID);
|
335
|
+
}
|
336
|
+
/* INTERNAL HELPERS */
|
337
|
+
#generateUUID() {
|
338
|
+
return (0, uuid_1.v4)();
|
339
|
+
}
|
340
|
+
/**
|
341
|
+
* A recovery process that by default runs during executor init time.
|
342
|
+
* It runs to completion all pending workflows that were executing when the previous executor failed.
|
343
|
+
*/
|
344
|
+
async recoverPendingWorkflows(executorIDs = ["local"]) {
|
345
|
+
const pendingWorkflows = [];
|
346
|
+
for (const execID of executorIDs) {
|
347
|
+
this.logger.debug(`Recovering workflows of executor: ${execID}`);
|
348
|
+
const wIDs = await this.systemDatabase.getPendingWorkflows(execID);
|
349
|
+
pendingWorkflows.push(...wIDs);
|
350
|
+
}
|
351
|
+
const handlerArray = [];
|
352
|
+
for (const workflowUUID of pendingWorkflows) {
|
353
|
+
try {
|
354
|
+
const wfStatus = await this.systemDatabase.getWorkflowStatus(workflowUUID);
|
355
|
+
const inputs = await this.systemDatabase.getWorkflowInputs(workflowUUID);
|
356
|
+
if (!inputs || !wfStatus) {
|
357
|
+
this.logger.error(`Failed to find inputs during recover, workflow UUID: ${workflowUUID}`);
|
358
|
+
continue;
|
359
|
+
}
|
360
|
+
const wfInfo = this.workflowInfoMap.get(wfStatus.workflowName);
|
361
|
+
const parentCtx = this.#getRecoveryContext(workflowUUID, wfStatus);
|
362
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
363
|
+
handlerArray.push(await this.workflow(wfInfo.workflow, { workflowUUID: workflowUUID, parentCtx: parentCtx ?? undefined }, ...inputs));
|
364
|
+
}
|
365
|
+
catch (e) {
|
366
|
+
this.logger.warn(`Recovery of workflow ${workflowUUID} failed:`, e);
|
367
|
+
}
|
368
|
+
}
|
369
|
+
return handlerArray;
|
370
|
+
}
|
371
|
+
#getRecoveryContext(workflowUUID, status) {
|
372
|
+
const span = this.tracer.startSpan(status.workflowName);
|
373
|
+
span.setAttributes({
|
374
|
+
operationName: status.workflowName,
|
375
|
+
});
|
376
|
+
const oc = new context_1.DBOSContextImpl(status.workflowName, span, this.logger);
|
377
|
+
oc.request = status.request;
|
378
|
+
oc.authenticatedUser = status.authenticatedUser;
|
379
|
+
oc.authenticatedRoles = status.authenticatedRoles;
|
380
|
+
oc.assumedRole = status.assumedRole;
|
381
|
+
oc.workflowUUID = workflowUUID;
|
382
|
+
return oc;
|
383
|
+
}
|
384
|
+
/* BACKGROUND PROCESSES */
|
385
|
+
/**
|
386
|
+
* Periodically flush the workflow output buffer to the system database.
|
387
|
+
*/
|
388
|
+
async flushWorkflowStatusBuffer() {
|
389
|
+
if (this.initialized) {
|
390
|
+
await this.systemDatabase.flushWorkflowStatusBuffer();
|
391
|
+
}
|
392
|
+
}
|
393
|
+
logRegisteredHTTPUrls() {
|
394
|
+
this.logger.info("HTTP endpoints supported:");
|
395
|
+
this.registeredOperations.forEach((registeredOperation) => {
|
396
|
+
const ro = registeredOperation;
|
397
|
+
if (ro.apiURL) {
|
398
|
+
this.logger.info(" " + ro.apiType.padEnd(4) + " : " + ro.apiURL);
|
399
|
+
const roles = ro.getRequiredRoles();
|
400
|
+
if (roles.length > 0) {
|
401
|
+
this.logger.info(" Required Roles: " + JSON.stringify(roles));
|
402
|
+
}
|
403
|
+
}
|
404
|
+
});
|
405
|
+
}
|
406
|
+
}
|
407
|
+
exports.DBOSExecutor = DBOSExecutor;
|
408
|
+
//# sourceMappingURL=dbos-executor.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"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,EAAE,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAChD,EAAE,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;QAClD,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACpC,EAAE,CAAC,YAAY,GAAG,YAAY,CAAC;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,0BAA0B;IAC1B;;OAEG;IACH,KAAK,CAAC,yBAAyB;QAC7B,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,MAAM,IAAI,CAAC,cAAc,CAAC,yBAAyB,EAAE,CAAC;SACvD;IACH,CAAC;IAED,qBAAqB;QACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC9C,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,mBAAmB,EAAE,EAAE;YACxD,MAAM,EAAE,GAAG,mBAAuE,CAAC;YACnF,IAAI,EAAE,CAAC,MAAM,EAAE;gBACb,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;gBACtE,MAAM,KAAK,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAC;gBACpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;iBACtE;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;;AA9ZH,oCAgaC"}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import ts from 'typescript';
|
2
|
+
export interface ClassInfo {
|
3
|
+
readonly node: ts.ClassDeclaration;
|
4
|
+
readonly name?: string;
|
5
|
+
readonly decorators: readonly DecoratorInfo[];
|
6
|
+
readonly methods: readonly MethodInfo[];
|
7
|
+
}
|
8
|
+
export interface MethodInfo {
|
9
|
+
readonly node: ts.MethodDeclaration;
|
10
|
+
readonly name: string;
|
11
|
+
readonly decorators: readonly DecoratorInfo[];
|
12
|
+
readonly parameters: readonly ParameterInfo[];
|
13
|
+
}
|
14
|
+
export interface ParameterInfo {
|
15
|
+
readonly node: ts.ParameterDeclaration;
|
16
|
+
readonly name: string;
|
17
|
+
readonly decorators: readonly DecoratorInfo[];
|
18
|
+
readonly required: boolean;
|
19
|
+
}
|
20
|
+
export interface DecoratorInfo {
|
21
|
+
node: ts.Decorator;
|
22
|
+
identifier: ts.Identifier;
|
23
|
+
args: readonly ts.Expression[];
|
24
|
+
name?: string;
|
25
|
+
module?: string;
|
26
|
+
}
|
27
|
+
export declare class TypeParser {
|
28
|
+
#private;
|
29
|
+
get diags(): readonly ts.Diagnostic[];
|
30
|
+
constructor(program: ts.Program);
|
31
|
+
parse(): readonly ClassInfo[] | undefined;
|
32
|
+
}
|
33
|
+
//# sourceMappingURL=TypeParser.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TypeParser.d.ts","sourceRoot":"","sources":["../../../src/dbos-runtime/TypeParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC;IACnB,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,IAAI,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAOD,qBAAa,UAAU;;IAIrB,IAAI,KAAK,6BAAgC;gBAE7B,OAAO,EAAE,EAAE,CAAC,OAAO;IAK/B,KAAK,IAAI,SAAS,SAAS,EAAE,GAAG,SAAS;CA2F1C"}
|
@@ -0,0 +1,104 @@
|
|
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.TypeParser = void 0;
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
8
|
+
const tsDiagUtil_1 = require("./tsDiagUtil");
|
9
|
+
function isStaticMethod(node) {
|
10
|
+
const mods = node.modifiers ?? [];
|
11
|
+
return mods.some(m => m.kind === typescript_1.default.SyntaxKind.StaticKeyword);
|
12
|
+
}
|
13
|
+
class TypeParser {
|
14
|
+
#program;
|
15
|
+
#checker;
|
16
|
+
#diags = new tsDiagUtil_1.DiagnosticsCollector();
|
17
|
+
get diags() { return this.#diags.diags; }
|
18
|
+
constructor(program) {
|
19
|
+
this.#program = program;
|
20
|
+
this.#checker = program.getTypeChecker();
|
21
|
+
}
|
22
|
+
parse() {
|
23
|
+
const classes = new Array();
|
24
|
+
for (const file of this.#program.getSourceFiles()) {
|
25
|
+
if (file.isDeclarationFile)
|
26
|
+
continue;
|
27
|
+
for (const stmt of file.statements) {
|
28
|
+
if (typescript_1.default.isClassDeclaration(stmt)) {
|
29
|
+
const staticMethods = stmt.members
|
30
|
+
.filter(typescript_1.default.isMethodDeclaration)
|
31
|
+
// Only static methods are supported now, so filter out instance methods by default
|
32
|
+
.filter(isStaticMethod)
|
33
|
+
.map(m => this.#getMethod(m));
|
34
|
+
classes.push({
|
35
|
+
node: stmt,
|
36
|
+
// a class may not have a name if it's the default export
|
37
|
+
name: stmt.name?.getText(),
|
38
|
+
decorators: this.#getDecorators(stmt),
|
39
|
+
methods: staticMethods,
|
40
|
+
});
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
if (classes.length === 0) {
|
45
|
+
this.#diags.warn(`no classes found in ${JSON.stringify(this.#program.getRootFileNames())}`);
|
46
|
+
}
|
47
|
+
return (0, tsDiagUtil_1.diagResult)(classes, this.diags);
|
48
|
+
}
|
49
|
+
#getMethod(node) {
|
50
|
+
const name = node.name.getText();
|
51
|
+
const decorators = this.#getDecorators(node);
|
52
|
+
const parameters = node.parameters.map(p => this.#getParameter(p));
|
53
|
+
return { node, name, decorators, parameters };
|
54
|
+
}
|
55
|
+
#getParameter(node) {
|
56
|
+
const decorators = this.#getDecorators(node);
|
57
|
+
const name = node.name.getText();
|
58
|
+
const required = !node.questionToken && !node.initializer;
|
59
|
+
return { node, name, decorators, required };
|
60
|
+
}
|
61
|
+
#getDecoratorIdentifier(node) {
|
62
|
+
if (typescript_1.default.isCallExpression(node.expression)) {
|
63
|
+
if (typescript_1.default.isIdentifier(node.expression.expression)) {
|
64
|
+
return { identifier: node.expression.expression, args: node.expression.arguments };
|
65
|
+
}
|
66
|
+
this.#diags.raise(`Unexpected decorator CallExpression.expression type: ${typescript_1.default.SyntaxKind[node.expression.expression.kind]}`, node);
|
67
|
+
}
|
68
|
+
if (typescript_1.default.isIdentifier(node.expression)) {
|
69
|
+
return { identifier: node.expression, args: [] };
|
70
|
+
}
|
71
|
+
this.#diags.raise(`Unexpected decorator expression type: ${typescript_1.default.SyntaxKind[node.expression.kind]}`, node);
|
72
|
+
}
|
73
|
+
#getDecorators(node) {
|
74
|
+
return (typescript_1.default.getDecorators(node) ?? [])
|
75
|
+
.map(node => {
|
76
|
+
const decoratorIdentifier = this.#getDecoratorIdentifier(node);
|
77
|
+
if (!decoratorIdentifier)
|
78
|
+
return undefined;
|
79
|
+
const { identifier, args } = decoratorIdentifier;
|
80
|
+
const { name, module } = getImportSpecifier(identifier, this.#checker) ?? {};
|
81
|
+
return { node, identifier, name, module, args };
|
82
|
+
})
|
83
|
+
.filter((d) => !!d);
|
84
|
+
function getImportSpecifier(node, checker) {
|
85
|
+
const symbol = checker.getSymbolAtLocation(node);
|
86
|
+
const decls = symbol?.getDeclarations() ?? [];
|
87
|
+
for (const decl of decls) {
|
88
|
+
if (typescript_1.default.isImportSpecifier(decl)) {
|
89
|
+
// decl.name is the name for this type used in the local module.
|
90
|
+
// If the type name was overridden in the local module, the original type name is stored in decl.propertyName.
|
91
|
+
// Otherwise, decl.propertyName is undefined.
|
92
|
+
const name = (decl.propertyName ?? decl.name).getText();
|
93
|
+
// comment in TS AST declaration indicates moduleSpecifier *must* be a string literal
|
94
|
+
// "If [ImportDeclaration.moduleSpecifier] is not a StringLiteral it will be a grammar error."
|
95
|
+
const module = decl.parent.parent.parent.moduleSpecifier;
|
96
|
+
return { name, module: module.text };
|
97
|
+
}
|
98
|
+
}
|
99
|
+
return undefined;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
exports.TypeParser = TypeParser;
|
104
|
+
//# sourceMappingURL=TypeParser.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TypeParser.js","sourceRoot":"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CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAsB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,SAAS,kBAAkB,CAAC,IAAa,EAAE,OAAuB;YAChE,MAAM,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACjD,MAAM,KAAK,GAAG,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;YAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,IAAI,oBAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE;oBAC9B,gEAAgE;oBAChE,8GAA8G;oBAC9G,6CAA6C;oBAC7C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;oBAExD,qFAAqF;oBACrF,iGAAiG;oBACjG,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,eAAmC,CAAC;oBAE7E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;iBACtC;aACF;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AAtGD,gCAsGC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"applicationVersion.d.ts","sourceRoot":"","sources":["../../../src/dbos-runtime/applicationVersion.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAE1D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3D"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.setApplicationVersion = exports.getApplicationVersion = void 0;
|
4
|
+
function getApplicationVersion() {
|
5
|
+
return applicationVersion;
|
6
|
+
}
|
7
|
+
exports.getApplicationVersion = getApplicationVersion;
|
8
|
+
function setApplicationVersion(version) {
|
9
|
+
applicationVersion = version;
|
10
|
+
}
|
11
|
+
exports.setApplicationVersion = setApplicationVersion;
|
12
|
+
let applicationVersion = undefined;
|
13
|
+
//# sourceMappingURL=applicationVersion.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"applicationVersion.js","sourceRoot":"","sources":["../../../src/dbos-runtime/applicationVersion.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qBAAqB;IACjC,OAAO,kBAAkB,CAAC;AAC9B,CAAC;AAFD,sDAEC;AAED,SAAgB,qBAAqB,CAAC,OAAe;IACjD,kBAAkB,GAAG,OAAO,CAAC;AACjC,CAAC;AAFD,sDAEC;AAED,IAAI,kBAAkB,GAAuB,SAAS,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/dbos-runtime/cli.ts"],"names":[],"mappings":";AAkBA,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|