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