@domino-sdk/relay-cli 0.4.0 → 0.6.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,9 @@
1
1
  // src/index.ts
2
+ import { rewardDeliveriesSchema } from "@domino-sdk/relay";
3
+ import {
4
+ observationInputSchema,
5
+ observationReceiptSchema
6
+ } from "@domino-sdk/relay";
2
7
  import {
3
8
  publishedReferralSchema,
4
9
  referralManagementSchema,
@@ -32,6 +37,46 @@ import { z as z3 } from "zod";
32
37
  // src/hosting.ts
33
38
  import { z } from "zod";
34
39
  import { identifier } from "@domino-sdk/relay";
40
+ var outputPathSchema = z.string().min(1).max(512).refine(
41
+ (path) => path.split("/").every(
42
+ (part) => /^[\w-][\w.-]*$/.test(part) && part !== "node_modules"
43
+ ),
44
+ "Expected a relative build output path without hidden segments"
45
+ );
46
+ var appRoutingSchema = z.enum(["legacy", "transparent"]).default("legacy");
47
+ var appScripts = {
48
+ routing: appRoutingSchema,
49
+ devScript: z.string().regex(/^[\w:-]+$/),
50
+ checkScript: z.string().regex(/^[\w:-]+$/),
51
+ buildScript: z.string().regex(/^[\w:-]+$/)
52
+ };
53
+ var workerSettings = {
54
+ runWorkerFirst: z.boolean().default(false),
55
+ main: outputPathSchema.refine(
56
+ (path) => /\.m?js$/.test(path),
57
+ "Expected a compiled JavaScript entry"
58
+ ),
59
+ compatibilityDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
60
+ compatibilityFlags: z.array(z.string().min(1)).max(50).default([]),
61
+ vars: z.record(
62
+ z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).refine((name) => name !== "ASSETS"),
63
+ z.string()
64
+ ).default({})
65
+ };
66
+ var hostedAppSchema = z.discriminatedUnion("kind", [
67
+ z.object({
68
+ kind: z.literal("static"),
69
+ directory: outputPathSchema,
70
+ ...appScripts
71
+ }).strict(),
72
+ z.object({
73
+ kind: z.literal("worker"),
74
+ directory: outputPathSchema,
75
+ assetsDirectory: outputPathSchema.optional(),
76
+ ...appScripts,
77
+ ...workerSettings
78
+ }).strict()
79
+ ]);
35
80
  var repositorySchema = z.object({
36
81
  id: z.string().uuid(),
37
82
  organization: identifier,
@@ -60,6 +105,8 @@ var stageRequestSchema = z.object({
60
105
  requestId: z.string().uuid()
61
106
  }).strict();
62
107
  var buildIdentitySchema = z.object({
108
+ routing: appRoutingSchema,
109
+ slug: z.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
63
110
  runtime: z.enum(["simulation", "hosted-test"]).default("simulation"),
64
111
  id: z.string().uuid(),
65
112
  repository: z.string().uuid(),
@@ -99,11 +146,29 @@ var buildSnapshotSchema = z.object({
99
146
  logs: z.string()
100
147
  });
101
148
  var assetPathSchema = z.string().max(512).refine(
102
- (path) => path.startsWith("/") && !/[\\\u0000-\u001f?#%]/.test(path) && path.slice(1).split("/").every((part) => part.length > 0 && !part.startsWith(".")) && !path.startsWith("/relay/") && !path.startsWith("/__domino/"),
103
- "Expected a public asset path without hidden or reserved segments"
149
+ (path) => path.startsWith("/") && !/[\\\u0000-\u001f?#%]/.test(path) && path.slice(1).split("/").every((part) => part.length > 0 && !part.startsWith(".")),
150
+ "Expected a public asset path without hidden segments"
104
151
  );
105
152
  var buildArtifactsSchema = z.object({
106
153
  format: z.literal(1),
154
+ routing: appRoutingSchema,
155
+ worker: z.object({
156
+ ...workerSettings,
157
+ modules: z.array(
158
+ z.object({
159
+ path: outputPathSchema.refine((path) => path !== "metadata"),
160
+ type: z.enum([
161
+ "application/javascript+module",
162
+ "application/wasm",
163
+ "text/plain",
164
+ "application/octet-stream"
165
+ ]),
166
+ content: z.string().max(14e6).regex(
167
+ /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/
168
+ )
169
+ }).strict()
170
+ ).min(1).max(500)
171
+ }).strict().optional(),
107
172
  assets: z.array(
108
173
  z.object({
109
174
  path: assetPathSchema,
@@ -112,13 +177,36 @@ var buildArtifactsSchema = z.object({
112
177
  ),
113
178
  size: z.number().int().min(0).max(1e7)
114
179
  }).strict()
115
- ).min(1).max(500),
180
+ ).max(500),
116
181
  quests: z.unknown(),
117
182
  catalog: z.unknown()
118
183
  }).strict().superRefine((value, ctx) => {
184
+ if (value.worker) {
185
+ const modules = value.worker.modules;
186
+ if (new Set(modules.map((m) => m.path)).size !== modules.length)
187
+ ctx.addIssue({
188
+ code: "custom",
189
+ message: "Duplicate Worker module paths"
190
+ });
191
+ if (!modules.some(
192
+ (m) => m.path === value.worker?.main && m.type === "application/javascript+module"
193
+ ))
194
+ ctx.addIssue({
195
+ code: "custom",
196
+ message: "Worker entry module is missing"
197
+ });
198
+ if (modules.reduce(
199
+ (sum, m) => sum + m.content.length * 3 / 4 - (m.content.endsWith("==") ? 2 : m.content.endsWith("=") ? 1 : 0),
200
+ 0
201
+ ) > 1e7)
202
+ ctx.addIssue({
203
+ code: "custom",
204
+ message: "Worker modules exceed 10 MB"
205
+ });
206
+ }
119
207
  if (new Set(value.assets.map((a) => a.path)).size !== value.assets.length)
120
208
  ctx.addIssue({ code: "custom", message: "Duplicate asset paths" });
121
- if (!value.assets.some((a) => a.path === "/index.html"))
209
+ if (!value.worker && !value.assets.some((a) => a.path === "/index.html"))
122
210
  ctx.addIssue({
123
211
  code: "custom",
124
212
  message: "Build must include index.html"
@@ -181,10 +269,11 @@ var permissionSchema = z3.enum([
181
269
  "handover",
182
270
  "inventory",
183
271
  "access",
184
- "points"
272
+ "points",
273
+ "observe"
185
274
  ]);
186
275
  var rolePermissions = {
187
- editor: ["read", "publish", "inventory", "points"],
276
+ editor: ["read", "publish", "inventory", "points", "observe"],
188
277
  reviewer: ["read", "review"],
189
278
  staff: ["read", "confirm", "handover"]
190
279
  };
@@ -193,6 +282,7 @@ var projectSetupSchema = z3.object({
193
282
  brief: z3.string().trim().min(1).max(4e3)
194
283
  }).strict();
195
284
  var projectSchema = z3.object({
285
+ slug: z3.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
196
286
  setup: projectSetupSchema.optional(),
197
287
  id: z3.string().min(1),
198
288
  organization: identifier2,
@@ -265,6 +355,10 @@ var memberSchema = z3.object({
265
355
  rewards: z3.number(),
266
356
  lastActivity: z3.number().nullable()
267
357
  });
358
+ var personSchema = z3.object({
359
+ id: z3.string(),
360
+ accounts: z3.array(memberAccountSchema).default([])
361
+ });
268
362
  var metricsSchema = z3.object({
269
363
  quests: z3.number(),
270
364
  members: z3.number(),
@@ -301,6 +395,7 @@ var auditRecordSchema = z3.object({
301
395
  var pageSchema = z3.object({
302
396
  snapshot: snapshotSchema,
303
397
  members: z3.array(memberSchema),
398
+ people: z3.array(personSchema).default([]),
304
399
  metrics: metricsSchema,
305
400
  total: z3.number(),
306
401
  offset: z3.number(),
@@ -383,6 +478,13 @@ function createManagementClient(options) {
383
478
  return {
384
479
  raw,
385
480
  request,
481
+ observations: {
482
+ submit: (input) => request(
483
+ "/observations",
484
+ observationReceiptSchema,
485
+ observationInputSchema.parse(input)
486
+ )
487
+ },
386
488
  points: {
387
489
  update: (input) => request(
388
490
  "/points",
@@ -516,16 +618,25 @@ function createManagementClient(options) {
516
618
  readiness: () => request("/readiness", readinessSchema),
517
619
  access: () => request("/access", accessSchema),
518
620
  createProject: (input) => request("/projects", projectSchema, input),
621
+ people: (members) => request(
622
+ `/people?${new URLSearchParams({ ids: members.join(",") })}`,
623
+ z3.array(personSchema)
624
+ ),
519
625
  page: (page, query) => request(
520
626
  `/${page}?${new URLSearchParams(Object.entries(query).map(([k, v]) => [k, String(v)]))}`,
521
627
  pageSchema
522
628
  ),
629
+ rewardDeliveries: (member) => request(
630
+ "/reward-deliveries" + (member ? "?member=" + encodeURIComponent(member) : ""),
631
+ rewardDeliveriesSchema
632
+ ),
523
633
  member: (id) => request(`/members/${encodeURIComponent(id)}`, memberDetailSchema)
524
634
  };
525
635
  }
526
636
  export {
527
637
  accessSchema,
528
638
  accountProfileSchema,
639
+ appRoutingSchema,
529
640
  assetPathSchema,
530
641
  auditRecordSchema,
531
642
  buildArtifactsSchema,
@@ -542,6 +653,7 @@ export {
542
653
  deviceStartSchema,
543
654
  environmentSchema,
544
655
  grantSchema,
656
+ hostedAppSchema,
545
657
  hostedBuildSchema,
546
658
  inventorySchema,
547
659
  memberAccountSchema,
@@ -552,6 +664,7 @@ export {
552
664
  operationSchema,
553
665
  pageSchema,
554
666
  permissionSchema,
667
+ personSchema,
555
668
  projectInputSchema,
556
669
  projectSchema,
557
670
  projectSetupSchema,
package/package.json CHANGED
@@ -10,9 +10,9 @@
10
10
  "dependencies": {
11
11
  "commander": "15.0.0",
12
12
  "zod": "4.3.6",
13
- "@domino-sdk/relay": "0.4.0"
13
+ "@domino-sdk/relay": "0.6.0"
14
14
  },
15
- "version": "0.4.0",
15
+ "version": "0.6.0",
16
16
  "bin": {
17
17
  "domino": "./cli.mjs"
18
18
  },