@farcaster/snap 1.4.1 → 1.5.1
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/colors.d.ts +32 -0
- package/dist/colors.js +64 -0
- package/dist/constants.d.ts +12 -35
- package/dist/constants.js +19 -67
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/schemas.d.ts +143 -10
- package/dist/schemas.js +140 -32
- package/dist/server/parseRequest.d.ts +6 -0
- package/dist/server/parseRequest.js +1 -2
- package/dist/ui/bar-chart.js +2 -1
- package/dist/ui/button-group.d.ts +10 -2
- package/dist/ui/button-group.js +12 -4
- package/dist/ui/button.d.ts +6 -4
- package/dist/ui/button.js +2 -1
- package/dist/ui/catalog.d.ts +17 -9
- package/dist/ui/catalog.js +7 -4
- package/dist/ui/group.d.ts +0 -1
- package/dist/ui/group.js +2 -1
- package/dist/ui/progress.js +1 -1
- package/dist/ui/schema.js +1 -1
- package/dist/ui/spacer.d.ts +1 -1
- package/dist/ui/spacer.js +2 -2
- package/dist/ui/toggle.d.ts +1 -1
- package/dist/ui/toggle.js +1 -1
- package/package.json +1 -1
- package/src/colors.ts +73 -0
- package/src/constants.ts +22 -77
- package/src/index.ts +14 -2
- package/src/schemas.ts +181 -43
- package/src/server/parseRequest.ts +8 -2
- package/src/ui/bar-chart.ts +2 -5
- package/src/ui/button-group.ts +22 -9
- package/src/ui/button.ts +2 -1
- package/src/ui/catalog.ts +8 -4
- package/src/ui/group.ts +2 -1
- package/src/ui/progress.ts +1 -1
- package/src/ui/schema.ts +1 -1
- package/src/ui/spacer.ts +2 -2
- package/src/ui/toggle.ts +1 -1
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named color palette for snaps. Snap authors specify a name; the client maps
|
|
3
|
+
* it to a hex value appropriate for its current light/dark mode.
|
|
4
|
+
*
|
|
5
|
+
* Light-mode hex values (used by emulator):
|
|
6
|
+
* gray=#8F8F8F blue=#006BFF red=#FC0036 amber=#FFAE00
|
|
7
|
+
* green=#28A948 teal=#00AC96 purple=#8B5CF6 pink=#F32782
|
|
8
|
+
*
|
|
9
|
+
* Dark-mode hex values (for reference; client-owned):
|
|
10
|
+
* gray=#8F8F8F blue=#006FFE red=#F13342 amber=#FFAE00
|
|
11
|
+
* green=#00AC3A teal=#00AA96 purple=#A78BFA pink=#F12B82
|
|
12
|
+
*/
|
|
13
|
+
export declare const PALETTE_COLOR: {
|
|
14
|
+
readonly gray: "gray";
|
|
15
|
+
readonly blue: "blue";
|
|
16
|
+
readonly red: "red";
|
|
17
|
+
readonly amber: "amber";
|
|
18
|
+
readonly green: "green";
|
|
19
|
+
readonly teal: "teal";
|
|
20
|
+
readonly purple: "purple";
|
|
21
|
+
readonly pink: "pink";
|
|
22
|
+
};
|
|
23
|
+
export declare const PALETTE_COLOR_ACCENT: "accent";
|
|
24
|
+
export declare const DEFAULT_THEME_ACCENT: "purple";
|
|
25
|
+
export declare const PALETTE_COLOR_VALUES: readonly ["gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
|
26
|
+
export type PaletteColor = (typeof PALETTE_COLOR_VALUES)[number];
|
|
27
|
+
/** Light-mode hex for each palette color (emulator / reference client). */
|
|
28
|
+
export declare const PALETTE_LIGHT_HEX: Record<PaletteColor, string>;
|
|
29
|
+
/** Dark-mode hex for each palette color (reference). */
|
|
30
|
+
export declare const PALETTE_DARK_HEX: Record<PaletteColor, string>;
|
|
31
|
+
export declare const PROGRESS_COLOR_VALUES: readonly ["accent", "gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
|
32
|
+
export declare const BAR_CHART_COLOR_VALUES: readonly ["accent", "gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
package/dist/colors.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named color palette for snaps. Snap authors specify a name; the client maps
|
|
3
|
+
* it to a hex value appropriate for its current light/dark mode.
|
|
4
|
+
*
|
|
5
|
+
* Light-mode hex values (used by emulator):
|
|
6
|
+
* gray=#8F8F8F blue=#006BFF red=#FC0036 amber=#FFAE00
|
|
7
|
+
* green=#28A948 teal=#00AC96 purple=#8B5CF6 pink=#F32782
|
|
8
|
+
*
|
|
9
|
+
* Dark-mode hex values (for reference; client-owned):
|
|
10
|
+
* gray=#8F8F8F blue=#006FFE red=#F13342 amber=#FFAE00
|
|
11
|
+
* green=#00AC3A teal=#00AA96 purple=#A78BFA pink=#F12B82
|
|
12
|
+
*/
|
|
13
|
+
export const PALETTE_COLOR = {
|
|
14
|
+
gray: "gray",
|
|
15
|
+
blue: "blue",
|
|
16
|
+
red: "red",
|
|
17
|
+
amber: "amber",
|
|
18
|
+
green: "green",
|
|
19
|
+
teal: "teal",
|
|
20
|
+
purple: "purple",
|
|
21
|
+
pink: "pink",
|
|
22
|
+
};
|
|
23
|
+
export const PALETTE_COLOR_ACCENT = "accent";
|
|
24
|
+
export const DEFAULT_THEME_ACCENT = PALETTE_COLOR.purple;
|
|
25
|
+
export const PALETTE_COLOR_VALUES = [
|
|
26
|
+
PALETTE_COLOR.gray,
|
|
27
|
+
PALETTE_COLOR.blue,
|
|
28
|
+
PALETTE_COLOR.red,
|
|
29
|
+
PALETTE_COLOR.amber,
|
|
30
|
+
PALETTE_COLOR.green,
|
|
31
|
+
PALETTE_COLOR.teal,
|
|
32
|
+
PALETTE_COLOR.purple,
|
|
33
|
+
PALETTE_COLOR.pink,
|
|
34
|
+
];
|
|
35
|
+
/** Light-mode hex for each palette color (emulator / reference client). */
|
|
36
|
+
export const PALETTE_LIGHT_HEX = {
|
|
37
|
+
gray: "#8F8F8F",
|
|
38
|
+
blue: "#006BFF",
|
|
39
|
+
red: "#FC0036",
|
|
40
|
+
amber: "#FFAE00",
|
|
41
|
+
green: "#28A948",
|
|
42
|
+
teal: "#00AC96",
|
|
43
|
+
purple: "#8B5CF6",
|
|
44
|
+
pink: "#F32782",
|
|
45
|
+
};
|
|
46
|
+
/** Dark-mode hex for each palette color (reference). */
|
|
47
|
+
export const PALETTE_DARK_HEX = {
|
|
48
|
+
gray: "#8F8F8F",
|
|
49
|
+
blue: "#006FFE",
|
|
50
|
+
red: "#F13342",
|
|
51
|
+
amber: "#FFAE00",
|
|
52
|
+
green: "#00AC3A",
|
|
53
|
+
teal: "#00AA96",
|
|
54
|
+
purple: "#A78BFA",
|
|
55
|
+
pink: "#F12B82",
|
|
56
|
+
};
|
|
57
|
+
export const PROGRESS_COLOR_VALUES = [
|
|
58
|
+
PALETTE_COLOR_ACCENT,
|
|
59
|
+
...PALETTE_COLOR_VALUES,
|
|
60
|
+
];
|
|
61
|
+
export const BAR_CHART_COLOR_VALUES = [
|
|
62
|
+
PALETTE_COLOR_ACCENT,
|
|
63
|
+
...PALETTE_COLOR_VALUES,
|
|
64
|
+
];
|
package/dist/constants.d.ts
CHANGED
|
@@ -38,40 +38,11 @@ export declare const SPACER_SIZE: {
|
|
|
38
38
|
readonly large: "large";
|
|
39
39
|
};
|
|
40
40
|
export declare const SPACER_SIZE_VALUES: readonly ["small", "medium", "large"];
|
|
41
|
-
/**
|
|
42
|
-
* Named color palette for snaps. Snap authors specify a name; the client maps
|
|
43
|
-
* it to a hex value appropriate for its current light/dark mode.
|
|
44
|
-
*
|
|
45
|
-
* Light-mode hex values (used by emulator):
|
|
46
|
-
* gray=#8F8F8F blue=#006BFF red=#FC0036 amber=#FFAE00
|
|
47
|
-
* green=#28A948 teal=#00AC96 purple=#8B5CF6 pink=#F32782
|
|
48
|
-
*
|
|
49
|
-
* Dark-mode hex values (for reference; client-owned):
|
|
50
|
-
* gray=#8F8F8F blue=#006FFE red=#F13342 amber=#FFAE00
|
|
51
|
-
* green=#00AC3A teal=#00AA96 purple=#A78BFA pink=#F12B82
|
|
52
|
-
*/
|
|
53
|
-
export declare const PALETTE_COLOR: {
|
|
54
|
-
readonly gray: "gray";
|
|
55
|
-
readonly blue: "blue";
|
|
56
|
-
readonly red: "red";
|
|
57
|
-
readonly amber: "amber";
|
|
58
|
-
readonly green: "green";
|
|
59
|
-
readonly teal: "teal";
|
|
60
|
-
readonly purple: "purple";
|
|
61
|
-
readonly pink: "pink";
|
|
62
|
-
};
|
|
63
|
-
export declare const PALETTE_COLOR_ACCENT: "accent";
|
|
64
|
-
export declare const PALETTE_COLOR_VALUES: readonly ["gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
|
65
|
-
export type PaletteColor = (typeof PALETTE_COLOR_VALUES)[number];
|
|
66
|
-
/** Light-mode hex for each palette color (emulator / reference client). */
|
|
67
|
-
export declare const PALETTE_LIGHT_HEX: Record<PaletteColor, string>;
|
|
68
|
-
/** Dark-mode hex for each palette color (reference). */
|
|
69
|
-
export declare const PALETTE_DARK_HEX: Record<PaletteColor, string>;
|
|
70
|
-
export declare const PROGRESS_COLOR_VALUES: readonly ["accent", "gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
|
71
41
|
export declare const LIST_STYLE_VALUES: readonly ["ordered", "unordered", "plain"];
|
|
72
42
|
export declare const DEFAULT_LIST_STYLE: "ordered";
|
|
73
43
|
export declare const GRID_CELL_SIZE_VALUES: readonly ["auto", "square"];
|
|
74
44
|
export declare const GRID_GAP_VALUES: readonly ["none", "small", "medium"];
|
|
45
|
+
export declare const DEFAULT_GRID_GAP: "small";
|
|
75
46
|
export declare const BUTTON_GROUP_STYLE: {
|
|
76
47
|
readonly row: "row";
|
|
77
48
|
readonly stack: "stack";
|
|
@@ -82,9 +53,18 @@ export declare const BUTTON_ACTION: {
|
|
|
82
53
|
readonly post: "post";
|
|
83
54
|
readonly link: "link";
|
|
84
55
|
readonly mini_app: "mini_app";
|
|
85
|
-
readonly
|
|
56
|
+
readonly client: "client";
|
|
57
|
+
};
|
|
58
|
+
export declare const BUTTON_ACTION_VALUES: readonly ["post", "link", "mini_app", "client"];
|
|
59
|
+
export declare const CLIENT_ACTION: {
|
|
60
|
+
readonly view_cast: "view_cast";
|
|
61
|
+
readonly view_profile: "view_profile";
|
|
62
|
+
readonly compose_cast: "compose_cast";
|
|
63
|
+
readonly view_token: "view_token";
|
|
64
|
+
readonly send_token: "send_token";
|
|
65
|
+
readonly swap_token: "swap_token";
|
|
86
66
|
};
|
|
87
|
-
export declare const
|
|
67
|
+
export declare const CLIENT_ACTION_VALUES: readonly ["view_cast", "view_profile", "compose_cast", "view_token", "send_token", "swap_token"];
|
|
88
68
|
export declare const BUTTON_STYLE: {
|
|
89
69
|
readonly primary: "primary";
|
|
90
70
|
readonly secondary: "secondary";
|
|
@@ -92,7 +72,6 @@ export declare const BUTTON_STYLE: {
|
|
|
92
72
|
export declare const BUTTON_STYLE_VALUES: readonly ["primary", "secondary"];
|
|
93
73
|
export declare const BUTTON_LAYOUT_VALUES: readonly ["stack", "row", "grid"];
|
|
94
74
|
export declare const DEFAULT_BUTTON_LAYOUT: "stack";
|
|
95
|
-
export declare const BAR_CHART_COLOR_VALUES: readonly ["accent", "gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
|
96
75
|
export declare const EFFECT_VALUES: readonly ["confetti"];
|
|
97
76
|
export declare const GROUP_LAYOUT_VALUES: readonly ["row"];
|
|
98
77
|
/** Only valid as `page.elements`: vertical container for the page body (matches json-render trees). */
|
|
@@ -119,8 +98,6 @@ export declare const HTTPS_PREFIX: "https://";
|
|
|
119
98
|
export declare const HTTP_PREFIX: "http://";
|
|
120
99
|
/** 6-digit hex only (#RRGGBB); used for grid cell backgrounds (free hex). */
|
|
121
100
|
export declare const HEX_COLOR_6_RE: RegExp;
|
|
122
|
-
/** Default snap accent when `page.theme` or `page.theme.accent` is omitted (SPEC.md). */
|
|
123
|
-
export declare const DEFAULT_THEME_ACCENT: "purple";
|
|
124
101
|
export declare const TEXT_CONTENT_MAX: {
|
|
125
102
|
readonly title: 80;
|
|
126
103
|
readonly body: 160;
|
package/dist/constants.js
CHANGED
|
@@ -53,69 +53,11 @@ export const SPACER_SIZE_VALUES = [
|
|
|
53
53
|
SPACER_SIZE.medium,
|
|
54
54
|
SPACER_SIZE.large,
|
|
55
55
|
];
|
|
56
|
-
/**
|
|
57
|
-
* Named color palette for snaps. Snap authors specify a name; the client maps
|
|
58
|
-
* it to a hex value appropriate for its current light/dark mode.
|
|
59
|
-
*
|
|
60
|
-
* Light-mode hex values (used by emulator):
|
|
61
|
-
* gray=#8F8F8F blue=#006BFF red=#FC0036 amber=#FFAE00
|
|
62
|
-
* green=#28A948 teal=#00AC96 purple=#8B5CF6 pink=#F32782
|
|
63
|
-
*
|
|
64
|
-
* Dark-mode hex values (for reference; client-owned):
|
|
65
|
-
* gray=#8F8F8F blue=#006FFE red=#F13342 amber=#FFAE00
|
|
66
|
-
* green=#00AC3A teal=#00AA96 purple=#A78BFA pink=#F12B82
|
|
67
|
-
*/
|
|
68
|
-
export const PALETTE_COLOR = {
|
|
69
|
-
gray: "gray",
|
|
70
|
-
blue: "blue",
|
|
71
|
-
red: "red",
|
|
72
|
-
amber: "amber",
|
|
73
|
-
green: "green",
|
|
74
|
-
teal: "teal",
|
|
75
|
-
purple: "purple",
|
|
76
|
-
pink: "pink",
|
|
77
|
-
};
|
|
78
|
-
export const PALETTE_COLOR_ACCENT = "accent";
|
|
79
|
-
export const PALETTE_COLOR_VALUES = [
|
|
80
|
-
PALETTE_COLOR.gray,
|
|
81
|
-
PALETTE_COLOR.blue,
|
|
82
|
-
PALETTE_COLOR.red,
|
|
83
|
-
PALETTE_COLOR.amber,
|
|
84
|
-
PALETTE_COLOR.green,
|
|
85
|
-
PALETTE_COLOR.teal,
|
|
86
|
-
PALETTE_COLOR.purple,
|
|
87
|
-
PALETTE_COLOR.pink,
|
|
88
|
-
];
|
|
89
|
-
/** Light-mode hex for each palette color (emulator / reference client). */
|
|
90
|
-
export const PALETTE_LIGHT_HEX = {
|
|
91
|
-
gray: "#8F8F8F",
|
|
92
|
-
blue: "#006BFF",
|
|
93
|
-
red: "#FC0036",
|
|
94
|
-
amber: "#FFAE00",
|
|
95
|
-
green: "#28A948",
|
|
96
|
-
teal: "#00AC96",
|
|
97
|
-
purple: "#8B5CF6",
|
|
98
|
-
pink: "#F32782",
|
|
99
|
-
};
|
|
100
|
-
/** Dark-mode hex for each palette color (reference). */
|
|
101
|
-
export const PALETTE_DARK_HEX = {
|
|
102
|
-
gray: "#8F8F8F",
|
|
103
|
-
blue: "#006FFE",
|
|
104
|
-
red: "#F13342",
|
|
105
|
-
amber: "#FFAE00",
|
|
106
|
-
green: "#00AC3A",
|
|
107
|
-
teal: "#00AA96",
|
|
108
|
-
purple: "#A78BFA",
|
|
109
|
-
pink: "#F12B82",
|
|
110
|
-
};
|
|
111
|
-
export const PROGRESS_COLOR_VALUES = [
|
|
112
|
-
PALETTE_COLOR_ACCENT,
|
|
113
|
-
...PALETTE_COLOR_VALUES,
|
|
114
|
-
];
|
|
115
56
|
export const LIST_STYLE_VALUES = ["ordered", "unordered", "plain"];
|
|
116
57
|
export const DEFAULT_LIST_STYLE = "ordered";
|
|
117
58
|
export const GRID_CELL_SIZE_VALUES = ["auto", "square"];
|
|
118
59
|
export const GRID_GAP_VALUES = ["none", "small", "medium"];
|
|
60
|
+
export const DEFAULT_GRID_GAP = "small";
|
|
119
61
|
export const BUTTON_GROUP_STYLE = {
|
|
120
62
|
row: "row",
|
|
121
63
|
stack: "stack",
|
|
@@ -130,13 +72,29 @@ export const BUTTON_ACTION = {
|
|
|
130
72
|
post: "post",
|
|
131
73
|
link: "link",
|
|
132
74
|
mini_app: "mini_app",
|
|
133
|
-
|
|
75
|
+
client: "client",
|
|
134
76
|
};
|
|
135
77
|
export const BUTTON_ACTION_VALUES = [
|
|
136
78
|
BUTTON_ACTION.post,
|
|
137
79
|
BUTTON_ACTION.link,
|
|
138
80
|
BUTTON_ACTION.mini_app,
|
|
139
|
-
BUTTON_ACTION.
|
|
81
|
+
BUTTON_ACTION.client,
|
|
82
|
+
];
|
|
83
|
+
export const CLIENT_ACTION = {
|
|
84
|
+
view_cast: "view_cast",
|
|
85
|
+
view_profile: "view_profile",
|
|
86
|
+
compose_cast: "compose_cast",
|
|
87
|
+
view_token: "view_token",
|
|
88
|
+
send_token: "send_token",
|
|
89
|
+
swap_token: "swap_token",
|
|
90
|
+
};
|
|
91
|
+
export const CLIENT_ACTION_VALUES = [
|
|
92
|
+
CLIENT_ACTION.view_cast,
|
|
93
|
+
CLIENT_ACTION.view_profile,
|
|
94
|
+
CLIENT_ACTION.compose_cast,
|
|
95
|
+
CLIENT_ACTION.view_token,
|
|
96
|
+
CLIENT_ACTION.send_token,
|
|
97
|
+
CLIENT_ACTION.swap_token,
|
|
140
98
|
];
|
|
141
99
|
export const BUTTON_STYLE = {
|
|
142
100
|
primary: "primary",
|
|
@@ -148,10 +106,6 @@ export const BUTTON_STYLE_VALUES = [
|
|
|
148
106
|
];
|
|
149
107
|
export const BUTTON_LAYOUT_VALUES = ["stack", "row", "grid"];
|
|
150
108
|
export const DEFAULT_BUTTON_LAYOUT = BUTTON_LAYOUT_VALUES[0];
|
|
151
|
-
export const BAR_CHART_COLOR_VALUES = [
|
|
152
|
-
PALETTE_COLOR_ACCENT,
|
|
153
|
-
...PALETTE_COLOR_VALUES,
|
|
154
|
-
];
|
|
155
109
|
export const EFFECT_VALUES = ["confetti"];
|
|
156
110
|
export const GROUP_LAYOUT_VALUES = ["row"];
|
|
157
111
|
/** Only valid as `page.elements`: vertical container for the page body (matches json-render trees). */
|
|
@@ -177,8 +131,6 @@ export const HTTPS_PREFIX = "https://";
|
|
|
177
131
|
export const HTTP_PREFIX = "http://";
|
|
178
132
|
/** 6-digit hex only (#RRGGBB); used for grid cell backgrounds (free hex). */
|
|
179
133
|
export const HEX_COLOR_6_RE = /^#[0-9a-fA-F]{6}$/;
|
|
180
|
-
/** Default snap accent when `page.theme` or `page.theme.accent` is omitted (SPEC.md). */
|
|
181
|
-
export const DEFAULT_THEME_ACCENT = PALETTE_COLOR.purple;
|
|
182
134
|
export const TEXT_CONTENT_MAX = {
|
|
183
135
|
[TEXT_STYLE.title]: 80,
|
|
184
136
|
[TEXT_STYLE.body]: 160,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE,
|
|
2
|
-
export {
|
|
1
|
+
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, CLIENT_ACTION, CLIENT_ACTION_VALUES, } from "./constants.js";
|
|
2
|
+
export { DEFAULT_THEME_ACCENT, PALETTE_COLOR, PALETTE_COLOR_ACCENT, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, type PaletteColor, } from "./colors.js";
|
|
3
|
+
export { ACTION_TYPE_GET, ACTION_TYPE_POST, snapResponseSchema, firstPageResponseSchema, payloadSchema, clientActionSchema, createDefaultDataStore, type Button, type Element, type Elements, type GroupChildElement, type ClientAction, type SnapAction, type SnapPageElementInput, type SnapContext, type SnapResponse, type SnapHandlerResult, type SnapFunction, type SnapPayload, type DataStoreValue, type SnapDataStore, type SnapDataStoreOperations, } from "./schemas.js";
|
|
3
4
|
export { validateSnapResponse, validateFirstPageResponse, type ValidationResult, } from "./validator.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE,
|
|
2
|
-
export {
|
|
1
|
+
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, CLIENT_ACTION, CLIENT_ACTION_VALUES, } from "./constants.js";
|
|
2
|
+
export { DEFAULT_THEME_ACCENT, PALETTE_COLOR, PALETTE_COLOR_ACCENT, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, } from "./colors.js";
|
|
3
|
+
export { ACTION_TYPE_GET, ACTION_TYPE_POST, snapResponseSchema, firstPageResponseSchema, payloadSchema, clientActionSchema, createDefaultDataStore, } from "./schemas.js";
|
|
3
4
|
export { validateSnapResponse, validateFirstPageResponse, } from "./validator.js";
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,13 +1,74 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export declare const clientActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"view_cast">;
|
|
4
|
+
hash: z.ZodString;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
type: z.ZodLiteral<"view_profile">;
|
|
7
|
+
fid: z.ZodNumber;
|
|
8
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
9
|
+
type: z.ZodLiteral<"compose_cast">;
|
|
10
|
+
text: z.ZodOptional<z.ZodString>;
|
|
11
|
+
embeds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
parent: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"cast">;
|
|
14
|
+
hash: z.ZodString;
|
|
15
|
+
}, z.core.$strict>>;
|
|
16
|
+
channelKey: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"view_token">;
|
|
19
|
+
token: z.ZodString;
|
|
20
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
21
|
+
type: z.ZodLiteral<"send_token">;
|
|
22
|
+
token: z.ZodOptional<z.ZodString>;
|
|
23
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
24
|
+
recipientFid: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
recipientAddress: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
+
type: z.ZodLiteral<"swap_token">;
|
|
28
|
+
sellToken: z.ZodOptional<z.ZodString>;
|
|
29
|
+
buyToken: z.ZodOptional<z.ZodString>;
|
|
30
|
+
sellAmount: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strict>], "type">;
|
|
32
|
+
export type ClientAction = z.infer<typeof clientActionSchema>;
|
|
2
33
|
declare const buttonSchema: z.ZodObject<{
|
|
3
34
|
label: z.ZodString;
|
|
4
35
|
action: z.ZodEnum<{
|
|
5
36
|
post: "post";
|
|
6
37
|
link: "link";
|
|
7
38
|
mini_app: "mini_app";
|
|
8
|
-
|
|
39
|
+
client: "client";
|
|
9
40
|
}>;
|
|
10
|
-
target: z.ZodString
|
|
41
|
+
target: z.ZodOptional<z.ZodString>;
|
|
42
|
+
client_action: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"view_cast">;
|
|
44
|
+
hash: z.ZodString;
|
|
45
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"view_profile">;
|
|
47
|
+
fid: z.ZodNumber;
|
|
48
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
49
|
+
type: z.ZodLiteral<"compose_cast">;
|
|
50
|
+
text: z.ZodOptional<z.ZodString>;
|
|
51
|
+
embeds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
52
|
+
parent: z.ZodOptional<z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"cast">;
|
|
54
|
+
hash: z.ZodString;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
channelKey: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"view_token">;
|
|
59
|
+
token: z.ZodString;
|
|
60
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
61
|
+
type: z.ZodLiteral<"send_token">;
|
|
62
|
+
token: z.ZodOptional<z.ZodString>;
|
|
63
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
64
|
+
recipientFid: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
recipientAddress: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
67
|
+
type: z.ZodLiteral<"swap_token">;
|
|
68
|
+
sellToken: z.ZodOptional<z.ZodString>;
|
|
69
|
+
buyToken: z.ZodOptional<z.ZodString>;
|
|
70
|
+
sellAmount: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strict>], "type">>;
|
|
11
72
|
style: z.ZodOptional<z.ZodEnum<{
|
|
12
73
|
primary: "primary";
|
|
13
74
|
secondary: "secondary";
|
|
@@ -230,7 +291,7 @@ declare const elementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
230
291
|
auto: "auto";
|
|
231
292
|
square: "square";
|
|
232
293
|
}>>;
|
|
233
|
-
gap: z.
|
|
294
|
+
gap: z.ZodDefault<z.ZodEnum<{
|
|
234
295
|
small: "small";
|
|
235
296
|
medium: "medium";
|
|
236
297
|
none: "none";
|
|
@@ -546,7 +607,7 @@ declare const elementsSchema: z.ZodObject<{
|
|
|
546
607
|
auto: "auto";
|
|
547
608
|
square: "square";
|
|
548
609
|
}>>;
|
|
549
|
-
gap: z.
|
|
610
|
+
gap: z.ZodDefault<z.ZodEnum<{
|
|
550
611
|
small: "small";
|
|
551
612
|
medium: "medium";
|
|
552
613
|
none: "none";
|
|
@@ -885,7 +946,7 @@ export declare const snapResponseSchema: z.ZodObject<{
|
|
|
885
946
|
auto: "auto";
|
|
886
947
|
square: "square";
|
|
887
948
|
}>>;
|
|
888
|
-
gap: z.
|
|
949
|
+
gap: z.ZodDefault<z.ZodEnum<{
|
|
889
950
|
small: "small";
|
|
890
951
|
medium: "medium";
|
|
891
952
|
none: "none";
|
|
@@ -1129,9 +1190,39 @@ export declare const snapResponseSchema: z.ZodObject<{
|
|
|
1129
1190
|
post: "post";
|
|
1130
1191
|
link: "link";
|
|
1131
1192
|
mini_app: "mini_app";
|
|
1132
|
-
|
|
1193
|
+
client: "client";
|
|
1133
1194
|
}>;
|
|
1134
|
-
target: z.ZodString
|
|
1195
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1196
|
+
client_action: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1197
|
+
type: z.ZodLiteral<"view_cast">;
|
|
1198
|
+
hash: z.ZodString;
|
|
1199
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1200
|
+
type: z.ZodLiteral<"view_profile">;
|
|
1201
|
+
fid: z.ZodNumber;
|
|
1202
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1203
|
+
type: z.ZodLiteral<"compose_cast">;
|
|
1204
|
+
text: z.ZodOptional<z.ZodString>;
|
|
1205
|
+
embeds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1206
|
+
parent: z.ZodOptional<z.ZodObject<{
|
|
1207
|
+
type: z.ZodLiteral<"cast">;
|
|
1208
|
+
hash: z.ZodString;
|
|
1209
|
+
}, z.core.$strict>>;
|
|
1210
|
+
channelKey: z.ZodOptional<z.ZodString>;
|
|
1211
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1212
|
+
type: z.ZodLiteral<"view_token">;
|
|
1213
|
+
token: z.ZodString;
|
|
1214
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1215
|
+
type: z.ZodLiteral<"send_token">;
|
|
1216
|
+
token: z.ZodOptional<z.ZodString>;
|
|
1217
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
1218
|
+
recipientFid: z.ZodOptional<z.ZodNumber>;
|
|
1219
|
+
recipientAddress: z.ZodOptional<z.ZodString>;
|
|
1220
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1221
|
+
type: z.ZodLiteral<"swap_token">;
|
|
1222
|
+
sellToken: z.ZodOptional<z.ZodString>;
|
|
1223
|
+
buyToken: z.ZodOptional<z.ZodString>;
|
|
1224
|
+
sellAmount: z.ZodOptional<z.ZodString>;
|
|
1225
|
+
}, z.core.$strict>], "type">>;
|
|
1135
1226
|
style: z.ZodOptional<z.ZodEnum<{
|
|
1136
1227
|
primary: "primary";
|
|
1137
1228
|
secondary: "secondary";
|
|
@@ -1241,7 +1332,7 @@ export declare const firstPageResponseSchema: z.ZodObject<{
|
|
|
1241
1332
|
auto: "auto";
|
|
1242
1333
|
square: "square";
|
|
1243
1334
|
}>>;
|
|
1244
|
-
gap: z.
|
|
1335
|
+
gap: z.ZodDefault<z.ZodEnum<{
|
|
1245
1336
|
small: "small";
|
|
1246
1337
|
medium: "medium";
|
|
1247
1338
|
none: "none";
|
|
@@ -1485,9 +1576,39 @@ export declare const firstPageResponseSchema: z.ZodObject<{
|
|
|
1485
1576
|
post: "post";
|
|
1486
1577
|
link: "link";
|
|
1487
1578
|
mini_app: "mini_app";
|
|
1488
|
-
|
|
1579
|
+
client: "client";
|
|
1489
1580
|
}>;
|
|
1490
|
-
target: z.ZodString
|
|
1581
|
+
target: z.ZodOptional<z.ZodString>;
|
|
1582
|
+
client_action: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1583
|
+
type: z.ZodLiteral<"view_cast">;
|
|
1584
|
+
hash: z.ZodString;
|
|
1585
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1586
|
+
type: z.ZodLiteral<"view_profile">;
|
|
1587
|
+
fid: z.ZodNumber;
|
|
1588
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1589
|
+
type: z.ZodLiteral<"compose_cast">;
|
|
1590
|
+
text: z.ZodOptional<z.ZodString>;
|
|
1591
|
+
embeds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1592
|
+
parent: z.ZodOptional<z.ZodObject<{
|
|
1593
|
+
type: z.ZodLiteral<"cast">;
|
|
1594
|
+
hash: z.ZodString;
|
|
1595
|
+
}, z.core.$strict>>;
|
|
1596
|
+
channelKey: z.ZodOptional<z.ZodString>;
|
|
1597
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1598
|
+
type: z.ZodLiteral<"view_token">;
|
|
1599
|
+
token: z.ZodString;
|
|
1600
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1601
|
+
type: z.ZodLiteral<"send_token">;
|
|
1602
|
+
token: z.ZodOptional<z.ZodString>;
|
|
1603
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
1604
|
+
recipientFid: z.ZodOptional<z.ZodNumber>;
|
|
1605
|
+
recipientAddress: z.ZodOptional<z.ZodString>;
|
|
1606
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1607
|
+
type: z.ZodLiteral<"swap_token">;
|
|
1608
|
+
sellToken: z.ZodOptional<z.ZodString>;
|
|
1609
|
+
buyToken: z.ZodOptional<z.ZodString>;
|
|
1610
|
+
sellAmount: z.ZodOptional<z.ZodString>;
|
|
1611
|
+
}, z.core.$strict>], "type">>;
|
|
1491
1612
|
style: z.ZodOptional<z.ZodEnum<{
|
|
1492
1613
|
primary: "primary";
|
|
1493
1614
|
secondary: "secondary";
|
|
@@ -1536,9 +1657,21 @@ export declare const snapActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1536
1657
|
type: z.ZodLiteral<"post">;
|
|
1537
1658
|
}, z.core.$strict>], "type">;
|
|
1538
1659
|
export type SnapAction = z.infer<typeof snapActionSchema>;
|
|
1660
|
+
export type DataStoreValue = string | number | boolean | null | DataStoreValue[] | {
|
|
1661
|
+
[key: string]: DataStoreValue;
|
|
1662
|
+
};
|
|
1663
|
+
export type SnapDataStoreOperations = {
|
|
1664
|
+
get(key: string): Promise<DataStoreValue | null>;
|
|
1665
|
+
set(key: string, value: DataStoreValue): Promise<void>;
|
|
1666
|
+
};
|
|
1667
|
+
export type SnapDataStore = SnapDataStoreOperations & {
|
|
1668
|
+
withLock<T>(fn: (store: SnapDataStoreOperations) => Promise<T>): Promise<T>;
|
|
1669
|
+
};
|
|
1670
|
+
export declare function createDefaultDataStore(): SnapDataStore;
|
|
1539
1671
|
export type SnapContext = {
|
|
1540
1672
|
action: SnapAction;
|
|
1541
1673
|
request: Request;
|
|
1674
|
+
data: SnapDataStore;
|
|
1542
1675
|
};
|
|
1543
1676
|
export type SnapFunction = (ctx: SnapContext) => Promise<SnapHandlerResult>;
|
|
1544
1677
|
export {};
|