@adland/data 0.2.0 → 0.3.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/.eslintrc.js +0 -1
- package/CHANGELOG.md +6 -0
- package/package.json +2 -2
- package/src/index.ts +0 -2
- package/src/schemas/index.ts +36 -16
- package/src/types/index.ts +1 -7
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adland/data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./package.json": "./package.json"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"zod": "^
|
|
21
|
+
"zod": "^4.1.12"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20",
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ export type {
|
|
|
6
6
|
CastAd,
|
|
7
7
|
MiniAppAd,
|
|
8
8
|
TokenAd,
|
|
9
|
-
SwapAd,
|
|
10
9
|
} from "./types";
|
|
11
10
|
|
|
12
11
|
// Export Zod schemas
|
|
@@ -15,7 +14,6 @@ export {
|
|
|
15
14
|
castAdSchema,
|
|
16
15
|
miniappAdSchema,
|
|
17
16
|
tokenAdSchema,
|
|
18
|
-
swapAdSchema,
|
|
19
17
|
adDataSchema,
|
|
20
18
|
adSchemas,
|
|
21
19
|
getAdSchema,
|
package/src/schemas/index.ts
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Link ad data schema - basic link
|
|
5
|
+
*/
|
|
6
|
+
const linkAdDataSchema = z.object({
|
|
7
|
+
url: z.string().url("Must be a valid URL").nonoptional("URL is required"),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Cast ad data schema - link to a Farcaster cast
|
|
12
|
+
*/
|
|
13
|
+
const castAdDataSchema = z.object({
|
|
14
|
+
url: z.string().url("Must be a valid URL").nonoptional("URL is required"),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* MiniApp ad data schema - link to a Farcaster mini app
|
|
19
|
+
*/
|
|
20
|
+
const miniappAdDataSchema = z.object({
|
|
21
|
+
url: z.string().url("Must be a valid URL").nonoptional("URL is required"),
|
|
22
|
+
icon: z.string().url("Must be a valid URL").optional(),
|
|
23
|
+
name: z.string().optional(),
|
|
24
|
+
creatorPfpUrl: z.string().url("Must be a valid URL").optional(),
|
|
25
|
+
creatorUsername: z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Token ad data schema - token information
|
|
30
|
+
*/
|
|
31
|
+
const tokenAdDataSchema = z.object({
|
|
32
|
+
token: z.string().min(1, "Token is required"),
|
|
33
|
+
});
|
|
34
|
+
|
|
3
35
|
/**
|
|
4
36
|
* Link ad schema - basic link
|
|
5
37
|
*/
|
|
6
38
|
export const linkAdSchema = z.object({
|
|
7
39
|
type: z.literal("link"),
|
|
8
|
-
|
|
40
|
+
data: linkAdDataSchema,
|
|
9
41
|
});
|
|
10
42
|
|
|
11
43
|
/**
|
|
@@ -13,7 +45,7 @@ export const linkAdSchema = z.object({
|
|
|
13
45
|
*/
|
|
14
46
|
export const castAdSchema = z.object({
|
|
15
47
|
type: z.literal("cast"),
|
|
16
|
-
|
|
48
|
+
data: castAdDataSchema,
|
|
17
49
|
});
|
|
18
50
|
|
|
19
51
|
/**
|
|
@@ -21,7 +53,7 @@ export const castAdSchema = z.object({
|
|
|
21
53
|
*/
|
|
22
54
|
export const miniappAdSchema = z.object({
|
|
23
55
|
type: z.literal("miniapp"),
|
|
24
|
-
|
|
56
|
+
data: miniappAdDataSchema,
|
|
25
57
|
});
|
|
26
58
|
|
|
27
59
|
/**
|
|
@@ -29,17 +61,7 @@ export const miniappAdSchema = z.object({
|
|
|
29
61
|
*/
|
|
30
62
|
export const tokenAdSchema = z.object({
|
|
31
63
|
type: z.literal("token"),
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Swap ad schema - token swap information
|
|
37
|
-
*/
|
|
38
|
-
export const swapAdSchema = z.object({
|
|
39
|
-
type: z.literal("swap"),
|
|
40
|
-
fromToken: z.string().min(1, "From token is required"),
|
|
41
|
-
toToken: z.string().min(1, "To token is required"),
|
|
42
|
-
amount: z.string().optional(),
|
|
64
|
+
data: tokenAdDataSchema,
|
|
43
65
|
});
|
|
44
66
|
|
|
45
67
|
/**
|
|
@@ -50,7 +72,6 @@ export const adDataSchema = z.discriminatedUnion("type", [
|
|
|
50
72
|
castAdSchema,
|
|
51
73
|
miniappAdSchema,
|
|
52
74
|
tokenAdSchema,
|
|
53
|
-
swapAdSchema,
|
|
54
75
|
]);
|
|
55
76
|
|
|
56
77
|
/**
|
|
@@ -61,7 +82,6 @@ export const adSchemas = {
|
|
|
61
82
|
cast: castAdSchema,
|
|
62
83
|
miniapp: miniappAdSchema,
|
|
63
84
|
token: tokenAdSchema,
|
|
64
|
-
swap: swapAdSchema,
|
|
65
85
|
} as const;
|
|
66
86
|
|
|
67
87
|
/**
|
package/src/types/index.ts
CHANGED
|
@@ -4,14 +4,13 @@ import {
|
|
|
4
4
|
castAdSchema,
|
|
5
5
|
miniappAdSchema,
|
|
6
6
|
tokenAdSchema,
|
|
7
|
-
swapAdSchema,
|
|
8
7
|
adDataSchema,
|
|
9
8
|
} from "../schemas";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Base ad type
|
|
13
12
|
*/
|
|
14
|
-
export type AdType = "link" | "cast" | "miniapp" | "token"
|
|
13
|
+
export type AdType = "link" | "cast" | "miniapp" | "token";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Link ad type - basic link
|
|
@@ -33,11 +32,6 @@ export type MiniAppAd = z.infer<typeof miniappAdSchema>;
|
|
|
33
32
|
*/
|
|
34
33
|
export type TokenAd = z.infer<typeof tokenAdSchema>;
|
|
35
34
|
|
|
36
|
-
/**
|
|
37
|
-
* Swap ad type - token swap information
|
|
38
|
-
*/
|
|
39
|
-
export type SwapAd = z.infer<typeof swapAdSchema>;
|
|
40
|
-
|
|
41
35
|
/**
|
|
42
36
|
* Union type of all ad types
|
|
43
37
|
*/
|