@seriousgaming/sdk-tools 1.5.0 → 1.6.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/agent/guidance.md +350 -0
- package/dist/bundling/ui-bundler.d.ts +12 -0
- package/dist/cli-25RWY5BQ.js +41 -0
- package/dist/cli-2BH7FX27.js +52 -0
- package/dist/cli-2GZYGRVL.js +36 -0
- package/dist/cli-2NU2LPEE.js +97 -0
- package/dist/cli-3BRC32CP.js +132 -0
- package/dist/cli-3D3ZXWOV.js +111 -0
- package/dist/cli-3ZKWV3PN.js +96 -0
- package/dist/cli-45OCBG53.js +60 -0
- package/dist/cli-4LKXZQ2B.js +48 -0
- package/dist/cli-4PXNOJQX.js +81 -0
- package/dist/cli-4SIWLHQO.js +717 -0
- package/dist/cli-4UWFQNGF.js +54 -0
- package/dist/cli-4VFZHLDG.js +202 -0
- package/dist/cli-4YB3ROVR.js +78 -0
- package/dist/cli-5ACDPCXI.js +21 -0
- package/dist/cli-5IAW3LIF.js +38 -0
- package/dist/cli-5SM367K7.js +30 -0
- package/dist/cli-64AB62PM.js +25 -0
- package/dist/cli-6K3VQQUS.js +307 -0
- package/dist/cli-6QB2VFPY.js +80 -0
- package/dist/cli-6SGCYEEC.js +649 -0
- package/dist/cli-6UTPHWRQ.js +207 -0
- package/dist/cli-6VNKQ3OX.js +391 -0
- package/dist/cli-72XDEFU3.js +61 -0
- package/dist/cli-7A6MKCUJ.js +463 -0
- package/dist/cli-7XLHO2FE.js +226 -0
- package/dist/cli-AV2FYC5G.js +225 -0
- package/dist/cli-B6YHEKIJ.js +248 -0
- package/dist/cli-BJMS3VX3.js +1837 -0
- package/dist/cli-BUQI5UU4.js +43 -0
- package/dist/cli-BWX5E7TQ.js +23 -0
- package/dist/cli-BYCHKSSH.js +1331 -0
- package/dist/cli-C3CMJSNL.js +89 -0
- package/dist/cli-C47GJATR.js +42 -0
- package/dist/cli-C5QOJJWX.js +46 -0
- package/dist/cli-C6ZLPK2U.js +124 -0
- package/dist/cli-CD5CIJZI.js +72 -0
- package/dist/cli-DDJYUKQG.js +36 -0
- package/dist/cli-DFBTZEBX.js +167 -0
- package/dist/cli-DOXRQ3S5.js +60 -0
- package/dist/cli-EVI36HEM.js +79 -0
- package/dist/cli-F2D4GGUA.js +549 -0
- package/dist/cli-FQRVFGN6.js +0 -0
- package/dist/cli-FWFRKQNE.js +11 -0
- package/dist/cli-G6CANSPL.js +88 -0
- package/dist/cli-GFNDW2DL.js +124 -0
- package/dist/cli-HCRTYQQS.js +16 -0
- package/dist/cli-HFX3YPUL.js +76 -0
- package/dist/cli-HKORECAG.js +53 -0
- package/dist/cli-HOE3WLFH.js +73 -0
- package/dist/cli-HSIHDN6K.js +187 -0
- package/dist/cli-HW53ICZC.js +89 -0
- package/dist/cli-IDVUHGKG.js +218 -0
- package/dist/cli-IEMKI7J7.js +1387 -0
- package/dist/cli-ILFDANBR.js +101 -0
- package/dist/cli-ILKCQNM6.js +8 -0
- package/dist/cli-IP4RXGHM.js +2847 -0
- package/dist/cli-IUS2YCD3.js +31 -0
- package/dist/cli-J4DKUUTK.js +138 -0
- package/dist/cli-J4UBELKF.js +37 -0
- package/dist/cli-JJSWBW4H.js +89 -0
- package/dist/cli-JVI24FI6.js +68 -0
- package/dist/cli-JZCLIT3O.js +135 -0
- package/dist/cli-JZOZOEZM.js +131 -0
- package/dist/cli-KGM6RRQW.js +185 -0
- package/dist/cli-KGT5L7VZ.js +13641 -0
- package/dist/cli-KOGRWFN7.js +89 -0
- package/dist/cli-KSGB2ZLK.js +101 -0
- package/dist/cli-L7VYSXQK.js +243 -0
- package/dist/cli-LK3V4RI5.js +36 -0
- package/dist/cli-LQOHATY2.js +126 -0
- package/dist/cli-MJUYJIEP.js +13 -0
- package/dist/cli-MJV47HKI.js +143 -0
- package/dist/cli-MMN4BPO4.js +145 -0
- package/dist/cli-MOPSZ3CS.js +88 -0
- package/dist/cli-MU5LB43S.js +136 -0
- package/dist/cli-MYJGMA6U.js +40 -0
- package/dist/cli-N24OHSAN.js +36 -0
- package/dist/cli-N45DREM4.js +99 -0
- package/dist/cli-N6H6T2E2.js +616 -0
- package/dist/cli-NROTDF5Y.js +182 -0
- package/dist/cli-O5ABH2WK.js +226 -0
- package/dist/cli-OMWC75CC.js +256 -0
- package/dist/cli-OXAUOWCN.js +50 -0
- package/dist/cli-PGCIHPU7.js +143 -0
- package/dist/cli-Q6ZBZYK2.js +35 -0
- package/dist/cli-QUNIRH7A.js +57 -0
- package/dist/cli-QUSCIUOM.js +142 -0
- package/dist/cli-QVASWX2A.js +187 -0
- package/dist/cli-QWQMPCL6.js +253 -0
- package/dist/cli-QY5NZAR7.js +97 -0
- package/dist/cli-R2MUZQE2.js +62 -0
- package/dist/cli-RCIWBCXD.js +36 -0
- package/dist/cli-RLEGRWFM.js +81 -0
- package/dist/cli-RSW6EBBD.js +89 -0
- package/dist/cli-RZITKPJX.js +367 -0
- package/dist/cli-S5IVGDDD.js +32 -0
- package/dist/cli-SRHBXZCN.js +159 -0
- package/dist/cli-TDSQSCX4.js +131 -0
- package/dist/cli-TIDQ4WUE.js +257 -0
- package/dist/cli-TT36JCU5.js +370 -0
- package/dist/cli-TTKICM5P.js +100 -0
- package/dist/cli-TTMBBEJC.js +131 -0
- package/dist/cli-UMEBPAZQ.js +16 -0
- package/dist/cli-UNAJ2OTE.js +15 -0
- package/dist/cli-UZZFNXRX.js +226 -0
- package/dist/cli-VDBW23SS.js +81 -0
- package/dist/cli-VL2P354N.js +46 -0
- package/dist/cli-VPRRICZA.js +304 -0
- package/dist/cli-VQ6HVQW4.js +4010 -0
- package/dist/cli-WR3NOY74.js +36 -0
- package/dist/cli-WU43JT4T.js +52 -0
- package/dist/cli-XAT25PRU.js +117 -0
- package/dist/cli-XOTNXEJA.js +124 -0
- package/dist/cli-XSLNH5PR.js +6417 -0
- package/dist/cli-XSVGKI3R.js +39 -0
- package/dist/cli-XZCJIKIV.js +124 -0
- package/dist/cli-Y3DDNMPX.js +97 -0
- package/dist/cli-Y3O5F4JN.js +90 -0
- package/dist/cli-YOTGR3NB.js +82 -0
- package/dist/cli-Z56ZIVA6.js +97 -0
- package/dist/cli-ZBN5KAIB.js +59 -0
- package/dist/cli-ZDOTXEKL.js +31 -0
- package/dist/cli-ZDUADFBY.js +88 -0
- package/dist/cli-ZJFQ7EEA.js +131 -0
- package/dist/cli-ZTWOE3ZT.js +65 -0
- package/dist/cli.js +148 -43093
- package/dist/client/build-surfaces.d.ts +33 -0
- package/dist/client/dev-server.d.ts +6 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/playwright.d.ts +62 -0
- package/dist/client.js +228 -48
- package/dist/core/session.d.ts +15 -1
- package/dist/dev/console/assets/{index-BVF8exas.js → index-CuMOOH9m.js} +1 -1
- package/dist/dev/console/index.html +1 -1
- package/dist/dev/shell.d.ts +19 -0
- package/dist/dev/surfaces.d.ts +7 -0
- package/dist/docs/ai-agents.md +1 -1
- package/dist/docs/api/index.md +14 -12
- package/dist/docs/api/sdk-tools-client.md +29 -0
- package/dist/docs/api/sdk-tools-playwright.md +104 -0
- package/dist/docs/changelog.md +34 -0
- package/dist/docs/cli-and-dev-server.md +21 -0
- package/dist/docs/cli-reference.md +45 -31
- package/dist/docs/environment-variables.md +6 -0
- package/dist/docs/getting-started.md +1 -1
- package/dist/docs/guides/designing-a-game.md +29 -4
- package/dist/docs/guides/starter-game.md +3 -3
- package/dist/docs/guides/testing.md +33 -18
- package/dist/docs/guides/upgrading.md +19 -2
- package/dist/docs/page-index.md +10 -9
- package/dist/docs/recipes/e2e-testing.md +19 -20
- package/dist/playwright.js +32232 -0
- package/dist/templates/package/CLAUDE.md.template +7 -346
- package/dist/templates/package/claude/rules/workflow-create-engine.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-guide.md +2 -2
- package/dist/templates/package/claude/rules/workflow-create-user-interface.md +1 -1
- package/dist/templates/package/claude/rules/workflow-test-engine-or-ui.md +1 -1
- package/dist/templates/package/claude/rules/workflow-update-sdk-version.md +3 -3
- package/dist/templates/package/global-setup.ts.template +7 -18
- package/dist/templates/package/playwright.config.ts.liquid +8 -11
- package/dist/templates/starter-game/playwright.config.ts +8 -11
- package/dist/templates/starter-game/testing/e2e/game.spec.ts +1 -1
- package/dist/templates/starter-game/testing/e2e/global-setup.ts +7 -18
- package/dist/utils/prompt.d.ts +5 -5
- package/dist/utils/resource-scan.d.ts +39 -0
- package/package.json +7 -3
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// cli/storage/blob-store.ts
|
|
4
|
+
import { randomUUID } from "crypto";
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import { mkdir, readdir, readFile, rm, stat, writeFile } from "fs/promises";
|
|
7
|
+
import { join, resolve } from "path";
|
|
8
|
+
var MAX_BLOB_SIZE = 20 * 1024 * 1024;
|
|
9
|
+
var redirected = /* @__PURE__ */ new Map();
|
|
10
|
+
function getBlobsDir(packagePath) {
|
|
11
|
+
return redirected.get(resolve(packagePath)) ?? join(packagePath, ".seriousgaming-sdk", "blobs");
|
|
12
|
+
}
|
|
13
|
+
function redirectBlobs(packagePath, dir) {
|
|
14
|
+
const key = resolve(packagePath);
|
|
15
|
+
redirected.set(key, dir);
|
|
16
|
+
return () => {
|
|
17
|
+
if (redirected.get(key) === dir) redirected.delete(key);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var BLOB_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
21
|
+
function blobPath(dir, id, suffix) {
|
|
22
|
+
if (!BLOB_ID.test(id)) throw new Error(`Blob not found: ${id}`);
|
|
23
|
+
return join(dir, `${id}${suffix}`);
|
|
24
|
+
}
|
|
25
|
+
function metaPath(dir, id) {
|
|
26
|
+
return blobPath(dir, id, ".meta.json");
|
|
27
|
+
}
|
|
28
|
+
function binPath(dir, id) {
|
|
29
|
+
return blobPath(dir, id, ".bin");
|
|
30
|
+
}
|
|
31
|
+
async function storeBlob(packagePath, data, name, mimeType, retention) {
|
|
32
|
+
if (data.length > MAX_BLOB_SIZE) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Blob exceeds maximum size of 20 MB (got ${(data.length / 1024 / 1024).toFixed(1)} MB)`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
const dir = getBlobsDir(packagePath);
|
|
38
|
+
await mkdir(dir, { recursive: true });
|
|
39
|
+
const id = randomUUID();
|
|
40
|
+
const meta = { name, mimeType, retention };
|
|
41
|
+
await writeFile(binPath(dir, id), data);
|
|
42
|
+
await writeFile(metaPath(dir, id), JSON.stringify(meta, null, 2), "utf-8");
|
|
43
|
+
return id;
|
|
44
|
+
}
|
|
45
|
+
async function readBlob(packagePath, id) {
|
|
46
|
+
const dir = getBlobsDir(packagePath);
|
|
47
|
+
const mp = metaPath(dir, id);
|
|
48
|
+
const bp = binPath(dir, id);
|
|
49
|
+
if (!existsSync(mp) || !existsSync(bp)) {
|
|
50
|
+
throw new Error(`Blob not found: ${id}`);
|
|
51
|
+
}
|
|
52
|
+
const [metaRaw, data] = await Promise.all([readFile(mp, "utf-8"), readFile(bp)]);
|
|
53
|
+
const meta = JSON.parse(metaRaw);
|
|
54
|
+
return { ...meta, data };
|
|
55
|
+
}
|
|
56
|
+
async function describeBlob(packagePath, id) {
|
|
57
|
+
const dir = getBlobsDir(packagePath);
|
|
58
|
+
try {
|
|
59
|
+
const [metaRaw, bin] = await Promise.all([
|
|
60
|
+
readFile(metaPath(dir, id), "utf-8"),
|
|
61
|
+
stat(binPath(dir, id))
|
|
62
|
+
]);
|
|
63
|
+
return { ...JSON.parse(metaRaw), size: bin.size };
|
|
64
|
+
} catch {
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
async function deleteBlobs(packagePath, retentions) {
|
|
69
|
+
const dir = getBlobsDir(packagePath);
|
|
70
|
+
let entries;
|
|
71
|
+
try {
|
|
72
|
+
entries = await readdir(dir);
|
|
73
|
+
} catch {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const ids = entries.filter((entry) => entry.endsWith(".meta.json")).map((entry) => entry.slice(0, -".meta.json".length)).filter((id) => BLOB_ID.test(id));
|
|
77
|
+
await Promise.all(
|
|
78
|
+
ids.map(async (id) => {
|
|
79
|
+
let meta;
|
|
80
|
+
try {
|
|
81
|
+
meta = JSON.parse(await readFile(metaPath(dir, id), "utf-8"));
|
|
82
|
+
} catch {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!retentions.includes(meta.retention)) return;
|
|
86
|
+
await rm(binPath(dir, id), { force: true });
|
|
87
|
+
await rm(metaPath(dir, id), { force: true });
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// cli/storage/asset-resolver.ts
|
|
93
|
+
import { readFile as readFile2, stat as stat2 } from "fs/promises";
|
|
94
|
+
import { basename, isAbsolute, normalize, resolve as resolvePath, sep } from "path";
|
|
95
|
+
var ASSET_PREFIX = "asset:";
|
|
96
|
+
var SHARED_PREFIX = "shared:";
|
|
97
|
+
var BLOB_PREFIX = "blob:";
|
|
98
|
+
var EXTENSION_MEDIA_TYPES = {
|
|
99
|
+
aac: "audio/aac",
|
|
100
|
+
avif: "image/avif",
|
|
101
|
+
bmp: "image/bmp",
|
|
102
|
+
css: "text/css",
|
|
103
|
+
csv: "text/csv",
|
|
104
|
+
doc: "application/msword",
|
|
105
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
106
|
+
flac: "audio/flac",
|
|
107
|
+
gif: "image/gif",
|
|
108
|
+
htm: "text/html",
|
|
109
|
+
html: "text/html",
|
|
110
|
+
ico: "image/x-icon",
|
|
111
|
+
jpeg: "image/jpeg",
|
|
112
|
+
jpg: "image/jpeg",
|
|
113
|
+
js: "text/javascript",
|
|
114
|
+
json: "application/json",
|
|
115
|
+
m4a: "audio/mp4",
|
|
116
|
+
m4v: "video/mp4",
|
|
117
|
+
md: "text/markdown",
|
|
118
|
+
mjs: "text/javascript",
|
|
119
|
+
mov: "video/quicktime",
|
|
120
|
+
mp3: "audio/mpeg",
|
|
121
|
+
mp4: "video/mp4",
|
|
122
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
123
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
124
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
125
|
+
ogg: "audio/ogg",
|
|
126
|
+
opus: "audio/ogg",
|
|
127
|
+
otf: "font/otf",
|
|
128
|
+
pdf: "application/pdf",
|
|
129
|
+
png: "image/png",
|
|
130
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
131
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
132
|
+
rtf: "application/rtf",
|
|
133
|
+
svg: "image/svg+xml",
|
|
134
|
+
tif: "image/tiff",
|
|
135
|
+
tiff: "image/tiff",
|
|
136
|
+
ttf: "font/ttf",
|
|
137
|
+
txt: "text/plain",
|
|
138
|
+
vtt: "text/vtt",
|
|
139
|
+
wav: "audio/wav",
|
|
140
|
+
webm: "video/webm",
|
|
141
|
+
webp: "image/webp",
|
|
142
|
+
woff: "font/woff",
|
|
143
|
+
woff2: "font/woff2",
|
|
144
|
+
xls: "application/vnd.ms-excel",
|
|
145
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
146
|
+
xml: "application/xml",
|
|
147
|
+
yaml: "application/yaml",
|
|
148
|
+
yml: "application/yaml",
|
|
149
|
+
zip: "application/zip"
|
|
150
|
+
};
|
|
151
|
+
var UNLISTED_MEDIA_TYPE = "application/octet-stream";
|
|
152
|
+
function mediaTypeOf(path) {
|
|
153
|
+
const name = path.slice(Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")) + 1);
|
|
154
|
+
const dot = name.lastIndexOf(".");
|
|
155
|
+
if (dot < 0) return UNLISTED_MEDIA_TYPE;
|
|
156
|
+
const ext = name.slice(dot + 1).toLowerCase();
|
|
157
|
+
return Object.hasOwn(EXTENSION_MEDIA_TYPES, ext) ? EXTENSION_MEDIA_TYPES[ext] : UNLISTED_MEDIA_TYPE;
|
|
158
|
+
}
|
|
159
|
+
function isAssetReference(value) {
|
|
160
|
+
return typeof value === "string" && (value.startsWith(ASSET_PREFIX) || value.startsWith(SHARED_PREFIX) || value.startsWith(BLOB_PREFIX));
|
|
161
|
+
}
|
|
162
|
+
function scenarioAssetPath(scenarioRootDirectory, path) {
|
|
163
|
+
const assetsRoot = resolvePath(scenarioRootDirectory, "assets");
|
|
164
|
+
const resolvedPath = resolvePath(assetsRoot, normalize(path));
|
|
165
|
+
if (!resolvedPath.startsWith(assetsRoot + sep)) {
|
|
166
|
+
throw new Error(`Asset path escapes scenario assets directory: ${path}`);
|
|
167
|
+
}
|
|
168
|
+
return resolvedPath;
|
|
169
|
+
}
|
|
170
|
+
function sharedAssetPath(packagePath, path) {
|
|
171
|
+
const sharedRoot = resolvePath(packagePath, "shared-assets");
|
|
172
|
+
const resolvedPath = resolvePath(sharedRoot, normalize(path));
|
|
173
|
+
if (!resolvedPath.startsWith(sharedRoot + sep)) {
|
|
174
|
+
throw new Error(`Asset path escapes shared-assets directory: ${path}`);
|
|
175
|
+
}
|
|
176
|
+
return resolvedPath;
|
|
177
|
+
}
|
|
178
|
+
async function resolveAsset(scenarioRootDirectory, path) {
|
|
179
|
+
const resolvedPath = scenarioAssetPath(scenarioRootDirectory, path);
|
|
180
|
+
const data = await readFile2(resolvedPath);
|
|
181
|
+
return {
|
|
182
|
+
data,
|
|
183
|
+
mimeType: mediaTypeOf(resolvedPath),
|
|
184
|
+
name: basename(resolvedPath)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
async function resolveSharedAsset(packagePath, path) {
|
|
188
|
+
const resolvedPath = sharedAssetPath(packagePath, path);
|
|
189
|
+
const data = await readFile2(resolvedPath);
|
|
190
|
+
return {
|
|
191
|
+
data,
|
|
192
|
+
mimeType: mediaTypeOf(resolvedPath),
|
|
193
|
+
name: basename(resolvedPath)
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async function readAssetByReference(packagePath, scenarioRootDirectory, reference) {
|
|
197
|
+
if (reference.startsWith(BLOB_PREFIX)) {
|
|
198
|
+
const id = reference.slice(BLOB_PREFIX.length);
|
|
199
|
+
const blob = await readBlob(packagePath, id);
|
|
200
|
+
return { data: blob.data, mimeType: blob.mimeType, name: blob.name };
|
|
201
|
+
}
|
|
202
|
+
if (reference.startsWith(SHARED_PREFIX)) {
|
|
203
|
+
const path = reference.slice(SHARED_PREFIX.length);
|
|
204
|
+
return resolveSharedAsset(packagePath, path);
|
|
205
|
+
}
|
|
206
|
+
if (reference.startsWith(ASSET_PREFIX)) {
|
|
207
|
+
if (!scenarioRootDirectory) {
|
|
208
|
+
throw new Error(`Cannot resolve asset reference "${reference}": no scenario is active`);
|
|
209
|
+
}
|
|
210
|
+
const path = reference.slice(ASSET_PREFIX.length);
|
|
211
|
+
const root = isAbsolute(scenarioRootDirectory) ? scenarioRootDirectory : resolvePath(packagePath, scenarioRootDirectory);
|
|
212
|
+
return resolveAsset(root, path);
|
|
213
|
+
}
|
|
214
|
+
throw new Error(
|
|
215
|
+
`Invalid asset reference "${reference}": expected an "asset:", "shared:", or "blob:" prefix`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
async function describeAssetByReference(packagePath, scenarioRootDirectory, reference) {
|
|
219
|
+
if (reference.startsWith(BLOB_PREFIX)) {
|
|
220
|
+
const blob = await describeBlob(packagePath, reference.slice(BLOB_PREFIX.length));
|
|
221
|
+
return blob && { mimeType: blob.mimeType, size: blob.size };
|
|
222
|
+
}
|
|
223
|
+
let path;
|
|
224
|
+
if (reference.startsWith(SHARED_PREFIX)) {
|
|
225
|
+
path = sharedAssetPath(packagePath, reference.slice(SHARED_PREFIX.length));
|
|
226
|
+
} else if (reference.startsWith(ASSET_PREFIX)) {
|
|
227
|
+
if (!scenarioRootDirectory) return void 0;
|
|
228
|
+
const root = isAbsolute(scenarioRootDirectory) ? scenarioRootDirectory : resolvePath(packagePath, scenarioRootDirectory);
|
|
229
|
+
path = scenarioAssetPath(root, reference.slice(ASSET_PREFIX.length));
|
|
230
|
+
} else {
|
|
231
|
+
throw new Error(
|
|
232
|
+
`Invalid asset reference "${reference}": expected an "asset:", "shared:", or "blob:" prefix`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
try {
|
|
236
|
+
const file = await stat2(path);
|
|
237
|
+
return file.isFile() ? { mimeType: mediaTypeOf(path), size: file.size } : void 0;
|
|
238
|
+
} catch {
|
|
239
|
+
return void 0;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
redirectBlobs,
|
|
245
|
+
storeBlob,
|
|
246
|
+
readBlob,
|
|
247
|
+
describeBlob,
|
|
248
|
+
deleteBlobs,
|
|
249
|
+
mediaTypeOf,
|
|
250
|
+
isAssetReference,
|
|
251
|
+
readAssetByReference,
|
|
252
|
+
describeAssetByReference
|
|
253
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolvePatchedDefinition
|
|
4
|
+
} from "./cli-5IAW3LIF.js";
|
|
5
|
+
import "./cli-S5IVGDDD.js";
|
|
6
|
+
import {
|
|
7
|
+
readAuthoredBundle
|
|
8
|
+
} from "./cli-4VFZHLDG.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveInputSource
|
|
11
|
+
} from "./cli-4UWFQNGF.js";
|
|
12
|
+
import {
|
|
13
|
+
updateSessionUserInterfaceFiles
|
|
14
|
+
} from "./cli-4SIWLHQO.js";
|
|
15
|
+
import "./cli-IUS2YCD3.js";
|
|
16
|
+
import "./cli-QUNIRH7A.js";
|
|
17
|
+
import "./cli-J4UBELKF.js";
|
|
18
|
+
import {
|
|
19
|
+
loadPackageContext
|
|
20
|
+
} from "./cli-XSVGKI3R.js";
|
|
21
|
+
import "./cli-TT36JCU5.js";
|
|
22
|
+
import "./cli-OXAUOWCN.js";
|
|
23
|
+
import {
|
|
24
|
+
operationError,
|
|
25
|
+
printOperationResult,
|
|
26
|
+
regenerateTypes
|
|
27
|
+
} from "./cli-KSGB2ZLK.js";
|
|
28
|
+
import "./cli-LQOHATY2.js";
|
|
29
|
+
import "./cli-IEMKI7J7.js";
|
|
30
|
+
import "./cli-OMWC75CC.js";
|
|
31
|
+
import "./cli-BYCHKSSH.js";
|
|
32
|
+
import "./cli-25RWY5BQ.js";
|
|
33
|
+
import "./cli-QWQMPCL6.js";
|
|
34
|
+
import {
|
|
35
|
+
validateSDKSessionUserInterface
|
|
36
|
+
} from "./cli-VQ6HVQW4.js";
|
|
37
|
+
import "./cli-F2D4GGUA.js";
|
|
38
|
+
import {
|
|
39
|
+
logger
|
|
40
|
+
} from "./cli-4YB3ROVR.js";
|
|
41
|
+
import {
|
|
42
|
+
CliError
|
|
43
|
+
} from "./cli-N6H6T2E2.js";
|
|
44
|
+
|
|
45
|
+
// cli/commands/resources/session/update.ts
|
|
46
|
+
async function updateSessionUserInterface(definitionInput, options) {
|
|
47
|
+
logger.info("\nUpdating session user interface...\n");
|
|
48
|
+
const identifier = "session";
|
|
49
|
+
loadPackageContext(options.workingDir);
|
|
50
|
+
let jsonDefinition = null;
|
|
51
|
+
if (options.patch) {
|
|
52
|
+
jsonDefinition = resolvePatchedDefinition({
|
|
53
|
+
patch: options.patch,
|
|
54
|
+
workingDir: options.workingDir,
|
|
55
|
+
type: "session",
|
|
56
|
+
identifier,
|
|
57
|
+
resourceLabel: "Session user interface"
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
61
|
+
if (inputSource.kind === "json") jsonDefinition = inputSource.json;
|
|
62
|
+
}
|
|
63
|
+
if (jsonDefinition) {
|
|
64
|
+
const uiInput = readAuthoredBundle({
|
|
65
|
+
json: jsonDefinition,
|
|
66
|
+
type: "session",
|
|
67
|
+
command: "update",
|
|
68
|
+
validate: validateSDKSessionUserInterface,
|
|
69
|
+
identifier
|
|
70
|
+
});
|
|
71
|
+
logger.info("Updating session user interface files...\n");
|
|
72
|
+
const result = updateSessionUserInterfaceFiles({
|
|
73
|
+
packagePath: options.workingDir,
|
|
74
|
+
oldIdentifier: identifier,
|
|
75
|
+
newDefinition: uiInput.definition
|
|
76
|
+
});
|
|
77
|
+
if (!result.success) {
|
|
78
|
+
throw operationError(result, "Failed to update session user interface files");
|
|
79
|
+
}
|
|
80
|
+
logger.success("Session user interface updated successfully!");
|
|
81
|
+
printOperationResult(result);
|
|
82
|
+
await regenerateTypes(options.workingDir);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw new CliError(
|
|
86
|
+
"USAGE_MISSING_INPUT",
|
|
87
|
+
`A session user interface takes no interactive input: a game holds one, so there is
|
|
88
|
+
nothing to name and nothing to pick.
|
|
89
|
+
|
|
90
|
+
Edit it with a definition or a patch:
|
|
91
|
+
$ seriousgaming-sdk update session-user-interface '{"definition":{...}}'
|
|
92
|
+
$ seriousgaming-sdk update session-user-interface --patch '[...]'`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
updateSessionUserInterface
|
|
97
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolveSession
|
|
4
|
+
} from "./cli-6K3VQQUS.js";
|
|
5
|
+
import "./cli-WU43JT4T.js";
|
|
6
|
+
import "./cli-XSLNH5PR.js";
|
|
7
|
+
import "./cli-TDSQSCX4.js";
|
|
8
|
+
import "./cli-SRHBXZCN.js";
|
|
9
|
+
import "./cli-KGT5L7VZ.js";
|
|
10
|
+
import "./cli-4LKXZQ2B.js";
|
|
11
|
+
import "./cli-MMN4BPO4.js";
|
|
12
|
+
import "./cli-QUNIRH7A.js";
|
|
13
|
+
import "./cli-BYCHKSSH.js";
|
|
14
|
+
import "./cli-25RWY5BQ.js";
|
|
15
|
+
import "./cli-QWQMPCL6.js";
|
|
16
|
+
import "./cli-VQ6HVQW4.js";
|
|
17
|
+
import "./cli-F2D4GGUA.js";
|
|
18
|
+
import "./cli-4YB3ROVR.js";
|
|
19
|
+
import {
|
|
20
|
+
CliError,
|
|
21
|
+
reportResult
|
|
22
|
+
} from "./cli-N6H6T2E2.js";
|
|
23
|
+
|
|
24
|
+
// cli/commands/endpoint-audit.ts
|
|
25
|
+
function describe(entry) {
|
|
26
|
+
const who = entry.principal ? `${entry.role} ${entry.principal.kind}:${entry.principal.id}` + (entry.principal.name ? ` (${entry.principal.name})` : "") : entry.role;
|
|
27
|
+
const changed = [
|
|
28
|
+
...entry.wrote.length > 0 ? [`wrote ${entry.wrote.join(", ")}`] : [],
|
|
29
|
+
...Object.entries(entry.teams ?? {}).map(
|
|
30
|
+
([teamId, capabilities]) => `wrote ${capabilities.join(", ")} on ${teamId}`
|
|
31
|
+
),
|
|
32
|
+
...entry.actions.length > 0 ? [`did ${entry.actions.join(", ")}`] : []
|
|
33
|
+
];
|
|
34
|
+
return `${new Date(entry.at).toISOString()} ${entry.endpoint}${entry.teamId ? ` for ${entry.teamId}` : ""} by ${who}
|
|
35
|
+
${changed.join("; ")}` + (entry.stoppedAt ? `
|
|
36
|
+
stopped at ${entry.stoppedAt}` : "");
|
|
37
|
+
}
|
|
38
|
+
async function endpointAuditCommand(options) {
|
|
39
|
+
const session = await resolveSession({
|
|
40
|
+
packagePath: options.workingDir,
|
|
41
|
+
autoStart: false,
|
|
42
|
+
...options.walkthrough ? { runKind: "walkthrough" } : {}
|
|
43
|
+
});
|
|
44
|
+
try {
|
|
45
|
+
const result = await session.send({ type: "getEndpointAudit" });
|
|
46
|
+
if (!("type" in result) || result.type !== "endpointAudit") {
|
|
47
|
+
throw new CliError("DEV_SERVER_OUTDATED", "The session returned no audit");
|
|
48
|
+
}
|
|
49
|
+
const entries = result.entries;
|
|
50
|
+
reportResult(
|
|
51
|
+
entries,
|
|
52
|
+
() => console.log(
|
|
53
|
+
entries.length === 0 ? "No endpoint call has changed this session." : entries.map(describe).join("\n\n")
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
} finally {
|
|
57
|
+
await session.close();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
endpointAuditCommand
|
|
62
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
deleteSettingsEditor
|
|
4
|
+
} from "./cli-AV2FYC5G.js";
|
|
5
|
+
import "./cli-Q6ZBZYK2.js";
|
|
6
|
+
import "./cli-5IAW3LIF.js";
|
|
7
|
+
import "./cli-S5IVGDDD.js";
|
|
8
|
+
import "./cli-4VFZHLDG.js";
|
|
9
|
+
import "./cli-4UWFQNGF.js";
|
|
10
|
+
import "./cli-4SIWLHQO.js";
|
|
11
|
+
import "./cli-IUS2YCD3.js";
|
|
12
|
+
import "./cli-QUNIRH7A.js";
|
|
13
|
+
import "./cli-J4UBELKF.js";
|
|
14
|
+
import "./cli-XSVGKI3R.js";
|
|
15
|
+
import "./cli-TT36JCU5.js";
|
|
16
|
+
import "./cli-OXAUOWCN.js";
|
|
17
|
+
import "./cli-KSGB2ZLK.js";
|
|
18
|
+
import "./cli-ZTWOE3ZT.js";
|
|
19
|
+
import "./cli-LQOHATY2.js";
|
|
20
|
+
import "./cli-IEMKI7J7.js";
|
|
21
|
+
import "./cli-OMWC75CC.js";
|
|
22
|
+
import "./cli-BYCHKSSH.js";
|
|
23
|
+
import "./cli-25RWY5BQ.js";
|
|
24
|
+
import "./cli-QWQMPCL6.js";
|
|
25
|
+
import "./cli-VQ6HVQW4.js";
|
|
26
|
+
import "./cli-F2D4GGUA.js";
|
|
27
|
+
import "./cli-4YB3ROVR.js";
|
|
28
|
+
import "./cli-N6H6T2E2.js";
|
|
29
|
+
|
|
30
|
+
// cli/commands/resources/setup/delete.ts
|
|
31
|
+
function deleteSetup(options) {
|
|
32
|
+
return deleteSettingsEditor("setup", options);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
deleteSetup
|
|
36
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
submitPatch,
|
|
4
|
+
submitSharedPatch
|
|
5
|
+
} from "./cli-C6ZLPK2U.js";
|
|
6
|
+
import {
|
|
7
|
+
resolveSession
|
|
8
|
+
} from "./cli-6K3VQQUS.js";
|
|
9
|
+
import "./cli-WU43JT4T.js";
|
|
10
|
+
import {
|
|
11
|
+
emit,
|
|
12
|
+
teamIndexFromArgument,
|
|
13
|
+
tickReport
|
|
14
|
+
} from "./cli-L7VYSXQK.js";
|
|
15
|
+
import "./cli-FQRVFGN6.js";
|
|
16
|
+
import "./cli-XSLNH5PR.js";
|
|
17
|
+
import "./cli-TDSQSCX4.js";
|
|
18
|
+
import "./cli-SRHBXZCN.js";
|
|
19
|
+
import "./cli-KGT5L7VZ.js";
|
|
20
|
+
import "./cli-4LKXZQ2B.js";
|
|
21
|
+
import "./cli-MMN4BPO4.js";
|
|
22
|
+
import "./cli-S5IVGDDD.js";
|
|
23
|
+
import "./cli-QUNIRH7A.js";
|
|
24
|
+
import "./cli-BYCHKSSH.js";
|
|
25
|
+
import "./cli-25RWY5BQ.js";
|
|
26
|
+
import "./cli-QWQMPCL6.js";
|
|
27
|
+
import "./cli-VQ6HVQW4.js";
|
|
28
|
+
import "./cli-F2D4GGUA.js";
|
|
29
|
+
import "./cli-4YB3ROVR.js";
|
|
30
|
+
import {
|
|
31
|
+
CliError
|
|
32
|
+
} from "./cli-N6H6T2E2.js";
|
|
33
|
+
|
|
34
|
+
// cli/commands/patch.ts
|
|
35
|
+
async function patchCommand(patch, options) {
|
|
36
|
+
if (!patch) {
|
|
37
|
+
throw new CliError(
|
|
38
|
+
"USAGE_MISSING_INPUT",
|
|
39
|
+
"JSON Patch is required\nUsage: pnpm run sdk patch <patch>"
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const session = await resolveSession({
|
|
43
|
+
packagePath: options.workingDir,
|
|
44
|
+
...options.walkthrough ? { runKind: "walkthrough" } : {},
|
|
45
|
+
...options.server === false ? { noServer: true } : {}
|
|
46
|
+
});
|
|
47
|
+
try {
|
|
48
|
+
const state = await session.state();
|
|
49
|
+
if (options.shared) {
|
|
50
|
+
if (options.team !== void 0) {
|
|
51
|
+
throw new CliError(
|
|
52
|
+
"USAGE_BAD_FLAG",
|
|
53
|
+
"--shared and --team cannot be combined: the shared store has one value for every team"
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
await submitSharedPatch(session, state, patch);
|
|
57
|
+
emit(tickReport(await session.state()));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const teamIndex = teamIndexFromArgument(state, options.team);
|
|
61
|
+
if (state.teams.length > 1 && teamIndex === void 0) {
|
|
62
|
+
throw new CliError(
|
|
63
|
+
"USAGE_MISSING_ARGUMENT",
|
|
64
|
+
"--team <number> is required for multi-team games, or --shared for the shared store"
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
if (state.teams.length <= 1 && teamIndex !== void 0) {
|
|
68
|
+
throw new CliError(
|
|
69
|
+
"USAGE_NOT_APPLICABLE",
|
|
70
|
+
"--team can only be used with multi-team games"
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
await submitPatch(session, state, patch, teamIndex);
|
|
74
|
+
emit(tickReport(await session.state()));
|
|
75
|
+
} finally {
|
|
76
|
+
await session.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
patchCommand
|
|
81
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
resolvePatchedDefinition
|
|
4
|
+
} from "./cli-5IAW3LIF.js";
|
|
5
|
+
import "./cli-S5IVGDDD.js";
|
|
6
|
+
import {
|
|
7
|
+
readAuthoredBundle
|
|
8
|
+
} from "./cli-4VFZHLDG.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveInputSource
|
|
11
|
+
} from "./cli-4UWFQNGF.js";
|
|
12
|
+
import {
|
|
13
|
+
updateScenarioFiles
|
|
14
|
+
} from "./cli-J4UBELKF.js";
|
|
15
|
+
import {
|
|
16
|
+
loadPackageContext
|
|
17
|
+
} from "./cli-XSVGKI3R.js";
|
|
18
|
+
import "./cli-TT36JCU5.js";
|
|
19
|
+
import "./cli-OXAUOWCN.js";
|
|
20
|
+
import {
|
|
21
|
+
operationError,
|
|
22
|
+
printOperationResult
|
|
23
|
+
} from "./cli-KSGB2ZLK.js";
|
|
24
|
+
import "./cli-LQOHATY2.js";
|
|
25
|
+
import "./cli-IEMKI7J7.js";
|
|
26
|
+
import "./cli-OMWC75CC.js";
|
|
27
|
+
import "./cli-BYCHKSSH.js";
|
|
28
|
+
import "./cli-25RWY5BQ.js";
|
|
29
|
+
import "./cli-QWQMPCL6.js";
|
|
30
|
+
import {
|
|
31
|
+
validateSDKScenario
|
|
32
|
+
} from "./cli-VQ6HVQW4.js";
|
|
33
|
+
import "./cli-F2D4GGUA.js";
|
|
34
|
+
import {
|
|
35
|
+
logger
|
|
36
|
+
} from "./cli-4YB3ROVR.js";
|
|
37
|
+
import {
|
|
38
|
+
CliError
|
|
39
|
+
} from "./cli-N6H6T2E2.js";
|
|
40
|
+
|
|
41
|
+
// cli/commands/resources/scenario/update.ts
|
|
42
|
+
async function updateScenario(identifier, definitionInput, options) {
|
|
43
|
+
logger.info("\nUpdating scenario...\n");
|
|
44
|
+
loadPackageContext(options.workingDir);
|
|
45
|
+
let jsonDefinition = null;
|
|
46
|
+
if (options.patch) {
|
|
47
|
+
jsonDefinition = resolvePatchedDefinition({
|
|
48
|
+
patch: options.patch,
|
|
49
|
+
workingDir: options.workingDir,
|
|
50
|
+
type: "scenario",
|
|
51
|
+
identifier,
|
|
52
|
+
resourceLabel: "Scenario"
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
const inputSource = await resolveInputSource(definitionInput, options.file);
|
|
56
|
+
if (inputSource.kind === "json") jsonDefinition = inputSource.json;
|
|
57
|
+
}
|
|
58
|
+
if (jsonDefinition) {
|
|
59
|
+
const scenarioInput = readAuthoredBundle({
|
|
60
|
+
json: jsonDefinition,
|
|
61
|
+
type: "scenario",
|
|
62
|
+
command: "update",
|
|
63
|
+
validate: validateSDKScenario,
|
|
64
|
+
identifier
|
|
65
|
+
});
|
|
66
|
+
logger.info("Updating scenario files...\n");
|
|
67
|
+
const result = updateScenarioFiles({
|
|
68
|
+
packagePath: options.workingDir,
|
|
69
|
+
oldIdentifier: identifier,
|
|
70
|
+
newDefinition: scenarioInput.definition,
|
|
71
|
+
newIdentifier: scenarioInput.definition?.identifier
|
|
72
|
+
});
|
|
73
|
+
if (!result.success) {
|
|
74
|
+
throw operationError(result, "Failed to update scenario files");
|
|
75
|
+
}
|
|
76
|
+
logger.success("Scenario updated successfully!");
|
|
77
|
+
printOperationResult(result);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
throw new CliError(
|
|
81
|
+
"USAGE_MISSING_INPUT",
|
|
82
|
+
`JSON definition or --patch is required for scenario updates.
|
|
83
|
+
Usage: sdk update scenario <id> '{"definition": {...}}'
|
|
84
|
+
or: sdk update scenario <id> --patch '[{"op":"replace","path":"/definition/locales/en/name","value":"New Name"}]'`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
updateScenario
|
|
89
|
+
};
|