@crowdedkingdoms/crowdyjs 17.13.0-dev.1 → 18.0.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/MIGRATION.md +163 -1
- package/README.md +142 -146
- package/dist/crowdy-client.d.ts +12 -31
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +15 -37
- package/dist/crowdy-dsh/bridge.d.ts.map +1 -1
- package/dist/crowdy-dsh/bridge.js +3 -6
- package/dist/crowdy-studio/controller.d.ts +59 -57
- package/dist/crowdy-studio/controller.d.ts.map +1 -1
- package/dist/crowdy-studio/controller.js +268 -206
- package/dist/crowdy-studio/diagnostics.d.ts +3 -12
- package/dist/crowdy-studio/diagnostics.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.d.ts +2 -4
- package/dist/crowdy-studio/dom-shell.d.ts.map +1 -1
- package/dist/crowdy-studio/dom-shell.js +16 -47
- package/dist/crowdy-studio/embed/hud-layer.d.ts +1 -1
- package/dist/crowdy-studio/embed/panel.d.ts +3 -12
- package/dist/crowdy-studio/embed/panel.d.ts.map +1 -1
- package/dist/crowdy-studio/embed/panel.js +3 -6
- package/dist/crowdy-studio/index.d.ts +1 -3
- package/dist/crowdy-studio/index.d.ts.map +1 -1
- package/dist/crowdy-studio/index.js +0 -2
- package/dist/crowdy-studio/models.d.ts +3 -4
- package/dist/crowdy-studio/models.d.ts.map +1 -1
- package/dist/crowdy-studio/starter-projects.d.ts +8 -4
- package/dist/crowdy-studio/starter-projects.d.ts.map +1 -1
- package/dist/crowdy-studio/starter-projects.js +83 -100
- package/dist/domains/appAccess.d.ts +14 -1
- package/dist/domains/appAccess.d.ts.map +1 -1
- package/dist/domains/appAccess.js +37 -1
- package/dist/domains/exec.d.ts +162 -15
- package/dist/domains/exec.d.ts.map +1 -1
- package/dist/domains/exec.js +180 -18
- package/dist/domains/host.d.ts +3 -3
- package/dist/domains/host.js +3 -3
- package/dist/domains/marketplace.d.ts +9 -58
- package/dist/domains/marketplace.d.ts.map +1 -1
- package/dist/domains/marketplace.js +9 -106
- package/dist/domains/playerWallet.d.ts +6 -12
- package/dist/domains/playerWallet.d.ts.map +1 -1
- package/dist/domains/playerWallet.js +6 -21
- package/dist/errors.d.ts +7 -13
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +6 -10
- package/dist/generated/graphql.d.ts +1384 -7977
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +22 -321
- package/dist/grid-mods/exec-client-halves.d.ts +156 -0
- package/dist/grid-mods/exec-client-halves.d.ts.map +1 -0
- package/dist/grid-mods/exec-client-halves.js +356 -0
- package/dist/grid-mods/grid-host-calls.d.ts +29 -15
- package/dist/grid-mods/grid-host-calls.d.ts.map +1 -1
- package/dist/grid-mods/grid-host-calls.js +40 -44
- package/dist/grid-mods/index.d.ts +1 -0
- package/dist/grid-mods/index.d.ts.map +1 -1
- package/dist/grid-mods/index.js +1 -0
- package/dist/grid-mods/mod-runtime.d.ts +21 -6
- package/dist/grid-mods/mod-runtime.d.ts.map +1 -1
- package/dist/grid-mods/mod-runtime.js +6 -2
- package/dist/grid-scope.d.ts +0 -188
- package/dist/grid-scope.d.ts.map +1 -1
- package/dist/grid-scope.js +0 -69
- package/dist/index.d.ts +12 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -16
- package/dist/kit/actions.d.ts +5 -9
- package/dist/kit/actions.d.ts.map +1 -1
- package/dist/kit/actions.js +5 -9
- package/dist/kit/index.d.ts +2 -33
- package/dist/kit/index.d.ts.map +1 -1
- package/dist/kit/index.js +1 -32
- package/dist/kit/kit.d.ts +8 -208
- package/dist/kit/kit.d.ts.map +1 -1
- package/dist/kit/kit.js +5 -163
- package/dist/kit/social.d.ts +1 -3
- package/dist/kit/social.d.ts.map +1 -1
- package/dist/kit/social.js +1 -3
- package/dist/kit/wire.d.ts +16 -5
- package/dist/kit/wire.d.ts.map +1 -1
- package/dist/kit/wire.js +19 -5
- package/dist/live-coding/assets/browser-authoring-index.json +1 -1
- package/dist/live-coding/assets/manifest.json +1 -1
- package/dist/live-coding/browser-authoring-index.generated.d.ts.map +1 -1
- package/dist/live-coding/browser-authoring-index.generated.js +1496 -4386
- package/dist/live-coding/rust-analysis.d.ts.map +1 -1
- package/dist/live-coding/rust-analysis.js +31 -23
- package/dist/player-runtime/client-host-calls.d.ts +8 -0
- package/dist/player-runtime/client-host-calls.d.ts.map +1 -0
- package/dist/player-runtime/client-host-calls.js +28 -0
- package/dist/player-runtime/glue-runtime.d.ts +27 -10
- package/dist/player-runtime/glue-runtime.d.ts.map +1 -1
- package/dist/player-runtime/glue-runtime.js +40 -45
- package/dist/player-runtime/glue-sab.d.ts +2 -2
- package/dist/player-runtime/glue-sab.js +2 -2
- package/dist/player-runtime/player-code-broker.d.ts +80 -24
- package/dist/player-runtime/player-code-broker.d.ts.map +1 -1
- package/dist/player-runtime/player-code-broker.js +169 -41
- package/dist/player-runtime/player-glue-worker.d.ts +8 -8
- package/dist/player-runtime/player-glue-worker.d.ts.map +1 -1
- package/dist/player-runtime/player-glue-worker.js +26 -9
- package/dist/stores/actors.d.ts +12 -2
- package/dist/stores/actors.d.ts.map +1 -1
- package/dist/stores/actors.js +43 -18
- package/dist/stores/chunks.d.ts +12 -0
- package/dist/stores/chunks.d.ts.map +1 -1
- package/dist/stores/chunks.js +112 -39
- package/dist/stores/durable.d.ts.map +1 -1
- package/dist/stores/durable.js +2 -1
- package/dist/stores/inbox.d.ts +1 -1
- package/dist/stores/inbox.d.ts.map +1 -1
- package/dist/stores/index.d.ts +0 -11
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +0 -4
- package/dist/stores/session.d.ts +0 -2
- package/dist/stores/session.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/crowdy-studio/model-lint-log.d.ts +0 -76
- package/dist/crowdy-studio/model-lint-log.d.ts.map +0 -1
- package/dist/crowdy-studio/model-lint-log.js +0 -93
- package/dist/crowdy-studio/model-lint.d.ts +0 -61
- package/dist/crowdy-studio/model-lint.d.ts.map +0 -1
- package/dist/crowdy-studio/model-lint.js +0 -45
- package/dist/domains/compute.d.ts +0 -208
- package/dist/domains/compute.d.ts.map +0 -1
- package/dist/domains/compute.js +0 -274
- package/dist/domains/controlPlane.d.ts +0 -38
- package/dist/domains/controlPlane.d.ts.map +0 -1
- package/dist/domains/controlPlane.js +0 -43
- package/dist/domains/gameModel.d.ts +0 -1174
- package/dist/domains/gameModel.d.ts.map +0 -1
- package/dist/domains/gameModel.js +0 -1333
- package/dist/domains/playerCompute.d.ts +0 -91
- package/dist/domains/playerCompute.d.ts.map +0 -1
- package/dist/domains/playerCompute.js +0 -136
- package/dist/domains/playerModel.d.ts +0 -20
- package/dist/domains/playerModel.d.ts.map +0 -1
- package/dist/domains/playerModel.js +0 -54
- package/dist/kit/abilities.d.ts +0 -66
- package/dist/kit/abilities.d.ts.map +0 -1
- package/dist/kit/abilities.js +0 -71
- package/dist/kit/blueprints/combat.d.ts +0 -81
- package/dist/kit/blueprints/combat.d.ts.map +0 -1
- package/dist/kit/blueprints/combat.js +0 -357
- package/dist/kit/blueprints/core.d.ts +0 -222
- package/dist/kit/blueprints/core.d.ts.map +0 -1
- package/dist/kit/blueprints/core.js +0 -185
- package/dist/kit/blueprints/decks.d.ts +0 -50
- package/dist/kit/blueprints/decks.d.ts.map +0 -1
- package/dist/kit/blueprints/decks.js +0 -163
- package/dist/kit/blueprints/economy.d.ts +0 -88
- package/dist/kit/blueprints/economy.d.ts.map +0 -1
- package/dist/kit/blueprints/economy.js +0 -533
- package/dist/kit/blueprints/guild.d.ts +0 -51
- package/dist/kit/blueprints/guild.d.ts.map +0 -1
- package/dist/kit/blueprints/guild.js +0 -50
- package/dist/kit/blueprints/index.d.ts +0 -23
- package/dist/kit/blueprints/index.d.ts.map +0 -1
- package/dist/kit/blueprints/index.js +0 -22
- package/dist/kit/blueprints/inventory.d.ts +0 -84
- package/dist/kit/blueprints/inventory.d.ts.map +0 -1
- package/dist/kit/blueprints/inventory.js +0 -257
- package/dist/kit/blueprints/leaderboards.d.ts +0 -49
- package/dist/kit/blueprints/leaderboards.d.ts.map +0 -1
- package/dist/kit/blueprints/leaderboards.js +0 -126
- package/dist/kit/blueprints/liveops.d.ts +0 -42
- package/dist/kit/blueprints/liveops.d.ts.map +0 -1
- package/dist/kit/blueprints/liveops.js +0 -170
- package/dist/kit/blueprints/locks.d.ts +0 -82
- package/dist/kit/blueprints/locks.d.ts.map +0 -1
- package/dist/kit/blueprints/locks.js +0 -155
- package/dist/kit/blueprints/loot.d.ts +0 -90
- package/dist/kit/blueprints/loot.d.ts.map +0 -1
- package/dist/kit/blueprints/loot.js +0 -229
- package/dist/kit/blueprints/matches.d.ts +0 -84
- package/dist/kit/blueprints/matches.d.ts.map +0 -1
- package/dist/kit/blueprints/matches.js +0 -349
- package/dist/kit/blueprints/moderation.d.ts +0 -32
- package/dist/kit/blueprints/moderation.d.ts.map +0 -1
- package/dist/kit/blueprints/moderation.js +0 -140
- package/dist/kit/blueprints/npcs.d.ts +0 -78
- package/dist/kit/blueprints/npcs.d.ts.map +0 -1
- package/dist/kit/blueprints/npcs.js +0 -125
- package/dist/kit/blueprints/plots.d.ts +0 -63
- package/dist/kit/blueprints/plots.d.ts.map +0 -1
- package/dist/kit/blueprints/plots.js +0 -151
- package/dist/kit/blueprints/progression.d.ts +0 -68
- package/dist/kit/blueprints/progression.d.ts.map +0 -1
- package/dist/kit/blueprints/progression.js +0 -324
- package/dist/kit/blueprints/quests.d.ts +0 -72
- package/dist/kit/blueprints/quests.d.ts.map +0 -1
- package/dist/kit/blueprints/quests.js +0 -285
- package/dist/kit/blueprints/worldsim.d.ts +0 -91
- package/dist/kit/blueprints/worldsim.d.ts.map +0 -1
- package/dist/kit/blueprints/worldsim.js +0 -468
- package/dist/kit/combat.d.ts +0 -141
- package/dist/kit/combat.d.ts.map +0 -1
- package/dist/kit/combat.js +0 -196
- package/dist/kit/decks.d.ts +0 -157
- package/dist/kit/decks.d.ts.map +0 -1
- package/dist/kit/decks.js +0 -186
- package/dist/kit/director.d.ts +0 -88
- package/dist/kit/director.d.ts.map +0 -1
- package/dist/kit/director.js +0 -86
- package/dist/kit/economy.d.ts +0 -289
- package/dist/kit/economy.d.ts.map +0 -1
- package/dist/kit/economy.js +0 -427
- package/dist/kit/engine.d.ts +0 -48
- package/dist/kit/engine.d.ts.map +0 -1
- package/dist/kit/engine.js +0 -113
- package/dist/kit/features.d.ts +0 -60
- package/dist/kit/features.d.ts.map +0 -1
- package/dist/kit/features.js +0 -65
- package/dist/kit/instances.d.ts +0 -52
- package/dist/kit/instances.d.ts.map +0 -1
- package/dist/kit/instances.js +0 -60
- package/dist/kit/inventory.d.ts +0 -129
- package/dist/kit/inventory.d.ts.map +0 -1
- package/dist/kit/inventory.js +0 -200
- package/dist/kit/leaderboards.d.ts +0 -86
- package/dist/kit/leaderboards.d.ts.map +0 -1
- package/dist/kit/leaderboards.js +0 -133
- package/dist/kit/liveops.d.ts +0 -112
- package/dist/kit/liveops.d.ts.map +0 -1
- package/dist/kit/liveops.js +0 -183
- package/dist/kit/loot.d.ts +0 -128
- package/dist/kit/loot.d.ts.map +0 -1
- package/dist/kit/loot.js +0 -160
- package/dist/kit/matches.d.ts +0 -301
- package/dist/kit/matches.d.ts.map +0 -1
- package/dist/kit/matches.js +0 -458
- package/dist/kit/matchmaking.d.ts +0 -57
- package/dist/kit/matchmaking.d.ts.map +0 -1
- package/dist/kit/matchmaking.js +0 -59
- package/dist/kit/minigames.d.ts +0 -30
- package/dist/kit/minigames.d.ts.map +0 -1
- package/dist/kit/minigames.js +0 -38
- package/dist/kit/mobs.d.ts +0 -90
- package/dist/kit/mobs.d.ts.map +0 -1
- package/dist/kit/mobs.js +0 -98
- package/dist/kit/moderation.d.ts +0 -73
- package/dist/kit/moderation.d.ts.map +0 -1
- package/dist/kit/moderation.js +0 -103
- package/dist/kit/movement.d.ts +0 -78
- package/dist/kit/movement.d.ts.map +0 -1
- package/dist/kit/movement.js +0 -103
- package/dist/kit/notifications.d.ts +0 -45
- package/dist/kit/notifications.d.ts.map +0 -1
- package/dist/kit/notifications.js +0 -67
- package/dist/kit/npcs.d.ts +0 -226
- package/dist/kit/npcs.d.ts.map +0 -1
- package/dist/kit/npcs.js +0 -141
- package/dist/kit/objects.d.ts +0 -116
- package/dist/kit/objects.d.ts.map +0 -1
- package/dist/kit/objects.js +0 -119
- package/dist/kit/pets.d.ts +0 -85
- package/dist/kit/pets.d.ts.map +0 -1
- package/dist/kit/pets.js +0 -96
- package/dist/kit/plots.d.ts +0 -85
- package/dist/kit/plots.d.ts.map +0 -1
- package/dist/kit/plots.js +0 -113
- package/dist/kit/progression.d.ts +0 -181
- package/dist/kit/progression.d.ts.map +0 -1
- package/dist/kit/progression.js +0 -265
- package/dist/kit/quests.d.ts +0 -171
- package/dist/kit/quests.d.ts.map +0 -1
- package/dist/kit/quests.js +0 -237
- package/dist/kit/racing.d.ts +0 -85
- package/dist/kit/racing.d.ts.map +0 -1
- package/dist/kit/racing.js +0 -99
- package/dist/kit/shared.d.ts +0 -73
- package/dist/kit/shared.d.ts.map +0 -1
- package/dist/kit/shared.js +0 -101
- package/dist/kit/telemetry.d.ts +0 -66
- package/dist/kit/telemetry.d.ts.map +0 -1
- package/dist/kit/telemetry.js +0 -133
- package/dist/kit/territory.d.ts +0 -97
- package/dist/kit/territory.d.ts.map +0 -1
- package/dist/kit/territory.js +0 -114
- package/dist/kit/worldsim.d.ts +0 -263
- package/dist/kit/worldsim.d.ts.map +0 -1
- package/dist/kit/worldsim.js +0 -268
- package/dist/stores/model.d.ts +0 -81
- package/dist/stores/model.d.ts.map +0 -1
- package/dist/stores/model.js +0 -163
package/dist/domains/exec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decode, encode } from '@msgpack/msgpack';
|
|
2
|
-
import { CrowdyError } from '../errors.js';
|
|
3
|
-
import { ExecActivateVersionDocument, ExecAppStatusDocument, ExecBuildDocument, ExecBuildStatusDocument, ExecConnectAsDeveloperDocument, ExecConnectDocument, ExecDeployDocument, ExecEndpointStatsDocument, ExecInstancesDocument, ExecLogsDocument, ExecAppModsDocument, ExecModBuildDocument, ExecModBuildStatusDocument, ExecModDeleteDocument, ExecModDeployDocument, ExecModInstallDocument, ExecModListingsDocument, ExecModLogsDocument, ExecModPublishDocument, ExecModScope, ExecModSetEnabledDocument, ExecModSetSwitchDocument, ExecModStarterDocument, ExecModSwitchesDocument, ExecModUnpublishDocument, ExecModsDocument, ExecMyModsDocument, ExecSetEnabledDocument, ExecStartersDocument, ExecVersionsDocument, } from '../generated/graphql.js';
|
|
2
|
+
import { CrowdyError, CrowdyProtocolError } from '../errors.js';
|
|
3
|
+
import { ExecActivateVersionDocument, ExecAppStatusDocument, ExecBuildDocument, ExecBuildStatusDocument, ExecConnectAsDeveloperDocument, ExecConnectDocument, ExecConsentClientModDocument, ExecDeployDocument, ExecEndpointStatsDocument, ExecGridClientModsDocument, ExecInstancesDocument, ExecLogsDocument, ExecAppModsDocument, ExecModBuildDocument, ExecModBuildStatusDocument, ExecModClientArtifactDocument, ExecModClientBuildDocument, ExecModClientDeleteDocument, ExecModClientDeployDocument, ExecModDeleteDocument, ExecModDeployDocument, ExecModInstallDocument, ExecModListingsDocument, ExecModLogsDocument, ExecModPublishDocument, ExecModScope, ExecModSetEnabledDocument, ExecModSetSwitchDocument, ExecModStarterDocument, ExecModSwitchesDocument, ExecModUnpublishDocument, ExecModsDocument, ExecMyModsDocument, ExecSetEnabledDocument, ExecStartersDocument, ExecTrustAuthorDocument, ExecVersionsDocument, } from '../generated/graphql.js';
|
|
4
4
|
export { ExecModScope };
|
|
5
5
|
/**
|
|
6
6
|
* ck-exec, the hub-and-spoke execution service (dev-tier preview).
|
|
@@ -519,10 +519,19 @@ function base64(bytes) {
|
|
|
519
519
|
}
|
|
520
520
|
return btoa(s);
|
|
521
521
|
}
|
|
522
|
+
function fromBase64(b64) {
|
|
523
|
+
const binary = atob(b64);
|
|
524
|
+
const out = new Uint8Array(binary.length);
|
|
525
|
+
for (let i = 0; i < binary.length; i++)
|
|
526
|
+
out[i] = binary.charCodeAt(i);
|
|
527
|
+
return out;
|
|
528
|
+
}
|
|
522
529
|
async function sha256Hex(bytes) {
|
|
523
530
|
const d = new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));
|
|
524
531
|
return Array.from(d, (x) => x.toString(16).padStart(2, '0')).join('');
|
|
525
532
|
}
|
|
533
|
+
/** The CLIENT ABI version the player runtime's glue implements (crowdy-client-sdk `ABI_VERSION`). */
|
|
534
|
+
export const EXEC_CLIENT_ABI_VERSION = 0;
|
|
526
535
|
/** The node type players call a mod by: `mod:<name>`, keyed by its grid id. */
|
|
527
536
|
export function execModType(name) {
|
|
528
537
|
return `mod:${name}`;
|
|
@@ -537,18 +546,46 @@ function parseManifest(json) {
|
|
|
537
546
|
return null;
|
|
538
547
|
}
|
|
539
548
|
}
|
|
549
|
+
function parseCapabilities(json) {
|
|
550
|
+
if (!json)
|
|
551
|
+
return null;
|
|
552
|
+
try {
|
|
553
|
+
const parsed = JSON.parse(json);
|
|
554
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
555
|
+
? parsed
|
|
556
|
+
: null;
|
|
557
|
+
}
|
|
558
|
+
catch {
|
|
559
|
+
return null;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
540
562
|
function strip(v) {
|
|
541
563
|
const { __typename: _, ...rest } = v;
|
|
542
564
|
return rest;
|
|
543
565
|
}
|
|
544
566
|
function build(b) {
|
|
545
567
|
const { __typename: _, artifacts, ...rest } = b;
|
|
546
|
-
return {
|
|
568
|
+
return {
|
|
569
|
+
...rest,
|
|
570
|
+
artifacts: artifacts.map((a) => ({
|
|
571
|
+
...strip(a),
|
|
572
|
+
capabilitySummary: parseCapabilities(a.capabilitySummaryJson),
|
|
573
|
+
})),
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
function listing(l) {
|
|
577
|
+
return { ...strip(l), clientCapabilitySummary: parseCapabilities(l.clientCapabilitySummaryJson) };
|
|
578
|
+
}
|
|
579
|
+
function crateInput(crate) {
|
|
580
|
+
const files = Array.isArray(crate.files)
|
|
581
|
+
? crate.files
|
|
582
|
+
: Object.entries(crate.files).map(([path, content]) => ({ path, content }));
|
|
583
|
+
return { name: crate.name, files };
|
|
547
584
|
}
|
|
548
585
|
/**
|
|
549
586
|
* `client.exec`: connecting players to ck-exec, building and deploying an app's nodes (and
|
|
550
|
-
* the starter packs),
|
|
551
|
-
*
|
|
587
|
+
* the starter packs), operating them (logs, instances, versions, rollback, the kill switch,
|
|
588
|
+
* developer connections), and players' mods with their CLIENT halves.
|
|
552
589
|
*/
|
|
553
590
|
export class ExecAPI {
|
|
554
591
|
constructor(graphql) {
|
|
@@ -698,21 +735,15 @@ export class ExecAPI {
|
|
|
698
735
|
* player. Requires `write_server_code` in the app.
|
|
699
736
|
*/
|
|
700
737
|
async modBuild(appId, crate) {
|
|
701
|
-
const
|
|
702
|
-
? crate.files
|
|
703
|
-
: Object.entries(crate.files).map(([path, content]) => ({ path, content }));
|
|
704
|
-
const data = await this.graphql.request(ExecModBuildDocument, {
|
|
705
|
-
appId,
|
|
706
|
-
crate: { name: crate.name, files },
|
|
707
|
-
});
|
|
738
|
+
const data = await this.graphql.request(ExecModBuildDocument, { appId, crate: crateInput(crate) });
|
|
708
739
|
return build(data.execModBuild);
|
|
709
740
|
}
|
|
710
|
-
/** A mod build of yours. */
|
|
741
|
+
/** A mod build of yours: a mod's (`kind` `exec`) or a CLIENT half's (`kind` `client`). */
|
|
711
742
|
async modBuildStatus(appId, buildId) {
|
|
712
743
|
const data = await this.graphql.request(ExecModBuildStatusDocument, { appId, buildId });
|
|
713
744
|
return build(data.execModBuildStatus);
|
|
714
745
|
}
|
|
715
|
-
/** Polls a mod build until it succeeds or fails, like {@link waitForBuild}. */
|
|
746
|
+
/** Polls a mod build, server or CLIENT, until it succeeds or fails, like {@link waitForBuild}. */
|
|
716
747
|
async waitForModBuild(appId, buildId, options = {}) {
|
|
717
748
|
const until = Date.now() + (options.timeoutMs ?? 600000);
|
|
718
749
|
for (;;) {
|
|
@@ -764,19 +795,22 @@ export class ExecAPI {
|
|
|
764
795
|
/** Publishes a mod of yours, at its current version, for other grid owners to install. */
|
|
765
796
|
async modPublish(appId, gridId, name, title, description) {
|
|
766
797
|
const data = await this.graphql.request(ExecModPublishDocument, { appId, gridId, name, title, description });
|
|
767
|
-
return
|
|
798
|
+
return listing(data.execModPublish);
|
|
768
799
|
}
|
|
769
|
-
/** The app's listed mods, most installed first. */
|
|
800
|
+
/** The app's listed mods, most installed first, each with the CLIENT half it carries, if any. */
|
|
770
801
|
async modListings(appId) {
|
|
771
802
|
const data = await this.graphql.request(ExecModListingsDocument, { appId });
|
|
772
|
-
return data.execModListings.map(
|
|
803
|
+
return data.execModListings.map(listing);
|
|
773
804
|
}
|
|
774
805
|
/** Delists a listing you published; installed copies keep running. */
|
|
775
806
|
async modUnpublish(appId, listingId) {
|
|
776
807
|
const data = await this.graphql.request(ExecModUnpublishDocument, { appId, listingId });
|
|
777
808
|
return data.execModUnpublish;
|
|
778
809
|
}
|
|
779
|
-
/**
|
|
810
|
+
/**
|
|
811
|
+
* Installs a listing onto a grid you own as your own mod, switched off, with the listing's
|
|
812
|
+
* CLIENT half if it has one; visitors, you too, consent to that CLIENT half afresh.
|
|
813
|
+
*/
|
|
780
814
|
async modInstall(appId, gridId, name, listingId) {
|
|
781
815
|
const data = await this.graphql.request(ExecModInstallDocument, { appId, gridId, name, listingId });
|
|
782
816
|
return strip(data.execModInstall);
|
|
@@ -800,6 +834,134 @@ export class ExecAPI {
|
|
|
800
834
|
const data = await this.graphql.request(ExecModSetSwitchDocument, { appId, scope, off, ...options });
|
|
801
835
|
return data.execModSetSwitch.map(strip);
|
|
802
836
|
}
|
|
837
|
+
// ---- CLIENT halves: a mod's browser half ----
|
|
838
|
+
/**
|
|
839
|
+
* Builds the CLIENT half of a mod from one `crowdy-client-sdk` crate: compiled for
|
|
840
|
+
* `wasm32-unknown-unknown` in the build sandbox, fuel-metered and optimized there, checked
|
|
841
|
+
* against the CLIENT ABI and at most 512 KiB, with its capability summary derived from the
|
|
842
|
+
* module. Its `Cargo.toml` may have only `[package]`, `[lib]` as a cdylib, `[dependencies]` on
|
|
843
|
+
* `crowdy-client-sdk`, `serde` and `serde_json`, and `[package.metadata.crowdy]
|
|
844
|
+
* tick_interval_ms`. Returns at once with the build queued (`kind` `client`); wait with
|
|
845
|
+
* {@link waitForModBuild}, then attach it with {@link modClientDeploy}. One build, server or
|
|
846
|
+
* CLIENT, at a time per player. Requires `write_client_code` in the app.
|
|
847
|
+
*/
|
|
848
|
+
async modClientBuild(appId, crate) {
|
|
849
|
+
const data = await this.graphql.request(ExecModClientBuildDocument, { appId, crate: crateInput(crate) });
|
|
850
|
+
return build(data.execModClientBuild);
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Attaches a succeeded CLIENT build of yours to your mod `name` on a grid you own, replacing
|
|
854
|
+
* the CLIENT half it had; its `clientVersion` rises by one. The mod must exist and run as
|
|
855
|
+
* you. A visitor's consent carries over only while the capability hash is unchanged.
|
|
856
|
+
* Requires being the grid's owner, `write_client_code` on the app tier and the grid, and the
|
|
857
|
+
* app's code admission admitting the new CLIENT version.
|
|
858
|
+
*/
|
|
859
|
+
async modClientDeploy(appId, gridId, name, buildId) {
|
|
860
|
+
const data = await this.graphql.request(ExecModClientDeployDocument, { appId, gridId, name, buildId });
|
|
861
|
+
const c = strip(data.execModClientDeploy);
|
|
862
|
+
return { ...c, capabilitySummary: parseCapabilities(c.capabilitySummaryJson) };
|
|
863
|
+
}
|
|
864
|
+
/** Detaches the CLIENT half of a mod on your grid, with every visitor's consent to it; the mod keeps running. */
|
|
865
|
+
async modClientDelete(appId, gridId, name) {
|
|
866
|
+
const data = await this.graphql.request(ExecModClientDeleteDocument, { appId, gridId, name });
|
|
867
|
+
return data.execModClientDelete;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* The CLIENT halves a grid serves: those of its mods that are switched on, not stopped by the
|
|
871
|
+
* kill ladder, running as the grid's owner and admitted. Each has its capability summary and
|
|
872
|
+
* hash and whether you consented to it, and its author's union summary and hash and whether
|
|
873
|
+
* you trust them. Prompt once per author ({@link trustAuthor}) or per CLIENT half
|
|
874
|
+
* ({@link consentClientMod}), fetch with {@link modClientArtifactBytes}, cache by `digest`, and
|
|
875
|
+
* poll this to stop the CLIENT halves that are no longer listed or whose digest changed:
|
|
876
|
+
* `ExecClientHalves` does all of that for a game. Requires access to the app.
|
|
877
|
+
*/
|
|
878
|
+
async gridClientMods(appId, gridId) {
|
|
879
|
+
const data = await this.graphql.request(ExecGridClientModsDocument, { appId, gridId });
|
|
880
|
+
return data.execGridClientMods.map((m) => ({
|
|
881
|
+
...strip(m),
|
|
882
|
+
capabilitySummary: parseCapabilities(m.capabilitySummaryJson),
|
|
883
|
+
authorCapabilitySummary: parseCapabilities(m.authorCapabilitySummaryJson),
|
|
884
|
+
}));
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Consents to run one mod's CLIENT half in your browser at `capabilityHash`, the one
|
|
888
|
+
* {@link gridClientMods} showed you. A CLIENT half whose capabilities change carries a new hash,
|
|
889
|
+
* and the consent stops holding until you consent again; a hash that is not the current one
|
|
890
|
+
* is refused as `CONFLICT` (`CrowdyGraphQLError.code`). Requires access to the app.
|
|
891
|
+
*/
|
|
892
|
+
async consentClientMod(appId, modId, capabilityHash) {
|
|
893
|
+
const data = await this.graphql.request(ExecConsentClientModDocument, { appId, modId, capabilityHash });
|
|
894
|
+
return data.execConsentClientMod;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Trusts one author's CLIENT halves on a grid you stand in, at the hash of their union
|
|
898
|
+
* (`authorCapabilityHash`): the trust covers their CLIENT halves there while the union is no
|
|
899
|
+
* wider, and consents to each current one at its own hash. A hash that is not the current one
|
|
900
|
+
* is `CONFLICT`; not standing in the grid, or an author with nothing served there, is
|
|
901
|
+
* `NOT_FOUND`. Requires access to the app.
|
|
902
|
+
*/
|
|
903
|
+
async trustAuthor(appId, gridId, authorId, capabilityHash) {
|
|
904
|
+
const data = await this.graphql.request(ExecTrustAuthorDocument, { appId, gridId, authorId, capabilityHash });
|
|
905
|
+
return data.execTrustAuthor;
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* A served CLIENT half's module, base64, with what the broker needs to run it. Served only to a
|
|
909
|
+
* player holding `run_client_code` in the app, standing in the mod's grid now, who consented
|
|
910
|
+
* to it at its current hash or trusts its author at a union no wider; every refusal is
|
|
911
|
+
* `NOT_FOUND`. At most 12 fetches a minute per player and mod on each API instance
|
|
912
|
+
* (`RATE_LIMITED`): the module never changes for its digest, so cache it by `digest`.
|
|
913
|
+
*/
|
|
914
|
+
async modClientArtifact(appId, modId) {
|
|
915
|
+
const data = await this.graphql.request(ExecModClientArtifactDocument, { appId, modId });
|
|
916
|
+
const a = strip(data.execModClientArtifact);
|
|
917
|
+
return { ...a, capabilitySummary: parseCapabilities(a.capabilitySummaryJson) };
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* {@link modClientArtifact} decoded for `PlayerCodeBroker`: the module's bytes, their SHA-256
|
|
921
|
+
* recomputed with WebCrypto, and the fuel budget as a bigint; the exec twin of
|
|
922
|
+
* `marketplace.clientArtifactBytes`. Bytes that differ from `digest`, a module built for a
|
|
923
|
+
* CLIENT ABI other than {@link EXEC_CLIENT_ABI_VERSION}, or a capability summary that does not
|
|
924
|
+
* parse are refused with a {@link CrowdyProtocolError} and never returned. Start the broker
|
|
925
|
+
* with `engine: 'ck-exec'`, `artifactHash: digest`, `fuelPerDispatch`, `tickIntervalMs` and
|
|
926
|
+
* `consentedHostCalls: capabilitySummary.hostFunctions`.
|
|
927
|
+
*/
|
|
928
|
+
async modClientArtifactBytes(appId, modId) {
|
|
929
|
+
const a = await this.modClientArtifact(appId, modId);
|
|
930
|
+
if (a.abiVersion !== EXEC_CLIENT_ABI_VERSION) {
|
|
931
|
+
throw new CrowdyProtocolError({
|
|
932
|
+
message: `CLIENT half of mod ${a.modId} is built for CLIENT ABI ${a.abiVersion}; this SDK runs ABI ${EXEC_CLIENT_ABI_VERSION}`,
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
const capabilitySummary = a.capabilitySummary;
|
|
936
|
+
if (!capabilitySummary || !Array.isArray(capabilitySummary.hostFunctions)) {
|
|
937
|
+
throw new CrowdyProtocolError({
|
|
938
|
+
message: `CLIENT half of mod ${a.modId}: its capability summary does not parse, so nothing bounds its host calls`,
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
const bytes = fromBase64(a.wasmBase64);
|
|
942
|
+
const digest = a.digest.toLowerCase();
|
|
943
|
+
const actual = await sha256Hex(bytes);
|
|
944
|
+
if (actual !== digest) {
|
|
945
|
+
throw new CrowdyProtocolError({
|
|
946
|
+
message: `CLIENT half of mod ${a.modId}: the module's SHA-256 is ${actual}, not the digest ${digest} it was served with`,
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
return {
|
|
950
|
+
modId: a.modId,
|
|
951
|
+
name: a.name,
|
|
952
|
+
gridId: a.gridId,
|
|
953
|
+
clientVersion: a.clientVersion,
|
|
954
|
+
bytes: bytes.buffer,
|
|
955
|
+
digest,
|
|
956
|
+
sizeBytes: a.sizeBytes,
|
|
957
|
+
fuelPerDispatch: BigInt(a.fuelPerDispatch),
|
|
958
|
+
tickIntervalMs: a.tickIntervalMs,
|
|
959
|
+
capabilitySummaryJson: a.capabilitySummaryJson,
|
|
960
|
+
capabilitySummary,
|
|
961
|
+
capabilityHash: a.capabilityHash,
|
|
962
|
+
abiVersion: a.abiVersion,
|
|
963
|
+
};
|
|
964
|
+
}
|
|
803
965
|
/** A host for this player and its connect token (valid for about a minute). */
|
|
804
966
|
async endpoint(appId, options = {}) {
|
|
805
967
|
const data = await this.graphql.request(ExecConnectDocument, {
|
package/dist/domains/host.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { type GameHostQuery, type AmIGameHostQuery, type ActorHeartbeatMutation
|
|
|
8
8
|
* first wins). {@link heartbeat} refreshes the caller's actor freshness (keeping
|
|
9
9
|
* them host-eligible) and returns the freshly-elected host in one round-trip —
|
|
10
10
|
* call it on an interval shorter than the server's freshness window.
|
|
11
|
-
* {@link amIHost} is a UI convenience (not authoritative for mutations —
|
|
12
|
-
*
|
|
11
|
+
* {@link amIHost} is a UI convenience (not authoritative for mutations — a hub
|
|
12
|
+
* decides that from the caller). All require a valid session;
|
|
13
13
|
* `appId` is a `BigInt` decimal string.
|
|
14
14
|
*
|
|
15
15
|
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session.
|
|
@@ -28,7 +28,7 @@ export declare class HostAPI {
|
|
|
28
28
|
/**
|
|
29
29
|
* Return whether the authenticated caller is the currently elected host for
|
|
30
30
|
* the app. Convenience for UI only — not authoritative for server mutations
|
|
31
|
-
* (
|
|
31
|
+
* (a hub decides those from the caller).
|
|
32
32
|
*
|
|
33
33
|
* @param appId - The app to check host election for.
|
|
34
34
|
* @returns `true` if the caller is the elected host; otherwise `false`.
|
package/dist/domains/host.js
CHANGED
|
@@ -7,8 +7,8 @@ import { GameHostDocument, AmIGameHostDocument, ActorHeartbeatDocument, } from '
|
|
|
7
7
|
* first wins). {@link heartbeat} refreshes the caller's actor freshness (keeping
|
|
8
8
|
* them host-eligible) and returns the freshly-elected host in one round-trip —
|
|
9
9
|
* call it on an interval shorter than the server's freshness window.
|
|
10
|
-
* {@link amIHost} is a UI convenience (not authoritative for mutations —
|
|
11
|
-
*
|
|
10
|
+
* {@link amIHost} is a UI convenience (not authoritative for mutations — a hub
|
|
11
|
+
* decides that from the caller). All require a valid session;
|
|
12
12
|
* `appId` is a `BigInt` decimal string.
|
|
13
13
|
*
|
|
14
14
|
* @throws {CrowdyGraphQLError} `UNAUTHENTICATED` without a session.
|
|
@@ -31,7 +31,7 @@ export class HostAPI {
|
|
|
31
31
|
/**
|
|
32
32
|
* Return whether the authenticated caller is the currently elected host for
|
|
33
33
|
* the app. Convenience for UI only — not authoritative for server mutations
|
|
34
|
-
* (
|
|
34
|
+
* (a hub decides those from the caller).
|
|
35
35
|
*
|
|
36
36
|
* @param appId - The app to check host election for.
|
|
37
37
|
* @returns `true` if the caller is the elected host; otherwise `false`.
|
|
@@ -1,65 +1,17 @@
|
|
|
1
1
|
import type { GraphQLClient } from '../client.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type MarketplaceGridClaimPolicyQuery, type MarketplaceGridClaimPolicyQueryVariables, type MarketplaceGridClaimRequestsQuery, type MarketplaceGridClaimRequestsQueryVariables, type MarketplaceClaimGridOwnershipMutation, type MarketplaceClaimGridOwnershipMutationVariables, type MarketplaceClaimGridChunkMutation, type MarketplaceClaimGridChunkMutationVariables, type MarketplaceReleaseClaimedGridMutation, type MarketplaceReleaseClaimedGridMutationVariables, type MarketplaceDecideGridClaimMutation, type MarketplaceDecideGridClaimMutationVariables, type MarketplaceIssueGridClaimInviteMutationVariables, type MarketplaceAdmissionQueueQuery, type MarketplaceAdmissionQueueQueryVariables, type MarketplaceAppListingsQuery, type MarketplaceAppListingsQueryVariables, type MarketplaceAppAcquisitionsQuery, type MarketplaceAppAcquisitionsQueryVariables, type MarketplaceTransferListingMutation, type MarketplaceTransferListingMutationVariables, type MarketplaceSetListingStatusMutation, type MarketplaceSetListingStatusMutationVariables, type MarketplaceSetGridClaimPolicyMutation, type MarketplaceSetGridClaimPolicyMutationVariables } from '../generated/graphql.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* `client.marketplace
|
|
6
|
-
*
|
|
7
|
-
* administration, ownership transfer, claim-policy config).
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* an acquisition is an entitlement write, and the paid modes ship with P4b.
|
|
12
|
-
* Publishing snapshots artifact hashes and the DERIVED capability summary —
|
|
13
|
-
* never source; installs consent to the summary's hash.
|
|
4
|
+
* Grid claims and the app's player-code administration — exposed as
|
|
5
|
+
* `client.marketplace`: the D4 grid claim flows (policy, requests, chunk and
|
|
6
|
+
* ownership claims, invites) and studio moderation (admission queue, catalog
|
|
7
|
+
* administration, ownership transfer, claim-policy config). The player-facing
|
|
8
|
+
* listings (publish, acquire, install) and grid-attached client mods went with
|
|
9
|
+
* legacy player compute; ck-exec mods publish and install with
|
|
10
|
+
* `client.exec.modPublish` / `modInstall`.
|
|
14
11
|
*/
|
|
15
12
|
export declare class MarketplaceAPI {
|
|
16
13
|
private readonly game;
|
|
17
14
|
constructor(game: GraphQLClient);
|
|
18
|
-
/** Browse the app's active listings with admission standing per listing. */
|
|
19
|
-
listings(variables: MarketplaceListingsQueryVariables): Promise<MarketplaceListingsQuery['playerCodeListings']>;
|
|
20
|
-
/** Published versions of one listing (capability summaries + consent hashes). */
|
|
21
|
-
versions(variables: MarketplaceListingVersionsQueryVariables): Promise<MarketplaceListingVersionsQuery['playerCodeListingVersions']>;
|
|
22
|
-
/** The caller's entitlements in this app. */
|
|
23
|
-
myAcquisitions(variables: MarketplaceMyAcquisitionsQueryVariables): Promise<MarketplaceMyAcquisitionsQuery['myPlayerCodeAcquisitions']>;
|
|
24
|
-
/** The caller's active installs in this app. */
|
|
25
|
-
myInstalls(variables: MarketplaceMyInstallsQueryVariables): Promise<MarketplaceMyInstallsQuery['myPlayerCodeInstalls']>;
|
|
26
|
-
/** Create a listing (personal, or org-owned via input.ownerOrgId). */
|
|
27
|
-
publishListing(variables: MarketplacePublishListingMutationVariables): Promise<MarketplacePublishListingMutation['publishPlayerCode']>;
|
|
28
|
-
/** Publish an immutable version from compiled module versions (hashes only). */
|
|
29
|
-
publishVersion(variables: MarketplacePublishVersionMutationVariables): Promise<MarketplacePublishVersionMutation['publishPlayerCodeVersion']>;
|
|
30
|
-
/** Free acquisition (entitlement write; idempotent per listing+caller). */
|
|
31
|
-
acquire(variables: MarketplaceAcquireMutationVariables): Promise<MarketplaceAcquireMutation['acquirePlayerCode']>;
|
|
32
|
-
/**
|
|
33
|
-
* Install an acquisition after consenting to the version's capability
|
|
34
|
-
* hash. Server/bundled listings need an owned target gridId.
|
|
35
|
-
*/
|
|
36
|
-
install(variables: MarketplaceInstallMutationVariables): Promise<MarketplaceInstallMutation['installPlayerCode']>;
|
|
37
|
-
/** Remove instances/attachments/fetch rights; the acquisition is retained. */
|
|
38
|
-
uninstall(variables: MarketplaceUninstallMutationVariables): Promise<boolean>;
|
|
39
|
-
/** Client mods attached to a grid, with the caller's consent state. */
|
|
40
|
-
gridClientMods(variables: MarketplaceGridClientModsQueryVariables): Promise<MarketplaceGridClientModsQuery['gridClientMods']>;
|
|
41
|
-
/** Consent to one attachment's exact capability hash (per player). */
|
|
42
|
-
consentGridClientMod(variables: MarketplaceConsentGridClientModMutationVariables): Promise<boolean>;
|
|
43
|
-
/**
|
|
44
|
-
* Trust one author's active attachments in a grid at the exact aggregate
|
|
45
|
-
* capability hash returned by `gridClientMods`. Capability widening changes
|
|
46
|
-
* the hash and requires another explicit call.
|
|
47
|
-
*/
|
|
48
|
-
trustGridAuthor(variables: MarketplaceTrustGridAuthorMutationVariables): Promise<MarketplaceTrustGridAuthorMutation['trustGridAuthor']>;
|
|
49
|
-
/** Fetch an acquired/attached listing's client artifact (base64 + metadata). */
|
|
50
|
-
clientArtifact(variables: MarketplaceClientArtifactQueryVariables): Promise<MarketplaceClientArtifactQuery['playerCodeClientArtifact']>;
|
|
51
|
-
/**
|
|
52
|
-
* Fetch and decode a client artifact into broker inputs (bytes, content
|
|
53
|
-
* hash, per-dispatch fuel budget) — the marketplace twin of
|
|
54
|
-
* `playerCompute.artifactBytes` for acquired and grid-attached mods.
|
|
55
|
-
*/
|
|
56
|
-
clientArtifactBytes(variables: MarketplaceClientArtifactQueryVariables): Promise<{
|
|
57
|
-
bytes: ArrayBuffer;
|
|
58
|
-
artifactHash: string;
|
|
59
|
-
fuelPerDispatch: bigint;
|
|
60
|
-
contractJson: string | null;
|
|
61
|
-
versionId: string;
|
|
62
|
-
}>;
|
|
63
15
|
/** The app's claim policy (self_claim / approval / invite / marketplace_only). */
|
|
64
16
|
gridClaimPolicy(variables: MarketplaceGridClaimPolicyQueryVariables): Promise<MarketplaceGridClaimPolicyQuery['gridClaimPolicy']>;
|
|
65
17
|
/** Pending claim requests (approvers see the app queue; players their own). */
|
|
@@ -91,8 +43,7 @@ export declare class MarketplaceAPI {
|
|
|
91
43
|
transferListing(variables: MarketplaceTransferListingMutationVariables): Promise<MarketplaceTransferListingMutation['transferPlayerCodeListing']>;
|
|
92
44
|
/**
|
|
93
45
|
* Catalog status: DELISTED/ACTIVE are owner actions; KILLED is the studio
|
|
94
|
-
* catalog kill
|
|
95
|
-
* also disable running installs fleet-wide.
|
|
46
|
+
* catalog kill.
|
|
96
47
|
*/
|
|
97
48
|
setListingStatus(variables: MarketplaceSetListingStatusMutationVariables): Promise<MarketplaceSetListingStatusMutation['setPlayerCodeListingStatus']>;
|
|
98
49
|
/** Configure the app's D4 grid claim policy (manage_apps). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marketplace.d.ts","sourceRoot":"","sources":["../../src/domains/marketplace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"marketplace.d.ts","sourceRoot":"","sources":["../../src/domains/marketplace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAcL,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAC7C,KAAK,iCAAiC,EACtC,KAAK,0CAA0C,EAC/C,KAAK,qCAAqC,EAC1C,KAAK,8CAA8C,EACnD,KAAK,iCAAiC,EACtC,KAAK,0CAA0C,EAC/C,KAAK,qCAAqC,EAC1C,KAAK,8CAA8C,EACnD,KAAK,kCAAkC,EACvC,KAAK,2CAA2C,EAChD,KAAK,gDAAgD,EACrD,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAC5C,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EACzC,KAAK,+BAA+B,EACpC,KAAK,wCAAwC,EAC7C,KAAK,kCAAkC,EACvC,KAAK,2CAA2C,EAChD,KAAK,mCAAmC,EACxC,KAAK,4CAA4C,EACjD,KAAK,qCAAqC,EAC1C,KAAK,8CAA8C,EACpD,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAIhD,kFAAkF;IAC5E,eAAe,CACnB,SAAS,EAAE,wCAAwC,GAClD,OAAO,CAAC,+BAA+B,CAAC,iBAAiB,CAAC,CAAC;IAQ9D,+EAA+E;IACzE,iBAAiB,CACrB,SAAS,EAAE,0CAA0C,GACpD,OAAO,CAAC,iCAAiC,CAAC,mBAAmB,CAAC,CAAC;IAQlE,yEAAyE;IACnE,kBAAkB,CACtB,SAAS,EAAE,8CAA8C,GACxD,OAAO,CAAC,qCAAqC,CAAC,oBAAoB,CAAC,CAAC;IAQvE;;;;OAIG;IACG,cAAc,CAClB,SAAS,EAAE,0CAA0C,GACpD,OAAO,CAAC,iCAAiC,CAAC,gBAAgB,CAAC,CAAC;IAQ/D;;;OAGG;IACG,kBAAkB,CACtB,SAAS,EAAE,8CAA8C,GACxD,OAAO,CAAC,qCAAqC,CAAC,oBAAoB,CAAC,CAAC;IAQvE,iEAAiE;IAC3D,eAAe,CACnB,SAAS,EAAE,2CAA2C,GACrD,OAAO,CAAC,kCAAkC,CAAC,iBAAiB,CAAC,CAAC;IAQjE,oEAAoE;IAC9D,oBAAoB,CACxB,SAAS,EAAE,gDAAgD,GAC1D,OAAO,CAAC,OAAO,CAAC;IAWnB,qEAAqE;IAC/D,cAAc,CAClB,SAAS,EAAE,uCAAuC,GACjD,OAAO,CAAC,8BAA8B,CAAC,uBAAuB,CAAC,CAAC;IAQnE,gFAAgF;IAC1E,WAAW,CACf,SAAS,EAAE,oCAAoC,GAC9C,OAAO,CAAC,2BAA2B,CAAC,uBAAuB,CAAC,CAAC;IAQhE,uDAAuD;IACjD,eAAe,CACnB,SAAS,EAAE,wCAAwC,GAClD,OAAO,CAAC,+BAA+B,CAAC,2BAA2B,CAAC,CAAC;IASxE,sDAAsD;IAChD,eAAe,CACnB,SAAS,EAAE,2CAA2C,GACrD,OAAO,CAAC,kCAAkC,CAAC,2BAA2B,CAAC,CAAC;IAS3E;;;OAGG;IACG,gBAAgB,CACpB,SAAS,EAAE,4CAA4C,GACtD,OAAO,CAAC,mCAAmC,CAAC,4BAA4B,CAAC,CAAC;IAS7E,8DAA8D;IACxD,kBAAkB,CACtB,SAAS,EAAE,8CAA8C,GACxD,OAAO,CAAC,qCAAqC,CAAC,uBAAuB,CAAC,CAAC;CAQ3E"}
|
|
@@ -1,113 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MarketplaceGridClaimPolicyDocument, MarketplaceGridClaimRequestsDocument, MarketplaceClaimGridOwnershipDocument, MarketplaceClaimGridChunkDocument, MarketplaceReleaseClaimedGridDocument, MarketplaceDecideGridClaimDocument, MarketplaceIssueGridClaimInviteDocument, MarketplaceAdmissionQueueDocument, MarketplaceAppListingsDocument, MarketplaceAppAcquisitionsDocument, MarketplaceTransferListingDocument, MarketplaceSetListingStatusDocument, MarketplaceSetGridClaimPolicyDocument, } from '../generated/graphql.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* `client.marketplace
|
|
5
|
-
*
|
|
6
|
-
* administration, ownership transfer, claim-policy config).
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* an acquisition is an entitlement write, and the paid modes ship with P4b.
|
|
11
|
-
* Publishing snapshots artifact hashes and the DERIVED capability summary —
|
|
12
|
-
* never source; installs consent to the summary's hash.
|
|
3
|
+
* Grid claims and the app's player-code administration — exposed as
|
|
4
|
+
* `client.marketplace`: the D4 grid claim flows (policy, requests, chunk and
|
|
5
|
+
* ownership claims, invites) and studio moderation (admission queue, catalog
|
|
6
|
+
* administration, ownership transfer, claim-policy config). The player-facing
|
|
7
|
+
* listings (publish, acquire, install) and grid-attached client mods went with
|
|
8
|
+
* legacy player compute; ck-exec mods publish and install with
|
|
9
|
+
* `client.exec.modPublish` / `modInstall`.
|
|
13
10
|
*/
|
|
14
11
|
export class MarketplaceAPI {
|
|
15
12
|
constructor(game) {
|
|
16
13
|
this.game = game;
|
|
17
14
|
}
|
|
18
|
-
// -- Store ---------------------------------------------------------
|
|
19
|
-
/** Browse the app's active listings with admission standing per listing. */
|
|
20
|
-
async listings(variables) {
|
|
21
|
-
const data = await this.game.request(MarketplaceListingsDocument, variables);
|
|
22
|
-
return data.playerCodeListings;
|
|
23
|
-
}
|
|
24
|
-
/** Published versions of one listing (capability summaries + consent hashes). */
|
|
25
|
-
async versions(variables) {
|
|
26
|
-
const data = await this.game.request(MarketplaceListingVersionsDocument, variables);
|
|
27
|
-
return data.playerCodeListingVersions;
|
|
28
|
-
}
|
|
29
|
-
/** The caller's entitlements in this app. */
|
|
30
|
-
async myAcquisitions(variables) {
|
|
31
|
-
const data = await this.game.request(MarketplaceMyAcquisitionsDocument, variables);
|
|
32
|
-
return data.myPlayerCodeAcquisitions;
|
|
33
|
-
}
|
|
34
|
-
/** The caller's active installs in this app. */
|
|
35
|
-
async myInstalls(variables) {
|
|
36
|
-
const data = await this.game.request(MarketplaceMyInstallsDocument, variables);
|
|
37
|
-
return data.myPlayerCodeInstalls;
|
|
38
|
-
}
|
|
39
|
-
/** Create a listing (personal, or org-owned via input.ownerOrgId). */
|
|
40
|
-
async publishListing(variables) {
|
|
41
|
-
const data = await this.game.request(MarketplacePublishListingDocument, variables);
|
|
42
|
-
return data.publishPlayerCode;
|
|
43
|
-
}
|
|
44
|
-
/** Publish an immutable version from compiled module versions (hashes only). */
|
|
45
|
-
async publishVersion(variables) {
|
|
46
|
-
const data = await this.game.request(MarketplacePublishVersionDocument, variables);
|
|
47
|
-
return data.publishPlayerCodeVersion;
|
|
48
|
-
}
|
|
49
|
-
/** Free acquisition (entitlement write; idempotent per listing+caller). */
|
|
50
|
-
async acquire(variables) {
|
|
51
|
-
const data = await this.game.request(MarketplaceAcquireDocument, variables);
|
|
52
|
-
return data.acquirePlayerCode;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Install an acquisition after consenting to the version's capability
|
|
56
|
-
* hash. Server/bundled listings need an owned target gridId.
|
|
57
|
-
*/
|
|
58
|
-
async install(variables) {
|
|
59
|
-
const data = await this.game.request(MarketplaceInstallDocument, variables);
|
|
60
|
-
return data.installPlayerCode;
|
|
61
|
-
}
|
|
62
|
-
/** Remove instances/attachments/fetch rights; the acquisition is retained. */
|
|
63
|
-
async uninstall(variables) {
|
|
64
|
-
const data = await this.game.request(MarketplaceUninstallDocument, variables);
|
|
65
|
-
return data.uninstallPlayerCode;
|
|
66
|
-
}
|
|
67
|
-
// -- Grid-attached client mods (D2) --------------------------------------------
|
|
68
|
-
/** Client mods attached to a grid, with the caller's consent state. */
|
|
69
|
-
async gridClientMods(variables) {
|
|
70
|
-
const data = await this.game.request(MarketplaceGridClientModsDocument, variables);
|
|
71
|
-
return data.gridClientMods;
|
|
72
|
-
}
|
|
73
|
-
/** Consent to one attachment's exact capability hash (per player). */
|
|
74
|
-
async consentGridClientMod(variables) {
|
|
75
|
-
const data = await this.game.request(MarketplaceConsentGridClientModDocument, variables);
|
|
76
|
-
return data.consentGridClientMod;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Trust one author's active attachments in a grid at the exact aggregate
|
|
80
|
-
* capability hash returned by `gridClientMods`. Capability widening changes
|
|
81
|
-
* the hash and requires another explicit call.
|
|
82
|
-
*/
|
|
83
|
-
async trustGridAuthor(variables) {
|
|
84
|
-
const data = await this.game.request(MarketplaceTrustGridAuthorDocument, variables);
|
|
85
|
-
return data.trustGridAuthor;
|
|
86
|
-
}
|
|
87
|
-
/** Fetch an acquired/attached listing's client artifact (base64 + metadata). */
|
|
88
|
-
async clientArtifact(variables) {
|
|
89
|
-
const data = await this.game.request(MarketplaceClientArtifactDocument, variables);
|
|
90
|
-
return data.playerCodeClientArtifact;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Fetch and decode a client artifact into broker inputs (bytes, content
|
|
94
|
-
* hash, per-dispatch fuel budget) — the marketplace twin of
|
|
95
|
-
* `playerCompute.artifactBytes` for acquired and grid-attached mods.
|
|
96
|
-
*/
|
|
97
|
-
async clientArtifactBytes(variables) {
|
|
98
|
-
const a = await this.clientArtifact(variables);
|
|
99
|
-
const binary = atob(a.artifactBase64);
|
|
100
|
-
const bytes = new Uint8Array(binary.length);
|
|
101
|
-
for (let i = 0; i < binary.length; i++)
|
|
102
|
-
bytes[i] = binary.charCodeAt(i);
|
|
103
|
-
return {
|
|
104
|
-
bytes: bytes.buffer,
|
|
105
|
-
artifactHash: a.artifactHash,
|
|
106
|
-
fuelPerDispatch: BigInt(a.clientFuelPerDispatch),
|
|
107
|
-
contractJson: a.contractJson ?? null,
|
|
108
|
-
versionId: a.versionId,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
15
|
// -- D4 grid claim flows (Game API) ---------------------------------------------
|
|
112
16
|
/** The app's claim policy (self_claim / approval / invite / marketplace_only). */
|
|
113
17
|
async gridClaimPolicy(variables) {
|
|
@@ -174,8 +78,7 @@ export class MarketplaceAPI {
|
|
|
174
78
|
}
|
|
175
79
|
/**
|
|
176
80
|
* Catalog status: DELISTED/ACTIVE are owner actions; KILLED is the studio
|
|
177
|
-
* catalog kill
|
|
178
|
-
* also disable running installs fleet-wide.
|
|
81
|
+
* catalog kill.
|
|
179
82
|
*/
|
|
180
83
|
async setListingStatus(variables) {
|
|
181
84
|
const data = await this.game.request(MarketplaceSetListingStatusDocument, variables);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { GraphQLClient } from "../client.js";
|
|
2
|
-
import { type BeginPlayerCardSetupMutation, type PlayerWalletBalanceQuery, type PlayerWalletTransactionsQuery, type PlayerWalletTransactionsQueryVariables, type PlayerUsageChargesQuery, type PlayerUsageChargesQueryVariables, type PlayerSpendCapsQuery, type SetPlayerSpendCapMutation, type SetPlayerSpendCapMutationVariables, type PlayerAutoBillingQuery, type SetPlayerAutoBillingMutation, type SetPlayerAutoBillingMutationVariables, type PlayerRuntimeStatesQuery, type
|
|
2
|
+
import { type BeginPlayerCardSetupMutation, type PlayerWalletBalanceQuery, type PlayerWalletTransactionsQuery, type PlayerWalletTransactionsQueryVariables, type PlayerUsageChargesQuery, type PlayerUsageChargesQueryVariables, type PlayerSpendCapsQuery, type SetPlayerSpendCapMutation, type SetPlayerSpendCapMutationVariables, type PlayerAutoBillingQuery, type SetPlayerAutoBillingMutation, type SetPlayerAutoBillingMutationVariables, type PlayerRuntimeStatesQuery, type PlayerRateMarkupQuery, type PlayerRateMarkupQueryVariables, type SetPlayerRateMarkupMutation, type SetPlayerRateMarkupMutationVariables, type AppPlayerUsageQuery, type AppPlayerUsageQueryVariables, type AppPlayerMarkupAccruedQuery, type AppPlayerMarkupAccruedQueryVariables, type AppPlayerMarkupAccruedMicrousdQuery, type AppPlayerMarkupAccruedMicrousdQueryVariables } from "../generated/graphql.js";
|
|
3
3
|
/**
|
|
4
|
-
* The player wallet and player-billing surface (
|
|
5
|
-
*
|
|
4
|
+
* The player wallet and player-billing surface (DN-5) — exposed as
|
|
5
|
+
* `client.playerWallet`. A ck-exec mod's compute is billed here, to its owner.
|
|
6
6
|
*
|
|
7
7
|
* Every viewer-scoped call operates on the CALLER's own wallet: balance,
|
|
8
8
|
* ledger, hourly usage charges (platform vs studio-markup split), self-set
|
|
9
9
|
* spend caps, auto-recharge config, and per-app gate states. Fund the wallet
|
|
10
10
|
* via `client.payments.createCheckout` with purpose `PLAYER_WALLET_TOPUP`.
|
|
11
11
|
*
|
|
12
|
-
* The studio-scoped calls (
|
|
13
|
-
*
|
|
14
|
-
* `
|
|
12
|
+
* The studio-scoped calls (markup, per-player usage, accrued markup) require
|
|
13
|
+
* the corresponding org permissions (`manage_billing`,
|
|
14
|
+
* `view_compute_diagnostics`, `view_billing`).
|
|
15
15
|
*/
|
|
16
16
|
export declare class PlayerWalletAPI {
|
|
17
17
|
private readonly graphql;
|
|
@@ -46,12 +46,6 @@ export declare class PlayerWalletAPI {
|
|
|
46
46
|
beginCardSetup(): Promise<BeginPlayerCardSetupMutation["beginPlayerCardSetup"]>;
|
|
47
47
|
/** The caller's per-app gate states (absence means active). */
|
|
48
48
|
runtimeStates(): Promise<PlayerRuntimeStatesQuery["playerRuntimeStates"]>;
|
|
49
|
-
/** Studio: list an app's player policy rows (`view_compute_diagnostics`). */
|
|
50
|
-
policies(variables: PlayerWasmPoliciesQueryVariables): Promise<PlayerWasmPoliciesQuery["playerWasmPolicies"]>;
|
|
51
|
-
/** Studio: upsert a player policy row (`manage_compute`). */
|
|
52
|
-
setPolicy(variables: SetPlayerWasmPolicyMutationVariables): Promise<SetPlayerWasmPolicyMutation["setPlayerWasmPolicy"]>;
|
|
53
|
-
/** Studio: delete a player policy row (`manage_compute`). */
|
|
54
|
-
deletePolicy(variables: DeletePlayerWasmPolicyMutationVariables): Promise<DeletePlayerWasmPolicyMutation["deletePlayerWasmPolicy"]>;
|
|
55
49
|
/** Studio: read the app's player rate-card markup in bps (`view_billing`). */
|
|
56
50
|
rateMarkup(variables: PlayerRateMarkupQueryVariables): Promise<PlayerRateMarkupQuery["playerRateMarkup"]>;
|
|
57
51
|
/** Studio: set the app's player rate-card markup in bps (`manage_billing`). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"playerWallet.d.ts","sourceRoot":"","sources":["../../src/domains/playerWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EASL,KAAK,4BAA4B,
|
|
1
|
+
{"version":3,"file":"playerWallet.d.ts","sourceRoot":"","sources":["../../src/domains/playerWallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EASL,KAAK,4BAA4B,EAOjC,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,sCAAsC,EAC3C,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,kCAAkC,EACvC,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,qCAAqC,EAC1C,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EACzC,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,oCAAoC,EACzC,KAAK,mCAAmC,EACxC,KAAK,4CAA4C,EAClD,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,aAAa;IAEnD;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,wBAAwB,CAAC,qBAAqB,CAAC,CAAC;IAKzE,gDAAgD;IAC1C,YAAY,CAChB,SAAS,GAAE,sCAA2C,GACrD,OAAO,CAAC,6BAA6B,CAAC,0BAA0B,CAAC,CAAC;IAQrE;;;OAGG;IACG,OAAO,CACX,SAAS,GAAE,gCAAqC,GAC/C,OAAO,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAC;IAQzD,8DAA8D;IACxD,SAAS,IAAI,OAAO,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAKnE,0EAA0E;IACpE,WAAW,CACf,SAAS,EAAE,kCAAkC,GAC5C,OAAO,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,CAAC;IAQ1D,2CAA2C;IACrC,WAAW,IAAI,OAAO,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;IAKzE,6EAA6E;IACvE,cAAc,CAClB,SAAS,EAAE,qCAAqC,GAC/C,OAAO,CAAC,4BAA4B,CAAC,sBAAsB,CAAC,CAAC;IAQhE;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAC7B,4BAA4B,CAAC,sBAAsB,CAAC,CACrD;IAKD,+DAA+D;IACzD,aAAa,IAAI,OAAO,CAC5B,wBAAwB,CAAC,qBAAqB,CAAC,CAChD;IAKD,8EAA8E;IACxE,UAAU,CACd,SAAS,EAAE,8BAA8B,GACxC,OAAO,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAQrD,+EAA+E;IACzE,aAAa,CACjB,SAAS,EAAE,oCAAoC,GAC9C,OAAO,CAAC,2BAA2B,CAAC,qBAAqB,CAAC,CAAC;IAQ9D,uEAAuE;IACjE,cAAc,CAClB,SAAS,EAAE,4BAA4B,GACtC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAKjD;;;OAGG;IACG,gBAAgB,CACpB,SAAS,EAAE,oCAAoC,GAC9C,OAAO,CAAC,2BAA2B,CAAC,wBAAwB,CAAC,CAAC;IAQjE,gFAAgF;IAC1E,wBAAwB,CAC5B,SAAS,EAAE,4CAA4C,GACtD,OAAO,CACR,mCAAmC,CAAC,gCAAgC,CAAC,CACtE;CAOF"}
|