@intuned/runtime-dev 0.1.0-test.10 → 0.1.0-test.12

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.
Files changed (103) hide show
  1. package/.babelrc +1 -2
  2. package/dist/commands/api/run.js +170 -105
  3. package/dist/commands/api/run.ts +105 -0
  4. package/dist/commands/auth-sessions/load.js +26 -28
  5. package/dist/commands/auth-sessions/load.ts +30 -0
  6. package/dist/commands/auth-sessions/run-check.js +53 -52
  7. package/dist/commands/auth-sessions/run-check.ts +51 -0
  8. package/dist/commands/auth-sessions/run-create.js +96 -91
  9. package/dist/commands/auth-sessions/run-create.ts +91 -0
  10. package/dist/commands/browser/save-state.js +16 -14
  11. package/dist/commands/browser/save-state.ts +14 -0
  12. package/dist/commands/browser/start-browser.js +11 -11
  13. package/dist/commands/browser/start-browser.ts +11 -0
  14. package/dist/commands/build.js +108 -75
  15. package/dist/commands/build.ts +78 -0
  16. package/dist/commands/common/browserUtils.js +51 -53
  17. package/dist/commands/common/browserUtils.ts +45 -0
  18. package/dist/commands/common/getDefaultExportFromFile.js +12 -17
  19. package/dist/commands/common/getDefaultExportFromFile.ts +11 -0
  20. package/dist/commands/common/getFirstLineNumber.js +93 -93
  21. package/dist/commands/common/{getFirstLineNumber.test.js → getFirstLineNumber.test.ts} +46 -51
  22. package/dist/commands/common/getFirstLineNumber.ts +96 -0
  23. package/dist/commands/common/sendMessageToClient.js +4 -9
  24. package/dist/commands/common/sendMessageToClient.ts +3 -0
  25. package/dist/commands/common/utils/fileUtils.js +22 -32
  26. package/dist/commands/common/utils/fileUtils.ts +23 -0
  27. package/dist/commands/common/utils/settings.js +19 -27
  28. package/dist/commands/common/utils/settings.ts +22 -0
  29. package/dist/commands/common/utils/unixSocket.js +43 -43
  30. package/dist/commands/common/utils/unixSocket.ts +38 -0
  31. package/dist/commands/common/utils/webTemplate.js +27 -29
  32. package/dist/commands/common/utils/webTemplate.ts +22 -0
  33. package/dist/commands/interface/run.js +151 -150
  34. package/dist/commands/interface/run.ts +156 -0
  35. package/dist/commands/ts-check.js +49 -49
  36. package/dist/commands/ts-check.ts +50 -0
  37. package/dist/common/Logger/Logger/index.d.ts +1 -1
  38. package/dist/common/Logger/Logger/index.js +42 -55
  39. package/dist/common/Logger/Logger/index.ts +53 -0
  40. package/dist/common/Logger/Logger/types.js +1 -5
  41. package/dist/common/Logger/Logger/types.ts +1 -0
  42. package/dist/common/Logger/index.d.ts +1 -1
  43. package/dist/common/Logger/index.js +42 -55
  44. package/dist/common/Logger/index.ts +53 -0
  45. package/dist/common/Logger/types.js +1 -5
  46. package/dist/common/Logger/types.ts +1 -0
  47. package/dist/common/asyncLocalStorage/index.js +8 -16
  48. package/dist/common/asyncLocalStorage/index.ts +9 -0
  49. package/dist/common/cleanEnvironmentVariables.js +12 -16
  50. package/dist/common/cleanEnvironmentVariables.ts +10 -0
  51. package/dist/common/constants.js +1 -7
  52. package/dist/common/constants.ts +1 -0
  53. package/dist/common/contextStorageStateHelpers.js +38 -47
  54. package/dist/common/contextStorageStateHelpers.ts +43 -0
  55. package/dist/common/getPlaywrightConstructs.d.ts +1 -1
  56. package/dist/common/getPlaywrightConstructs.js +196 -177
  57. package/dist/common/getPlaywrightConstructs.ts +181 -0
  58. package/dist/common/jwtTokenManager.js +79 -76
  59. package/dist/common/jwtTokenManager.ts +71 -0
  60. package/dist/common/runApi/errors.d.ts +1 -1
  61. package/dist/common/runApi/errors.js +150 -159
  62. package/dist/common/runApi/errors.ts +154 -0
  63. package/dist/common/runApi/index.d.ts +4 -4
  64. package/dist/common/runApi/index.js +220 -269
  65. package/dist/common/runApi/index.ts +253 -0
  66. package/dist/common/runApi/types.d.ts +1 -1
  67. package/dist/common/runApi/types.js +56 -49
  68. package/dist/common/runApi/types.ts +43 -0
  69. package/dist/common/settingsSchema.js +10 -15
  70. package/dist/common/settingsSchema.ts +9 -0
  71. package/dist/common/telemetry.js +30 -28
  72. package/dist/common/telemetry.ts +23 -0
  73. package/dist/index.d.ts +4 -4
  74. package/dist/index.js +4 -69
  75. package/dist/index.ts +4 -0
  76. package/dist/runtime/RunError.d.ts +1 -1
  77. package/dist/runtime/RunError.js +11 -18
  78. package/dist/runtime/RunError.ts +12 -0
  79. package/dist/runtime/downloadDirectory.js +13 -19
  80. package/dist/runtime/downloadDirectory.ts +13 -0
  81. package/dist/runtime/enums.d.ts +1 -11
  82. package/dist/runtime/enums.js +12 -18
  83. package/dist/runtime/enums.ts +12 -0
  84. package/dist/runtime/executionHelpers.test.ts +51 -0
  85. package/dist/runtime/export.d.ts +1 -202
  86. package/dist/runtime/extendPayload.d.ts +1 -1
  87. package/dist/runtime/extendPayload.js +15 -21
  88. package/dist/runtime/extendPayload.ts +15 -0
  89. package/dist/runtime/extendTimeout.js +21 -28
  90. package/dist/runtime/extendTimeout.ts +24 -0
  91. package/dist/runtime/index.d.ts +7 -7
  92. package/dist/runtime/index.js +6 -53
  93. package/dist/runtime/index.ts +6 -0
  94. package/dist/runtime/requestMoreInfo.js +16 -23
  95. package/dist/runtime/requestMoreInfo.ts +18 -0
  96. package/dist/runtime/runInfo.d.ts +1 -1
  97. package/dist/runtime/runInfo.js +14 -21
  98. package/dist/runtime/runInfo.ts +15 -0
  99. package/package.json +3 -2
  100. package/tsconfig.json +1 -1
  101. package/dist/runtime/enums.d.js +0 -5
  102. package/dist/runtime/executionHelpers.test.js +0 -53
  103. package/dist/runtime/export.d.js +0 -5
