@domino-sdk/relay 1.0.0-next.5 → 1.0.0-next.7

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.
Files changed (42) hide show
  1. package/README.md +13 -1
  2. package/build.mjs +18 -1
  3. package/dist/authoring.d.ts +322 -14
  4. package/dist/authoring.js +187 -25
  5. package/dist/avatar.d.ts +29 -0
  6. package/dist/avatar.js +21 -0
  7. package/dist/browser.d.ts +19 -3
  8. package/dist/browser.js +6 -6
  9. package/dist/catalog-C09gnPYT.d.ts +3948 -0
  10. package/dist/chunk-7HSTFBMO.js +24 -0
  11. package/dist/{chunk-VH4OQ5VX.js → chunk-ADSP377G.js} +1 -1
  12. package/dist/{chunk-FDWRBMB3.js → chunk-AWLLGCKU.js} +2 -2
  13. package/dist/chunk-DJZB5RY5.js +901 -0
  14. package/dist/chunk-SKETUPST.js +171 -0
  15. package/dist/chunk-UFXBQ6FN.js +257 -0
  16. package/dist/{chunk-NKGJEYZM.js → chunk-UW6R2QGT.js} +610 -719
  17. package/dist/chunk-V7UKZLHA.js +35 -0
  18. package/dist/{chunk-4KNTMNXA.js → chunk-X6FJIPXR.js} +166 -724
  19. package/dist/client-BufGakEt.d.ts +4577 -0
  20. package/dist/collection-BGneJ6Bk.d.ts +114 -0
  21. package/dist/images-e6FW9QSx.d.ts +234 -0
  22. package/dist/index.d.ts +11 -13115
  23. package/dist/index.js +11 -693
  24. package/dist/integrations-C3Sp558f.d.ts +1297 -0
  25. package/dist/internal.d.ts +109 -0
  26. package/dist/internal.js +104 -0
  27. package/dist/point-ledgers-iS00Z_v0.d.ts +37 -0
  28. package/dist/portal-proxy.js +5 -6
  29. package/dist/profiles-BtOXMGcC.d.ts +297 -0
  30. package/dist/react/index.d.ts +51 -34
  31. package/dist/react/index.js +7 -13
  32. package/dist/schema-DCapSPHz.d.ts +3396 -0
  33. package/dist/schema.d.ts +3194 -2366
  34. package/dist/schema.js +539 -3
  35. package/dist/streaks-CwGReWGt.d.ts +73 -0
  36. package/dist/submission-input-Bter6XiI.d.ts +2672 -0
  37. package/dist/units-CwgsPB_r.d.ts +9 -0
  38. package/dist/wallet-Bu6sqJvQ.d.ts +231 -0
  39. package/package.json +17 -4
  40. package/dist/chunk-B76BAJ25.js +0 -624
  41. package/dist/chunk-ONDBQSMU.js +0 -373
  42. package/dist/submission-input-CZDukyb3.d.ts +0 -4998
