@domino-sdk/relay 1.53.1 → 1.55.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/CHANGELOG.md +1848 -0
- package/dist/analytics-URV-mxjH.d.ts +482 -0
- package/dist/{attempt-captures-QC4kTA44.d.ts → attempt-captures-CxxO7DeD.d.ts} +1 -1
- package/dist/authoring.d.ts +233 -78
- package/dist/authoring.js +112 -14
- package/dist/{automatic-outcomes-CVyZHxir.d.ts → automatic-outcomes-DxW_v5Wc.d.ts} +5 -2
- package/dist/avatar.d.ts +1 -1
- package/dist/browser.d.ts +8 -7
- package/dist/browser.js +14 -10
- package/dist/{capability-error-FQGGb5xS.d.ts → capability-error-DSd8EMQC.d.ts} +76 -2
- package/dist/{chunk-53JMTUWG.js → chunk-56DBFNR2.js} +1 -1
- package/dist/chunk-C7QZ4UBB.js +937 -0
- package/dist/chunk-F6HECAXA.js +661 -0
- package/dist/{chunk-VKHSC5MD.js → chunk-GL43VQ5D.js} +16 -16
- package/dist/{chunk-GTQJSDBS.js → chunk-IUF7DW76.js} +27 -16
- package/dist/{chunk-YBR4BUFK.js → chunk-IZRITLVV.js} +2 -2
- package/dist/chunk-KDR2VAJP.js +34 -0
- package/dist/{chunk-S2PMKZSX.js → chunk-SABMNPF2.js} +21 -2
- package/dist/{chunk-XFAYQFRO.js → chunk-TLK2MD4S.js} +1 -1
- package/dist/{chunk-ZJ3FVZRP.js → chunk-UY6KMLQG.js} +10 -3
- package/dist/{chunk-JYJAS4E3.js → chunk-VFBQVY4X.js} +1 -1
- package/dist/{chunk-YVC3B72P.js → chunk-WHG5WE43.js} +1 -1
- package/dist/chunk-WHMXXHPX.js +344 -0
- package/dist/{chunk-MP2ZF5U6.js → chunk-WUEQOKJH.js} +4 -4
- package/dist/{chunk-7BNCLWAO.js → chunk-XALIFNMD.js} +1 -1
- package/dist/{chunk-IELNFM3V.js → chunk-YCOKTQ4E.js} +96 -7
- package/dist/{chunk-LPHXTZDA.js → chunk-YE3XYB2F.js} +2 -2
- package/dist/{chunk-K6TVMNU4.js → chunk-YEVD4A5X.js} +1 -1
- package/dist/{client-CzNtl8UO.d.ts → client-C4zUZKpj.d.ts} +35 -7
- package/dist/{deployments-ovtqtAcx.d.ts → deployments-B32QS1CI.d.ts} +1060 -233
- package/dist/{groups-B5R1RCsl.d.ts → groups-O6onGPmC.d.ts} +131 -137
- package/dist/host-environment-FN4zg3hw.d.ts +30 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -9
- package/dist/integrations-C6_uUh-s.d.ts +584 -0
- package/dist/internal.d.ts +12 -10
- package/dist/internal.js +14 -8
- package/dist/{offers-CH1RZekg.d.ts → offers-BMDNcvwB.d.ts} +2 -2
- package/dist/{pages-BTlOg8sl.d.ts → pages-BFloMpyQ.d.ts} +25 -1
- package/dist/portal-proxy.d.ts +11 -1
- package/dist/portal-proxy.js +26 -5
- package/dist/{profiles-Cdv4BSd_.d.ts → profiles-BoOK03cR.d.ts} +2 -0
- package/dist/react/index.d.ts +488 -13
- package/dist/react/index.js +51 -15
- package/dist/runtime/authoring.js +1 -1
- package/dist/runtime/chunks/WKATKZXE.js +1 -0
- package/dist/runtime/manifest.json +3 -3
- package/dist/runtime/schema.js +1 -1
- package/dist/{schema-BJ9bOgpN.d.ts → schema-C4m9RhCR.d.ts} +166 -6
- package/dist/schema.d.ts +392 -334
- package/dist/schema.js +84 -40
- package/dist/server/index.d.ts +11 -10
- package/dist/server/index.js +1604 -838
- package/dist/{submission-input-BNah53go.d.ts → submission-input-BbdawqVy.d.ts} +2 -2
- package/dist/{telegram-browser-C36j_6v-.d.ts → telegram-browser-CwaxROAZ.d.ts} +1 -1
- package/dist/testing.d.ts +85 -12
- package/dist/testing.js +322 -37
- package/dist/{transport-DuB_fiA2.d.ts → transport-CZJOW5Sr.d.ts} +8018 -3150
- package/dist/vite.d.ts +54 -1
- package/dist/vite.js +35 -0
- package/dist/{x-BfQcsDp0.d.ts → x-1czZFVUW.d.ts} +1 -1
- package/package.json +3 -2
- package/dist/chunk-2NUD237O.js +0 -102
- package/dist/chunk-CCE2JWES.js +0 -1083
- package/dist/integrations-CllF-kWg.d.ts +0 -314
- package/dist/runtime/chunks/AVRVSLHX.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayAction,
|
|
3
3
|
withActionId
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WHG5WE43.js";
|
|
5
5
|
import {
|
|
6
6
|
collectionPassSchema,
|
|
7
7
|
participantActivityQuerySchema,
|
|
@@ -17,10 +17,8 @@ import {
|
|
|
17
17
|
questOutcomeSchema,
|
|
18
18
|
rewardDeliveriesSchema,
|
|
19
19
|
rewardDeliveryQuerySchema
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-UY6KMLQG.js";
|
|
21
21
|
import {
|
|
22
|
-
AVATAR_UPLOAD_LIMIT,
|
|
23
|
-
avatarUploadTypes,
|
|
24
22
|
badgeSchema,
|
|
25
23
|
engagementBoundaryPageSchema,
|
|
26
24
|
engagementPageQuerySchema,
|
|
@@ -33,6 +31,15 @@ import {
|
|
|
33
31
|
leaderboardQuerySchema,
|
|
34
32
|
memberBadgesSchema,
|
|
35
33
|
offerSchema,
|
|
34
|
+
redemptionSchema,
|
|
35
|
+
referralAcceptSchema,
|
|
36
|
+
referralDefinitionSchema,
|
|
37
|
+
referralHistorySchema,
|
|
38
|
+
referralSummarySchema
|
|
39
|
+
} from "./chunk-C7QZ4UBB.js";
|
|
40
|
+
import {
|
|
41
|
+
AVATAR_UPLOAD_LIMIT,
|
|
42
|
+
avatarUploadTypes,
|
|
36
43
|
ownProfileSchema,
|
|
37
44
|
pointBalancesSchema,
|
|
38
45
|
pointHistoryPageSchema,
|
|
@@ -43,34 +50,27 @@ import {
|
|
|
43
50
|
profileReferralSchema,
|
|
44
51
|
profileSummarySchema,
|
|
45
52
|
profileUpdateSchema,
|
|
46
|
-
redemptionSchema,
|
|
47
|
-
referralAcceptSchema,
|
|
48
|
-
referralDefinitionSchema,
|
|
49
|
-
referralHistorySchema,
|
|
50
|
-
referralSummarySchema
|
|
51
|
-
} from "./chunk-CCE2JWES.js";
|
|
52
|
-
import {
|
|
53
53
|
telegramAccountConnectionSchema,
|
|
54
54
|
telegramMiniAppSignInSchema,
|
|
55
55
|
telegramSignInMethodsSchema
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-WHMXXHPX.js";
|
|
57
57
|
import {
|
|
58
58
|
PARTICIPANT_TIMEOUT,
|
|
59
59
|
lifetime,
|
|
60
60
|
retryAfter,
|
|
61
61
|
retrying,
|
|
62
62
|
validTimeout
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-TLK2MD4S.js";
|
|
64
64
|
import {
|
|
65
65
|
clientIdentity
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-VFBQVY4X.js";
|
|
67
67
|
import {
|
|
68
68
|
exchangeResultSchema,
|
|
69
69
|
exchangeSchema,
|
|
70
70
|
memberSummarySchema,
|
|
71
71
|
participantSessionSchema,
|
|
72
72
|
sessionMember
|
|
73
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-56DBFNR2.js";
|
|
74
74
|
import {
|
|
75
75
|
RelayError,
|
|
76
76
|
RelayErrorCode,
|
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
walletSignInNetworksSchema,
|
|
110
110
|
walletSignatureSchema,
|
|
111
111
|
walletUnlinkInputSchema
|
|
112
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-YCOKTQ4E.js";
|
|
113
113
|
|
|
114
114
|
// src/legacy-submissions.ts
|
|
115
115
|
import * as z from "zod";
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dashboardArtifactSchema,
|
|
3
|
+
dashboardPreviewSchema
|
|
4
|
+
} from "./chunk-F6HECAXA.js";
|
|
1
5
|
import {
|
|
2
6
|
imageAssetArtifactSchema,
|
|
3
7
|
imageComparisonSchema,
|
|
@@ -6,7 +10,7 @@ import {
|
|
|
6
10
|
imageSightingsSchema,
|
|
7
11
|
imageUploadsSchema,
|
|
8
12
|
publishedImageSchema
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-YEVD4A5X.js";
|
|
10
14
|
import {
|
|
11
15
|
catalogDeploymentSchema,
|
|
12
16
|
collectionPassSchema,
|
|
@@ -24,7 +28,7 @@ import {
|
|
|
24
28
|
questTypeVersionSchema,
|
|
25
29
|
questViewSchema,
|
|
26
30
|
rewardDeliveriesSchema
|
|
27
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-UY6KMLQG.js";
|
|
28
32
|
import {
|
|
29
33
|
badgeArtifactSchema,
|
|
30
34
|
badgeSchema,
|
|
@@ -43,6 +47,14 @@ import {
|
|
|
43
47
|
offerArtifactSchema,
|
|
44
48
|
offerDefinitionSchema,
|
|
45
49
|
offerSchema,
|
|
50
|
+
publishedReferralSchema,
|
|
51
|
+
redemptionSchema,
|
|
52
|
+
referralArtifactSchema,
|
|
53
|
+
referralDefinitionSchema,
|
|
54
|
+
referralHistorySchema,
|
|
55
|
+
referralSummarySchema
|
|
56
|
+
} from "./chunk-C7QZ4UBB.js";
|
|
57
|
+
import {
|
|
46
58
|
ownProfileSchema,
|
|
47
59
|
pointBalancesSchema,
|
|
48
60
|
pointHistoryPageSchema,
|
|
@@ -52,21 +64,13 @@ import {
|
|
|
52
64
|
profileCompletionPageSchema,
|
|
53
65
|
profileReferralSchema,
|
|
54
66
|
profileSummarySchema,
|
|
55
|
-
publishedReferralSchema,
|
|
56
|
-
redemptionSchema,
|
|
57
|
-
referralArtifactSchema,
|
|
58
|
-
referralDefinitionSchema,
|
|
59
|
-
referralHistorySchema,
|
|
60
|
-
referralSummarySchema
|
|
61
|
-
} from "./chunk-CCE2JWES.js";
|
|
62
|
-
import {
|
|
63
67
|
telegramAccountConnectionSchema
|
|
64
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-WHMXXHPX.js";
|
|
65
69
|
import {
|
|
66
70
|
exchangeResultSchema,
|
|
67
71
|
memberSummarySchema,
|
|
68
72
|
participantSessionSchema
|
|
69
|
-
} from "./chunk-
|
|
73
|
+
} from "./chunk-56DBFNR2.js";
|
|
70
74
|
import {
|
|
71
75
|
accountConnectionSchema,
|
|
72
76
|
attemptSchema,
|
|
@@ -99,7 +103,7 @@ import {
|
|
|
99
103
|
walletBalanceSchema,
|
|
100
104
|
walletMessageChallengeSchema,
|
|
101
105
|
walletSignInNetworksSchema
|
|
102
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-YCOKTQ4E.js";
|
|
103
107
|
|
|
104
108
|
// src/deployments.ts
|
|
105
109
|
import * as z from "zod";
|
|
@@ -112,6 +116,8 @@ var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevisi
|
|
|
112
116
|
referrals: z.array(referralArtifactSchema).max(50).default([]),
|
|
113
117
|
leaderboards: z.array(leaderboardArtifactSchema).max(50).default([]),
|
|
114
118
|
images: z.array(imageAssetArtifactSchema).max(10).default([]),
|
|
119
|
+
// A generous bound: the deployment answers too-many-dashboards past dashboardLimits.dashboards.
|
|
120
|
+
dashboards: z.array(dashboardArtifactSchema).max(100).default([]),
|
|
115
121
|
/** relay.json `calendar`: the project timezone. Omitted, the deployment leaves it unchanged. */
|
|
116
122
|
calendar: projectCalendarDeclarationSchema.optional(),
|
|
117
123
|
/**
|
|
@@ -123,8 +129,8 @@ var projectCatalogArtifactSchema = catalogDeploymentSchema.omit({ expectedRevisi
|
|
|
123
129
|
var projectDeploymentSchema = projectCatalogArtifactSchema.extend({
|
|
124
130
|
releases: z.array(releaseSchema).max(questScaleLimits.quests).default([])
|
|
125
131
|
}).refine(
|
|
126
|
-
(value) => value.engagement.length > 0 || value.trackers.length > 0 || value.pointLedgers.length > 0 || value.badges.length > 0 || value.offers.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,
|
|
127
|
-
"No resources configured. Add engagement, trackers, quests, questTypes, badges, pointLedgers, offers, leaderboards, referrals, images, collections, supportedInteractions, or calendar to relay.json."
|
|
132
|
+
(value) => value.engagement.length > 0 || value.trackers.length > 0 || value.pointLedgers.length > 0 || value.badges.length > 0 || value.offers.length > 0 || value.releases.length > 0 || value.leaderboards.length > 0 || value.referrals.length > 0 || value.images.length > 0 || value.dashboards.length > 0 || value.types.length > 0 || value.collections.length > 0 || value.supportedInteractions !== void 0 || value.calendar !== void 0,
|
|
133
|
+
"No resources configured. Add engagement, trackers, quests, questTypes, badges, pointLedgers, offers, leaderboards, referrals, images, dashboards, collections, supportedInteractions, or calendar to relay.json."
|
|
128
134
|
);
|
|
129
135
|
var deploymentWarningSchema = z.object({
|
|
130
136
|
code: z.string(),
|
|
@@ -147,6 +153,11 @@ var deploymentPreviewSchema = z.object({
|
|
|
147
153
|
referrals: z.array(publishedReferralSchema).default([]),
|
|
148
154
|
leaderboards: z.array(leaderboardPreviewSchema).default([]),
|
|
149
155
|
images: z.array(publishedImageSchema).default([]),
|
|
156
|
+
/**
|
|
157
|
+
* The deployment's dashboards; `change` says whether each publishes a new version. Relay sends an
|
|
158
|
+
* empty list when there is none; optional so values built for older SDKs still fit.
|
|
159
|
+
*/
|
|
160
|
+
dashboards: z.array(dashboardPreviewSchema).optional(),
|
|
150
161
|
/**
|
|
151
162
|
* The project timezone change this deployment makes, or null for none. A declared timezone
|
|
152
163
|
* applies only when relay.json changes it, so a change made in Console stays until relay.json
|
|
@@ -351,7 +362,7 @@ var automaticOutcomeSchema = z3.union([
|
|
|
351
362
|
automaticOutcomeWithoutAttemptSchema,
|
|
352
363
|
automaticOutcomeWithAttemptSchema
|
|
353
364
|
]);
|
|
354
|
-
var isRetryableAutomaticOutcome = (outcome) => outcome.linkedAttempt?.status === "rejected" && outcome.linkedAttempt.code === "budget-exhausted";
|
|
365
|
+
var isRetryableAutomaticOutcome = (outcome) => outcome.linkedAttempt?.status === "rejected" && outcome.linkedAttempt.code === "budget-exhausted" || outcome.linkedAttempt?.status === "failed" && outcome.linkedAttempt.code === "integration-required";
|
|
355
366
|
var automaticOutcomeQuerySchema = z3.strictObject({
|
|
356
367
|
quest: identifier.optional(),
|
|
357
368
|
member: identifier.optional(),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createRelayClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GL43VQ5D.js";
|
|
4
4
|
import {
|
|
5
5
|
RelayErrorCode,
|
|
6
6
|
asRelayError,
|
|
7
7
|
clientError,
|
|
8
8
|
cosmosChain
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YCOKTQ4E.js";
|
|
10
10
|
|
|
11
11
|
// src/base58.ts
|
|
12
12
|
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/host-environment.ts
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
var hostEnvironmentPath = "/__domino/environment";
|
|
4
|
+
var hostEnvironmentSchema = z.object({
|
|
5
|
+
environment: z.enum(["test", "live"]),
|
|
6
|
+
kind: z.enum(["staging", "preview", "live"])
|
|
7
|
+
});
|
|
8
|
+
var pending;
|
|
9
|
+
async function readHostEnvironment() {
|
|
10
|
+
try {
|
|
11
|
+
const response = await fetch(hostEnvironmentPath, {
|
|
12
|
+
headers: { Accept: "application/json" }
|
|
13
|
+
});
|
|
14
|
+
if (response.status !== 200) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const parsed = hostEnvironmentSchema.safeParse(await response.json());
|
|
18
|
+
return parsed.success ? parsed.data : null;
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getHostEnvironment() {
|
|
24
|
+
if (!globalThis.location) {
|
|
25
|
+
return Promise.resolve(null);
|
|
26
|
+
}
|
|
27
|
+
return pending ??= readHostEnvironment();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
hostEnvironmentPath,
|
|
32
|
+
hostEnvironmentSchema,
|
|
33
|
+
getHostEnvironment
|
|
34
|
+
};
|
|
@@ -5,11 +5,18 @@ import {
|
|
|
5
5
|
isKnownTrackerSource,
|
|
6
6
|
trackerDataSchema,
|
|
7
7
|
xAccountRoles
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YCOKTQ4E.js";
|
|
9
9
|
|
|
10
10
|
// src/quest-shape.ts
|
|
11
11
|
function validateQuestShape(description, options = {}) {
|
|
12
|
-
const {
|
|
12
|
+
const {
|
|
13
|
+
trigger,
|
|
14
|
+
completion,
|
|
15
|
+
requires,
|
|
16
|
+
performance,
|
|
17
|
+
retryCooldownMs,
|
|
18
|
+
completionCooldownMs
|
|
19
|
+
} = description;
|
|
13
20
|
const tracker = trigger.kind === "automatic" ? trigger.tracker : void 0;
|
|
14
21
|
const content = tracker?.content === true;
|
|
15
22
|
if (performance && !content) {
|
|
@@ -30,6 +37,18 @@ function validateQuestShape(description, options = {}) {
|
|
|
30
37
|
"A retry cooldown applies only to quests members submit themselves"
|
|
31
38
|
);
|
|
32
39
|
}
|
|
40
|
+
if (completionCooldownMs !== void 0) {
|
|
41
|
+
if (trigger.kind !== "manual" || trigger.actor === "staff") {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"A completion cooldown applies only to quests members submit themselves"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (completion.kind === "once") {
|
|
47
|
+
throw new Error(
|
|
48
|
+
"A completion cooldown needs a quest members can complete more than once: this one completes once per member"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
33
52
|
if (trigger.kind === "automatic" && !tracker) {
|
|
34
53
|
if (!options.template && requires.length === 0) {
|
|
35
54
|
throw new Error("Automatic quests need at least one prerequisite");
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
badgeSchema
|
|
2
|
+
badgeSchema
|
|
3
|
+
} from "./chunk-C7QZ4UBB.js";
|
|
4
|
+
import {
|
|
3
5
|
pointLedgerReferenceSchema
|
|
4
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WHMXXHPX.js";
|
|
5
7
|
import {
|
|
6
8
|
authoringIdentityShape,
|
|
7
9
|
entitlementSchema,
|
|
@@ -23,7 +25,7 @@ import {
|
|
|
23
25
|
storedQuestDescriptionSchema,
|
|
24
26
|
storedReviewModeSchema,
|
|
25
27
|
tieredRewardReferenceSchema
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-YCOKTQ4E.js";
|
|
27
29
|
|
|
28
30
|
// src/participant-activity.ts
|
|
29
31
|
import * as z from "zod";
|
|
@@ -166,6 +168,11 @@ var questInstanceSchema = z2.object({
|
|
|
166
168
|
* no cooldown. Omitted: the quest type's own `retryCooldownMs`.
|
|
167
169
|
*/
|
|
168
170
|
retryCooldownMs: retryCooldownMsSchema.nullable().optional(),
|
|
171
|
+
/**
|
|
172
|
+
* Milliseconds a member waits after an accepted completion before submitting again, or `null`
|
|
173
|
+
* for no cooldown. Omitted: the quest type's own `completionCooldownMs`.
|
|
174
|
+
*/
|
|
175
|
+
completionCooldownMs: retryCooldownMsSchema.nullable().optional(),
|
|
169
176
|
status: z2.enum(["active", "paused", "archived"])
|
|
170
177
|
}).strict();
|
|
171
178
|
var questDraftChangesSchema = z2.object({
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import {
|
|
2
|
+
accountConnectionSchema,
|
|
3
|
+
identifier,
|
|
4
|
+
pageCursorSchema
|
|
5
|
+
} from "./chunk-YCOKTQ4E.js";
|
|
6
|
+
|
|
7
|
+
// src/point-ledgers.ts
|
|
8
|
+
import * as z from "zod";
|
|
9
|
+
var pointLedgerPropertiesSchema = z.object({
|
|
10
|
+
name: z.string().trim().min(1).max(120),
|
|
11
|
+
description: z.string().trim().max(1e3).default("")
|
|
12
|
+
}).strict();
|
|
13
|
+
var createPointLedgerSchema = pointLedgerPropertiesSchema.extend({ actionId: identifier, key: identifier.optional() }).strict();
|
|
14
|
+
var pointLedgerSchema = pointLedgerPropertiesSchema.extend({
|
|
15
|
+
id: identifier
|
|
16
|
+
});
|
|
17
|
+
var managedPointLedgerSchema = pointLedgerSchema.extend({
|
|
18
|
+
archivedAt: z.number().int().nonnegative().nullable()
|
|
19
|
+
});
|
|
20
|
+
var pointLedgerDeclarationSchema = pointLedgerPropertiesSchema.extend({ key: identifier }).strict();
|
|
21
|
+
var pointLedgerArtifactSchema = z.union([
|
|
22
|
+
pointLedgerDeclarationSchema,
|
|
23
|
+
z.object({ code: z.string().min(1).max(2e6) }).strict()
|
|
24
|
+
]);
|
|
25
|
+
var pointLedgerReferenceSchema = z.object({
|
|
26
|
+
id: identifier,
|
|
27
|
+
key: identifier.nullable(),
|
|
28
|
+
name: z.string()
|
|
29
|
+
});
|
|
30
|
+
var points = z.number().int().safe();
|
|
31
|
+
var pointBalanceSchema = z.object({
|
|
32
|
+
ledger: pointLedgerReferenceSchema,
|
|
33
|
+
balance: points,
|
|
34
|
+
available: points
|
|
35
|
+
});
|
|
36
|
+
var pointBalancesSchema = z.object({
|
|
37
|
+
items: z.array(pointBalanceSchema)
|
|
38
|
+
});
|
|
39
|
+
var PointEntryKind = {
|
|
40
|
+
/** Points a quest completion, an engagement settlement or an operator awarded. */
|
|
41
|
+
Award: "award",
|
|
42
|
+
/** Points the member spent. */
|
|
43
|
+
Spend: "spend",
|
|
44
|
+
/** A correction in either direction, by an operator or a referral payout. */
|
|
45
|
+
Adjust: "adjust",
|
|
46
|
+
/** Undoes part or all of an award or a positive adjustment (`reverses`). */
|
|
47
|
+
Reverse: "reverse"
|
|
48
|
+
};
|
|
49
|
+
var pointEntryKindSchema = z.string().min(1).max(64);
|
|
50
|
+
var pointEntrySchema = z.object({
|
|
51
|
+
id: identifier,
|
|
52
|
+
amount: points,
|
|
53
|
+
kind: pointEntryKindSchema,
|
|
54
|
+
/** When the entry took effect, in epoch milliseconds. A reversal keeps its source's. */
|
|
55
|
+
at: points.nonnegative(),
|
|
56
|
+
quest: identifier.nullable(),
|
|
57
|
+
reverses: identifier.nullable(),
|
|
58
|
+
/**
|
|
59
|
+
* True for an opening balance a member import recorded (an `adjust`). Absent from Relay
|
|
60
|
+
* versions without imports.
|
|
61
|
+
*/
|
|
62
|
+
imported: z.boolean().optional()
|
|
63
|
+
});
|
|
64
|
+
var pointHistoryQuerySchema = z.strictObject({
|
|
65
|
+
ledger: identifier,
|
|
66
|
+
cursor: pageCursorSchema.optional()
|
|
67
|
+
});
|
|
68
|
+
var pointHistoryPageSchema = z.object({
|
|
69
|
+
items: z.array(pointEntrySchema),
|
|
70
|
+
nextCursor: pageCursorSchema.nullable()
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// src/telegram.ts
|
|
74
|
+
import * as z2 from "zod";
|
|
75
|
+
var telegramSignInMethodsSchema = z2.object({
|
|
76
|
+
/** Telegram Login, the OpenID Connect sign-in Domino configures for the platform. */
|
|
77
|
+
login: z2.boolean(),
|
|
78
|
+
/** Mini App sign-in, which the project enables in Console with its bot's ID. */
|
|
79
|
+
miniApp: z2.boolean()
|
|
80
|
+
});
|
|
81
|
+
var telegramAccountConnectionSchema = accountConnectionSchema.extend({
|
|
82
|
+
provider: z2.literal("telegram")
|
|
83
|
+
});
|
|
84
|
+
var telegramInitDataSchema = z2.string().min(1, "Pass the Mini App's Telegram.WebApp.initData").max(8192);
|
|
85
|
+
var telegramMiniAppSignInSchema = z2.object({
|
|
86
|
+
initData: telegramInitDataSchema,
|
|
87
|
+
mode: z2.enum(["sign-in", "connect"])
|
|
88
|
+
}).strict();
|
|
89
|
+
var telegramChatIdSchema = z2.string().regex(
|
|
90
|
+
/^-?[1-9][0-9]{0,19}$/,
|
|
91
|
+
"Use the chat's numeric ID, such as -1001234567890"
|
|
92
|
+
);
|
|
93
|
+
var telegramChatSchema = z2.object({
|
|
94
|
+
/** The numeric chat ID, as a string. */
|
|
95
|
+
id: telegramChatIdSchema,
|
|
96
|
+
/** `group`, `supergroup` or `channel`; a later Telegram may add others. */
|
|
97
|
+
type: z2.string(),
|
|
98
|
+
title: z2.string(),
|
|
99
|
+
/** The public @username, without the @, or null for a private chat. */
|
|
100
|
+
username: z2.string().nullable(),
|
|
101
|
+
status: z2.string(),
|
|
102
|
+
issue: z2.string().nullable(),
|
|
103
|
+
connectedAt: z2.number()
|
|
104
|
+
});
|
|
105
|
+
var telegramChatsSchema = z2.object({
|
|
106
|
+
configured: z2.boolean(),
|
|
107
|
+
/** Domino's bot, the one operators add to their chats. */
|
|
108
|
+
bot: z2.object({ username: z2.string() }).nullable(),
|
|
109
|
+
chats: z2.array(telegramChatSchema)
|
|
110
|
+
});
|
|
111
|
+
var telegramChatConnectionSchema = z2.object({
|
|
112
|
+
url: z2.string(),
|
|
113
|
+
expiresAt: z2.number()
|
|
114
|
+
});
|
|
115
|
+
var telegramMemberInputSchema = z2.object({
|
|
116
|
+
chat: z2.string().regex(
|
|
117
|
+
/^(-?[1-9][0-9]{0,19}|@[A-Za-z][A-Za-z0-9_]{3,31})$/,
|
|
118
|
+
"Name a chat the project connected, by its numeric ID or @username"
|
|
119
|
+
)
|
|
120
|
+
}).strict();
|
|
121
|
+
var telegramChatMemberSchema = z2.object({
|
|
122
|
+
/** The numeric Telegram user ID. */
|
|
123
|
+
userId: z2.string(),
|
|
124
|
+
username: z2.string().nullable(),
|
|
125
|
+
status: z2.custom(
|
|
126
|
+
(value) => typeof value === "string"
|
|
127
|
+
),
|
|
128
|
+
/** Whether they are in the chat now: a creator, administrator, member, or restricted member. */
|
|
129
|
+
isMember: z2.boolean(),
|
|
130
|
+
/** Whether they are its creator or an administrator. */
|
|
131
|
+
isAdmin: z2.boolean(),
|
|
132
|
+
/** When a paid subscription or a restriction ends, epoch milliseconds; null when it does not. */
|
|
133
|
+
untilDate: z2.number().nullable()
|
|
134
|
+
});
|
|
135
|
+
var telegramReactionsNamespace = "telegram-reactions";
|
|
136
|
+
var telegramReactionDataSchema = z2.object({
|
|
137
|
+
/** The chat's numeric ID, as a string. */
|
|
138
|
+
chatId: z2.string(),
|
|
139
|
+
/** `group` or `supergroup`: channel reactions are anonymous and never recorded. */
|
|
140
|
+
chatType: z2.string(),
|
|
141
|
+
messageId: z2.number(),
|
|
142
|
+
/** `emoji`, `custom_emoji` or `paid`. */
|
|
143
|
+
reactionType: z2.string(),
|
|
144
|
+
/** The emoji, such as "❤", for an `emoji` reaction; null otherwise. */
|
|
145
|
+
emoji: z2.string().nullable(),
|
|
146
|
+
/** The custom emoji's ID for a `custom_emoji` reaction; null otherwise. */
|
|
147
|
+
customEmojiId: z2.string().nullable(),
|
|
148
|
+
/**
|
|
149
|
+
* `creator` or `administrator` for one of the chat's administrators, read at most ten minutes
|
|
150
|
+
* before Relay recorded the reaction; `member` for anyone else.
|
|
151
|
+
*/
|
|
152
|
+
reactorStatus: z2.string(),
|
|
153
|
+
/** Whether the reactor was the chat's creator or an administrator then. */
|
|
154
|
+
reactorIsAdmin: z2.boolean()
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// src/profiles.ts
|
|
158
|
+
import * as z3 from "zod";
|
|
159
|
+
var count = z3.number().int().nonnegative().safe();
|
|
160
|
+
var profileVisibilitySchema = z3.enum([
|
|
161
|
+
"private",
|
|
162
|
+
"participants",
|
|
163
|
+
"public"
|
|
164
|
+
]);
|
|
165
|
+
var avatarProviderSchema = z3.enum(["x", "discord", "google"]);
|
|
166
|
+
var profileDefaultProviderSchema = z3.enum(["x", "discord"]);
|
|
167
|
+
var profileDefaultsSchema = z3.array(profileDefaultProviderSchema).max(profileDefaultProviderSchema.options.length).refine(
|
|
168
|
+
(providers) => new Set(providers).size === providers.length,
|
|
169
|
+
"List each provider once"
|
|
170
|
+
);
|
|
171
|
+
var avatarSeedSchema = z3.string().min(1).max(100);
|
|
172
|
+
var profileAvatarSchema = z3.discriminatedUnion("source", [
|
|
173
|
+
z3.object({
|
|
174
|
+
source: z3.literal("upload"),
|
|
175
|
+
url: z3.string().url(),
|
|
176
|
+
seed: avatarSeedSchema
|
|
177
|
+
}),
|
|
178
|
+
z3.object({
|
|
179
|
+
source: z3.literal("account"),
|
|
180
|
+
provider: avatarProviderSchema,
|
|
181
|
+
url: z3.string().url(),
|
|
182
|
+
seed: avatarSeedSchema
|
|
183
|
+
}),
|
|
184
|
+
z3.object({ source: z3.literal("generated"), seed: avatarSeedSchema })
|
|
185
|
+
]);
|
|
186
|
+
var profileSummarySchema = z3.object({
|
|
187
|
+
id: identifier,
|
|
188
|
+
name: z3.string(),
|
|
189
|
+
avatar: profileAvatarSchema
|
|
190
|
+
});
|
|
191
|
+
var invisible = /[\p{Cc}----]/u;
|
|
192
|
+
var displayNameSchema = z3.string().max(200).transform((value) => value.normalize("NFC").replace(/\s+/g, " ").trim()).pipe(
|
|
193
|
+
z3.string().min(1, "Enter a name").max(40, "Use at most 40 characters").refine((value) => !invisible.test(value), "Use visible characters only")
|
|
194
|
+
);
|
|
195
|
+
var profileUpdateSchema = z3.object({
|
|
196
|
+
displayName: displayNameSchema.nullable().optional(),
|
|
197
|
+
avatar: z3.discriminatedUnion("source", [
|
|
198
|
+
z3.object({
|
|
199
|
+
source: z3.literal("account"),
|
|
200
|
+
provider: avatarProviderSchema
|
|
201
|
+
}).strict(),
|
|
202
|
+
z3.object({ source: z3.literal("generated") }).strict()
|
|
203
|
+
]).nullable().optional(),
|
|
204
|
+
hidden: z3.boolean().optional()
|
|
205
|
+
}).strict().refine(
|
|
206
|
+
(value) => Object.values(value).some((field) => field !== void 0),
|
|
207
|
+
"Change at least one field"
|
|
208
|
+
);
|
|
209
|
+
var ownProfileSchema = profileSummarySchema.extend({
|
|
210
|
+
/** The name the member chose, or null for the default. */
|
|
211
|
+
displayName: z3.string().nullable(),
|
|
212
|
+
/** The avatar the member chose: `default` follows the project's defaults. */
|
|
213
|
+
avatarChoice: z3.enum(["default", "upload", "account", "generated"]),
|
|
214
|
+
/** The account of an `account` choice. */
|
|
215
|
+
avatarProvider: avatarProviderSchema.nullable(),
|
|
216
|
+
hidden: z3.boolean(),
|
|
217
|
+
/** An operator locked the name and avatar; the member can still hide the profile. */
|
|
218
|
+
locked: z3.boolean(),
|
|
219
|
+
/** Who can see profiles in this project, so the app can explain it. */
|
|
220
|
+
visibility: profileVisibilitySchema,
|
|
221
|
+
/** The member's connected accounts a picture or name can come from. */
|
|
222
|
+
options: z3.array(
|
|
223
|
+
z3.object({
|
|
224
|
+
provider: avatarProviderSchema,
|
|
225
|
+
name: z3.string().nullable(),
|
|
226
|
+
/**
|
|
227
|
+
* The account's first name, where the provider sends one (Google does; X and Discord don't).
|
|
228
|
+
* Only the member's own profile carries it.
|
|
229
|
+
*/
|
|
230
|
+
givenName: z3.string().nullable().default(null),
|
|
231
|
+
imageUrl: z3.string().url().nullable()
|
|
232
|
+
})
|
|
233
|
+
)
|
|
234
|
+
});
|
|
235
|
+
var cursor = z3.string().min(1).max(512);
|
|
236
|
+
var profileCompletionQuerySchema = z3.object({
|
|
237
|
+
limit: z3.coerce.number().int().min(1).max(100).default(20),
|
|
238
|
+
cursor: cursor.optional()
|
|
239
|
+
}).strict();
|
|
240
|
+
var profileCompletionSchema = z3.object({
|
|
241
|
+
quest: identifier,
|
|
242
|
+
key: identifier.optional(),
|
|
243
|
+
title: z3.string(),
|
|
244
|
+
completions: count.positive(),
|
|
245
|
+
/** Null for completions recorded before completion times were. */
|
|
246
|
+
lastCompletedAt: count.nullable()
|
|
247
|
+
});
|
|
248
|
+
var profileCompletionPageSchema = z3.object({
|
|
249
|
+
items: z3.array(profileCompletionSchema),
|
|
250
|
+
nextCursor: cursor.nullable()
|
|
251
|
+
});
|
|
252
|
+
var profileReferralSchema = z3.object({
|
|
253
|
+
program: identifier,
|
|
254
|
+
key: identifier.optional(),
|
|
255
|
+
title: z3.string(),
|
|
256
|
+
/** Members this member invited. Invitations are shared by every program. */
|
|
257
|
+
invited: count,
|
|
258
|
+
/** Invited members who qualified in this program. */
|
|
259
|
+
qualified: count,
|
|
260
|
+
milestones: z3.array(
|
|
261
|
+
z3.object({ id: identifier, count, reached: z3.boolean() })
|
|
262
|
+
)
|
|
263
|
+
});
|
|
264
|
+
var profileSettingsSchema = z3.object({
|
|
265
|
+
visibility: profileVisibilitySchema,
|
|
266
|
+
defaults: profileDefaultsSchema,
|
|
267
|
+
revision: count,
|
|
268
|
+
actor: z3.string().nullable(),
|
|
269
|
+
updatedAt: count.nullable()
|
|
270
|
+
});
|
|
271
|
+
var profileSettingsInputSchema = profileSettingsSchema.omit({ revision: true, actor: true, updatedAt: true }).extend({
|
|
272
|
+
actionId: identifier,
|
|
273
|
+
/** The revision the change was made against; a newer one is a 409. */
|
|
274
|
+
expectedRevision: count,
|
|
275
|
+
reason: z3.string().trim().min(1).max(500)
|
|
276
|
+
}).strict();
|
|
277
|
+
var profileModerationSchema = z3.object({
|
|
278
|
+
actionId: identifier,
|
|
279
|
+
resetName: z3.boolean().default(false),
|
|
280
|
+
removeAvatar: z3.boolean().default(false),
|
|
281
|
+
/** True locks the name and avatar, false unlocks them. */
|
|
282
|
+
lock: z3.boolean().optional(),
|
|
283
|
+
reason: z3.string().trim().min(1).max(1e3)
|
|
284
|
+
}).strict().refine(
|
|
285
|
+
(value) => value.resetName || value.removeAvatar || value.lock !== void 0,
|
|
286
|
+
"Choose an action"
|
|
287
|
+
);
|
|
288
|
+
var managedProfileSchema = ownProfileSchema.omit({ options: true }).extend({
|
|
289
|
+
member: identifier,
|
|
290
|
+
lockedAt: count.nullable(),
|
|
291
|
+
lockedBy: z3.string().nullable(),
|
|
292
|
+
lockedReason: z3.string().nullable(),
|
|
293
|
+
updatedAt: count
|
|
294
|
+
});
|
|
295
|
+
var AVATAR_UPLOAD_LIMIT = 5 * 1024 * 1024;
|
|
296
|
+
var avatarUploadTypes = ["image/jpeg", "image/png", "image/webp"];
|
|
297
|
+
|
|
298
|
+
export {
|
|
299
|
+
pointLedgerPropertiesSchema,
|
|
300
|
+
createPointLedgerSchema,
|
|
301
|
+
pointLedgerSchema,
|
|
302
|
+
managedPointLedgerSchema,
|
|
303
|
+
pointLedgerDeclarationSchema,
|
|
304
|
+
pointLedgerArtifactSchema,
|
|
305
|
+
pointLedgerReferenceSchema,
|
|
306
|
+
pointBalanceSchema,
|
|
307
|
+
pointBalancesSchema,
|
|
308
|
+
PointEntryKind,
|
|
309
|
+
pointEntrySchema,
|
|
310
|
+
pointHistoryQuerySchema,
|
|
311
|
+
pointHistoryPageSchema,
|
|
312
|
+
telegramSignInMethodsSchema,
|
|
313
|
+
telegramAccountConnectionSchema,
|
|
314
|
+
telegramInitDataSchema,
|
|
315
|
+
telegramMiniAppSignInSchema,
|
|
316
|
+
telegramChatIdSchema,
|
|
317
|
+
telegramChatSchema,
|
|
318
|
+
telegramChatsSchema,
|
|
319
|
+
telegramChatConnectionSchema,
|
|
320
|
+
telegramMemberInputSchema,
|
|
321
|
+
telegramChatMemberSchema,
|
|
322
|
+
telegramReactionsNamespace,
|
|
323
|
+
telegramReactionDataSchema,
|
|
324
|
+
profileVisibilitySchema,
|
|
325
|
+
avatarProviderSchema,
|
|
326
|
+
profileDefaultProviderSchema,
|
|
327
|
+
profileDefaultsSchema,
|
|
328
|
+
avatarSeedSchema,
|
|
329
|
+
profileAvatarSchema,
|
|
330
|
+
profileSummarySchema,
|
|
331
|
+
displayNameSchema,
|
|
332
|
+
profileUpdateSchema,
|
|
333
|
+
ownProfileSchema,
|
|
334
|
+
profileCompletionQuerySchema,
|
|
335
|
+
profileCompletionSchema,
|
|
336
|
+
profileCompletionPageSchema,
|
|
337
|
+
profileReferralSchema,
|
|
338
|
+
profileSettingsSchema,
|
|
339
|
+
profileSettingsInputSchema,
|
|
340
|
+
profileModerationSchema,
|
|
341
|
+
managedProfileSchema,
|
|
342
|
+
AVATAR_UPLOAD_LIMIT,
|
|
343
|
+
avatarUploadTypes
|
|
344
|
+
};
|