@crowdedkingdoms/crowdyjs 17.9.0-dev.1 → 17.11.0-dev.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/dist/domains/exec.d.ts +123 -4
- package/dist/domains/exec.d.ts.map +1 -1
- package/dist/domains/exec.js +144 -4
- package/dist/generated/graphql.d.ts +412 -1
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +12 -0
- package/dist/grid-scope.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/kit/npcs.d.ts.map +1 -1
- package/dist/kit/social.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/domains/exec.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DecoderOptions } from '@msgpack/msgpack';
|
|
2
2
|
import type { GraphQLClient } from '../client.js';
|
|
3
3
|
import { CrowdyError } from '../errors.js';
|
|
4
|
+
import { type ExecAppStatusFieldsFragment, type ExecBuildFieldsFragment, type ExecInstancesQuery, type ExecLogsQuery, type ExecVersionsQuery } from '../generated/graphql.js';
|
|
4
5
|
/**
|
|
5
6
|
* ck-exec, the hub-and-spoke execution service (dev-tier preview).
|
|
6
7
|
*
|
|
@@ -180,7 +181,9 @@ export declare class ExecConnection {
|
|
|
180
181
|
export interface ExecNodeTypeInput {
|
|
181
182
|
kind: 'hub' | 'spoke';
|
|
182
183
|
/** The compiled module (`wasm32-unknown-unknown`, built with `ckx-sdk`). */
|
|
183
|
-
wasm
|
|
184
|
+
wasm?: Uint8Array;
|
|
185
|
+
/** Instead of `wasm`: a crate of the deploy's `buildId`. */
|
|
186
|
+
crate?: string;
|
|
184
187
|
/** The type that owns this one; none for the root. */
|
|
185
188
|
parent?: string;
|
|
186
189
|
/** Clients may call it through the gateway. */
|
|
@@ -195,11 +198,126 @@ export interface ExecDeployOptions {
|
|
|
195
198
|
/** The root hub's type name. */
|
|
196
199
|
root: string;
|
|
197
200
|
types: Record<string, ExecNodeTypeInput>;
|
|
201
|
+
/** A succeeded {@link ExecAPI.build} of this app whose crates the types may name. */
|
|
202
|
+
buildId?: string;
|
|
198
203
|
}
|
|
199
|
-
/**
|
|
204
|
+
/** One crate for {@link ExecAPI.build}: its files by path (`Cargo.toml`, `src/lib.rs`, ...). */
|
|
205
|
+
export interface ExecCrate {
|
|
206
|
+
name: string;
|
|
207
|
+
files: Record<string, string> | ExecSourceFile[];
|
|
208
|
+
}
|
|
209
|
+
export interface ExecSourceFile {
|
|
210
|
+
path: string;
|
|
211
|
+
content: string;
|
|
212
|
+
}
|
|
213
|
+
/** A build: `queued`, `building`, `succeeded` or `failed`, its log, and one module per crate. */
|
|
214
|
+
export type ExecBuild = Omit<ExecBuildFieldsFragment, '__typename' | 'artifacts'> & {
|
|
215
|
+
artifacts: Array<{
|
|
216
|
+
crate: string;
|
|
217
|
+
digest: string;
|
|
218
|
+
sizeBytes: number;
|
|
219
|
+
}>;
|
|
220
|
+
};
|
|
221
|
+
/** A starter crate, with its files ready for {@link ExecAPI.build}. */
|
|
222
|
+
export interface ExecStarter {
|
|
223
|
+
crate: string;
|
|
224
|
+
nodeType: string;
|
|
225
|
+
description: string;
|
|
226
|
+
files: ExecSourceFile[];
|
|
227
|
+
}
|
|
228
|
+
/** The starter packs, and the manifest that deploys them as one app, its types naming their crates. */
|
|
229
|
+
export interface ExecStarterPack {
|
|
230
|
+
manifest: {
|
|
231
|
+
root: string;
|
|
232
|
+
types: Record<string, ExecNodeTypeInput>;
|
|
233
|
+
};
|
|
234
|
+
starters: ExecStarter[];
|
|
235
|
+
}
|
|
236
|
+
/** One guest log line (`ctx.log`); `level` is 0 error, 1 warn, 2 info, 3 debug. */
|
|
237
|
+
export type ExecLogLine = Omit<ExecLogsQuery['execLogs'][number], '__typename'>;
|
|
238
|
+
/** An instance the execution manager has placed. */
|
|
239
|
+
export type ExecInstance = Omit<ExecInstancesQuery['execInstances'][number], '__typename'>;
|
|
240
|
+
/** A deployed version. */
|
|
241
|
+
export type ExecVersion = Omit<ExecVersionsQuery['execVersions'][number], '__typename'>;
|
|
242
|
+
/** An app's active version, kill switches and budget pause. */
|
|
243
|
+
export type ExecAppStatus = Omit<ExecAppStatusFieldsFragment, '__typename'>;
|
|
244
|
+
export interface ExecLogsOptions {
|
|
245
|
+
nodeType?: string;
|
|
246
|
+
key?: string;
|
|
247
|
+
/** The least severe level included: 0 errors only … 3 everything (the default). */
|
|
248
|
+
maxLevel?: number;
|
|
249
|
+
/** Only lines older than this line id, to page back. */
|
|
250
|
+
before?: string;
|
|
251
|
+
/** At most this many lines (default 100, at most 500). */
|
|
252
|
+
limit?: number;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* `client.exec`: connecting players to ck-exec, building and deploying an app's nodes (and
|
|
256
|
+
* the starter packs), and operating them (logs, instances, versions, rollback, the kill
|
|
257
|
+
* switch, developer connections).
|
|
258
|
+
*/
|
|
200
259
|
export declare class ExecAPI {
|
|
201
260
|
private readonly graphql;
|
|
202
261
|
constructor(graphql: GraphQLClient);
|
|
262
|
+
/**
|
|
263
|
+
* A host and a developer connect token for `appId` (valid for about a minute). The
|
|
264
|
+
* session's calls arrive as `Caller::Developer` with your user id and may reach any
|
|
265
|
+
* node type, not only `client` ones. Requires the org `manage_compute` permission and
|
|
266
|
+
* your own session token, not an app token.
|
|
267
|
+
*/
|
|
268
|
+
developerEndpoint(appId: string, options?: {
|
|
269
|
+
nodeType?: string;
|
|
270
|
+
key?: string;
|
|
271
|
+
}): Promise<ExecEndpoint & {
|
|
272
|
+
expiresAt: string;
|
|
273
|
+
}>;
|
|
274
|
+
/**
|
|
275
|
+
* Connects as one of the app's developers, for studio tools, manual runs and admin
|
|
276
|
+
* endpoints. The same connection as {@link connect}, reconnecting with a fresh
|
|
277
|
+
* developer token.
|
|
278
|
+
*/
|
|
279
|
+
connectAsDeveloper(appId: string, options?: ExecConnectOptions): Promise<ExecConnection>;
|
|
280
|
+
/** Guest log lines, newest first, kept for 24 hours. Requires `view_compute_diagnostics`. */
|
|
281
|
+
logs(appId: string, options?: ExecLogsOptions): Promise<ExecLogLine[]>;
|
|
282
|
+
/** What the manager has placed for the app. Requires `view_compute_diagnostics`. */
|
|
283
|
+
instances(appId: string): Promise<ExecInstance[]>;
|
|
284
|
+
/** The app's versions, newest first. Requires `view_compute_diagnostics`. */
|
|
285
|
+
versions(appId: string): Promise<ExecVersion[]>;
|
|
286
|
+
/** The active version and the switches. Requires `view_compute_diagnostics`. */
|
|
287
|
+
status(appId: string): Promise<ExecAppStatus>;
|
|
288
|
+
/**
|
|
289
|
+
* Makes an earlier version active again, a rollback; instances pick it up when they
|
|
290
|
+
* next start. Requires `manage_compute`.
|
|
291
|
+
*/
|
|
292
|
+
activateVersion(appId: string, version: number): Promise<ExecAppStatus>;
|
|
293
|
+
/**
|
|
294
|
+
* The kill switch, for the whole app or one node type. Off: nothing of it is placed,
|
|
295
|
+
* what runs is persisted and stopped, and calls are refused with `Denied`. Requires
|
|
296
|
+
* `manage_compute`.
|
|
297
|
+
*/
|
|
298
|
+
setEnabled(appId: string, enabled: boolean, nodeType?: string): Promise<ExecAppStatus>;
|
|
299
|
+
/**
|
|
300
|
+
* The starter packs, which replace the compute templates: a world tick (the root hub), a
|
|
301
|
+
* matchmaker, game sessions and an NPC and mob engine. Build them with {@link build} and
|
|
302
|
+
* deploy the build with `manifest`. Requires `manage_compute`.
|
|
303
|
+
*/
|
|
304
|
+
starters(appId: string): Promise<ExecStarterPack>;
|
|
305
|
+
/**
|
|
306
|
+
* Builds crates into modules on the platform (`ckx-sdk`, `wasm32-unknown-unknown`), so you
|
|
307
|
+
* need no Rust toolchain. Returns at once with the build queued; wait with
|
|
308
|
+
* {@link waitForBuild}, then {@link deploy} with its `buildId`. Requires `manage_compute`.
|
|
309
|
+
*/
|
|
310
|
+
build(appId: string, crates: ExecCrate[]): Promise<ExecBuild>;
|
|
311
|
+
/** A build's status, log and modules, or null. Requires `view_compute_diagnostics`. */
|
|
312
|
+
buildStatus(appId: string, buildId: string): Promise<ExecBuild | null>;
|
|
313
|
+
/**
|
|
314
|
+
* Polls a build until it succeeds or fails, and returns it either way; a failed build's
|
|
315
|
+
* `log` says why. Throws when it is not done in `timeoutMs` (default 10 minutes).
|
|
316
|
+
*/
|
|
317
|
+
waitForBuild(appId: string, buildId: string, options?: {
|
|
318
|
+
intervalMs?: number;
|
|
319
|
+
timeoutMs?: number;
|
|
320
|
+
}): Promise<ExecBuild>;
|
|
203
321
|
/** A host for this player and its connect token (valid for about a minute). */
|
|
204
322
|
endpoint(appId: string, options?: {
|
|
205
323
|
nodeType?: string;
|
|
@@ -215,8 +333,9 @@ export declare class ExecAPI {
|
|
|
215
333
|
connect(appId: string, options?: ExecConnectOptions): Promise<ExecConnection>;
|
|
216
334
|
/**
|
|
217
335
|
* Deploys a new version of the app's nodes and makes it active: the manifest, and
|
|
218
|
-
* each distinct module once.
|
|
219
|
-
*
|
|
336
|
+
* each distinct module once. A type gives its module as `wasm`, or names a `crate` of
|
|
337
|
+
* `buildId`, whose modules the platform already holds. Running instances pick it up
|
|
338
|
+
* when they next start. Requires the org `manage_compute` permission.
|
|
220
339
|
*/
|
|
221
340
|
deploy(options: ExecDeployOptions): Promise<{
|
|
222
341
|
version: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/domains/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/domains/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,KAAK,EA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AC;IAShD;;;;OAIG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,cAAc,CAAC;IASvF;;;;;OAKG;IACG,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CA0BvE"}
|
package/dist/domains/exec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decode, encode } from '@msgpack/msgpack';
|
|
2
2
|
import { CrowdyError } from '../errors.js';
|
|
3
|
-
import { ExecConnectDocument, ExecDeployDocument, } from '../generated/graphql.js';
|
|
3
|
+
import { ExecActivateVersionDocument, ExecAppStatusDocument, ExecBuildDocument, ExecBuildStatusDocument, ExecConnectAsDeveloperDocument, ExecConnectDocument, ExecDeployDocument, ExecInstancesDocument, ExecLogsDocument, ExecSetEnabledDocument, ExecStartersDocument, ExecVersionsDocument, } from '../generated/graphql.js';
|
|
4
4
|
/**
|
|
5
5
|
* ck-exec, the hub-and-spoke execution service (dev-tier preview).
|
|
6
6
|
*
|
|
@@ -512,11 +512,142 @@ async function sha256Hex(bytes) {
|
|
|
512
512
|
const d = new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));
|
|
513
513
|
return Array.from(d, (x) => x.toString(16).padStart(2, '0')).join('');
|
|
514
514
|
}
|
|
515
|
-
|
|
515
|
+
function strip(v) {
|
|
516
|
+
const { __typename: _, ...rest } = v;
|
|
517
|
+
return rest;
|
|
518
|
+
}
|
|
519
|
+
function build(b) {
|
|
520
|
+
const { __typename: _, artifacts, ...rest } = b;
|
|
521
|
+
return { ...rest, artifacts: artifacts.map(strip) };
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* `client.exec`: connecting players to ck-exec, building and deploying an app's nodes (and
|
|
525
|
+
* the starter packs), and operating them (logs, instances, versions, rollback, the kill
|
|
526
|
+
* switch, developer connections).
|
|
527
|
+
*/
|
|
516
528
|
export class ExecAPI {
|
|
517
529
|
constructor(graphql) {
|
|
518
530
|
this.graphql = graphql;
|
|
519
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* A host and a developer connect token for `appId` (valid for about a minute). The
|
|
534
|
+
* session's calls arrive as `Caller::Developer` with your user id and may reach any
|
|
535
|
+
* node type, not only `client` ones. Requires the org `manage_compute` permission and
|
|
536
|
+
* your own session token, not an app token.
|
|
537
|
+
*/
|
|
538
|
+
async developerEndpoint(appId, options = {}) {
|
|
539
|
+
const data = await this.graphql.request(ExecConnectAsDeveloperDocument, {
|
|
540
|
+
appId,
|
|
541
|
+
nodeType: options.nodeType,
|
|
542
|
+
key: options.key,
|
|
543
|
+
});
|
|
544
|
+
return data.execConnectAsDeveloper;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Connects as one of the app's developers, for studio tools, manual runs and admin
|
|
548
|
+
* endpoints. The same connection as {@link connect}, reconnecting with a fresh
|
|
549
|
+
* developer token.
|
|
550
|
+
*/
|
|
551
|
+
async connectAsDeveloper(appId, options = {}) {
|
|
552
|
+
const c = new ExecConnection(() => this.developerEndpoint(appId, { nodeType: options.nodeType, key: options.key }), options);
|
|
553
|
+
await c.connect();
|
|
554
|
+
return c;
|
|
555
|
+
}
|
|
556
|
+
/** Guest log lines, newest first, kept for 24 hours. Requires `view_compute_diagnostics`. */
|
|
557
|
+
async logs(appId, options = {}) {
|
|
558
|
+
const data = await this.graphql.request(ExecLogsDocument, { appId, ...options });
|
|
559
|
+
return data.execLogs.map(strip);
|
|
560
|
+
}
|
|
561
|
+
/** What the manager has placed for the app. Requires `view_compute_diagnostics`. */
|
|
562
|
+
async instances(appId) {
|
|
563
|
+
const data = await this.graphql.request(ExecInstancesDocument, { appId });
|
|
564
|
+
return data.execInstances.map(strip);
|
|
565
|
+
}
|
|
566
|
+
/** The app's versions, newest first. Requires `view_compute_diagnostics`. */
|
|
567
|
+
async versions(appId) {
|
|
568
|
+
const data = await this.graphql.request(ExecVersionsDocument, { appId });
|
|
569
|
+
return data.execVersions.map(strip);
|
|
570
|
+
}
|
|
571
|
+
/** The active version and the switches. Requires `view_compute_diagnostics`. */
|
|
572
|
+
async status(appId) {
|
|
573
|
+
const data = await this.graphql.request(ExecAppStatusDocument, { appId });
|
|
574
|
+
return strip(data.execAppStatus);
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Makes an earlier version active again, a rollback; instances pick it up when they
|
|
578
|
+
* next start. Requires `manage_compute`.
|
|
579
|
+
*/
|
|
580
|
+
async activateVersion(appId, version) {
|
|
581
|
+
const data = await this.graphql.request(ExecActivateVersionDocument, { appId, version });
|
|
582
|
+
return strip(data.execActivateVersion);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* The kill switch, for the whole app or one node type. Off: nothing of it is placed,
|
|
586
|
+
* what runs is persisted and stopped, and calls are refused with `Denied`. Requires
|
|
587
|
+
* `manage_compute`.
|
|
588
|
+
*/
|
|
589
|
+
async setEnabled(appId, enabled, nodeType) {
|
|
590
|
+
const data = await this.graphql.request(ExecSetEnabledDocument, { appId, enabled, nodeType });
|
|
591
|
+
return strip(data.execSetEnabled);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* The starter packs, which replace the compute templates: a world tick (the root hub), a
|
|
595
|
+
* matchmaker, game sessions and an NPC and mob engine. Build them with {@link build} and
|
|
596
|
+
* deploy the build with `manifest`. Requires `manage_compute`.
|
|
597
|
+
*/
|
|
598
|
+
async starters(appId) {
|
|
599
|
+
const data = await this.graphql.request(ExecStartersDocument, { appId });
|
|
600
|
+
return {
|
|
601
|
+
manifest: JSON.parse(data.execStarters.manifestJson),
|
|
602
|
+
starters: data.execStarters.starters.map((s) => ({
|
|
603
|
+
crate: s.crate,
|
|
604
|
+
nodeType: s.nodeType,
|
|
605
|
+
description: s.description,
|
|
606
|
+
files: s.files.map(strip),
|
|
607
|
+
})),
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Builds crates into modules on the platform (`ckx-sdk`, `wasm32-unknown-unknown`), so you
|
|
612
|
+
* need no Rust toolchain. Returns at once with the build queued; wait with
|
|
613
|
+
* {@link waitForBuild}, then {@link deploy} with its `buildId`. Requires `manage_compute`.
|
|
614
|
+
*/
|
|
615
|
+
async build(appId, crates) {
|
|
616
|
+
const data = await this.graphql.request(ExecBuildDocument, {
|
|
617
|
+
input: {
|
|
618
|
+
appId,
|
|
619
|
+
crates: crates.map((c) => ({
|
|
620
|
+
name: c.name,
|
|
621
|
+
files: Array.isArray(c.files)
|
|
622
|
+
? c.files
|
|
623
|
+
: Object.entries(c.files).map(([path, content]) => ({ path, content })),
|
|
624
|
+
})),
|
|
625
|
+
},
|
|
626
|
+
});
|
|
627
|
+
return build(data.execBuild);
|
|
628
|
+
}
|
|
629
|
+
/** A build's status, log and modules, or null. Requires `view_compute_diagnostics`. */
|
|
630
|
+
async buildStatus(appId, buildId) {
|
|
631
|
+
const data = await this.graphql.request(ExecBuildStatusDocument, { appId, buildId });
|
|
632
|
+
return data.execBuildStatus ? build(data.execBuildStatus) : null;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Polls a build until it succeeds or fails, and returns it either way; a failed build's
|
|
636
|
+
* `log` says why. Throws when it is not done in `timeoutMs` (default 10 minutes).
|
|
637
|
+
*/
|
|
638
|
+
async waitForBuild(appId, buildId, options = {}) {
|
|
639
|
+
const until = Date.now() + (options.timeoutMs ?? 600000);
|
|
640
|
+
for (;;) {
|
|
641
|
+
const b = await this.buildStatus(appId, buildId);
|
|
642
|
+
if (!b)
|
|
643
|
+
throw new CrowdyError({ message: `no build ${buildId} in app ${appId}` });
|
|
644
|
+
if (b.status === 'succeeded' || b.status === 'failed')
|
|
645
|
+
return b;
|
|
646
|
+
if (Date.now() > until)
|
|
647
|
+
throw new CrowdyError({ message: `build ${buildId} is still ${b.status}` });
|
|
648
|
+
await new Promise((r) => setTimeout(r, options.intervalMs ?? 2000));
|
|
649
|
+
}
|
|
650
|
+
}
|
|
520
651
|
/** A host for this player and its connect token (valid for about a minute). */
|
|
521
652
|
async endpoint(appId, options = {}) {
|
|
522
653
|
const data = await this.graphql.request(ExecConnectDocument, {
|
|
@@ -538,14 +669,22 @@ export class ExecAPI {
|
|
|
538
669
|
}
|
|
539
670
|
/**
|
|
540
671
|
* Deploys a new version of the app's nodes and makes it active: the manifest, and
|
|
541
|
-
* each distinct module once.
|
|
542
|
-
*
|
|
672
|
+
* each distinct module once. A type gives its module as `wasm`, or names a `crate` of
|
|
673
|
+
* `buildId`, whose modules the platform already holds. Running instances pick it up
|
|
674
|
+
* when they next start. Requires the org `manage_compute` permission.
|
|
543
675
|
*/
|
|
544
676
|
async deploy(options) {
|
|
545
677
|
const types = {};
|
|
546
678
|
const artifacts = new Map();
|
|
547
679
|
for (const [name, t] of Object.entries(options.types)) {
|
|
548
680
|
const { wasm, ...spec } = t;
|
|
681
|
+
if (!wasm) {
|
|
682
|
+
if (!spec.crate || !options.buildId) {
|
|
683
|
+
throw new CrowdyError({ message: `type '${name}' needs its wasm, or a crate of the deploy's buildId` });
|
|
684
|
+
}
|
|
685
|
+
types[name] = spec;
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
549
688
|
const digest = await sha256Hex(wasm);
|
|
550
689
|
if (!artifacts.has(digest))
|
|
551
690
|
artifacts.set(digest, base64(wasm));
|
|
@@ -556,6 +695,7 @@ export class ExecAPI {
|
|
|
556
695
|
appId: options.appId,
|
|
557
696
|
manifestJson: JSON.stringify({ root: options.root, types }),
|
|
558
697
|
artifacts: [...artifacts].map(([digest, wasmBase64]) => ({ digest, wasmBase64 })),
|
|
698
|
+
buildId: options.buildId,
|
|
559
699
|
},
|
|
560
700
|
});
|
|
561
701
|
return data.execDeploy;
|