@requence/service 0.8.2-edge.1151 → 0.8.2-edge.1155
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/README.md +258 -0
- package/build/{chunk-974rc2jy.js → chunk-gpyt51xn.js} +164 -3
- package/build/{chunk-974rc2jy.js.map → chunk-gpyt51xn.js.map} +7 -4
- package/build/cli.js +17 -30
- package/build/cli.js.map +3 -3
- package/build/index.js +538 -94
- package/build/index.js.map +18 -10
- package/build/types/helpers/src/index.d.ts +5 -0
- package/build/types/helpers/src/index.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/NodeTree.d.ts +29 -0
- package/build/types/helpers/src/protocol/NodeTree.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/command.d.ts +859 -7
- package/build/types/helpers/src/protocol/command.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/index.d.ts +1 -0
- package/build/types/helpers/src/protocol/index.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/sliceTreeList.d.ts +81 -0
- package/build/types/helpers/src/protocol/sliceTreeList.d.ts.map +1 -0
- package/build/types/helpers/src/protocol/treeNodes.d.ts +577 -2
- package/build/types/helpers/src/protocol/treeNodes.d.ts.map +1 -1
- package/build/types/helpers/src/protocol/update.d.ts +128 -10
- package/build/types/helpers/src/protocol/update.d.ts.map +1 -1
- package/build/types/helpers/src/utils/amqpPublishRetry.d.ts +113 -18
- package/build/types/helpers/src/utils/amqpPublishRetry.d.ts.map +1 -1
- package/build/types/helpers/src/utils/matchSchema.d.ts +14 -0
- package/build/types/helpers/src/utils/matchSchema.d.ts.map +1 -1
- package/build/types/helpers/src/utils/serviceRender.d.ts +73 -0
- package/build/types/helpers/src/utils/serviceRender.d.ts.map +1 -0
- package/build/types/helpers/src/utils/sliceClock.d.ts +61 -0
- package/build/types/helpers/src/utils/sliceClock.d.ts.map +1 -0
- package/build/types/helpers/src/utils/surfaceComponent.d.ts +116 -0
- package/build/types/helpers/src/utils/surfaceComponent.d.ts.map +1 -0
- package/build/types/helpers/src/utils/surfaceHandler.d.ts +171 -0
- package/build/types/helpers/src/utils/surfaceHandler.d.ts.map +1 -0
- package/build/types/helpers/src/utils/uiRebuild.d.ts +48 -0
- package/build/types/helpers/src/utils/uiRebuild.d.ts.map +1 -0
- package/build/types/service/src/boundary.d.ts +14 -1
- package/build/types/service/src/boundary.d.ts.map +1 -1
- package/build/types/service/src/createAmqpConnection.d.ts +55 -0
- package/build/types/service/src/createAmqpConnection.d.ts.map +1 -1
- package/build/types/service/src/errors.d.ts +11 -0
- package/build/types/service/src/errors.d.ts.map +1 -1
- package/build/types/service/src/helpers.d.ts +68 -0
- package/build/types/service/src/helpers.d.ts.map +1 -1
- package/build/types/service/src/index.d.ts +2 -0
- package/build/types/service/src/index.d.ts.map +1 -1
- package/build/types/service/src/surfaceHandler.d.ts +36 -0
- package/build/types/service/src/surfaceHandler.d.ts.map +1 -0
- package/build/types/service/src/surfaceUi.d.ts +141 -0
- package/build/types/service/src/surfaceUi.d.ts.map +1 -0
- package/build/types/service/src/transformer.d.ts +14 -0
- package/build/types/service/src/transformer.d.ts.map +1 -1
- package/build/types/service/src/ui.d.ts +247 -0
- package/build/types/service/src/ui.d.ts.map +1 -0
- package/build/types/service/src/uiWatch.d.ts +68 -0
- package/build/types/service/src/uiWatch.d.ts.map +1 -0
- package/package.json +10 -4
package/build/cli.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import {
|
|
3
3
|
RequenceUnreachableError,
|
|
4
4
|
deobfuscate,
|
|
5
|
-
reachableFetch
|
|
6
|
-
|
|
5
|
+
reachableFetch,
|
|
6
|
+
simple_default
|
|
7
|
+
} from "./chunk-gpyt51xn.js";
|
|
7
8
|
|
|
8
9
|
// src/cli.ts
|
|
9
10
|
import fs from "node:fs";
|
|
10
11
|
import path from "node:path";
|
|
11
|
-
import chalk from "chalk";
|
|
12
12
|
import { createEventSource } from "eventsource-client";
|
|
13
13
|
import yargs from "yargs";
|
|
14
14
|
import { hideBin } from "yargs/helpers";
|
|
@@ -19,19 +19,10 @@ if (typeof process.loadEnvFile === "function") {
|
|
|
19
19
|
} catch {}
|
|
20
20
|
}
|
|
21
21
|
var y = yargs(hideBin(process.argv));
|
|
22
|
-
var colors = {
|
|
23
|
-
red: chalk.hex("#ef4444"),
|
|
24
|
-
green: chalk.hex("#22c55e"),
|
|
25
|
-
yellow: chalk.hex("#eab308"),
|
|
26
|
-
orange: chalk.hex("#f97316"),
|
|
27
|
-
zinc: chalk.hex("#71717a")
|
|
28
|
-
};
|
|
29
22
|
function errorExit(title, text) {
|
|
30
|
-
|
|
31
|
-
`));
|
|
23
|
+
simple_default.error(title);
|
|
32
24
|
if (text) {
|
|
33
|
-
|
|
34
|
-
`);
|
|
25
|
+
simple_default.error(text);
|
|
35
26
|
}
|
|
36
27
|
process.exit(1);
|
|
37
28
|
}
|
|
@@ -42,8 +33,7 @@ function loadPkgJson() {
|
|
|
42
33
|
}
|
|
43
34
|
return pkgJson;
|
|
44
35
|
}
|
|
45
|
-
async function fetchTypes(url, headers, targetFile, clear = false
|
|
46
|
-
const timestamp = () => colors.zinc(new Date().toLocaleTimeString("en-GB", { hour12: false }));
|
|
36
|
+
async function fetchTypes(url, headers, targetFile, clear = false) {
|
|
47
37
|
let response;
|
|
48
38
|
try {
|
|
49
39
|
response = await reachableFetch(url, {
|
|
@@ -79,10 +69,11 @@ ${text}`;
|
|
|
79
69
|
if (clear) {
|
|
80
70
|
console.clear();
|
|
81
71
|
}
|
|
72
|
+
const target = path.relative(process.cwd(), targetFile);
|
|
82
73
|
if (branchName) {
|
|
83
|
-
|
|
74
|
+
simple_default.info(`types for branch |${branchName}| saved to |${target}|`);
|
|
84
75
|
} else {
|
|
85
|
-
|
|
76
|
+
simple_default.info(`types saved to |${target}|`);
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
79
|
y.command("generate-types", "generates typescript types", (yargs2) => yargs2.option("access-token", {
|
|
@@ -111,9 +102,9 @@ y.command("generate-types", "generates typescript types", (yargs2) => yargs2.opt
|
|
|
111
102
|
console.info();
|
|
112
103
|
}
|
|
113
104
|
if (!token) {
|
|
114
|
-
errorExit("No access token found", `You can provide the access token as argument to
|
|
115
|
-
as environment variable
|
|
116
|
-
in your
|
|
105
|
+
errorExit("No access token found", `You can provide the access token as argument to |requence-service|,
|
|
106
|
+
as environment variable |REQUENCE_ACCESS_TOKEN| / |REQUENCE_SERVICE_ACCESS_TOKEN| or
|
|
107
|
+
in your |package.json| in |requence.accessToken| / |requence.service.accessToken|`);
|
|
117
108
|
}
|
|
118
109
|
const parts = deobfuscate(token);
|
|
119
110
|
if (parts.length !== 3 || parts[0] !== "service") {
|
|
@@ -145,7 +136,7 @@ in your ${chalk.bold("package.json")} in ${chalk.bold("requence.accessToken")} /
|
|
|
145
136
|
if (argv.clear) {
|
|
146
137
|
console.clear();
|
|
147
138
|
}
|
|
148
|
-
|
|
139
|
+
simple_default.info("Watching for type changes…");
|
|
149
140
|
let lastWrite = Date.now();
|
|
150
141
|
const timeSchema = z.coerce.number().int().positive();
|
|
151
142
|
createEventSource({
|
|
@@ -161,16 +152,12 @@ in your ${chalk.bold("package.json")} in ${chalk.bold("requence.accessToken")} /
|
|
|
161
152
|
if (argv.clear) {
|
|
162
153
|
console.clear();
|
|
163
154
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
await fetchTypes(serverUrl + "/service/types/typescript", headers, path.join(argv.outdir || process.cwd(), argv.outfile), argv.clear, true);
|
|
168
|
-
console.info(colors.orange.bold(`${argv.clear ? `
|
|
169
|
-
|
|
170
|
-
` : ""}Watching for type changes…`));
|
|
155
|
+
simple_default.info("Regenerating types…");
|
|
156
|
+
await fetchTypes(serverUrl + "/service/types/typescript", headers, path.join(argv.outdir || process.cwd(), argv.outfile), argv.clear);
|
|
157
|
+
simple_default.info("Watching for type changes…");
|
|
171
158
|
}
|
|
172
159
|
});
|
|
173
160
|
}).scriptName("requence-service").help("h").demandCommand(1, 1).strict().parse();
|
|
174
161
|
|
|
175
|
-
//# debugId=
|
|
162
|
+
//# debugId=E55977E6C49870B264756E2164756E21
|
|
176
163
|
//# 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
|
|
5
|
+
"#!/usr/bin/env node\n\nimport fs from 'node:fs'\nimport path from 'node:path'\n\nimport { deobfuscate } from '@requence/helpers'\nimport logger from '@requence/logger/simple'\nimport { createEventSource } from 'eventsource-client'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\nimport { z } from 'zod/v4'\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 logger.error(title)\n if (text) {\n logger.error(text)\n }\n process.exit(1)\n}\n\nlet pkgJson: any | null\nfunction loadPkgJson() {\n if (!pkgJson) {\n pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'))\n }\n return pkgJson\n}\n\n// Every line the logger writes carries a timestamp, so the caller no longer\n// has to ask for one in watch mode.\nasync function fetchTypes(\n url: string,\n headers: HeadersInit,\n targetFile: string,\n clear = false,\n) {\n let response: Response\n try {\n response = await reachableFetch(url, {\n method: 'GET',\n headers,\n })\n } catch (error) {\n if (error instanceof RequenceUnreachableError) {\n errorExit(error.message)\n }\n throw error\n }\n\n const branchName = response.headers.get('x-branch-name')\n const text = await response.text()\n\n if (!response.ok) {\n errorExit(text)\n }\n\n let header =\n '// Generated by requence-service CLI — DO NOT EDIT.\\n// Changes will be overwritten.\\n\\n'\n\n if (branchName) {\n header += `// !!! types for branch \"${branchName}\" !!!\\n\\n`\n }\n const data = `${header}/* eslint-disable */\\n/* oxlint-disable */\\n/* prettier-ignore */\\n\\n${text}`\n\n fs.writeFileSync(targetFile, data)\n\n if (clear) {\n console.clear()\n }\n\n const target = path.relative(process.cwd(), targetFile)\n\n if (branchName) {\n logger.info(`types for branch |${branchName}| saved to |${target}|`)\n } else {\n logger.info(`types saved to |${target}|`)\n }\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('dev-token', {\n description: 'dev token',\n type: 'string',\n })\n .option('outfile', {\n default: 'requence-env.d.ts',\n })\n .option('outdir', {\n default: '',\n })\n .option('watch', {\n type: 'boolean',\n })\n .option('clear', {\n description:\n 'clear the terminal on watch updates (use --no-clear to disable)',\n type: 'boolean',\n default: true,\n }),\n async (argv) => {\n let token =\n argv.accessToken ??\n process.env.REQUENCE_SERVICE_ACCESS_TOKEN ??\n process.env.REQUENCE_ACCESS_TOKEN\n\n if (!token) {\n const pkgJson = loadPkgJson()\n token =\n pkgJson.requence?.service?.accessToken ?? pkgJson.requence?.accessToken\n }\n\n if (argv.clear) {\n console.info() // newline\n }\n if (!token) {\n errorExit(\n 'No access token found',\n 'You can provide the access token as argument to |requence-service|,\\nas environment variable |REQUENCE_ACCESS_TOKEN| / |REQUENCE_SERVICE_ACCESS_TOKEN| or\\nin your |package.json| in |requence.accessToken| / |requence.service.accessToken|',\n )\n }\n\n const parts = deobfuscate(token)\n if (parts.length !== 3 || parts[0] !== 'service') {\n errorExit('Invalid service key')\n }\n\n const [, connectionString, serverUrl] = parts\n const headers: HeadersInit = {\n Authorization: `Bearer ${connectionString}`,\n }\n let devToken =\n argv.devToken ??\n process.env.REQUENCE_SERVICE_DEV_TOKEN ??\n process.env.REQUENCE_DEV_TOKEN\n\n if (!devToken) {\n const pkgJson = loadPkgJson()\n devToken =\n pkgJson.requence?.service?.devToken ?? pkgJson.requence?.devToken\n }\n\n if (devToken) {\n const devParts = deobfuscate(devToken)\n if (devParts[0] !== 'api') {\n throw new Error(\n 'invalid dev token: please provide a personal access token',\n )\n }\n if (devParts[2] !== parts[2]) {\n throw new Error(\n 'invalid dev token: access token and dev token belong to different requence instances',\n )\n }\n\n headers['x-dev-authorization'] = devParts[1]\n }\n\n await fetchTypes(\n serverUrl + '/service/types/typescript',\n headers,\n path.join(argv.outdir || process.cwd(), argv.outfile),\n )\n\n if (!argv.watch) {\n return\n }\n\n if (argv.clear) {\n console.clear()\n }\n logger.info('Watching for type changes…')\n let lastWrite = Date.now()\n const timeSchema = z.coerce.number().int().positive()\n createEventSource({\n method: 'GET',\n url: serverUrl + '/service/watch',\n headers,\n async onMessage({ data }) {\n const timeResult = timeSchema.safeParse(data)\n if (!timeResult.success || timeResult.data < lastWrite) {\n return\n }\n lastWrite = timeResult.data\n if (argv.clear) {\n console.clear()\n }\n logger.info('Regenerating types…')\n\n await fetchTypes(\n serverUrl + '/service/types/typescript',\n headers,\n path.join(argv.outdir || process.cwd(), argv.outfile),\n argv.clear,\n )\n logger.info('Watching for type changes…')\n },\n })\n },\n)\n .scriptName('requence-service')\n .help('h')\n .demandCommand(1, 1)\n .strict()\n .parse()\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;AAEA;AACA;AAIA;AACA;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,eAAO,MAAM,KAAK;AAAA,EAClB,IAAI,MAAM;AAAA,IACR,eAAO,MAAM,IAAI;AAAA,EACnB;AAAA,EACA,QAAQ,K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