@dreamboard-games/cli 0.1.30-alpha.0 → 0.1.30-alpha.2

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.
Files changed (114) hide show
  1. package/README.md +179 -22
  2. package/dist/{chunk-TSJVWTJO.js → chunk-N7XPNNUI.js} +14 -12
  3. package/dist/chunk-N7XPNNUI.js.map +1 -0
  4. package/dist/chunk-SEGVTWSK.js +44 -0
  5. package/dist/{chunk-3XNJT3RK.js → chunk-TAQKH67O.js} +21279 -35845
  6. package/dist/chunk-TAQKH67O.js.map +1 -0
  7. package/dist/{global-config-UKSWNDTX.js → global-config-S4ZIPECE.js} +3 -3
  8. package/dist/index.js +955 -230
  9. package/dist/index.js.map +1 -1
  10. package/dist/internal.js +3 -4
  11. package/dist/{agent-verifier/keychain-backend-TNOPQV3Z.mjs → keychain-backend-HDF4TZDL.js} +2 -1
  12. package/dist/{agent-verifier/prompt-3BAINGAQ.mjs → prompt-NDV3AE5L.js} +2 -1
  13. package/package.json +6 -6
  14. package/skills/dreamboard/references/building-your-first-game.md +510 -0
  15. package/skills/dreamboard/references/cli.md +104 -0
  16. package/skills/dreamboard/references/game-interface.md +548 -0
  17. package/skills/dreamboard/references/manifest-authoring.md +597 -0
  18. package/skills/dreamboard/references/quickstart.md +66 -0
  19. package/skills/dreamboard/references/reducer.md +864 -0
  20. package/skills/dreamboard/references/rule-authoring.md +147 -0
  21. package/skills/dreamboard/references/testing.md +249 -0
  22. package/skills/dreamboard/scripts/events-extract.mjs +218 -0
  23. package/dist/agent-verifier/agent-workspace-verifier.mjs +0 -227
  24. package/dist/agent-verifier/chunk-2E5P5NWG.mjs +0 -835
  25. package/dist/agent-verifier/chunk-2GBBP27W.mjs +0 -301
  26. package/dist/agent-verifier/chunk-2NZNKIND.mjs +0 -166
  27. package/dist/agent-verifier/chunk-2QMNAVV4.mjs +0 -14522
  28. package/dist/agent-verifier/chunk-2SZHMP6F.mjs +0 -264
  29. package/dist/agent-verifier/chunk-54TAYXUD.mjs +0 -12
  30. package/dist/agent-verifier/chunk-6A5HRJMQ.mjs +0 -3174
  31. package/dist/agent-verifier/chunk-6UUJEYDV.mjs +0 -213
  32. package/dist/agent-verifier/chunk-7653FPGJ.mjs +0 -381
  33. package/dist/agent-verifier/chunk-BVVNBJM4.mjs +0 -221
  34. package/dist/agent-verifier/chunk-CEDUHGNH.mjs +0 -74
  35. package/dist/agent-verifier/chunk-CEQ2VJWN.mjs +0 -149
  36. package/dist/agent-verifier/chunk-CFU5EWIC.mjs +0 -69
  37. package/dist/agent-verifier/chunk-DTMJCPS4.mjs +0 -730
  38. package/dist/agent-verifier/chunk-EIQWDQWJ.mjs +0 -186
  39. package/dist/agent-verifier/chunk-EOQIV6PS.mjs +0 -649
  40. package/dist/agent-verifier/chunk-HBNDKQT5.mjs +0 -8381
  41. package/dist/agent-verifier/chunk-HJFQDSTU.mjs +0 -225
  42. package/dist/agent-verifier/chunk-LI3ZR3BI.mjs +0 -41
  43. package/dist/agent-verifier/chunk-LM3OZLZG.mjs +0 -48
  44. package/dist/agent-verifier/chunk-MINCYHXN.mjs +0 -106
  45. package/dist/agent-verifier/chunk-MRCUP5SW.mjs +0 -128
  46. package/dist/agent-verifier/chunk-PM3SVG6R.mjs +0 -38
  47. package/dist/agent-verifier/chunk-RBDDIIPM.mjs +0 -19
  48. package/dist/agent-verifier/chunk-RJBLBYHX.mjs +0 -1681
  49. package/dist/agent-verifier/chunk-SHUMAVAP.mjs +0 -59
  50. package/dist/agent-verifier/chunk-SYPLYRGB.mjs +0 -2812
  51. package/dist/agent-verifier/chunk-U6OJN7XS.mjs +0 -8092
  52. package/dist/agent-verifier/chunk-VYJTHSYR.mjs +0 -44
  53. package/dist/agent-verifier/chunk-XYDL7GY6.mjs +0 -10
  54. package/dist/agent-verifier/compile-WNCQQVOF.mjs +0 -313
  55. package/dist/agent-verifier/global-config-WX3ZZIVU.mjs +0 -17
  56. package/dist/agent-verifier/local-files-MTPLP62S.mjs +0 -46
  57. package/dist/agent-verifier/local-typecheck-QFYYAZOK.mjs +0 -9
  58. package/dist/agent-verifier/materialize-workspace-EWGZIVOY.mjs +0 -90
  59. package/dist/agent-verifier/project-state-7GR6BQTQ.mjs +0 -32
  60. package/dist/agent-verifier/reducer-bundle-preflight-C73LEXI2.mjs +0 -23
  61. package/dist/agent-verifier/reducer-contract-preflight-22X7DSZW.mjs +0 -10
  62. package/dist/agent-verifier/reducer-native-test-harness-GMWBUISX.mjs +0 -53
  63. package/dist/agent-verifier/static-scaffold-4YEQME5N.mjs +0 -28
  64. package/dist/agent-verifier/sync-LOQAH4RC.mjs +0 -594
  65. package/dist/agent-verifier/test-YOJERVHN.mjs +0 -356
  66. package/dist/agent-verifier/testing-5K2BJYF2.mjs +0 -674
  67. package/dist/agent-verifier/workspace-codegen-JDZJRSDV.mjs +0 -11
  68. package/dist/agent-verifier/workspace-dependencies-HZ6VVS4G.mjs +0 -14
  69. package/dist/chunk-2H7UOFLK.js +0 -11
  70. package/dist/chunk-3XNJT3RK.js.map +0 -1
  71. package/dist/chunk-7FOO4AJI.js +0 -50
  72. package/dist/chunk-7FOO4AJI.js.map +0 -1
  73. package/dist/chunk-TSJVWTJO.js.map +0 -1
  74. package/dist/internal.d.ts +0 -311
  75. package/dist/keychain-backend-JHTXAKWC.js +0 -135
  76. package/dist/prompt-GMZABCJC.js +0 -756
  77. package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +0 -71
  78. package/dist/runtime-packages/ui-host-runtime/src/browser-interaction.ts +0 -139
  79. package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +0 -374
  80. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +0 -266
  81. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +0 -212
  82. package/dist/runtime-packages/ui-host-runtime/src/components/host-primitives.tsx +0 -271
  83. package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +0 -135
  84. package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +0 -5
  85. package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +0 -194
  86. package/dist/runtime-packages/ui-host-runtime/src/gameplay-authority-transport.ts +0 -626
  87. package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +0 -1
  88. package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +0 -1
  89. package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +0 -294
  90. package/dist/runtime-packages/ui-host-runtime/src/index.ts +0 -3
  91. package/dist/runtime-packages/ui-host-runtime/src/logger.ts +0 -11
  92. package/dist/runtime-packages/ui-host-runtime/src/perf.ts +0 -324
  93. package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +0 -195
  94. package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +0 -138
  95. package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +0 -159
  96. package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +0 -551
  97. package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +0 -13
  98. package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +0 -122
  99. package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +0 -26
  100. package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +0 -583
  101. package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +0 -219
  102. package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +0 -117
  103. package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +0 -431
  104. package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +0 -211
  105. package/dist/runtime-packages/ui-host-runtime/src/session-recovery.ts +0 -80
  106. package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +0 -1034
  107. package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +0 -416
  108. package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +0 -184
  109. package/dist/testing-KLSV6CPJ.js +0 -674
  110. package/dist/testing-KLSV6CPJ.js.map +0 -1
  111. /package/dist/{chunk-2H7UOFLK.js.map → chunk-SEGVTWSK.js.map} +0 -0
  112. /package/dist/{global-config-UKSWNDTX.js.map → global-config-S4ZIPECE.js.map} +0 -0
  113. /package/dist/{keychain-backend-JHTXAKWC.js.map → keychain-backend-HDF4TZDL.js.map} +0 -0
  114. /package/dist/{prompt-GMZABCJC.js.map → prompt-NDV3AE5L.js.map} +0 -0