package/dist/authoring.js CHANGED
@@ -1,49 +1,203 @@
1
1
  import {
2
- authoringKey,
3
- defineEngagementReward,
4
- defineLeaderboard,
5
- defineReferral,
6
2
  formatUnits,
7
3
  parseUnits
8
- } from "./chunk-B76BAJ25.js";
4
+ } from "./chunk-V7UKZLHA.js";
9
5
  import {
10
- isEvmChainId
11
- } from "./chunk-ONDBQSMU.js";
6
+ authoringKey,
7
+ engagementDefinitionSchema,
8
+ engagementScoreInputSchema,
9
+ engagementScoreSchema,
10
+ isEvmChainId,
11
+ leaderboardAuthoringSchema,
12
+ referralAuthoringSchema
13
+ } from "./chunk-DJZB5RY5.js";
12
14
  import {
13
15
  admittedContentSchema,
14
16
  budgetSchema,
15
- content,
16
17
  contentPerformancePolicySchema,
17
18
  contentPerformanceSnapshotSchema,
18
- customSource,
19
+ contentPolicySchema,
20
+ customSourceSchema,
19
21
  decisionSchema,
20
22
  defaultTriggerMode,
21
- defineTracker,
22
- discord,
23
+ identifier,
23
24
  integrationRewardSchema,
24
25
  parseSettings,
25
- perContent,
26
- pointLedgers,
27
26
  pointsRewardSchema,
28
27
  questDescriptionSchema,
29
28
  quizAnswersSchema,
29
+ quizContentSchema,
30
+ resourceSourceSchema,
30
31
  rewardBundleSchema,
31
32
  settingFieldSchema,
32
- settings,
33
+ settingInstant,
34
+ settingResourceId,
33
35
  sourceIdentities,
34
- streak,
36
+ streakPolicySchema,
35
37
  textOptionsSchema,
36
38
  tierRewardSchema,
37
39
  tieredRewardDefinitionSchema,
40
+ trackerDefinitionSchema,
38
41
  trackerTriggerContextSchema,
39
42
  trackerTriggerPolicySchema,
40
43
  urlOptionsSchema,
41
- x,
42
- xAccountRoles
43
- } from "./chunk-NKGJEYZM.js";
44
+ xAccountRoles,
45
+ xSearchSourceSchema
46
+ } from "./chunk-UW6R2QGT.js";
44
47
 
45
- // src/authoring.ts
48
+ // src/builders.ts
46
49
  import { z } from "zod";
