@dbos-inc/dbos-sdk 0.9.16-preview → 0.9.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. package/dbos-config.schema.json +3 -6
  2. package/dbos-test-config.yaml +2 -2
  3. package/dist/src/dbos-executor.d.ts +1 -2
  4. package/dist/src/dbos-executor.d.ts.map +1 -1
  5. package/dist/src/dbos-executor.js.map +1 -1
  6. package/dist/src/dbos-runtime/config.d.ts +2 -3
  7. package/dist/src/dbos-runtime/config.d.ts.map +1 -1
  8. package/dist/src/dbos-runtime/config.js +5 -3
  9. package/dist/src/dbos-runtime/config.js.map +1 -1
  10. package/dist/src/dbos-runtime/migrate.js +8 -8
  11. package/dist/src/dbos-runtime/migrate.js.map +1 -1
  12. package/dist/src/testing/testing_runtime.d.ts +2 -0
  13. package/dist/src/testing/testing_runtime.d.ts.map +1 -1
  14. package/dist/src/testing/testing_runtime.js +4 -1
  15. package/dist/src/testing/testing_runtime.js.map +1 -1
  16. package/dist/tsconfig.build.tsbuildinfo +1 -1
  17. package/examples/hello/dbos-config.yaml +2 -2
  18. package/package.json +1 -1
  19. package/dist/packages/communicator-bcrypt/index.d.ts +0 -8
  20. package/dist/packages/communicator-bcrypt/index.d.ts.map +0 -1
  21. package/dist/packages/communicator-bcrypt/index.js +0 -43
  22. package/dist/packages/communicator-bcrypt/index.js.map +0 -1
  23. package/dist/packages/communicator-datetime/index.d.ts +0 -7
  24. package/dist/packages/communicator-datetime/index.d.ts.map +0 -1
  25. package/dist/packages/communicator-datetime/index.js +0 -35
  26. package/dist/packages/communicator-datetime/index.js.map +0 -1
  27. package/dist/packages/communicator-random/index.d.ts +0 -6
  28. package/dist/packages/communicator-random/index.d.ts.map +0 -1
  29. package/dist/packages/communicator-random/index.js +0 -26
  30. package/dist/packages/communicator-random/index.js.map +0 -1
  31. package/dist/packages/dbos-cloud/applications/delete-app.d.ts +0 -2
  32. package/dist/packages/dbos-cloud/applications/delete-app.d.ts.map +0 -1
  33. package/dist/packages/dbos-cloud/applications/delete-app.js +0 -42
  34. package/dist/packages/dbos-cloud/applications/delete-app.js.map +0 -1
  35. package/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts +0 -2
  36. package/dist/packages/dbos-cloud/applications/deploy-app-code.d.ts.map +0 -1
  37. package/dist/packages/dbos-cloud/applications/deploy-app-code.js +0 -160
  38. package/dist/packages/dbos-cloud/applications/deploy-app-code.js.map +0 -1
  39. package/dist/packages/dbos-cloud/applications/get-app-info.d.ts +0 -2
  40. package/dist/packages/dbos-cloud/applications/get-app-info.d.ts.map +0 -1
  41. package/dist/packages/dbos-cloud/applications/get-app-info.js +0 -54
  42. package/dist/packages/dbos-cloud/applications/get-app-info.js.map +0 -1
  43. package/dist/packages/dbos-cloud/applications/get-app-logs.d.ts +0 -2
  44. package/dist/packages/dbos-cloud/applications/get-app-logs.d.ts.map +0 -1
  45. package/dist/packages/dbos-cloud/applications/get-app-logs.js +0 -53
  46. package/dist/packages/dbos-cloud/applications/get-app-logs.js.map +0 -1
  47. package/dist/packages/dbos-cloud/applications/index.d.ts +0 -7
  48. package/dist/packages/dbos-cloud/applications/index.d.ts.map +0 -1
  49. package/dist/packages/dbos-cloud/applications/index.js +0 -16
  50. package/dist/packages/dbos-cloud/applications/index.js.map +0 -1
  51. package/dist/packages/dbos-cloud/applications/list-apps.d.ts +0 -2
  52. package/dist/packages/dbos-cloud/applications/list-apps.d.ts.map +0 -1
  53. package/dist/packages/dbos-cloud/applications/list-apps.js +0 -54
  54. package/dist/packages/dbos-cloud/applications/list-apps.js.map +0 -1
  55. package/dist/packages/dbos-cloud/applications/register-app.d.ts +0 -2
  56. package/dist/packages/dbos-cloud/applications/register-app.d.ts.map +0 -1
  57. package/dist/packages/dbos-cloud/applications/register-app.js +0 -47
  58. package/dist/packages/dbos-cloud/applications/register-app.js.map +0 -1
  59. package/dist/packages/dbos-cloud/applications/types.d.ts +0 -9
  60. package/dist/packages/dbos-cloud/applications/types.d.ts.map +0 -1
  61. package/dist/packages/dbos-cloud/applications/types.js +0 -3
  62. package/dist/packages/dbos-cloud/applications/types.js.map +0 -1
  63. package/dist/packages/dbos-cloud/applications/update-app.d.ts +0 -2
  64. package/dist/packages/dbos-cloud/applications/update-app.d.ts.map +0 -1
  65. package/dist/packages/dbos-cloud/applications/update-app.js +0 -46
  66. package/dist/packages/dbos-cloud/applications/update-app.js.map +0 -1
  67. package/dist/packages/dbos-cloud/cli.d.ts +0 -3
  68. package/dist/packages/dbos-cloud/cli.d.ts.map +0 -1
  69. package/dist/packages/dbos-cloud/cli.js +0 -138
  70. package/dist/packages/dbos-cloud/cli.js.map +0 -1
  71. package/dist/packages/dbos-cloud/cloudutils.d.ts +0 -27
  72. package/dist/packages/dbos-cloud/cloudutils.d.ts.map +0 -1
  73. package/dist/packages/dbos-cloud/cloudutils.js +0 -121
  74. package/dist/packages/dbos-cloud/cloudutils.js.map +0 -1
  75. package/dist/packages/dbos-cloud/login.d.ts +0 -2
  76. package/dist/packages/dbos-cloud/login.d.ts.map +0 -1
  77. package/dist/packages/dbos-cloud/login.js +0 -103
  78. package/dist/packages/dbos-cloud/login.js.map +0 -1
  79. package/dist/packages/dbos-cloud/register.d.ts +0 -2
  80. package/dist/packages/dbos-cloud/register.d.ts.map +0 -1
  81. package/dist/packages/dbos-cloud/register.js +0 -69
  82. package/dist/packages/dbos-cloud/register.js.map +0 -1
  83. package/dist/packages/dbos-cloud/userdb.d.ts +0 -13
  84. package/dist/packages/dbos-cloud/userdb.d.ts.map +0 -1
  85. package/dist/packages/dbos-cloud/userdb.js +0 -153
  86. package/dist/packages/dbos-cloud/userdb.js.map +0 -1
  87. package/dist/packages/dbos-openapi/TypeParser.d.ts +0 -36
  88. package/dist/packages/dbos-openapi/TypeParser.d.ts.map +0 -1
  89. package/dist/packages/dbos-openapi/TypeParser.js +0 -162
  90. package/dist/packages/dbos-openapi/TypeParser.js.map +0 -1
  91. package/dist/packages/dbos-openapi/cli.d.ts +0 -3
  92. package/dist/packages/dbos-openapi/cli.d.ts.map +0 -1
  93. package/dist/packages/dbos-openapi/cli.js +0 -32
  94. package/dist/packages/dbos-openapi/cli.js.map +0 -1
  95. package/dist/packages/dbos-openapi/openApi.d.ts +0 -36
  96. package/dist/packages/dbos-openapi/openApi.d.ts.map +0 -1
  97. package/dist/packages/dbos-openapi/openApi.js +0 -566
  98. package/dist/packages/dbos-openapi/openApi.js.map +0 -1
  99. package/dist/packages/dbos-openapi/tests/makeProgram.d.ts +0 -3
  100. package/dist/packages/dbos-openapi/tests/makeProgram.d.ts.map +0 -1
  101. package/dist/packages/dbos-openapi/tests/makeProgram.js +0 -71
  102. package/dist/packages/dbos-openapi/tests/makeProgram.js.map +0 -1
  103. package/dist/packages/dbos-openapi/tests/openapi.test.d.ts +0 -2
  104. package/dist/packages/dbos-openapi/tests/openapi.test.d.ts.map +0 -1
  105. package/dist/packages/dbos-openapi/tests/openapi.test.js +0 -373
  106. package/dist/packages/dbos-openapi/tests/openapi.test.js.map +0 -1
  107. package/dist/packages/dbos-openapi/tsDiagUtil.d.ts +0 -16
  108. package/dist/packages/dbos-openapi/tsDiagUtil.d.ts.map +0 -1
  109. package/dist/packages/dbos-openapi/tsDiagUtil.js +0 -72
  110. package/dist/packages/dbos-openapi/tsDiagUtil.js.map +0 -1