@@ -1,835 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // ../../packages/api-client/src/core/bodySerializer.gen.ts
4
- var jsonBodySerializer = {
5
- bodySerializer: (body) => JSON.stringify(
6
- body,
7
- (_key, value) => typeof value === "bigint" ? value.toString() : value
8
- )
9
- };
10
-
11
- // ../../packages/api-client/src/core/params.gen.ts
12
- var extraPrefixesMap = {
13
- $body_: "body",
14
- $headers_: "headers",
15
- $path_: "path",
16
- $query_: "query"
17
- };
18
- var extraPrefixes = Object.entries(extraPrefixesMap);
19
-
20
- // ../../packages/api-client/src/core/serverSentEvents.gen.ts
21
- var createSseClient = ({
22
- onRequest,
23
- onSseError,
24
- onSseEvent,
25
- responseTransformer,
26
- responseValidator,
27
- sseDefaultRetryDelay,
28
- sseMaxRetryAttempts,
29
- sseMaxRetryDelay,
30
- sseSleepFn,
31
- url,
32
- ...options
33
- }) => {
34
- let lastEventId;
35
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
36
- const createStream = async function* () {
37
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
38
- let attempt = 0;
39
- const signal = options.signal ?? new AbortController().signal;
40
- while (true) {
41
- if (signal.aborted) break;
42
- attempt++;
43
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
44
- if (lastEventId !== void 0) {
45
- headers.set("Last-Event-ID", lastEventId);
46
- }
47
- try {
48
- const requestInit = {
49
- redirect: "follow",
50
- ...options,
51
- body: options.serializedBody,
52
- headers,
53
- signal
54
- };
55
- let request = new Request(url, requestInit);
56
- if (onRequest) {
57
- request = await onRequest(url, requestInit);
58
- }
59
- const _fetch = options.fetch ?? globalThis.fetch;
60
- const response = await _fetch(request);
61
- if (!response.ok)
62
- throw new Error(
63
- `SSE failed: ${response.status} ${response.statusText}`
64
- );
65
- if (!response.body) throw new Error("No body in SSE response");
66
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
67
- let buffer = "";
68
- const abortHandler = () => {
69
- try {
70
- reader.cancel();
71
- } catch {
72
- }
73
- };
74
- signal.addEventListener("abort", abortHandler);
75
- try {
76
- while (true) {
77
- const { done, value } = await reader.read();
78
- if (done) break;
79
- buffer += value;
80
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
81
- const chunks = buffer.split("\n\n");
82
- buffer = chunks.pop() ?? "";
83
- for (const chunk of chunks) {
84
- const lines = chunk.split("\n");
85
- const dataLines = [];
86
- let eventName;
87
- for (const line of lines) {
88
- if (line.startsWith("data:")) {
89
- dataLines.push(line.replace(/^data:\s*/, ""));
90
- } else if (line.startsWith("event:")) {
91
- eventName = line.replace(/^event:\s*/, "");
92
- } else if (line.startsWith("id:")) {
93
- lastEventId = line.replace(/^id:\s*/, "");
94
- } else if (line.startsWith("retry:")) {
95
- const parsed = Number.parseInt(
96
- line.replace(/^retry:\s*/, ""),
97
- 10
98
- );
99
- if (!Number.isNaN(parsed)) {
100
- retryDelay = parsed;
101
- }
102
- }
103
- }
104
- let data;
105
- let parsedJson = false;
106
- if (dataLines.length) {
107
- const rawData = dataLines.join("\n");
108
- try {
109
- data = JSON.parse(rawData);
110
- parsedJson = true;
111
- } catch {
112
- data = rawData;
113
- }
114
- }
115
- if (parsedJson) {
116
- if (responseValidator) {
117
- await responseValidator(data);
118
- }
119
- if (responseTransformer) {
120
- data = await responseTransformer(data);
121
- }
122
- }
123
- onSseEvent?.({
124
- data,
125
- event: eventName,
126
- id: lastEventId,
127
- retry: retryDelay
128
- });
129
- if (dataLines.length && data !== "") {
130
- yield data;
131
- }
132
- }
133
- }
134
- } finally {
135
- signal.removeEventListener("abort", abortHandler);
136
- reader.releaseLock();
137
- }
138
- break;
139
- } catch (error) {
140
- onSseError?.(error);
141
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
142
- throw error;
143
- }
144
- const backoff = Math.min(
145
- retryDelay * 2 ** (attempt - 1),
146
- sseMaxRetryDelay ?? 3e4
147
- );
148
- await sleep(backoff);
149
- }
150
- }
151
- };
152
- const stream = createStream();
153
- return { stream };
154
- };
155
-
156
- // ../../packages/api-client/src/core/pathSerializer.gen.ts
157
- var separatorArrayExplode = (style) => {
158
- switch (style) {
159
- case "label":
160
- return ".";
161
- case "matrix":
162
- return ";";
163
- case "simple":
164
- return ",";
165
- default:
166
- return "&";
167
- }
168
- };
169
- var separatorArrayNoExplode = (style) => {
170
- switch (style) {
171
- case "form":
172
- return ",";
173
- case "pipeDelimited":
174
- return "|";
175
- case "spaceDelimited":
176
- return "%20";
177
- default:
178
- return ",";
179
- }
180
- };
181
- var separatorObjectExplode = (style) => {
182
- switch (style) {
183
- case "label":
184
- return ".";
185
- case "matrix":
186
- return ";";
187
- case "simple":
188
- return ",";
189
- default:
190
- return "&";
191
- }
192
- };
193
- var serializeArrayParam = ({
194
- allowReserved,
195
- explode,
196
- name,
197
- style,
198
- value
199
- }) => {
200
- if (!explode) {
201
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
202
- switch (style) {
203
- case "label":
204
- return `.${joinedValues2}`;
205
- case "matrix":
206
- return `;${name}=${joinedValues2}`;
207
- case "simple":
208
- return joinedValues2;
209
- default:
210
- return `${name}=${joinedValues2}`;
211
- }
212
- }
213
- const separator = separatorArrayExplode(style);
214
- const joinedValues = value.map((v) => {
215
- if (style === "label" || style === "simple") {
216
- return allowReserved ? v : encodeURIComponent(v);
217
- }
218
- return serializePrimitiveParam({
219
- allowReserved,
220
- name,
221
- value: v
222
- });
223
- }).join(separator);
224
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
225
- };
226
- var serializePrimitiveParam = ({
227
- allowReserved,
228
- name,
229
- value
230
- }) => {
231
- if (value === void 0 || value === null) {
232
- return "";
233
- }
234
- if (typeof value === "object") {
235
- throw new Error(
236
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
237
- );
238
- }
239
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
240
- };
241
- var serializeObjectParam = ({
242
- allowReserved,
243
- explode,
244
- name,
245
- style,
246
- value,
247
- valueOnly
248
- }) => {
249
- if (value instanceof Date) {
250
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
251
- }
252
- if (style !== "deepObject" && !explode) {
253
- let values = [];
254
- Object.entries(value).forEach(([key, v]) => {
255
- values = [
256
- ...values,
257
- key,
258
- allowReserved ? v : encodeURIComponent(v)
259
- ];
260
- });
261
- const joinedValues2 = values.join(",");
262
- switch (style) {
263
- case "form":
264
- return `${name}=${joinedValues2}`;
265
- case "label":
266
- return `.${joinedValues2}`;
267
- case "matrix":
268
- return `;${name}=${joinedValues2}`;
269
- default:
270
- return joinedValues2;
271
- }
272
- }
273
- const separator = separatorObjectExplode(style);
274
- const joinedValues = Object.entries(value).map(
275
- ([key, v]) => serializePrimitiveParam({
276
- allowReserved,
277
- name: style === "deepObject" ? `${name}[${key}]` : key,
278
- value: v
279
- })
280
- ).join(separator);
281
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
282
- };
283
-
284
- // ../../packages/api-client/src/core/utils.gen.ts
285
- var PATH_PARAM_RE = /\{[^{}]+\}/g;
286
- var defaultPathSerializer = ({ path, url: _url }) => {
287
- let url = _url;
288
- const matches = _url.match(PATH_PARAM_RE);
289
- if (matches) {
290
- for (const match of matches) {
291
- let explode = false;
292
- let name = match.substring(1, match.length - 1);
293
- let style = "simple";
294
- if (name.endsWith("*")) {
295
- explode = true;
296
- name = name.substring(0, name.length - 1);
297
- }
298
- if (name.startsWith(".")) {
299
- name = name.substring(1);
300
- style = "label";
301
- } else if (name.startsWith(";")) {
302
- name = name.substring(1);
303
- style = "matrix";
304
- }
305
- const value = path[name];
306
- if (value === void 0 || value === null) {
307
- continue;
308
- }
309
- if (Array.isArray(value)) {
310
- url = url.replace(
311
- match,
312
- serializeArrayParam({ explode, name, style, value })
313
- );
314
- continue;
315
- }
316
- if (typeof value === "object") {
317
- url = url.replace(
318
- match,
319
- serializeObjectParam({
320
- explode,
321
- name,
322
- style,
323
- value,
324
- valueOnly: true
325
- })
326
- );
327
- continue;
328
- }
329
- if (style === "matrix") {
330
- url = url.replace(
331
- match,
332
- `;${serializePrimitiveParam({
333
- name,
334
- value
335
- })}`
336
- );
337
- continue;
338
- }
339
- const replaceValue = encodeURIComponent(
340
- style === "label" ? `.${value}` : value
341
- );
342
- url = url.replace(match, replaceValue);
343
- }
344
- }
345
- return url;
346
- };
347
- var getUrl = ({
348
- baseUrl,
349
- path,
350
- query,
351
- querySerializer,
352
- url: _url
353
- }) => {
354
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
355
- let url = (baseUrl ?? "") + pathUrl;
356
- if (path) {
357
- url = defaultPathSerializer({ path, url });
358
- }
359
- let search = query ? querySerializer(query) : "";
360
- if (search.startsWith("?")) {
361
- search = search.substring(1);
362
- }
363
- if (search) {
364
- url += `?${search}`;
365
- }
366
- return url;
367
- };
368
- function getValidRequestBody(options) {
369
- const hasBody = options.body !== void 0;
370
- const isSerializedBody = hasBody && options.bodySerializer;
371
- if (isSerializedBody) {
372
- if ("serializedBody" in options) {
373
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
374
- return hasSerializedBody ? options.serializedBody : null;
375
- }
376
- return options.body !== "" ? options.body : null;
377
- }
378
- if (hasBody) {
379
- return options.body;
380
- }
381
- return void 0;
382
- }
383
-
384
- // ../../packages/api-client/src/core/auth.gen.ts
385
- var getAuthToken = async (auth, callback) => {
386
- const token = typeof callback === "function" ? await callback(auth) : callback;
387
- if (!token) {
388
- return;
389
- }
390
- if (auth.scheme === "bearer") {
391
- return `Bearer ${token}`;
392
- }
393
- if (auth.scheme === "basic") {
394
- return `Basic ${btoa(token)}`;
395
- }
396
- return token;
397
- };
398
-
399
- // ../../packages/api-client/src/client/utils.gen.ts
400
- var createQuerySerializer = ({
401
- parameters = {},
402
- ...args
403
- } = {}) => {
404
- const querySerializer = (queryParams) => {
405
- const search = [];
406
- if (queryParams && typeof queryParams === "object") {
407
- for (const name in queryParams) {
408
- const value = queryParams[name];
409
- if (value === void 0 || value === null) {
410
- continue;
411
- }
412
- const options = parameters[name] || args;
413
- if (Array.isArray(value)) {
414
- const serializedArray = serializeArrayParam({
415
- allowReserved: options.allowReserved,
416
- explode: true,
417
- name,
418
- style: "form",
419
- value,
420
- ...options.array
421
- });
422
- if (serializedArray) search.push(serializedArray);
423
- } else if (typeof value === "object") {
424
- const serializedObject = serializeObjectParam({
425
- allowReserved: options.allowReserved,
426
- explode: true,
427
- name,
428
- style: "deepObject",
429
- value,
430
- ...options.object
431
- });
432
- if (serializedObject) search.push(serializedObject);
433
- } else {
434
- const serializedPrimitive = serializePrimitiveParam({
435
- allowReserved: options.allowReserved,
436
- name,
437
- value
438
- });
439
- if (serializedPrimitive) search.push(serializedPrimitive);
440
- }
441
- }
442
- }
443
- return search.join("&");
444
- };
445
- return querySerializer;
446
- };
447
- var getParseAs = (contentType) => {
448
- if (!contentType) {
449
- return "stream";
450
- }
451
- const cleanContent = contentType.split(";")[0]?.trim();
452
- if (!cleanContent) {
453
- return;
454
- }
455
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
456
- return "json";
457
- }
458
- if (cleanContent === "multipart/form-data") {
459
- return "formData";
460
- }
461
- if (["application/", "audio/", "image/", "video/"].some(
462
- (type) => cleanContent.startsWith(type)
463
- )) {
464
- return "blob";
465
- }
466
- if (cleanContent.startsWith("text/")) {
467
- return "text";
468
- }
469
- return;
470
- };
471
- var checkForExistence = (options, name) => {
472
- if (!name) {
473
- return false;
474
- }
475
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
476
- return true;
477
- }
478
- return false;
479
- };
480
- var setAuthParams = async ({
481
- security,
482
- ...options
483
- }) => {
484
- for (const auth of security) {
485
- if (checkForExistence(options, auth.name)) {
486
- continue;
487
- }
488
- const token = await getAuthToken(auth, options.auth);
489
- if (!token) {
490
- continue;
491
- }
492
- const name = auth.name ?? "Authorization";
493
- switch (auth.in) {
494
- case "query":
495
- if (!options.query) {
496
- options.query = {};
497
- }
498
- options.query[name] = token;
499
- break;
500
- case "cookie":
501
- options.headers.append("Cookie", `${name}=${token}`);
502
- break;
503
- case "header":
504
- default:
505
- options.headers.set(name, token);
506
- break;
507
- }
508
- }
509
- };
510
- var buildUrl = (options) => getUrl({
511
- baseUrl: options.baseUrl,
512
- path: options.path,
513
- query: options.query,
514
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
515
- url: options.url
516
- });
517
- var mergeConfigs = (a, b) => {
518
- const config = { ...a, ...b };
519
- if (config.baseUrl?.endsWith("/")) {
520
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
521
- }
522
- config.headers = mergeHeaders(a.headers, b.headers);
523
- return config;
524
- };
525
- var headersEntries = (headers) => {
526
- const entries = [];
527
- headers.forEach((value, key) => {
528
- entries.push([key, value]);
529
- });
530
- return entries;
531
- };
532
- var mergeHeaders = (...headers) => {
533
- const mergedHeaders = new Headers();
534
- for (const header of headers) {
535
- if (!header) {
536
- continue;
537
- }
538
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
539
- for (const [key, value] of iterator) {
540
- if (value === null) {
541
- mergedHeaders.delete(key);
542
- } else if (Array.isArray(value)) {
543
- for (const v of value) {
544
- mergedHeaders.append(key, v);
545
- }
546
- } else if (value !== void 0) {
547
- mergedHeaders.set(
548
- key,
549
- typeof value === "object" ? JSON.stringify(value) : value
550
- );
551
- }
552
- }
553
- }
554
- return mergedHeaders;
555
- };
556
- var Interceptors = class {
557
- fns = [];
558
- clear() {
559
- this.fns = [];
560
- }
561
- eject(id) {
562
- const index = this.getInterceptorIndex(id);
563
- if (this.fns[index]) {
564
- this.fns[index] = null;
565
- }
566
- }
567
- exists(id) {
568
- const index = this.getInterceptorIndex(id);
569
- return Boolean(this.fns[index]);
570
- }
571
- getInterceptorIndex(id) {
572
- if (typeof id === "number") {
573
- return this.fns[id] ? id : -1;
574
- }
575
- return this.fns.indexOf(id);
576
- }
577
- update(id, fn) {
578
- const index = this.getInterceptorIndex(id);
579
- if (this.fns[index]) {
580
- this.fns[index] = fn;
581
- return id;
582
- }
583
- return false;
584
- }
585
- use(fn) {
586
- this.fns.push(fn);
587
- return this.fns.length - 1;
588
- }
589
- };
590
- var createInterceptors = () => ({
591
- error: new Interceptors(),
592
- request: new Interceptors(),
593
- response: new Interceptors()
594
- });
595
- var defaultQuerySerializer = createQuerySerializer({
596
- allowReserved: false,
597
- array: {
598
- explode: true,
599
- style: "form"
600
- },
601
- object: {
602
- explode: true,
603
- style: "deepObject"
604
- }
605
- });
606
- var defaultHeaders = {
607
- "Content-Type": "application/json"
608
- };
609
- var createConfig = (override = {}) => ({
610
- ...jsonBodySerializer,
611
- headers: defaultHeaders,
612
- parseAs: "auto",
613
- querySerializer: defaultQuerySerializer,
614
- ...override
615
- });
616
-
617
- // ../../packages/api-client/src/client/client.gen.ts
618
- var createClient = (config = {}) => {
619
- let _config = mergeConfigs(createConfig(), config);
620
- const getConfig = () => ({ ..._config });
621
- const setConfig = (config2) => {
622
- _config = mergeConfigs(_config, config2);
623
- return getConfig();
624
- };
625
- const interceptors = createInterceptors();
626
- const beforeRequest = async (options) => {
627
- const opts = {
628
- ..._config,
629
- ...options,
630
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
631
- headers: mergeHeaders(_config.headers, options.headers),
632
- serializedBody: void 0
633
- };
634
- if (opts.security) {
635
- await setAuthParams({
636
- ...opts,
637
- security: opts.security
638
- });
639
- }
640
- if (opts.requestValidator) {
641
- await opts.requestValidator(opts);
642
- }
643
- if (opts.body !== void 0 && opts.bodySerializer) {
644
- opts.serializedBody = opts.bodySerializer(opts.body);
645
- }
646
- if (opts.body === void 0 || opts.serializedBody === "") {
647
- opts.headers.delete("Content-Type");
648
- }
649
- const url = buildUrl(opts);
650
- return { opts, url };
651
- };
652
- const request = async (options) => {
653
- const { opts, url } = await beforeRequest(options);
654
- const requestInit = {
655
- redirect: "follow",
656
- ...opts,
657
- body: getValidRequestBody(opts)
658
- };
659
- let request2 = new Request(url, requestInit);
660
- for (const fn of interceptors.request.fns) {
661
- if (fn) {
662
- request2 = await fn(request2, opts);
663
- }
664
- }
665
- const _fetch = opts.fetch;
666
- let response;
667
- try {
668
- response = await _fetch(request2);
669
- } catch (error2) {
670
- let finalError2 = error2;
671
- for (const fn of interceptors.error.fns) {
672
- if (fn) {
673
- finalError2 = await fn(
674
- error2,
675
- void 0,
676
- request2,
677
- opts
678
- );
679
- }
680
- }
681
- finalError2 = finalError2 || {};
682
- if (opts.throwOnError) {
683
- throw finalError2;
684
- }
685
- return opts.responseStyle === "data" ? void 0 : {
686
- error: finalError2,
687
- request: request2,
688
- response: void 0
689
- };
690
- }
691
- for (const fn of interceptors.response.fns) {
692
- if (fn) {
693
- response = await fn(response, request2, opts);
694
- }
695
- }
696
- const result = {
697
- request: request2,
698
- response
699
- };
700
- if (response.ok) {
701
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
702
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
703
- let emptyData;
704
- switch (parseAs) {
705
- case "arrayBuffer":
706
- case "blob":
707
- case "text":
708
- emptyData = await response[parseAs]();
709
- break;
710
- case "formData":
711
- emptyData = new FormData();
712
- break;
713
- case "stream":
714
- emptyData = response.body;
715
- break;
716
- case "json":
717
- default:
718
- emptyData = {};
719
- break;
720
- }
721
- return opts.responseStyle === "data" ? emptyData : {
722
- data: emptyData,
723
- ...result
724
- };
725
- }
726
- let data;
727
- switch (parseAs) {
728
- case "arrayBuffer":
729
- case "blob":
730
- case "formData":
731
- case "text":
732
- data = await response[parseAs]();
733
- break;
734
- case "json": {
735
- const text = await response.text();
736
- data = text ? JSON.parse(text) : {};
737
- break;
738
- }
739
- case "stream":
740
- return opts.responseStyle === "data" ? response.body : {
741
- data: response.body,
742
- ...result
743
- };
744
- }
745
- if (parseAs === "json") {
746
- if (opts.responseValidator) {
747
- await opts.responseValidator(data);
748
- }
749
- if (opts.responseTransformer) {
750
- data = await opts.responseTransformer(data);
751
- }
752
- }
753
- return opts.responseStyle === "data" ? data : {
754
- data,
755
- ...result
756
- };
757
- }
758
- const textError = await response.text();
759
- let jsonError;
760
- try {
761
- jsonError = JSON.parse(textError);
762
- } catch {
763
- }
764
- const error = jsonError ?? textError;
765
- let finalError = error;
766
- for (const fn of interceptors.error.fns) {
767
- if (fn) {
768
- finalError = await fn(error, response, request2, opts);
769
- }
770
- }
771
- finalError = finalError || {};
772
- if (opts.throwOnError) {
773
- throw finalError;
774
- }
775
- return opts.responseStyle === "data" ? void 0 : {
776
- error: finalError,
777
- ...result
778
- };
779
- };
780
- const makeMethodFn = (method) => (options) => request({ ...options, method });
781
- const makeSseFn = (method) => async (options) => {
782
- const { opts, url } = await beforeRequest(options);
783
- return createSseClient({
784
- ...opts,
785
- body: opts.body,
786
- headers: opts.headers,
787
- method,
788
- onRequest: async (url2, init) => {
789
- let request2 = new Request(url2, init);
790
- for (const fn of interceptors.request.fns) {
791
- if (fn) {
792
- request2 = await fn(request2, opts);
793
- }
794
- }
795
- return request2;
796
- },
797
- serializedBody: getValidRequestBody(opts),
798
- url
799
- });
800
- };
801
- return {
802
- buildUrl,
803
- connect: makeMethodFn("CONNECT"),
804
- delete: makeMethodFn("DELETE"),
805
- get: makeMethodFn("GET"),
806
- getConfig,
807
- head: makeMethodFn("HEAD"),
808
- interceptors,
809
- options: makeMethodFn("OPTIONS"),
810
- patch: makeMethodFn("PATCH"),
811
- post: makeMethodFn("POST"),
812
- put: makeMethodFn("PUT"),
813
- request,
814
- setConfig,
815
- sse: {
816
- connect: makeSseFn("CONNECT"),
817
- delete: makeSseFn("DELETE"),
818
- get: makeSseFn("GET"),
819
- head: makeSseFn("HEAD"),
820
- options: makeSseFn("OPTIONS"),
821
- patch: makeSseFn("PATCH"),
822
- post: makeSseFn("POST"),
823
- put: makeSseFn("PUT"),
824
- trace: makeSseFn("TRACE")
825
- },
826
- trace: makeMethodFn("TRACE")
827
- };
828
- };
829
-
830
- // ../../packages/api-client/src/client.gen.ts
831
- var client = createClient(createConfig({ baseUrl: "https://dreamboard.games" }));
832
-
833
- export {
834
- client
835
- };