50
+ function content(tracker, policy = {}) {
51
+ if (tracker.source.kind !== "x-search") {
52
+ throw new Error("Content quests require an X tracker");
53
+ }
54
+ return {
55
+ kind: "automatic",
56
+ content: contentPolicySchema.parse({
57
+ tracker: tracker.key,
58
+ window: tracker.window,
59
+ ...policy
60
+ })
61
+ };
62
+ }
63
+ function perContent() {
64
+ return {
65
+ kind: "keyed",
66
+ perContent: true,
67
+ key: (ctx) => {
68
+ if (!ctx.content) {
69
+ throw new Error("perContent requires an admitted content item");
70
+ }
71
+ return ctx.content.completionKey;
72
+ }
73
+ };
74
+ }
75
+ function defineEngagementReward(input) {
76
+ const { target, ...config } = input;
77
+ const definition = engagementDefinitionSchema.parse({
78
+ ...config,
79
+ qualifiedBy: typeof input.qualifiedBy === "string" ? input.qualifiedBy : input.qualifiedBy.key
80
+ });
81
+ const selected = z.record(
82
+ z.enum(input.metrics),
83
+ engagementScoreSchema.shape.target
84
+ );
85
+ return {
86
+ key: definition.key,
87
+ describe: () => definition,
88
+ score(raw) {
89
+ const sample = engagementScoreInputSchema.parse(raw);
90
+ return engagementScoreSchema.parse({
91
+ target: target({ metrics: selected.parse(sample.metrics) }),
92
+ baseline: target({ metrics: selected.parse(sample.baseline) })
93
+ });
94
+ }
95
+ };
96
+ }
97
+ var streak = (options) => streakPolicySchema.parse({ kind: "streak", ...options });
98
+ function defineReferral(input) {
99
+ const definition = referralAuthoringSchema.parse(input);
100
+ return {
101
+ ...definition,
102
+ /** @deprecated Use key. */
103
+ id: definition.key
104
+ };
105
+ }
106
+ function defineLeaderboard(input) {
107
+ const definition = leaderboardAuthoringSchema.parse(input);
108
+ return {
109
+ ...definition,
110
+ /** @deprecated Use key. */
111
+ id: definition.key
112
+ };
113
+ }
114
+ var x = {
115
+ search: (input) => xSearchSourceSchema.parse({ kind: "x-search", ...input })
116
+ };
117
+ var customSource = (namespace, options = {}) => customSourceSchema.parse({
118
+ kind: "custom",
119
+ namespace,
120
+ ...options
121
+ });
122
+ function defineTracker(input) {
123
+ return trackerDefinitionSchema.parse(input);
124
+ }
125
+ var discord = {
126
+ roles(options = {}) {
127
+ return resourceSourceSchema.parse({
128
+ provider: "discord",
129
+ resource: "role",
130
+ assignable: options.assignable ?? false
131
+ });
132
+ },
133
+ channels(options = {}) {
134
+ return resourceSourceSchema.parse({
135
+ provider: "discord",
136
+ resource: "channel",
137
+ types: options.types ?? ["text", "announcement"]
138
+ });
139
+ }
140
+ };
141
+ var pointLedgers = () => ({
142
+ provider: "domino",
143
+ resource: "point-ledger"
144
+ });
145
+ var settings = {
146
+ pointLedger(options) {
147
+ const field = {
148
+ ...options,
149
+ kind: "point-ledger",
150
+ default: identifier.parse(options.default)
151
+ };
152
+ return identifier.default(field.default).meta(field);
153
+ },
154
+ datetime(options) {
155
+ const field = {
156
+ ...options,
157
+ kind: "datetime",
158
+ default: settingInstant.parse(options.default)
159
+ };
160
+ return settingInstant.default(field.default).meta(field);
161
+ },
162
+ resource(options) {
163
+ const field = {
164
+ ...options,
165
+ source: resourceSourceSchema.parse(options.source),
166
+ kind: "resource",
167
+ default: settingResourceId.parse(options.default ?? "")
168
+ };
169
+ return settingResourceId.default(field.default).meta(field);
170
+ },
171
+ quiz(options) {
172
+ const value = quizContentSchema.parse(options.default);
173
+ return quizContentSchema.default(value).meta({ ...options, default: value, kind: "quiz" });
174
+ },
175
+ text(options) {
176
+ const field = {
177
+ ...options,
178
+ kind: "text",
179
+ minLength: options.minLength ?? 1,
180
+ maxLength: options.maxLength ?? 2e3,
181
+ multiline: options.multiline ?? false
182
+ };
183
+ return z.string().min(field.minLength).max(field.maxLength).default(field.default).meta(field);
184
+ },
185
+ integer(options) {
186
+ return z.number().int().min(options.min).max(options.max).default(options.default).meta({ ...options, kind: "integer" });
187
+ },
188
+ boolean(options) {
189
+ return z.boolean().default(options.default).meta({ ...options, kind: "boolean" });
190
+ },
191
+ choice(options) {
192
+ return z.enum(options.options).default(options.default).meta({ ...options, kind: "choice" });
193
+ },
194
+ object(shape) {
195
+ return z.object(shape).strict();
196
+ }
197
+ };
198
+
199
+ // src/authoring.ts
200
+ import { z as z2 } from "zod";
47
201
  var points = (balance, amount) => pointsRewardSchema.parse({ kind: "points", balance, amount });