@@ -1,54 +0,0 @@
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.listApps = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const cloudutils_1 = require("../cloudutils");
9
- async function listApps(host, json) {
10
- const logger = (0, cloudutils_1.getLogger)();
11
- const userCredentials = (0, cloudutils_1.getCloudCredentials)();
12
- const bearerToken = "Bearer " + userCredentials.token;
13
- try {
14
- const list = await axios_1.default.get(`https://${host}/${userCredentials.userName}/application`, {
15
- headers: {
16
- Authorization: bearerToken,
17
- },
18
- });
19
- const applications = list.data;
20
- if (applications.length === 0) {
21
- logger.info("No applications found");
22
- return 1;
23
- }
24
- if (json) {
25
- console.log(JSON.stringify(applications));
26
- }
27
- else {
28
- logger.info(`Listing applications for ${userCredentials.userName}`);
29
- applications.forEach(app => {
30
- console.log(`Application Name: ${app.Name}`);
31
- console.log(`ID: ${app.ID}`);
32
- console.log(`Postgres Instance Name: ${app.ApplicationDatabaseName}`);
33
- console.log(`Application Database Name: ${app.ApplicationDatabaseName}`);
34
- console.log(`Status: ${app.Status}`);
35
- console.log(`Version: ${app.Version}`);
36
- console.log('-------------------------');
37
- });
38
- }
39
- return 0;
40
- }
41
- catch (e) {
42
- const errorLabel = 'Failed to list applications';
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.listApps = listApps;
54
- //# sourceMappingURL=list-apps.js.map
@@ -1 +0,0 @@
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,GAAG,eAAe,CAAC,KAAK,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,eAAK,CAAC,GAAG,CAC1B,WAAW,IAAI,IAAI,eAAe,CAAC,QAAQ,cAAc,EACzD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,WAAW;aAC3B;SACF,CACF,CAAC;QACF,MAAM,YAAY,GAAkB,IAAI,CAAC,IAAqB,CAAC;QAC/D,IAAI,YAAY,CA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,KAAK,CAAC,GAAG,UAAU,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AA5CD,4BA4CC"}
@@ -1,2 +0,0 @@
1
- export declare function registerApp(dbname: string, host: string): Promise<number>;
2
- //# sourceMappingURL=register-app.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-app.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/register-app.ts"],"names":[],"mappings":"AAIA,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAuC/E"}
@@ -1,47 +0,0 @@
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.registerApp = 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 registerApp(dbname, host) {
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
- logger.info(`Loaded application name from package.json: ${appName}`);
18
- logger.info(`Registering application: ${appName}`);
19
- try {
20
- const register = await axios_1.default.put(`https://${host}/${userCredentials.userName}/application`, {
21
- name: appName,
22
- database: dbname,
23
- }, {
24
- headers: {
25
- "Content-Type": "application/json",
26
- Authorization: bearerToken,
27
- },
28
- });
29
- const uuid = register.data;
30
- logger.info(`Successfully registered: ${appName}`);
31
- logger.info(`${appName} ID: ${uuid}`);
32
- return 0;
33
- }
34
- catch (e) {
35
- const errorLabel = `Failed to register application ${appName}`;
36
- const axiosError = e;
37
- if ((0, cloudutils_1.isCloudAPIErrorResponse)(axiosError.response?.data)) {
38
- (0, cloudutils_1.handleAPIErrors)(errorLabel, axiosError);
39
- }
40
- else {
41
- logger.error(`${errorLabel}: ${e.message}`);
42
- }
43
- return 1;
44
- }
45
- }
46
- exports.registerApp = registerApp;
47
- //# sourceMappingURL=register-app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-app.js","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/register-app.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAC1C,8CAAyG;AACzG,0DAA6B;AAEtB,KAAK,UAAU,WAAW,CAAC,MAAc,EAAE,IAAY;IAC5D,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,MAAM,CAAC,IAAI,CAAC,8CAA8C,OAAO,EAAE,CAAC,CAAA;IACpE,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAA;IAElD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,WAAW,IAAI,IAAI,eAAe,CAAC,QAAQ,cAAc,EACzD;YACE,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,MAAM;SACjB,EACD;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,WAAW;aAC3B;SACF,CACF,CAAC;QACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAc,CAAC;QACrC,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,QAAQ,IAAI,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,UAAU,GAAG,kCAAkC,OAAO,EAAE,CAAC;QAC/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;AAvCD,kCAuCC"}
@@ -1,9 +0,0 @@
1
- export type Application = {
2
- Name: string;
3
- ID: string;
4
- PostgresInstanceName: string;
5
- ApplicationDatabaseName: string;
6
- Status: string;
7
- Version: string;
8
- };
9
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare function updateApp(host: string): Promise<number>;
2
- //# sourceMappingURL=update-app.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-app.d.ts","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/update-app.ts"],"names":[],"mappings":"AAKA,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsC7D"}
@@ -1,46 +0,0 @@
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.updateApp = 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 updateApp(host) {
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
- logger.info(`Loaded application name from package.json: ${appName}`);
18
- logger.info(`Updating application: ${appName}`);
19
- try {
20
- logger.info(`Updating application ${appName}`);
21
- const update = await axios_1.default.patch(`https://${host}/${userCredentials.userName}/application/${appName}`, {
22
- name: appName,
23
- }, {
24
- headers: {
25
- "Content-Type": "application/json",
26
- Authorization: bearerToken,
27
- },
28
- });
29
- const application = update.data;
30
- logger.info(`Successfully updated: ${application.Name}`);
31
- return 0;
32
- }
33
- catch (e) {
34
- const errorLabel = "Failed to update application";
35
- const axiosError = e;
36
- if ((0, cloudutils_1.isCloudAPIErrorResponse)(axiosError.response?.data)) {
37
- (0, cloudutils_1.handleAPIErrors)(errorLabel, axiosError);
38
- }
39
- else {
40
- logger.error(`${errorLabel}: ${e.message}`);
41
- }
42
- return 1;
43
- }
44
- }
45
- exports.updateApp = updateApp;
46
- //# sourceMappingURL=update-app.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-app.js","sourceRoot":"","sources":["../../../../packages/dbos-cloud/applications/update-app.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0C;AAC1C,8CAAyG;AAEzG,0DAA6B;AAEtB,KAAK,UAAU,SAAS,CAAC,IAAY;IAC1C,MAAM,MAAM,GAAI,IAAA,sBAAS,GAAE,CAAC;IAC5B,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,MAAM,CAAC,IAAI,CAAC,8CAA8C,OAAO,EAAE,CAAC,CAAA;IACpE,MAAM,CAAC,IAAI,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAA;IAE/C,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,eAAK,CAAC,KAAK,CAC9B,WAAW,IAAI,IAAI,eAAe,CAAC,QAAQ,gBAAgB,OAAO,EAAE,EACpE;YACE,IAAI,EAAE,OAAO;SACd,EACD;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,WAAW;aAC3B;SACF,CACF,CAAC;QACF,MAAM,WAAW,GAAgB,MAAM,CAAC,IAAmB,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,yBAAyB,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,UAAU,GAAG,8BAA8B,CAAC;QAClD,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;AAtCD,8BAsCC"}
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=cli.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/cli.ts"],"names":[],"mappings":""}
@@ -1,138 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const applications_1 = require("./applications");
5
- const commander_1 = require("commander");
6
- const login_1 = require("./login");
7
- const register_1 = require("./register");
8
- const userdb_1 = require("./userdb");
9
- const cloudutils_1 = require("./cloudutils");
10
- const get_app_info_1 = require("./applications/get-app-info");
11
- const program = new commander_1.Command();
12
- // eslint-disable-next-line @typescript-eslint/no-var-requires
13
- const packageJson = require('../../../package.json');
14
- program.
15
- version(packageJson.version);
16
- /////////////////////
17
- /* AUTHENTICATION */
18
- /////////////////////
19
- program
20
- .command('login')
21
- .description('Log in to DBOS cloud')
22
- .requiredOption('-u, --username <string>', 'Username')
23
- .action(async (options) => {
24
- const exitCode = await (0, login_1.login)(options.username);
25
- process.exit(exitCode);
26
- });
27
- program
28
- .command('register')
29
- .description('Register a user and log in to DBOS cloud')
30
- .requiredOption('-u, --username <string>', 'Username')
31
- .action(async (options) => {
32
- const exitCode = await (0, register_1.registerUser)(options.username, cloudutils_1.DBOSCloudHost);
33
- process.exit(exitCode);
34
- });
35
- /////////////////////////////
36
- /* APPLICATIONS MANAGEMENT */
37
- /////////////////////////////
38
- const applicationCommands = program
39
- .command('applications')
40
- .description('Manage your DBOS applications');
41
- applicationCommands
42
- .command('register')
43
- .description('Register a new application')
44
- .requiredOption('-d, --database <string>', 'Specify the app database name')
45
- .action(async (options) => {
46
- const exitCode = await (0, applications_1.registerApp)(options.database, cloudutils_1.DBOSCloudHost);
47
- process.exit(exitCode);
48
- });
49
- applicationCommands
50
- .command('update')
51
- .description('Update an application')
52
- .action(async () => {
53
- const exitCode = await (0, applications_1.updateApp)(cloudutils_1.DBOSCloudHost);
54
- process.exit(exitCode);
55
- });
56
- applicationCommands
57
- .command('deploy')
58
- .description('Deploy an application code to the cloud')
59
- .option('--no-docker', 'Build the code locally without using Docker')
60
- .action(async (options) => {
61
- const exitCode = await (0, applications_1.deployAppCode)(cloudutils_1.DBOSCloudHost, options.docker);
62
- process.exit(exitCode);
63
- });
64
- applicationCommands
65
- .command('delete')
66
- .description('Delete a previously deployed application')
67
- .action(async () => {
68
- const exitCode = await (0, applications_1.deleteApp)(cloudutils_1.DBOSCloudHost);
69
- process.exit(exitCode);
70
- });
71
- applicationCommands
72
- .command('list')
73
- .description('List all deployed applications')
74
- .option('--json', 'Emit JSON output')
75
- .action(async (options) => {
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);
85
- process.exit(exitCode);
86
- });
87
- applicationCommands
88
- .command('logs')
89
- .description('Print the microVM logs of a deployed application')
90
- .option('-l, --last <integer>', 'How far back to query, in seconds from current time. By default, we retrieve all data', parseInt)
91
- .action(async (options) => {
92
- const exitCode = await (0, applications_1.getAppLogs)(cloudutils_1.DBOSCloudHost, options.last);
93
- process.exit(exitCode);
94
- });
95
- //////////////////////////////
96
- /* USER DATABASE MANAGEMENT */
97
- //////////////////////////////
98
- const userdbCommands = program
99
- .command('userdb')
100
- .description('Manage your databases');
101
- userdbCommands
102
- .command('create')
103
- .argument('<string>', 'database name')
104
- .requiredOption('-a, --admin <string>', 'Specify the admin user')
105
- .requiredOption('-W, --password <string>', 'Specify the admin password')
106
- .option('-s, --sync', 'make synchronous call', true)
107
- .action((async (dbname, options) => {
108
- const exitCode = await (0, userdb_1.createUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.admin, options.password, options.sync);
109
- process.exit(exitCode);
110
- }));
111
- userdbCommands
112
- .command('status')
113
- .argument('<string>', 'database name')
114
- .option('--json', 'Emit JSON output')
115
- .action((async (dbname, options) => {
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);
124
- process.exit(exitCode);
125
- }));
126
- userdbCommands
127
- .command('delete')
128
- .argument('<string>', 'database name')
129
- .action((async (dbname) => {
130
- const exitCode = await (0, userdb_1.deleteUserDb)(cloudutils_1.DBOSCloudHost, dbname);
131
- process.exit(exitCode);
132
- }));
133
- program.parse(process.argv);
134
- // If no arguments provided, display help by default
135
- if (!process.argv.slice(2).length) {
136
- program.outputHelp();
137
- }
138
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
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,mBA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C,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,27 +0,0 @@
1
- /// <reference types="node" />
2
- import { Logger } from "winston";
3
- import { AxiosError } from "axios";
4
- export interface DBOSCloudCredentials {
5
- token: string;
6
- userName: string;
7
- }
8
- export declare const dbosConfigFilePath = "dbos-config.yaml";
9
- export declare const DBOSCloudHost: string;
10
- export declare const dbosEnvPath = ".dbos";
11
- export declare function getLogger(): Logger;
12
- export declare function getCloudCredentials(): DBOSCloudCredentials;
13
- export declare function credentialsExist(): boolean;
14
- export declare function runCommand(command: string, args?: string[]): Promise<number>;
15
- export declare function readFileSync(path: string, encoding?: BufferEncoding): string | Buffer;
16
- export declare const sleep: (ms: number) => Promise<unknown>;
17
- export type ValuesOf<T> = T[keyof T];
18
- export declare function createDirectory(path: string): string | undefined;
19
- interface CloudAPIErrorResponse {
20
- message: string;
21
- statusCode: number;
22
- requestID: string;
23
- }
24
- export declare function isCloudAPIErrorResponse(obj: unknown): obj is CloudAPIErrorResponse;
25
- export declare function handleAPIErrors(label: string, e: AxiosError): void;
26
- export {};
27
- //# sourceMappingURL=cloudutils.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,121 +0,0 @@
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.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;
7
- const child_process_1 = require("child_process");
8
- const winston_1 = require("winston");
9
- const fs_1 = __importDefault(require("fs"));
10
- const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
11
- exports.dbosConfigFilePath = "dbos-config.yaml";
12
- exports.DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
13
- exports.dbosEnvPath = ".dbos";
14
- // FIXME: we should have a global instance of the logger created in cli.ts
15
- function getLogger() {
16
- const winstonTransports = [];
17
- winstonTransports.push(new winston_1.transports.Console({
18
- format: consoleFormat,
19
- level: "info",
20
- }));
21
- return (0, winston_1.createLogger)({ transports: winstonTransports });
22
- }
23
- exports.getLogger = getLogger;
24
- const consoleFormat = winston_1.format.combine(winston_1.format.errors({ stack: true }), winston_1.format.timestamp(), winston_1.format.colorize(), winston_1.format.printf((info) => {
25
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
26
- const { timestamp, level, message, stack } = info;
27
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
28
- const ts = timestamp.slice(0, 19).replace("T", " ");
29
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment
30
- const formattedStack = stack?.split("\n").slice(1).join("\n");
31
- const messageString = typeof message === "string" ? message : JSON.stringify(message);
32
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
33
- return `${ts} [${level}]: ${messageString} ${stack ? "\n" + formattedStack : ""}`;
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
- }
46
- function getCloudCredentials() {
47
- const logger = getLogger();
48
- if (!credentialsExist()) {
49
- logger.error("Error: not logged in");
50
- process.exit(1);
51
- }
52
- const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${exports.dbosEnvPath}/credentials`).toString("utf-8"));
53
- const credentials = {
54
- userName: userCredentials.userName,
55
- token: userCredentials.token.replace(/\r|\n/g, ""), // Trim the trailing /r /n.
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;
62
- }
63
- exports.getCloudCredentials = getCloudCredentials;
64
- function credentialsExist() {
65
- return fs_1.default.existsSync(`./${exports.dbosEnvPath}/credentials`);
66
- }
67
- exports.credentialsExist = credentialsExist;
68
- // Run a command, streaming its output to stdout
69
- function runCommand(command, args = []) {
70
- return new Promise((resolve, reject) => {
71
- const stdio = 'inherit';
72
- const process = (0, child_process_1.spawn)(command, args, { stdio });
73
- process.on('close', (code) => {
74
- if (code === 0) {
75
- resolve(code);
76
- }
77
- else {
78
- reject(new Error(`Command "${command}" exited with code ${code}`));
79
- }
80
- });
81
- process.on('error', (error) => {
82
- reject(error);
83
- });
84
- });
85
- }
86
- exports.runCommand = runCommand;
87
- function readFileSync(path, encoding = "utf8") {
88
- // First, check the file
89
- fs_1.default.stat(path, (error, stats) => {
90
- if (error) {
91
- throw new Error(`checking on ${path}. ${error.code}: ${error.errno}`);
92
- }
93
- else if (!stats.isFile()) {
94
- throw new Error(`config file ${path} is not a file`);
95
- }
96
- });
97
- // Then, read its content
98
- const fileContent = fs_1.default.readFileSync(path, { encoding });
99
- return fileContent;
100
- }
101
- exports.readFileSync = readFileSync;
102
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
103
- exports.sleep = sleep;
104
- function createDirectory(path) {
105
- return fs_1.default.mkdirSync(path, { recursive: true });
106
- }
107
- exports.createDirectory = createDirectory;
108
- function isCloudAPIErrorResponse(obj) {
109
- return typeof obj === 'object' && obj !== null &&
110
- 'message' in obj && typeof obj['message'] === 'string' &&
111
- 'statusCode' in obj && typeof obj['statusCode'] === 'number' &&
112
- 'requestID' in obj && typeof obj['requestID'] === 'string';
113
- }
114
- exports.isCloudAPIErrorResponse = isCloudAPIErrorResponse;
115
- function handleAPIErrors(label, e) {
116
- const logger = getLogger();
117
- const resp = e.response?.data;
118
- logger.error(`[${resp.requestID}] ${label}: ${resp.message}.`);
119
- }
120
- exports.handleAPIErrors = handleAPIErrors;
121
- //# sourceMappingURL=cloudutils.js.map
@@ -1 +0,0 @@
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;IACF,OAAO,IAAA,sBAAY,EAAC,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC,CAAC;AACzD,CAAC;AATD,8BASC;AAED,MAAM,aAAa,GAAG,gBAAM,CAAC,OAAO,CAClC,gBAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAC9B,gBAAM,CAAC,SAAS,EAAE,EAClB,gBAAM,CAAC,QAAQ,EAAE,EACjB,gBAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;IACrB,mEAAmE;IACnE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAClD,kJAAkJ;IAClJ,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,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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,2 +0,0 @@
1
- export declare function login(username: string): Promise<number>;
2
- //# sourceMappingURL=login.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,103 +0,0 @@
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.login = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
9
- const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
10
- const child_process_1 = require("child_process");
11
- const fs_1 = __importDefault(require("fs"));
12
- const cloudutils_1 = require("./cloudutils");
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';
18
- const client = (0, jwks_rsa_1.default)({
19
- jwksUri: `https://${Auth0Domain}/.well-known/jwks.json`
20
- });
21
- async function getSigningKey(kid) {
22
- const key = await client.getSigningKey(kid);
23
- return key.getPublicKey();
24
- }
25
- async function verifyToken(token) {
26
- const decoded = jsonwebtoken_1.default.decode(token, { complete: true });
27
- if (!decoded || typeof decoded === 'string' || !decoded.header.kid) {
28
- throw new Error('Invalid token');
29
- }
30
- const signingKey = await getSigningKey(decoded.header.kid);
31
- return new Promise((resolve, reject) => {
32
- jsonwebtoken_1.default.verify(token, signingKey, { algorithms: ['RS256'] }, (err, verifiedToken) => {
33
- if (err) {
34
- reject(err);
35
- }
36
- else {
37
- resolve(verifiedToken);
38
- }
39
- });
40
- });
41
- }
42
- async function login(username) {
43
- const logger = (0, cloudutils_1.getLogger)();
44
- logger.info(`Please authenticate with DBOS Cloud!`);
45
- const deviceCodeRequest = {
46
- method: 'POST',
47
- url: `https://${Auth0Domain}/oauth/device/code`,
48
- headers: { 'content-type': 'application/x-www-form-urlencoded' },
49
- data: { client_id: DBOSClientID, scope: 'sub', audience: DBOSCloudIdentifier }
50
- };
51
- let deviceCodeResponse;
52
- try {
53
- const response = await axios_1.default.request(deviceCodeRequest);
54
- deviceCodeResponse = response.data;
55
- }
56
- catch (e) {
57
- e.message = `failed to log in: ${e.message}`;
58
- logger.error(e);
59
- }
60
- if (!deviceCodeResponse) {
61
- return 1;
62
- }
63
- console.log(`Login URL: ${deviceCodeResponse.verification_uri_complete}`);
64
- const tokenRequest = {
65
- method: 'POST',
66
- url: `https://${Auth0Domain}/oauth/token`,
67
- headers: { 'content-type': 'application/x-www-form-urlencoded' },
68
- data: new URLSearchParams({
69
- grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
70
- device_code: deviceCodeResponse.device_code,
71
- client_id: DBOSClientID
72
- })
73
- };
74
- let tokenResponse;
75
- let elapsedTimeSec = 0;
76
- while (elapsedTimeSec < deviceCodeResponse.expires_in) {
77
- try {
78
- await (0, cloudutils_1.sleep)(deviceCodeResponse.interval * 1000);
79
- elapsedTimeSec += deviceCodeResponse.interval;
80
- const response = await axios_1.default.request(tokenRequest);
81
- tokenResponse = response.data;
82
- break;
83
- }
84
- catch (e) {
85
- logger.info(`Waiting for login...`);
86
- }
87
- }
88
- if (!tokenResponse) {
89
- return 1;
90
- }
91
- await verifyToken(tokenResponse.access_token);
92
- const credentials = {
93
- token: tokenResponse.access_token,
94
- userName: username,
95
- };
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");
98
- logger.info(`Successfully logged in as user: ${credentials.userName}`);
99
- logger.info(`You can view your credentials in: ./${cloudutils_1.dbosEnvPath}/credentials`);
100
- return 0;
101
- }
102
- exports.login = login;
103
- //# sourceMappingURL=login.js.map