@domino-sdk/relay-cli 0.3.0 → 0.5.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,20 @@
1
1
  // src/index.ts
2
2
  import {
3
+ publishedReferralSchema,
4
+ referralManagementSchema,
5
+ referralControlSchema,
6
+ referralHistorySchema
7
+ } from "@domino-sdk/relay";
8
+ import {
9
+ leaderboardPageSchema,
10
+ publishedLeaderboardSchema,
11
+ leaderboardQuerySchema,
12
+ leaderboardExclusionSchema,
13
+ leaderboardGroupSchema,
14
+ pointsMutationSchema,
15
+ pointsResultSchema,
16
+ pointsAccountSchema,
17
+ pointsEntrySchema,
3
18
  projectDeploymentSchema,
4
19
  deploymentPreviewSchema,
5
20
  publishDeploymentSchema,
@@ -17,6 +32,46 @@ import { z as z3 } from "zod";
17
32
  // src/hosting.ts
18
33
  import { z } from "zod";
19
34
  import { identifier } from "@domino-sdk/relay";
35
+ var outputPathSchema = z.string().min(1).max(512).refine(
36
+ (path) => path.split("/").every(
37
+ (part) => /^[\w-][\w.-]*$/.test(part) && part !== "node_modules"
38
+ ),
39
+ "Expected a relative build output path without hidden segments"
40
+ );
41
+ var appRoutingSchema = z.enum(["legacy", "transparent"]).default("legacy");
42
+ var appScripts = {
43
+ routing: appRoutingSchema,
44
+ devScript: z.string().regex(/^[\w:-]+$/),
45
+ checkScript: z.string().regex(/^[\w:-]+$/),
46
+ buildScript: z.string().regex(/^[\w:-]+$/)
47
+ };
48
+ var workerSettings = {
49
+ runWorkerFirst: z.boolean().default(false),
50
+ main: outputPathSchema.refine(
51
+ (path) => /\.m?js$/.test(path),
52
+ "Expected a compiled JavaScript entry"
53
+ ),
54
+ compatibilityDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
55
+ compatibilityFlags: z.array(z.string().min(1)).max(50).default([]),
56
+ vars: z.record(
57
+ z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/).refine((name) => name !== "ASSETS"),
58
+ z.string()
59
+ ).default({})
60
+ };
61
+ var hostedAppSchema = z.discriminatedUnion("kind", [
62
+ z.object({
63
+ kind: z.literal("static"),
64
+ directory: outputPathSchema,
65
+ ...appScripts
66
+ }).strict(),
67
+ z.object({
68
+ kind: z.literal("worker"),
69
+ directory: outputPathSchema,
70
+ assetsDirectory: outputPathSchema.optional(),
71
+ ...appScripts,
72
+ ...workerSettings
73
+ }).strict()
74
+ ]);
20
75
  var repositorySchema = z.object({
21
76
  id: z.string().uuid(),
22
77
  organization: identifier,
@@ -45,6 +100,8 @@ var stageRequestSchema = z.object({
45
100
  requestId: z.string().uuid()
46
101
  }).strict();
47
102
  var buildIdentitySchema = z.object({
103
+ routing: appRoutingSchema,
104
+ slug: z.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
48
105
  runtime: z.enum(["simulation", "hosted-test"]).default("simulation"),
49
106
  id: z.string().uuid(),
50
107
  repository: z.string().uuid(),
@@ -52,7 +109,8 @@ var buildIdentitySchema = z.object({
52
109
  project: identifier,
53
110
  commit: commitSchema,
54
111
  createdAt: z.number(),
55
- actor: z.string()
112
+ actor: z.string(),
113
+ commitMessage: z.string().max(500).optional()
56
114
  });
57
115
  var buildPhaseSchema = z.enum([
58
116
  "queued",
@@ -66,15 +124,46 @@ var buildPhaseSchema = z.enum([
66
124
  ]);
67
125
  var buildStatusSchema = z.object({
68
126
  phase: buildPhaseSchema,
127
+ failedPhase: buildPhaseSchema.optional(),
69
128
  updatedAt: z.number(),
70
129
  message: z.string()
71
130
  });
131
+ var hostedBuildSchema = buildIdentitySchema.extend({
132
+ ...buildStatusSchema.shape,
133
+ finished: z.boolean(),
134
+ current: z.boolean(),
135
+ stagingUrl: z.string().url()
136
+ });
137
+ var buildSnapshotSchema = z.object({
138
+ builds: z.array(hostedBuildSchema),
139
+ current: hostedBuildSchema.nullable(),
140
+ selected: hostedBuildSchema.nullable(),
141
+ logs: z.string()
142
+ });
72
143
  var assetPathSchema = z.string().max(512).refine(
73
- (path) => path.startsWith("/") && !/[\\\u0000-\u001f?#%]/.test(path) && path.slice(1).split("/").every((part) => part.length > 0 && !part.startsWith(".")) && !path.startsWith("/relay/") && !path.startsWith("/__domino/"),
74
- "Expected a public asset path without hidden or reserved segments"
144
+ (path) => path.startsWith("/") && !/[\\\u0000-\u001f?#%]/.test(path) && path.slice(1).split("/").every((part) => part.length > 0 && !part.startsWith(".")),
145
+ "Expected a public asset path without hidden segments"
75
146
  );
76
147
  var buildArtifactsSchema = z.object({
77
148
  format: z.literal(1),
149
+ routing: appRoutingSchema,
150
+ worker: z.object({
151
+ ...workerSettings,
152
+ modules: z.array(
153
+ z.object({
154
+ path: outputPathSchema.refine((path) => path !== "metadata"),
155
+ type: z.enum([
156
+ "application/javascript+module",
157
+ "application/wasm",
158
+ "text/plain",
159
+ "application/octet-stream"
160
+ ]),
161
+ content: z.string().max(14e6).regex(
162
+ /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/
163
+ )
164
+ }).strict()
165
+ ).min(1).max(500)
166
+ }).strict().optional(),
78
167
  assets: z.array(
79
168
  z.object({
80
169
  path: assetPathSchema,
@@ -83,13 +172,36 @@ var buildArtifactsSchema = z.object({
83
172
  ),
84
173
  size: z.number().int().min(0).max(1e7)
85
174
  }).strict()
86
- ).min(1).max(500),
175
+ ).max(500),
87
176
  quests: z.unknown(),
88
177
  catalog: z.unknown()
89
178
  }).strict().superRefine((value, ctx) => {
179
+ if (value.worker) {
180
+ const modules = value.worker.modules;
181
+ if (new Set(modules.map((m) => m.path)).size !== modules.length)
182
+ ctx.addIssue({
183
+ code: "custom",
184
+ message: "Duplicate Worker module paths"
185
+ });
186
+ if (!modules.some(
187
+ (m) => m.path === value.worker?.main && m.type === "application/javascript+module"
188
+ ))
189
+ ctx.addIssue({
190
+ code: "custom",
191
+ message: "Worker entry module is missing"
192
+ });
193
+ if (modules.reduce(
194
+ (sum, m) => sum + m.content.length * 3 / 4 - (m.content.endsWith("==") ? 2 : m.content.endsWith("=") ? 1 : 0),
195
+ 0
196
+ ) > 1e7)
197
+ ctx.addIssue({
198
+ code: "custom",
199
+ message: "Worker modules exceed 10 MB"
200
+ });
201
+ }
90
202
  if (new Set(value.assets.map((a) => a.path)).size !== value.assets.length)
91
203
  ctx.addIssue({ code: "custom", message: "Duplicate asset paths" });
92
- if (!value.assets.some((a) => a.path === "/index.html"))
204
+ if (!value.worker && !value.assets.some((a) => a.path === "/index.html"))
93
205
  ctx.addIssue({
94
206
  code: "custom",
95
207
  message: "Build must include index.html"
@@ -151,10 +263,11 @@ var permissionSchema = z3.enum([
151
263
  "confirm",
152
264
  "handover",
153
265
  "inventory",
154
- "access"
266
+ "access",
267
+ "points"
155
268
  ]);
156
269
  var rolePermissions = {
157
- editor: ["read", "publish", "inventory"],
270
+ editor: ["read", "publish", "inventory", "points"],
158
271
  reviewer: ["read", "review"],
159
272
  staff: ["read", "confirm", "handover"]
160
273
  };
@@ -163,6 +276,7 @@ var projectSetupSchema = z3.object({
163
276
  brief: z3.string().trim().min(1).max(4e3)
164
277
  }).strict();
165
278
  var projectSchema = z3.object({
279
+ slug: z3.string().min(1).max(35).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
166
280
  setup: projectSetupSchema.optional(),
167
281
  id: z3.string().min(1),
168
282
  organization: identifier2,
@@ -353,6 +467,72 @@ function createManagementClient(options) {
353
467
  return {
354
468
  raw,
355
469
  request,
470
+ points: {
471
+ update: (input) => request(
472
+ "/points",
473
+ pointsResultSchema,
474
+ pointsMutationSchema.parse(input)
475
+ ),
476
+ balance: (member, balance) => request(
477
+ `/points/${identifier2.parse(member)}/${identifier2.parse(balance)}`,
478
+ pointsAccountSchema
479
+ ),
480
+ history: (member, balance, before) => request(
481
+ `/points/${identifier2.parse(member)}/${identifier2.parse(balance)}/history${before === void 0 ? "" : "?before=" + before}`,
482
+ z3.object({
483
+ items: z3.array(pointsEntrySchema),
484
+ next: z3.number().nullable()
485
+ })
486
+ )
487
+ },
488
+ referrals: {
489
+ history: (member, before) => request(
490
+ `/referrals/history/${identifier2.parse(member)}${before === void 0 ? "" : "?before=" + before}`,
491
+ referralHistorySchema
492
+ ),
493
+ list: () => request("/referrals", z3.array(publishedReferralSchema)),
494
+ participants: (before) => request(
495
+ `/referrals/participants${before === void 0 ? "" : "?before=" + before}`,
496
+ referralManagementSchema
497
+ ),
498
+ control: (input) => request(
499
+ "/referrals/control",
500
+ z3.object({ ok: z3.literal(true) }),
501
+ referralControlSchema.parse(input)
502
+ )
503
+ },
504
+ leaderboards: {
505
+ list: () => request("/leaderboards", z3.array(publishedLeaderboardSchema)),
506
+ standings: (board, input = {}) => {
507
+ const query = leaderboardQuerySchema.parse(input);
508
+ const params = new URLSearchParams({
509
+ limit: String(query.limit),
510
+ ...query.cursor ? { cursor: query.cursor } : {}
511
+ });
512
+ return request(
513
+ `/leaderboards/${identifier2.parse(board)}?${params}`,
514
+ leaderboardPageSchema
515
+ );
516
+ },
517
+ history: (board) => request(
518
+ `/leaderboards/${identifier2.parse(board)}/history`,
519
+ z3.array(publishedLeaderboardSchema)
520
+ ),
521
+ exclusions: (board) => request(
522
+ `/leaderboards/${identifier2.parse(board)}/exclusions`,
523
+ z3.array(z3.object({ member: identifier2 }))
524
+ ),
525
+ exclude: (board, input) => request(
526
+ `/leaderboards/${identifier2.parse(board)}/exclusions`,
527
+ z3.object({ ok: z3.literal(true) }),
528
+ leaderboardExclusionSchema.parse(input)
529
+ ),
530
+ group: (group, input) => request(
531
+ `/leaderboard-groups/${identifier2.parse(group)}`,
532
+ z3.object({ ok: z3.literal(true) }),
533
+ leaderboardGroupSchema.parse(input)
534
+ )
535
+ },
356
536
  deployments: {
357
537
  preview: (input) => request(
358
538
  "/deployments/preview",
@@ -430,11 +610,13 @@ function createManagementClient(options) {
430
610
  export {
431
611
  accessSchema,
432
612
  accountProfileSchema,
613
+ appRoutingSchema,
433
614
  assetPathSchema,
434
615
  auditRecordSchema,
435
616
  buildArtifactsSchema,
436
617
  buildIdentitySchema,
437
618
  buildPhaseSchema,
619
+ buildSnapshotSchema,
438
620
  buildStatusSchema,
439
621
  commitSchema,
440
622
  createManagementClient,
@@ -445,6 +627,8 @@ export {
445
627
  deviceStartSchema,
446
628
  environmentSchema,
447
629
  grantSchema,
630
+ hostedAppSchema,
631
+ hostedBuildSchema,
448
632
  inventorySchema,
449
633
  memberAccountSchema,
450
634
  memberDetailSchema,
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.3.0"
13
+ "@domino-sdk/relay": "0.5.0"
14
14
  },
15
- "version": "0.3.0",
15
+ "version": "0.5.0",
16
16
  "bin": {
17
17
  "domino": "./cli.mjs"
18
18
  },