@adland/data 0.4.0 → 0.6.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 +13 -0
- package/dist/index.cjs +160 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +603 -186
- package/dist/index.d.ts +603 -186
- package/dist/index.js +152 -123
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,229 +1,646 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
url: z.ZodNonOptional<z.ZodString>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
/**
|
|
13
|
-
* Cast ad schema - link to a Farcaster cast
|
|
14
|
-
*/
|
|
15
|
-
declare const castAdSchema: z.ZodObject<{
|
|
16
|
-
type: z.ZodLiteral<"cast">;
|
|
17
|
-
data: z.ZodObject<{
|
|
18
|
-
hash: z.ZodNonOptional<z.ZodString>;
|
|
19
|
-
}, z.core.$strip>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
/**
|
|
22
|
-
* MiniApp ad schema - link to a Farcaster mini app
|
|
23
|
-
*/
|
|
24
|
-
declare const miniappAdSchema: z.ZodObject<{
|
|
25
|
-
type: z.ZodLiteral<"miniapp">;
|
|
26
|
-
data: z.ZodObject<{
|
|
27
|
-
url: z.ZodNonOptional<z.ZodString>;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
|
-
}, z.core.$strip>;
|
|
30
|
-
/**
|
|
31
|
-
* Union schema for all ad types
|
|
32
|
-
*/
|
|
33
|
-
declare const adDataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
|
-
type: z.ZodLiteral<"link">;
|
|
35
|
-
data: z.ZodObject<{
|
|
36
|
-
url: z.ZodNonOptional<z.ZodString>;
|
|
37
|
-
}, z.core.$strip>;
|
|
38
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
-
type: z.ZodLiteral<"cast">;
|
|
40
|
-
data: z.ZodObject<{
|
|
41
|
-
hash: z.ZodNonOptional<z.ZodString>;
|
|
42
|
-
}, z.core.$strip>;
|
|
4
|
+
* Cast Ad Definition
|
|
5
|
+
* Represents a Farcaster cast ad with validation and verification
|
|
6
|
+
*/
|
|
7
|
+
declare const castAd: AdDefinition<z.ZodObject<{
|
|
8
|
+
hash: z.ZodString;
|
|
43
9
|
}, z.core.$strip>, z.ZodObject<{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
10
|
+
username: z.ZodOptional<z.ZodString>;
|
|
11
|
+
text: z.ZodOptional<z.ZodString>;
|
|
12
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
}, z.core.$strip>> & {
|
|
14
|
+
process: (input: {
|
|
15
|
+
hash: string;
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
data: {
|
|
18
|
+
hash: string;
|
|
19
|
+
};
|
|
20
|
+
metadata: {
|
|
21
|
+
username?: string | undefined;
|
|
22
|
+
text?: string | undefined;
|
|
23
|
+
timestamp?: number | undefined;
|
|
24
|
+
} | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
safeProcess: (input: {
|
|
27
|
+
hash: string;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
data?: {
|
|
31
|
+
hash: string;
|
|
32
|
+
} | undefined;
|
|
33
|
+
metadata?: {
|
|
34
|
+
username?: string | undefined;
|
|
35
|
+
text?: string | undefined;
|
|
36
|
+
timestamp?: number | undefined;
|
|
37
|
+
} | undefined;
|
|
38
|
+
error?: z.ZodError | string;
|
|
39
|
+
}>;
|
|
71
40
|
};
|
|
72
41
|
/**
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
42
|
+
* Type inference for CastAd data
|
|
43
|
+
*/
|
|
44
|
+
type CastAdData = z.infer<typeof castAd.data>;
|
|
45
|
+
/**
|
|
46
|
+
* Type inference for CastAd metadata
|
|
47
|
+
*/
|
|
48
|
+
type CastAdMetadata = z.infer<NonNullable<typeof castAd.metadata>>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Link Ad Definition
|
|
52
|
+
* Represents a basic link ad with validation and verification
|
|
53
|
+
*/
|
|
54
|
+
declare const linkAd: AdDefinition<z.ZodObject<{
|
|
55
|
+
url: z.ZodString;
|
|
56
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
57
|
+
title: z.ZodOptional<z.ZodString>;
|
|
58
|
+
description: z.ZodOptional<z.ZodString>;
|
|
59
|
+
image: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>> & {
|
|
61
|
+
process: (input: {
|
|
62
|
+
url: string;
|
|
63
|
+
}) => Promise<{
|
|
64
|
+
data: {
|
|
65
|
+
url: string;
|
|
66
|
+
};
|
|
67
|
+
metadata: {
|
|
68
|
+
title?: string | undefined;
|
|
69
|
+
description?: string | undefined;
|
|
70
|
+
image?: string | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
safeProcess: (input: {
|
|
74
|
+
url: string;
|
|
75
|
+
}) => Promise<{
|
|
76
|
+
success: boolean;
|
|
77
|
+
data?: {
|
|
78
|
+
url: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
metadata?: {
|
|
81
|
+
title?: string | undefined;
|
|
82
|
+
description?: string | undefined;
|
|
83
|
+
image?: string | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
error?: z.ZodError | string;
|
|
86
|
+
}>;
|
|
113
87
|
};
|
|
114
88
|
/**
|
|
115
|
-
*
|
|
89
|
+
* Type inference for LinkAd data
|
|
116
90
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
91
|
+
type LinkAdData = z.infer<typeof linkAd.data>;
|
|
92
|
+
/**
|
|
93
|
+
* Type inference for LinkAd metadata
|
|
94
|
+
*/
|
|
95
|
+
type LinkAdMetadata = z.infer<NonNullable<typeof linkAd.metadata>>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* MiniApp Ad Definition
|
|
99
|
+
* Represents a Farcaster mini app ad with validation and verification
|
|
100
|
+
*/
|
|
101
|
+
declare const miniappAd: AdDefinition<z.ZodObject<{
|
|
102
|
+
url: z.ZodString;
|
|
103
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
104
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
105
|
+
title: z.ZodOptional<z.ZodString>;
|
|
106
|
+
}, z.core.$strip>> & {
|
|
107
|
+
process: (input: {
|
|
108
|
+
url: string;
|
|
109
|
+
}) => Promise<{
|
|
110
|
+
data: {
|
|
111
|
+
url: string;
|
|
112
|
+
};
|
|
113
|
+
metadata: {
|
|
114
|
+
icon?: string | undefined;
|
|
115
|
+
title?: string | undefined;
|
|
116
|
+
} | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
safeProcess: (input: {
|
|
119
|
+
url: string;
|
|
120
|
+
}) => Promise<{
|
|
121
|
+
success: boolean;
|
|
122
|
+
data?: {
|
|
123
|
+
url: string;
|
|
124
|
+
} | undefined;
|
|
125
|
+
metadata?: {
|
|
126
|
+
icon?: string | undefined;
|
|
127
|
+
title?: string | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
error?: z.ZodError | string;
|
|
130
|
+
}>;
|
|
121
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Type inference for MiniAppAd data
|
|
134
|
+
*/
|
|
135
|
+
type MiniAppAdData = z.infer<typeof miniappAd.data>;
|
|
136
|
+
/**
|
|
137
|
+
* Type inference for MiniAppAd metadata
|
|
138
|
+
*/
|
|
139
|
+
type MiniAppAdMetadata = z.infer<NonNullable<typeof miniappAd.metadata>>;
|
|
122
140
|
|
|
123
141
|
/**
|
|
124
|
-
*
|
|
142
|
+
* Ad Definition type
|
|
143
|
+
* Represents a data contract + behavior for an ad type
|
|
125
144
|
*/
|
|
126
|
-
|
|
127
|
-
readonly schema: S;
|
|
128
|
-
constructor(schema: S);
|
|
145
|
+
type AdDefinition<TData extends z.ZodTypeAny, TMetadata extends z.ZodTypeAny | undefined = undefined> = {
|
|
129
146
|
/**
|
|
130
|
-
*
|
|
147
|
+
* The literal type string for this ad (e.g., "cast", "link")
|
|
131
148
|
*/
|
|
132
|
-
|
|
149
|
+
type: string;
|
|
133
150
|
/**
|
|
134
|
-
*
|
|
135
|
-
* Throw an error if verification fails
|
|
151
|
+
* The Zod schema for the ad's data field
|
|
136
152
|
*/
|
|
137
|
-
|
|
153
|
+
data: TData;
|
|
138
154
|
/**
|
|
139
|
-
*
|
|
155
|
+
* Optional Zod schema for the ad's metadata field
|
|
140
156
|
*/
|
|
141
|
-
|
|
157
|
+
metadata?: TMetadata;
|
|
142
158
|
/**
|
|
143
|
-
*
|
|
159
|
+
* Optional verification function that runs after parsing
|
|
160
|
+
* Receives already-validated data
|
|
144
161
|
*/
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
162
|
+
verify?: (data: z.infer<TData>) => Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* Optional metadata enrichment function
|
|
165
|
+
* Only available if metadata schema is defined
|
|
166
|
+
*/
|
|
167
|
+
getMetadata?: (data: z.infer<TData>) => Promise<TMetadata extends z.ZodTypeAny ? z.infer<TMetadata> : never>;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Typed helper to define an ad
|
|
171
|
+
* Locks type inference and prevents widening
|
|
172
|
+
* Adds a `process` method for convenience
|
|
173
|
+
* @param def - Ad definition object
|
|
174
|
+
* @returns The same definition with proper types and a process method
|
|
175
|
+
*/
|
|
176
|
+
declare function defineAd<const TData extends z.ZodTypeAny, const TMetadata extends z.ZodTypeAny | undefined>(def: AdDefinition<TData, TMetadata>): AdDefinition<TData, TMetadata> & {
|
|
177
|
+
/**
|
|
178
|
+
* Process this ad through the full pipeline: parse → verify → getMetadata
|
|
179
|
+
* @param input - Raw input data to process
|
|
180
|
+
* @returns Processed data and optional metadata
|
|
181
|
+
*/
|
|
182
|
+
process: (input: z.infer<TData>) => Promise<{
|
|
183
|
+
data: z.infer<TData>;
|
|
184
|
+
metadata: TMetadata extends z.ZodTypeAny ? TMetadata extends undefined ? undefined : z.infer<TMetadata> | undefined : undefined;
|
|
149
185
|
}>;
|
|
150
186
|
/**
|
|
151
|
-
* Safe
|
|
187
|
+
* Safe version of process that returns a result object
|
|
188
|
+
* @param input - Raw input data to process
|
|
189
|
+
* @returns Result object with success flag and data or error
|
|
152
190
|
*/
|
|
153
|
-
|
|
191
|
+
safeProcess: (input: z.infer<TData>) => Promise<{
|
|
154
192
|
success: boolean;
|
|
155
|
-
data?: z.infer<
|
|
156
|
-
|
|
193
|
+
data?: z.infer<TData>;
|
|
194
|
+
metadata?: TMetadata extends z.ZodTypeAny ? TMetadata extends undefined ? undefined : z.infer<TMetadata> | undefined : undefined;
|
|
195
|
+
error?: z.ZodError | string;
|
|
157
196
|
}>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
declare const adTypes: readonly ["link", "cast", "miniapp"];
|
|
161
|
-
/**
|
|
162
|
-
* Base ad type
|
|
163
|
-
*/
|
|
164
|
-
type AdType = (typeof adTypes)[number];
|
|
165
|
-
/**
|
|
166
|
-
* Link ad type - basic link
|
|
167
|
-
*/
|
|
168
|
-
type LinkAd = z.infer<typeof linkAdSchema>;
|
|
169
|
-
/**
|
|
170
|
-
* Cast ad type - link to a Farcaster cast
|
|
171
|
-
*/
|
|
172
|
-
type CastAd = z.infer<typeof castAdSchema>;
|
|
197
|
+
};
|
|
173
198
|
/**
|
|
174
|
-
*
|
|
199
|
+
* Process an ad through the full pipeline: parse → verify → getMetadata
|
|
200
|
+
* @param ad - Ad definition
|
|
201
|
+
* @param input - Raw input data to process
|
|
202
|
+
* @returns Processed data and optional metadata
|
|
175
203
|
*/
|
|
176
|
-
|
|
204
|
+
declare function processAd<TData extends z.ZodTypeAny, TMetadata extends z.ZodTypeAny | undefined>(ad: AdDefinition<TData, TMetadata>, input: z.infer<TData>): Promise<{
|
|
205
|
+
data: z.infer<TData>;
|
|
206
|
+
metadata: TMetadata extends z.ZodTypeAny ? TMetadata extends undefined ? undefined : z.infer<TMetadata> | undefined : undefined;
|
|
207
|
+
}>;
|
|
177
208
|
/**
|
|
178
|
-
*
|
|
209
|
+
* Safe version of processAd that returns a result object
|
|
210
|
+
* @param ad - Ad definition
|
|
211
|
+
* @param input - Raw input data to process
|
|
212
|
+
* @returns Result object with success flag and data or error
|
|
179
213
|
*/
|
|
180
|
-
|
|
214
|
+
declare function safeProcessAd<TData extends z.ZodTypeAny, TMetadata extends z.ZodTypeAny | undefined>(ad: AdDefinition<TData, TMetadata>, input: unknown): Promise<{
|
|
215
|
+
success: boolean;
|
|
216
|
+
data?: z.infer<TData>;
|
|
217
|
+
metadata?: TMetadata extends z.ZodTypeAny ? TMetadata extends undefined ? undefined : z.infer<TMetadata> | undefined : undefined;
|
|
218
|
+
error?: z.ZodError | string;
|
|
219
|
+
}>;
|
|
181
220
|
|
|
182
221
|
/**
|
|
183
|
-
*
|
|
222
|
+
* Registry of all ad definitions
|
|
223
|
+
* Each entry is an AdDefinition object
|
|
184
224
|
*/
|
|
185
|
-
declare
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
225
|
+
declare const ads: {
|
|
226
|
+
readonly link: AdDefinition<z.ZodObject<{
|
|
227
|
+
url: z.ZodString;
|
|
228
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
229
|
+
title: z.ZodOptional<z.ZodString>;
|
|
230
|
+
description: z.ZodOptional<z.ZodString>;
|
|
231
|
+
image: z.ZodOptional<z.ZodString>;
|
|
232
|
+
}, z.core.$strip>> & {
|
|
233
|
+
process: (input: {
|
|
234
|
+
url: string;
|
|
235
|
+
}) => Promise<{
|
|
236
|
+
data: {
|
|
237
|
+
url: string;
|
|
238
|
+
};
|
|
239
|
+
metadata: {
|
|
240
|
+
title?: string | undefined;
|
|
241
|
+
description?: string | undefined;
|
|
242
|
+
image?: string | undefined;
|
|
243
|
+
} | undefined;
|
|
244
|
+
}>;
|
|
245
|
+
safeProcess: (input: {
|
|
246
|
+
url: string;
|
|
247
|
+
}) => Promise<{
|
|
248
|
+
success: boolean;
|
|
249
|
+
data?: {
|
|
250
|
+
url: string;
|
|
251
|
+
} | undefined;
|
|
252
|
+
metadata?: {
|
|
253
|
+
title?: string | undefined;
|
|
254
|
+
description?: string | undefined;
|
|
255
|
+
image?: string | undefined;
|
|
256
|
+
} | undefined;
|
|
257
|
+
error?: z.ZodError | string;
|
|
258
|
+
}>;
|
|
259
|
+
};
|
|
260
|
+
readonly cast: AdDefinition<z.ZodObject<{
|
|
261
|
+
hash: z.ZodString;
|
|
262
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
263
|
+
username: z.ZodOptional<z.ZodString>;
|
|
264
|
+
text: z.ZodOptional<z.ZodString>;
|
|
265
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
266
|
+
}, z.core.$strip>> & {
|
|
267
|
+
process: (input: {
|
|
268
|
+
hash: string;
|
|
269
|
+
}) => Promise<{
|
|
270
|
+
data: {
|
|
271
|
+
hash: string;
|
|
272
|
+
};
|
|
273
|
+
metadata: {
|
|
274
|
+
username?: string | undefined;
|
|
275
|
+
text?: string | undefined;
|
|
276
|
+
timestamp?: number | undefined;
|
|
277
|
+
} | undefined;
|
|
278
|
+
}>;
|
|
279
|
+
safeProcess: (input: {
|
|
280
|
+
hash: string;
|
|
281
|
+
}) => Promise<{
|
|
282
|
+
success: boolean;
|
|
283
|
+
data?: {
|
|
284
|
+
hash: string;
|
|
285
|
+
} | undefined;
|
|
286
|
+
metadata?: {
|
|
287
|
+
username?: string | undefined;
|
|
288
|
+
text?: string | undefined;
|
|
289
|
+
timestamp?: number | undefined;
|
|
290
|
+
} | undefined;
|
|
291
|
+
error?: z.ZodError | string;
|
|
292
|
+
}>;
|
|
293
|
+
};
|
|
294
|
+
readonly miniapp: AdDefinition<z.ZodObject<{
|
|
295
|
+
url: z.ZodString;
|
|
296
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
297
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
298
|
+
title: z.ZodOptional<z.ZodString>;
|
|
299
|
+
}, z.core.$strip>> & {
|
|
300
|
+
process: (input: {
|
|
301
|
+
url: string;
|
|
302
|
+
}) => Promise<{
|
|
303
|
+
data: {
|
|
304
|
+
url: string;
|
|
305
|
+
};
|
|
306
|
+
metadata: {
|
|
307
|
+
icon?: string | undefined;
|
|
308
|
+
title?: string | undefined;
|
|
309
|
+
} | undefined;
|
|
310
|
+
}>;
|
|
311
|
+
safeProcess: (input: {
|
|
312
|
+
url: string;
|
|
313
|
+
}) => Promise<{
|
|
314
|
+
success: boolean;
|
|
315
|
+
data?: {
|
|
316
|
+
url: string;
|
|
317
|
+
} | undefined;
|
|
318
|
+
metadata?: {
|
|
319
|
+
icon?: string | undefined;
|
|
320
|
+
title?: string | undefined;
|
|
321
|
+
} | undefined;
|
|
322
|
+
error?: z.ZodError | string;
|
|
323
|
+
}>;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
declare const adTypes: readonly ["link", "cast", "miniapp"];
|
|
189
327
|
/**
|
|
190
|
-
*
|
|
328
|
+
* Type for ad definition keys
|
|
191
329
|
*/
|
|
192
|
-
|
|
193
|
-
readonly type: "link";
|
|
194
|
-
constructor();
|
|
195
|
-
verify(data: LinkAd): Promise<void>;
|
|
196
|
-
}
|
|
197
|
-
|
|
330
|
+
type AdType = keyof typeof ads;
|
|
198
331
|
/**
|
|
199
|
-
*
|
|
332
|
+
* Get ad definition by type
|
|
200
333
|
*/
|
|
201
|
-
declare
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
334
|
+
declare function getAd(type: AdType): (AdDefinition<z.ZodObject<{
|
|
335
|
+
url: z.ZodString;
|
|
336
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
337
|
+
title: z.ZodOptional<z.ZodString>;
|
|
338
|
+
description: z.ZodOptional<z.ZodString>;
|
|
339
|
+
image: z.ZodOptional<z.ZodString>;
|
|
340
|
+
}, z.core.$strip>> & {
|
|
341
|
+
process: (input: {
|
|
342
|
+
url: string;
|
|
343
|
+
}) => Promise<{
|
|
344
|
+
data: {
|
|
345
|
+
url: string;
|
|
346
|
+
};
|
|
347
|
+
metadata: {
|
|
348
|
+
title?: string | undefined;
|
|
349
|
+
description?: string | undefined;
|
|
350
|
+
image?: string | undefined;
|
|
351
|
+
} | undefined;
|
|
352
|
+
}>;
|
|
353
|
+
safeProcess: (input: {
|
|
354
|
+
url: string;
|
|
355
|
+
}) => Promise<{
|
|
356
|
+
success: boolean;
|
|
357
|
+
data?: {
|
|
358
|
+
url: string;
|
|
359
|
+
} | undefined;
|
|
360
|
+
metadata?: {
|
|
361
|
+
title?: string | undefined;
|
|
362
|
+
description?: string | undefined;
|
|
363
|
+
image?: string | undefined;
|
|
364
|
+
} | undefined;
|
|
365
|
+
error?: z.ZodError | string;
|
|
366
|
+
}>;
|
|
367
|
+
}) | (AdDefinition<z.ZodObject<{
|
|
368
|
+
hash: z.ZodString;
|
|
369
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
370
|
+
username: z.ZodOptional<z.ZodString>;
|
|
371
|
+
text: z.ZodOptional<z.ZodString>;
|
|
372
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
373
|
+
}, z.core.$strip>> & {
|
|
374
|
+
process: (input: {
|
|
375
|
+
hash: string;
|
|
376
|
+
}) => Promise<{
|
|
377
|
+
data: {
|
|
378
|
+
hash: string;
|
|
379
|
+
};
|
|
380
|
+
metadata: {
|
|
381
|
+
username?: string | undefined;
|
|
382
|
+
text?: string | undefined;
|
|
383
|
+
timestamp?: number | undefined;
|
|
384
|
+
} | undefined;
|
|
385
|
+
}>;
|
|
386
|
+
safeProcess: (input: {
|
|
387
|
+
hash: string;
|
|
388
|
+
}) => Promise<{
|
|
389
|
+
success: boolean;
|
|
390
|
+
data?: {
|
|
391
|
+
hash: string;
|
|
392
|
+
} | undefined;
|
|
393
|
+
metadata?: {
|
|
394
|
+
username?: string | undefined;
|
|
395
|
+
text?: string | undefined;
|
|
396
|
+
timestamp?: number | undefined;
|
|
397
|
+
} | undefined;
|
|
398
|
+
error?: z.ZodError | string;
|
|
399
|
+
}>;
|
|
400
|
+
}) | (AdDefinition<z.ZodObject<{
|
|
401
|
+
url: z.ZodString;
|
|
402
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
403
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
404
|
+
title: z.ZodOptional<z.ZodString>;
|
|
405
|
+
}, z.core.$strip>> & {
|
|
406
|
+
process: (input: {
|
|
407
|
+
url: string;
|
|
408
|
+
}) => Promise<{
|
|
409
|
+
data: {
|
|
410
|
+
url: string;
|
|
411
|
+
};
|
|
412
|
+
metadata: {
|
|
413
|
+
icon?: string | undefined;
|
|
414
|
+
title?: string | undefined;
|
|
415
|
+
} | undefined;
|
|
416
|
+
}>;
|
|
417
|
+
safeProcess: (input: {
|
|
418
|
+
url: string;
|
|
419
|
+
}) => Promise<{
|
|
420
|
+
success: boolean;
|
|
421
|
+
data?: {
|
|
422
|
+
url: string;
|
|
423
|
+
} | undefined;
|
|
424
|
+
metadata?: {
|
|
425
|
+
icon?: string | undefined;
|
|
426
|
+
title?: string | undefined;
|
|
427
|
+
} | undefined;
|
|
428
|
+
error?: z.ZodError | string;
|
|
429
|
+
}>;
|
|
430
|
+
});
|
|
207
431
|
/**
|
|
208
|
-
*
|
|
432
|
+
* Validate ad data against any ad definition
|
|
209
433
|
*/
|
|
210
|
-
declare
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
434
|
+
declare function validateAdData(data: any): {
|
|
435
|
+
success: boolean;
|
|
436
|
+
data?: {
|
|
437
|
+
type: AdType;
|
|
438
|
+
data: unknown;
|
|
439
|
+
};
|
|
440
|
+
error?: z.ZodError | string;
|
|
441
|
+
};
|
|
215
442
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
443
|
+
declare const adDefinitions: {
|
|
444
|
+
readonly link: AdDefinition<z.ZodObject<{
|
|
445
|
+
url: z.ZodString;
|
|
446
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
447
|
+
title: z.ZodOptional<z.ZodString>;
|
|
448
|
+
description: z.ZodOptional<z.ZodString>;
|
|
449
|
+
image: z.ZodOptional<z.ZodString>;
|
|
450
|
+
}, z.core.$strip>> & {
|
|
451
|
+
process: (input: {
|
|
452
|
+
url: string;
|
|
453
|
+
}) => Promise<{
|
|
454
|
+
data: {
|
|
455
|
+
url: string;
|
|
456
|
+
};
|
|
457
|
+
metadata: {
|
|
458
|
+
title?: string | undefined;
|
|
459
|
+
description?: string | undefined;
|
|
460
|
+
image?: string | undefined;
|
|
461
|
+
} | undefined;
|
|
462
|
+
}>;
|
|
463
|
+
safeProcess: (input: {
|
|
464
|
+
url: string;
|
|
465
|
+
}) => Promise<{
|
|
466
|
+
success: boolean;
|
|
467
|
+
data?: {
|
|
468
|
+
url: string;
|
|
469
|
+
} | undefined;
|
|
470
|
+
metadata?: {
|
|
471
|
+
title?: string | undefined;
|
|
472
|
+
description?: string | undefined;
|
|
473
|
+
image?: string | undefined;
|
|
474
|
+
} | undefined;
|
|
475
|
+
error?: z.ZodError | string;
|
|
476
|
+
}>;
|
|
477
|
+
};
|
|
478
|
+
readonly cast: AdDefinition<z.ZodObject<{
|
|
479
|
+
hash: z.ZodString;
|
|
480
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
481
|
+
username: z.ZodOptional<z.ZodString>;
|
|
482
|
+
text: z.ZodOptional<z.ZodString>;
|
|
483
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
484
|
+
}, z.core.$strip>> & {
|
|
485
|
+
process: (input: {
|
|
486
|
+
hash: string;
|
|
487
|
+
}) => Promise<{
|
|
488
|
+
data: {
|
|
489
|
+
hash: string;
|
|
490
|
+
};
|
|
491
|
+
metadata: {
|
|
492
|
+
username?: string | undefined;
|
|
493
|
+
text?: string | undefined;
|
|
494
|
+
timestamp?: number | undefined;
|
|
495
|
+
} | undefined;
|
|
496
|
+
}>;
|
|
497
|
+
safeProcess: (input: {
|
|
498
|
+
hash: string;
|
|
499
|
+
}) => Promise<{
|
|
500
|
+
success: boolean;
|
|
501
|
+
data?: {
|
|
502
|
+
hash: string;
|
|
503
|
+
} | undefined;
|
|
504
|
+
metadata?: {
|
|
505
|
+
username?: string | undefined;
|
|
506
|
+
text?: string | undefined;
|
|
507
|
+
timestamp?: number | undefined;
|
|
508
|
+
} | undefined;
|
|
509
|
+
error?: z.ZodError | string;
|
|
510
|
+
}>;
|
|
511
|
+
};
|
|
512
|
+
readonly miniapp: AdDefinition<z.ZodObject<{
|
|
513
|
+
url: z.ZodString;
|
|
514
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
515
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
516
|
+
title: z.ZodOptional<z.ZodString>;
|
|
517
|
+
}, z.core.$strip>> & {
|
|
518
|
+
process: (input: {
|
|
519
|
+
url: string;
|
|
520
|
+
}) => Promise<{
|
|
521
|
+
data: {
|
|
522
|
+
url: string;
|
|
523
|
+
};
|
|
524
|
+
metadata: {
|
|
525
|
+
icon?: string | undefined;
|
|
526
|
+
title?: string | undefined;
|
|
527
|
+
} | undefined;
|
|
528
|
+
}>;
|
|
529
|
+
safeProcess: (input: {
|
|
530
|
+
url: string;
|
|
531
|
+
}) => Promise<{
|
|
532
|
+
success: boolean;
|
|
533
|
+
data?: {
|
|
534
|
+
url: string;
|
|
535
|
+
} | undefined;
|
|
536
|
+
metadata?: {
|
|
537
|
+
icon?: string | undefined;
|
|
538
|
+
title?: string | undefined;
|
|
539
|
+
} | undefined;
|
|
540
|
+
error?: z.ZodError | string;
|
|
541
|
+
}>;
|
|
542
|
+
};
|
|
543
|
+
};
|
|
219
544
|
declare const adModels: {
|
|
220
|
-
readonly link:
|
|
221
|
-
|
|
222
|
-
|
|
545
|
+
readonly link: AdDefinition<z.ZodObject<{
|
|
546
|
+
url: z.ZodString;
|
|
547
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
548
|
+
title: z.ZodOptional<z.ZodString>;
|
|
549
|
+
description: z.ZodOptional<z.ZodString>;
|
|
550
|
+
image: z.ZodOptional<z.ZodString>;
|
|
551
|
+
}, z.core.$strip>> & {
|
|
552
|
+
process: (input: {
|
|
553
|
+
url: string;
|
|
554
|
+
}) => Promise<{
|
|
555
|
+
data: {
|
|
556
|
+
url: string;
|
|
557
|
+
};
|
|
558
|
+
metadata: {
|
|
559
|
+
title?: string | undefined;
|
|
560
|
+
description?: string | undefined;
|
|
561
|
+
image?: string | undefined;
|
|
562
|
+
} | undefined;
|
|
563
|
+
}>;
|
|
564
|
+
safeProcess: (input: {
|
|
565
|
+
url: string;
|
|
566
|
+
}) => Promise<{
|
|
567
|
+
success: boolean;
|
|
568
|
+
data?: {
|
|
569
|
+
url: string;
|
|
570
|
+
} | undefined;
|
|
571
|
+
metadata?: {
|
|
572
|
+
title?: string | undefined;
|
|
573
|
+
description?: string | undefined;
|
|
574
|
+
image?: string | undefined;
|
|
575
|
+
} | undefined;
|
|
576
|
+
error?: z.ZodError | string;
|
|
577
|
+
}>;
|
|
578
|
+
};
|
|
579
|
+
readonly cast: AdDefinition<z.ZodObject<{
|
|
580
|
+
hash: z.ZodString;
|
|
581
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
582
|
+
username: z.ZodOptional<z.ZodString>;
|
|
583
|
+
text: z.ZodOptional<z.ZodString>;
|
|
584
|
+
timestamp: z.ZodOptional<z.ZodNumber>;
|
|
585
|
+
}, z.core.$strip>> & {
|
|
586
|
+
process: (input: {
|
|
587
|
+
hash: string;
|
|
588
|
+
}) => Promise<{
|
|
589
|
+
data: {
|
|
590
|
+
hash: string;
|
|
591
|
+
};
|
|
592
|
+
metadata: {
|
|
593
|
+
username?: string | undefined;
|
|
594
|
+
text?: string | undefined;
|
|
595
|
+
timestamp?: number | undefined;
|
|
596
|
+
} | undefined;
|
|
597
|
+
}>;
|
|
598
|
+
safeProcess: (input: {
|
|
599
|
+
hash: string;
|
|
600
|
+
}) => Promise<{
|
|
601
|
+
success: boolean;
|
|
602
|
+
data?: {
|
|
603
|
+
hash: string;
|
|
604
|
+
} | undefined;
|
|
605
|
+
metadata?: {
|
|
606
|
+
username?: string | undefined;
|
|
607
|
+
text?: string | undefined;
|
|
608
|
+
timestamp?: number | undefined;
|
|
609
|
+
} | undefined;
|
|
610
|
+
error?: z.ZodError | string;
|
|
611
|
+
}>;
|
|
612
|
+
};
|
|
613
|
+
readonly miniapp: AdDefinition<z.ZodObject<{
|
|
614
|
+
url: z.ZodString;
|
|
615
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
616
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
617
|
+
title: z.ZodOptional<z.ZodString>;
|
|
618
|
+
}, z.core.$strip>> & {
|
|
619
|
+
process: (input: {
|
|
620
|
+
url: string;
|
|
621
|
+
}) => Promise<{
|
|
622
|
+
data: {
|
|
623
|
+
url: string;
|
|
624
|
+
};
|
|
625
|
+
metadata: {
|
|
626
|
+
icon?: string | undefined;
|
|
627
|
+
title?: string | undefined;
|
|
628
|
+
} | undefined;
|
|
629
|
+
}>;
|
|
630
|
+
safeProcess: (input: {
|
|
631
|
+
url: string;
|
|
632
|
+
}) => Promise<{
|
|
633
|
+
success: boolean;
|
|
634
|
+
data?: {
|
|
635
|
+
url: string;
|
|
636
|
+
} | undefined;
|
|
637
|
+
metadata?: {
|
|
638
|
+
icon?: string | undefined;
|
|
639
|
+
title?: string | undefined;
|
|
640
|
+
} | undefined;
|
|
641
|
+
error?: z.ZodError | string;
|
|
642
|
+
}>;
|
|
643
|
+
};
|
|
223
644
|
};
|
|
224
|
-
/**
|
|
225
|
-
* Get ad model for a specific type
|
|
226
|
-
*/
|
|
227
|
-
declare function getAdModel<T extends "link" | "cast" | "miniapp">(type: T): T extends "link" ? LinkAdModel : T extends "cast" ? CastAdModel : T extends "miniapp" ? MiniAppAdModel : never;
|
|
228
645
|
|
|
229
|
-
export { type
|
|
646
|
+
export { type AdDefinition, type AdType, type CastAdData, type CastAdMetadata, type LinkAdData, type LinkAdMetadata, type MiniAppAdData, type MiniAppAdMetadata, adDefinitions, adModels, adTypes, ads, castAd, defineAd, getAd, linkAd, miniappAd, processAd, safeProcessAd, validateAdData };
|