@requence/task 0.7.1 → 0.8.2-edge.1149
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/CHANGELOG.md +39 -0
- package/README.md +5 -5
- package/build/{chunk-b4h2we9a.js → chunk-f7g9gsa0.js} +33 -3
- package/build/chunk-f7g9gsa0.js.map +11 -0
- package/build/cli.js +18 -8
- package/build/cli.js.map +3 -3
- package/build/index.js +1062 -502
- package/build/index.js.map +27 -16
- package/build/types/helpers/src/index.d.ts +8 -2
- package/build/types/helpers/src/index.d.ts.map +1 -1
- package/build/types/helpers/src/jsonschema/validate.d.ts +1 -5
- package/build/types/helpers/src/jsonschema/validate.d.ts.map +1 -1
- package/build/types/helpers/src/jsonschema/zod.d.ts +11 -1
- package/build/types/helpers/src/jsonschema/zod.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/NodeTree.d.ts +532 -148
- package/build/types/helpers/src/protocol/NodeTree.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/clientProperties.d.ts +66 -0
- package/build/types/helpers/src/protocol/clientProperties.d.ts.map +1 -0
- package/build/types/helpers/src/protocol/command.d.ts +372 -142
- package/build/types/helpers/src/protocol/command.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/configurationScript.d.ts +10 -0
- package/build/types/helpers/src/protocol/configurationScript.d.ts.map +1 -0
- package/build/types/helpers/src/protocol/helpers.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/index.d.ts +5 -0
- package/build/types/helpers/src/protocol/index.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/logicLanguages.d.ts +19 -0
- package/build/types/helpers/src/protocol/logicLanguages.d.ts.map +1 -0
- package/build/types/helpers/src/protocol/loopDetection.d.ts +23 -0
- package/build/types/helpers/src/protocol/loopDetection.d.ts.map +1 -0
- package/build/types/helpers/src/protocol/nodeType.d.ts +81 -27
- package/build/types/helpers/src/protocol/nodeType.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/taskOptions.d.ts +4 -1
- package/build/types/helpers/src/protocol/taskOptions.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/templateNodeTypes.d.ts +36 -20
- package/build/types/helpers/src/protocol/templateNodeTypes.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/treeNodes.d.ts +508 -164
- package/build/types/helpers/src/protocol/treeNodes.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/update.d.ts +40 -24
- package/build/types/helpers/src/protocol/update.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/validateTreeStructure.d.ts +22 -0
- package/build/types/helpers/src/protocol/validateTreeStructure.d.ts.map +1 -0
- package/build/types/helpers/src/utils/amqpHeartbeat.d.ts +3 -0
- package/build/types/helpers/src/utils/amqpHeartbeat.d.ts.map +1 -0
- package/build/types/helpers/src/utils/amqpPublishRetry.d.ts +45 -0
- package/build/types/helpers/src/utils/amqpPublishRetry.d.ts.map +1 -0
- package/build/types/helpers/src/utils/claimCheckObject.d.ts +40 -0
- package/build/types/helpers/src/utils/claimCheckObject.d.ts.map +1 -0
- package/build/types/helpers/src/utils/debounce.d.ts.map +1 -1
- package/build/types/helpers/src/{files → utils}/fileObject.d.ts.map +1 -1
- package/build/types/helpers/src/{files → utils}/isValidMimeType.d.ts.map +1 -1
- package/build/types/helpers/src/utils/mapData.d.ts +1 -1
- package/build/types/helpers/src/utils/mapData.d.ts.map +1 -1
- package/build/types/helpers/src/{files → utils}/streamObject.d.ts.map +1 -1
- package/build/types/helpers/src/utils/variableRef.d.ts +19 -0
- package/build/types/helpers/src/utils/variableRef.d.ts.map +1 -0
- package/build/types/helpers/src/utils/variableScriptPatterns.d.ts +125 -0
- package/build/types/helpers/src/utils/variableScriptPatterns.d.ts.map +1 -0
- package/build/types/task/src/abortTask.d.ts.map +1 -1
- package/build/types/task/src/ackTask.d.ts.map +1 -1
- package/build/types/task/src/createTask.d.ts +0 -1
- package/build/types/task/src/createTask.d.ts.map +1 -1
- package/build/types/task/src/errors.d.ts +27 -0
- package/build/types/task/src/errors.d.ts.map +1 -0
- package/build/types/task/src/getTask.d.ts +4 -4
- package/build/types/task/src/getTask.d.ts.map +1 -1
- package/build/types/task/src/index.d.ts +2 -1
- package/build/types/task/src/index.d.ts.map +1 -1
- package/build/types/task/src/ingress.d.ts +26 -0
- package/build/types/task/src/ingress.d.ts.map +1 -0
- package/build/types/task/src/protectTask.d.ts.map +1 -1
- package/build/types/task/src/recreateTask.d.ts +1 -1
- package/build/types/task/src/recreateTask.d.ts.map +1 -1
- package/build/types/task/src/types.d.ts +10 -10
- package/build/types/task/src/utils/getAccessToken.d.ts.map +1 -1
- package/build/types/task/src/watchTasks.d.ts +2 -0
- package/build/types/task/src/watchTasks.d.ts.map +1 -1
- package/package.json +7 -3
- package/build/chunk-b4h2we9a.js.map +0 -10
- package/build/types/helpers/src/files/RequenceFile.d.ts +0 -40
- package/build/types/helpers/src/files/RequenceFile.d.ts.map +0 -1
- package/build/types/helpers/src/files/RequenceStream.d.ts +0 -32
- package/build/types/helpers/src/files/RequenceStream.d.ts.map +0 -1
- package/build/types/helpers/src/files/index.d.ts +0 -7
- package/build/types/helpers/src/files/index.d.ts.map +0 -1
- package/build/types/helpers/src/files/mapOutput.d.ts +0 -10
- package/build/types/helpers/src/files/mapOutput.d.ts.map +0 -1
- package/build/types/helpers/src/files/types.d.ts +0 -4
- package/build/types/helpers/src/files/types.d.ts.map +0 -1
- package/build/types/helpers/src/utils/createObjectProxy.d.ts +0 -2
- package/build/types/helpers/src/utils/createObjectProxy.d.ts.map +0 -1
- package/build/types/helpers/src/utils/resolveRequenceTypes.d.ts +0 -8
- package/build/types/helpers/src/utils/resolveRequenceTypes.d.ts.map +0 -1
- /package/build/types/helpers/src/{files → utils}/fileObject.d.ts +0 -0
- /package/build/types/helpers/src/{files → utils}/isValidMimeType.d.ts +0 -0
- /package/build/types/helpers/src/{files → utils}/streamObject.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @requence/task
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c73b646: fixed bun internal typing
|
|
8
|
+
|
|
9
|
+
## 0.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- ccf4065: Prevent tasks from being stranded in the IDLE state. `finalizeTask` now dispatches
|
|
14
|
+
inside its try/catch so a publish failure deletes the task instead of leaving a
|
|
15
|
+
non-temp IDLE row, and housekeeping reaps any stranded non-temp IDLE task after 10
|
|
16
|
+
minutes. In the task SDKs, the public task-id accessor (`getTaskId()` / `task_id` /
|
|
17
|
+
`sync.id`) now resolves only after finalize succeeds — never for a task that failed
|
|
18
|
+
to finalize — while `abort()`/`protect()` keep using the prepared-phase id. The now
|
|
19
|
+
redundant `finalized()` / `sync.finalized()` was removed and the docs updated.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 8d86c93: Introduce the TypeScript 7 native compiler (Go) alongside TypeScript 6 for
|
|
24
|
+
parallel use. The `typescript` module now resolves to real v6 (6.0.2) so the full
|
|
25
|
+
JS compiler API that `@requence/typing` consumes at runtime stays available, while
|
|
26
|
+
type-checking and declaration emit run on the native v7 compiler via Microsoft's
|
|
27
|
+
`tsgo` binary (`@typescript/native-preview`) — every package's `check-types` and
|
|
28
|
+
`build-declaration` script now calls `tsgo`, so v6 remains only as the library API
|
|
29
|
+
for `@requence/typing`. Uniform model: `tsc` = v6, `tsgo` = v7. VS Code is pointed
|
|
30
|
+
at the native TS7 language server.
|
|
31
|
+
|
|
32
|
+
Also fixes the `@requence/service` and `@requence/task` declaration builds: add an
|
|
33
|
+
explicit `rootDir` so emitted `.d.ts` land at the path `exports.types` declares
|
|
34
|
+
(previously the types entry pointed at a nonexistent file), and drop a stale
|
|
35
|
+
`files` reference to a removed `helpers/src/files` path.
|
|
36
|
+
|
|
37
|
+
Note: the native compiler is invoked as `tsgo` because Microsoft's `tsc`/`tsc6`
|
|
38
|
+
wrapper packaging fails to resolve under bun.
|
|
39
|
+
|
|
40
|
+
- 37771f8: release
|
|
41
|
+
|
|
3
42
|
## 0.7.1
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ console.log(result.result) // The final output of the task
|
|
|
44
44
|
```typescript
|
|
45
45
|
const task = createTask({ taskTemplate: 'my-template', input: {} })
|
|
46
46
|
|
|
47
|
-
const taskId = await task.getTaskId() // Resolves
|
|
47
|
+
const taskId = await task.getTaskId() // Resolves once the task is validated and started
|
|
48
48
|
const taskUrl = await task.getTaskUrl() // URL to view the task in the Requence UI
|
|
49
49
|
|
|
50
50
|
await task.abort('No longer needed') // Abort the running task
|
|
@@ -56,22 +56,22 @@ const result = await task
|
|
|
56
56
|
|
|
57
57
|
The task handle is also an **AsyncIterable** — iterate over it to stream updates as the task executes.
|
|
58
58
|
|
|
59
|
-
###
|
|
59
|
+
### Confirming the Task Started (Cheap Monitoring)
|
|
60
60
|
|
|
61
|
-
By default, awaiting the result or iterating the handle starts full SSE monitoring. If you only need to confirm that the task passed input validation and started on the backend — without tracking every node — await `task.
|
|
61
|
+
By default, awaiting the result or iterating the handle starts full SSE monitoring. If you only need to confirm that the task passed input validation and started on the backend — without tracking every node — await `task.getTaskId()`:
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
64
|
const task = createTask({ taskTemplate: 'my-template', input: { /* ... */ } })
|
|
65
65
|
|
|
66
66
|
try {
|
|
67
|
-
const taskId = await task.
|
|
67
|
+
const taskId = await task.getTaskId()
|
|
68
68
|
console.log(`Task ${taskId} is running in the background`)
|
|
69
69
|
} catch (error) {
|
|
70
70
|
console.error('Validation failed:', error.message)
|
|
71
71
|
}
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
`
|
|
74
|
+
`getTaskId()` resolves with the task ID once the task has passed validation and started on the backend, or rejects with a `TaskError` if the task cannot be created (e.g. schema validation failure). It never opens the SSE stream, so it stays cheap — and it never resolves with an ID for a task that failed to start.
|
|
75
75
|
|
|
76
76
|
## Options
|
|
77
77
|
|
|
@@ -29,7 +29,37 @@ function deobfuscate(str) {
|
|
|
29
29
|
return decodedString.split(separator);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// src/errors.ts
|
|
33
|
+
var UNREACHABLE_STATUS = new Set([502, 503, 504]);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
class RequenceUnreachableError extends Error {
|
|
36
|
+
status;
|
|
37
|
+
constructor(status, options) {
|
|
38
|
+
super("The requence system is currently not reachable. Please retry later.", options);
|
|
39
|
+
this.status = status;
|
|
40
|
+
this.name = "RequenceUnreachableError";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function isUnreachableStatus(status) {
|
|
44
|
+
return UNREACHABLE_STATUS.has(status);
|
|
45
|
+
}
|
|
46
|
+
function assertReachable(response) {
|
|
47
|
+
if (isUnreachableStatus(response.status)) {
|
|
48
|
+
throw new RequenceUnreachableError(response.status);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function reachableFetch(input, init) {
|
|
52
|
+
let response;
|
|
53
|
+
try {
|
|
54
|
+
response = await fetch(input, init);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new RequenceUnreachableError(undefined, { cause: error });
|
|
57
|
+
}
|
|
58
|
+
assertReachable(response);
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { deobfuscate, RequenceUnreachableError, isUnreachableStatus, reachableFetch };
|
|
63
|
+
|
|
64
|
+
//# debugId=BB37885AF7B09DA164756E2164756E21
|
|
65
|
+
//# sourceMappingURL=chunk-f7g9gsa0.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../helpers/src/utils/obfuscate.ts", "../src/errors.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"const separator = '\\u{f6ee}'\n\nconst base65Chars =\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$'\n\nconst base65CharToIndex: Record<string, number> = {}\nfor (let i = 0; i < base65Chars.length; i++) {\n base65CharToIndex[base65Chars[i]] = i\n}\n\nexport function obfuscate(...parts: Array<string>) {\n const str = parts.join(separator)\n let binaryString = ''\n\n for (let i = 0; i < str.length; i++) {\n const charCode = str.charCodeAt(i)\n binaryString += charCode.toString(2).padStart(16, '0')\n }\n\n let encodedString = ''\n const chunkSize = 6\n let paddingCount = 0\n\n for (let i = 0; i < binaryString.length; i += chunkSize) {\n let chunk = binaryString.substring(i, i + chunkSize)\n\n if (chunk.length < chunkSize) {\n paddingCount = chunkSize - chunk.length\n chunk = chunk.padEnd(chunkSize, '0')\n }\n\n const decimalValue = parseInt(chunk, 2)\n encodedString += base65Chars[decimalValue]\n }\n\n return encodedString + paddingCount.toString()\n}\n\nexport function randomString(length: number) {\n const randomValues = new Uint8Array(length)\n crypto.getRandomValues(randomValues)\n\n let randomString = ''\n for (let i = 0; i < length; i++) {\n randomString += base65Chars[randomValues[i] % base65Chars.length]\n }\n\n return randomString\n}\n\nexport function deobfuscate(str: string) {\n const paddingCount = parseInt(str.slice(-1), 10)\n str = str.slice(0, -1)\n\n let binaryString = ''\n\n for (let i = 0; i < str.length; i++) {\n const decimalValue = base65CharToIndex[str[i]]\n const binaryChunk = decimalValue.toString(2).padStart(6, '0')\n binaryString += binaryChunk\n }\n\n if (paddingCount > 0) {\n binaryString = binaryString.slice(0, -paddingCount)\n }\n\n let decodedString = ''\n const charSize = 16\n\n for (let i = 0; i < binaryString.length; i += charSize) {\n const byte = binaryString.substring(i, i + charSize)\n if (byte.length === 16) {\n const charCode = parseInt(byte, 2)\n decodedString += String.fromCharCode(charCode)\n }\n }\n\n return decodedString.split(separator)\n}\n",
|
|
6
|
+
"// Gateway statuses an ingress/load balancer emits when no healthy backend is\n// available (maintenance window, deploy, cutover). The task endpoints never\n// return these themselves, so treating them as \"unreachable\" is unambiguous.\nconst UNREACHABLE_STATUS = new Set([502, 503, 504])\n\n/**\n * Signals that the requence system could not be reached — e.g. during a\n * maintenance window or deploy, when the ui backend is unreachable (connection\n * refused / timeout / DNS failure) or an ingress returns a gateway error\n * (502/503/504). Callers should treat this as transient and retry later.\n */\nexport class RequenceUnreachableError extends Error {\n constructor(\n public readonly status?: number,\n options?: { cause?: unknown },\n ) {\n super(\n 'The requence system is currently not reachable. Please retry later.',\n options,\n )\n this.name = 'RequenceUnreachableError'\n }\n}\n\nexport function isUnreachableStatus(status: number): boolean {\n return UNREACHABLE_STATUS.has(status)\n}\n\n/**\n * Throws a {@link RequenceUnreachableError} when the response carries a gateway\n * status indicating the system is unreachable. Call right after a fetch, before\n * inspecting `response.ok`.\n */\nexport function assertReachable(response: Response): void {\n if (isUnreachableStatus(response.status)) {\n throw new RequenceUnreachableError(response.status)\n }\n}\n\n/**\n * Wraps `fetch` so a transport-level failure (connection refused, DNS failure,\n * timeout) surfaces as a {@link RequenceUnreachableError} instead of a raw\n * TypeError, and gateway statuses (502/503/504) do the same. The returned\n * response is guaranteed not to be a gateway-error response.\n */\nexport async function reachableFetch(\n input: Parameters<typeof fetch>[0],\n init?: Parameters<typeof fetch>[1],\n): Promise<Response> {\n let response: Response\n try {\n response = await fetch(input, init)\n } catch (error) {\n throw new RequenceUnreachableError(undefined, { cause: error })\n }\n assertReachable(response)\n return response\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";AAAA,IAAM,YAAY;AAElB,IAAM,cACJ;AAEF,IAAM,oBAA4C,CAAC;AACnD,SAAS,IAAI,EAAG,IAAI,YAAY,QAAQ,KAAK;AAAA,EAC3C,kBAAkB,YAAY,MAAM;AACtC;AA0CO,SAAS,WAAW,CAAC,KAAa;AAAA,EACvC,MAAM,eAAe,SAAS,IAAI,MAAM,EAAE,GAAG,EAAE;AAAA,EAC/C,MAAM,IAAI,M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IAAI;AAAA,IAClC,OAAO,OAAO;AAAA,IACd,MAAM,IAAI,yBAAyB,WAAW,EAAE,OAAO,MAAM,CAAC;AAAA;AAAA,EAEhE,gBAAgB,QAAQ;AAAA,EACxB,OAAO;AAAA;",
|
|
9
|
+
"debugId": "BB37885AF7B09DA164756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
package/build/cli.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
RequenceUnreachableError,
|
|
4
|
+
deobfuscate,
|
|
5
|
+
reachableFetch
|
|
6
|
+
} from "./chunk-f7g9gsa0.js";
|
|
5
7
|
|
|
6
8
|
// src/cli.ts
|
|
7
9
|
import fs from "node:fs";
|
|
@@ -49,12 +51,20 @@ in your ${chalk.bold("package.json")} in ${chalk.bold("requence.accessToken")}`)
|
|
|
49
51
|
}
|
|
50
52
|
const [, accessToken, serverUrl] = parts;
|
|
51
53
|
console.info(chalk.gray("generating typescript definitions…"));
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
let response;
|
|
55
|
+
try {
|
|
56
|
+
response = await reachableFetch(serverUrl + "/task/types/typescript", {
|
|
57
|
+
method: "GET",
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: `Bearer ${accessToken}`
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
if (error instanceof RequenceUnreachableError) {
|
|
64
|
+
errorExit(error.message);
|
|
56
65
|
}
|
|
57
|
-
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
58
68
|
if (!response.ok) {
|
|
59
69
|
const error = await response.text();
|
|
60
70
|
errorExit(error);
|
|
@@ -72,5 +82,5 @@ in your ${chalk.bold("package.json")} in ${chalk.bold("requence.accessToken")}`)
|
|
|
72
82
|
console.info(chalk.green("types saved to", chalk.bold(path.relative(process.cwd(), file))));
|
|
73
83
|
}).scriptName("requence-task").help("h").demandCommand(1, 1).strict().parse();
|
|
74
84
|
|
|
75
|
-
//# debugId=
|
|
85
|
+
//# debugId=0C9810153DD07A5E64756E2164756E21
|
|
76
86
|
//# sourceMappingURL=cli.js.map
|
package/build/cli.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/cli.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"#!/usr/bin/env node\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { deobfuscate } from '@requence/helpers'\nimport chalk from 'chalk'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\n\n// Load .env automatically (Node 20.12+)\nif (typeof process.loadEnvFile === 'function') {\n try {\n process.loadEnvFile()\n } catch {\n // Ignore if .env is missing\n }\n}\n\nconst y = yargs(hideBin(process.argv))\n\nfunction errorExit(title: string, text?: string): never {\n console.error(chalk.red.bold(title + '\\n'))\n if (text) {\n console.error(chalk.red(text) + '\\n')\n }\n process.exit(1)\n}\n\ny.command(\n 'generate-types',\n 'generates typescript types',\n (yargs) =>\n yargs\n .option('access-token', {\n describe: 'access token',\n type: 'string',\n })\n .option('outfile', {\n default: 'requence-env.d.ts',\n })\n .option('outdir', {\n default: '',\n }),\n async (argv) => {\n let token =\n argv.accessToken ??\n process.env.REQUENCE_TASK_ACCESS_TOKEN ??\n process.env.REQUENCE_ACCESS_TOKEN\n\n if (!token) {\n const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'))\n token =\n pkgJson.requence?.task?.accessToken ?? pkgJson.requence?.accessToken\n }\n\n console.info() // newline\n if (!token) {\n errorExit(\n 'No access token found',\n `You can provide the access token as argument to ${chalk.bold('createTask')},\\nas environment variable ${chalk.bold('REQUENCE_ACCESS_TOKEN')} or\\nin your ${chalk.bold('package.json')} in ${chalk.bold('requence.accessToken')}`,\n )\n }\n\n const parts = deobfuscate(token)\n if (parts.length !== 3 || parts[0] !== 'api') {\n errorExit('Invalid access token')\n }\n\n const [, accessToken, serverUrl] = parts\n\n console.info(chalk.gray('generating typescript definitions…'))\n
|
|
5
|
+
"#!/usr/bin/env node\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { deobfuscate } from '@requence/helpers'\nimport chalk from 'chalk'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\n\nimport { RequenceUnreachableError, reachableFetch } from './errors.ts'\n\n// Load .env automatically (Node 20.12+)\nif (typeof process.loadEnvFile === 'function') {\n try {\n process.loadEnvFile()\n } catch {\n // Ignore if .env is missing\n }\n}\n\nconst y = yargs(hideBin(process.argv))\n\nfunction errorExit(title: string, text?: string): never {\n console.error(chalk.red.bold(title + '\\n'))\n if (text) {\n console.error(chalk.red(text) + '\\n')\n }\n process.exit(1)\n}\n\ny.command(\n 'generate-types',\n 'generates typescript types',\n (yargs) =>\n yargs\n .option('access-token', {\n describe: 'access token',\n type: 'string',\n })\n .option('outfile', {\n default: 'requence-env.d.ts',\n })\n .option('outdir', {\n default: '',\n }),\n async (argv) => {\n let token =\n argv.accessToken ??\n process.env.REQUENCE_TASK_ACCESS_TOKEN ??\n process.env.REQUENCE_ACCESS_TOKEN\n\n if (!token) {\n const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'))\n token =\n pkgJson.requence?.task?.accessToken ?? pkgJson.requence?.accessToken\n }\n\n console.info() // newline\n if (!token) {\n errorExit(\n 'No access token found',\n `You can provide the access token as argument to ${chalk.bold('createTask')},\\nas environment variable ${chalk.bold('REQUENCE_ACCESS_TOKEN')} or\\nin your ${chalk.bold('package.json')} in ${chalk.bold('requence.accessToken')}`,\n )\n }\n\n const parts = deobfuscate(token)\n if (parts.length !== 3 || parts[0] !== 'api') {\n errorExit('Invalid access token')\n }\n\n const [, accessToken, serverUrl] = parts\n\n console.info(chalk.gray('generating typescript definitions…'))\n let response: Response\n try {\n response = await reachableFetch(serverUrl + '/task/types/typescript', {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n })\n } catch (error) {\n if (error instanceof RequenceUnreachableError) {\n errorExit(error.message)\n }\n throw error\n }\n\n if (!response.ok) {\n const error = await response.text()\n errorExit(error)\n }\n\n const text = await response.text()\n\n const data = [\n '/* eslint-disable */',\n '/* oxlint-disable */',\n '/* prettier-ignore */',\n text,\n ].join('\\n')\n\n const file = path.join(argv.outdir || process.cwd(), argv.outfile)\n fs.writeFileSync(file, data)\n\n console.info(\n chalk.green(\n 'types saved to',\n chalk.bold(path.relative(process.cwd(), file)),\n ),\n )\n },\n)\n .scriptName('requence-task')\n .help('h')\n .demandCommand(1, 1)\n .strict()\n .parse()\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;AAEA;AACA;AAGA;AACA;AACA;AAKA,IAAI,OAAO,QAAQ,gBAAgB,YAAY;AAAA,EAC7C,IAAI;AAAA,IACF,QAAQ,YAAY;AAAA,IACpB,MAAM;AAGV;AAEA,IAAM,IAAI,MAAM,QAAQ,QAAQ,IAAI,CAAC;AAErC,SAAS,SAAS,CAAC,OAAe,MAAsB;AAAA,EACtD,QAAQ,MAAM,MAAM,IAAI,KAAK,QAAQ;AAAA,CAAI,CAAC;AAAA,EAC1C,IAAI,MAAM;AAAA,IACR,QAAQ,MAAM,MAAM,IAAI,IAAI,IAAI;AAAA,CAAI;AAAA,EACtC;AAAA,EACA,QAAQ,KAAK,CAAC;AAAA;AAGhB,EAAE,QACA,kBACA,8BACA,CAAC,WACC,OACG,OAAO,gBAAgB;AAAA,EACtB,UAAU;AAAA,EACV,MAAM;AACR,CAAC,EACA,OAAO,WAAW;AAAA,EACjB,SAAS;AACX,CAAC,EACA,OAAO,UAAU;AAAA,EAChB,SAAS;AACX,CAAC,GACL,OAAO,SAAS;AAAA,EACd,IAAI,QACF,KAAK,eACL,QAAQ,IAAI,8BACZ,QAAQ,IAAI;AAAA,EAEd,IAA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