@intuned/runtime-dev 0.1.0-test.14 → 0.1.0-test.16
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/.babelrc +1 -2
- package/WebTemplate/api.ts +90 -92
- package/WebTemplate/controllers/authSessions/create.ts +2 -2
- package/WebTemplate/controllers/authSessions/store.ts +1 -1
- package/WebTemplate/controllers/runApi/helpers.ts +14 -12
- package/WebTemplate/index.playwright.ts +32 -42
- package/WebTemplate/jobs.ts +13 -2
- package/WebTemplate/utils.ts +53 -1
- package/api/test2.ts +6 -1
- package/auth-sessions/check.ts +3 -1
- package/auth-sessions/create.ts +10 -10
- package/bin/intuned-api-run +1 -1
- package/bin/intuned-auth-session-check +1 -1
- package/bin/intuned-auth-session-create +1 -1
- package/bin/intuned-auth-session-load +1 -1
- package/bin/intuned-auth-session-refresh +1 -1
- package/bin/intuned-browser-save-state +1 -1
- package/bin/intuned-browser-start +1 -1
- package/bin/intuned-build +1 -1
- package/bin/intuned-ts-check +1 -1
- package/dist/commands/api/run.js +109 -170
- package/dist/commands/auth-sessions/load.js +28 -26
- package/dist/commands/auth-sessions/run-check.js +54 -53
- package/dist/commands/auth-sessions/run-create.js +93 -96
- package/dist/commands/browser/save-state.js +14 -16
- package/dist/commands/browser/start-browser.js +11 -11
- package/dist/commands/build.js +79 -109
- package/dist/commands/common/browserUtils.js +53 -51
- package/dist/commands/common/getFirstLineNumber.js +93 -93
- package/dist/commands/common/{getFirstLineNumber.test.ts → getFirstLineNumber.test.js} +53 -48
- package/dist/commands/common/sendMessageToClient.js +9 -4
- package/dist/commands/common/tsNodeImport.d.ts +1 -0
- package/dist/commands/common/tsNodeImport.js +18 -0
- package/dist/commands/common/utils/fileUtils.js +32 -22
- package/dist/commands/common/utils/settings.js +27 -19
- package/dist/commands/common/utils/unixSocket.js +43 -43
- package/dist/commands/common/utils/webTemplate.js +30 -28
- package/dist/commands/interface/run.js +162 -139
- package/dist/commands/ts-check.js +50 -50
- package/dist/common/Logger/Logger/index.js +55 -42
- package/dist/common/Logger/Logger/types.js +5 -1
- package/dist/common/Logger/index.js +55 -42
- package/dist/common/Logger/types.js +5 -1
- package/dist/common/asyncLocalStorage/index.js +16 -8
- package/dist/common/cleanEnvironmentVariables.js +16 -12
- package/dist/common/constants.js +7 -1
- package/dist/common/contextStorageStateHelpers.js +47 -38
- package/dist/common/getPlaywrightConstructs.js +178 -197
- package/dist/common/jwtTokenManager.js +76 -79
- package/dist/common/runApi/errors.js +159 -150
- package/dist/common/runApi/index.js +240 -232
- package/dist/common/runApi/types.d.ts +19 -5
- package/dist/common/runApi/types.js +53 -56
- package/dist/common/settingsSchema.js +15 -10
- package/dist/common/telemetry.js +28 -30
- package/dist/index.js +69 -4
- package/dist/runtime/RunError.js +18 -11
- package/dist/runtime/downloadDirectory.js +19 -13
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -1
- package/dist/runtime/enums.js +18 -12
- package/dist/runtime/executionHelpers.test.js +53 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +202 -1
- package/dist/runtime/extendPayload.js +21 -15
- package/dist/runtime/extendTimeout.js +28 -21
- package/dist/runtime/index.js +53 -6
- package/dist/runtime/requestMoreInfo.js +23 -16
- package/dist/runtime/runInfo.js +21 -14
- package/package.json +4 -7
- package/dist/commands/api/run.ts +0 -105
- package/dist/commands/auth-sessions/load.ts +0 -30
- package/dist/commands/auth-sessions/run-check.ts +0 -51
- package/dist/commands/auth-sessions/run-create.ts +0 -91
- package/dist/commands/browser/save-state.ts +0 -14
- package/dist/commands/browser/start-browser.ts +0 -11
- package/dist/commands/build.ts +0 -79
- package/dist/commands/common/browserUtils.ts +0 -45
- package/dist/commands/common/getDefaultExportFromFile.d.ts +0 -1
- package/dist/commands/common/getDefaultExportFromFile.js +0 -12
- package/dist/commands/common/getDefaultExportFromFile.ts +0 -11
- package/dist/commands/common/getFirstLineNumber.ts +0 -96
- package/dist/commands/common/sendMessageToClient.ts +0 -3
- package/dist/commands/common/utils/fileUtils.ts +0 -23
- package/dist/commands/common/utils/settings.ts +0 -22
- package/dist/commands/common/utils/unixSocket.ts +0 -38
- package/dist/commands/common/utils/webTemplate.ts +0 -23
- package/dist/commands/interface/run.ts +0 -156
- package/dist/commands/ts-check.ts +0 -51
- package/dist/common/Logger/Logger/index.ts +0 -53
- package/dist/common/Logger/Logger/types.ts +0 -1
- package/dist/common/Logger/index.ts +0 -53
- package/dist/common/Logger/types.ts +0 -1
- package/dist/common/asyncLocalStorage/index.ts +0 -9
- package/dist/common/cleanEnvironmentVariables.ts +0 -10
- package/dist/common/constants.ts +0 -1
- package/dist/common/contextStorageStateHelpers.ts +0 -43
- package/dist/common/getPlaywrightConstructs.ts +0 -182
- package/dist/common/jwtTokenManager.ts +0 -71
- package/dist/common/runApi/errors.ts +0 -154
- package/dist/common/runApi/index.ts +0 -253
- package/dist/common/runApi/types.ts +0 -43
- package/dist/common/settingsSchema.ts +0 -9
- package/dist/common/telemetry.ts +0 -23
- package/dist/index.ts +0 -4
- package/dist/runtime/RunError.ts +0 -12
- package/dist/runtime/downloadDirectory.ts +0 -13
- package/dist/runtime/enums.ts +0 -12
- package/dist/runtime/executionHelpers.test.ts +0 -51
- package/dist/runtime/extendPayload.ts +0 -15
- package/dist/runtime/extendTimeout.ts +0 -24
- package/dist/runtime/index.ts +0 -6
- package/dist/runtime/requestMoreInfo.ts +0 -18
- package/dist/runtime/runInfo.ts +0 -15
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
getFullPathInProject("yarn.lock"),
|
|
24
|
-
getFullPathInProject(".env"),
|
|
25
|
-
];
|
|
26
|
-
const filesToCopy = filesAndFolders.filter((file) => !pathsIgnoreList.includes(file.fullPath));
|
|
27
|
-
for (const file of filesToCopy) {
|
|
28
|
-
await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moveWebTemplateFiles = void 0;
|
|
7
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
8
|
+
var path = _interopRequireWildcard(require("path"));
|
|
9
|
+
var _fileUtils = require("./fileUtils.js");
|
|
10
|
+
var _url = require("url");
|
|
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 && Object.prototype.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
|
+
const moveWebTemplateFiles = async () => {
|
|
14
|
+
await fs.remove("./intuned");
|
|
15
|
+
await fs.ensureDir("./intuned");
|
|
16
|
+
const currentFileLocation = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "..", "..", "..", "WebTemplate");
|
|
17
|
+
await fs.copy(`${currentFileLocation}`, "./intuned/WebTemplate", {
|
|
18
|
+
filter: (src, dest) => {
|
|
19
|
+
if (src.includes(".d.ts")) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
29
23
|
}
|
|
24
|
+
});
|
|
25
|
+
const filesAndFolders = await (0, _fileUtils.listProjectFilesAndFolders)();
|
|
26
|
+
const pathsIgnoreList = [(0, _fileUtils.getFullPathInProject)("intuned"), (0, _fileUtils.getFullPathInProject)("node_modules"), (0, _fileUtils.getFullPathInProject)("package.json"), (0, _fileUtils.getFullPathInProject)("yarn.lock"), (0, _fileUtils.getFullPathInProject)(".env")];
|
|
27
|
+
const filesToCopy = filesAndFolders.filter(file => !pathsIgnoreList.includes(file.fullPath));
|
|
28
|
+
for (const file of filesToCopy) {
|
|
29
|
+
await fs.copy(file.fullPath, `./intuned/WebTemplate/${file.name}`);
|
|
30
|
+
}
|
|
30
31
|
};
|
|
32
|
+
exports.moveWebTemplateFiles = moveWebTemplateFiles;
|
|
@@ -1,162 +1,185 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.optional(),
|
|
23
|
-
}),
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _commander = require("commander");
|
|
5
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
6
|
+
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
7
|
+
var net = _interopRequireWildcard(require("net"));
|
|
8
|
+
var _zod = _interopRequireDefault(require("zod"));
|
|
9
|
+
var _runApi = require("../../common/runApi");
|
|
10
|
+
var _enums = require("src/runtime/enums");
|
|
11
|
+
var _unixSocket = require("../common/utils/unixSocket");
|
|
12
|
+
var _promises = require("timers/promises");
|
|
13
|
+
var _jwtTokenManager = require("src/common/jwtTokenManager");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
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); }
|
|
16
|
+
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 && Object.prototype.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; }
|
|
17
|
+
const nextRunApiSchema = _zod.default.object({
|
|
18
|
+
type: _zod.default.literal("next"),
|
|
19
|
+
parameters: _zod.default.object({
|
|
20
|
+
value: _zod.default.string()
|
|
21
|
+
})
|
|
24
22
|
});
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const abortRunApiSchema = _zod.default.object({
|
|
24
|
+
type: _zod.default.literal("abort"),
|
|
25
|
+
parameters: _zod.default.object({}).optional()
|
|
28
26
|
});
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const tokenUpdateSchema = _zod.default.object({
|
|
28
|
+
type: _zod.default.literal("tokenUpdate"),
|
|
29
|
+
parameters: _zod.default.object({
|
|
30
|
+
functionsToken: _zod.default.string()
|
|
31
|
+
})
|
|
32
32
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
nextRunApiSchema,
|
|
36
|
-
abortRunApiSchema,
|
|
37
|
-
]);
|
|
38
|
-
dotenv.config({
|
|
39
|
-
path: `.env`,
|
|
33
|
+
_dotenv.default.config({
|
|
34
|
+
path: `.env`
|
|
40
35
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
function main(importFunction) {
|
|
37
|
+
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath => {
|
|
38
|
+
const startRunApiSchema = _zod.default.object({
|
|
39
|
+
type: _zod.default.literal("start"),
|
|
40
|
+
parameters: _runApi.runApiParametersSchema.extend({
|
|
41
|
+
automationFunction: _runApi.runApiParametersSchema.shape.automationFunction.omit({
|
|
42
|
+
module: true
|
|
43
|
+
}).extend({
|
|
44
|
+
name: _zod.default.string()
|
|
45
|
+
}),
|
|
46
|
+
retrieveSession: _zod.default.boolean(),
|
|
47
|
+
context: _zod.default.object({
|
|
48
|
+
jobId: _zod.default.string().optional(),
|
|
49
|
+
jobRunId: _zod.default.string().optional(),
|
|
50
|
+
runId: _zod.default.string().optional(),
|
|
51
|
+
queueId: _zod.default.string().optional()
|
|
52
|
+
}).optional()
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
const inputSchema = _zod.default.union([startRunApiSchema, nextRunApiSchema, abortRunApiSchema, tokenUpdateSchema]);
|
|
45
56
|
let context;
|
|
46
57
|
const throttleTime = 1_000;
|
|
47
58
|
let timeoutTimestamp = Date.now();
|
|
48
|
-
const client = net.createConnection(socketPath
|
|
49
|
-
console.log("connected to server!");
|
|
50
|
-
});
|
|
59
|
+
const client = net.createConnection(socketPath);
|
|
51
60
|
let generator = null;
|
|
52
61
|
const abortController = new AbortController();
|
|
53
|
-
client.on("
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
client.on("error", (err) => {
|
|
57
|
-
console.error("Child connection error:", err);
|
|
58
|
-
void generator?.throw(err).catch(() => undefined);
|
|
62
|
+
client.on("error", err => {
|
|
63
|
+
var _generator2;
|
|
64
|
+
void ((_generator2 = generator) === null || _generator2 === void 0 ? void 0 : _generator2.throw(err).catch(() => undefined));
|
|
59
65
|
});
|
|
60
66
|
process.on("SIGINT", () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
var _generator3;
|
|
68
|
+
void ((_generator3 = generator) === null || _generator3 === void 0 ? void 0 : _generator3.throw(new Error("Interrupted")).catch(() => undefined));
|
|
69
|
+
client.end();
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
process.on("SIGTERM", () => {
|
|
73
|
+
var _generator4;
|
|
74
|
+
void ((_generator4 = generator) === null || _generator4 === void 0 ? void 0 : _generator4.throw(new Error("Interrupted")).catch(() => undefined));
|
|
75
|
+
client.end();
|
|
76
|
+
process.exit(1);
|
|
65
77
|
});
|
|
66
|
-
const jsonUnixSocket = new JSONUnixSocket(client);
|
|
78
|
+
const jsonUnixSocket = new _unixSocket.JSONUnixSocket(client);
|
|
67
79
|
async function runGeneratorAndSendResult(next) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
const _generator = generator;
|
|
81
|
+
if (_generator == null) return;
|
|
82
|
+
const result = await (0, _asyncLocalStorage.runWithContext)(context, () => _generator.next(next));
|
|
83
|
+
if (result.done) {
|
|
84
|
+
const resultToSend = result.value.isOk() ? result.value.value : result.value.error.json;
|
|
85
|
+
const success = result.value.isOk();
|
|
86
|
+
jsonUnixSocket.sendJSON({
|
|
87
|
+
type: "done",
|
|
88
|
+
result: resultToSend,
|
|
89
|
+
success
|
|
90
|
+
});
|
|
91
|
+
return true;
|
|
92
|
+
} else {
|
|
93
|
+
jsonUnixSocket.sendJSON({
|
|
94
|
+
type: "yield",
|
|
95
|
+
result: result.value
|
|
96
|
+
});
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
87
99
|
}
|
|
88
100
|
for await (const data of jsonUnixSocket.receiveJSON()) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
success: false,
|
|
102
|
-
});
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
const input = inputParseResult.data;
|
|
106
|
-
if (input.type === "abort") {
|
|
107
|
-
abortController.abort();
|
|
108
|
-
await setTimeout(10);
|
|
109
|
-
jsonUnixSocket.sendJSON({ type: "done", result: null });
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
if (input.type === "start") {
|
|
113
|
-
const gen = runApiGenerator({
|
|
114
|
-
...input.parameters,
|
|
115
|
-
abortSignal: abortController.signal,
|
|
116
|
-
});
|
|
117
|
-
generator = gen;
|
|
118
|
-
context = {
|
|
119
|
-
extendedPayloads: [],
|
|
120
|
-
runEnvironment: input.parameters.runOptions.environment === "deployed"
|
|
121
|
-
? RunEnvironment.DEPLOYED
|
|
122
|
-
: RunEnvironment.IDE,
|
|
123
|
-
timeoutInfo: {
|
|
124
|
-
extendTimeoutCallback: async () => {
|
|
125
|
-
if (Date.now() - timeoutTimestamp < throttleTime)
|
|
126
|
-
return;
|
|
127
|
-
timeoutTimestamp = Date.now();
|
|
128
|
-
jsonUnixSocket.sendJSON({ type: "extend" });
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
...(input.parameters.context ?? {}),
|
|
132
|
-
proxy: getProxyUrlFromRunOptions(input.parameters.runOptions),
|
|
133
|
-
};
|
|
134
|
-
if (await runGeneratorAndSendResult()) {
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (input.type === "next") {
|
|
140
|
-
if (!generator) {
|
|
141
|
-
throw new Error("generator not started");
|
|
101
|
+
const inputParseResult = inputSchema.safeParse(data);
|
|
102
|
+
if (!inputParseResult.success) {
|
|
103
|
+
console.error(inputParseResult.error.errors);
|
|
104
|
+
jsonUnixSocket.sendJSON({
|
|
105
|
+
type: "done",
|
|
106
|
+
result: {
|
|
107
|
+
error: "InvalidInput",
|
|
108
|
+
message: "Invalid input",
|
|
109
|
+
details: {
|
|
110
|
+
errors: inputParseResult.error.errors
|
|
142
111
|
}
|
|
143
|
-
|
|
144
|
-
|
|
112
|
+
},
|
|
113
|
+
success: false
|
|
114
|
+
});
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
const input = inputParseResult.data;
|
|
118
|
+
if (input.type === "abort") {
|
|
119
|
+
abortController.abort();
|
|
120
|
+
await (0, _promises.setTimeout)(10);
|
|
121
|
+
jsonUnixSocket.sendJSON({
|
|
122
|
+
type: "done",
|
|
123
|
+
result: null
|
|
124
|
+
});
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
if (input.type === "start") {
|
|
128
|
+
const gen = (0, _runApi.runApiGenerator)({
|
|
129
|
+
...input.parameters,
|
|
130
|
+
automationFunction: {
|
|
131
|
+
...input.parameters.automationFunction,
|
|
132
|
+
module: importFunction ? await importFunction(input.parameters.automationFunction.name) : await (specifier => new Promise(r => r(`${specifier}`)).then(s => _interopRequireWildcard(require(s))))(input.parameters.automationFunction.name)
|
|
133
|
+
},
|
|
134
|
+
abortSignal: abortController.signal
|
|
135
|
+
});
|
|
136
|
+
generator = gen;
|
|
137
|
+
context = {
|
|
138
|
+
extendedPayloads: [],
|
|
139
|
+
runEnvironment: input.parameters.runOptions.environment === "deployed" ? _enums.RunEnvironment.DEPLOYED : _enums.RunEnvironment.IDE,
|
|
140
|
+
timeoutInfo: {
|
|
141
|
+
extendTimeoutCallback: async () => {
|
|
142
|
+
if (Date.now() - timeoutTimestamp < throttleTime) return;
|
|
143
|
+
timeoutTimestamp = Date.now();
|
|
144
|
+
jsonUnixSocket.sendJSON({
|
|
145
|
+
type: "extend"
|
|
146
|
+
});
|
|
145
147
|
}
|
|
146
|
-
|
|
148
|
+
},
|
|
149
|
+
...(input.parameters.context ?? {}),
|
|
150
|
+
proxy: getProxyUrlFromRunOptions(input.parameters.runOptions)
|
|
151
|
+
};
|
|
152
|
+
if (await runGeneratorAndSendResult()) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (input.type === "next") {
|
|
158
|
+
if (!generator) {
|
|
159
|
+
throw new Error("generator not started");
|
|
147
160
|
}
|
|
161
|
+
if (await runGeneratorAndSendResult(input.parameters.value)) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (input.type === "tokenUpdate") {
|
|
167
|
+
_jwtTokenManager.backendFunctionsTokenManager.token = input.parameters.functionsToken;
|
|
168
|
+
}
|
|
148
169
|
}
|
|
149
170
|
process.exit(0);
|
|
150
|
-
});
|
|
151
|
-
program.parse(process.argv);
|
|
171
|
+
});
|
|
172
|
+
_commander.program.parse(process.argv);
|
|
173
|
+
}
|
|
152
174
|
function getProxyUrlFromRunOptions(runOptions) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
url.password = proxy.password;
|
|
161
|
-
return url.toString();
|
|
175
|
+
if ((runOptions === null || runOptions === void 0 ? void 0 : runOptions.environment) !== "deployed") return undefined;
|
|
176
|
+
const proxy = runOptions.proxy;
|
|
177
|
+
if (!proxy) return undefined;
|
|
178
|
+
const url = new URL(proxy.server);
|
|
179
|
+
url.username = proxy.username;
|
|
180
|
+
url.password = proxy.password;
|
|
181
|
+
return url.toString();
|
|
162
182
|
}
|
|
183
|
+
if (require.main === module) {
|
|
184
|
+
main();
|
|
185
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var ts = _interopRequireWildcard(require("typescript"));
|
|
5
|
+
var _commander = require("commander");
|
|
6
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
7
|
+
var path = _interopRequireWildcard(require("path"));
|
|
8
|
+
var _webTemplate = require("./common/utils/webTemplate.js");
|
|
9
|
+
var _url = require("url");
|
|
10
|
+
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); }
|
|
11
|
+
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 && Object.prototype.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; }
|
|
12
|
+
_commander.program.description("Check TypeScript types in the project").allowUnknownOption().action(async () => {
|
|
13
|
+
await (0, _webTemplate.moveWebTemplateFiles)();
|
|
14
|
+
const templateTsConfig = path.resolve(path.dirname((0, _url.fileURLToPath)(import.meta.url)), "..", "..", "template.tsconfig.json");
|
|
15
|
+
await fs.copy(templateTsConfig, "./intuned/WebTemplate/tsconfig.json");
|
|
16
|
+
checkTypes();
|
|
16
17
|
});
|
|
17
18
|
function checkTypes() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
if (allDiagnostics.length === 0) {
|
|
48
|
-
console.log("✨ TypeScript type checking passed without errors.");
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
console.error("Errors found during TypeScript type checking.");
|
|
52
|
-
process.exit(1);
|
|
19
|
+
const configPath = ts.findConfigFile("./intuned/WebTemplate", ts.sys.fileExists, "tsconfig.json");
|
|
20
|
+
if (!configPath) {
|
|
21
|
+
console.error("Could not find a valid 'tsconfig.json'.");
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
const readConfigResult = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
25
|
+
const config = readConfigResult.config;
|
|
26
|
+
const parseConfigHost = {
|
|
27
|
+
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
|
|
28
|
+
readDirectory: ts.sys.readDirectory,
|
|
29
|
+
fileExists: ts.sys.fileExists,
|
|
30
|
+
readFile: ts.sys.readFile
|
|
31
|
+
};
|
|
32
|
+
const parsed = ts.parseJsonConfigFileContent(config, parseConfigHost, "./intuned");
|
|
33
|
+
const program = ts.createProgram(parsed.fileNames, parsed.options);
|
|
34
|
+
const emitResult = program.emit();
|
|
35
|
+
const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
36
|
+
allDiagnostics.forEach(diagnostic => {
|
|
37
|
+
if (diagnostic.file) {
|
|
38
|
+
const {
|
|
39
|
+
line,
|
|
40
|
+
character
|
|
41
|
+
} = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
|
42
|
+
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
43
|
+
console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
44
|
+
} else {
|
|
45
|
+
console.log(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
|
53
46
|
}
|
|
47
|
+
});
|
|
48
|
+
if (allDiagnostics.length === 0) {
|
|
49
|
+
console.log("✨ TypeScript type checking passed without errors.");
|
|
50
|
+
} else {
|
|
51
|
+
console.error("Errors found during TypeScript type checking.");
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
54
|
}
|
|
55
|
-
program.parse(process.argv);
|
|
55
|
+
_commander.program.parse(process.argv);
|
|
@@ -1,47 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logger = void 0;
|
|
7
|
+
var _nodeUtil = require("node:util");
|
|
8
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
const format = _nodeUtil.formatWithOptions.bind(undefined, {
|
|
11
|
+
colors: true
|
|
12
|
+
});
|
|
4
13
|
const LOG_LEVEL_COLORS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
TRACE: _chalk.default.gray,
|
|
15
|
+
DEBUG: _chalk.default.blue,
|
|
16
|
+
INFO: _chalk.default.green,
|
|
17
|
+
WARN: _chalk.default.yellow,
|
|
18
|
+
ERROR: _chalk.default.red
|
|
10
19
|
};
|
|
11
20
|
class Logger {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
level,
|
|
26
|
-
message,
|
|
27
|
-
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
28
|
-
timestamp: Date.now(),
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
trace(message, meta) {
|
|
32
|
-
this.log("TRACE", message, meta);
|
|
33
|
-
}
|
|
34
|
-
debug(message, meta) {
|
|
35
|
-
this.log("DEBUG", message, meta);
|
|
36
|
-
}
|
|
37
|
-
info(message, meta) {
|
|
38
|
-
this.log("INFO", message, meta);
|
|
39
|
-
}
|
|
40
|
-
warn(message, meta) {
|
|
41
|
-
this.log("WARN", message, meta);
|
|
42
|
-
}
|
|
43
|
-
error(message, meta) {
|
|
44
|
-
this.log("ERROR", message, meta);
|
|
21
|
+
logFunction(entry) {
|
|
22
|
+
const {
|
|
23
|
+
level,
|
|
24
|
+
timestamp,
|
|
25
|
+
message,
|
|
26
|
+
meta
|
|
27
|
+
} = entry;
|
|
28
|
+
const date = new Date(timestamp);
|
|
29
|
+
const levelColor = LOG_LEVEL_COLORS[level];
|
|
30
|
+
if (meta === undefined) {
|
|
31
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message}\n`);
|
|
32
|
+
} else {
|
|
33
|
+
process.stderr.write(`${format(date)} [@intuned/sdk][${levelColor(level)}] ${message} ${format(meta)}\n`);
|
|
45
34
|
}
|
|
35
|
+
}
|
|
36
|
+
log(level, message, meta) {
|
|
37
|
+
this.logFunction({
|
|
38
|
+
level,
|
|
39
|
+
message,
|
|
40
|
+
meta: meta && Object.keys(meta).length === 0 ? undefined : meta,
|
|
41
|
+
timestamp: Date.now()
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
trace(message, meta) {
|
|
45
|
+
this.log("TRACE", message, meta);
|
|
46
|
+
}
|
|
47
|
+
debug(message, meta) {
|
|
48
|
+
this.log("DEBUG", message, meta);
|
|
49
|
+
}
|
|
50
|
+
info(message, meta) {
|
|
51
|
+
this.log("INFO", message, meta);
|
|
52
|
+
}
|
|
53
|
+
warn(message, meta) {
|
|
54
|
+
this.log("WARN", message, meta);
|
|
55
|
+
}
|
|
56
|
+
error(message, meta) {
|
|
57
|
+
this.log("ERROR", message, meta);
|
|
58
|
+
}
|
|
46
59
|
}
|
|
47
|
-
|
|
60
|
+
const logger = exports.logger = new Logger();
|