@dbos-inc/dbos-cloud 0.9.9-preview → 0.9.11-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.ts +12 -25
- package/cloudutils.ts +8 -1
- package/dist/packages/dbos-cloud/cli.js +13 -25
- package/dist/packages/dbos-cloud/cli.js.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts +7 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.js +6 -4
- package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
- package/dist/packages/dbos-cloud/login.d.ts +2 -6
- package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/login.js +9 -9
- package/dist/packages/dbos-cloud/login.js.map +1 -1
- package/dist/packages/dbos-cloud/userdb.d.ts +3 -3
- package/login.ts +7 -12
- package/package.json +1 -1
package/cli.ts
CHANGED
|
@@ -12,11 +12,10 @@ import { Command } from 'commander';
|
|
|
12
12
|
import { login } from "./login";
|
|
13
13
|
import { registerUser } from "./register";
|
|
14
14
|
import { createUserDb, getUserDb, deleteUserDb } from "./userdb";
|
|
15
|
+
import { DBOSCloudHost } from "./cloudutils";
|
|
15
16
|
|
|
16
17
|
const program = new Command();
|
|
17
18
|
|
|
18
|
-
const DEFAULT_HOST = process.env.DBOS_DOMAIN; // TODO: Once we have a "production" cluster, hardcode its domain name here
|
|
19
|
-
|
|
20
19
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
21
20
|
const packageJson = require('../../../package.json') as { version: string };
|
|
22
21
|
program.
|
|
@@ -39,9 +38,8 @@ program
|
|
|
39
38
|
.command('register')
|
|
40
39
|
.description('Register a user and log in to DBOS cloud')
|
|
41
40
|
.requiredOption('-u, --username <string>', 'Username')
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
const exitCode = await registerUser(options.username, options.host);
|
|
41
|
+
.action(async (options: { username: string}) => {
|
|
42
|
+
const exitCode = await registerUser(options.username, DBOSCloudHost);
|
|
45
43
|
process.exit(exitCode);
|
|
46
44
|
});
|
|
47
45
|
|
|
@@ -52,15 +50,13 @@ program
|
|
|
52
50
|
const applicationCommands = program
|
|
53
51
|
.command('applications')
|
|
54
52
|
.description('Manage your DBOS applications')
|
|
55
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST)
|
|
56
53
|
|
|
57
54
|
applicationCommands
|
|
58
55
|
.command('register')
|
|
59
56
|
.description('Register a new application')
|
|
60
57
|
.requiredOption('-d, --database <string>', 'Specify the app database name')
|
|
61
58
|
.action(async (options: { database: string }) => {
|
|
62
|
-
const
|
|
63
|
-
const exitCode = await registerApp(options.database, host);
|
|
59
|
+
const exitCode = await registerApp(options.database, DBOSCloudHost);
|
|
64
60
|
process.exit(exitCode);
|
|
65
61
|
});
|
|
66
62
|
|
|
@@ -68,8 +64,7 @@ applicationCommands
|
|
|
68
64
|
.command('update')
|
|
69
65
|
.description('Update an application')
|
|
70
66
|
.action(async () => {
|
|
71
|
-
const
|
|
72
|
-
const exitCode = await updateApp(host);
|
|
67
|
+
const exitCode = await updateApp(DBOSCloudHost);
|
|
73
68
|
process.exit(exitCode);
|
|
74
69
|
});
|
|
75
70
|
|
|
@@ -78,8 +73,7 @@ applicationCommands
|
|
|
78
73
|
.description('Deploy an application code to the cloud')
|
|
79
74
|
.option('--no-docker', 'Build the code locally without using Docker')
|
|
80
75
|
.action(async (options: { docker: boolean }) => {
|
|
81
|
-
const
|
|
82
|
-
const exitCode = await deployAppCode(host, options.docker);
|
|
76
|
+
const exitCode = await deployAppCode(DBOSCloudHost, options.docker);
|
|
83
77
|
process.exit(exitCode);
|
|
84
78
|
});
|
|
85
79
|
|
|
@@ -87,8 +81,7 @@ applicationCommands
|
|
|
87
81
|
.command('delete')
|
|
88
82
|
.description('Delete a previously deployed application')
|
|
89
83
|
.action(async () => {
|
|
90
|
-
const
|
|
91
|
-
const exitCode = await deleteApp(host);
|
|
84
|
+
const exitCode = await deleteApp(DBOSCloudHost);
|
|
92
85
|
process.exit(exitCode);
|
|
93
86
|
});
|
|
94
87
|
|
|
@@ -97,8 +90,7 @@ applicationCommands
|
|
|
97
90
|
.description('List all deployed applications')
|
|
98
91
|
.option('--json', 'Emit JSON output')
|
|
99
92
|
.action(async (options: { json: boolean }) => {
|
|
100
|
-
const
|
|
101
|
-
const exitCode = await listApps(host, options.json);
|
|
93
|
+
const exitCode = await listApps(DBOSCloudHost, options.json);
|
|
102
94
|
process.exit(exitCode);
|
|
103
95
|
});
|
|
104
96
|
|
|
@@ -107,8 +99,7 @@ applicationCommands
|
|
|
107
99
|
.description('Print the microVM logs of a deployed application')
|
|
108
100
|
.option('-l, --last <integer>', 'How far back to query, in seconds from current time. By default, we retrieve all data', parseInt)
|
|
109
101
|
.action(async (options: { last: number}) => {
|
|
110
|
-
const
|
|
111
|
-
const exitCode = await getAppLogs(host, options.last);
|
|
102
|
+
const exitCode = await getAppLogs(DBOSCloudHost, options.last);
|
|
112
103
|
process.exit(exitCode);
|
|
113
104
|
});
|
|
114
105
|
|
|
@@ -119,7 +110,6 @@ applicationCommands
|
|
|
119
110
|
const userdbCommands = program
|
|
120
111
|
.command('userdb')
|
|
121
112
|
.description('Manage your databases')
|
|
122
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST)
|
|
123
113
|
|
|
124
114
|
userdbCommands
|
|
125
115
|
.command('create')
|
|
@@ -128,8 +118,7 @@ userdbCommands
|
|
|
128
118
|
.requiredOption('-W, --password <string>', 'Specify the admin password')
|
|
129
119
|
.option('-s, --sync', 'make synchronous call', true)
|
|
130
120
|
.action((async (dbname: string, options: { admin: string, password: string, sync: boolean }) => {
|
|
131
|
-
const
|
|
132
|
-
const exitCode = await createUserDb(host, dbname, options.admin, options.password, options.sync)
|
|
121
|
+
const exitCode = await createUserDb(DBOSCloudHost, dbname, options.admin, options.password, options.sync)
|
|
133
122
|
process.exit(exitCode);
|
|
134
123
|
}))
|
|
135
124
|
|
|
@@ -138,8 +127,7 @@ userdbCommands
|
|
|
138
127
|
.argument('<string>', 'database name')
|
|
139
128
|
.option('--json', 'Emit JSON output')
|
|
140
129
|
.action((async (dbname: string, options: { json: boolean}) => {
|
|
141
|
-
const
|
|
142
|
-
const exitCode = await getUserDb(host, dbname, options.json)
|
|
130
|
+
const exitCode = await getUserDb(DBOSCloudHost, dbname, options.json)
|
|
143
131
|
process.exit(exitCode);
|
|
144
132
|
}))
|
|
145
133
|
|
|
@@ -147,8 +135,7 @@ userdbCommands
|
|
|
147
135
|
.command('delete')
|
|
148
136
|
.argument('<string>', 'database name')
|
|
149
137
|
.action((async (dbname: string) => {
|
|
150
|
-
const
|
|
151
|
-
const exitCode = await deleteUserDb(host, dbname)
|
|
138
|
+
const exitCode = await deleteUserDb(DBOSCloudHost, dbname)
|
|
152
139
|
process.exit(exitCode);
|
|
153
140
|
}))
|
|
154
141
|
|
package/cloudutils.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import { DBOSCloudCredentials, dbosEnvPath } from "./login";
|
|
2
1
|
import TransportStream = require("winston-transport");
|
|
3
2
|
import { spawn, StdioOptions } from 'child_process';
|
|
4
3
|
import { transports, createLogger, format, Logger } from "winston";
|
|
5
4
|
import fs from "fs";
|
|
6
5
|
import { AxiosError } from "axios";
|
|
7
6
|
|
|
7
|
+
export interface DBOSCloudCredentials {
|
|
8
|
+
token: string;
|
|
9
|
+
userName: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
export const dbosConfigFilePath = "dbos-config.yaml";
|
|
13
|
+
export const DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
|
|
14
|
+
export const productionEnvironment = DBOSCloudHost === "cloud.dbos.dev";
|
|
15
|
+
export const dbosEnvPath = ".dbos";
|
|
9
16
|
|
|
10
17
|
// FIXME: we should have a global instance of the logger created in cli.ts
|
|
11
18
|
export function getLogger(): Logger {
|
|
@@ -6,8 +6,8 @@ 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");
|
|
9
10
|
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
11
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
12
|
const packageJson = require('../../../package.json');
|
|
13
13
|
program.
|
|
@@ -27,9 +27,8 @@ program
|
|
|
27
27
|
.command('register')
|
|
28
28
|
.description('Register a user and log in to DBOS cloud')
|
|
29
29
|
.requiredOption('-u, --username <string>', 'Username')
|
|
30
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST)
|
|
31
30
|
.action(async (options) => {
|
|
32
|
-
const exitCode = await (0, register_1.registerUser)(options.username,
|
|
31
|
+
const exitCode = await (0, register_1.registerUser)(options.username, cloudutils_1.DBOSCloudHost);
|
|
33
32
|
process.exit(exitCode);
|
|
34
33
|
});
|
|
35
34
|
/////////////////////////////
|
|
@@ -37,23 +36,20 @@ program
|
|
|
37
36
|
/////////////////////////////
|
|
38
37
|
const applicationCommands = program
|
|
39
38
|
.command('applications')
|
|
40
|
-
.description('Manage your DBOS applications')
|
|
41
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST);
|
|
39
|
+
.description('Manage your DBOS applications');
|
|
42
40
|
applicationCommands
|
|
43
41
|
.command('register')
|
|
44
42
|
.description('Register a new application')
|
|
45
43
|
.requiredOption('-d, --database <string>', 'Specify the app database name')
|
|
46
44
|
.action(async (options) => {
|
|
47
|
-
const
|
|
48
|
-
const exitCode = await (0, applications_1.registerApp)(options.database, host);
|
|
45
|
+
const exitCode = await (0, applications_1.registerApp)(options.database, cloudutils_1.DBOSCloudHost);
|
|
49
46
|
process.exit(exitCode);
|
|
50
47
|
});
|
|
51
48
|
applicationCommands
|
|
52
49
|
.command('update')
|
|
53
50
|
.description('Update an application')
|
|
54
51
|
.action(async () => {
|
|
55
|
-
const
|
|
56
|
-
const exitCode = await (0, applications_1.updateApp)(host);
|
|
52
|
+
const exitCode = await (0, applications_1.updateApp)(cloudutils_1.DBOSCloudHost);
|
|
57
53
|
process.exit(exitCode);
|
|
58
54
|
});
|
|
59
55
|
applicationCommands
|
|
@@ -61,16 +57,14 @@ applicationCommands
|
|
|
61
57
|
.description('Deploy an application code to the cloud')
|
|
62
58
|
.option('--no-docker', 'Build the code locally without using Docker')
|
|
63
59
|
.action(async (options) => {
|
|
64
|
-
const
|
|
65
|
-
const exitCode = await (0, applications_1.deployAppCode)(host, options.docker);
|
|
60
|
+
const exitCode = await (0, applications_1.deployAppCode)(cloudutils_1.DBOSCloudHost, options.docker);
|
|
66
61
|
process.exit(exitCode);
|
|
67
62
|
});
|
|
68
63
|
applicationCommands
|
|
69
64
|
.command('delete')
|
|
70
65
|
.description('Delete a previously deployed application')
|
|
71
66
|
.action(async () => {
|
|
72
|
-
const
|
|
73
|
-
const exitCode = await (0, applications_1.deleteApp)(host);
|
|
67
|
+
const exitCode = await (0, applications_1.deleteApp)(cloudutils_1.DBOSCloudHost);
|
|
74
68
|
process.exit(exitCode);
|
|
75
69
|
});
|
|
76
70
|
applicationCommands
|
|
@@ -78,8 +72,7 @@ applicationCommands
|
|
|
78
72
|
.description('List all deployed applications')
|
|
79
73
|
.option('--json', 'Emit JSON output')
|
|
80
74
|
.action(async (options) => {
|
|
81
|
-
const
|
|
82
|
-
const exitCode = await (0, applications_1.listApps)(host, options.json);
|
|
75
|
+
const exitCode = await (0, applications_1.listApps)(cloudutils_1.DBOSCloudHost, options.json);
|
|
83
76
|
process.exit(exitCode);
|
|
84
77
|
});
|
|
85
78
|
applicationCommands
|
|
@@ -87,8 +80,7 @@ applicationCommands
|
|
|
87
80
|
.description('Print the microVM logs of a deployed application')
|
|
88
81
|
.option('-l, --last <integer>', 'How far back to query, in seconds from current time. By default, we retrieve all data', parseInt)
|
|
89
82
|
.action(async (options) => {
|
|
90
|
-
const
|
|
91
|
-
const exitCode = await (0, applications_1.getAppLogs)(host, options.last);
|
|
83
|
+
const exitCode = await (0, applications_1.getAppLogs)(cloudutils_1.DBOSCloudHost, options.last);
|
|
92
84
|
process.exit(exitCode);
|
|
93
85
|
});
|
|
94
86
|
//////////////////////////////
|
|
@@ -96,8 +88,7 @@ applicationCommands
|
|
|
96
88
|
//////////////////////////////
|
|
97
89
|
const userdbCommands = program
|
|
98
90
|
.command('userdb')
|
|
99
|
-
.description('Manage your databases')
|
|
100
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST);
|
|
91
|
+
.description('Manage your databases');
|
|
101
92
|
userdbCommands
|
|
102
93
|
.command('create')
|
|
103
94
|
.argument('<string>', 'database name')
|
|
@@ -105,8 +96,7 @@ userdbCommands
|
|
|
105
96
|
.requiredOption('-W, --password <string>', 'Specify the admin password')
|
|
106
97
|
.option('-s, --sync', 'make synchronous call', true)
|
|
107
98
|
.action((async (dbname, options) => {
|
|
108
|
-
const
|
|
109
|
-
const exitCode = await (0, userdb_1.createUserDb)(host, dbname, options.admin, options.password, options.sync);
|
|
99
|
+
const exitCode = await (0, userdb_1.createUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.admin, options.password, options.sync);
|
|
110
100
|
process.exit(exitCode);
|
|
111
101
|
}));
|
|
112
102
|
userdbCommands
|
|
@@ -114,16 +104,14 @@ userdbCommands
|
|
|
114
104
|
.argument('<string>', 'database name')
|
|
115
105
|
.option('--json', 'Emit JSON output')
|
|
116
106
|
.action((async (dbname, options) => {
|
|
117
|
-
const
|
|
118
|
-
const exitCode = await (0, userdb_1.getUserDb)(host, dbname, options.json);
|
|
107
|
+
const exitCode = await (0, userdb_1.getUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.json);
|
|
119
108
|
process.exit(exitCode);
|
|
120
109
|
}));
|
|
121
110
|
userdbCommands
|
|
122
111
|
.command('delete')
|
|
123
112
|
.argument('<string>', 'database name')
|
|
124
113
|
.action((async (dbname) => {
|
|
125
|
-
const
|
|
126
|
-
const exitCode = await (0, userdb_1.deleteUserDb)(host, dbname);
|
|
114
|
+
const exitCode = await (0, userdb_1.deleteUserDb)(cloudutils_1.DBOSCloudHost, dbname);
|
|
127
115
|
process.exit(exitCode);
|
|
128
116
|
}));
|
|
129
117
|
program.parse(process.argv);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../cli.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AACxB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAAiE;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../cli.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AACxB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAAiE;AACjE,6CAA6C;AAE7C,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,yBAAy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,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,14 @@
|
|
|
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 productionEnvironment: boolean;
|
|
11
|
+
export declare const dbosEnvPath = ".dbos";
|
|
6
12
|
export declare function getLogger(): Logger;
|
|
7
13
|
export declare function getCloudCredentials(): DBOSCloudCredentials;
|
|
8
14
|
export declare function credentialsExist(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudutils.d.ts","sourceRoot":"","sources":["../../../cloudutils.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cloudutils.d.ts","sourceRoot":"","sources":["../../../cloudutils.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,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,qBAAqB,SAAqC,CAAC;AACxE,eAAO,MAAM,WAAW,UAAU,CAAC;AAGnC,wBAAgB,SAAS,IAAI,MAAM,CASlC;AAqBD,wBAAgB,mBAAmB,IAAI,oBAAoB,CAW1D;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.productionEnvironment = 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"));
|
|
11
10
|
exports.dbosConfigFilePath = "dbos-config.yaml";
|
|
11
|
+
exports.DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
|
|
12
|
+
exports.productionEnvironment = exports.DBOSCloudHost === "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 = [];
|
|
@@ -36,7 +38,7 @@ function getCloudCredentials() {
|
|
|
36
38
|
logger.error("Error: not logged in");
|
|
37
39
|
process.exit(1);
|
|
38
40
|
}
|
|
39
|
-
const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${
|
|
41
|
+
const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${exports.dbosEnvPath}/credentials`).toString("utf-8"));
|
|
40
42
|
return {
|
|
41
43
|
userName: userCredentials.userName,
|
|
42
44
|
token: userCredentials.token.replace(/\r|\n/g, ""), // Trim the trailing /r /n.
|
|
@@ -44,7 +46,7 @@ function getCloudCredentials() {
|
|
|
44
46
|
}
|
|
45
47
|
exports.getCloudCredentials = getCloudCredentials;
|
|
46
48
|
function credentialsExist() {
|
|
47
|
-
return fs_1.default.existsSync(`./${
|
|
49
|
+
return fs_1.default.existsSync(`./${exports.dbosEnvPath}/credentials`);
|
|
48
50
|
}
|
|
49
51
|
exports.credentialsExist = credentialsExist;
|
|
50
52
|
// Run a command, streaming its output to stdout
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudutils.js","sourceRoot":"","sources":["../../../cloudutils.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"cloudutils.js","sourceRoot":"","sources":["../../../c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AAe,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,5 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const DBOSClientID
|
|
1
|
+
export declare const Auth0Domain: string;
|
|
2
|
+
export declare const DBOSClientID: string;
|
|
3
3
|
export declare const DBOSCloudIdentifier = "dbos-cloud-api";
|
|
4
|
-
export interface DBOSCloudCredentials {
|
|
5
|
-
token: string;
|
|
6
|
-
userName: string;
|
|
7
|
-
}
|
|
8
4
|
export declare function login(username: string): Promise<number>;
|
|
9
5
|
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../login.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../login.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,WAAW,QAAqE,CAAC;AAC9F,eAAO,MAAM,YAAY,QAAkG,CAAC;AAC5H,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AA8CpD,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4D7D"}
|
|
@@ -3,18 +3,18 @@ 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 = exports.DBOSCloudIdentifier = exports.DBOSClientID = exports.
|
|
6
|
+
exports.login = exports.DBOSCloudIdentifier = exports.DBOSClientID = exports.Auth0Domain = 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
|
-
exports.
|
|
14
|
-
exports.DBOSClientID = 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu';
|
|
13
|
+
exports.Auth0Domain = cloudutils_1.productionEnvironment ? 'login.dbos.dev' : 'dbos-inc.us.auth0.com';
|
|
14
|
+
exports.DBOSClientID = cloudutils_1.productionEnvironment ? '6p7Sjxf13cyLMkdwn14MxlH7JdhILled' : 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu';
|
|
15
15
|
exports.DBOSCloudIdentifier = 'dbos-cloud-api';
|
|
16
16
|
const client = (0, jwks_rsa_1.default)({
|
|
17
|
-
jwksUri:
|
|
17
|
+
jwksUri: `https://${exports.Auth0Domain}/.well-known/jwks.json`
|
|
18
18
|
});
|
|
19
19
|
async function getSigningKey(kid) {
|
|
20
20
|
const key = await client.getSigningKey(kid);
|
|
@@ -42,7 +42,7 @@ async function login(username) {
|
|
|
42
42
|
logger.info(`Please authenticate with DBOS Cloud!`);
|
|
43
43
|
const deviceCodeRequest = {
|
|
44
44
|
method: 'POST',
|
|
45
|
-
url:
|
|
45
|
+
url: `https://${exports.Auth0Domain}/oauth/device/code`,
|
|
46
46
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
47
47
|
data: { client_id: exports.DBOSClientID, scope: 'sub', audience: exports.DBOSCloudIdentifier }
|
|
48
48
|
};
|
|
@@ -61,7 +61,7 @@ async function login(username) {
|
|
|
61
61
|
console.log(`Login URL: ${deviceCodeResponse.verification_uri_complete}`);
|
|
62
62
|
const tokenRequest = {
|
|
63
63
|
method: 'POST',
|
|
64
|
-
url:
|
|
64
|
+
url: `https://${exports.Auth0Domain}/oauth/token`,
|
|
65
65
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
66
66
|
data: new URLSearchParams({
|
|
67
67
|
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
|
@@ -91,10 +91,10 @@ async function login(username) {
|
|
|
91
91
|
token: tokenResponse.access_token,
|
|
92
92
|
userName: username,
|
|
93
93
|
};
|
|
94
|
-
(0, child_process_1.execSync)(`mkdir -p ${
|
|
95
|
-
fs_1.default.writeFileSync(`${
|
|
94
|
+
(0, child_process_1.execSync)(`mkdir -p ${cloudutils_1.dbosEnvPath}`);
|
|
95
|
+
fs_1.default.writeFileSync(`${cloudutils_1.dbosEnvPath}/credentials`, JSON.stringify(credentials), "utf-8");
|
|
96
96
|
logger.info(`Successfully logged in as user: ${credentials.userName}`);
|
|
97
|
-
logger.info(`You can view your credentials in: ./${
|
|
97
|
+
logger.info(`You can view your credentials in: ./${cloudutils_1.dbosEnvPath}/credentials`);
|
|
98
98
|
return 0;
|
|
99
99
|
}
|
|
100
100
|
exports.login = login;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../login.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gEAA+C;AAC/C,wDAAkC;AAClC,iDAAyC;AACzC,4CAAoB;AACpB,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../login.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gEAA+C;AAC/C,wDAAkC;AAClC,iDAAyC;AACzC,4CAAoB;AACpB,6CAA0G;AAE7F,QAAA,WAAW,GAAG,kCAAqB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,uBAAuB,CAAC;AACjF,QAAA,YAAY,GAAG,kCAAqB,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,kCAAkC,CAAC;AAC/G,QAAA,mBAAmB,GAAG,gBAAgB,CAAC;AAiBpD,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC;IACxB,OAAO,EAAE,WAAW,mBAAW,wBAAwB;CACxD,CAAC,CAAC;AAEH,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5C,OAAO,GAAG,CAAC,YAAY,EAAE,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,KAAa;IACtC,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAE3D,OAAO,IAAI,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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"}
|
|
@@ -4,8 +4,8 @@ export interface UserDBInstance {
|
|
|
4
4
|
readonly HostName: string;
|
|
5
5
|
readonly Port: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function createUserDb(host: string, dbName: string, adminName: string, adminPassword: string, sync: boolean): Promise<
|
|
8
|
-
export declare function deleteUserDb(host: string, dbName: string): Promise<
|
|
9
|
-
export declare function getUserDb(host: string, dbName: string, json: boolean): Promise<
|
|
7
|
+
export declare function createUserDb(host: string, dbName: string, adminName: string, adminPassword: string, sync: boolean): Promise<0 | 1>;
|
|
8
|
+
export declare function deleteUserDb(host: string, dbName: string): Promise<0 | 1>;
|
|
9
|
+
export declare function getUserDb(host: string, dbName: string, json: boolean): Promise<0 | 1>;
|
|
10
10
|
export declare function getUserDBInfo(host: string, dbName: string): Promise<UserDBInstance>;
|
|
11
11
|
//# sourceMappingURL=userdb.d.ts.map
|
package/login.ts
CHANGED
|
@@ -3,16 +3,11 @@ import jwt, { JwtPayload } from 'jsonwebtoken';
|
|
|
3
3
|
import jwksClient from 'jwks-rsa';
|
|
4
4
|
import { execSync } from "child_process";
|
|
5
5
|
import fs from "fs";
|
|
6
|
-
import { getLogger, sleep } from "./cloudutils";
|
|
6
|
+
import { DBOSCloudCredentials, dbosEnvPath, getLogger, productionEnvironment, sleep } from "./cloudutils";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
export const DBOSClientID = 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu'
|
|
10
|
-
export const DBOSCloudIdentifier = 'dbos-cloud-api'
|
|
11
|
-
|
|
12
|
-
export interface DBOSCloudCredentials {
|
|
13
|
-
token: string;
|
|
14
|
-
userName: string;
|
|
15
|
-
}
|
|
8
|
+
export const Auth0Domain = productionEnvironment ? 'login.dbos.dev' : 'dbos-inc.us.auth0.com';
|
|
9
|
+
export const DBOSClientID = productionEnvironment ? '6p7Sjxf13cyLMkdwn14MxlH7JdhILled' : 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu';
|
|
10
|
+
export const DBOSCloudIdentifier = 'dbos-cloud-api';
|
|
16
11
|
|
|
17
12
|
interface DeviceCodeResponse {
|
|
18
13
|
device_code: string;
|
|
@@ -30,7 +25,7 @@ interface TokenResponse {
|
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
const client = jwksClient({
|
|
33
|
-
jwksUri:
|
|
28
|
+
jwksUri: `https://${Auth0Domain}/.well-known/jwks.json`
|
|
34
29
|
});
|
|
35
30
|
|
|
36
31
|
async function getSigningKey(kid: string): Promise<string> {
|
|
@@ -64,7 +59,7 @@ export async function login(username: string): Promise<number> {
|
|
|
64
59
|
|
|
65
60
|
const deviceCodeRequest = {
|
|
66
61
|
method: 'POST',
|
|
67
|
-
url:
|
|
62
|
+
url: `https://${Auth0Domain}/oauth/device/code`,
|
|
68
63
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
69
64
|
data: { client_id: DBOSClientID, scope: 'sub', audience: DBOSCloudIdentifier }
|
|
70
65
|
};
|
|
@@ -83,7 +78,7 @@ export async function login(username: string): Promise<number> {
|
|
|
83
78
|
|
|
84
79
|
const tokenRequest = {
|
|
85
80
|
method: 'POST',
|
|
86
|
-
url:
|
|
81
|
+
url: `https://${Auth0Domain}/oauth/token`,
|
|
87
82
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
|
88
83
|
data: new URLSearchParams({
|
|
89
84
|
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|