@domino-sdk/relay 0.15.0 → 0.16.1
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 +49 -4
- package/dist/authoring.js +17 -3
- package/dist/browser.d.ts +327 -50
- package/dist/browser.js +5 -5
- package/dist/{chunk-I2CCMGN6.js → chunk-GEJK7LMK.js} +1 -1
- package/dist/{chunk-CQ5YSQQE.js → chunk-MK2E36HR.js} +1 -1
- package/dist/{chunk-YZJOZL4V.js → chunk-TI22MU2X.js} +121 -30
- package/dist/{chunk-CJARNIVP.js → chunk-XNS25KST.js} +1 -1
- package/dist/{chunk-FUQYKTOJ.js → chunk-YUAE6PFY.js} +406 -285
- package/dist/index.d.ts +842 -130
- package/dist/index.js +36 -6
- package/dist/portal-proxy.js +2 -2
- package/dist/react/index.d.ts +317 -14
- package/dist/react/index.js +8 -5
- package/dist/schema.d.ts +255 -13
- package/dist/schema.js +7 -1
- package/dist/{settings-e0nHA0JA.d.ts → submission-input-Cktvl71b.d.ts} +110 -1
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
browserSubmissionStore,
|
|
3
3
|
createBrowserRelayClient
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-MK2E36HR.js";
|
|
5
|
+
import "./chunk-TI22MU2X.js";
|
|
6
|
+
import "./chunk-XNS25KST.js";
|
|
7
|
+
import "./chunk-GEJK7LMK.js";
|
|
8
|
+
import "./chunk-YUAE6PFY.js";
|
|
9
9
|
export {
|
|
10
10
|
browserSubmissionStore,
|
|
11
11
|
createBrowserRelayClient
|
|
@@ -14,13 +14,14 @@ import {
|
|
|
14
14
|
referralHistorySchema,
|
|
15
15
|
referralSummarySchema,
|
|
16
16
|
trackerArtifactSchema,
|
|
17
|
-
validateAuthoringIdentity
|
|
18
|
-
|
|
17
|
+
validateAuthoringIdentity,
|
|
18
|
+
xTweetSchema
|
|
19
|
+
} from "./chunk-XNS25KST.js";
|
|
19
20
|
import {
|
|
20
21
|
authScopeSchema,
|
|
21
22
|
exchangeResultSchema,
|
|
22
23
|
sessionSchema
|
|
23
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-GEJK7LMK.js";
|
|
24
25
|
import {
|
|
25
26
|
accountConnectionSchema,
|
|
26
27
|
attemptSchema,
|
|
@@ -44,8 +45,11 @@ import {
|
|
|
44
45
|
settingsValuesSchema,
|
|
45
46
|
snapshotSchema,
|
|
46
47
|
storedReviewModeSchema,
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
submissionEvidenceSchema,
|
|
49
|
+
templateSchema,
|
|
50
|
+
validateSubmissionValue,
|
|
51
|
+
valueEvidenceSchema
|
|
52
|
+
} from "./chunk-YUAE6PFY.js";
|
|
49
53
|
|
|
50
54
|
// src/point-ledgers.ts
|
|
51
55
|
import { z } from "zod";
|
|
@@ -91,6 +95,8 @@ var rewardDeliveriesSchema = z2.object({
|
|
|
91
95
|
import { z as z3 } from "zod";
|
|
92
96
|
var interactionSchema = z3.enum([
|
|
93
97
|
"photo",
|
|
98
|
+
"text",
|
|
99
|
+
"url",
|
|
94
100
|
"quiz",
|
|
95
101
|
"claim",
|
|
96
102
|
"staff",
|
|
@@ -229,7 +235,7 @@ var common = {
|
|
|
229
235
|
release: identifier.optional()
|
|
230
236
|
};
|
|
231
237
|
var claimInputSchema = z4.union([
|
|
232
|
-
|
|
238
|
+
submissionEvidenceSchema,
|
|
233
239
|
z4.object({ kind: z4.literal("none") }).strict()
|
|
234
240
|
]);
|
|
235
241
|
var draftSchema = z4.union([
|
|
@@ -322,7 +328,7 @@ function submissions(transport, configuredStore, namespace) {
|
|
|
322
328
|
quest,
|
|
323
329
|
actionId: record.id,
|
|
324
330
|
...record.release ? { release: record.release } : {},
|
|
325
|
-
..."evidence" in record ? { evidence: record.evidence } : record.input.kind
|
|
331
|
+
..."evidence" in record ? { evidence: record.evidence } : record.input.kind !== "none" ? { input: record.input } : {}
|
|
326
332
|
},
|
|
327
333
|
sessionId
|
|
328
334
|
);
|
|
@@ -356,6 +362,10 @@ function submissions(transport, configuredStore, namespace) {
|
|
|
356
362
|
try {
|
|
357
363
|
attempt = await claim(record);
|
|
358
364
|
} catch (error) {
|
|
365
|
+
if (error instanceof RelayError && error.status === 422 && error.code === "invalid-submission" && record.stage === "claim") {
|
|
366
|
+
await store.write(key, null);
|
|
367
|
+
throw error;
|
|
368
|
+
}
|
|
359
369
|
if (error instanceof RelayError && error.status === 409 && (error.code === "quest-updated" || error.code === "stale-quiz") && record.stage === "claim") {
|
|
360
370
|
const draft = "input" in record ? record.input : "file" in record && record.file ? { kind: "photo", file: record.file } : null;
|
|
361
371
|
await store.write(
|
|
@@ -455,6 +465,22 @@ function submissions(transport, configuredStore, namespace) {
|
|
|
455
465
|
});
|
|
456
466
|
}
|
|
457
467
|
};
|
|
468
|
+
if (options.input === "text" || options.input === "url") {
|
|
469
|
+
const kind = options.input;
|
|
470
|
+
return {
|
|
471
|
+
...handle,
|
|
472
|
+
submit(value) {
|
|
473
|
+
const input = valueEvidenceSchema.parse({ kind, value });
|
|
474
|
+
return submit({
|
|
475
|
+
id: crypto.randomUUID(),
|
|
476
|
+
quest,
|
|
477
|
+
release: options.release,
|
|
478
|
+
stage: "claim",
|
|
479
|
+
input
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
458
484
|
if (options.input === "quiz") {
|
|
459
485
|
return {
|
|
460
486
|
...handle,
|
|
@@ -524,6 +550,9 @@ function reconcileQuestDraft(view, draft) {
|
|
|
524
550
|
if (!draft) {
|
|
525
551
|
return null;
|
|
526
552
|
}
|
|
553
|
+
if (draft.kind === "text" || draft.kind === "url") {
|
|
554
|
+
return view.interaction === draft.kind ? draft : null;
|
|
555
|
+
}
|
|
527
556
|
if (draft.kind === "photo") {
|
|
528
557
|
return view.interaction === "photo" ? draft : null;
|
|
529
558
|
}
|
|
@@ -577,6 +606,36 @@ function questActions(submission, latest) {
|
|
|
577
606
|
};
|
|
578
607
|
}
|
|
579
608
|
switch (view.interaction) {
|
|
609
|
+
case "text":
|
|
610
|
+
case "url": {
|
|
611
|
+
const kind = view.interaction;
|
|
612
|
+
const handle = await submission(view.quest, {
|
|
613
|
+
input: kind,
|
|
614
|
+
release: view.release,
|
|
615
|
+
recoverPrevious: true,
|
|
616
|
+
repeatable: view.completion.kind === "keyed"
|
|
617
|
+
});
|
|
618
|
+
return {
|
|
619
|
+
kind,
|
|
620
|
+
view,
|
|
621
|
+
status: handle.status,
|
|
622
|
+
discard: handle.discard,
|
|
623
|
+
resume: () => run(handle.resume),
|
|
624
|
+
submit: (value) => run(() => {
|
|
625
|
+
if (view.trigger.kind !== "manual" || view.trigger.input !== "text" && view.trigger.input !== "url") {
|
|
626
|
+
throw new Error("Quest input changed");
|
|
627
|
+
}
|
|
628
|
+
const problem = validateSubmissionValue(
|
|
629
|
+
{ kind, value },
|
|
630
|
+
view.trigger
|
|
631
|
+
);
|
|
632
|
+
if (problem) {
|
|
633
|
+
throw new Error(problem);
|
|
634
|
+
}
|
|
635
|
+
return handle.submit(value);
|
|
636
|
+
})
|
|
637
|
+
};
|
|
638
|
+
}
|
|
580
639
|
case "photo": {
|
|
581
640
|
const handle = await submission(view.quest, {
|
|
582
641
|
input: "photo",
|
|
@@ -729,7 +788,7 @@ function observeProgress(transport, listener, options = {}, onDispose = () => {
|
|
|
729
788
|
}
|
|
730
789
|
|
|
731
790
|
// src/index.ts
|
|
732
|
-
import { z as
|
|
791
|
+
import { z as z10 } from "zod";
|
|
733
792
|
|
|
734
793
|
// src/wallet.ts
|
|
735
794
|
import { z as z5 } from "zod";
|
|
@@ -849,6 +908,33 @@ var participantExchangeSchema = z8.object({
|
|
|
849
908
|
previousToken: z8.string().max(200).optional()
|
|
850
909
|
}).strict();
|
|
851
910
|
|
|
911
|
+
// src/x.ts
|
|
912
|
+
import { z as z9 } from "zod";
|
|
913
|
+
var xIdSchema = z9.string().regex(/^[0-9]{1,20}$/);
|
|
914
|
+
var xConnectionSchema = z9.object({ userId: xIdSchema });
|
|
915
|
+
var xProfileSchema = z9.object({
|
|
916
|
+
id: xIdSchema,
|
|
917
|
+
username: z9.string(),
|
|
918
|
+
name: z9.string(),
|
|
919
|
+
bio: z9.string().nullable(),
|
|
920
|
+
profileImageUrl: z9.string().url().nullable(),
|
|
921
|
+
followersCount: z9.number().int().nonnegative().nullable(),
|
|
922
|
+
verified: z9.boolean().nullable()
|
|
923
|
+
});
|
|
924
|
+
var xPostSchema = xTweetSchema.extend({
|
|
925
|
+
quotedTweetId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
926
|
+
inReplyToUserId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
927
|
+
inReplyToStatusId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
928
|
+
retweetedTweetId: xIdSchema.nullish().transform((v) => v ?? null)
|
|
929
|
+
});
|
|
930
|
+
var xRequestSchema = z9.discriminatedUnion("operation", [
|
|
931
|
+
z9.object({ operation: z9.literal("connection") }).strict(),
|
|
932
|
+
z9.object({ operation: z9.literal("profile") }).strict(),
|
|
933
|
+
z9.object({ operation: z9.literal("post"), postId: xIdSchema }).strict(),
|
|
934
|
+
z9.object({ operation: z9.literal("follows"), userId: xIdSchema }).strict(),
|
|
935
|
+
z9.object({ operation: z9.literal("reposted"), postId: xIdSchema }).strict()
|
|
936
|
+
]);
|
|
937
|
+
|
|
852
938
|
// src/index.ts
|
|
853
939
|
function createRelayClient(options) {
|
|
854
940
|
async function send(path, init = {}) {
|
|
@@ -980,19 +1066,19 @@ function createRelayClient(options) {
|
|
|
980
1066
|
}
|
|
981
1067
|
return {
|
|
982
1068
|
referrals: {
|
|
983
|
-
list: () => request("/v1/referrals",
|
|
1069
|
+
list: () => request("/v1/referrals", z10.array(referralDefinitionSchema)),
|
|
984
1070
|
summary: () => request("/v1/referrals/me", referralSummarySchema),
|
|
985
1071
|
history: (before) => request(
|
|
986
1072
|
query("/v1/referrals/history", { before }),
|
|
987
1073
|
referralHistorySchema
|
|
988
1074
|
),
|
|
989
|
-
accept: (input) => request("/v1/referrals/accept",
|
|
1075
|
+
accept: (input) => request("/v1/referrals/accept", z10.object({ ok: z10.literal(true) }), {
|
|
990
1076
|
method: "POST",
|
|
991
1077
|
body: JSON.stringify(referralAcceptSchema.parse(input))
|
|
992
1078
|
})
|
|
993
1079
|
},
|
|
994
1080
|
leaderboards: {
|
|
995
|
-
list: () => request("/v1/leaderboards",
|
|
1081
|
+
list: () => request("/v1/leaderboards", z10.array(leaderboardDefinitionSchema)),
|
|
996
1082
|
standings: (board, options2 = {}) => {
|
|
997
1083
|
const parsed = leaderboardQuerySchema.parse(options2);
|
|
998
1084
|
return request(
|
|
@@ -1077,25 +1163,25 @@ function createRelayClient(options) {
|
|
|
1077
1163
|
auth: {
|
|
1078
1164
|
providers: () => request(
|
|
1079
1165
|
"/v1/auth/providers",
|
|
1080
|
-
|
|
1081
|
-
providers:
|
|
1082
|
-
|
|
1166
|
+
z10.object({
|
|
1167
|
+
providers: z10.array(
|
|
1168
|
+
z10.object({
|
|
1083
1169
|
provider: authProviderSchema,
|
|
1084
|
-
configured:
|
|
1170
|
+
configured: z10.boolean()
|
|
1085
1171
|
})
|
|
1086
1172
|
),
|
|
1087
|
-
email:
|
|
1088
|
-
demo:
|
|
1173
|
+
email: z10.boolean(),
|
|
1174
|
+
demo: z10.boolean()
|
|
1089
1175
|
})
|
|
1090
1176
|
),
|
|
1091
1177
|
start: (provider, mode) => request(
|
|
1092
1178
|
"/v1/auth/start",
|
|
1093
|
-
|
|
1179
|
+
z10.object({ url: z10.string() }),
|
|
1094
1180
|
json({ provider, mode })
|
|
1095
1181
|
),
|
|
1096
1182
|
emailStart: (email) => request(
|
|
1097
1183
|
"/v1/auth/email/start",
|
|
1098
|
-
|
|
1184
|
+
z10.object({ challenge: z10.string() }),
|
|
1099
1185
|
json({ email })
|
|
1100
1186
|
),
|
|
1101
1187
|
emailVerify: (challenge, code) => changeSession(
|
|
@@ -1105,25 +1191,25 @@ function createRelayClient(options) {
|
|
|
1105
1191
|
json({ challenge, code })
|
|
1106
1192
|
)
|
|
1107
1193
|
),
|
|
1108
|
-
accounts: () => request("/v1/auth/accounts",
|
|
1194
|
+
accounts: () => request("/v1/auth/accounts", z10.array(accountConnectionSchema)),
|
|
1109
1195
|
disconnect: (provider) => request(
|
|
1110
1196
|
"/v1/auth/accounts/disconnect",
|
|
1111
|
-
|
|
1197
|
+
z10.object({ ok: z10.boolean() }),
|
|
1112
1198
|
json({ provider })
|
|
1113
1199
|
),
|
|
1114
1200
|
connections: () => request(
|
|
1115
1201
|
"/v1/auth/connections",
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
provider:
|
|
1119
|
-
subject:
|
|
1120
|
-
signInEnabled:
|
|
1202
|
+
z10.array(
|
|
1203
|
+
z10.object({
|
|
1204
|
+
provider: z10.string(),
|
|
1205
|
+
subject: z10.string(),
|
|
1206
|
+
signInEnabled: z10.boolean()
|
|
1121
1207
|
})
|
|
1122
1208
|
)
|
|
1123
1209
|
),
|
|
1124
1210
|
session: () => request("/v1/auth/session", sessionSchema.nullable()),
|
|
1125
1211
|
signOut: () => changeSession(
|
|
1126
|
-
() => request("/v1/auth/logout",
|
|
1212
|
+
() => request("/v1/auth/logout", z10.object({ ok: z10.boolean() }), json({}))
|
|
1127
1213
|
),
|
|
1128
1214
|
/** Local development only. Existing hosted apps use createParticipantBackend from /portal-proxy. */
|
|
1129
1215
|
exchange: (input) => request("/v1/auth/exchange", exchangeResultSchema, json(input))
|
|
@@ -1204,11 +1290,11 @@ function createRelayClient(options) {
|
|
|
1204
1290
|
/** @deprecated The participant API accepts only member sessions and rejects this staff call. Use the management API with a management key instead. */
|
|
1205
1291
|
lookupMember: (issuer, subject) => request(
|
|
1206
1292
|
"/v1/members/lookup",
|
|
1207
|
-
|
|
1293
|
+
z10.object({ member: z10.string() }),
|
|
1208
1294
|
json({ issuer, subject })
|
|
1209
1295
|
),
|
|
1210
1296
|
/** @deprecated Removed from the participant API. Build quests with `domino` and `@domino-sdk/relay/build`. */
|
|
1211
|
-
journeyTemplate: () => request("/v1/journey-template",
|
|
1297
|
+
journeyTemplate: () => request("/v1/journey-template", z10.array(templateSchema)),
|
|
1212
1298
|
/** @deprecated Removed from the participant API. Build quests with `domino` and `@domino-sdk/relay/build`. */
|
|
1213
1299
|
template: () => request("/v1/template", templateSchema),
|
|
1214
1300
|
/** @deprecated The participant API accepts only member sessions and rejects this staff call. Use the management API with a management key instead. */
|
|
@@ -1218,7 +1304,7 @@ function createRelayClient(options) {
|
|
|
1218
1304
|
/** @deprecated The participant API rejects publication. Publish with `domino deploy` or the management API. */
|
|
1219
1305
|
publishBatch: (releases) => request(
|
|
1220
1306
|
"/v1/releases/batch",
|
|
1221
|
-
|
|
1307
|
+
z10.array(publishedReleaseSchema),
|
|
1222
1308
|
json({ releases })
|
|
1223
1309
|
),
|
|
1224
1310
|
progress: (member) => request(
|
|
@@ -1297,5 +1383,10 @@ export {
|
|
|
1297
1383
|
identityIntegrationSchema,
|
|
1298
1384
|
identityIntegrationSecretSchema,
|
|
1299
1385
|
participantExchangeSchema,
|
|
1386
|
+
xIdSchema,
|
|
1387
|
+
xConnectionSchema,
|
|
1388
|
+
xProfileSchema,
|
|
1389
|
+
xPostSchema,
|
|
1390
|
+
xRequestSchema,
|
|
1300
1391
|
createRelayClient
|
|
1301
1392
|
};
|