@domino-sdk/relay-cli 0.6.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,4 +1,7 @@
1
1
  // src/index.ts
2
+ import { createStockItemSchema, stockItemSchema } from "@domino-sdk/relay";
3
+ import { allocateQuestSchema, allocatedQuestSchema } from "@domino-sdk/relay";
4
+ import { createPointLedgerSchema, pointLedgerSchema } from "@domino-sdk/relay";
2
5
  import { rewardDeliveriesSchema } from "@domino-sdk/relay";
3
6
  import {
4
7
  observationInputSchema,
@@ -295,7 +298,7 @@ var projectSchema = z3.object({
295
298
  environments: z3.array(environmentSchema)
296
299
  });
297
300
  var projectInputSchema = z3.object({
298
- project: identifier2,
301
+ actionId: identifier2,
299
302
  name: z3.string().trim().min(1).max(80),
300
303
  setup: projectSetupSchema.optional()
301
304
  }).strict();
@@ -380,6 +383,7 @@ var readinessSchema = z3.object({
380
383
  });
381
384
  var inventorySchema = z3.object({
382
385
  item: z3.string(),
386
+ name: z3.string().nullable().default(null),
383
387
  available: z3.number(),
384
388
  reserved: z3.number(),
385
389
  allocated: z3.number().default(0)
@@ -442,6 +446,14 @@ var tokenSchema = z3.object({
442
446
  permissions: z3.array(permissionSchema),
443
447
  expiresAt: z3.number()
444
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
+ };
445
457
  function createManagementClient(options) {
446
458
  async function raw(path, init) {
447
459
  const headers = new Headers(init?.headers);
@@ -458,8 +470,11 @@ function createManagementClient(options) {
458
470
  });
459
471
  if (!response.ok) {
460
472
  const error = z3.object({ error: z3.string() }).safeParse(await response.json().catch(() => null));
461
- throw new Error(
462
- 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 }
463
478
  );
464
479
  }
465
480
  return response;
@@ -475,6 +490,26 @@ function createManagementClient(options) {
475
490
  );
476
491
  return schema.parse(await response.json());
477
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
+ }
478
513
  return {
479
514
  raw,
480
515
  request,
@@ -485,7 +520,22 @@ function createManagementClient(options) {
485
520
  observationInputSchema.parse(input)
486
521
  )
487
522
  },
523
+ pointLedgers: {
524
+ list: () => request("/point-ledgers", z3.array(pointLedgerSchema)),
525
+ save: (input) => request(
526
+ "/point-ledgers/update",
527
+ pointLedgerSchema,
528
+ pointLedgerSchema.parse(input)
529
+ )
530
+ },
488
531
  points: {
532
+ ledgers: () => request("/point-ledgers", z3.array(pointLedgerSchema)),
533
+ createLedger: (input) => create(
534
+ "/point-ledgers",
535
+ pointLedgerSchema,
536
+ createPointLedgerSchema,
537
+ input
538
+ ),
489
539
  update: (input) => request(
490
540
  "/points",
491
541
  pointsResultSchema,
@@ -564,6 +614,12 @@ function createManagementClient(options) {
564
614
  )
565
615
  },
566
616
  catalog: {
617
+ allocateQuest: (input = {}) => create(
618
+ "/catalog/quests",
619
+ allocatedQuestSchema,
620
+ allocateQuestSchema,
621
+ input
622
+ ),
567
623
  read: () => request("/catalog", questCatalogSchema),
568
624
  previewDeployment: (input) => request(
569
625
  "/catalog/deploy/preview",
@@ -604,6 +660,7 @@ function createManagementClient(options) {
604
660
  )
605
661
  },
606
662
  inventory: {
663
+ createItem: (input) => create("/stock-items", stockItemSchema, createStockItemSchema, input),
607
664
  catalog: () => request("/pickup-inventory", z3.array(pickupCatalogSchema)),
608
665
  configure: (input) => request(
609
666
  "/pickup-inventory",
@@ -617,7 +674,7 @@ function createManagementClient(options) {
617
674
  },
618
675
  readiness: () => request("/readiness", readinessSchema),
619
676
  access: () => request("/access", accessSchema),
620
- createProject: (input) => request("/projects", projectSchema, input),
677
+ createProject: (input) => create("/projects", projectSchema, projectInputSchema, input),
621
678
  people: (members) => request(
622
679
  `/people?${new URLSearchParams({ ids: members.join(",") })}`,
623
680
  z3.array(personSchema)
@@ -634,6 +691,7 @@ function createManagementClient(options) {
634
691
  };
635
692
  }
636
693
  export {
694
+ CreationError,
637
695
  accessSchema,
638
696
  accountProfileSchema,
639
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.6.0"
15
+ "@domino-sdk/relay": "0.8.0"
14
16
  },
15
- "version": "0.6.0",
17
+ "version": "0.8.0",
16
18
  "bin": {
17
19
  "domino": "./cli.mjs"
18
20
  },