@@ -0,0 +1,12 @@
1
+ export class RunError extends Error {
2
+ constructor(message, options) {
3
+ super(message);
4
+ this.message = message;
5
+ this.name = "USER_GENERATED_ERROR";
6
+ this.options = options ?? {
7
+ retryable: false
8
+ };
9
+ Object.setPrototypeOf(this, RunError.prototype);
10
+ }
11
+ }
12
+ new RunError("", {});
@@ -1,19 +1,13 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getDownloadDirectoryPath = getDownloadDirectoryPath;
7
- var _ = require("..");
8
- var _fsExtra = require("fs-extra");
9
- function getDownloadDirectoryPath() {
10
- const context = (0, _.getExecutionContext)();
11
- if (!context) {
12
- throw new Error("ExecutionContext not found");
13
- }
14
- const path = `/tmp/downloads/${context.runId}`;
15
- (0, _fsExtra.ensureDirSync)(path, {
16
- mode: 0o2775
17
- });
18
- return path;
19
- }
1
+ import { getExecutionContext } from "..";
2
+ import { ensureDirSync } from "fs-extra";
3
+ export function getDownloadDirectoryPath() {
4
+ const context = getExecutionContext();
5
+ if (!context) {
6
+ throw new Error("ExecutionContext not found");
7
+ }
8
+ const path = `/tmp/downloads/${context.runId}`;
9
+ ensureDirSync(path, {
10
+ mode: 0o2775,
11
+ });
12
+ return path;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { getExecutionContext } from "..";
2
+ import { ensureDirSync } from "fs-extra";
3
+ export function getDownloadDirectoryPath() {
4
+ const context = getExecutionContext();
5
+ if (!context) {
6
+ throw new Error("ExecutionContext not found");
7
+ }
8
+ const path = `/tmp/downloads/${context.runId}`;
9
+ ensureDirSync(path, {
10
+ mode: 0o2775
11
+ });
12
+ return path;
13
+ }
@@ -1,11 +1 @@
1
- export declare enum RunEnvironment {
2
- IDE = "IDE",
3
- DEPLOYED = "DEPLOYED",
4
- }
5
-
6
- export declare enum RunType {
7
- SYNC = "SYNC",
8
- ASYNC = "ASYNC",
9
- JOB = "JOB",
10
- QUEUE = "QUEUE",
11
- }
1
+ export {};
@@ -1,18 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.RunType = exports.RunEnvironment = void 0;
7
- let RunEnvironment = exports.RunEnvironment = function (RunEnvironment) {
8
- RunEnvironment["IDE"] = "IDE";
9
- RunEnvironment["DEPLOYED"] = "DEPLOYED";
10
- return RunEnvironment;
11
- }({});
12
- let RunType = exports.RunType = function (RunType) {
13
- RunType["SYNC"] = "SYNC";
14
- RunType["ASYNC"] = "ASYNC";
15
- RunType["JOB"] = "JOB";
16
- RunType["QUEUE"] = "QUEUE";
17
- return RunType;
18
- }({});
1
+ export var RunEnvironment;
2
+ (function (RunEnvironment) {
3
+ RunEnvironment["IDE"] = "IDE";
4
+ RunEnvironment["DEPLOYED"] = "DEPLOYED";
5
+ })(RunEnvironment || (RunEnvironment = {}));
6
+ export var RunType;
7
+ (function (RunType) {
8
+ RunType["SYNC"] = "SYNC";
9
+ RunType["ASYNC"] = "ASYNC";
10
+ RunType["JOB"] = "JOB";
11
+ RunType["QUEUE"] = "QUEUE";
12
+ })(RunType || (RunType = {}));
@@ -0,0 +1,12 @@
1
+ export let RunEnvironment = function (RunEnvironment) {
2
+ RunEnvironment["IDE"] = "IDE";
3
+ RunEnvironment["DEPLOYED"] = "DEPLOYED";
4
+ return RunEnvironment;
5
+ }({});
6
+ export let RunType = function (RunType) {
7
+ RunType["SYNC"] = "SYNC";
8
+ RunType["ASYNC"] = "ASYNC";
9
+ RunType["JOB"] = "JOB";
10
+ RunType["QUEUE"] = "QUEUE";
11
+ return RunType;
12
+ }({});
@@ -0,0 +1,51 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { getExecutionContext, runWithContext } from "../common/asyncLocalStorage";
3
+ import { extendPayload, runInfo } from "./index.js";
4
+ import { RunEnvironment } from "./enums.js";
5
+ describe("Execution Helpers", () => {
6
+ it("should be able to get execution info", () => {
7
+ runWithContext({
8
+ runEnvironment: RunEnvironment.IDE,
9
+ runId: "test-run-id",
10
+ extendedPayloads: []
11
+ }, () => {
12
+ expect(runInfo().runId).toEqual("test-run-id");
13
+ });
14
+ });
15
+ it("should be able to mutate extendedPayloads and get the accmulated value at the end ", () => {
16
+ const context = {
17
+ extendedPayloads: [],
18
+ runId: "test-run-id"
19
+ };
20
+ runWithContext({
21
+ runEnvironment: RunEnvironment.IDE,
22
+ runId: "test-run-id",
23
+ extendedPayloads: []
24
+ }, () => {
25
+ var _getExecutionContext, _getExecutionContext2;
26
+ expect((_getExecutionContext = getExecutionContext()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads).toEqual([]);
27
+ extendPayload({
28
+ api: "test-api",
29
+ parameters: {}
30
+ });
31
+ expect((_getExecutionContext2 = getExecutionContext()) === null || _getExecutionContext2 === void 0 ? void 0 : _getExecutionContext2.extendedPayloads).toEqual([{
32
+ api: "test-api",
33
+ parameters: {}
34
+ }]);
35
+ extendPayload({
36
+ api: "test-api",
37
+ parameters: {}
38
+ });
39
+ extendPayload({
40
+ api: "test-api",
41
+ parameters: {}
42
+ });
43
+ extendPayload({
44
+ api: "test-api",
45
+ parameters: {}
46
+ });
47
+ const context = getExecutionContext();
48
+ expect(context === null || context === void 0 ? void 0 : context.extendedPayloads).toHaveLength(4);
49
+ });
50
+ });
51
+ });
@@ -1,202 +1 @@
1
- import { RunEnvironment } from "./enums";
2
-
3
- /**
4
- * ## Description
5
- * In the context of a job, extendTimeout will increase the timeout of the currently executing payload.
6
- * This is useful when the payload is expected to take a long time. For example, when running pagination code.
7
- *
8
- * @example
9
- * ```typescript Example
10
- * import { extendTimeout } from "@intuned/sdk/runtime"
11
- *
12
- * extendTimeout();
13
- * ```
14
- *
15
- */
16
- export declare function extendTimeout(): void;
17
-
18
- /**
19
- * ## Description
20
- * In the context of a job or queue execution, extendPayload appends new payloads to the end of the queue of job.
21
- * Calling extendPayload will also call extendTimeout.
22
- *
23
- * @param {Payload | Payload[]} payload - The payload or array of payloads to extend. you can specify the api name and what parameters you want to pass it, the new added apis will use the same proxy and auth-session settings as the api that extended them
24
- *
25
- * @example
26
- * ```typescript Single payload
27
- * import { extendPayload } from "@intuned/sdk/runtime"
28
- *
29
- * // this function will append the exampleApi to the end of the queue or job it's executing in.
30
- * extendPayload({ api: 'exampleApi', parameters: { key: 'value' } });
31
- * ```
32
- *
33
- * @example
34
- * ```typescript Array of payloads
35
- * import { extendPayload } from "@intuned/sdk/runtime"
36
- *
37
- * const payloadArray: Payload[] = [
38
- * { api: 'exampleApi1', parameters: { key1: 'value1' } },
39
- * { api: 'exampleApi2', parameters: { key2: 'value2' } }
40
- * ];
41
- *
42
- * // this function will append 2 apis to the end of the queue or job it's executing in.
43
- * extendPayload(payloadArray);
44
- * ```
45
- */
46
- export declare function extendPayload(payload: Payload | Payload[]): void;
47
-
48
- /**
49
- * @interface Payload
50
- * @property {string} api - The API path you want to extend.
51
- * @property {Record<string, any>} parameters - A record of key-value pairs representing the parameters to be sent to the API
52
- *
53
- * @example
54
- *
55
- * ```typescript payload
56
- * import { Payload } from "@intuned/sdk/runtime"
57
- *
58
- * const payload: Payload = {
59
- * api: 'exampleApi',
60
- * parameters: {
61
- * key1: 'value1',
62
- * key2: 'value2'
63
- * }
64
- * };
65
- * ```
66
- */
67
- export interface Payload {
68
- api: string;
69
- parameters: Record<string, any>;
70
- }
71
-
72
- /**
73
- * Retrieves information about the current run environment.
74
- *
75
- * @returns {RunInfo} An object containing details about the run environment and the run ID.
76
- *
77
- * @example
78
- * ```typescript runInfo
79
- * import { runInfo } from "@intuned/sdk/runtime"
80
- *
81
- * const info = runInfo();
82
- * console.log(info.runEnvironment); // Outputs the run environment, IDE or DEPLOYED
83
- * console.log(info.runId); // Outputs the run ID, if available, in IDE run id will be undefined
84
- * ```
85
- */
86
- export declare function runInfo(): RunInfo;
87
-
88
- /**
89
- * Represents information about the current run.
90
- *
91
- * @interface RunInfo
92
- * @property {RunEnvironment} runEnvironment - the run environment `IDE` or `DEPLOYED`
93
- * @property {string} [runId] - Optional. The ID of the current run, in IDE environment, run id will be undefined
94
- */
95
- export interface RunInfo {
96
- runEnvironment: RunEnvironment;
97
- runId?: string;
98
- jobId?: string;
99
- jobRunId?: string;
100
- queueId?: string;
101
- proxy?: string;
102
- }
103
-
104
- /**
105
- * @interface RunErrorOptions
106
- * @property {boolean} [retryable] - Optional. Indicates whether the error is retryable.
107
- * @property {number} [status_code] - Optional. The HTTP status code associated with the error.
108
- * @property {string} [error_code] - Optional. A specific error code to identify the type of error.
109
- *
110
- * @example
111
- * ```typescript RunErrorOptions
112
- * import { RunErrorOptions } from "@intuned/sdk/runtime"
113
- *
114
- * const options: RunErrorOptions = {
115
- * retryable: true,
116
- * status_code: 500,
117
- * error_code: 'SERVER_ERROR'
118
- * };
119
- * ```
120
- */
121
- export interface RunErrorOptions {
122
- retryable?: boolean;
123
- status_code?: number;
124
- error_code?: string;
125
- }
126
-
127
- /**
128
- * Represents an error that occurs during a run.
129
- *
130
- * @class
131
- * @extends Error
132
- *
133
- * @param {string} message - The error message.
134
- * @param {RunErrorOptions} [options] - Optional. Additional options for the error.
135
- *
136
- * @property {RunErrorOptions} options - The options associated with the error.
137
- *
138
- * @example
139
- * ```typescript RunError
140
- * import { RunError } from "@intuned/sdk/runtime"
141
- *
142
- * throw new RunError('An error occurred', {
143
- * retryable: true,
144
- * status_code: 500,
145
- * error_code: 'SERVER_ERROR'
146
- * });
147
- *
148
- * ```
149
- */
150
- export declare class RunError extends Error {
151
- constructor(message: string, options?: RunErrorOptions);
152
- options: RunErrorOptions;
153
- }
154
-
155
- /**
156
- * in the create auth session flow, you might to need a multiple choice answer from the user, requestMultipleChoice prompts the user with the question and possible options and returns their selection.
157
- *
158
- * **Note:** This function is currently in beta and may be subject to changes.
159
- *
160
- * @param {string} message - The message to display to the user.
161
- * @param {string[]} choices - An array of choices to present to the user.
162
- *
163
- * @example
164
- * ```typescript requestMultipleChoice
165
- * // in auth-sessions/create.ts
166
- *
167
- * import { requestMultipleChoice } from "@intuned/sdk/runtime"
168
- *
169
- * const message = "What is your favorite color?";
170
- * const choices = ["Red", "Blue", "Green", "Yellow"];
171
- *
172
- * const selectedChoice = yield requestMultipleChoice(message, choices);
173
- *
174
- * console.log(selectedChoice);
175
- * ```
176
- */
177
- export declare function requestMultipleChoice(
178
- message: string,
179
- choices: string[]
180
- ): unknown;
181
-
182
- /**
183
- * **Note:** This function is currently in beta and may be subject to changes.
184
- *
185
- * requestOTP help you to ask the user for an otp in the create auth-session flow.
186
- *
187
- * @param {string} message - The message to display to the user.
188
- *
189
- * @example
190
- * ```typescript requestOTP
191
- * // in auth-sessions/create.ts
192
- *
193
- * import { requestOTP } from "@intuned/sdk/runtime"
194
- *
195
- * const message = "please submit and OTP from your authenticator app";
196
- *
197
- * const otp = yield requestOTP(message);
198
- *
199
- * console.log(otp);
200
- * ```
201
- */
202
- export declare function requestOTP(message: string): unknown;
1
+ export {};
@@ -1,2 +1,2 @@
1
- import { Payload } from "./export";
1
+ import { Payload } from "./export.js";
2
2
  export declare function extendPayload(payload: Payload | Payload[]): void;
@@ -1,21 +1,15 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extendPayload = extendPayload;
7
- var _asyncLocalStorage = require("../common/asyncLocalStorage");
8
- var _extendTimeout = require("./extendTimeout");
9
- function extendPayload(payload) {
10
- const context = (0, _asyncLocalStorage.getExecutionContext)();
11
- if (!context) {
12
- throw new Error("extendPayload failed due to an internal error.");
13
- }
14
- const items = Array.isArray(payload) ? payload : [payload];
15
- if (!context.extendedPayloads) {
16
- context.extendedPayloads = [...items];
17
- return;
18
- }
19
- context === null || context === void 0 || context.extendedPayloads.push(...items);
20
- (0, _extendTimeout.extendTimeout)();
21
- }
1
+ import { getExecutionContext } from "../common/asyncLocalStorage";
2
+ import { extendTimeout } from "./extendTimeout.js";
3
+ export function extendPayload(payload) {
4
+ const context = getExecutionContext();
5
+ if (!context) {
6
+ throw new Error("extendPayload failed due to an internal error.");
7
+ }
8
+ const items = Array.isArray(payload) ? payload : [payload];
9
+ if (!context.extendedPayloads) {
10
+ context.extendedPayloads = [...items];
11
+ return;
12
+ }
13
+ context?.extendedPayloads.push(...items);
14
+ extendTimeout();
15
+ }
@@ -0,0 +1,15 @@
1
+ import { getExecutionContext } from "../common/asyncLocalStorage";
2
+ import { extendTimeout } from "./extendTimeout.js";
3
+ export function extendPayload(payload) {
4
+ const context = getExecutionContext();
5
+ if (!context) {
6
+ throw new Error("extendPayload failed due to an internal error.");
7
+ }
8
+ const items = Array.isArray(payload) ? payload : [payload];
9
+ if (!context.extendedPayloads) {
10
+ context.extendedPayloads = [...items];
11
+ return;
12
+ }
13
+ context === null || context === void 0 || context.extendedPayloads.push(...items);
14
+ extendTimeout();
15
+ }
@@ -1,30 +1,23 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extendTimeout = extendTimeout;
7
- var _asyncLocalStorage = require("../common/asyncLocalStorage");
1
+ import { getExecutionContext } from "../common/asyncLocalStorage";
8
2
  const _DEBOUNCE_TIME = 60_000;
9
- function extendTimeout() {
10
- const context = (0, _asyncLocalStorage.getExecutionContext)();
11
- if (!context) {
12
- throw new Error("extendTimeout failed due to an internal error.");
13
- }
14
- const {
15
- timeoutInfo
16
- } = context;
17
- if (!timeoutInfo) {
18
- return;
19
- }
20
- if (timeoutInfo.timeoutTimestamp !== undefined && timeoutInfo.timeoutDuration !== undefined) {
21
- const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
22
- if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
23
- return;
3
+ export function extendTimeout() {
4
+ const context = getExecutionContext();
5
+ if (!context) {
6
+ throw new Error("extendTimeout failed due to an internal error.");
24
7
  }
25
- timeoutInfo.timeoutTimestamp = newTimeoutStamp;
26
- }
27
- if (timeoutInfo.extendTimeoutCallback !== undefined) {
28
- void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
29
- }
30
- }
8
+ const { timeoutInfo } = context;
9
+ if (!timeoutInfo) {
10
+ return;
11
+ }
12
+ if (timeoutInfo.timeoutTimestamp !== undefined &&
13
+ timeoutInfo.timeoutDuration !== undefined) {
14
+ const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
15
+ if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
16
+ return;
17
+ }
18
+ timeoutInfo.timeoutTimestamp = newTimeoutStamp;
19
+ }
20
+ if (timeoutInfo.extendTimeoutCallback !== undefined) {
21
+ void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
22
+ }
23
+ }
@@ -0,0 +1,24 @@
1
+ import { getExecutionContext } from "../common/asyncLocalStorage";
2
+ const _DEBOUNCE_TIME = 60_000;
3
+ export function extendTimeout() {
4
+ const context = getExecutionContext();
5
+ if (!context) {
6
+ throw new Error("extendTimeout failed due to an internal error.");
7
+ }
8
+ const {
9
+ timeoutInfo
10
+ } = context;
11
+ if (!timeoutInfo) {
12
+ return;
13
+ }
14
+ if (timeoutInfo.timeoutTimestamp !== undefined && timeoutInfo.timeoutDuration !== undefined) {
15
+ const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
16
+ if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
17
+ return;
18
+ }
19
+ timeoutInfo.timeoutTimestamp = newTimeoutStamp;
20
+ }
21
+ if (timeoutInfo.extendTimeoutCallback !== undefined) {
22
+ void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
23
+ }
24
+ }
@@ -1,7 +1,7 @@
1
- export { extendPayload } from "./extendPayload";
2
- export { extendTimeout } from "./extendTimeout";
3
- export { runInfo } from "./runInfo";
4
- export { RunError } from "./RunError";
5
- export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
6
- export type { RequestMoreInfoDetails } from "./requestMoreInfo";
7
- export { getDownloadDirectoryPath } from "./downloadDirectory";
1
+ export { extendPayload } from "./extendPayload.js";
2
+ export { extendTimeout } from "./extendTimeout.js";
3
+ export { runInfo } from "./runInfo.js";
4
+ export { RunError } from "./RunError.js";
5
+ export { requestMultipleChoice, requestOTP } from "./requestMoreInfo.js";
6
+ export type { RequestMoreInfoDetails } from "./requestMoreInfo.js";
7
+ export { getDownloadDirectoryPath } from "./downloadDirectory.js";
@@ -1,53 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "RunError", {
7
- enumerable: true,
8
- get: function () {
9
- return _RunError.RunError;
10
- }
11
- });
12
- Object.defineProperty(exports, "extendPayload", {
13
- enumerable: true,
14
- get: function () {
15
- return _extendPayload.extendPayload;
16
- }
17
- });
18
- Object.defineProperty(exports, "extendTimeout", {
19
- enumerable: true,
20
- get: function () {
21
- return _extendTimeout.extendTimeout;
22
- }
23
- });
24
- Object.defineProperty(exports, "getDownloadDirectoryPath", {
25
- enumerable: true,
26
- get: function () {
27
- return _downloadDirectory.getDownloadDirectoryPath;
28
- }
29
- });
30
- Object.defineProperty(exports, "requestMultipleChoice", {
31
- enumerable: true,
32
- get: function () {
33
- return _requestMoreInfo.requestMultipleChoice;
34
- }
35
- });
36
- Object.defineProperty(exports, "requestOTP", {
37
- enumerable: true,
38
- get: function () {
39
- return _requestMoreInfo.requestOTP;
40
- }
41
- });
42
- Object.defineProperty(exports, "runInfo", {
43
- enumerable: true,
44
- get: function () {
45
- return _runInfo.runInfo;
46
- }
47
- });
48
- var _extendPayload = require("./extendPayload");
49
- var _extendTimeout = require("./extendTimeout");
50
- var _runInfo = require("./runInfo");
51
- var _RunError = require("./RunError");
52
- var _requestMoreInfo = require("./requestMoreInfo");
53
- var _downloadDirectory = require("./downloadDirectory");
1
+ export { extendPayload } from "./extendPayload.js";
2
+ export { extendTimeout } from "./extendTimeout.js";
3
+ export { runInfo } from "./runInfo.js";
4
+ export { RunError } from "./RunError.js";
5
+ export { requestMultipleChoice, requestOTP } from "./requestMoreInfo.js";
6
+ export { getDownloadDirectoryPath } from "./downloadDirectory.js";
@@ -0,0 +1,6 @@
1
+ export { extendPayload } from "./extendPayload.js";
2
+ export { extendTimeout } from "./extendTimeout.js";
3
+ export { runInfo } from "./runInfo.js";
4
+ export { RunError } from "./RunError.js";
5
+ export { requestMultipleChoice, requestOTP } from "./requestMoreInfo.js";
6
+ export { getDownloadDirectoryPath } from "./downloadDirectory.js";
@@ -1,25 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.requestMultipleChoice = requestMultipleChoice;
7
- exports.requestOTP = requestOTP;
8
1
  const REQUEST_MORE_INFO_KEY = Symbol("REQUEST_MORE_INFO");