48
202
  var discordRole = (roleId) => integrationRewardSchema.parse({
49
203
  kind: "integration",
@@ -152,7 +306,7 @@ var evaluators = {
152
306
  quiz(answerKey, options = {}) {
153
307
  const expected = quizAnswersSchema.parse(answerKey);
154
308
  const questions = Object.keys(expected);
155
- const minimum = z.number().int().min(1).max(questions.length).parse(options.minimumCorrect ?? questions.length);
309
+ const minimum = z2.number().int().min(1).max(questions.length).parse(options.minimumCorrect ?? questions.length);
156
310
  return async ({ input }) => {
157
311
  const complete = Object.keys(input.answers).length === questions.length && questions.every((question) => Object.hasOwn(input.answers, question));
158
312
  const correct = questions.filter(
@@ -270,9 +424,9 @@ function defineQuest(definition) {
270
424
  throw new Error("Quest has no performance evaluator");
271
425
  }
272
426
  const sample = contentPerformanceSnapshotSchema.parse(ctx.performance);
273
- const metrics = z.record(
274
- z.enum(definition.performance.metrics),
275
- z.number().int().safe().nonnegative()
427
+ const metrics = z2.record(
428
+ z2.enum(definition.performance.metrics),
429
+ z2.number().int().safe().nonnegative()
276
430
  ).parse(sample.metrics);
277
431
  const result2 = await definition.performance.evaluate({
278
432
  settings: settings2,
@@ -298,7 +452,11 @@ function defineQuest(definition) {
298
452
  kind: "review",
299
453
  reason: result2.reason,
300
454
  rewards: sample.rewards
301
- } : { kind: "reject", reason: result2.reason }
455
+ } : {
456
+ kind: "reject",
457
+ reason: result2.reason,
458
+ ...result2.kind === "review" ? { requestedReview: true } : {}
459
+ }
302
460
  );
303
461
  }
304
462
  const result = definition.evaluate ? await definition.evaluate({
@@ -321,7 +479,11 @@ function defineQuest(definition) {
321
479
  throw new Error("Evaluator returned no decision");
322
480
  }
323
481
  if (result.kind === "review" && !ctx.humanReview) {
324
- return decisionSchema.parse({ kind: "reject", reason: result.reason });
482
+ return decisionSchema.parse({
483
+ kind: "reject",
484
+ reason: result.reason,
485
+ requestedReview: true
486
+ });
325
487
  }
326
488
  return decisionSchema.parse(
327
489
  result.kind === "accept" || result.kind === "review" ? {
@@ -0,0 +1,29 @@
1
+ import { L as LinkedWallet } from './wallet-Bu6sqJvQ.js';
2
+ import { P as ProfileAvatar } from './profiles-BtOXMGcC.js';
3
+ import 'zod';
4
+
5
+ /**
6
+ * The `<img src>` of a profile's avatar (`profile.avatar`). Pictures from accounts are hotlinked
7
+ * and can disappear: on the image's error event, fall back to `defaultAvatar(avatar.seed)`.
8
+ */
9
+ declare function avatarSrc(avatar: ProfileAvatar): string;
10
+ /**
11
+ * A deterministic SVG avatar for `seed`, as a data URI for an `<img src>`. The same seed always
12
+ * gives the same image.
13
+ *
14
+ * Seed avatars that other people see with a value that reveals nothing, such as the `avatarSeed`
15
+ * Relay returns (`relay.me.get()`), never with a wallet address: anyone could compute the avatar
16
+ * of every holder's address and match members to wallets. Use `walletAvatarSeed` only for a
17
+ * member's own wallets, in their own UI.
18
+ */
19
+ declare function defaultAvatar(seed: string): string;
20
+ /** `defaultAvatar` as raw SVG markup, for inlining during server rendering. */
21
+ declare function defaultAvatarSvg(seed: string): string;
22
+ /**
23
+ * The seed for a wallet shown to its own member, such as in their list of linked wallets. EVM and
24
+ * Cosmos addresses are case-folded, so a checksummed and a lowercase address give one image. Never
25
+ * use it on surfaces other people see (see `defaultAvatar`).
26
+ */
27
+ declare function walletAvatarSeed(wallet: Pick<LinkedWallet, "chain" | "address">): string;
28
+
29
+ export { avatarSrc, defaultAvatar, defaultAvatarSvg, walletAvatarSeed };
package/dist/avatar.js ADDED
@@ -0,0 +1,21 @@
1
+ // src/avatar.ts
2
+ import { createAvatar } from "@dicebear/core";
3
+ import * as shapes from "@dicebear/shapes";
4
+ function avatarSrc(avatar) {
5
+ return avatar.source === "generated" ? defaultAvatar(avatar.seed) : avatar.url;
6
+ }
7
+ function defaultAvatar(seed) {
8
+ return createAvatar(shapes, { seed }).toDataUri();
9
+ }
10
+ function defaultAvatarSvg(seed) {
11
+ return createAvatar(shapes, { seed }).toString();
12
+ }
13
+ function walletAvatarSeed(wallet) {
14
+ return `${wallet.chain}:${wallet.chain === "solana" ? wallet.address : wallet.address.toLowerCase()}`;
15
+ }
16
+ export {
17
+ avatarSrc,
18
+ defaultAvatar,
19
+ defaultAvatarSvg,
20
+ walletAvatarSeed
21
+ };
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { a8 as CosmosChain, a9 as CosmosNetwork, R as WalletSigner, a5 as WalletSignInNetwork, Z as AuthProvider, M as referralAcceptSchema, N as LeaderboardQuery, P as WalletAddressInput, Q as walletSignatureSchema, L as LinkedWallet, V as walletChallengeInputSchema, Y as walletProofSchema, _ as WalletSignature, $ as engagementPageQuerySchema, a0 as contentQualificationQuerySchema, a1 as contentAdmissionQuerySchema, a2 as contentEnrollmentInputSchema, a3 as contentReleaseInputSchema } from './submission-input-CZDukyb3.js';
2
- import { SubmitInput, ReleaseInput, beginHandoverSchema, contentPerformanceQuerySchema } from './schema.js';
3
- import { createRelayClient, SubmissionStore, ProfileUpdate, ProfileCompletionQuery, QuestView, QuestController, ProgressObservation, questExperienceSchema, ProgressObserver, ExchangeInput, PhotoSubmission, QuizSubmission, ClaimSubmission, ValueSubmission } from './index.js';
1
+ import { a as AuthProvider, i as referralAcceptSchema, d as LeaderboardQuery, j as engagementPageQuerySchema, k as contentQualificationQuerySchema, m as contentAdmissionQuerySchema, n as contentEnrollmentInputSchema, o as contentReleaseInputSchema } from './submission-input-Bter6XiI.js';
2
+ import { c as SubmitInput, g as ReleaseInput, h as beginHandoverSchema, i as contentPerformanceQuerySchema } from './schema-DCapSPHz.js';
3
+ import { h as createRelayClient, g as SubmissionStore, c as QuestController, a as ProgressObservation, b as ProgressObserver, P as PhotoSubmission, e as QuizSubmission, C as ClaimSubmission, V as ValueSubmission } from './client-BufGakEt.js';
4
+ import { b as QuestView, q as questExperienceSchema, E as ExchangeInput } from './catalog-C09gnPYT.js';
5
+ import { C as CosmosChain, a as CosmosNetwork, g as WalletSigner, e as WalletSignInNetwork, W as WalletAddressInput, w as walletSignatureSchema, L as LinkedWallet, l as walletChallengeInputSchema, m as walletProofSchema, f as WalletSignature } from './wallet-Bu6sqJvQ.js';
6
+ import { f as ProfileUpdate, c as ProfileCompletionQuery } from './profiles-BtOXMGcC.js';
4
7
  import * as zod from 'zod';
5
8
 
6
9
  /** An EIP-1193 provider, such as `window.ethereum` or an EIP-6963 announcement's provider. */
@@ -885,6 +888,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
885
888
  action: "grant-role";
886
889
  roleId: string;
887
890
  })[] | null;
891
+ requestedReview: boolean;
888
892
  createdAt: number;
889
893
  input?: {
890
894
  kind: "quiz";
@@ -995,6 +999,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
995
999
  action: "grant-role";
996
1000
  roleId: string;
997
1001
  })[] | null;
1002
+ requestedReview: boolean;
998
1003
  createdAt: number;
999
1004
  input?: {
1000
1005
  kind: "quiz";
@@ -1181,6 +1186,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
1181
1186
  action: "grant-role";
1182
1187
  roleId: string;
1183
1188
  })[] | null;
1189
+ requestedReview: boolean;
1184
1190
  createdAt: number;
1185
1191
  input?: {
1186
1192
  kind: "quiz";
@@ -1425,6 +1431,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
1425
1431
  action: "grant-role";
1426
1432
  roleId: string;
1427
1433
  })[] | null;
1434
+ requestedReview: boolean;
1428
1435
  createdAt: number;
1429
1436
  input?: {
1430
1437
  kind: "quiz";
@@ -1672,6 +1679,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
1672
1679
  action: "grant-role";
1673
1680
  roleId: string;
1674
1681
  })[] | null;
1682
+ requestedReview: boolean;
1675
1683
  createdAt: number;
1676
1684
  input?: {
1677
1685
  kind: "quiz";
@@ -2023,6 +2031,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
2023
2031
  action: "grant-role";
2024
2032
  roleId: string;
2025
2033
  })[] | null;
2034
+ requestedReview: boolean;
2026
2035
  createdAt: number;
2027
2036
  input?: {
2028
2037
  kind: "quiz";
@@ -2209,6 +2218,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
2209
2218
  action: "grant-role";
2210
2219
  roleId: string;
2211
2220
  })[] | null;
2221
+ requestedReview: boolean;
2212
2222
  createdAt: number;
2213
2223
  input?: {
2214
2224
  kind: "quiz";
@@ -2392,6 +2402,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
2392
2402
  action: "grant-role";
2393
2403
  roleId: string;
2394
2404
  })[] | null;
2405
+ requestedReview: boolean;
2395
2406
  createdAt: number;
2396
2407
  input?: {
2397
2408
  kind: "quiz";
@@ -3244,6 +3255,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
3244
3255
  action: "grant-role";
3245
3256
  roleId: string;
3246
3257
  })[] | null;
