@domino-sdk/relay 1.0.0-next.10 → 1.0.0-next.13
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/authoring.d.ts +39 -36
- package/dist/authoring.js +10 -3
- package/dist/avatar.d.ts +2 -2
- package/dist/browser.d.ts +153 -129
- package/dist/browser.js +6 -6
- package/dist/{pages-D3titw5B.d.ts → catalog-C85V1NgW.d.ts} +178 -216
- package/dist/{chunk-ZWY3R6B3.js → chunk-6A2V4L3T.js} +4 -0
- package/dist/{chunk-YYD4QUBO.js → chunk-CRNQP7NV.js} +550 -470
- package/dist/{chunk-X2F2RAR3.js → chunk-EZWNGI5B.js} +23 -4
- package/dist/{chunk-7Q4BGGT6.js → chunk-FXYJ4OMX.js} +1 -1
- package/dist/{chunk-4LBUTHD6.js → chunk-II7DRZSL.js} +1 -1
- package/dist/chunk-KS33GOUL.js +83 -0
- package/dist/{chunk-QR7ZA2BJ.js → chunk-M64XHC42.js} +48 -4
- package/dist/chunk-MNQI35OG.js +100 -0
- package/dist/{chunk-PHU5VDLR.js → chunk-OA2KMQVZ.js} +41 -26
- package/dist/{chunk-P6FK43GG.js → chunk-WQ24ILGO.js} +140 -41
- package/dist/{client-CT4-S5vc.d.ts → client-Bf9PNUIi.d.ts} +61 -80
- package/dist/deployments-CNCP0JnD.d.ts +4250 -0
- package/dist/identity-integration-CBR8l3ju.d.ts +37 -0
- package/dist/images-BG4pdO4y.d.ts +234 -0
- package/dist/index.d.ts +10 -8
- package/dist/index.js +8 -5
- package/dist/{integrations-Ba5TtqTv.d.ts → integrations-EjQzIApL.d.ts} +1 -88
- package/dist/internal.d.ts +7 -38
- package/dist/internal.js +15 -88
- package/dist/observations-CQ6IcNuQ.d.ts +90 -0
- package/dist/pages-KYK1L60W.d.ts +152 -0
- package/dist/portal-proxy.js +5 -4
- package/dist/{profiles-DDMFBRKe.d.ts → profiles-BtOXMGcC.d.ts} +1 -1
- package/dist/react/index.d.ts +150 -31
- package/dist/react/index.js +149 -11
- package/dist/{submission-input-0OOGaq8c.d.ts → referrals-KQfP4pBf.d.ts} +189 -182
- package/dist/request-error-VnTiMXc3.d.ts +52 -0
- package/dist/{schema-Di3aLSiK.d.ts → schema-BF_TQsmT.d.ts} +338 -47
- package/dist/schema.d.ts +14 -4126
- package/dist/schema.js +46 -40
- package/dist/server/index.d.ts +19445 -0
- package/dist/server/index.js +1884 -0
- package/dist/{streaks-CwGReWGt.d.ts → streaks-CWyq8Px5.d.ts} +2 -4
- package/dist/submission-input-CccwAl5Z.d.ts +83 -0
- package/dist/{images-BTgk6OmC.d.ts → trackers-W7nRdRr7.d.ts} +1 -232
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -0
- package/dist/{wallet-BGOfFkG9.d.ts → wallet-BtiG0Xhr.d.ts} +1 -1
- package/package.json +5 -1
- package/dist/point-ledgers-iS00Z_v0.d.ts +0 -37
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectionPassSchema,
|
|
3
|
+
pointBalancesSchema,
|
|
4
|
+
pointHistoryPageSchema,
|
|
5
|
+
pointHistoryQuerySchema,
|
|
3
6
|
pointLedgerReferenceSchema,
|
|
4
7
|
questExperienceSchema,
|
|
5
8
|
rewardDeliveriesSchema
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-M64XHC42.js";
|
|
7
10
|
import {
|
|
8
11
|
AVATAR_UPLOAD_LIMIT,
|
|
9
12
|
RelayError,
|
|
@@ -35,14 +38,14 @@ import {
|
|
|
35
38
|
walletSignInNetworksSchema,
|
|
36
39
|
walletSignatureSchema,
|
|
37
40
|
walletUnlinkInputSchema
|
|
38
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-OA2KMQVZ.js";
|
|
39
42
|
import {
|
|
40
43
|
exchangeResultSchema,
|
|
41
44
|
exchangeSchema,
|
|
42
45
|
memberSummarySchema,
|
|
43
46
|
participantSessionSchema,
|
|
44
47
|
sessionMember
|
|
45
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-FXYJ4OMX.js";
|
|
46
49
|
import {
|
|
47
50
|
accountConnectionSchema,
|
|
48
51
|
attemptSchema,
|
|
@@ -67,7 +70,7 @@ import {
|
|
|
67
70
|
tieredRewardReferenceSchema,
|
|
68
71
|
validateSubmissionValue,
|
|
69
72
|
valueEvidenceSchema
|
|
70
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-CRNQP7NV.js";
|
|
71
74
|
|
|
72
75
|
// src/submissions.ts
|
|
73
76
|
import { z } from "zod";
|
|
@@ -1301,6 +1304,22 @@ function createRelayClient(options) {
|
|
|
1301
1304
|
rewardDeliveries: (requestOptions) => request("/v1/reward-deliveries", rewardDeliveriesSchema, {
|
|
1302
1305
|
options: requestOptions
|
|
1303
1306
|
}),
|
|
1307
|
+
/**
|
|
1308
|
+
* `{ items }`: the member's balance in each of the project's point ledgers, in the project's
|
|
1309
|
+
* ledger order, zero in a ledger they have no entries in.
|
|
1310
|
+
*/
|
|
1311
|
+
balances: (requestOptions) => request("/v1/me/points", pointBalancesSchema, {
|
|
1312
|
+
options: requestOptions
|
|
1313
|
+
}),
|
|
1314
|
+
/** The member's own entries in one ledger, by key or ID, most recently recorded first. */
|
|
1315
|
+
pointHistory: async (query, requestOptions) => {
|
|
1316
|
+
const { ledger, cursor } = parseInput(pointHistoryQuerySchema, query);
|
|
1317
|
+
return request(
|
|
1318
|
+
withQuery(`/v1/me/points/${ledger}/history`, { cursor }),
|
|
1319
|
+
pointHistoryPageSchema,
|
|
1320
|
+
{ options: requestOptions }
|
|
1321
|
+
);
|
|
1322
|
+
},
|
|
1304
1323
|
/** Claims a quest for the signed-in member. Quest controllers (`quests.open`) call this. */
|
|
1305
1324
|
claim: async (value, requestOptions) => {
|
|
1306
1325
|
const claim = parseInput(submitSchema.omit({ member: true }), value);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
imageAssetArtifactSchema,
|
|
3
|
+
publishedImageSchema
|
|
4
|
+
} from "./chunk-II7DRZSL.js";
|
|
5
|
+
import {
|
|
6
|
+
catalogDeploymentSchema,
|
|
7
|
+
interactionSchema,
|
|
8
|
+
pointLedgerDeclarationSchema,
|
|
9
|
+
pointLedgerSchema,
|
|
10
|
+
questCollectionSchema,
|
|
11
|
+
questTypeVersionSchema
|
|
12
|
+
} from "./chunk-M64XHC42.js";
|
|
13
|
+
import {
|
|
14
|
+
engagementArtifactSchema,
|
|
15
|
+
engagementDeploymentEntrySchema,
|
|
16
|
+
leaderboardArtifactSchema,
|
|
17
|
+
leaderboardPreviewSchema,
|
|
18
|
+
publishedReferralSchema,
|
|
19
|
+
referralArtifactSchema
|
|
20
|
+
} from "./chunk-OA2KMQVZ.js";
|
|
21
|
+
import {
|
|
22
|
+
identifier,
|
|
23
|
+
projectCalendarDeclarationSchema,
|
|
24
|
+
publishedReleaseSchema,
|
|
25
|
+
publishedTrackerSchema,
|
|
26
|
+
releaseSchema,
|
|
27
|
+
timeZoneNameSchema,
|
|
28
|
+
trackerArtifactSchema
|
|
29
|
+
} from "./chunk-CRNQP7NV.js";
|
|
30
|
+
|
|
31
|
+
// src/deployments.ts
|
|
32
|
+
import { z } from "zod";
|
|
33
|
+
var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevision: true }).extend({
|
|
34
|
+
engagement: z.array(engagementArtifactSchema).max(50).default([]),
|
|
35
|
+
trackers: z.array(trackerArtifactSchema).max(50).default([]),
|
|
36
|
+
pointLedgers: z.array(pointLedgerDeclarationSchema).max(50).default([]),
|
|
37
|
+
referrals: z.array(referralArtifactSchema).max(50).default([]),
|
|
38
|
+
leaderboards: z.array(leaderboardArtifactSchema).max(50).default([]),
|
|
39
|
+
images: z.array(imageAssetArtifactSchema).max(10).default([]),
|
|
40
|
+
/** relay.json `calendar`: the project timezone. Omitted, the deployment leaves it unchanged. */
|
|
41
|
+
calendar: projectCalendarDeclarationSchema.optional()
|
|
42
|
+
});
|
|
43
|
+
var projectDeploymentSchema = projectCatalogArtifactSchema.extend({ releases: z.array(releaseSchema).max(50).default([]) }).refine(
|
|
44
|
+
(value) => value.engagement.length > 0 || value.trackers.length > 0 || value.pointLedgers.length > 0 || value.releases.length > 0 || value.leaderboards.length > 0 || value.referrals.length > 0 || value.images.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0 || value.calendar !== void 0,
|
|
45
|
+
"No resources configured. Add engagement, trackers, quests, questTypes, pointLedgers, leaderboards, referrals, images, collections, supportedInteractions, or calendar to relay.json."
|
|
46
|
+
);
|
|
47
|
+
var deploymentPreviewSchema = z.object({
|
|
48
|
+
id: identifier,
|
|
49
|
+
engagement: z.array(engagementDeploymentEntrySchema).default([]),
|
|
50
|
+
trackers: z.array(publishedTrackerSchema).default([]),
|
|
51
|
+
baseRevision: z.number().int().nonnegative(),
|
|
52
|
+
pointLedgers: z.array(pointLedgerSchema).default([]),
|
|
53
|
+
releases: z.array(publishedReleaseSchema),
|
|
54
|
+
types: z.array(questTypeVersionSchema),
|
|
55
|
+
collections: z.array(questCollectionSchema),
|
|
56
|
+
supportedInteractions: z.array(interactionSchema),
|
|
57
|
+
referrals: z.array(publishedReferralSchema).default([]),
|
|
58
|
+
leaderboards: z.array(leaderboardPreviewSchema).default([]),
|
|
59
|
+
images: z.array(publishedImageSchema).default([]),
|
|
60
|
+
/**
|
|
61
|
+
* The project timezone change this deployment makes, or null for none. A declared timezone
|
|
62
|
+
* applies only when relay.json changes it, so a change made in Console stays until relay.json
|
|
63
|
+
* changes. `effectiveAt` is when a scheduled change takes effect; null means the deployment keeps
|
|
64
|
+
* `timeZone` and cancels a pending change. Publishing makes exactly this change, or fails when the
|
|
65
|
+
* calendar moved since the preview (such as past a day boundary).
|
|
66
|
+
*/
|
|
67
|
+
calendar: z.object({
|
|
68
|
+
timeZone: timeZoneNameSchema,
|
|
69
|
+
effectiveAt: z.number().int().nullable()
|
|
70
|
+
}).nullable().default(null)
|
|
71
|
+
});
|
|
72
|
+
var publishDeploymentSchema = z.object({ id: identifier }).strict();
|
|
73
|
+
var deploymentResultSchema = deploymentPreviewSchema.extend({
|
|
74
|
+
revision: z.number().int().positive()
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export {
|
|
78
|
+
projectCatalogArtifactSchema,
|
|
79
|
+
projectDeploymentSchema,
|
|
80
|
+
deploymentPreviewSchema,
|
|
81
|
+
publishDeploymentSchema,
|
|
82
|
+
deploymentResultSchema
|
|
83
|
+
};
|
|
@@ -2,20 +2,21 @@ import {
|
|
|
2
2
|
authoringIdentityShape,
|
|
3
3
|
normalizeAuthoringIdentity,
|
|
4
4
|
validateAuthoringIdentity
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-OA2KMQVZ.js";
|
|
6
6
|
import {
|
|
7
7
|
entitlementSchema,
|
|
8
8
|
identifier,
|
|
9
9
|
memberProgressSchema,
|
|
10
|
+
pageCursorSchema,
|
|
10
11
|
pickupAvailabilitySchema,
|
|
11
12
|
pickupSelectionSchema,
|
|
12
13
|
publishedReleaseSchema,
|
|
13
|
-
questDescriptionSchema,
|
|
14
14
|
reviewModeSchema,
|
|
15
15
|
settingsValuesSchema,
|
|
16
|
+
storedQuestDescriptionSchema,
|
|
16
17
|
storedReviewModeSchema,
|
|
17
18
|
tieredRewardReferenceSchema
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CRNQP7NV.js";
|
|
19
20
|
|
|
20
21
|
// src/point-ledgers.ts
|
|
21
22
|
import { z } from "zod";
|
|
@@ -33,6 +34,43 @@ var pointLedgerReferenceSchema = z.object({
|
|
|
33
34
|
key: identifier.nullable(),
|
|
34
35
|
name: z.string()
|
|
35
36
|
});
|
|
37
|
+
var points = z.number().int().safe();
|
|
38
|
+
var pointBalanceSchema = z.object({
|
|
39
|
+
ledger: pointLedgerReferenceSchema,
|
|
40
|
+
balance: points,
|
|
41
|
+
available: points
|
|
42
|
+
});
|
|
43
|
+
var pointBalancesSchema = z.object({
|
|
44
|
+
items: z.array(pointBalanceSchema)
|
|
45
|
+
});
|
|
46
|
+
var PointEntryKind = {
|
|
47
|
+
/** Points a quest completion, an engagement settlement or an operator awarded. */
|
|
48
|
+
Award: "award",
|
|
49
|
+
/** Points the member spent. */
|
|
50
|
+
Spend: "spend",
|
|
51
|
+
/** A correction in either direction, by an operator or a referral payout. */
|
|
52
|
+
Adjust: "adjust",
|
|
53
|
+
/** Undoes part or all of an award or a positive adjustment (`reverses`). */
|
|
54
|
+
Reverse: "reverse"
|
|
55
|
+
};
|
|
56
|
+
var pointEntryKindSchema = z.string().min(1).max(64);
|
|
57
|
+
var pointEntrySchema = z.object({
|
|
58
|
+
id: identifier,
|
|
59
|
+
amount: points,
|
|
60
|
+
kind: pointEntryKindSchema,
|
|
61
|
+
/** When the entry took effect, in epoch milliseconds. A reversal keeps its source's. */
|
|
62
|
+
at: points.nonnegative(),
|
|
63
|
+
quest: identifier.nullable(),
|
|
64
|
+
reverses: identifier.nullable()
|
|
65
|
+
});
|
|
66
|
+
var pointHistoryQuerySchema = z.strictObject({
|
|
67
|
+
ledger: identifier,
|
|
68
|
+
cursor: pageCursorSchema.optional()
|
|
69
|
+
});
|
|
70
|
+
var pointHistoryPageSchema = z.object({
|
|
71
|
+
items: z.array(pointEntrySchema),
|
|
72
|
+
nextCursor: pageCursorSchema.nullable()
|
|
73
|
+
});
|
|
36
74
|
|
|
37
75
|
// src/catalog.ts
|
|
38
76
|
import { z as z2 } from "zod";
|
|
@@ -53,7 +91,7 @@ var questTypeVersionSchema = z2.object({
|
|
|
53
91
|
id: identifier,
|
|
54
92
|
version: identifier,
|
|
55
93
|
code: z2.string(),
|
|
56
|
-
definition:
|
|
94
|
+
definition: storedQuestDescriptionSchema,
|
|
57
95
|
provider: storedReviewModeSchema,
|
|
58
96
|
createdAt: z2.number()
|
|
59
97
|
});
|
|
@@ -226,6 +264,12 @@ export {
|
|
|
226
264
|
pointLedgerSchema,
|
|
227
265
|
pointLedgerDeclarationSchema,
|
|
228
266
|
pointLedgerReferenceSchema,
|
|
267
|
+
pointBalanceSchema,
|
|
268
|
+
pointBalancesSchema,
|
|
269
|
+
PointEntryKind,
|
|
270
|
+
pointEntrySchema,
|
|
271
|
+
pointHistoryQuerySchema,
|
|
272
|
+
pointHistoryPageSchema,
|
|
229
273
|
interactionSchema,
|
|
230
274
|
questInteraction,
|
|
231
275
|
questTypeVersionSchema,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
imageComparisonSchema,
|
|
3
|
+
imageExtractionSchema,
|
|
4
|
+
imageFieldsSchema,
|
|
5
|
+
imageInspectionSchema,
|
|
6
|
+
imageSightingsSchema
|
|
7
|
+
} from "./chunk-II7DRZSL.js";
|
|
8
|
+
import {
|
|
9
|
+
authScopeSchema
|
|
10
|
+
} from "./chunk-FXYJ4OMX.js";
|
|
11
|
+
import {
|
|
12
|
+
photoResultSchema
|
|
13
|
+
} from "./chunk-CRNQP7NV.js";
|
|
14
|
+
|
|
15
|
+
// src/configuration.ts
|
|
16
|
+
function questConfiguration(release) {
|
|
17
|
+
return release.configuration ?? {
|
|
18
|
+
defaults: Object.fromEntries(
|
|
19
|
+
Object.entries(release.fields).map(([key, field]) => [
|
|
20
|
+
key,
|
|
21
|
+
field.default
|
|
22
|
+
])
|
|
23
|
+
),
|
|
24
|
+
overrides: { ...release.values },
|
|
25
|
+
preserved: Object.keys(release.values)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/identity-integration.ts
|
|
30
|
+
import { z } from "zod";
|
|
31
|
+
var identityIntegrationInputSchema = z.object({
|
|
32
|
+
name: z.string().trim().min(1).max(80),
|
|
33
|
+
origin: z.string().url().refine((value) => {
|
|
34
|
+
const url = new URL(value);
|
|
35
|
+
return url.protocol === "https:" && url.origin === value;
|
|
36
|
+
}, "Use an exact HTTPS application origin")
|
|
37
|
+
}).strict();
|
|
38
|
+
var identityIntegrationSchema = authScopeSchema.extend({
|
|
39
|
+
id: z.string().uuid(),
|
|
40
|
+
name: z.string(),
|
|
41
|
+
origin: z.string(),
|
|
42
|
+
expiresAt: z.number()
|
|
43
|
+
});
|
|
44
|
+
var identityIntegrationSecretSchema = identityIntegrationSchema.extend(
|
|
45
|
+
{
|
|
46
|
+
token: z.string()
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
var participantExchangeSchema = z.object({
|
|
50
|
+
subject: z.string().min(1).max(200),
|
|
51
|
+
previousToken: z.string().max(200).optional()
|
|
52
|
+
}).strict();
|
|
53
|
+
|
|
54
|
+
// src/image-results.ts
|
|
55
|
+
function parseImageExtraction(raw, value) {
|
|
56
|
+
const result = imageExtractionSchema.parse(value);
|
|
57
|
+
const fields = imageFieldsSchema.parse(raw);
|
|
58
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
59
|
+
const extracted = result.values[key];
|
|
60
|
+
if (extracted === void 0) {
|
|
61
|
+
throw new Error("Image extraction omitted " + key);
|
|
62
|
+
}
|
|
63
|
+
if (extracted !== null && typeof extracted !== field.type) {
|
|
64
|
+
throw new Error("Image extraction returned the wrong type for " + key);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (Object.keys(result.values).some((key) => !Object.hasOwn(fields, key))) {
|
|
68
|
+
throw new Error("Image extraction returned an undeclared field");
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
function parseImageResult(request, value) {
|
|
73
|
+
switch (request.operation) {
|
|
74
|
+
case "inspect":
|
|
75
|
+
return imageInspectionSchema.parse(value);
|
|
76
|
+
case "compare":
|
|
77
|
+
return imageComparisonSchema.parse(value);
|
|
78
|
+
case "review":
|
|
79
|
+
return photoResultSchema.parse(value);
|
|
80
|
+
case "extract":
|
|
81
|
+
return parseImageExtraction(request.fields, value);
|
|
82
|
+
case "seen":
|
|
83
|
+
return imageSightingsSchema.parse(value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/sequence-cursor.ts
|
|
88
|
+
import { z as z2 } from "zod";
|
|
89
|
+
var sequenceCursorSchema = z2.string().regex(/^[1-9][0-9]{0,15}$/, "Invalid cursor").transform(Number).pipe(z2.number().int().positive().safe());
|
|
90
|
+
|
|
91
|
+
export {
|
|
92
|
+
questConfiguration,
|
|
93
|
+
identityIntegrationInputSchema,
|
|
94
|
+
identityIntegrationSchema,
|
|
95
|
+
identityIntegrationSecretSchema,
|
|
96
|
+
participantExchangeSchema,
|
|
97
|
+
parseImageExtraction,
|
|
98
|
+
parseImageResult,
|
|
99
|
+
sequenceCursorSchema
|
|
100
|
+
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
calendarPeriodSchema,
|
|
2
3
|
contentMetricSchema,
|
|
3
4
|
contentMetricsSchema,
|
|
4
5
|
identifier,
|
|
5
6
|
pageCursorSchema,
|
|
6
7
|
pointsRewardSchema,
|
|
8
|
+
refuseWindowTimeZone,
|
|
7
9
|
tierRewardSchema
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CRNQP7NV.js";
|
|
9
11
|
|
|
10
12
|
// src/authoring-identity.ts
|
|
11
13
|
import { z } from "zod";
|
|
@@ -39,6 +41,11 @@ var authoringKey = (input) => identitySchema.parse(input).key;
|
|
|
39
41
|
// src/engagement.ts
|
|
40
42
|
import { z as z2 } from "zod";
|
|
41
43
|
var amount = z2.number().int().safe().nonnegative();
|
|
44
|
+
var engagementBudgetSchema = z2.strictObject({
|
|
45
|
+
scope: z2.enum(["member", "project"]),
|
|
46
|
+
period: calendarPeriodSchema,
|
|
47
|
+
limit: amount
|
|
48
|
+
});
|
|
42
49
|
var engagementDefinitionSchema = z2.strictObject({
|
|
43
50
|
key: identifier,
|
|
44
51
|
qualifiedBy: identifier,
|
|
@@ -49,11 +56,10 @@ var engagementDefinitionSchema = z2.strictObject({
|
|
|
49
56
|
),
|
|
50
57
|
baseline: z2.literal("historical"),
|
|
51
58
|
maxAgeMs: z2.number().int().positive().max(864e5).default(36e5),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}).default({})
|
|
59
|
+
budgets: z2.array(engagementBudgetSchema).max(8).default([]).refine(
|
|
60
|
+
(budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
|
|
61
|
+
"Give each scope and period one budget"
|
|
62
|
+
)
|
|
57
63
|
});
|
|
58
64
|
var engagementScoreInputSchema = z2.strictObject({
|
|
59
65
|
metrics: contentMetricsSchema,
|
|
@@ -221,8 +227,13 @@ var RelayErrorCode = {
|
|
|
221
227
|
NotFound: "not-found",
|
|
222
228
|
/** The quest has no failed attempt the member can retry. */
|
|
223
229
|
RetryUnavailable: "retry-unavailable",
|
|
224
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* Durable submission storage is missing, blocked or unreadable. Nothing was lost: call the
|
|
232
|
+
* handle's `status()` or `resume()` again once storage is available.
|
|
233
|
+
*/
|
|
225
234
|
SubmissionStorage: "submission-storage",
|
|
235
|
+
/** Browser storage is full, so submission progress was not saved. Free space, then resume. */
|
|
236
|
+
SubmissionStorageQuota: "submission-storage-quota",
|
|
226
237
|
/** The saved submission is in a state that does not allow this action. */
|
|
227
238
|
SubmissionConflict: "submission-conflict",
|
|
228
239
|
/** The quest changed since the member saw it; review it before submitting again. */
|
|
@@ -233,6 +244,10 @@ var RelayErrorCode = {
|
|
|
233
244
|
InvalidSubmission: "invalid-submission",
|
|
234
245
|
/** A page cursor Relay cannot read; start again from the first page. */
|
|
235
246
|
InvalidCursor: "invalid-cursor",
|
|
247
|
+
/** No point ledger in the project has the key or ID the call named. */
|
|
248
|
+
PointLedgerNotFound: "point-ledger-not-found",
|
|
249
|
+
/** The member has not joined this project, so it holds no points here. */
|
|
250
|
+
NotJoined: "not-joined",
|
|
236
251
|
/** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
|
|
237
252
|
WalletSigner: "wallet-signer"
|
|
238
253
|
};
|
|
@@ -409,40 +424,39 @@ var leaderboardWindowSchema = z5.discriminatedUnion("kind", [
|
|
|
409
424
|
z5.object({ kind: z5.literal("all-time") }).strict(),
|
|
410
425
|
z5.object({ kind: z5.literal("fixed"), start: timestamp, end: timestamp }).strict().refine((w) => w.end > w.start, "Window end must follow its start"),
|
|
411
426
|
z5.object({ kind: z5.literal("rolling"), days: integer.min(1).max(3660) }).strict(),
|
|
427
|
+
// Not strict: boards published while a calendar window named its own `timeZone` keep reading,
|
|
428
|
+
// and the field drops on parse. The authoring schema refuses it.
|
|
412
429
|
z5.object({
|
|
413
430
|
kind: z5.literal("calendar"),
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
new Intl.DateTimeFormat("en", { timeZone: zone });
|
|
418
|
-
return true;
|
|
419
|
-
} catch {
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
}, "Use an IANA timezone")
|
|
423
|
-
}).strict()
|
|
431
|
+
/** The current day, week (ISO, starting on Monday) or month of the project calendar. */
|
|
432
|
+
period: calendarPeriodSchema.exclude(["lifetime"])
|
|
433
|
+
})
|
|
424
434
|
]);
|
|
425
435
|
var periodScore = {
|
|
426
436
|
window: leaderboardWindowSchema.default({ kind: "all-time" }),
|
|
427
437
|
quests: z5.array(identifier).min(1).max(100).optional()
|
|
428
438
|
};
|
|
439
|
+
var scoreSchema = z5.discriminatedUnion("kind", [
|
|
440
|
+
z5.object({ kind: z5.literal("balance") }).strict(),
|
|
441
|
+
z5.object({ kind: z5.literal("earned"), ...periodScore }).strict(),
|
|
442
|
+
z5.object({
|
|
443
|
+
kind: z5.literal("net"),
|
|
444
|
+
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
445
|
+
}).strict()
|
|
446
|
+
]).default({ kind: "balance" });
|
|
429
447
|
var leaderboardDefinitionSchema = z5.object({
|
|
430
448
|
id: identifier,
|
|
431
449
|
key: identifier.optional(),
|
|
432
450
|
title: z5.string().trim().min(1).max(120),
|
|
433
451
|
balance: identifier,
|
|
434
|
-
score:
|
|
435
|
-
z5.object({ kind: z5.literal("balance") }).strict(),
|
|
436
|
-
z5.object({ kind: z5.literal("earned"), ...periodScore }).strict(),
|
|
437
|
-
z5.object({
|
|
438
|
-
kind: z5.literal("net"),
|
|
439
|
-
window: leaderboardWindowSchema.default({ kind: "all-time" })
|
|
440
|
-
}).strict()
|
|
441
|
-
]).default({ kind: "balance" }),
|
|
452
|
+
score: scoreSchema,
|
|
442
453
|
access: z5.enum(["participants", "public"]).default("participants"),
|
|
443
454
|
group: identifier.optional()
|
|
444
455
|
}).strict();
|
|
445
|
-
var leaderboardAuthoringSchema = leaderboardDefinitionSchema.omit({ id: true }).extend(
|
|
456
|
+
var leaderboardAuthoringSchema = leaderboardDefinitionSchema.omit({ id: true }).extend({
|
|
457
|
+
...authoringIdentityShape,
|
|
458
|
+
score: z5.preprocess(refuseWindowTimeZone, scoreSchema)
|
|
459
|
+
}).strict().superRefine(validateAuthoringIdentity).transform(normalizeAuthoringIdentity);
|
|
446
460
|
var leaderboardArtifactSchema = z5.union([
|
|
447
461
|
leaderboardAuthoringSchema,
|
|
448
462
|
z5.object({ code: z5.string().min(1).max(2e6) }).strict()
|
|
@@ -903,6 +917,7 @@ export {
|
|
|
903
917
|
validateAuthoringIdentity,
|
|
904
918
|
normalizeAuthoringIdentity,
|
|
905
919
|
authoringKey,
|
|
920
|
+
engagementBudgetSchema,
|
|
906
921
|
engagementDefinitionSchema,
|
|
907
922
|
engagementScoreInputSchema,
|
|
908
923
|
engagementScoreSchema,
|