@domino-sdk/relay 1.0.0-next.2 → 1.0.0-next.34
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/README.md +13 -1
- package/build.mjs +18 -1
- package/dist/activity-B8k9Sa_a.d.ts +9112 -0
- package/dist/authoring.d.ts +1355 -182
- package/dist/authoring.js +658 -225
- package/dist/automatic-outcomes-B1xrETxm.d.ts +758 -0
- package/dist/avatar.d.ts +29 -0
- package/dist/avatar.js +21 -0
- package/dist/browser-J7tUpXxy.d.ts +4154 -0
- package/dist/browser.d.ts +11 -4580
- package/dist/browser.js +8 -6
- package/dist/capability-error-DNMwKmlL.d.ts +458 -0
- package/dist/chunk-36HTX2BM.js +1223 -0
- package/dist/chunk-6QJ3LADK.js +112 -0
- package/dist/chunk-BGGKNIRP.js +171 -0
- package/dist/chunk-EYH5RDIE.js +496 -0
- package/dist/chunk-GQKYAQM6.js +84 -0
- package/dist/chunk-GUP7YRR4.js +42 -0
- package/dist/chunk-GZ6FJAXN.js +1659 -0
- package/dist/chunk-JON5SESL.js +2986 -0
- package/dist/chunk-MC6V6VMG.js +49 -0
- package/dist/chunk-NPGENI7K.js +37 -0
- package/dist/chunk-V7UKZLHA.js +35 -0
- package/dist/chunk-VFHHLN6A.js +284 -0
- package/dist/chunk-WJSSJ7AF.js +151 -0
- package/dist/{chunk-VH4OQ5VX.js → chunk-XFMSUPNS.js} +26 -5
- package/dist/{chunk-FDWRBMB3.js → chunk-ZVIRG24J.js} +150 -33
- package/dist/client-XiuFnug_.d.ts +4262 -0
- package/dist/groups-Ck-OxzjD.d.ts +2449 -0
- package/dist/identity-integration-GxAHdKR2.d.ts +58 -0
- package/dist/images-Dv-P5VBw.d.ts +234 -0
- package/dist/index.d.ts +15 -13115
- package/dist/index.js +30 -689
- package/dist/internal.d.ts +159 -0
- package/dist/internal.js +79 -0
- package/dist/offers-Cy-e4o5x.d.ts +431 -0
- package/dist/outcomes-kVB-Juzs.d.ts +4902 -0
- package/dist/pages-BBYD21IE.d.ts +359 -0
- package/dist/participant-rewards-3duLb8YJ.d.ts +668 -0
- package/dist/portal-proxy.js +26 -9
- package/dist/profiles-D2aFcOxu.d.ts +297 -0
- package/dist/react/index.d.ts +3378 -3318
- package/dist/react/index.js +1635 -783
- package/dist/request-error-DWduJCGV.d.ts +62 -0
- package/dist/schema-DfJzH2ci.d.ts +5644 -0
- package/dist/schema.d.ts +15 -3388
- package/dist/schema.js +790 -3
- package/dist/server/index.d.ts +81498 -0
- package/dist/server/index.js +2520 -0
- package/dist/streaks-CWyq8Px5.d.ts +71 -0
- package/dist/submission-input-BZkm6ohU.d.ts +290 -0
- package/dist/units-CwgsPB_r.d.ts +9 -0
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -0
- package/dist/wallet-YssWxGg8.d.ts +228 -0
- package/package.json +24 -5
- package/dist/chunk-4KNTMNXA.js +0 -1847
- package/dist/chunk-B76BAJ25.js +0 -624
- package/dist/chunk-NKGJEYZM.js +0 -1833
- package/dist/chunk-ONDBQSMU.js +0 -373
- package/dist/submission-input-JDwq3EVK.d.ts +0 -4986
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRequestError
|
|
3
|
+
} from "./chunk-NPGENI7K.js";
|
|
4
|
+
|
|
5
|
+
// src/request-lifetime.ts
|
|
6
|
+
var PARTICIPANT_TIMEOUT = 15e3;
|
|
7
|
+
var MANAGEMENT_TIMEOUT = 3e4;
|
|
8
|
+
var MAX_ATTEMPTS = 3;
|
|
9
|
+
var transientStatuses = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
|
|
10
|
+
function validTimeout(value) {
|
|
11
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
12
|
+
}
|
|
13
|
+
function lifetime(timeout, caller) {
|
|
14
|
+
const deadline = new AbortController();
|
|
15
|
+
const expiresAt = Date.now() + timeout;
|
|
16
|
+
const timer = setTimeout(
|
|
17
|
+
() => deadline.abort(
|
|
18
|
+
new DOMException(`No answer within ${timeout} ms`, "TimeoutError")
|
|
19
|
+
),
|
|
20
|
+
timeout
|
|
21
|
+
);
|
|
22
|
+
const signal = caller ? AbortSignal.any([caller, deadline.signal]) : deadline.signal;
|
|
23
|
+
return {
|
|
24
|
+
signal,
|
|
25
|
+
timeout,
|
|
26
|
+
ended: () => caller?.aborted ? "aborted" : deadline.signal.aborted ? "timeout" : void 0,
|
|
27
|
+
remaining: () => Math.max(0, expiresAt - Date.now()),
|
|
28
|
+
reason: () => caller?.aborted ? caller.reason : deadline.signal.reason,
|
|
29
|
+
end: () => clearTimeout(timer)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function retryAfter(headers, now = Date.now()) {
|
|
33
|
+
const value = headers.get("Retry-After")?.trim();
|
|
34
|
+
if (!value) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
if (/^\d+$/.test(value)) {
|
|
38
|
+
return Number(value) * 1e3;
|
|
39
|
+
}
|
|
40
|
+
const date = Date.parse(value);
|
|
41
|
+
return Number.isNaN(date) ? void 0 : Math.max(0, date - now);
|
|
42
|
+
}
|
|
43
|
+
function backoff(retry) {
|
|
44
|
+
return Math.round(250 * 4 ** (retry - 1) * (0.5 + Math.random() / 2));
|
|
45
|
+
}
|
|
46
|
+
function retryDelay(failure, context) {
|
|
47
|
+
const transient = failure.kind === "network" && (failure.status === void 0 || failure.status < 400) || (failure.kind === "http" || failure.kind === "network") && transientStatuses.has(failure.status ?? 0) && // Domino's rate limits run for minutes or hours: a 429 waits only when told how long.
|
|
48
|
+
(failure.status !== 429 || failure.retryAfter !== void 0);
|
|
49
|
+
if (!transient || !context.replaySafe || context.attempt >= MAX_ATTEMPTS) {
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
const wait = failure.retryAfter ?? backoff(context.attempt);
|
|
53
|
+
return wait < context.remaining ? wait : void 0;
|
|
54
|
+
}
|
|
55
|
+
function pause(ms, signal) {
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
const done = () => {
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
signal.removeEventListener("abort", done);
|
|
60
|
+
resolve();
|
|
61
|
+
};
|
|
62
|
+
const timer = setTimeout(done, ms);
|
|
63
|
+
signal.addEventListener("abort", done, { once: true });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function retrying(life, rules, attempt) {
|
|
67
|
+
const describe = rules.describe ?? describeRequestError;
|
|
68
|
+
const uncertain = rules.uncertain ?? markUncertain;
|
|
69
|
+
let earlierUncertain = false;
|
|
70
|
+
for (let number = 1; ; number++) {
|
|
71
|
+
try {
|
|
72
|
+
return await attempt();
|
|
73
|
+
} catch (error) {
|
|
74
|
+
const failure = describe(error);
|
|
75
|
+
const wait = failure && !life.ended() ? retryDelay(failure, {
|
|
76
|
+
attempt: number,
|
|
77
|
+
replaySafe: rules.replaySafe,
|
|
78
|
+
remaining: life.remaining()
|
|
79
|
+
}) : void 0;
|
|
80
|
+
if (wait === void 0) {
|
|
81
|
+
throw earlierUncertain && !failure?.uncertain ? uncertain(error) : error;
|
|
82
|
+
}
|
|
83
|
+
earlierUncertain ||= failure?.uncertain ?? false;
|
|
84
|
+
await pause(wait, life.signal);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function describeRequestError(error) {
|
|
89
|
+
return isRequestError(error) ? {
|
|
90
|
+
kind: error.kind,
|
|
91
|
+
status: error.status,
|
|
92
|
+
uncertain: error.uncertain,
|
|
93
|
+
retryAfter: error.retryAfter
|
|
94
|
+
} : void 0;
|
|
95
|
+
}
|
|
96
|
+
function markUncertain(error) {
|
|
97
|
+
if (isRequestError(error)) {
|
|
98
|
+
const target = error;
|
|
99
|
+
target.uncertain = true;
|
|
100
|
+
target.recovery = error.operationId ? "replay" : "reconcile";
|
|
101
|
+
}
|
|
102
|
+
return error;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
PARTICIPANT_TIMEOUT,
|
|
107
|
+
MANAGEMENT_TIMEOUT,
|
|
108
|
+
validTimeout,
|
|
109
|
+
lifetime,
|
|
110
|
+
retryAfter,
|
|
111
|
+
retrying
|
|
112
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import {
|
|
2
|
+
identifier,
|
|
3
|
+
xTweetSchema
|
|
4
|
+
} from "./chunk-JON5SESL.js";
|
|
5
|
+
|
|
6
|
+
// src/x.ts
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var xIdSchema = z.string().regex(/^[0-9]{1,20}$/);
|
|
9
|
+
var xConnectionSchema = z.object({ userId: xIdSchema });
|
|
10
|
+
var xProfileSchema = z.object({
|
|
11
|
+
id: xIdSchema,
|
|
12
|
+
username: z.string(),
|
|
13
|
+
name: z.string(),
|
|
14
|
+
bio: z.string().nullable(),
|
|
15
|
+
profileImageUrl: z.string().url().nullable(),
|
|
16
|
+
followersCount: z.number().int().nonnegative().nullable(),
|
|
17
|
+
verified: z.boolean().nullable()
|
|
18
|
+
});
|
|
19
|
+
var xPostSchema = xTweetSchema.extend({
|
|
20
|
+
quotedTweetId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
21
|
+
inReplyToUserId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
22
|
+
inReplyToStatusId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
23
|
+
retweetedTweetId: xIdSchema.nullish().transform((v) => v ?? null),
|
|
24
|
+
/**
|
|
25
|
+
* Attached media in post order. Videos and GIFs carry their preview image URL. Like the tracker
|
|
26
|
+
* projection (migration 0056), a list with any malformed item is dropped whole, so positions
|
|
27
|
+
* never shift and a bad entry never fails the post read.
|
|
28
|
+
*/
|
|
29
|
+
media: z.unknown().transform(
|
|
30
|
+
(value) => z.array(z.object({ type: z.string(), url: z.string() })).safeParse(value).data ?? []
|
|
31
|
+
)
|
|
32
|
+
});
|
|
33
|
+
var xRequestSchema = z.discriminatedUnion("operation", [
|
|
34
|
+
z.object({ operation: z.literal("connection") }).strict(),
|
|
35
|
+
z.object({ operation: z.literal("profile") }).strict(),
|
|
36
|
+
z.object({ operation: z.literal("post"), postId: xIdSchema }).strict(),
|
|
37
|
+
z.object({ operation: z.literal("follows"), userId: xIdSchema }).strict(),
|
|
38
|
+
z.object({ operation: z.literal("reposted"), postId: xIdSchema }).strict()
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
// src/images.ts
|
|
42
|
+
import { z as z2 } from "zod";
|
|
43
|
+
var imageReferenceSchema = z2.union([
|
|
44
|
+
z2.strictObject({ evidence: z2.string().min(1).max(256) }),
|
|
45
|
+
z2.strictObject({ x: z2.literal("profile") }),
|
|
46
|
+
z2.strictObject({
|
|
47
|
+
x: z2.literal("post"),
|
|
48
|
+
postId: xIdSchema,
|
|
49
|
+
index: z2.number().int().min(0).max(3).default(0)
|
|
50
|
+
}),
|
|
51
|
+
z2.strictObject({ asset: identifier })
|
|
52
|
+
]);
|
|
53
|
+
var criteria = z2.string().trim().min(1).max(2e3);
|
|
54
|
+
var imageFieldSchema = z2.strictObject({
|
|
55
|
+
type: z2.enum(["string", "number", "boolean"]),
|
|
56
|
+
description: z2.string().trim().min(1).max(500)
|
|
57
|
+
});
|
|
58
|
+
var imageFieldsSchema = z2.record(z2.string().regex(/^[a-zA-Z][a-zA-Z0-9_]{0,39}$/), imageFieldSchema).refine((fields) => {
|
|
59
|
+
const count = Object.keys(fields).length;
|
|
60
|
+
return count >= 1 && count <= 12;
|
|
61
|
+
}, "Declare between 1 and 12 fields");
|
|
62
|
+
var imageRequestSchema = z2.discriminatedUnion("operation", [
|
|
63
|
+
z2.strictObject({
|
|
64
|
+
operation: z2.literal("inspect"),
|
|
65
|
+
image: imageReferenceSchema
|
|
66
|
+
}),
|
|
67
|
+
z2.strictObject({
|
|
68
|
+
operation: z2.literal("compare"),
|
|
69
|
+
images: z2.tuple([imageReferenceSchema, imageReferenceSchema])
|
|
70
|
+
}),
|
|
71
|
+
z2.strictObject({
|
|
72
|
+
operation: z2.literal("review"),
|
|
73
|
+
images: z2.array(imageReferenceSchema).min(1).max(4),
|
|
74
|
+
criteria
|
|
75
|
+
}),
|
|
76
|
+
z2.strictObject({
|
|
77
|
+
operation: z2.literal("extract"),
|
|
78
|
+
image: imageReferenceSchema,
|
|
79
|
+
fields: imageFieldsSchema
|
|
80
|
+
}),
|
|
81
|
+
z2.strictObject({
|
|
82
|
+
operation: z2.literal("seen"),
|
|
83
|
+
image: imageReferenceSchema,
|
|
84
|
+
maxDistance: z2.number().int().min(0).max(8).default(8)
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
var hash = z2.string().regex(/^[0-9a-f]{16}$/);
|
|
88
|
+
var imageInspectionSchema = z2.strictObject({
|
|
89
|
+
width: z2.number().int().positive(),
|
|
90
|
+
height: z2.number().int().positive(),
|
|
91
|
+
format: z2.enum(["jpeg", "png", "webp", "gif", "avif"]),
|
|
92
|
+
bytes: z2.number().int().positive(),
|
|
93
|
+
sha256: z2.string().regex(/^[0-9a-f]{64}$/),
|
|
94
|
+
phash: hash,
|
|
95
|
+
dhash: hash
|
|
96
|
+
});
|
|
97
|
+
var distance = z2.number().int().min(0).max(64);
|
|
98
|
+
var imageComparisonSchema = z2.strictObject({
|
|
99
|
+
identical: z2.boolean(),
|
|
100
|
+
phashDistance: distance,
|
|
101
|
+
dhashDistance: distance
|
|
102
|
+
});
|
|
103
|
+
var imageExtractionSchema = z2.strictObject({
|
|
104
|
+
values: z2.record(
|
|
105
|
+
z2.string(),
|
|
106
|
+
z2.union([z2.string().max(2e3), z2.number(), z2.boolean(), z2.null()])
|
|
107
|
+
),
|
|
108
|
+
reason: z2.string().min(1).max(2e3)
|
|
109
|
+
});
|
|
110
|
+
var imageSightingsSchema = z2.strictObject({
|
|
111
|
+
matches: z2.number().int().nonnegative(),
|
|
112
|
+
closestDistance: distance.nullable(),
|
|
113
|
+
firstSeenAt: z2.number().int().nonnegative().nullable()
|
|
114
|
+
});
|
|
115
|
+
var sha256 = z2.string().regex(/^[0-9a-f]{64}$/);
|
|
116
|
+
var imageSize = z2.number().int().positive().max(5 * 1024 * 1024);
|
|
117
|
+
var imageAssetArtifactSchema = z2.strictObject({
|
|
118
|
+
key: identifier,
|
|
119
|
+
sha256,
|
|
120
|
+
size: imageSize,
|
|
121
|
+
path: z2.string().min(1).max(500).optional()
|
|
122
|
+
});
|
|
123
|
+
var imageUploadRequestSchema = z2.strictObject({
|
|
124
|
+
images: z2.array(
|
|
125
|
+
z2.strictObject({
|
|
126
|
+
sha256,
|
|
127
|
+
size: imageSize,
|
|
128
|
+
type: z2.enum(["image/jpeg", "image/png", "image/webp"])
|
|
129
|
+
})
|
|
130
|
+
).min(1).max(10)
|
|
131
|
+
});
|
|
132
|
+
var imageUploadsSchema = z2.strictObject({
|
|
133
|
+
images: z2.array(
|
|
134
|
+
z2.strictObject({
|
|
135
|
+
sha256,
|
|
136
|
+
upload: z2.strictObject({
|
|
137
|
+
url: z2.string().url(),
|
|
138
|
+
headers: z2.record(z2.string(), z2.string()),
|
|
139
|
+
expiresAt: z2.number().int().positive()
|
|
140
|
+
}).nullable()
|
|
141
|
+
})
|
|
142
|
+
)
|
|
143
|
+
});
|
|
144
|
+
var publishedImageSchema = z2.strictObject({
|
|
145
|
+
key: identifier,
|
|
146
|
+
sha256,
|
|
147
|
+
type: z2.enum(["image/jpeg", "image/png", "image/webp"]),
|
|
148
|
+
size: imageSize,
|
|
149
|
+
width: z2.number().int().positive(),
|
|
150
|
+
height: z2.number().int().positive()
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export {
|
|
154
|
+
xIdSchema,
|
|
155
|
+
xConnectionSchema,
|
|
156
|
+
xProfileSchema,
|
|
157
|
+
xPostSchema,
|
|
158
|
+
xRequestSchema,
|
|
159
|
+
imageReferenceSchema,
|
|
160
|
+
imageFieldSchema,
|
|
161
|
+
imageFieldsSchema,
|
|
162
|
+
imageRequestSchema,
|
|
163
|
+
imageInspectionSchema,
|
|
164
|
+
imageComparisonSchema,
|
|
165
|
+
imageExtractionSchema,
|
|
166
|
+
imageSightingsSchema,
|
|
167
|
+
imageAssetArtifactSchema,
|
|
168
|
+
imageUploadRequestSchema,
|
|
169
|
+
imageUploadsSchema,
|
|
170
|
+
publishedImageSchema
|
|
171
|
+
};
|