@dbos-inc/dbos-sdk 0.9.15-preview.g32137f5fa0 → 0.9.17
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/packages/dbos-cloud/applications/get-app-info.d.ts +2 -0
- package/dist/packages/dbos-cloud/applications/get-app-info.d.ts.map +1 -0
- package/dist/packages/dbos-cloud/applications/get-app-info.js +54 -0
- package/dist/packages/dbos-cloud/applications/get-app-info.js.map +1 -0
- package/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/applications/list-apps.js +2 -1
- package/dist/packages/dbos-cloud/applications/list-apps.js.map +1 -1
- package/dist/packages/dbos-cloud/applications/types.d.ts +2 -1
- package/dist/packages/dbos-cloud/applications/types.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/cli.js +29 -25
- package/dist/packages/dbos-cloud/cli.js.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts +6 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.js +23 -5
- package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
- package/dist/packages/dbos-cloud/login.d.ts +0 -7
- package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/login.js +14 -12
- package/dist/packages/dbos-cloud/login.js.map +1 -1
- package/dist/packages/dbos-cloud/userdb.d.ts +3 -1
- package/dist/packages/dbos-cloud/userdb.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/userdb.js +42 -4
- package/dist/packages/dbos-cloud/userdb.js.map +1 -1
- package/dist/src/dbos-runtime/init.d.ts.map +1 -1
- package/dist/src/dbos-runtime/init.js +8 -7
- package/dist/src/dbos-runtime/init.js.map +1 -1
- package/dist/src/dbos-runtime/migrate.d.ts +1 -0
- package/dist/src/dbos-runtime/migrate.d.ts.map +1 -1
- package/dist/src/dbos-runtime/migrate.js +55 -28
- package/dist/src/dbos-runtime/migrate.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/examples/hello/dbos-config.yaml +2 -2
- package/examples/hello/package-lock.json +1 -0
- package/examples/hello/start_postgres_docker.sh +4 -1
- package/package.json +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"get-app-info.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/get-app-info.ts"],"names":[],"mappings":"AAKA,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAyC7E"}
|
@@ -0,0 +1,54 @@
|
|
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.getAppInfo = void 0;
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
8
|
+
const cloudutils_1 = require("../cloudutils");
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
10
|
+
async function getAppInfo(host, json) {
|
11
|
+
const logger = (0, cloudutils_1.getLogger)();
|
12
|
+
const userCredentials = (0, cloudutils_1.getCloudCredentials)();
|
13
|
+
const bearerToken = "Bearer " + userCredentials.token;
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
15
|
+
const packageJson = require(node_path_1.default.join(process.cwd(), 'package.json'));
|
16
|
+
const appName = packageJson.name;
|
17
|
+
if (!json) {
|
18
|
+
logger.info(`Retrieving info for application: ${appName}`);
|
19
|
+
}
|
20
|
+
try {
|
21
|
+
const res = await axios_1.default.get(`https://${host}/${userCredentials.userName}/application/${appName}`, {
|
22
|
+
headers: {
|
23
|
+
"Content-Type": "application/json",
|
24
|
+
Authorization: bearerToken,
|
25
|
+
}
|
26
|
+
});
|
27
|
+
const app = res.data;
|
28
|
+
if (json) {
|
29
|
+
console.log(JSON.stringify(app));
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
console.log(`Application Name: ${app.Name}`);
|
33
|
+
console.log(`ID: ${app.ID}`);
|
34
|
+
console.log(`Postgres Instance Name: ${app.PostgresInstanceName}`);
|
35
|
+
console.log(`Application Database Name: ${app.ApplicationDatabaseName}`);
|
36
|
+
console.log(`Status: ${app.Status}`);
|
37
|
+
console.log(`Version: ${app.Version}`);
|
38
|
+
}
|
39
|
+
return 0;
|
40
|
+
}
|
41
|
+
catch (e) {
|
42
|
+
const errorLabel = `Failed to retrieve info for application ${appName}`;
|
43
|
+
const axiosError = e;
|
44
|
+
if ((0, cloudutils_1.isCloudAPIErrorResponse)(axiosError.response?.data)) {
|
45
|
+
(0, cloudutils_1.handleAPIErrors)(errorLabel, axiosError);
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
logger.error(`${errorLabel}: ${e.message}`);
|
49
|
+
}
|
50
|
+
return 1;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
exports.getAppInfo = getAppInfo;
|
54
|
+
//# sourceMappingURL=get-app-info.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"get-app-info.js","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/get-app-info.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA2C;AAC3C,8CAAyG;AACzG,0DAA6B;AAGtB,KAAK,UAAU,UAAU,CAAC,IAAY,EAAE,IAAa;IAC1D,MAAM,MAAM,GAAG,IAAA,sBAAS,GAAE,CAAC;IAC3B,MAAM,eAAe,GAAG,IAAA,gCAAmB,GAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;IAEtD,8DAA8D;IAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAqB,CAAC;IAC1F,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,CAAC,IAAI,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,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAzCD,gCAyCC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"list-apps.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/list-apps.ts"],"names":[],"mappings":"AAIA,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,
|
1
|
+
{"version":3,"file":"list-apps.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/list-apps.ts"],"names":[],"mappings":"AAIA,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA4C3E"}
|
@@ -29,7 +29,8 @@ async function listApps(host, json) {
|
|
29
29
|
applications.forEach(app => {
|
30
30
|
console.log(`Application Name: ${app.Name}`);
|
31
31
|
console.log(`ID: ${app.ID}`);
|
32
|
-
console.log(`
|
32
|
+
console.log(`Postgres Instance Name: ${app.ApplicationDatabaseName}`);
|
33
|
+
console.log(`Application Database Name: ${app.ApplicationDatabaseName}`);
|
33
34
|
console.log(`Status: ${app.Status}`);
|
34
35
|
console.log(`Version: ${app.Version}`);
|
35
36
|
console.log('-------------------------');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"list-apps.js","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/list-apps.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAC1C,8CAAyG;AAGlG,KAAK,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAa;IACxD,MAAM,MAAM,GAAG,IAAA,sBAAS,GAAE,CAAC;IAC3B,MAAM,eAAe,GAAG,IAAA,gCAAmB,GAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,SAAS,G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D,MAAM,UAAU,GAAG,CAAe,CAAC;QACnC,IAAI,IAAA,oCAAuB,EAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;YACvD,IAAA,4BAAe,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,GAAG,UAAU,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AA5CD,4BA4CC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
@@ -6,8 +6,9 @@ const commander_1 = require("commander");
|
|
6
6
|
const login_1 = require("./login");
|
7
7
|
const register_1 = require("./register");
|
8
8
|
const userdb_1 = require("./userdb");
|
9
|
+
const cloudutils_1 = require("./cloudutils");
|
10
|
+
const get_app_info_1 = require("./applications/get-app-info");
|
9
11
|
const program = new commander_1.Command();
|
10
|
-
const DEFAULT_HOST = process.env.DBOS_DOMAIN; // TODO: Once we have a "production" cluster, hardcode its domain name here
|
11
12
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
12
13
|
const packageJson = require('../../../package.json');
|
13
14
|
program.
|
@@ -27,9 +28,8 @@ program
|
|
27
28
|
.command('register')
|
28
29
|
.description('Register a user and log in to DBOS cloud')
|
29
30
|
.requiredOption('-u, --username <string>', 'Username')
|
30
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST)
|
31
31
|
.action(async (options) => {
|
32
|
-
const exitCode = await (0, register_1.registerUser)(options.username,
|
32
|
+
const exitCode = await (0, register_1.registerUser)(options.username, cloudutils_1.DBOSCloudHost);
|
33
33
|
process.exit(exitCode);
|
34
34
|
});
|
35
35
|
/////////////////////////////
|
@@ -37,23 +37,20 @@ program
|
|
37
37
|
/////////////////////////////
|
38
38
|
const applicationCommands = program
|
39
39
|
.command('applications')
|
40
|
-
.description('Manage your DBOS applications')
|
41
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST);
|
40
|
+
.description('Manage your DBOS applications');
|
42
41
|
applicationCommands
|
43
42
|
.command('register')
|
44
43
|
.description('Register a new application')
|
45
44
|
.requiredOption('-d, --database <string>', 'Specify the app database name')
|
46
45
|
.action(async (options) => {
|
47
|
-
const
|
48
|
-
const exitCode = await (0, applications_1.registerApp)(options.database, host);
|
46
|
+
const exitCode = await (0, applications_1.registerApp)(options.database, cloudutils_1.DBOSCloudHost);
|
49
47
|
process.exit(exitCode);
|
50
48
|
});
|
51
49
|
applicationCommands
|
52
50
|
.command('update')
|
53
51
|
.description('Update an application')
|
54
52
|
.action(async () => {
|
55
|
-
const
|
56
|
-
const exitCode = await (0, applications_1.updateApp)(host);
|
53
|
+
const exitCode = await (0, applications_1.updateApp)(cloudutils_1.DBOSCloudHost);
|
57
54
|
process.exit(exitCode);
|
58
55
|
});
|
59
56
|
applicationCommands
|
@@ -61,16 +58,14 @@ applicationCommands
|
|
61
58
|
.description('Deploy an application code to the cloud')
|
62
59
|
.option('--no-docker', 'Build the code locally without using Docker')
|
63
60
|
.action(async (options) => {
|
64
|
-
const
|
65
|
-
const exitCode = await (0, applications_1.deployAppCode)(host, options.docker);
|
61
|
+
const exitCode = await (0, applications_1.deployAppCode)(cloudutils_1.DBOSCloudHost, options.docker);
|
66
62
|
process.exit(exitCode);
|
67
63
|
});
|
68
64
|
applicationCommands
|
69
65
|
.command('delete')
|
70
66
|
.description('Delete a previously deployed application')
|
71
67
|
.action(async () => {
|
72
|
-
const
|
73
|
-
const exitCode = await (0, applications_1.deleteApp)(host);
|
68
|
+
const exitCode = await (0, applications_1.deleteApp)(cloudutils_1.DBOSCloudHost);
|
74
69
|
process.exit(exitCode);
|
75
70
|
});
|
76
71
|
applicationCommands
|
@@ -78,8 +73,15 @@ applicationCommands
|
|
78
73
|
.description('List all deployed applications')
|
79
74
|
.option('--json', 'Emit JSON output')
|
80
75
|
.action(async (options) => {
|
81
|
-
const
|
82
|
-
|
76
|
+
const exitCode = await (0, applications_1.listApps)(cloudutils_1.DBOSCloudHost, options.json);
|
77
|
+
process.exit(exitCode);
|
78
|
+
});
|
79
|
+
applicationCommands
|
80
|
+
.command('get')
|
81
|
+
.description('Get application info')
|
82
|
+
.option('--json', 'Emit JSON output')
|
83
|
+
.action(async (options) => {
|
84
|
+
const exitCode = await (0, get_app_info_1.getAppInfo)(cloudutils_1.DBOSCloudHost, options.json);
|
83
85
|
process.exit(exitCode);
|
84
86
|
});
|
85
87
|
applicationCommands
|
@@ -87,8 +89,7 @@ applicationCommands
|
|
87
89
|
.description('Print the microVM logs of a deployed application')
|
88
90
|
.option('-l, --last <integer>', 'How far back to query, in seconds from current time. By default, we retrieve all data', parseInt)
|
89
91
|
.action(async (options) => {
|
90
|
-
const
|
91
|
-
const exitCode = await (0, applications_1.getAppLogs)(host, options.last);
|
92
|
+
const exitCode = await (0, applications_1.getAppLogs)(cloudutils_1.DBOSCloudHost, options.last);
|
92
93
|
process.exit(exitCode);
|
93
94
|
});
|
94
95
|
//////////////////////////////
|
@@ -96,8 +97,7 @@ applicationCommands
|
|
96
97
|
//////////////////////////////
|
97
98
|
const userdbCommands = program
|
98
99
|
.command('userdb')
|
99
|
-
.description('Manage your databases')
|
100
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST);
|
100
|
+
.description('Manage your databases');
|
101
101
|
userdbCommands
|
102
102
|
.command('create')
|
103
103
|
.argument('<string>', 'database name')
|
@@ -105,8 +105,7 @@ userdbCommands
|
|
105
105
|
.requiredOption('-W, --password <string>', 'Specify the admin password')
|
106
106
|
.option('-s, --sync', 'make synchronous call', true)
|
107
107
|
.action((async (dbname, options) => {
|
108
|
-
const
|
109
|
-
const exitCode = await (0, userdb_1.createUserDb)(host, dbname, options.admin, options.password, options.sync);
|
108
|
+
const exitCode = await (0, userdb_1.createUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.admin, options.password, options.sync);
|
110
109
|
process.exit(exitCode);
|
111
110
|
}));
|
112
111
|
userdbCommands
|
@@ -114,16 +113,21 @@ userdbCommands
|
|
114
113
|
.argument('<string>', 'database name')
|
115
114
|
.option('--json', 'Emit JSON output')
|
116
115
|
.action((async (dbname, options) => {
|
117
|
-
const
|
118
|
-
|
116
|
+
const exitCode = await (0, userdb_1.getUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.json);
|
117
|
+
process.exit(exitCode);
|
118
|
+
}));
|
119
|
+
userdbCommands
|
120
|
+
.command('list')
|
121
|
+
.option('--json', 'Emit JSON output')
|
122
|
+
.action((async (options) => {
|
123
|
+
const exitCode = await (0, userdb_1.listUserDB)(cloudutils_1.DBOSCloudHost, options.json);
|
119
124
|
process.exit(exitCode);
|
120
125
|
}));
|
121
126
|
userdbCommands
|
122
127
|
.command('delete')
|
123
128
|
.argument('<string>', 'database name')
|
124
129
|
.action((async (dbname) => {
|
125
|
-
const
|
126
|
-
const exitCode = await (0, userdb_1.deleteUserDb)(host, dbname);
|
130
|
+
const exitCode = await (0, userdb_1.deleteUserDb)(cloudutils_1.DBOSCloudHost, dbname);
|
127
131
|
process.exit(exitCode);
|
128
132
|
}));
|
129
133
|
program.parse(process.argv);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cli.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AACxB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cli.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AACxB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAA6E;AAC7E,6CAA6C;AAC7C,8DAAyD;AAEzD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,8DAA8D;AAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAwB,CAAC;AAC5E,OAAO;IACL,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAE/B,qBAAqB;AACrB,qBAAqB;AACrB,qBAAqB;AAErB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,sBAAsB,CAAC;KACnC,cAAc,CAAC,yBAAyB,EAAE,UAAU,CAAC;KACrD,MAAM,CAAC,KAAK,EAAE,OAA6B,EAAE,EAAE;IAC9C,MAAM,QAAQ,GAAG,MAAM,IAAA,aAAK,EAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,0CAA0C,CAAC;KACvD,cAAc,CAAC,yBAAyB,EAAE,UAAU,CAAC;KACrD,MAAM,CAAC,KAAK,EAAE,OAA4B,EAAE,EAAE;IAC7C,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAY,EAAC,OAAO,CAAC,QAAQ,EAAE,0BAAa,CAAC,CAAC;IACrE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAEL,6BAA6B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CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC,CAAA;AAEL,cAAc;KACX,OAAO,CAAC,QAAQ,CAAC;KACjB,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;KACrC,MAAM,CAAC,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;IAChC,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAAC,0BAAa,EAAE,MAAM,CAAC,CAAA;IAC1D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC,CAAA;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,oDAAoD;AACpD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
@@ -1,8 +1,13 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { DBOSCloudCredentials } from "./login";
|
3
2
|
import { Logger } from "winston";
|
4
3
|
import { AxiosError } from "axios";
|
4
|
+
export interface DBOSCloudCredentials {
|
5
|
+
token: string;
|
6
|
+
userName: string;
|
7
|
+
}
|
5
8
|
export declare const dbosConfigFilePath = "dbos-config.yaml";
|
9
|
+
export declare const DBOSCloudHost: string;
|
10
|
+
export declare const dbosEnvPath = ".dbos";
|
6
11
|
export declare function getLogger(): Logger;
|
7
12
|
export declare function getCloudCredentials(): DBOSCloudCredentials;
|
8
13
|
export declare function credentialsExist(): boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloudutils.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"cloudutils.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAGnC,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AACrD,eAAO,MAAM,aAAa,QAA8C,CAAC;AACzE,eAAO,MAAM,WAAW,UAAU,CAAC;AAGnC,wBAAgB,SAAS,IAAI,MAAM,CASlC;AA+BD,wBAAgB,mBAAmB,IAAI,oBAAoB,CAgB1D;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAGD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBhF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,GAAG,MAAM,CAa7F;AAED,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAA0C,CAAC;AAE3E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGrC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhE;AAED,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,qBAAqB,CAKlF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,QAI3D"}
|
@@ -3,12 +3,14 @@ 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.handleAPIErrors = exports.isCloudAPIErrorResponse = exports.createDirectory = exports.sleep = exports.readFileSync = exports.runCommand = exports.credentialsExist = exports.getCloudCredentials = exports.getLogger = exports.dbosConfigFilePath = void 0;
|
7
|
-
const login_1 = require("./login");
|
6
|
+
exports.handleAPIErrors = exports.isCloudAPIErrorResponse = exports.createDirectory = exports.sleep = exports.readFileSync = exports.runCommand = exports.credentialsExist = exports.getCloudCredentials = exports.getLogger = exports.dbosEnvPath = exports.DBOSCloudHost = exports.dbosConfigFilePath = void 0;
|
8
7
|
const child_process_1 = require("child_process");
|
9
8
|
const winston_1 = require("winston");
|
10
9
|
const fs_1 = __importDefault(require("fs"));
|
10
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
11
11
|
exports.dbosConfigFilePath = "dbos-config.yaml";
|
12
|
+
exports.DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
|
13
|
+
exports.dbosEnvPath = ".dbos";
|
12
14
|
// FIXME: we should have a global instance of the logger created in cli.ts
|
13
15
|
function getLogger() {
|
14
16
|
const winstonTransports = [];
|
@@ -30,21 +32,37 @@ const consoleFormat = winston_1.format.combine(winston_1.format.errors({ stack:
|
|
30
32
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
31
33
|
return `${ts} [${level}]: ${messageString} ${stack ? "\n" + formattedStack : ""}`;
|
32
34
|
}));
|
35
|
+
function isTokenExpired(token) {
|
36
|
+
try {
|
37
|
+
const { exp } = jsonwebtoken_1.default.decode(token);
|
38
|
+
if (!exp)
|
39
|
+
return false;
|
40
|
+
return Date.now() >= exp * 1000;
|
41
|
+
}
|
42
|
+
catch (error) {
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
}
|
33
46
|
function getCloudCredentials() {
|
34
47
|
const logger = getLogger();
|
35
48
|
if (!credentialsExist()) {
|
36
49
|
logger.error("Error: not logged in");
|
37
50
|
process.exit(1);
|
38
51
|
}
|
39
|
-
const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${
|
40
|
-
|
52
|
+
const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${exports.dbosEnvPath}/credentials`).toString("utf-8"));
|
53
|
+
const credentials = {
|
41
54
|
userName: userCredentials.userName,
|
42
55
|
token: userCredentials.token.replace(/\r|\n/g, ""), // Trim the trailing /r /n.
|
43
56
|
};
|
57
|
+
if (isTokenExpired(credentials.token)) {
|
58
|
+
logger.error("Error: Login expired. Please log in again with 'npx dbos-cloud login -u <username>'");
|
59
|
+
process.exit(1);
|
60
|
+
}
|
61
|
+
return credentials;
|
44
62
|
}
|
45
63
|
exports.getCloudCredentials = getCloudCredentials;
|
46
64
|
function credentialsExist() {
|
47
|
-
return fs_1.default.existsSync(`./${
|
65
|
+
return fs_1.default.existsSync(`./${exports.dbosEnvPath}/credentials`);
|
48
66
|
}
|
49
67
|
exports.credentialsExist = credentialsExist;
|
50
68
|
// Run a command, streaming its output to stdout
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloudutils.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"cloudutils.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";;;;;;AACA,iDAAoD;AACpD,qCAAmE;AACnE,4CAAoB;AAEpB,gEAA+B;AAOlB,QAAA,kBAAkB,GAAG,kBAAkB,CAAC;AACxC,QAAA,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,gBAAgB,CAAC;AAC5D,QAAA,WAAW,GAAG,OAAO,CAAC;AAEnC,0EAA0E;AAC1E,SAAgB,SAAS;IACvB,MAAM,iBAAiB,GAAsB,EAAE,CAAC;IAChD,iBAAiB,CAAC,IAAI,CACpB,IAAI,oBAAU,CAAC,OAAO,CAAC;QACrB,MAAM,EAAE,aAAa;QACrB,KAAK,EAAG,MAAM;KACf,CAAC,CACH,CAAC;I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C;AAA9D,QAAA,KAAK,SAAyD;AAK3E,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,YAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,0CAEC;AAQD,SAAgB,uBAAuB,CAAC,GAAY;IAClD,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAC5C,SAAS,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,QAAQ;QACtD,YAAY,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,QAAQ;QAC5D,WAAW,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,QAAQ,CAAC;AAC/D,CAAC;AALD,0DAKC;AAED,SAAgB,eAAe,CAAC,KAAa,EAAE,CAAa;IAC1D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,IAAI,GAA0B,CAAC,CAAC,QAAQ,EAAE,IAA6B,CAAC;IAC9E,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,KAAK,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;AACjE,CAAC;AAJD,0CAIC"}
|
@@ -1,9 +1,2 @@
|
|
1
|
-
export declare const dbosEnvPath = ".dbos";
|
2
|
-
export declare const DBOSClientID = "G38fLmVErczEo9ioCFjVIHea6yd0qMZu";
|
3
|
-
export declare const DBOSCloudIdentifier = "dbos-cloud-api";
|
4
|
-
export interface DBOSCloudCredentials {
|
5
|
-
token: string;
|
6
|
-
userName: string;
|
7
|
-
}
|
8
1
|
export declare function login(username: string): Promise<number>;
|
9
2
|
//# sourceMappingURL=login.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[],"mappings":"AAyDA,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4D7D"}
|
@@ -3,18 +3,20 @@ 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.login =
|
6
|
+
exports.login = void 0;
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
8
8
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
9
9
|
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
10
10
|
const child_process_1 = require("child_process");
|
11
11
|
const fs_1 = __importDefault(require("fs"));
|
12
12
|
const cloudutils_1 = require("./cloudutils");
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
const DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
|
14
|
+
const productionEnvironment = DBOSCloudHost === "cloud.dbos.dev";
|
15
|
+
const Auth0Domain = productionEnvironment ? 'login.dbos.dev' : 'dbos-inc.us.auth0.com';
|
16
|
+
const DBOSClientID = productionEnvironment ? '6p7Sjxf13cyLMkdwn14MxlH7JdhILled' : 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu';
|
17
|
+
const DBOSCloudIdentifier = 'dbos-cloud-api';
|
16
18
|
const client = (0, jwks_rsa_1.default)({
|
17
|
-
jwksUri:
|
19
|
+
jwksUri: `https://${Auth0Domain}/.well-known/jwks.json`
|
18
20
|
});
|
19
21
|
async function getSigningKey(kid) {
|
20
22
|
const key = await client.getSigningKey(kid);
|
@@ -42,9 +44,9 @@ async function login(username) {
|
|
42
44
|
logger.info(`Please authenticate with DBOS Cloud!`);
|
43
45
|
const deviceCodeRequest = {
|
44
46
|
method: 'POST',
|
45
|
-
url:
|
47
|
+
url: `https://${Auth0Domain}/oauth/device/code`,
|
46
48
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
47
|
-
data: { client_id:
|
49
|
+
data: { client_id: DBOSClientID, scope: 'sub', audience: DBOSCloudIdentifier }
|
48
50
|
};
|
49
51
|
let deviceCodeResponse;
|
50
52
|
try {
|
@@ -61,12 +63,12 @@ async function login(username) {
|
|
61
63
|
console.log(`Login URL: ${deviceCodeResponse.verification_uri_complete}`);
|
62
64
|
const tokenRequest = {
|
63
65
|
method: 'POST',
|
64
|
-
url:
|
66
|
+
url: `https://${Auth0Domain}/oauth/token`,
|
65
67
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
66
68
|
data: new URLSearchParams({
|
67
69
|
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
68
70
|
device_code: deviceCodeResponse.device_code,
|
69
|
-
client_id:
|
71
|
+
client_id: DBOSClientID
|
70
72
|
})
|
71
73
|
};
|
72
74
|
let tokenResponse;
|
@@ -91,10 +93,10 @@ async function login(username) {
|
|
91
93
|
token: tokenResponse.access_token,
|
92
94
|
userName: username,
|
93
95
|
};
|
94
|
-
(0, child_process_1.execSync)(`mkdir -p ${
|
95
|
-
fs_1.default.writeFileSync(`${
|
96
|
+
(0, child_process_1.execSync)(`mkdir -p ${cloudutils_1.dbosEnvPath}`);
|
97
|
+
fs_1.default.writeFileSync(`${cloudutils_1.dbosEnvPath}/credentials`, JSON.stringify(credentials), "utf-8");
|
96
98
|
logger.info(`Successfully logged in as user: ${credentials.userName}`);
|
97
|
-
logger.info(`You can view your credentials in: ./${
|
99
|
+
logger.info(`You can view your credentials in: ./${cloudutils_1.dbosEnvPath}/credentials`);
|
98
100
|
return 0;
|
99
101
|
}
|
100
102
|
exports.login = login;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gEAA+C;AAC/C,wDAAkC;A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AAM,CAAC,IAAI,CAAC,mCAAmC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvE,MAAM,CAAC,IAAI,CAAC,uCAAuC,wBAAW,cAAc,CAAC,CAAC;IAC9E,OAAO,CAAC,CAAC;AACX,CAAC;AA5DD,sBA4DC"}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
export interface UserDBInstance {
|
2
|
-
readonly
|
2
|
+
readonly PostgresInstanceName: string;
|
3
3
|
readonly Status: string;
|
4
4
|
readonly HostName: string;
|
5
5
|
readonly Port: number;
|
6
|
+
readonly AdminUsername: string;
|
6
7
|
}
|
7
8
|
export declare function createUserDb(host: string, dbName: string, adminName: string, adminPassword: string, sync: boolean): Promise<1 | 0>;
|
8
9
|
export declare function deleteUserDb(host: string, dbName: string): Promise<1 | 0>;
|
9
10
|
export declare function getUserDb(host: string, dbName: string, json: boolean): Promise<1 | 0>;
|
11
|
+
export declare function listUserDB(host: string, json: boolean): Promise<1 | 0>;
|
10
12
|
export declare function getUserDBInfo(host: string, dbName: string): Promise<UserDBInstance>;
|
11
13
|
//# sourceMappingURL=userdb.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userdb.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/userdb.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,
|
1
|
+
{"version":3,"file":"userdb.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/userdb.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,kBAuCvH;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAwB9D;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,kBAyB1E;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,kBAqC3D;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAYzF"}
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.getUserDBInfo = exports.getUserDb = exports.deleteUserDb = exports.createUserDb = void 0;
|
6
|
+
exports.getUserDBInfo = exports.listUserDB = exports.getUserDb = exports.deleteUserDb = exports.createUserDb = void 0;
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
8
8
|
const cloudutils_1 = require("./cloudutils");
|
9
9
|
const utils_1 = require("../../src/utils");
|
@@ -78,11 +78,11 @@ async function getUserDb(host, dbName, json) {
|
|
78
78
|
console.log(JSON.stringify(userDBInfo));
|
79
79
|
}
|
80
80
|
else {
|
81
|
-
|
82
|
-
console.log(`DB Name: ${userDBInfo.DBName}`);
|
81
|
+
console.log(`Postgres Instance Name: ${userDBInfo.PostgresInstanceName}`);
|
83
82
|
console.log(`Status: ${userDBInfo.Status}`);
|
84
83
|
console.log(`Host Name: ${userDBInfo.HostName}`);
|
85
84
|
console.log(`Port: ${userDBInfo.Port}`);
|
85
|
+
console.log(`Admin Username: ${userDBInfo.AdminUsername}`);
|
86
86
|
}
|
87
87
|
return 0;
|
88
88
|
}
|
@@ -99,6 +99,45 @@ async function getUserDb(host, dbName, json) {
|
|
99
99
|
}
|
100
100
|
}
|
101
101
|
exports.getUserDb = getUserDb;
|
102
|
+
async function listUserDB(host, json) {
|
103
|
+
const logger = (0, cloudutils_1.getLogger)();
|
104
|
+
try {
|
105
|
+
const userCredentials = (0, cloudutils_1.getCloudCredentials)();
|
106
|
+
const bearerToken = "Bearer " + userCredentials.token;
|
107
|
+
const res = await axios_1.default.get(`https://${host}/${userCredentials.userName}/databases`, {
|
108
|
+
headers: {
|
109
|
+
"Content-Type": "application/json",
|
110
|
+
Authorization: bearerToken,
|
111
|
+
},
|
112
|
+
});
|
113
|
+
const userDBs = res.data;
|
114
|
+
if (json) {
|
115
|
+
console.log(JSON.stringify(userDBs));
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
userDBs.forEach(userDBInfo => {
|
119
|
+
console.log(`Postgres Instance Name: ${userDBInfo.PostgresInstanceName}`);
|
120
|
+
console.log(`Status: ${userDBInfo.Status}`);
|
121
|
+
console.log(`Host Name: ${userDBInfo.HostName}`);
|
122
|
+
console.log(`Port: ${userDBInfo.Port}`);
|
123
|
+
console.log(`Admin Username: ${userDBInfo.AdminUsername}`);
|
124
|
+
});
|
125
|
+
}
|
126
|
+
return 0;
|
127
|
+
}
|
128
|
+
catch (e) {
|
129
|
+
const errorLabel = `Failed to retrieve info`;
|
130
|
+
const axiosError = e;
|
131
|
+
if ((0, cloudutils_1.isCloudAPIErrorResponse)(axiosError.response?.data)) {
|
132
|
+
(0, cloudutils_1.handleAPIErrors)(errorLabel, axiosError);
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
logger.error(`${errorLabel}: ${e.message}`);
|
136
|
+
}
|
137
|
+
return 1;
|
138
|
+
}
|
139
|
+
}
|
140
|
+
exports.listUserDB = listUserDB;
|
102
141
|
async function getUserDBInfo(host, dbName) {
|
103
142
|
const userCredentials = (0, cloudutils_1.getCloudCredentials)();
|
104
143
|
const bearerToken = "Bearer " + userCredentials.token;
|
@@ -108,7 +147,6 @@ async function getUserDBInfo(host, dbName) {
|
|
108
147
|
Authorization: bearerToken,
|
109
148
|
},
|
110
149
|
});
|
111
|
-
// TODO: this needs a type guard
|
112
150
|
return res.data;
|
113
151
|
}
|
114
152
|
exports.getUserDBInfo = getUserDBInfo;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userdb.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/userdb.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAC1C,6CAAwG;AACxG,2CAAwC;
|
1
|
+
{"version":3,"file":"userdb.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/userdb.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAC1C,6CAAwG;AACxG,2CAAwC;AAUjC,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc,EAAE,SAAiB,EAAE,aAAqB,EAAE,IAAa;IACtH,MAAM,MAAM,GAAG,IAAA,sBAAS,GAAE,CAAC;IAC3B,MAAM,eAAe,GAAG,IAAA,gCAAmB,GAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,eAAK,CAAC,IAAI,CACd,WAAW,IAAI,IAAI,eAAe,CAAC,QAAQ,mBAAmB,EAC9D,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,EACpE;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,WAAW;aAC3B;SACF,CACF,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,2CAA2C,MAAM,EAAE,CAAC,CAAC;QAEjE,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,OAAO,MAAM,IAAI,WAAW,IAAI,MAAM,IAAI,YAAY,EAAE,CAAC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AClB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CACtC;AAID,eAAO,MAAM,IAAI,QACV,MAAM,WACF,MAAM,EAAE,QACX,MAAM,eACW,UAAU,oBA6BlC,CAAA;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/dbos-runtime/init.ts"],"names":[],"mappings":"AAMA,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;CACtC;AAID,eAAO,MAAM,IAAI,QACV,MAAM,WACF,MAAM,EAAE,QACX,MAAM,eACW,UAAU,oBA6BlC,CAAA;AAED,wBAAsB,IAAI,CAAC,OAAO,EAAE,MAAM,iBAmBzC"}
|