@domino-sdk/relay-cli 0.7.0 → 0.8.0

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/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  // src/index.ts
2
- import { pointLedgerSchema } from "@domino-sdk/relay";
2
+ import { createStockItemSchema, stockItemSchema } from "@domino-sdk/relay";
3
+ import { allocateQuestSchema, allocatedQuestSchema } from "@domino-sdk/relay";
4
+ import { createPointLedgerSchema, pointLedgerSchema } from "@domino-sdk/relay";
3
5
  import { rewardDeliveriesSchema } from "@domino-sdk/relay";
4
6
  import {
5
7
  observationInputSchema,
@@ -296,7 +298,7 @@ var projectSchema = z3.object({
296
298
  environments: z3.array(environmentSchema)
297
299
  });
298
300
  var projectInputSchema = z3.object({
299
- project: identifier2,
301
+ actionId: identifier2,
300
302
  name: z3.string().trim().min(1).max(80),
301
303
  setup: projectSetupSchema.optional()
302
304
  }).strict();
@@ -381,6 +383,7 @@ var readinessSchema = z3.object({
381
383
  });
382
384
  var inventorySchema = z3.object({
383
385
  item: z3.string(),
386
+ name: z3.string().nullable().default(null),
384
387
  available: z3.number(),
385
388
  reserved: z3.number(),
386
389
  allocated: z3.number().default(0)
@@ -443,6 +446,14 @@ var tokenSchema = z3.object({
443
446
  permissions: z3.array(permissionSchema),
444
447
  expiresAt: z3.number()
445
448
  });
449
+ var CreationError = class extends Error {
450
+ constructor(message, actionId, cause) {
451
+ super(message, { cause });
452
+ this.actionId = actionId;
453
+ this.name = "CreationError";
454
+ }
455
+ actionId;
456
+ };
446
457
  function createManagementClient(options) {
447
458
  async function raw(path, init) {
448
459
  const headers = new Headers(init?.headers);
@@ -459,8 +470,11 @@ function createManagementClient(options) {
459
470
  });
460
471
  if (!response.ok) {
461
472
  const error = z3.object({ error: z3.string() }).safeParse(await response.json().catch(() => null));
462
- throw new Error(
463
- error.success ? error.data.error : `Request failed (${response.status})`
473
+ throw Object.assign(
474
+ new Error(
475
+ error.success ? error.data.error : `Request failed (${response.status})`
476
+ ),
477
+ { status: response.status }
464
478
  );
465
479
  }
466
480
  return response;
@@ -476,6 +490,26 @@ function createManagementClient(options) {
476
490
  );
477
491
  return schema.parse(await response.json());
478
492
  }
493
+ async function create(path, responseSchema, inputSchema, input) {
494
+ const payload = inputSchema.parse({
495
+ ...input,
496
+ actionId: input.actionId ?? crypto.randomUUID()
497
+ });
498
+ for (let attempt = 0; ; attempt++) {
499
+ try {
500
+ return await request(path, responseSchema, payload);
501
+ } catch (error) {
502
+ const status = error instanceof Error && "status" in error ? error.status : void 0;
503
+ if (attempt === 0 && (status === void 0 || typeof status === "number" && status >= 500))
504
+ continue;
505
+ throw new CreationError(
506
+ error instanceof Error ? error.message : "Creation failed",
507
+ payload.actionId,
508
+ error
509
+ );
510
+ }
511
+ }
512
+ }
479
513
  return {
480
514
  raw,
481
515
  request,
@@ -489,12 +523,19 @@ function createManagementClient(options) {
489
523
  pointLedgers: {
490
524
  list: () => request("/point-ledgers", z3.array(pointLedgerSchema)),
491
525
  save: (input) => request(
492
- "/point-ledgers",
526
+ "/point-ledgers/update",
493
527
  pointLedgerSchema,
494
528
  pointLedgerSchema.parse(input)
495
529
  )
496
530
  },
497
531
  points: {
532
+ ledgers: () => request("/point-ledgers", z3.array(pointLedgerSchema)),
533
+ createLedger: (input) => create(
534
+ "/point-ledgers",
535
+ pointLedgerSchema,
536
+ createPointLedgerSchema,
537
+ input
538
+ ),
498
539
  update: (input) => request(
499
540
  "/points",
500
541
  pointsResultSchema,
@@ -573,6 +614,12 @@ function createManagementClient(options) {
573
614
  )
574
615
  },
575
616
  catalog: {
617
+ allocateQuest: (input = {}) => create(
618
+ "/catalog/quests",
619
+ allocatedQuestSchema,
620
+ allocateQuestSchema,
621
+ input
622
+ ),
576
623
  read: () => request("/catalog", questCatalogSchema),
577
624
  previewDeployment: (input) => request(
578
625
  "/catalog/deploy/preview",
@@ -613,6 +660,7 @@ function createManagementClient(options) {
613
660
  )
614
661
  },
615
662
  inventory: {
663
+ createItem: (input) => create("/stock-items", stockItemSchema, createStockItemSchema, input),
616
664
  catalog: () => request("/pickup-inventory", z3.array(pickupCatalogSchema)),
617
665
  configure: (input) => request(
618
666
  "/pickup-inventory",
@@ -626,7 +674,7 @@ function createManagementClient(options) {
626
674
  },
627
675
  readiness: () => request("/readiness", readinessSchema),
628
676
  access: () => request("/access", accessSchema),
629
- createProject: (input) => request("/projects", projectSchema, input),
677
+ createProject: (input) => create("/projects", projectSchema, projectInputSchema, input),
630
678
  people: (members) => request(
631
679
  `/people?${new URLSearchParams({ ids: members.join(",") })}`,
632
680
  z3.array(personSchema)
@@ -643,6 +691,7 @@ function createManagementClient(options) {
643
691
  };
644
692
  }
645
693
  export {
694
+ CreationError,
646
695
  accessSchema,
647
696
  accountProfileSchema,
648
697
  appRoutingSchema,
package/package.json CHANGED
@@ -9,10 +9,12 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "commander": "15.0.0",
12
+ "diff": "8.0.4",
13
+ "typescript": "6.0.2",
12
14
  "zod": "4.3.6",
13
- "@domino-sdk/relay": "0.7.0"
15
+ "@domino-sdk/relay": "0.8.0"
14
16
  },
15
- "version": "0.7.0",
17
+ "version": "0.8.0",
16
18
  "bin": {
17
19
  "domino": "./cli.mjs"
18
20
  },