@amos.com/amos-js 0.1.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/src/types.ts ADDED
@@ -0,0 +1,171 @@
1
+ import type { components } from "@amos.com/node";
2
+
3
+ /**
4
+ * CSS custom properties that control the appearance of the embedded
5
+ * Amos iframe UI. Only the variables you provide are sent; omitted
6
+ * variables keep their defaults.
7
+ */
8
+ export type ThemeVariable =
9
+ /*
10
+ * Page body and base surface color.
11
+ *
12
+ * Default: oklch(1 0 0) (white)
13
+ */
14
+ | "--background"
15
+ /*
16
+ * Default text color applied to the body.
17
+ *
18
+ * Default: oklch(0.145 0 0) (near-black)
19
+ */
20
+ | "--foreground"
21
+ /*
22
+ * Default button fill and input text-selection highlight.
23
+ *
24
+ * Default: oklch(0.205 0 0)
25
+ */
26
+ | "--primary"
27
+ /*
28
+ * Text on primary-colored surfaces (buttons, selections).
29
+ *
30
+ * Default: oklch(0.985 0 0)
31
+ */
32
+ | "--primary-foreground"
33
+ /*
34
+ * Secondary button fill.
35
+ *
36
+ * Default: oklch(0.97 0 0)
37
+ */
38
+ | "--secondary"
39
+ /*
40
+ * Text on secondary-colored surfaces.
41
+ *
42
+ * Default: oklch(0.205 0 0)
43
+ */
44
+ | "--secondary-foreground"
45
+ /*
46
+ * Placeholder text, helper labels, and muted icons.
47
+ *
48
+ * Default: oklch(0.556 0 0)
49
+ */
50
+ | "--muted-foreground"
51
+ /*
52
+ * Hover/focus highlight for interactive items (buttons, dropdown rows,
53
+ * skeleton pulse).
54
+ *
55
+ * Default: oklch(0.97 0 0)
56
+ */
57
+ | "--accent"
58
+ /*
59
+ * Text color on accent-highlighted items.
60
+ *
61
+ * Default: oklch(0.205 0 0)
62
+ */
63
+ | "--accent-foreground"
64
+ /*
65
+ * Error/invalid state borders and icons.
66
+ *
67
+ * Default: oklch(0.577 0.245 27.325)
68
+ */
69
+ | "--destructive"
70
+ /*
71
+ * General border color applied to all elements via the base layer.
72
+ *
73
+ * Default: oklch(0.922 0 0)
74
+ */
75
+ | "--border"
76
+ /*
77
+ * Input field border color.
78
+ *
79
+ * Default: oklch(0.922 0 0)
80
+ */
81
+ | "--input"
82
+ /*
83
+ * Focus ring and outline color for inputs and buttons.
84
+ *
85
+ * Default: oklch(0.708 0 0)
86
+ */
87
+ | "--ring"
88
+ /*
89
+ * Base border-radius; derived into --radius-sm/md/lg/xl.
90
+ *
91
+ * Default: 0.625rem
92
+ */
93
+ | "--radius";
94
+
95
+ /**
96
+ * Appearance overrides for the embedded Amos iframe UI.
97
+ */
98
+ export type Appearance = {
99
+ themeVariables?: Partial<Record<ThemeVariable, string>>;
100
+ };
101
+
102
+ /**
103
+ * Typed `postMessage` payloads exchanged between the host page and the
104
+ * embedded Amos iframe.
105
+ */
106
+ export type Message =
107
+ | {
108
+ type: "IFRAME_READY";
109
+ }
110
+ | {
111
+ type: "PARENT_ACKNOWLEDGED_IFRAME_READY";
112
+ }
113
+ | {
114
+ type: "UPDATE_HEIGHT";
115
+ height: string;
116
+ }
117
+ | {
118
+ type: "UPDATE_AMOUNT";
119
+ amount: string;
120
+ }
121
+ | {
122
+ type: "UPDATE_MERCHANT_NAME";
123
+ merchantName: string;
124
+ }
125
+ | {
126
+ type: "UPDATE_APPEARANCE";
127
+ appearance: Appearance;
128
+ }
129
+ | {
130
+ type: "VALIDATE_FORM";
131
+ requestId: string;
132
+ isValid?: boolean;
133
+ }
134
+ | {
135
+ type: "CREATE_PAYMENT_INTENT";
136
+ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
137
+ customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
138
+ }
139
+ | ({
140
+ type: "CONFIRM_PAYMENT_INTENT";
141
+ } & Pick<components["schemas"]["PaymentIntent"], "id"> &
142
+ Pick<components["schemas"]["EmbedToken"], "token">)
143
+ | ({
144
+ type: "CONFIRM_SETUP_INTENT";
145
+ } & Pick<components["schemas"]["SetupIntent"], "id"> &
146
+ Pick<components["schemas"]["EmbedToken"], "token">)
147
+ | {
148
+ type: "PAYMENT_INTENT_CONFIRMATION_SUCCEEDED";
149
+ paymentIntent: components["schemas"]["PaymentIntent"];
150
+ }
151
+ | {
152
+ type: "SETUP_INTENT_CONFIRMATION_SUCCEEDED";
153
+ setupIntent: components["schemas"]["SetupIntent"];
154
+ }
155
+ | {
156
+ type: "CONFIRMATION_FAILED";
157
+ errorMessage: string;
158
+ }
159
+ | {
160
+ type: "UPDATED_APPEARANCE";
161
+ };
162
+
163
+ /**
164
+ * Identity helper that brands an object as a typed `Message`.
165
+ *
166
+ * Useful when constructing `postMessage` payloads to ensure they conform
167
+ * to the schema understood by the embedded Amos iframe.
168
+ */
169
+ export function createMessage(message: Message): Message {
170
+ return message;
171
+ }