@builtbyfriends/realtime-cli 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +12 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +233 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -4
- package/src/bin.ts +15 -0
- package/src/index.ts +225 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026-present, Built By Friends Company
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @builtbyfriends/realtime-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command line client for an realtime Worker, driven by its manifest.
|
|
4
|
+
|
|
5
|
+
It's part of [Realtime](https://github.com/builtbyfriends/realtime), a procedure builder for Cloudflare Workers.
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @builtbyfriends/realtime-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
MIT license.
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from './index.js';
|
|
3
|
+
run({
|
|
4
|
+
argv: process.argv.slice(2),
|
|
5
|
+
env: process.env,
|
|
6
|
+
stdout: (s) => process.stdout.write(s),
|
|
7
|
+
stderr: (s) => process.stderr.write(s),
|
|
8
|
+
}).then((code) => process.exit(code), (e) => {
|
|
9
|
+
process.stderr.write(`realtime: ${e.message}\n`);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,GAAG,CAAC;IACF,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,GAAG,EAAE,OAAO,CAAC,GAAG;IAChB,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;CACvC,CAAC,CAAC,IAAI,CACL,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,CAAC,EAAE,EAAE;IACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAc,CAAW,CAAC,OAAO,IAAI,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Io = {
|
|
2
|
+
argv: string[];
|
|
3
|
+
env: Record<string, string | undefined>;
|
|
4
|
+
fetch?: typeof fetch;
|
|
5
|
+
stdout: (s: string) => void;
|
|
6
|
+
stderr: (s: string) => void;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Runs the CLI and returns the exit code: 0 on success, 1 when the call failed, 2 for usage errors.
|
|
10
|
+
* The CLI never imports handlers. It downloads the manifest and calls the Worker over HTTP.
|
|
11
|
+
*/
|
|
12
|
+
export declare function run(io: Io): Promise<number>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,KAAK,EAAE,GAAG;IACR,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B,CAAC;AAwIF;;;GAGG;AACH,wBAAsB,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA4EjD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
const kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/_/g, '-').toLowerCase();
|
|
2
|
+
function typeOf(p) {
|
|
3
|
+
const t = Array.isArray(p.type) ? p.type.find((x) => x !== 'null') : p.type;
|
|
4
|
+
if (t)
|
|
5
|
+
return t;
|
|
6
|
+
if (p.enum?.every((v) => typeof v === 'string'))
|
|
7
|
+
return 'string';
|
|
8
|
+
if (p.anyOf) {
|
|
9
|
+
const types = p.anyOf.map(typeOf).filter((x) => x !== 'null');
|
|
10
|
+
if (types.length === 1)
|
|
11
|
+
return types[0];
|
|
12
|
+
}
|
|
13
|
+
return 'json';
|
|
14
|
+
}
|
|
15
|
+
class UsageError extends Error {
|
|
16
|
+
}
|
|
17
|
+
function parseArgs(argv) {
|
|
18
|
+
const words = [];
|
|
19
|
+
const flags = [];
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
const a = argv[i];
|
|
22
|
+
if (a === '--') {
|
|
23
|
+
words.push(...argv.slice(i + 1));
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (a === '-h')
|
|
27
|
+
flags.push(['help', true]);
|
|
28
|
+
else if (a.startsWith('--')) {
|
|
29
|
+
const eq = a.indexOf('=');
|
|
30
|
+
if (eq > 0)
|
|
31
|
+
flags.push([a.slice(2, eq), a.slice(eq + 1)]);
|
|
32
|
+
else {
|
|
33
|
+
const next = argv[i + 1];
|
|
34
|
+
if (next !== undefined && !next.startsWith('--')) {
|
|
35
|
+
flags.push([a.slice(2), next]);
|
|
36
|
+
i++;
|
|
37
|
+
}
|
|
38
|
+
else
|
|
39
|
+
flags.push([a.slice(2), true]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
words.push(a);
|
|
44
|
+
}
|
|
45
|
+
return { words, flags };
|
|
46
|
+
}
|
|
47
|
+
function coerce(name, prop, raw) {
|
|
48
|
+
const t = typeOf(prop);
|
|
49
|
+
if (t === 'boolean') {
|
|
50
|
+
if (raw === true || raw === 'true')
|
|
51
|
+
return true;
|
|
52
|
+
if (raw === 'false')
|
|
53
|
+
return false;
|
|
54
|
+
throw new UsageError(`--${name} takes true or false`);
|
|
55
|
+
}
|
|
56
|
+
if (raw === true)
|
|
57
|
+
throw new UsageError(`--${name} needs a value`);
|
|
58
|
+
if (t === 'number' || t === 'integer') {
|
|
59
|
+
const n = Number(raw);
|
|
60
|
+
if (!Number.isFinite(n) || (t === 'integer' && !Number.isInteger(n)))
|
|
61
|
+
throw new UsageError(`--${name} must be ${t === 'integer' ? 'an integer' : 'a number'}`);
|
|
62
|
+
return n;
|
|
63
|
+
}
|
|
64
|
+
if (t === 'string') {
|
|
65
|
+
if (prop.enum && !prop.enum.includes(raw))
|
|
66
|
+
throw new UsageError(`--${name} must be one of: ${prop.enum.join(', ')}`);
|
|
67
|
+
return raw;
|
|
68
|
+
}
|
|
69
|
+
if (t === 'array' && !raw.trim().startsWith('['))
|
|
70
|
+
return [coerce(name, prop.items ?? {}, raw)];
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(raw);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
throw new UsageError(`--${name} must be JSON`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function inputFromFlags(entry, flags) {
|
|
79
|
+
const schema = (entry.input ?? {});
|
|
80
|
+
const props = schema.properties ?? {};
|
|
81
|
+
const byFlag = new Map(Object.keys(props).map((k) => [kebab(k), k]));
|
|
82
|
+
let input = {};
|
|
83
|
+
for (const [flag, raw] of flags) {
|
|
84
|
+
if (flag === 'json') {
|
|
85
|
+
if (raw === true)
|
|
86
|
+
throw new UsageError('--json needs a value');
|
|
87
|
+
try {
|
|
88
|
+
input = { ...input, ...JSON.parse(raw) };
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
throw new UsageError('--json must be a JSON object');
|
|
92
|
+
}
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const negated = flag.startsWith('no-') && byFlag.has(flag.slice(3));
|
|
96
|
+
const key = byFlag.get(negated ? flag.slice(3) : flag);
|
|
97
|
+
if (!key) {
|
|
98
|
+
const known = [...byFlag.keys()].map((f) => `--${f}`).join(', ') || '(none)';
|
|
99
|
+
throw new UsageError(`unknown flag --${flag} for "${entry.cli.command}". Flags: ${known}`);
|
|
100
|
+
}
|
|
101
|
+
const prop = props[key];
|
|
102
|
+
if (negated) {
|
|
103
|
+
if (typeOf(prop) !== 'boolean')
|
|
104
|
+
throw new UsageError(`--${flag} only works for true/false flags`);
|
|
105
|
+
input[key] = false;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const value = coerce(flag, prop, raw);
|
|
109
|
+
input[key] = typeOf(prop) === 'array' && Array.isArray(input[key]) && !(typeof raw === 'string' && raw.trim().startsWith('['))
|
|
110
|
+
? [...input[key], ...value]
|
|
111
|
+
: value;
|
|
112
|
+
}
|
|
113
|
+
const missing = (schema.required ?? []).filter((k) => input[k] === undefined);
|
|
114
|
+
if (missing.length)
|
|
115
|
+
throw new UsageError(`missing ${missing.map((k) => `--${kebab(k)}`).join(', ')}`);
|
|
116
|
+
return entry.input ? input : undefined;
|
|
117
|
+
}
|
|
118
|
+
function commandHelp(entry) {
|
|
119
|
+
const schema = (entry.input ?? {});
|
|
120
|
+
const lines = [`${entry.cli.command}: ${entry.cli.description}`, ''];
|
|
121
|
+
const props = Object.entries(schema.properties ?? {});
|
|
122
|
+
if (!props.length)
|
|
123
|
+
lines.push(' (no flags)');
|
|
124
|
+
for (const [k, p] of props) {
|
|
125
|
+
const req = schema.required?.includes(k) ? ' (required)' : '';
|
|
126
|
+
const t = p.enum ? p.enum.join('|') : typeOf(p);
|
|
127
|
+
lines.push(` --${kebab(k)} <${t}>${req}${p.description ? ` ${p.description}` : ''}`);
|
|
128
|
+
}
|
|
129
|
+
lines.push(' --json <object> pass the whole input as JSON');
|
|
130
|
+
const errs = Object.entries(entry.errors);
|
|
131
|
+
if (errs.length)
|
|
132
|
+
lines.push('', 'Errors:', ...errs.map(([c, s]) => ` ${c} (${s.status}) ${s.message}`));
|
|
133
|
+
return lines.join('\n') + '\n';
|
|
134
|
+
}
|
|
135
|
+
function listHelp(manifest) {
|
|
136
|
+
const cmds = manifest.procedures.map((p) => p.cli).sort((a, b) => a.command.localeCompare(b.command));
|
|
137
|
+
const width = Math.max(0, ...cmds.map((c) => c.command.length));
|
|
138
|
+
return [
|
|
139
|
+
'Usage: realtime [--url URL] [--token TOKEN] <command> [flags]',
|
|
140
|
+
' REALTIME_URL and REALTIME_TOKEN are read from the environment.',
|
|
141
|
+
'',
|
|
142
|
+
'Commands:',
|
|
143
|
+
...cmds.map((c) => ` ${c.command.padEnd(width)} ${c.description}`),
|
|
144
|
+
'',
|
|
145
|
+
'Run "realtime <command> --help" for its flags.',
|
|
146
|
+
].join('\n') + '\n';
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Runs the CLI and returns the exit code: 0 on success, 1 when the call failed, 2 for usage errors.
|
|
150
|
+
* The CLI never imports handlers. It downloads the manifest and calls the Worker over HTTP.
|
|
151
|
+
*/
|
|
152
|
+
export async function run(io) {
|
|
153
|
+
const f = io.fetch ?? fetch;
|
|
154
|
+
const { words, flags } = parseArgs(io.argv);
|
|
155
|
+
const take = (name) => {
|
|
156
|
+
const i = flags.findIndex(([k]) => k === name);
|
|
157
|
+
if (i < 0)
|
|
158
|
+
return undefined;
|
|
159
|
+
const [, v] = flags.splice(i, 1)[0];
|
|
160
|
+
return v;
|
|
161
|
+
};
|
|
162
|
+
const url = take('url') ?? io.env.REALTIME_URL;
|
|
163
|
+
const token = take('token') ?? io.env.REALTIME_TOKEN;
|
|
164
|
+
const basePath = io.env.REALTIME_BASE_PATH ?? '/rpc';
|
|
165
|
+
const help = take('help') !== undefined || words[0] === 'help';
|
|
166
|
+
if (words[0] === 'help')
|
|
167
|
+
words.shift();
|
|
168
|
+
if (!url) {
|
|
169
|
+
io.stderr('realtime: set --url or REALTIME_URL to your Worker, e.g. https://api.example.com\n');
|
|
170
|
+
return 2;
|
|
171
|
+
}
|
|
172
|
+
const origin = url.replace(/\/$/, '');
|
|
173
|
+
let manifest;
|
|
174
|
+
try {
|
|
175
|
+
const res = await f(`${origin}${basePath}/manifest.json`);
|
|
176
|
+
if (!res.ok)
|
|
177
|
+
throw new Error(`HTTP ${res.status}`);
|
|
178
|
+
manifest = (await res.json());
|
|
179
|
+
}
|
|
180
|
+
catch (e) {
|
|
181
|
+
io.stderr(`realtime: could not load ${origin}${basePath}/manifest.json: ${e.message}\n`);
|
|
182
|
+
return 1;
|
|
183
|
+
}
|
|
184
|
+
const entry = manifest.procedures
|
|
185
|
+
.filter((p) => {
|
|
186
|
+
const parts = p.cli.command.split(' ');
|
|
187
|
+
return parts.every((w, i) => words[i] === w);
|
|
188
|
+
})
|
|
189
|
+
.sort((a, b) => b.cli.command.length - a.cli.command.length)[0];
|
|
190
|
+
if (!entry) {
|
|
191
|
+
if (words.length && !help)
|
|
192
|
+
io.stderr(`realtime: unknown command "${words.join(' ')}"\n\n`);
|
|
193
|
+
(words.length && !help ? io.stderr : io.stdout)(listHelp(manifest));
|
|
194
|
+
return words.length && !help ? 2 : 0;
|
|
195
|
+
}
|
|
196
|
+
const extra = words.slice(entry.cli.command.split(' ').length);
|
|
197
|
+
if (help) {
|
|
198
|
+
io.stdout(commandHelp(entry));
|
|
199
|
+
return 0;
|
|
200
|
+
}
|
|
201
|
+
if (extra.length) {
|
|
202
|
+
io.stderr(`realtime: unexpected argument "${extra[0]}". Pass values as flags.\n\n${commandHelp(entry)}`);
|
|
203
|
+
return 2;
|
|
204
|
+
}
|
|
205
|
+
let input;
|
|
206
|
+
try {
|
|
207
|
+
input = inputFromFlags(entry, flags);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
if (!(e instanceof UsageError))
|
|
211
|
+
throw e;
|
|
212
|
+
io.stderr(`realtime: ${e.message}\n\n${commandHelp(entry)}`);
|
|
213
|
+
return 2;
|
|
214
|
+
}
|
|
215
|
+
const res = await f(`${origin}${entry.path}`, {
|
|
216
|
+
method: 'POST',
|
|
217
|
+
headers: { 'content-type': 'application/json', 'x-realtime-surface': 'cli', ...(token ? { authorization: `Bearer ${token}` } : {}) },
|
|
218
|
+
body: input === undefined ? '' : JSON.stringify(input),
|
|
219
|
+
});
|
|
220
|
+
const body = (await res.json().catch(() => ({})));
|
|
221
|
+
if (res.ok && !body.error) {
|
|
222
|
+
io.stdout(JSON.stringify(body.data, null, 2) + '\n');
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
const err = body.error ?? { code: 'INTERNAL', message: `HTTP ${res.status}` };
|
|
226
|
+
io.stderr(`error ${err.code}: ${err.message}\n`);
|
|
227
|
+
for (const i of err.issues ?? [])
|
|
228
|
+
io.stderr(` ${i.path ? `--${kebab(i.path.split('.')[0])}` : 'input'}: ${i.message}\n`);
|
|
229
|
+
if (res.status === 401)
|
|
230
|
+
io.stderr('Set --token or REALTIME_TOKEN to an API token.\n');
|
|
231
|
+
return 1;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAYA,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAEvG,SAAS,MAAM,CAAC,CAAO;IACrB,MAAM,CAAC,GAAG,KAAK,CAAC,OA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tbyfriends/realtime-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Command line client for an realtime Worker, driven by its manifest",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"realtime": "./dist/bin.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@builtbyfriends/realtime": "0.1.1"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/builtbyfriends/realtime.git",
|
|
29
|
+
"directory": "typescript/packages/cli"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/builtbyfriends/realtime#readme",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepack": "cp ../../../LICENSE LICENSE"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/bin.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { run } from './index.js';
|
|
3
|
+
|
|
4
|
+
run({
|
|
5
|
+
argv: process.argv.slice(2),
|
|
6
|
+
env: process.env,
|
|
7
|
+
stdout: (s) => process.stdout.write(s),
|
|
8
|
+
stderr: (s) => process.stderr.write(s),
|
|
9
|
+
}).then(
|
|
10
|
+
(code) => process.exit(code),
|
|
11
|
+
(e) => {
|
|
12
|
+
process.stderr.write(`realtime: ${(e as Error).message}\n`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
},
|
|
15
|
+
);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import type { Manifest, ManifestEntry } from '@builtbyfriends/realtime';
|
|
2
|
+
|
|
3
|
+
type Io = {
|
|
4
|
+
argv: string[];
|
|
5
|
+
env: Record<string, string | undefined>;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
stdout: (s: string) => void;
|
|
8
|
+
stderr: (s: string) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Prop = { type?: string | string[]; description?: string; enum?: unknown[]; items?: Prop; anyOf?: Prop[] };
|
|
12
|
+
|
|
13
|
+
const kebab = (s: string) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/_/g, '-').toLowerCase();
|
|
14
|
+
|
|
15
|
+
function typeOf(p: Prop): string {
|
|
16
|
+
const t = Array.isArray(p.type) ? p.type.find((x) => x !== 'null') : p.type;
|
|
17
|
+
if (t) return t;
|
|
18
|
+
if (p.enum?.every((v) => typeof v === 'string')) return 'string';
|
|
19
|
+
if (p.anyOf) {
|
|
20
|
+
const types = p.anyOf.map(typeOf).filter((x) => x !== 'null');
|
|
21
|
+
if (types.length === 1) return types[0]!;
|
|
22
|
+
}
|
|
23
|
+
return 'json';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class UsageError extends Error {}
|
|
27
|
+
|
|
28
|
+
function parseArgs(argv: string[]) {
|
|
29
|
+
const words: string[] = [];
|
|
30
|
+
const flags: [string, string | true][] = [];
|
|
31
|
+
for (let i = 0; i < argv.length; i++) {
|
|
32
|
+
const a = argv[i]!;
|
|
33
|
+
if (a === '--') {
|
|
34
|
+
words.push(...argv.slice(i + 1));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
if (a === '-h') flags.push(['help', true]);
|
|
38
|
+
else if (a.startsWith('--')) {
|
|
39
|
+
const eq = a.indexOf('=');
|
|
40
|
+
if (eq > 0) flags.push([a.slice(2, eq), a.slice(eq + 1)]);
|
|
41
|
+
else {
|
|
42
|
+
const next = argv[i + 1];
|
|
43
|
+
if (next !== undefined && !next.startsWith('--')) {
|
|
44
|
+
flags.push([a.slice(2), next]);
|
|
45
|
+
i++;
|
|
46
|
+
} else flags.push([a.slice(2), true]);
|
|
47
|
+
}
|
|
48
|
+
} else words.push(a);
|
|
49
|
+
}
|
|
50
|
+
return { words, flags };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function coerce(name: string, prop: Prop, raw: string | true): unknown {
|
|
54
|
+
const t = typeOf(prop);
|
|
55
|
+
if (t === 'boolean') {
|
|
56
|
+
if (raw === true || raw === 'true') return true;
|
|
57
|
+
if (raw === 'false') return false;
|
|
58
|
+
throw new UsageError(`--${name} takes true or false`);
|
|
59
|
+
}
|
|
60
|
+
if (raw === true) throw new UsageError(`--${name} needs a value`);
|
|
61
|
+
if (t === 'number' || t === 'integer') {
|
|
62
|
+
const n = Number(raw);
|
|
63
|
+
if (!Number.isFinite(n) || (t === 'integer' && !Number.isInteger(n))) throw new UsageError(`--${name} must be ${t === 'integer' ? 'an integer' : 'a number'}`);
|
|
64
|
+
return n;
|
|
65
|
+
}
|
|
66
|
+
if (t === 'string') {
|
|
67
|
+
if (prop.enum && !prop.enum.includes(raw)) throw new UsageError(`--${name} must be one of: ${prop.enum.join(', ')}`);
|
|
68
|
+
return raw;
|
|
69
|
+
}
|
|
70
|
+
if (t === 'array' && !raw.trim().startsWith('[')) return [coerce(name, prop.items ?? {}, raw)];
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(raw);
|
|
73
|
+
} catch {
|
|
74
|
+
throw new UsageError(`--${name} must be JSON`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function inputFromFlags(entry: ManifestEntry, flags: [string, string | true][]): unknown {
|
|
79
|
+
const schema = (entry.input ?? {}) as { properties?: Record<string, Prop>; required?: string[] };
|
|
80
|
+
const props = schema.properties ?? {};
|
|
81
|
+
const byFlag = new Map(Object.keys(props).map((k) => [kebab(k), k]));
|
|
82
|
+
let input: Record<string, unknown> = {};
|
|
83
|
+
for (const [flag, raw] of flags) {
|
|
84
|
+
if (flag === 'json') {
|
|
85
|
+
if (raw === true) throw new UsageError('--json needs a value');
|
|
86
|
+
try {
|
|
87
|
+
input = { ...input, ...JSON.parse(raw) };
|
|
88
|
+
} catch {
|
|
89
|
+
throw new UsageError('--json must be a JSON object');
|
|
90
|
+
}
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const negated = flag.startsWith('no-') && byFlag.has(flag.slice(3));
|
|
94
|
+
const key = byFlag.get(negated ? flag.slice(3) : flag);
|
|
95
|
+
if (!key) {
|
|
96
|
+
const known = [...byFlag.keys()].map((f) => `--${f}`).join(', ') || '(none)';
|
|
97
|
+
throw new UsageError(`unknown flag --${flag} for "${entry.cli!.command}". Flags: ${known}`);
|
|
98
|
+
}
|
|
99
|
+
const prop = props[key]!;
|
|
100
|
+
if (negated) {
|
|
101
|
+
if (typeOf(prop) !== 'boolean') throw new UsageError(`--${flag} only works for true/false flags`);
|
|
102
|
+
input[key] = false;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const value = coerce(flag, prop, raw);
|
|
106
|
+
input[key] = typeOf(prop) === 'array' && Array.isArray(input[key]) && !(typeof raw === 'string' && raw.trim().startsWith('['))
|
|
107
|
+
? [...(input[key] as unknown[]), ...(value as unknown[])]
|
|
108
|
+
: value;
|
|
109
|
+
}
|
|
110
|
+
const missing = (schema.required ?? []).filter((k) => input[k] === undefined);
|
|
111
|
+
if (missing.length) throw new UsageError(`missing ${missing.map((k) => `--${kebab(k)}`).join(', ')}`);
|
|
112
|
+
return entry.input ? input : undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function commandHelp(entry: ManifestEntry): string {
|
|
116
|
+
const schema = (entry.input ?? {}) as { properties?: Record<string, Prop>; required?: string[] };
|
|
117
|
+
const lines = [`${entry.cli!.command}: ${entry.cli!.description}`, ''];
|
|
118
|
+
const props = Object.entries(schema.properties ?? {});
|
|
119
|
+
if (!props.length) lines.push(' (no flags)');
|
|
120
|
+
for (const [k, p] of props) {
|
|
121
|
+
const req = schema.required?.includes(k) ? ' (required)' : '';
|
|
122
|
+
const t = p.enum ? p.enum.join('|') : typeOf(p);
|
|
123
|
+
lines.push(` --${kebab(k)} <${t}>${req}${p.description ? ` ${p.description}` : ''}`);
|
|
124
|
+
}
|
|
125
|
+
lines.push(' --json <object> pass the whole input as JSON');
|
|
126
|
+
const errs = Object.entries(entry.errors);
|
|
127
|
+
if (errs.length) lines.push('', 'Errors:', ...errs.map(([c, s]) => ` ${c} (${s.status}) ${s.message}`));
|
|
128
|
+
return lines.join('\n') + '\n';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function listHelp(manifest: Manifest): string {
|
|
132
|
+
const cmds = manifest.procedures.map((p) => p.cli!).sort((a, b) => a.command.localeCompare(b.command));
|
|
133
|
+
const width = Math.max(0, ...cmds.map((c) => c.command.length));
|
|
134
|
+
return [
|
|
135
|
+
'Usage: realtime [--url URL] [--token TOKEN] <command> [flags]',
|
|
136
|
+
' REALTIME_URL and REALTIME_TOKEN are read from the environment.',
|
|
137
|
+
'',
|
|
138
|
+
'Commands:',
|
|
139
|
+
...cmds.map((c) => ` ${c.command.padEnd(width)} ${c.description}`),
|
|
140
|
+
'',
|
|
141
|
+
'Run "realtime <command> --help" for its flags.',
|
|
142
|
+
].join('\n') + '\n';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Runs the CLI and returns the exit code: 0 on success, 1 when the call failed, 2 for usage errors.
|
|
147
|
+
* The CLI never imports handlers. It downloads the manifest and calls the Worker over HTTP.
|
|
148
|
+
*/
|
|
149
|
+
export async function run(io: Io): Promise<number> {
|
|
150
|
+
const f = io.fetch ?? fetch;
|
|
151
|
+
const { words, flags } = parseArgs(io.argv);
|
|
152
|
+
const take = (name: string) => {
|
|
153
|
+
const i = flags.findIndex(([k]) => k === name);
|
|
154
|
+
if (i < 0) return undefined;
|
|
155
|
+
const [, v] = flags.splice(i, 1)[0]!;
|
|
156
|
+
return v;
|
|
157
|
+
};
|
|
158
|
+
const url = (take('url') as string | undefined) ?? io.env.REALTIME_URL;
|
|
159
|
+
const token = (take('token') as string | undefined) ?? io.env.REALTIME_TOKEN;
|
|
160
|
+
const basePath = io.env.REALTIME_BASE_PATH ?? '/rpc';
|
|
161
|
+
const help = take('help') !== undefined || words[0] === 'help';
|
|
162
|
+
if (words[0] === 'help') words.shift();
|
|
163
|
+
|
|
164
|
+
if (!url) {
|
|
165
|
+
io.stderr('realtime: set --url or REALTIME_URL to your Worker, e.g. https://api.example.com\n');
|
|
166
|
+
return 2;
|
|
167
|
+
}
|
|
168
|
+
const origin = url.replace(/\/$/, '');
|
|
169
|
+
let manifest: Manifest;
|
|
170
|
+
try {
|
|
171
|
+
const res = await f(`${origin}${basePath}/manifest.json`);
|
|
172
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
173
|
+
manifest = (await res.json()) as Manifest;
|
|
174
|
+
} catch (e) {
|
|
175
|
+
io.stderr(`realtime: could not load ${origin}${basePath}/manifest.json: ${(e as Error).message}\n`);
|
|
176
|
+
return 1;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const entry = manifest.procedures
|
|
180
|
+
.filter((p) => {
|
|
181
|
+
const parts = p.cli!.command.split(' ');
|
|
182
|
+
return parts.every((w, i) => words[i] === w);
|
|
183
|
+
})
|
|
184
|
+
.sort((a, b) => b.cli!.command.length - a.cli!.command.length)[0];
|
|
185
|
+
|
|
186
|
+
if (!entry) {
|
|
187
|
+
if (words.length && !help) io.stderr(`realtime: unknown command "${words.join(' ')}"\n\n`);
|
|
188
|
+
(words.length && !help ? io.stderr : io.stdout)(listHelp(manifest));
|
|
189
|
+
return words.length && !help ? 2 : 0;
|
|
190
|
+
}
|
|
191
|
+
const extra = words.slice(entry.cli!.command.split(' ').length);
|
|
192
|
+
if (help) {
|
|
193
|
+
io.stdout(commandHelp(entry));
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
if (extra.length) {
|
|
197
|
+
io.stderr(`realtime: unexpected argument "${extra[0]}". Pass values as flags.\n\n${commandHelp(entry)}`);
|
|
198
|
+
return 2;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
let input: unknown;
|
|
202
|
+
try {
|
|
203
|
+
input = inputFromFlags(entry, flags);
|
|
204
|
+
} catch (e) {
|
|
205
|
+
if (!(e instanceof UsageError)) throw e;
|
|
206
|
+
io.stderr(`realtime: ${e.message}\n\n${commandHelp(entry)}`);
|
|
207
|
+
return 2;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const res = await f(`${origin}${entry.path}`, {
|
|
211
|
+
method: 'POST',
|
|
212
|
+
headers: { 'content-type': 'application/json', 'x-realtime-surface': 'cli', ...(token ? { authorization: `Bearer ${token}` } : {}) },
|
|
213
|
+
body: input === undefined ? '' : JSON.stringify(input),
|
|
214
|
+
});
|
|
215
|
+
const body = (await res.json().catch(() => ({}))) as { data?: unknown; error?: { code: string; message: string; issues?: { path: string; message: string }[] } };
|
|
216
|
+
if (res.ok && !body.error) {
|
|
217
|
+
io.stdout(JSON.stringify(body.data, null, 2) + '\n');
|
|
218
|
+
return 0;
|
|
219
|
+
}
|
|
220
|
+
const err = body.error ?? { code: 'INTERNAL', message: `HTTP ${res.status}` };
|
|
221
|
+
io.stderr(`error ${err.code}: ${err.message}\n`);
|
|
222
|
+
for (const i of err.issues ?? []) io.stderr(` ${i.path ? `--${kebab(i.path.split('.')[0]!)}` : 'input'}: ${i.message}\n`);
|
|
223
|
+
if (res.status === 401) io.stderr('Set --token or REALTIME_TOKEN to an API token.\n');
|
|
224
|
+
return 1;
|
|
225
|
+
}
|