9
- function requestOTP(messageToUser) {
10
- return {
11
- [REQUEST_MORE_INFO_KEY]: true,
12
- action: "request_more_info",
13
- messageToUser,
14
- requestType: "otp"
15
- };
2
+ export function requestOTP(messageToUser) {
3
+ return {
4
+ [REQUEST_MORE_INFO_KEY]: true,
5
+ action: "request_more_info",
6
+ messageToUser,
7
+ requestType: "otp",
8
+ };
9
+ }
10
+ export function requestMultipleChoice(messageToUser, choices) {
11
+ return {
12
+ [REQUEST_MORE_INFO_KEY]: true,
13
+ action: "request_more_info",
14
+ messageToUser,
15
+ requestType: "multiple_choice",
16
+ choices,
17
+ };
16
18
  }
17
- function requestMultipleChoice(messageToUser, choices) {
18
- return {
19
- [REQUEST_MORE_INFO_KEY]: true,
20
- action: "request_more_info",
21
- messageToUser,
22
- requestType: "multiple_choice",
23
- choices
24
- };
25
- }
@@ -0,0 +1,18 @@
1
+ const REQUEST_MORE_INFO_KEY = Symbol("REQUEST_MORE_INFO");
2
+ export function requestOTP(messageToUser) {
3
+ return {
4
+ [REQUEST_MORE_INFO_KEY]: true,
5
+ action: "request_more_info",
6
+ messageToUser,
7
+ requestType: "otp"
8
+ };
9
+ }
10
+ export function requestMultipleChoice(messageToUser, choices) {
11
+ return {
12
+ [REQUEST_MORE_INFO_KEY]: true,
13
+ action: "request_more_info",
14
+ messageToUser,
15
+ requestType: "multiple_choice",
16
+ choices
17
+ };
18
+ }
@@ -1,2 +1,2 @@
1
- import { RunInfo } from "./export";
1
+ import { RunInfo } from "./export.js";
2
2
  export declare function runInfo(): RunInfo;