@domino-sdk/relay 1.7.0 → 1.10.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/action-9Xl0StBg.d.ts +33 -0
- package/dist/{activity-Br6vyYze.d.ts → activity-C0O3g7VJ.d.ts} +9 -9
- package/dist/authoring.d.ts +12 -12
- package/dist/authoring.js +3 -3
- package/dist/{automatic-outcomes-C1Q9LrDb.d.ts → automatic-outcomes-kPIDv6X_.d.ts} +1 -1
- package/dist/avatar.d.ts +2 -2
- package/dist/browser.d.ts +9 -8
- package/dist/browser.js +8 -6
- package/dist/{capability-error-Bv996M-h.d.ts → capability-error-ty3SqD_b.d.ts} +1 -1
- package/dist/{chunk-KGJSKGKI.js → chunk-23JUD56J.js} +1119 -910
- package/dist/{chunk-ZOUEEK5L.js → chunk-7BRHUUVB.js} +83 -26
- package/dist/{chunk-C25TDFHN.js → chunk-BKLGWPPD.js} +48 -37
- package/dist/{chunk-6ON4RMEN.js → chunk-BUXNTVER.js} +1 -1
- package/dist/{chunk-BFZHJA2B.js → chunk-GEPSEVQO.js} +2 -2
- package/dist/chunk-GFAFH7XR.js +98 -0
- package/dist/{chunk-6RBF3UDA.js → chunk-GPS546KR.js} +232 -7
- package/dist/{chunk-5ECM6AWV.js → chunk-MMWTHVXW.js} +3 -3
- package/dist/chunk-N2HXMTVA.js +13 -0
- package/dist/{chunk-23QJ7WH4.js → chunk-QL77V77D.js} +1 -1
- package/dist/{chunk-GMPPLZKH.js → chunk-UIR6NSYZ.js} +243 -228
- package/dist/{chunk-JW4G3SY5.js → chunk-WRBPLXVP.js} +60 -47
- package/dist/{client-pfml_XAa.d.ts → client-Yq11HA_f.d.ts} +64 -43
- package/dist/{groups-BpWEqaPn.d.ts → groups-BK8ts2yK.d.ts} +94 -6
- package/dist/{images-BaKYd0fl.d.ts → images-aw6W7vFZ.d.ts} +2 -2
- package/dist/index.d.ts +10 -9
- package/dist/index.js +10 -5
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +5 -5
- package/dist/{offers-CYtal8jO.d.ts → offers-C2FANzrG.d.ts} +3 -3
- package/dist/{pages-CixTNnF4.d.ts → pages-D00JDZB-.d.ts} +70 -39
- package/dist/portal-proxy.js +8 -2
- package/dist/react/index.d.ts +203 -19
- package/dist/react/index.js +256 -113
- package/dist/{referral-reward-kinds-ClxAuCGx.d.ts → referral-reward-kinds-M3f0PdiR.d.ts} +2 -2
- package/dist/{schema-CQydLqw4.d.ts → schema-DEM8y8Fm.d.ts} +16 -16
- package/dist/schema.d.ts +11239 -13
- package/dist/schema.js +38 -6
- package/dist/server/index.d.ts +43693 -52
- package/dist/server/index.js +465 -53
- package/dist/{sign-in-options-CtXUFV7E.d.ts → sign-in-options-Coim0G1u.d.ts} +3 -3
- package/dist/{submission-input-CLefHTrj.d.ts → submission-input-BbBJTVlT.d.ts} +3 -3
- package/dist/util.d-w9f9t3ua.d.ts +5 -0
- package/dist/{wallet-YssWxGg8.d.ts → wallet-CDyo-U4n.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/{profiles-D2aFcOxu.d.ts → profiles-BHMVj0kM.d.ts} +5 -5
|
@@ -12,41 +12,164 @@ import {
|
|
|
12
12
|
pointsRewardSchema,
|
|
13
13
|
refuseWindowTimeZone,
|
|
14
14
|
resourceHandle,
|
|
15
|
+
responseShape,
|
|
15
16
|
rewardKey,
|
|
16
17
|
tierRewardSchema
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-23JUD56J.js";
|
|
18
19
|
|
|
19
|
-
// src/
|
|
20
|
+
// src/errors.ts
|
|
20
21
|
import { z } from "zod";
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
var RelayErrorCode = {
|
|
23
|
+
/** The call needs a signed-in member. */
|
|
24
|
+
NotSignedIn: "not-signed-in",
|
|
25
|
+
/** The session changed since the app read it (the `session` option). Reload before retrying. */
|
|
26
|
+
StaleSession: "stale-session",
|
|
27
|
+
/** The input failed validation before it was sent. */
|
|
28
|
+
InvalidInput: "invalid-input",
|
|
29
|
+
/** Relay's answer was not JSON or not the expected shape (kind `invalid-response`). */
|
|
30
|
+
InvalidResponse: "invalid-response",
|
|
31
|
+
/** The transport failed, before a response or while reading its body (kind `network`). */
|
|
32
|
+
Network: "network",
|
|
33
|
+
/** The client's deadline elapsed (kind `timeout`). */
|
|
34
|
+
Timeout: "timeout",
|
|
35
|
+
/** The caller cancelled the request (kind `aborted`). */
|
|
36
|
+
Aborted: "aborted",
|
|
37
|
+
/** A quest or collection the call named is not in the member's experience. */
|
|
38
|
+
NotFound: "not-found",
|
|
39
|
+
/** The quest has no failed attempt the member can retry. */
|
|
40
|
+
RetryUnavailable: "retry-unavailable",
|
|
41
|
+
/**
|
|
42
|
+
* Durable submission storage is missing, blocked or unreadable. Nothing was lost: call the
|
|
43
|
+
* handle's `status()` or `resume()` again once storage is available.
|
|
44
|
+
*/
|
|
45
|
+
SubmissionStorage: "submission-storage",
|
|
46
|
+
/** Browser storage is full, so submission progress was not saved. Free space, then resume. */
|
|
47
|
+
SubmissionStorageQuota: "submission-storage-quota",
|
|
48
|
+
/** The saved submission is in a state that does not allow this action. */
|
|
49
|
+
SubmissionConflict: "submission-conflict",
|
|
50
|
+
/** The quest changed since the member saw it; review it before submitting again. */
|
|
51
|
+
QuestUpdated: "quest-updated",
|
|
52
|
+
/** Wait for the deferred attempt before submitting another action. */
|
|
53
|
+
AttemptPending: "attempt-pending",
|
|
54
|
+
/** The quiz changed since the member answered it. */
|
|
55
|
+
StaleQuiz: "stale-quiz",
|
|
56
|
+
/** Relay refused the submitted evidence. */
|
|
57
|
+
InvalidSubmission: "invalid-submission",
|
|
58
|
+
/** A page cursor Relay cannot read; start again from the first page. */
|
|
59
|
+
InvalidCursor: "invalid-cursor",
|
|
60
|
+
/** No point ledger in the project has the key or ID the call named. */
|
|
61
|
+
PointLedgerNotFound: "point-ledger-not-found",
|
|
62
|
+
/** The member has not joined this project, so it holds no points here. */
|
|
63
|
+
NotJoined: "not-joined",
|
|
64
|
+
/** The quest or campaign is not open at this time. */
|
|
65
|
+
OutsideWindow: "outside-window",
|
|
66
|
+
/** The signed-in member must enroll in the campaign first. */
|
|
67
|
+
EnrollmentRequired: "enrollment-required",
|
|
68
|
+
/** The quest's current reward budget has no remaining capacity. */
|
|
69
|
+
BudgetExhausted: "budget-exhausted",
|
|
70
|
+
/** No published offer has the key or ID the call named. */
|
|
71
|
+
OfferNotFound: "offer-not-found",
|
|
72
|
+
/** The operator paused this offer. */
|
|
73
|
+
OfferPaused: "offer-paused",
|
|
74
|
+
/** This member has already used the offer's allowed number of redemptions. */
|
|
75
|
+
OfferLimitReached: "offer-limit-reached",
|
|
76
|
+
/** No declared units remain. */
|
|
77
|
+
OfferOutOfStock: "offer-out-of-stock",
|
|
78
|
+
/** The participant's available point balance is below the offer price. */
|
|
79
|
+
InsufficientPoints: "insufficient-points",
|
|
80
|
+
/** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
|
|
81
|
+
WalletSigner: "wallet-signer",
|
|
82
|
+
/** The member has not met the quest's prerequisites; `missing` lists them. */
|
|
83
|
+
PrerequisitesIncomplete: "prerequisites-incomplete",
|
|
84
|
+
/** The quest is archived or retired: it takes no new participation. */
|
|
85
|
+
QuestClosed: "quest-closed",
|
|
86
|
+
/** An operator paused the quest. */
|
|
87
|
+
QuestPaused: "quest-paused",
|
|
88
|
+
/** An operator locked the member's profile; hiding it is still allowed. */
|
|
89
|
+
ProfileLocked: "profile-locked",
|
|
90
|
+
/** No member in the project has the invitation code the member accepted. */
|
|
91
|
+
InvitationNotFound: "invitation-not-found",
|
|
92
|
+
/** The email sign-in code is wrong; the member can type it again. */
|
|
93
|
+
InvalidCode: "invalid-code",
|
|
94
|
+
/** The email sign-in code expired, was used or had too many attempts; request another. */
|
|
95
|
+
CodeExpired: "code-expired",
|
|
96
|
+
/** The wallet sign-in challenge expired, was used or changed; start sign-in again. */
|
|
97
|
+
ChallengeExpired: "challenge-expired",
|
|
98
|
+
/** Too many requests; `retryAfter` says how long to wait when Relay knows. */
|
|
99
|
+
RateLimited: "rate-limited"
|
|
100
|
+
};
|
|
101
|
+
var relayErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.RelayError");
|
|
102
|
+
function isRelayError(value) {
|
|
103
|
+
return isRequestError(value) && value[relayErrorBrand] === true;
|
|
104
|
+
}
|
|
105
|
+
var RelayError = class extends RequestError {
|
|
106
|
+
name = "RelayError";
|
|
107
|
+
[relayErrorBrand] = true;
|
|
108
|
+
/** Which window refused admission when `code` is `outside-window`. */
|
|
109
|
+
window;
|
|
110
|
+
/** Prerequisites the member does not currently meet, when Relay refused for that reason. */
|
|
111
|
+
missing;
|
|
112
|
+
constructor(message, details) {
|
|
113
|
+
super(message, details);
|
|
114
|
+
this.window = details.window;
|
|
115
|
+
this.missing = details.missing ?? [];
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function asRelayError(cause, fallback = "Request failed") {
|
|
119
|
+
if (isRelayError(cause)) {
|
|
120
|
+
return cause;
|
|
121
|
+
}
|
|
122
|
+
return new RelayError(
|
|
123
|
+
cause instanceof Error && cause.message ? cause.message : fallback,
|
|
124
|
+
{ kind: "client", cause }
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function clientError(message, code, details = {}) {
|
|
128
|
+
return new RelayError(message, { ...details, kind: "client", code });
|
|
129
|
+
}
|
|
130
|
+
function parseInput(schema, value) {
|
|
131
|
+
const parsed = schema.safeParse(value);
|
|
132
|
+
if (!parsed.success) {
|
|
133
|
+
throw clientError(
|
|
134
|
+
z.prettifyError(parsed.error),
|
|
135
|
+
RelayErrorCode.InvalidInput,
|
|
136
|
+
{ cause: parsed.error }
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return parsed.data;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/point-ledgers.ts
|
|
143
|
+
import { z as z2 } from "zod";
|
|
144
|
+
var pointLedgerPropertiesSchema = z2.object({
|
|
145
|
+
name: z2.string().trim().min(1).max(120),
|
|
146
|
+
description: z2.string().trim().max(1e3).default("")
|
|
24
147
|
}).strict();
|
|
25
148
|
var createPointLedgerSchema = pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict();
|
|
26
149
|
var pointLedgerSchema = pointLedgerPropertiesSchema.extend({
|
|
27
150
|
id: identifier
|
|
28
151
|
});
|
|
29
152
|
var managedPointLedgerSchema = pointLedgerSchema.extend({
|
|
30
|
-
archivedAt:
|
|
153
|
+
archivedAt: z2.number().int().nonnegative().nullable()
|
|
31
154
|
});
|
|
32
155
|
var pointLedgerDeclarationSchema = pointLedgerPropertiesSchema.extend({ key: identifier }).strict();
|
|
33
|
-
var pointLedgerArtifactSchema =
|
|
156
|
+
var pointLedgerArtifactSchema = z2.union([
|
|
34
157
|
pointLedgerDeclarationSchema,
|
|
35
|
-
|
|
158
|
+
z2.object({ code: z2.string().min(1).max(2e6) }).strict()
|
|
36
159
|
]);
|
|
37
|
-
var pointLedgerReferenceSchema =
|
|
160
|
+
var pointLedgerReferenceSchema = z2.object({
|
|
38
161
|
id: identifier,
|
|
39
162
|
key: identifier.nullable(),
|
|
40
|
-
name:
|
|
163
|
+
name: z2.string()
|
|
41
164
|
});
|
|
42
|
-
var points =
|
|
43
|
-
var pointBalanceSchema =
|
|
165
|
+
var points = z2.number().int().safe();
|
|
166
|
+
var pointBalanceSchema = z2.object({
|
|
44
167
|
ledger: pointLedgerReferenceSchema,
|
|
45
168
|
balance: points,
|
|
46
169
|
available: points
|
|
47
170
|
});
|
|
48
|
-
var pointBalancesSchema =
|
|
49
|
-
items:
|
|
171
|
+
var pointBalancesSchema = z2.object({
|
|
172
|
+
items: z2.array(pointBalanceSchema)
|
|
50
173
|
});
|
|
51
174
|
var PointEntryKind = {
|
|
52
175
|
/** Points a quest completion, an engagement settlement or an operator awarded. */
|
|
@@ -58,8 +181,8 @@ var PointEntryKind = {
|
|
|
58
181
|
/** Undoes part or all of an award or a positive adjustment (`reverses`). */
|
|
59
182
|
Reverse: "reverse"
|
|
60
183
|
};
|
|
61
|
-
var pointEntryKindSchema =
|
|
62
|
-
var pointEntrySchema =
|
|
184
|
+
var pointEntryKindSchema = z2.string().min(1).max(64);
|
|
185
|
+
var pointEntrySchema = z2.object({
|
|
63
186
|
id: identifier,
|
|
64
187
|
amount: points,
|
|
65
188
|
kind: pointEntryKindSchema,
|
|
@@ -68,64 +191,64 @@ var pointEntrySchema = z.object({
|
|
|
68
191
|
quest: identifier.nullable(),
|
|
69
192
|
reverses: identifier.nullable()
|
|
70
193
|
});
|
|
71
|
-
var pointHistoryQuerySchema =
|
|
194
|
+
var pointHistoryQuerySchema = z2.strictObject({
|
|
72
195
|
ledger: identifier,
|
|
73
196
|
cursor: pageCursorSchema.optional()
|
|
74
197
|
});
|
|
75
|
-
var pointHistoryPageSchema =
|
|
76
|
-
items:
|
|
198
|
+
var pointHistoryPageSchema = z2.object({
|
|
199
|
+
items: z2.array(pointEntrySchema),
|
|
77
200
|
nextCursor: pageCursorSchema.nullable()
|
|
78
201
|
});
|
|
79
202
|
|
|
80
203
|
// src/engagement.ts
|
|
81
|
-
import { z as
|
|
82
|
-
var amount =
|
|
83
|
-
var engagementBudgetSchema =
|
|
84
|
-
scope:
|
|
204
|
+
import { z as z3 } from "zod";
|
|
205
|
+
var amount = z3.number().int().safe().nonnegative();
|
|
206
|
+
var engagementBudgetSchema = z3.strictObject({
|
|
207
|
+
scope: z3.enum(["member", "project"]),
|
|
85
208
|
period: calendarPeriodSchema,
|
|
86
209
|
limit: amount
|
|
87
210
|
});
|
|
88
|
-
var engagementDefinitionSchema =
|
|
211
|
+
var engagementDefinitionSchema = z3.strictObject({
|
|
89
212
|
key: identifier,
|
|
90
213
|
qualifiedBy: identifier,
|
|
91
214
|
balance: identifier,
|
|
92
|
-
metrics:
|
|
215
|
+
metrics: z3.array(contentMetricSchema).min(1).max(10).refine(
|
|
93
216
|
(metrics) => new Set(metrics).size === metrics.length,
|
|
94
217
|
"Metrics must be unique"
|
|
95
218
|
),
|
|
96
|
-
baseline:
|
|
97
|
-
maxAgeMs:
|
|
98
|
-
budgets:
|
|
219
|
+
baseline: z3.literal("historical"),
|
|
220
|
+
maxAgeMs: z3.number().int().positive().max(864e5).default(36e5),
|
|
221
|
+
budgets: z3.array(engagementBudgetSchema).max(8).default([]).refine(
|
|
99
222
|
(budgets) => new Set(budgets.map((b) => b.scope + ":" + b.period)).size === budgets.length,
|
|
100
223
|
"Give each scope and period one budget"
|
|
101
224
|
)
|
|
102
225
|
});
|
|
103
|
-
var engagementScoreInputSchema =
|
|
226
|
+
var engagementScoreInputSchema = z3.strictObject({
|
|
104
227
|
metrics: contentMetricsSchema,
|
|
105
228
|
baseline: contentMetricsSchema
|
|
106
229
|
});
|
|
107
|
-
var engagementScoreSchema =
|
|
230
|
+
var engagementScoreSchema = z3.strictObject({
|
|
108
231
|
target: amount,
|
|
109
232
|
baseline: amount
|
|
110
233
|
});
|
|
111
|
-
var engagementPublishSchema =
|
|
234
|
+
var engagementPublishSchema = z3.strictObject({
|
|
112
235
|
actionId: identifier,
|
|
113
|
-
code:
|
|
236
|
+
code: z3.string().min(1).max(1e6)
|
|
114
237
|
});
|
|
115
|
-
var engagementRuleSchema =
|
|
238
|
+
var engagementRuleSchema = z3.strictObject({
|
|
116
239
|
version: identifier,
|
|
117
240
|
definition: engagementDefinitionSchema,
|
|
118
241
|
publishedAt: amount
|
|
119
242
|
});
|
|
120
|
-
var engagementPageQuerySchema =
|
|
243
|
+
var engagementPageQuerySchema = z3.strictObject({
|
|
121
244
|
rule: identifier,
|
|
122
|
-
content:
|
|
245
|
+
content: z3.string().min(1).max(256),
|
|
123
246
|
member: identifier.optional(),
|
|
124
247
|
cursor: pageCursorSchema.optional()
|
|
125
248
|
});
|
|
126
|
-
var engagementSettlementSchema =
|
|
249
|
+
var engagementSettlementSchema = z3.strictObject({
|
|
127
250
|
id: identifier,
|
|
128
|
-
day:
|
|
251
|
+
day: z3.string(),
|
|
129
252
|
observation: identifier,
|
|
130
253
|
qualification: identifier,
|
|
131
254
|
earned: amount,
|
|
@@ -135,9 +258,9 @@ var engagementSettlementSchema = z2.strictObject({
|
|
|
135
258
|
entry: identifier.nullable(),
|
|
136
259
|
createdAt: amount
|
|
137
260
|
});
|
|
138
|
-
var engagementPageSchema =
|
|
261
|
+
var engagementPageSchema = z3.strictObject({
|
|
139
262
|
rule: engagementRuleSchema,
|
|
140
|
-
account:
|
|
263
|
+
account: z3.strictObject({
|
|
141
264
|
member: identifier,
|
|
142
265
|
earned: amount,
|
|
143
266
|
accounted: amount,
|
|
@@ -148,28 +271,28 @@ var engagementPageSchema = z2.strictObject({
|
|
|
148
271
|
baseline: contentMetricsSchema,
|
|
149
272
|
observation: identifier.nullable(),
|
|
150
273
|
nextSettlementAt: amount.nullable(),
|
|
151
|
-
reason:
|
|
274
|
+
reason: z3.string().nullable()
|
|
152
275
|
}).nullable(),
|
|
153
|
-
items:
|
|
276
|
+
items: z3.array(engagementSettlementSchema),
|
|
154
277
|
nextCursor: pageCursorSchema.nullable()
|
|
155
278
|
});
|
|
156
|
-
var engagementChangePreviewInputSchema =
|
|
157
|
-
code:
|
|
279
|
+
var engagementChangePreviewInputSchema = z3.strictObject({
|
|
280
|
+
code: z3.string().min(1).max(1e6)
|
|
158
281
|
});
|
|
159
282
|
var engagementChangeSchema = engagementPublishSchema.extend({
|
|
160
283
|
expectedVersion: identifier,
|
|
161
284
|
previewHash: identifier
|
|
162
285
|
});
|
|
163
|
-
var total =
|
|
164
|
-
var engagementChangePreviewSchema =
|
|
286
|
+
var total = z3.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
287
|
+
var engagementChangePreviewSchema = z3.strictObject({
|
|
165
288
|
rule: identifier,
|
|
166
289
|
fromVersion: identifier,
|
|
167
290
|
toVersion: identifier,
|
|
168
291
|
previewHash: identifier,
|
|
169
292
|
definition: engagementDefinitionSchema,
|
|
170
|
-
boundary:
|
|
171
|
-
settlement:
|
|
172
|
-
summary:
|
|
293
|
+
boundary: z3.literal("available-eligible-observation"),
|
|
294
|
+
settlement: z3.literal("deferred"),
|
|
295
|
+
summary: z3.strictObject({
|
|
173
296
|
knownAdmissions: amount,
|
|
174
297
|
accounts: amount,
|
|
175
298
|
uninitialized: amount,
|
|
@@ -183,13 +306,13 @@ var engagementChangePreviewSchema = z2.strictObject({
|
|
|
183
306
|
var engagementVersionSchema = engagementRuleSchema.extend({
|
|
184
307
|
previousVersion: identifier.nullable()
|
|
185
308
|
});
|
|
186
|
-
var engagementRuleVersionPageSchema =
|
|
187
|
-
items:
|
|
188
|
-
|
|
309
|
+
var engagementRuleVersionPageSchema = z3.object({
|
|
310
|
+
items: z3.array(
|
|
311
|
+
z3.object({
|
|
189
312
|
version: identifier,
|
|
190
|
-
definition:
|
|
313
|
+
definition: z3.object({
|
|
191
314
|
...engagementDefinitionSchema.shape,
|
|
192
|
-
budgets:
|
|
315
|
+
budgets: z3.array(z3.object(engagementBudgetSchema.shape)).max(8).default([])
|
|
193
316
|
}),
|
|
194
317
|
publishedAt: amount,
|
|
195
318
|
previousVersion: identifier.nullable()
|
|
@@ -197,19 +320,19 @@ var engagementRuleVersionPageSchema = z2.object({
|
|
|
197
320
|
),
|
|
198
321
|
nextCursor: pageCursorSchema.nullable()
|
|
199
322
|
});
|
|
200
|
-
var engagementVersionPageSchema =
|
|
201
|
-
items:
|
|
323
|
+
var engagementVersionPageSchema = z3.strictObject({
|
|
324
|
+
items: z3.array(engagementVersionSchema),
|
|
202
325
|
next: amount.nullable()
|
|
203
326
|
});
|
|
204
|
-
var engagementVersionQuerySchema =
|
|
327
|
+
var engagementVersionQuerySchema = z3.strictObject({
|
|
205
328
|
rule: identifier,
|
|
206
|
-
before:
|
|
329
|
+
before: z3.coerce.number().int().positive().safe().optional()
|
|
207
330
|
});
|
|
208
|
-
var engagementBoundaryPageSchema =
|
|
331
|
+
var engagementBoundaryPageSchema = z3.strictObject({
|
|
209
332
|
current: engagementRuleSchema.nullable(),
|
|
210
333
|
requested: engagementRuleSchema,
|
|
211
|
-
items:
|
|
212
|
-
|
|
334
|
+
items: z3.array(
|
|
335
|
+
z3.strictObject({
|
|
213
336
|
from: identifier,
|
|
214
337
|
to: identifier,
|
|
215
338
|
baseline: contentMetricsSchema,
|
|
@@ -225,137 +348,15 @@ var engagementArtifactSchema = engagementPublishSchema.omit({
|
|
|
225
348
|
var deploymentEntry = engagementArtifactSchema.extend({
|
|
226
349
|
rule: engagementRuleSchema
|
|
227
350
|
});
|
|
228
|
-
var engagementDeploymentEntrySchema =
|
|
229
|
-
deploymentEntry.extend({ kind:
|
|
230
|
-
deploymentEntry.extend({ kind:
|
|
351
|
+
var engagementDeploymentEntrySchema = z3.discriminatedUnion("kind", [
|
|
352
|
+
deploymentEntry.extend({ kind: z3.literal("create") }),
|
|
353
|
+
deploymentEntry.extend({ kind: z3.literal("unchanged") }),
|
|
231
354
|
deploymentEntry.extend({
|
|
232
|
-
kind:
|
|
355
|
+
kind: z3.literal("change"),
|
|
233
356
|
change: engagementChangePreviewSchema
|
|
234
357
|
})
|
|
235
358
|
]);
|
|
236
359
|
|
|
237
|
-
// src/errors.ts
|
|
238
|
-
import { z as z3 } from "zod";
|
|
239
|
-
var RelayErrorCode = {
|
|
240
|
-
/** The call needs a signed-in member. */
|
|
241
|
-
NotSignedIn: "not-signed-in",
|
|
242
|
-
/** The session changed since the app read it (the `session` option). Reload before retrying. */
|
|
243
|
-
StaleSession: "stale-session",
|
|
244
|
-
/** The input failed validation before it was sent. */
|
|
245
|
-
InvalidInput: "invalid-input",
|
|
246
|
-
/** Relay's answer was not JSON or not the expected shape (kind `invalid-response`). */
|
|
247
|
-
InvalidResponse: "invalid-response",
|
|
248
|
-
/** The transport failed, before a response or while reading its body (kind `network`). */
|
|
249
|
-
Network: "network",
|
|
250
|
-
/** The client's deadline elapsed (kind `timeout`). */
|
|
251
|
-
Timeout: "timeout",
|
|
252
|
-
/** The caller cancelled the request (kind `aborted`). */
|
|
253
|
-
Aborted: "aborted",
|
|
254
|
-
/** A quest or collection the call named is not in the member's experience. */
|
|
255
|
-
NotFound: "not-found",
|
|
256
|
-
/** The quest has no failed attempt the member can retry. */
|
|
257
|
-
RetryUnavailable: "retry-unavailable",
|
|
258
|
-
/**
|
|
259
|
-
* Durable submission storage is missing, blocked or unreadable. Nothing was lost: call the
|
|
260
|
-
* handle's `status()` or `resume()` again once storage is available.
|
|
261
|
-
*/
|
|
262
|
-
SubmissionStorage: "submission-storage",
|
|
263
|
-
/** Browser storage is full, so submission progress was not saved. Free space, then resume. */
|
|
264
|
-
SubmissionStorageQuota: "submission-storage-quota",
|
|
265
|
-
/** The saved submission is in a state that does not allow this action. */
|
|
266
|
-
SubmissionConflict: "submission-conflict",
|
|
267
|
-
/** The quest changed since the member saw it; review it before submitting again. */
|
|
268
|
-
QuestUpdated: "quest-updated",
|
|
269
|
-
/** Wait for the deferred attempt before submitting another action. */
|
|
270
|
-
AttemptPending: "attempt-pending",
|
|
271
|
-
/** The quiz changed since the member answered it. */
|
|
272
|
-
StaleQuiz: "stale-quiz",
|
|
273
|
-
/** Relay refused the submitted evidence. */
|
|
274
|
-
InvalidSubmission: "invalid-submission",
|
|
275
|
-
/** A page cursor Relay cannot read; start again from the first page. */
|
|
276
|
-
InvalidCursor: "invalid-cursor",
|
|
277
|
-
/** No point ledger in the project has the key or ID the call named. */
|
|
278
|
-
PointLedgerNotFound: "point-ledger-not-found",
|
|
279
|
-
/** The member has not joined this project, so it holds no points here. */
|
|
280
|
-
NotJoined: "not-joined",
|
|
281
|
-
/** The quest or campaign is not open at this time. */
|
|
282
|
-
OutsideWindow: "outside-window",
|
|
283
|
-
/** The signed-in member must enroll in the campaign first. */
|
|
284
|
-
EnrollmentRequired: "enrollment-required",
|
|
285
|
-
/** The quest's current reward budget has no remaining capacity. */
|
|
286
|
-
BudgetExhausted: "budget-exhausted",
|
|
287
|
-
/** No published offer has the key or ID the call named. */
|
|
288
|
-
OfferNotFound: "offer-not-found",
|
|
289
|
-
/** The operator paused this offer. */
|
|
290
|
-
OfferPaused: "offer-paused",
|
|
291
|
-
/** This member has already used the offer's allowed number of redemptions. */
|
|
292
|
-
OfferLimitReached: "offer-limit-reached",
|
|
293
|
-
/** No declared units remain. */
|
|
294
|
-
OfferOutOfStock: "offer-out-of-stock",
|
|
295
|
-
/** The participant's available point balance is below the offer price. */
|
|
296
|
-
InsufficientPoints: "insufficient-points",
|
|
297
|
-
/** A wallet signer failed or the member refused to sign; `cause` is the wallet's own error. */
|
|
298
|
-
WalletSigner: "wallet-signer",
|
|
299
|
-
/** The member has not met the quest's prerequisites; `missing` lists them. */
|
|
300
|
-
PrerequisitesIncomplete: "prerequisites-incomplete",
|
|
301
|
-
/** The quest is archived or retired: it takes no new participation. */
|
|
302
|
-
QuestClosed: "quest-closed",
|
|
303
|
-
/** An operator paused the quest. */
|
|
304
|
-
QuestPaused: "quest-paused",
|
|
305
|
-
/** An operator locked the member's profile; hiding it is still allowed. */
|
|
306
|
-
ProfileLocked: "profile-locked",
|
|
307
|
-
/** No member in the project has the invitation code the member accepted. */
|
|
308
|
-
InvitationNotFound: "invitation-not-found",
|
|
309
|
-
/** The email sign-in code is wrong; the member can type it again. */
|
|
310
|
-
InvalidCode: "invalid-code",
|
|
311
|
-
/** The email sign-in code expired, was used or had too many attempts; request another. */
|
|
312
|
-
CodeExpired: "code-expired",
|
|
313
|
-
/** The wallet sign-in challenge expired, was used or changed; start sign-in again. */
|
|
314
|
-
ChallengeExpired: "challenge-expired",
|
|
315
|
-
/** Too many requests; `retryAfter` says how long to wait when Relay knows. */
|
|
316
|
-
RateLimited: "rate-limited"
|
|
317
|
-
};
|
|
318
|
-
var relayErrorBrand = /* @__PURE__ */ Symbol.for("@domino-sdk/relay.RelayError");
|
|
319
|
-
function isRelayError(value) {
|
|
320
|
-
return isRequestError(value) && value[relayErrorBrand] === true;
|
|
321
|
-
}
|
|
322
|
-
var RelayError = class extends RequestError {
|
|
323
|
-
name = "RelayError";
|
|
324
|
-
[relayErrorBrand] = true;
|
|
325
|
-
/** Which window refused admission when `code` is `outside-window`. */
|
|
326
|
-
window;
|
|
327
|
-
/** Prerequisites the member does not currently meet, when Relay refused for that reason. */
|
|
328
|
-
missing;
|
|
329
|
-
constructor(message, details) {
|
|
330
|
-
super(message, details);
|
|
331
|
-
this.window = details.window;
|
|
332
|
-
this.missing = details.missing ?? [];
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
function asRelayError(cause, fallback = "Request failed") {
|
|
336
|
-
if (isRelayError(cause)) {
|
|
337
|
-
return cause;
|
|
338
|
-
}
|
|
339
|
-
return new RelayError(
|
|
340
|
-
cause instanceof Error && cause.message ? cause.message : fallback,
|
|
341
|
-
{ kind: "client", cause }
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
function clientError(message, code, details = {}) {
|
|
345
|
-
return new RelayError(message, { ...details, kind: "client", code });
|
|
346
|
-
}
|
|
347
|
-
function parseInput(schema, value) {
|
|
348
|
-
const parsed = schema.safeParse(value);
|
|
349
|
-
if (!parsed.success) {
|
|
350
|
-
throw clientError(
|
|
351
|
-
z3.prettifyError(parsed.error),
|
|
352
|
-
RelayErrorCode.InvalidInput,
|
|
353
|
-
{ cause: parsed.error }
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
return parsed.data;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
360
|
// src/profiles.ts
|
|
360
361
|
import { z as z4 } from "zod";
|
|
361
362
|
var count = z4.number().int().nonnegative().safe();
|
|
@@ -577,6 +578,9 @@ var validateSettlementWindow = (definition, context) => {
|
|
|
577
578
|
}
|
|
578
579
|
};
|
|
579
580
|
var leaderboardDefinitionSchema = leaderboardDefinitionObject.superRefine(validateSettlementWindow);
|
|
581
|
+
var leaderboardDefinitionResponseSchema = responseShape(
|
|
582
|
+
leaderboardDefinitionSchema
|
|
583
|
+
);
|
|
580
584
|
var leaderboardAuthoringSchema = leaderboardDefinitionObject.omit({ id: true }).extend({
|
|
581
585
|
...authoringIdentityShape,
|
|
582
586
|
score: z5.preprocess(refuseWindowTimeZone, scoreSchema),
|
|
@@ -589,7 +593,7 @@ var leaderboardArtifactSchema = z5.union([
|
|
|
589
593
|
var publishedLeaderboardSchema = z5.object({
|
|
590
594
|
archivedAt: z5.number().int().nonnegative().nullable().optional(),
|
|
591
595
|
version: identifier,
|
|
592
|
-
definition:
|
|
596
|
+
definition: leaderboardDefinitionResponseSchema,
|
|
593
597
|
publishedAt: timestamp,
|
|
594
598
|
actor: z5.string().nullable()
|
|
595
599
|
});
|
|
@@ -943,18 +947,22 @@ var offerArtifactSchema = z7.union([
|
|
|
943
947
|
offerAuthoringSchema,
|
|
944
948
|
z7.object({ code: z7.string().min(1).max(2e6) }).strict()
|
|
945
949
|
]);
|
|
946
|
-
var offerAvailabilitySchema =
|
|
947
|
-
z7.
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
950
|
+
var offerAvailabilitySchema = responseShape(
|
|
951
|
+
z7.discriminatedUnion("kind", [
|
|
952
|
+
z7.object({ kind: z7.literal("available"), remaining: quantity }).strict(),
|
|
953
|
+
z7.object({ kind: z7.literal("out-of-stock") }).strict(),
|
|
954
|
+
z7.object({ kind: z7.literal("limit-reached") }).strict(),
|
|
955
|
+
z7.object({ kind: z7.literal("paused") }).strict()
|
|
956
|
+
])
|
|
957
|
+
);
|
|
958
|
+
var offerSchema = responseShape(
|
|
959
|
+
offerDefinitionSchema.extend({
|
|
960
|
+
revision: z7.number().int().positive(),
|
|
961
|
+
available: quantity,
|
|
962
|
+
redeemed: quantity,
|
|
963
|
+
availability: offerAvailabilitySchema
|
|
964
|
+
})
|
|
965
|
+
);
|
|
958
966
|
var redeemOfferSchema = z7.object({ actionId: identifier }).strict();
|
|
959
967
|
var redemptionBase = {
|
|
960
968
|
id: identifier,
|
|
@@ -972,15 +980,17 @@ var redemptionBase = {
|
|
|
972
980
|
revision: z7.number().int().positive(),
|
|
973
981
|
redeemedAt: z7.number().int().safe().nonnegative()
|
|
974
982
|
};
|
|
975
|
-
var redemptionSchema =
|
|
976
|
-
z7.
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
983
|
+
var redemptionSchema = responseShape(
|
|
984
|
+
z7.discriminatedUnion("status", [
|
|
985
|
+
z7.object({ ...redemptionBase, status: z7.literal("fulfilled") }).strict(),
|
|
986
|
+
z7.object({
|
|
987
|
+
...redemptionBase,
|
|
988
|
+
status: z7.literal("canceled"),
|
|
989
|
+
canceledAt: z7.number().int().safe().nonnegative(),
|
|
990
|
+
reason: z7.string().min(1).max(500)
|
|
991
|
+
}).strict()
|
|
992
|
+
])
|
|
993
|
+
);
|
|
984
994
|
var offerControlSchema = z7.object({
|
|
985
995
|
actionId: identifier,
|
|
986
996
|
revision: z7.number().int().positive(),
|
|
@@ -1130,22 +1140,32 @@ var evmChainIdSchema = z8.custom(
|
|
|
1130
1140
|
'Use an EVM chain ID such as "eip155:8453"'
|
|
1131
1141
|
);
|
|
1132
1142
|
var units = z8.string().regex(/^(0|[1-9][0-9]*)$/);
|
|
1133
|
-
var walletBalanceSchema =
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1143
|
+
var walletBalanceSchema = responseShape(
|
|
1144
|
+
z8.object({
|
|
1145
|
+
/** Canonical CAIP-2 ID for Solana, EVM or a supported Cosmos SDK chain. */
|
|
1146
|
+
chain: z8.string(),
|
|
1147
|
+
/** The canonical mint, EIP-55 contract or Cosmos bank denom; null for a native coin. */
|
|
1148
|
+
token: z8.string().nullable(),
|
|
1149
|
+
/** Null when token metadata does not report decimals. */
|
|
1150
|
+
decimals: z8.number().int().min(0).max(255).nullable(),
|
|
1151
|
+
/** The sum over `wallets`. */
|
|
1152
|
+
total: units,
|
|
1153
|
+
wallets: z8.array(
|
|
1154
|
+
z8.object({ address: z8.string(), amount: units }).strict()
|
|
1155
|
+
),
|
|
1156
|
+
/** Solana: lowest slot. EVM: approximate latest block. Cosmos: the fixed queried block. */
|
|
1157
|
+
at: z8.object({ kind: z8.enum(["slot", "block"]), number: units }).strict(),
|
|
1158
|
+
observedAt: z8.number().int().nonnegative()
|
|
1159
|
+
}).strict()
|
|
1160
|
+
);
|
|
1147
1161
|
|
|
1148
1162
|
export {
|
|
1163
|
+
RelayErrorCode,
|
|
1164
|
+
isRelayError,
|
|
1165
|
+
RelayError,
|
|
1166
|
+
asRelayError,
|
|
1167
|
+
clientError,
|
|
1168
|
+
parseInput,
|
|
1149
1169
|
pointLedgerPropertiesSchema,
|
|
1150
1170
|
createPointLedgerSchema,
|
|
1151
1171
|
pointLedgerSchema,
|
|
@@ -1177,12 +1197,6 @@ export {
|
|
|
1177
1197
|
engagementBoundaryPageSchema,
|
|
1178
1198
|
engagementArtifactSchema,
|
|
1179
1199
|
engagementDeploymentEntrySchema,
|
|
1180
|
-
RelayErrorCode,
|
|
1181
|
-
isRelayError,
|
|
1182
|
-
RelayError,
|
|
1183
|
-
asRelayError,
|
|
1184
|
-
clientError,
|
|
1185
|
-
parseInput,
|
|
1186
1200
|
profileVisibilitySchema,
|
|
1187
1201
|
avatarProviderSchema,
|
|
1188
1202
|
profileDefaultProviderSchema,
|
|
@@ -1208,6 +1222,7 @@ export {
|
|
|
1208
1222
|
leaderboardPrizeSchema,
|
|
1209
1223
|
leaderboardSettlementPolicySchema,
|
|
1210
1224
|
leaderboardDefinitionSchema,
|
|
1225
|
+
leaderboardDefinitionResponseSchema,
|
|
1211
1226
|
leaderboardAuthoringSchema,
|
|
1212
1227
|
leaderboardArtifactSchema,
|
|
1213
1228
|
publishedLeaderboardSchema,
|