@shoppexio/storefront 1.0.41 → 1.0.42
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/headless-customer.d.ts +182 -0
- package/dist/headless-customer.d.ts.map +1 -0
- package/dist/shoppex.esm.js +2 -2
- package/dist/shoppex.esm.js.map +1 -1
- package/dist/shoppex.umd.js +1 -1
- package/dist/shoppex.umd.js.map +1 -1
- package/dist/types/api.d.ts +1 -0
- package/dist/types/api.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
export interface HeadlessCustomerClientConfig {
|
|
2
|
+
/** Shop slug or Shoppex storefront domain. */
|
|
3
|
+
shop: string;
|
|
4
|
+
/** Existing Headless Checkout publishable key (`pk_live_` / `pk_test_`). */
|
|
5
|
+
publishableKey: string;
|
|
6
|
+
/** API origin override. Defaults to https://api.shoppex.io. */
|
|
7
|
+
apiBaseUrl?: string;
|
|
8
|
+
/** Optional fetch override for tests or compatible runtimes. */
|
|
9
|
+
fetchImpl?: typeof fetch;
|
|
10
|
+
/** Optional session storage override. Defaults to browser sessionStorage. */
|
|
11
|
+
storage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
12
|
+
/** Optional persistent storage override. Defaults to browser localStorage. */
|
|
13
|
+
persistentStorage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
14
|
+
}
|
|
15
|
+
export interface HeadlessCustomerSession {
|
|
16
|
+
accessToken: string;
|
|
17
|
+
expiresAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface HeadlessCustomerVerifyOptions {
|
|
20
|
+
/** Persist the customer session across browser restarts for up to 30 days. */
|
|
21
|
+
rememberMe?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface HeadlessCustomerOrdersQuery {
|
|
24
|
+
page?: number;
|
|
25
|
+
limit?: number;
|
|
26
|
+
status?: string;
|
|
27
|
+
search?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface HeadlessCustomerDownload {
|
|
30
|
+
blob: Blob;
|
|
31
|
+
filename: string | null;
|
|
32
|
+
contentType: string | null;
|
|
33
|
+
}
|
|
34
|
+
/** Public DTOs mirror the producer-owned schemas imported above. Passing each
|
|
35
|
+
* schema into `request<T>` makes TypeScript reject drift in required fields. */
|
|
36
|
+
export interface HeadlessCustomerMe {
|
|
37
|
+
customer: {
|
|
38
|
+
id: string | null;
|
|
39
|
+
email: string;
|
|
40
|
+
name: string;
|
|
41
|
+
avatar_url: string | null;
|
|
42
|
+
joined_at: string | null;
|
|
43
|
+
};
|
|
44
|
+
shop: {
|
|
45
|
+
id: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
name: string;
|
|
48
|
+
currency: string;
|
|
49
|
+
branding: {
|
|
50
|
+
logo_url: string | null;
|
|
51
|
+
primary_color: string;
|
|
52
|
+
secondary_color: string;
|
|
53
|
+
accent_color: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface HeadlessCustomerOrderSummary {
|
|
58
|
+
uniqid: string;
|
|
59
|
+
status: string;
|
|
60
|
+
total: string;
|
|
61
|
+
totalDisplay: string | null;
|
|
62
|
+
currency: string;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
lineItems: Array<{
|
|
65
|
+
productTitle: string | null;
|
|
66
|
+
quantity: number;
|
|
67
|
+
product: {
|
|
68
|
+
attachment_imageId: {
|
|
69
|
+
cloudflareImageId: string | null;
|
|
70
|
+
} | null;
|
|
71
|
+
} | null;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
export interface HeadlessCustomerOrders {
|
|
75
|
+
invoices: HeadlessCustomerOrderSummary[];
|
|
76
|
+
pagination: {
|
|
77
|
+
page: number;
|
|
78
|
+
limit: number;
|
|
79
|
+
total: number;
|
|
80
|
+
has_more: boolean;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface HeadlessCustomerPayment {
|
|
84
|
+
gateway: string;
|
|
85
|
+
displayName: string | null;
|
|
86
|
+
cryptoGateway?: string | null;
|
|
87
|
+
blockchain: string | null;
|
|
88
|
+
cryptoAddress: string | null;
|
|
89
|
+
apmMethod: string | null;
|
|
90
|
+
}
|
|
91
|
+
export interface HeadlessCustomerOrder {
|
|
92
|
+
id: string;
|
|
93
|
+
uniqid: string;
|
|
94
|
+
status: string;
|
|
95
|
+
statusDetails: string | null;
|
|
96
|
+
total: string;
|
|
97
|
+
totalDisplay: string | null;
|
|
98
|
+
subtotal: string;
|
|
99
|
+
discount: string;
|
|
100
|
+
discountDisplay: string | null;
|
|
101
|
+
tax: string;
|
|
102
|
+
taxPercentage: string;
|
|
103
|
+
currency: string;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
updatedAt: string;
|
|
106
|
+
gatewayUpdatedAt: string | null;
|
|
107
|
+
customFields: Record<string, unknown> | null;
|
|
108
|
+
balancePaidAmount: string;
|
|
109
|
+
currentPaymentAttemptId: string | null;
|
|
110
|
+
lineItems: Array<{
|
|
111
|
+
id: string;
|
|
112
|
+
productTitle: string;
|
|
113
|
+
productType: string;
|
|
114
|
+
variantTitle: string | null;
|
|
115
|
+
unitPrice: string;
|
|
116
|
+
quantity: number;
|
|
117
|
+
total: string;
|
|
118
|
+
deliveryText: string | null;
|
|
119
|
+
deliverySummary: {
|
|
120
|
+
codes: string[];
|
|
121
|
+
links: Array<{
|
|
122
|
+
label: string;
|
|
123
|
+
value: string;
|
|
124
|
+
/** External URL for non-Shoppex links. Portal-only download URLs are removed. */
|
|
125
|
+
href?: string | null;
|
|
126
|
+
/** Pass this value to `customer.download(orderId, downloadIndex)`. */
|
|
127
|
+
downloadIndex?: number | null;
|
|
128
|
+
}>;
|
|
129
|
+
notes: string[];
|
|
130
|
+
serials: Array<{
|
|
131
|
+
value: string;
|
|
132
|
+
is_replacement: boolean;
|
|
133
|
+
is_replaced: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
} | null;
|
|
136
|
+
deliveredAt: string | null;
|
|
137
|
+
deliveryStatus: 'PENDING' | 'AWAITING_FULFILLMENT' | 'DELIVERED' | 'FAILED';
|
|
138
|
+
customFields: Record<string, unknown> | null;
|
|
139
|
+
product: {
|
|
140
|
+
uniqid: string;
|
|
141
|
+
slug: string | null;
|
|
142
|
+
serviceText: string | null;
|
|
143
|
+
attachment_imageId: {
|
|
144
|
+
cloudflareImageId: string | null;
|
|
145
|
+
} | null;
|
|
146
|
+
} | null;
|
|
147
|
+
}>;
|
|
148
|
+
currentPayment: HeadlessCustomerPayment | null;
|
|
149
|
+
payments: HeadlessCustomerPayment[];
|
|
150
|
+
}
|
|
151
|
+
export declare class HeadlessCustomerError extends Error {
|
|
152
|
+
readonly status: number;
|
|
153
|
+
readonly code?: string | null | undefined;
|
|
154
|
+
constructor(status: number, message: string, code?: string | null | undefined);
|
|
155
|
+
}
|
|
156
|
+
export declare class HeadlessCustomerClient {
|
|
157
|
+
private readonly base;
|
|
158
|
+
private readonly shop;
|
|
159
|
+
private readonly publishableKey;
|
|
160
|
+
private readonly fetchImpl;
|
|
161
|
+
private readonly storage;
|
|
162
|
+
private readonly persistentStorage;
|
|
163
|
+
private readonly storageKey;
|
|
164
|
+
private memorySession;
|
|
165
|
+
constructor(config: HeadlessCustomerClientConfig);
|
|
166
|
+
getSession(): HeadlessCustomerSession | null;
|
|
167
|
+
clearSession(): void;
|
|
168
|
+
private saveSession;
|
|
169
|
+
private url;
|
|
170
|
+
private request;
|
|
171
|
+
requestOtp(email: string): Promise<{
|
|
172
|
+
requested: boolean;
|
|
173
|
+
}>;
|
|
174
|
+
verifyOtp(email: string, otp: string, options?: HeadlessCustomerVerifyOptions): Promise<HeadlessCustomerSession>;
|
|
175
|
+
me(): Promise<HeadlessCustomerMe>;
|
|
176
|
+
orders(options?: HeadlessCustomerOrdersQuery): Promise<HeadlessCustomerOrders>;
|
|
177
|
+
order(id: string): Promise<HeadlessCustomerOrder>;
|
|
178
|
+
download(orderId: string, fileIndex: number): Promise<HeadlessCustomerDownload>;
|
|
179
|
+
logout(): Promise<void>;
|
|
180
|
+
}
|
|
181
|
+
export declare function createCustomerClient(config: HeadlessCustomerClientConfig): HeadlessCustomerClient;
|
|
182
|
+
//# sourceMappingURL=headless-customer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless-customer.d.ts","sourceRoot":"","sources":["../src/headless-customer.ts"],"names":[],"mappings":"AAkCA,MAAM,WAAW,4BAA4B;IAC3C,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC;IAC9D,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC;CACzE;AAED,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,6BAA6B;IAC5C,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;gFACgF;AAChF,MAAM,WAA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