3258
+ requestedReview: boolean;
3247
3259
  createdAt: number;
3248
3260
  input?: {
3249
3261
  kind: "quiz";
@@ -3950,6 +3962,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
3950
3962
  action: "grant-role";
3951
3963
  roleId: string;
3952
3964
  })[] | null;
3965
+ requestedReview: boolean;
3953
3966
  createdAt: number;
3954
3967
  input?: {
3955
3968
  kind: "quiz";
@@ -4448,6 +4461,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
4448
4461
  action: "grant-role";
4449
4462
  roleId: string;
4450
4463
  })[] | null;
4464
+ requestedReview: boolean;
4451
4465
  createdAt: number;
4452
4466
  input?: {
4453
4467
  kind: "quiz";
@@ -4501,6 +4515,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
4501
4515
  action: "grant-role";
4502
4516
  roleId: string;
4503
4517
  })[] | null;
4518
+ requestedReview: boolean;
4504
4519
  createdAt: number;
4505
4520
  input?: {
4506
4521
  kind: "quiz";
@@ -4559,6 +4574,7 @@ declare function createBrowserRelayClient(options: Parameters<typeof createRelay
4559
4574
  action: "grant-role";
4560
4575
  roleId: string;
4561
4576
  })[] | null;
4577
+ requestedReview: boolean;
4562
4578
  createdAt: number;
4563
4579
  input?: {
4564
4580
  kind: "quiz";
package/dist/browser.js CHANGED
@@ -11,12 +11,12 @@ import {
11
11
  signInOptions,
12
12
  solanaSigner,
13
13
  walletStandardSolanaSigner
14
- } from "./chunk-FDWRBMB3.js";
15
- import "./chunk-4KNTMNXA.js";
16
- import "./chunk-B76BAJ25.js";
17
- import "./chunk-VH4OQ5VX.js";
18
- import "./chunk-ONDBQSMU.js";
19
- import "./chunk-NKGJEYZM.js";
14
+ } from "./chunk-AWLLGCKU.js";
15
+ import "./chunk-X6FJIPXR.js";
16
+ import "./chunk-UFXBQ6FN.js";
17
+ import "./chunk-DJZB5RY5.js";
18
+ import "./chunk-ADSP377G.js";
19
+ import "./chunk-UW6R2QGT.js";
20
20
  export {
21
21
  browserSubmissionStore,
22
22
  cosmosChainList,