@intuned/runtime-dev 1.3.8-deploy.8 → 1.3.8-fix.0
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/dist/commands/common/utils/unixSocket.d.ts +19 -5
- package/dist/commands/common/utils/unixSocket.js +53 -10
- package/dist/commands/interface/run.js +11 -12
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +1 -1
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +1 -1
- package/dist/commands/intuned-cli/controller/deploy.js +4 -115
- package/dist/commands/intuned-cli/controller/save.d.ts +1 -4
- package/dist/commands/intuned-cli/controller/save.js +2 -8
- package/dist/commands/intuned-cli/helpers/backend.js +1 -1
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +11 -69
- package/dist/commands/intuned-cli/helpers/intunedJson.js +3 -14
- package/package.json +1 -4
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export interface InterfaceClient {
|
|
2
|
+
sendJSON(data: any): void;
|
|
3
|
+
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
4
|
+
close(): void;
|
|
5
|
+
get closed(): boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class SocketClient implements InterfaceClient {
|
|
5
8
|
static readonly LENGTH_HEADER_LENGTH = 4;
|
|
6
|
-
|
|
9
|
+
private readonly socket;
|
|
10
|
+
constructor(socketPath: string);
|
|
11
|
+
sendJSON(data: any): void;
|
|
12
|
+
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
get closed(): boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class JSONLFileClient implements InterfaceClient {
|
|
17
|
+
private readonly fileStream;
|
|
18
|
+
constructor(filePath: string);
|
|
7
19
|
sendJSON(data: any): void;
|
|
8
20
|
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
get closed(): boolean;
|
|
9
23
|
}
|
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.SocketClient = exports.JSONLFileClient = void 0;
|
|
7
|
+
var net = _interopRequireWildcard(require("net"));
|
|
8
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
9
|
+
var _readline = require("readline");
|
|
10
|
+
var _promises = require("timers/promises");
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
+
class SocketClient {
|
|
8
14
|
static LENGTH_HEADER_LENGTH = 4;
|
|
9
|
-
constructor(
|
|
10
|
-
this.socket =
|
|
15
|
+
constructor(socketPath) {
|
|
16
|
+
this.socket = net.createConnection(socketPath);
|
|
11
17
|
}
|
|
12
18
|
sendJSON(data) {
|
|
13
19
|
const dataToSend = JSON.stringify(data);
|
|
14
20
|
const length = Buffer.byteLength(dataToSend);
|
|
15
|
-
const buffer = Buffer.alloc(
|
|
21
|
+
const buffer = Buffer.alloc(SocketClient.LENGTH_HEADER_LENGTH + length);
|
|
16
22
|
buffer.writeUInt32BE(length, 0);
|
|
17
|
-
buffer.write(dataToSend,
|
|
23
|
+
buffer.write(dataToSend, SocketClient.LENGTH_HEADER_LENGTH);
|
|
18
24
|
this.socket.write(buffer);
|
|
19
25
|
}
|
|
20
26
|
async *receiveJSON() {
|
|
@@ -32,13 +38,50 @@ class JSONUnixSocket {
|
|
|
32
38
|
}
|
|
33
39
|
buffer = Buffer.concat([buffer, chunk]);
|
|
34
40
|
const length = buffer.readUInt32BE(0);
|
|
35
|
-
if (buffer.length < length +
|
|
41
|
+
if (buffer.length < length + SocketClient.LENGTH_HEADER_LENGTH) {
|
|
36
42
|
continue;
|
|
37
43
|
}
|
|
38
|
-
const data = buffer.subarray(
|
|
39
|
-
buffer = buffer.subarray(length +
|
|
44
|
+
const data = buffer.subarray(SocketClient.LENGTH_HEADER_LENGTH, length + SocketClient.LENGTH_HEADER_LENGTH);
|
|
45
|
+
buffer = buffer.subarray(length + SocketClient.LENGTH_HEADER_LENGTH);
|
|
40
46
|
yield JSON.parse(data.toString());
|
|
41
47
|
}
|
|
42
48
|
}
|
|
49
|
+
async close() {
|
|
50
|
+
this.socket.end();
|
|
51
|
+
await Promise.race([new Promise(resolve => this.socket.once("close", resolve)), new Promise(resolve => this.socket.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
52
|
+
}
|
|
53
|
+
get closed() {
|
|
54
|
+
return this.socket.closed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SocketClient = SocketClient;
|
|
58
|
+
class JSONLFileClient {
|
|
59
|
+
constructor(filePath) {
|
|
60
|
+
this.fileStream = fs.createReadStream(filePath, {
|
|
61
|
+
encoding: "utf-8"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
sendJSON(data) {
|
|
65
|
+
console.log("Sending message", data);
|
|
66
|
+
}
|
|
67
|
+
async *receiveJSON() {
|
|
68
|
+
const rl = (0, _readline.createInterface)({
|
|
69
|
+
input: this.fileStream,
|
|
70
|
+
crlfDelay: Infinity
|
|
71
|
+
});
|
|
72
|
+
for await (const line of rl) {
|
|
73
|
+
if (line.trim() === "") {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
yield JSON.parse(line);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async close() {
|
|
80
|
+
this.fileStream.close();
|
|
81
|
+
await Promise.race([new Promise(resolve => this.fileStream.once("close", resolve)), new Promise(resolve => this.fileStream.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
82
|
+
}
|
|
83
|
+
get closed() {
|
|
84
|
+
return this.fileStream.closed;
|
|
85
|
+
}
|
|
43
86
|
}
|
|
44
|
-
exports.
|
|
87
|
+
exports.JSONLFileClient = JSONLFileClient;
|
|
@@ -7,7 +7,6 @@ exports.runAutomationCLI = runAutomationCLI;
|
|
|
7
7
|
var _commander = require("commander");
|
|
8
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
9
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
10
|
-
var net = _interopRequireWildcard(require("net"));
|
|
11
10
|
var _zod = _interopRequireDefault(require("zod"));
|
|
12
11
|
var _runApi = require("../../common/runApi");
|
|
13
12
|
var _enums = require("../../runtime/enums");
|
|
@@ -59,22 +58,23 @@ _dotenv.default.config({
|
|
|
59
58
|
path: `.env`
|
|
60
59
|
});
|
|
61
60
|
function runAutomationCLI(importFunction) {
|
|
62
|
-
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath
|
|
61
|
+
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").option("--jsonl", "use a JSONL client instead of socket.", false).action(async (socketPath, {
|
|
62
|
+
jsonl
|
|
63
|
+
}) => {
|
|
63
64
|
let context;
|
|
64
65
|
const throttleTime = 60 * 1000;
|
|
65
66
|
let timeoutTimestamp = Date.now();
|
|
66
|
-
const client =
|
|
67
|
+
const client = jsonl ? new _unixSocket.JSONLFileClient(socketPath) : new _unixSocket.SocketClient(socketPath);
|
|
67
68
|
const abortController = new AbortController();
|
|
68
69
|
const interruptSignalHandler = async () => {
|
|
69
70
|
abortController.abort();
|
|
70
71
|
await (0, _promises.setTimeout)(60_000);
|
|
71
|
-
client.
|
|
72
|
+
await client.close();
|
|
72
73
|
process.exit(1);
|
|
73
74
|
};
|
|
74
75
|
process.on("SIGINT", interruptSignalHandler);
|
|
75
76
|
process.on("SIGTERM", interruptSignalHandler);
|
|
76
|
-
const
|
|
77
|
-
const messagesGenerator = jsonUnixSocket.receiveJSON();
|
|
77
|
+
const messagesGenerator = client.receiveJSON();
|
|
78
78
|
async function receiveMessages() {
|
|
79
79
|
const data = await messagesGenerator.next();
|
|
80
80
|
if (data.done) {
|
|
@@ -109,7 +109,7 @@ function runAutomationCLI(importFunction) {
|
|
|
109
109
|
extendTimeoutCallback: async () => {
|
|
110
110
|
if (Date.now() - timeoutTimestamp < throttleTime) return;
|
|
111
111
|
timeoutTimestamp = Date.now();
|
|
112
|
-
|
|
112
|
+
client.sendJSON({
|
|
113
113
|
type: "extend"
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -149,7 +149,7 @@ function runAutomationCLI(importFunction) {
|
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
if (message.type === "error") {
|
|
152
|
-
|
|
152
|
+
client.sendJSON({
|
|
153
153
|
type: "done",
|
|
154
154
|
result: message.error.json,
|
|
155
155
|
success: false
|
|
@@ -157,7 +157,7 @@ function runAutomationCLI(importFunction) {
|
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
159
|
if (message.type === "ping") {
|
|
160
|
-
|
|
160
|
+
client.sendJSON({
|
|
161
161
|
type: "pong"
|
|
162
162
|
});
|
|
163
163
|
break;
|
|
@@ -171,7 +171,7 @@ function runAutomationCLI(importFunction) {
|
|
|
171
171
|
} = messageOrResult;
|
|
172
172
|
const success = result.isOk();
|
|
173
173
|
const resultToSend = success ? result.value : result.error.json;
|
|
174
|
-
|
|
174
|
+
client.sendJSON({
|
|
175
175
|
type: "done",
|
|
176
176
|
result: resultToSend,
|
|
177
177
|
success
|
|
@@ -179,8 +179,7 @@ function runAutomationCLI(importFunction) {
|
|
|
179
179
|
break;
|
|
180
180
|
}
|
|
181
181
|
if (!client.closed) {
|
|
182
|
-
client.
|
|
183
|
-
await Promise.race([new Promise(resolve => client.once("close", resolve)), new Promise(resolve => client.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
182
|
+
await client.close();
|
|
184
183
|
}
|
|
185
184
|
process.exit(0);
|
|
186
185
|
});
|
|
@@ -15,7 +15,7 @@ const optionsSchema = _types.baseCommandOptionsSchema.extend({
|
|
|
15
15
|
authSession: _zod.z.string().optional(),
|
|
16
16
|
outputFile: _zod.z.string().optional()
|
|
17
17
|
});
|
|
18
|
-
const attemptApiCommand = exports.attemptApiCommand = (0, _types.withBaseOptions)(_attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-
|
|
18
|
+
const attemptApiCommand = exports.attemptApiCommand = (0, _types.withBaseOptions)(_attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>.json").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
|
|
19
19
|
authSession,
|
|
20
20
|
...rest
|
|
21
21
|
}) => {
|
|
@@ -14,7 +14,7 @@ const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "Parameters are required
|
|
|
14
14
|
const optionsSchema = _types.baseCommandOptionsSchema.extend({
|
|
15
15
|
id: _zod.z.string().optional()
|
|
16
16
|
});
|
|
17
|
-
const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("create").description("Create a new auth session").argument("<parameters>", "Parameters for the auth session command").option("--id <id>", "ID of the auth session to use for the command. Defaults to ./auth-
|
|
17
|
+
const attemptAuthSessionCreateCommand = exports.attemptAuthSessionCreateCommand = (0, _types.withBaseOptions)(_attempt_authsession.attemptAuthSessionCommand.command("create").description("Create a new auth session").argument("<parameters>", "Parameters for the auth session command").option("--id <id>", "ID of the auth session to use for the command. Defaults to ./auth-session-instances/[current timestamp].json")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([parameters], options) => {
|
|
18
18
|
await (0, _helpers.assertAuthEnabled)();
|
|
19
19
|
const authSessionInput = (await (0, _controller.loadParameters)(parameters)) ?? {};
|
|
20
20
|
await (0, _authSession.executeAttemptCreateAuthSessionCLI)({
|
|
@@ -19,7 +19,7 @@ const optionsSchema = _types.baseCommandOptionsSchema.extend({
|
|
|
19
19
|
authSessionCheckAttempts: _types.authSessionCheckAttemptsSchema,
|
|
20
20
|
authSessionCreateAttempts: _types.authSessionCreateAttemptsSchema
|
|
21
21
|
});
|
|
22
|
-
const runApiCommand = exports.runApiCommand = (0, _types.withBaseOptions)(_run.runCommand.command("api").description("Execute an Intuned API run with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-
|
|
22
|
+
const runApiCommand = exports.runApiCommand = (0, _types.withBaseOptions)(_run.runCommand.command("api").description("Execute an Intuned API run with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the auth session to use for the API. This is expected to be in ./auth-session-instances/<id>").option("--retries <number>", "Number of retries for the API call", "1").option("--no-auth-session-auto-recreate", "disable auto recreate for auth session").option("--auth-session-check-attempts <number>", "auth session check attempts", "1").option("--auth-session-create-attempts <number>", "auth session create attempts", "1").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
|
|
23
23
|
retries,
|
|
24
24
|
outputFile,
|
|
25
25
|
authSession,
|
|
@@ -13,20 +13,9 @@ var _promises = require("timers/promises");
|
|
|
13
13
|
var _ms = _interopRequireDefault(require("ms"));
|
|
14
14
|
var _save = require("./save");
|
|
15
15
|
var _constants2 = require("../../../common/constants");
|
|
16
|
-
var _path = _interopRequireDefault(require("path"));
|
|
17
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
18
|
-
var _prompts = _interopRequireDefault(require("prompts"));
|
|
19
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
17
|
async function runDeployProject(projectName, auth) {
|
|
23
|
-
|
|
24
|
-
const shouldPromptFirstRunExperience = result?.state === "UNPUBLISHED";
|
|
25
|
-
let firstRunInfo = undefined;
|
|
26
|
-
const settings = await (0, _helpers.loadIntunedJson)();
|
|
27
|
-
if (shouldPromptFirstRunExperience) {
|
|
28
|
-
firstRunInfo = await promptFirstRunExperience(settings);
|
|
29
|
-
}
|
|
18
|
+
await (0, _save.runSaveProject)(projectName, auth);
|
|
30
19
|
const {
|
|
31
20
|
workspaceId,
|
|
32
21
|
apiKey
|
|
@@ -39,10 +28,7 @@ async function runDeployProject(projectName, auth) {
|
|
|
39
28
|
};
|
|
40
29
|
const response = await fetch(url, {
|
|
41
30
|
headers,
|
|
42
|
-
method: "POST"
|
|
43
|
-
body: JSON.stringify({
|
|
44
|
-
firstRunInfo
|
|
45
|
-
})
|
|
31
|
+
method: "POST"
|
|
46
32
|
});
|
|
47
33
|
if (!response.ok) {
|
|
48
34
|
if (response.status === 401) {
|
|
@@ -99,22 +85,8 @@ async function runDeployProject(projectName, auth) {
|
|
|
99
85
|
}
|
|
100
86
|
if (status === "completed") {
|
|
101
87
|
const url = (0, _helpers.getBaseUrl)();
|
|
102
|
-
const hasDefaultJob = await getDefaultJobExists({
|
|
103
|
-
baseUrl,
|
|
104
|
-
workspaceId,
|
|
105
|
-
projectName,
|
|
106
|
-
apiKey
|
|
107
|
-
});
|
|
108
|
-
const projectUrl = `${url}/projects/${projectId}`;
|
|
109
88
|
(0, _terminal.terminal)(`\n^g^+Project deployed successfully!^:\n`);
|
|
110
|
-
(0, _terminal.terminal)(`^+
|
|
111
|
-
if (settings.apiAccess.enabled) {
|
|
112
|
-
(0, _terminal.terminal)(`^+Run playground:^s ^c^_${projectUrl}/runs?playground=open^:\n`);
|
|
113
|
-
}
|
|
114
|
-
(0, _terminal.terminal)(`^+Manage jobs:^s ^c^_${projectUrl}/jobs^:\n`);
|
|
115
|
-
if (hasDefaultJob) {
|
|
116
|
-
(0, _terminal.terminal)(`^+Trigger default job:^s ^c^_${projectUrl}/jobs/default?action=trigger^:\n`);
|
|
117
|
-
}
|
|
89
|
+
(0, _terminal.terminal)(`^+You can check your project on the platform:^s ^c^_${url}/projects/${projectId}/details^:\n`);
|
|
118
90
|
return;
|
|
119
91
|
}
|
|
120
92
|
let errorMessage = `^r^+An error occurred while deploying project:^:\n^R${message}^:\n`;
|
|
@@ -164,87 +136,4 @@ const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey)
|
|
|
164
136
|
status: "failed",
|
|
165
137
|
message: `Deployment failed, please try again: ${data.message}`
|
|
166
138
|
};
|
|
167
|
-
};
|
|
168
|
-
{}
|
|
169
|
-
async function promptFirstRunExperience(settings) {
|
|
170
|
-
let testAuthSessionInput = undefined;
|
|
171
|
-
const shouldPromptForTestAuthSession = settings.authSessions.enabled && settings.authSessions.type === "API";
|
|
172
|
-
let shouldPromptForDefaultJob = true;
|
|
173
|
-
if (shouldPromptForTestAuthSession) {
|
|
174
|
-
testAuthSessionInput = await promptFirstRunExperienceTestAuthSessionParameters({
|
|
175
|
-
shouldPromptForDefaultJob
|
|
176
|
-
});
|
|
177
|
-
if (!testAuthSessionInput) {
|
|
178
|
-
shouldPromptForDefaultJob = false;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
testAuthSessionInput,
|
|
183
|
-
defaultJobInput: shouldPromptForDefaultJob ? await promptFirstRunExperienceDefaultJobParameters({
|
|
184
|
-
defaultJobInput: settings["metadata"].defaultJobInput
|
|
185
|
-
}) : undefined
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
async function promptFirstRunExperienceTestAuthSessionParameters({
|
|
189
|
-
shouldPromptForDefaultJob
|
|
190
|
-
}) {
|
|
191
|
-
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants2.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
192
|
-
const authSessionId = (await fs.readdir(authSessionsDirectoryPath)).shift();
|
|
193
|
-
if (authSessionId) {
|
|
194
|
-
const {
|
|
195
|
-
metadata
|
|
196
|
-
} = await (0, _helpers.loadAuthSessionInstance)(authSessionId);
|
|
197
|
-
if (metadata.authSessionInput) {
|
|
198
|
-
const message = shouldPromptForDefaultJob ? `Create a test auth session using ${authSessionId} parameters? (required for creating default job)` : `Create a test auth session using ${authSessionId} parameters?`;
|
|
199
|
-
const {
|
|
200
|
-
value
|
|
201
|
-
} = await (0, _prompts.default)({
|
|
202
|
-
type: "confirm",
|
|
203
|
-
name: "value",
|
|
204
|
-
message,
|
|
205
|
-
initial: true
|
|
206
|
-
});
|
|
207
|
-
if (value) {
|
|
208
|
-
return metadata.authSessionInput;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
async function promptFirstRunExperienceDefaultJobParameters({
|
|
214
|
-
defaultJobInput
|
|
215
|
-
}) {
|
|
216
|
-
const {
|
|
217
|
-
value
|
|
218
|
-
} = await (0, _prompts.default)({
|
|
219
|
-
type: "confirm",
|
|
220
|
-
name: "value",
|
|
221
|
-
message: `Create a default job with sample parameters?`,
|
|
222
|
-
initial: true
|
|
223
|
-
});
|
|
224
|
-
if (value) {
|
|
225
|
-
return defaultJobInput;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
async function getDefaultJobExists({
|
|
229
|
-
baseUrl,
|
|
230
|
-
workspaceId,
|
|
231
|
-
projectName,
|
|
232
|
-
apiKey
|
|
233
|
-
}) {
|
|
234
|
-
const url = `${baseUrl}/api/v1/workspace/${workspaceId}/projects/${projectName}/jobs/default`;
|
|
235
|
-
const headers = {
|
|
236
|
-
[_constants2.API_KEY_HEADER_NAME]: apiKey,
|
|
237
|
-
"Content-Type": "application/json"
|
|
238
|
-
};
|
|
239
|
-
const response = await fetch(url, {
|
|
240
|
-
headers,
|
|
241
|
-
method: "GET"
|
|
242
|
-
});
|
|
243
|
-
if (response.status === 404) {
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
if (!response.ok) {
|
|
247
|
-
throw new _helpers.CLIError(`Error checking default job existence ${response.status}: ${await response.text()}`);
|
|
248
|
-
}
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
139
|
+
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { AuthCredentials } from "../types";
|
|
3
|
-
export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<
|
|
4
|
-
projectId: string;
|
|
5
|
-
state: string | undefined;
|
|
6
|
-
} | undefined>;
|
|
3
|
+
export declare function runSaveProject(projectName: string, auth: AuthCredentials): Promise<void>;
|
|
7
4
|
export declare const projectNameSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
8
5
|
export declare const validateProjectName: (projectName: string) => {
|
|
9
6
|
isValid: true;
|
|
@@ -33,8 +33,7 @@ const saveProjectApiResponseSchema = _zod.z.string().transform((val, ctx) => {
|
|
|
33
33
|
return _zod.z.NEVER;
|
|
34
34
|
}
|
|
35
35
|
}).pipe(_zod.z.object({
|
|
36
|
-
id: _zod.z.string().uuid()
|
|
37
|
-
state: _zod.z.string().optional()
|
|
36
|
+
id: _zod.z.string().uuid()
|
|
38
37
|
}));
|
|
39
38
|
async function runSaveProject(projectName, auth) {
|
|
40
39
|
const {
|
|
@@ -87,8 +86,7 @@ async function runSaveProject(projectName, auth) {
|
|
|
87
86
|
return;
|
|
88
87
|
}
|
|
89
88
|
const {
|
|
90
|
-
id: projectId
|
|
91
|
-
state
|
|
89
|
+
id: projectId
|
|
92
90
|
} = parseResult.data;
|
|
93
91
|
const dotEnvPath = path.join(projectPath, ".env");
|
|
94
92
|
if (!(await fs.exists(dotEnvPath))) {
|
|
@@ -113,10 +111,6 @@ ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
|
|
|
113
111
|
await fs.appendFile(dotEnvPath, contentToAppend + "\n");
|
|
114
112
|
(0, _terminal.terminal)(`^g^+Updated .env file with project credentials.^:\n`);
|
|
115
113
|
}
|
|
116
|
-
return {
|
|
117
|
-
projectId,
|
|
118
|
-
state
|
|
119
|
-
};
|
|
120
114
|
}
|
|
121
115
|
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
|
|
122
116
|
message: "Name cannot be a UUID"
|
|
@@ -23,5 +23,5 @@ async function getAuthCredentials(options) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
function getBaseUrl() {
|
|
26
|
-
return
|
|
26
|
+
return process.env[_constants.API_BASE_URL_ENV_VAR_KEY] || process.env.INTUNED_API_DOMAIN || `https://app.intuned.io`;
|
|
27
27
|
}
|
|
@@ -1,43 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const intunedJsonSchema: z.
|
|
3
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
4
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
5
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
6
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
7
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
8
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
9
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
10
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
11
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
|
|
12
|
-
authSessions: z.ZodObject<{
|
|
13
|
-
enabled: z.ZodLiteral<false>;
|
|
14
|
-
}, "strip", z.ZodTypeAny, {
|
|
15
|
-
enabled: false;
|
|
16
|
-
}, {
|
|
17
|
-
enabled: false;
|
|
18
|
-
}>;
|
|
19
|
-
apiAccess: z.ZodObject<{
|
|
20
|
-
enabled: z.ZodLiteral<false>;
|
|
21
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
enabled: false;
|
|
23
|
-
}, {
|
|
24
|
-
enabled: false;
|
|
25
|
-
}>;
|
|
26
|
-
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
authSessions: {
|
|
28
|
-
enabled: false;
|
|
29
|
-
};
|
|
30
|
-
apiAccess: {
|
|
31
|
-
enabled: false;
|
|
32
|
-
};
|
|
33
|
-
}, {
|
|
34
|
-
authSessions: {
|
|
35
|
-
enabled: false;
|
|
36
|
-
};
|
|
37
|
-
apiAccess: {
|
|
38
|
-
enabled: false;
|
|
39
|
-
};
|
|
40
|
-
}>, z.ZodObject<{
|
|
2
|
+
export declare const intunedJsonSchema: z.ZodObject<{
|
|
41
3
|
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
42
4
|
enabled: z.ZodLiteral<false>;
|
|
43
5
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -60,13 +22,8 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
60
22
|
startUrl?: string | undefined;
|
|
61
23
|
finishUrl?: string | undefined;
|
|
62
24
|
}>]>;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, "strip", z.ZodTypeAny, {
|
|
66
|
-
enabled: true;
|
|
67
|
-
}, {
|
|
68
|
-
enabled: true;
|
|
69
|
-
}>;
|
|
25
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
26
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
70
27
|
}, "strip", z.ZodTypeAny, {
|
|
71
28
|
authSessions: {
|
|
72
29
|
enabled: false;
|
|
@@ -76,9 +33,8 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
76
33
|
startUrl?: string | undefined;
|
|
77
34
|
finishUrl?: string | undefined;
|
|
78
35
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
};
|
|
36
|
+
projectName?: string | undefined;
|
|
37
|
+
workspaceId?: string | undefined;
|
|
82
38
|
}, {
|
|
83
39
|
authSessions: {
|
|
84
40
|
enabled: false;
|
|
@@ -88,25 +44,12 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
|
88
44
|
startUrl?: string | undefined;
|
|
89
45
|
finishUrl?: string | undefined;
|
|
90
46
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}>]>>;
|
|
47
|
+
projectName?: string | undefined;
|
|
48
|
+
workspaceId?: string | undefined;
|
|
49
|
+
}>;
|
|
95
50
|
export type IntunedJson = z.infer<typeof intunedJsonSchema>;
|
|
96
51
|
export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
97
52
|
export declare function loadIntunedJson(): Promise<{
|
|
98
|
-
projectName?: string | undefined;
|
|
99
|
-
workspaceId?: string | undefined;
|
|
100
|
-
} & {
|
|
101
|
-
[k: string]: unknown;
|
|
102
|
-
} & ({
|
|
103
|
-
authSessions: {
|
|
104
|
-
enabled: false;
|
|
105
|
-
};
|
|
106
|
-
apiAccess: {
|
|
107
|
-
enabled: false;
|
|
108
|
-
};
|
|
109
|
-
} | {
|
|
110
53
|
authSessions: {
|
|
111
54
|
enabled: false;
|
|
112
55
|
} | {
|
|
@@ -115,10 +58,9 @@ export declare function loadIntunedJson(): Promise<{
|
|
|
115
58
|
startUrl?: string | undefined;
|
|
116
59
|
finishUrl?: string | undefined;
|
|
117
60
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})>;
|
|
61
|
+
projectName?: string | undefined;
|
|
62
|
+
workspaceId?: string | undefined;
|
|
63
|
+
}>;
|
|
122
64
|
export declare function getIntunedSettingsFile(): Promise<{
|
|
123
65
|
name: typeof intunedSettingsFileNames[number];
|
|
124
66
|
path: string;
|
|
@@ -18,16 +18,6 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
20
|
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
21
|
-
projectName: _zod.z.string().optional(),
|
|
22
|
-
workspaceId: _zod.z.string().optional()
|
|
23
|
-
}).passthrough().and(_zod.z.union([_zod.z.object({
|
|
24
|
-
authSessions: _zod.z.object({
|
|
25
|
-
enabled: _zod.z.literal(false)
|
|
26
|
-
}),
|
|
27
|
-
apiAccess: _zod.z.object({
|
|
28
|
-
enabled: _zod.z.literal(false)
|
|
29
|
-
})
|
|
30
|
-
}), _zod.z.object({
|
|
31
21
|
authSessions: _zod.z.union([_zod.z.object({
|
|
32
22
|
enabled: _zod.z.literal(false)
|
|
33
23
|
}), _zod.z.object({
|
|
@@ -36,10 +26,9 @@ const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
|
36
26
|
startUrl: _zod.z.string().optional(),
|
|
37
27
|
finishUrl: _zod.z.string().optional()
|
|
38
28
|
})]),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})]));
|
|
29
|
+
projectName: _zod.z.string().optional(),
|
|
30
|
+
workspaceId: _zod.z.string().optional()
|
|
31
|
+
});
|
|
43
32
|
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
44
33
|
async function loadIntunedJson() {
|
|
45
34
|
const settingsFile = await getIntunedSettingsFile();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.3.8-
|
|
3
|
+
"version": "1.3.8-fix.0",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"dotenv": "^16.3.1",
|
|
72
72
|
"fs-extra": "^11.3.0",
|
|
73
73
|
"image-size": "^1.1.1",
|
|
74
|
-
"inquirer": "12.6.0",
|
|
75
74
|
"jsonc-parser": "^3.3.1",
|
|
76
75
|
"jsonwebtoken": "9.0.2",
|
|
77
76
|
"lodash": "4.17.21",
|
|
@@ -83,7 +82,6 @@
|
|
|
83
82
|
"portfinder": "^1.0.37",
|
|
84
83
|
"prettier": "2.8.0",
|
|
85
84
|
"promptly": "3.2.0",
|
|
86
|
-
"prompts": "^2.4.2",
|
|
87
85
|
"rollup": "3.26.2",
|
|
88
86
|
"smol-toml": "^1.4.2",
|
|
89
87
|
"source-map": "0.7.4",
|
|
@@ -109,7 +107,6 @@
|
|
|
109
107
|
"@types/jsdom": "^21.1.1",
|
|
110
108
|
"@types/ms": "^2.1.0",
|
|
111
109
|
"@types/promptly": "^3.0.4",
|
|
112
|
-
"@types/prompts": "^2.4.9",
|
|
113
110
|
"@types/terminal-kit": "^2.5.7",
|
|
114
111
|
"@types/wait-on": "^5.3.4",
|
|
115
112
|
"@typescript-eslint/eslint-plugin": "^5.47.1",
|