@01.software/sdk 0.30.1 → 0.32.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/README.md +160 -48
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +91 -62
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +6 -6
- package/dist/client.d.ts +6 -6
- package/dist/client.js +91 -62
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-QPbwimkU.d.cts → collection-client-CORhppPb.d.cts} +3 -3
- package/dist/{collection-client-B9d9kr1d.d.ts → collection-client-DPGXnhoF.d.ts} +3 -3
- package/dist/{const-VZuk2tWc.d.cts → const-Brk2Ff0q.d.cts} +4 -4
- package/dist/{const-B75IFDRi.d.ts → const-DcY2_z9O.d.ts} +4 -4
- package/dist/{index-B2WbhEgT.d.cts → index-BGEhoDUs.d.cts} +1 -1
- package/dist/{index-B2WbhEgT.d.ts → index-BGEhoDUs.d.ts} +1 -1
- package/dist/index.cjs +214 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +214 -66
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DPjO_IbQ.d.cts → payload-types-DVK1QCeU.d.cts} +793 -531
- package/dist/{payload-types-DPjO_IbQ.d.ts → payload-types-DVK1QCeU.d.ts} +793 -531
- package/dist/query.cjs +63 -13
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +17 -17
- package/dist/query.d.ts +17 -17
- package/dist/query.js +63 -13
- package/dist/query.js.map +1 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/server.cjs +176 -18
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +124 -7
- package/dist/server.d.ts +124 -7
- package/dist/server.js +176 -18
- package/dist/server.js.map +1 -1
- package/dist/{types-BwT0eeaz.d.cts → types-ByMrR_Z_.d.cts} +6 -2
- package/dist/{types-DuSKPiY5.d.ts → types-CAkWqIr6.d.cts} +82 -9
- package/dist/{types-Dlb2mwpX.d.cts → types-CYMSBkJC.d.ts} +82 -9
- package/dist/{types-1fBLrYU7.d.ts → types-DUPC7Xn6.d.ts} +6 -2
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.cjs +48 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +73 -4
- package/dist/webhook.d.ts +73 -4
- package/dist/webhook.js +48 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse } from './types-
|
|
1
|
+
import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse } from './types-CAkWqIr6.cjs';
|
|
2
2
|
import { GenerateMetadataOptions, Metadata } from './metadata.cjs';
|
|
3
|
-
import { c as ServerCollection, P as PublicCollection } from './const-
|
|
4
|
-
import { C as CollectionType } from './types-
|
|
3
|
+
import { c as ServerCollection, P as PublicCollection } from './const-Brk2Ff0q.cjs';
|
|
4
|
+
import { C as CollectionType } from './types-ByMrR_Z_.cjs';
|
|
5
5
|
|
|
6
6
|
interface FetchOptions extends RequestInit {
|
|
7
7
|
apiUrl?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse } from './types-
|
|
1
|
+
import { D as DebugConfig, R as RetryConfig, A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse } from './types-CYMSBkJC.js';
|
|
2
2
|
import { GenerateMetadataOptions, Metadata } from './metadata.js';
|
|
3
|
-
import { c as ServerCollection, P as PublicCollection } from './const-
|
|
4
|
-
import { C as CollectionType } from './types-
|
|
3
|
+
import { c as ServerCollection, P as PublicCollection } from './const-DcY2_z9O.js';
|
|
4
|
+
import { C as CollectionType } from './types-DUPC7Xn6.js';
|
|
5
5
|
|
|
6
6
|
interface FetchOptions extends RequestInit {
|
|
7
7
|
apiUrl?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as Config } from './payload-types-DVK1QCeU.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection type derived from Payload Config.
|
|
@@ -9,12 +9,12 @@ type Collection = keyof Config['collections'];
|
|
|
9
9
|
* Internal collections that should not be exposed via SDK.
|
|
10
10
|
* Includes Payload system collections and admin-only collections.
|
|
11
11
|
*/
|
|
12
|
-
declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "inventory-reservations", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
|
|
12
|
+
declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "inventory-reservations", "product-collection-items", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
|
|
13
13
|
/**
|
|
14
14
|
* Array of all public collection names for runtime use (e.g., Zod enum validation).
|
|
15
15
|
* This is the single source of truth for which collections are publicly accessible via SDK.
|
|
16
16
|
*/
|
|
17
|
-
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-
|
|
17
|
+
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
|
|
18
18
|
/**
|
|
19
19
|
* Server-auth collection names for runtime use. These collections are safe for
|
|
20
20
|
* secret-key/PAT SDK and MCP server tools, but must not appear in browser or
|
|
@@ -26,7 +26,7 @@ declare const SERVER_ONLY_COLLECTIONS: readonly ["customer-groups", "reports", "
|
|
|
26
26
|
* Derived from the COLLECTIONS array (single source of truth).
|
|
27
27
|
*/
|
|
28
28
|
type PublicCollection = (typeof COLLECTIONS)[number];
|
|
29
|
-
declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-
|
|
29
|
+
declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "customer-groups", "reports", "community-bans"];
|
|
30
30
|
type ServerCollection = (typeof SERVER_COLLECTIONS)[number];
|
|
31
31
|
|
|
32
32
|
export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, SERVER_COLLECTIONS as S, COLLECTIONS as a, SERVER_ONLY_COLLECTIONS as b, type ServerCollection as c };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as Config } from './payload-types-DVK1QCeU.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Collection type derived from Payload Config.
|
|
@@ -9,12 +9,12 @@ type Collection = keyof Config['collections'];
|
|
|
9
9
|
* Internal collections that should not be exposed via SDK.
|
|
10
10
|
* Includes Payload system collections and admin-only collections.
|
|
11
11
|
*/
|
|
12
|
-
declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "inventory-reservations", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
|
|
12
|
+
declare const INTERNAL_COLLECTIONS: readonly ["users", "payload-kv", "payload-locked-documents", "payload-preferences", "payload-migrations", "payload-folders", "field-configs", "system-media", "track-assets", "audiences", "email-logs", "api-usage", "tenant-analytics-daily", "tenant-web-analytics-config", "analytics-event-schemas", "subscriptions", "billing-history", "inventory-reservations", "product-collection-items", "order-status-logs", "api-keys", "personal-access-tokens", "tenant-entitlements", "tenant-purge-jobs", "direct-upload-sessions", "webhook-events", "webhook-deliveries", "audit-logs", "plans", "webhooks", "event-registrations"];
|
|
13
13
|
/**
|
|
14
14
|
* Array of all public collection names for runtime use (e.g., Zod enum validation).
|
|
15
15
|
* This is the single source of truth for which collections are publicly accessible via SDK.
|
|
16
16
|
*/
|
|
17
|
-
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-
|
|
17
|
+
declare const COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags"];
|
|
18
18
|
/**
|
|
19
19
|
* Server-auth collection names for runtime use. These collections are safe for
|
|
20
20
|
* secret-key/PAT SDK and MCP server tools, but must not appear in browser or
|
|
@@ -26,7 +26,7 @@ declare const SERVER_ONLY_COLLECTIONS: readonly ["customer-groups", "reports", "
|
|
|
26
26
|
* Derived from the COLLECTIONS array (single source of truth).
|
|
27
27
|
*/
|
|
28
28
|
type PublicCollection = (typeof COLLECTIONS)[number];
|
|
29
|
-
declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-
|
|
29
|
+
declare const SERVER_COLLECTIONS: readonly ["tenants", "tenant-metadata", "tenant-logos", "products", "product-variants", "product-options", "product-option-values", "product-categories", "product-tags", "product-collections", "brands", "brand-logos", "orders", "order-items", "returns", "return-items", "fulfillments", "fulfillment-items", "transactions", "customers", "customer-profiles", "customer-addresses", "carts", "cart-items", "discounts", "shipping-policies", "shipping-zones", "documents", "document-categories", "document-types", "articles", "article-authors", "article-categories", "article-tags", "playlists", "playlist-categories", "playlist-tags", "tracks", "track-categories", "track-tags", "galleries", "gallery-categories", "gallery-tags", "gallery-items", "links", "link-categories", "link-tags", "canvases", "canvas-node-types", "canvas-edge-types", "canvas-categories", "canvas-tags", "canvas-nodes", "canvas-edges", "videos", "video-categories", "video-tags", "live-streams", "images", "forms", "form-submissions", "posts", "comments", "reactions", "reaction-types", "bookmarks", "post-categories", "customer-profile-lists", "event-calendars", "events", "event-categories", "event-occurrences", "event-tags", "customer-groups", "reports", "community-bans"];
|
|
30
30
|
type ServerCollection = (typeof SERVER_COLLECTIONS)[number];
|
|
31
31
|
|
|
32
32
|
export { type Collection as C, INTERNAL_COLLECTIONS as I, type PublicCollection as P, SERVER_COLLECTIONS as S, COLLECTIONS as a, SERVER_ONLY_COLLECTIONS as b, type ServerCollection as c };
|
|
@@ -25,7 +25,7 @@ declare class ValidationError extends SDKError {
|
|
|
25
25
|
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, status?: number);
|
|
26
26
|
}
|
|
27
27
|
declare class ApiError extends SDKError {
|
|
28
|
-
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
28
|
+
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
29
29
|
}
|
|
30
30
|
declare class ConfigError extends SDKError {
|
|
31
31
|
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
|
@@ -25,7 +25,7 @@ declare class ValidationError extends SDKError {
|
|
|
25
25
|
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string, status?: number);
|
|
26
26
|
}
|
|
27
27
|
declare class ApiError extends SDKError {
|
|
28
|
-
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string);
|
|
28
|
+
constructor(message: string, status: number, details?: unknown, userMessage?: string, suggestion?: string, requestId?: string);
|
|
29
29
|
}
|
|
30
30
|
declare class ConfigError extends SDKError {
|
|
31
31
|
constructor(message: string, details?: unknown, userMessage?: string, suggestion?: string);
|
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
INTERNAL_COLLECTIONS: () => INTERNAL_COLLECTIONS,
|
|
39
39
|
NetworkError: () => NetworkError,
|
|
40
40
|
NotFoundError: () => NotFoundError,
|
|
41
|
+
ORDER_CHANGED_EVENT_TYPE: () => ORDER_CHANGED_EVENT_TYPE,
|
|
41
42
|
OrderApi: () => OrderApi,
|
|
42
43
|
PermissionError: () => PermissionError,
|
|
43
44
|
ProductApi: () => ProductApi,
|
|
@@ -53,6 +54,7 @@ __export(src_exports, {
|
|
|
53
54
|
UsageLimitError: () => UsageLimitError,
|
|
54
55
|
ValidationError: () => ValidationError,
|
|
55
56
|
buildProductHref: () => buildProductHref,
|
|
57
|
+
buildProductListingCard: () => buildProductListingCard,
|
|
56
58
|
buildProductListingGroupsByOption: () => buildProductListingGroupsByOption,
|
|
57
59
|
buildProductListingProjection: () => buildProductListingProjection,
|
|
58
60
|
buildProductOptionMatrix: () => buildProductOptionMatrix,
|
|
@@ -91,6 +93,7 @@ __export(src_exports, {
|
|
|
91
93
|
isGoneError: () => isGoneError,
|
|
92
94
|
isNetworkError: () => isNetworkError,
|
|
93
95
|
isNotFoundError: () => isNotFoundError,
|
|
96
|
+
isOrderChangedWebhookEvent: () => isOrderChangedWebhookEvent,
|
|
94
97
|
isPermissionError: () => isPermissionError,
|
|
95
98
|
isRateLimitError: () => isRateLimitError,
|
|
96
99
|
isSDKError: () => isSDKError,
|
|
@@ -99,6 +102,8 @@ __export(src_exports, {
|
|
|
99
102
|
isUsageLimitError: () => isUsageLimitError,
|
|
100
103
|
isValidWebhookEvent: () => isValidWebhookEvent,
|
|
101
104
|
isValidationError: () => isValidationError,
|
|
105
|
+
isWebhookCollection: () => isWebhookCollection,
|
|
106
|
+
isWebhookOperation: () => isWebhookOperation,
|
|
102
107
|
normalizeProductSelection: () => normalizeProductSelection,
|
|
103
108
|
normalizeProductSelectionFromMatrix: () => normalizeProductSelectionFromMatrix,
|
|
104
109
|
normalizeSelectedValueIds: () => normalizeSelectedValueIds,
|
|
@@ -158,8 +163,16 @@ var ValidationError = class extends SDKError {
|
|
|
158
163
|
}
|
|
159
164
|
};
|
|
160
165
|
var ApiError = class extends SDKError {
|
|
161
|
-
constructor(message, status, details, userMessage, suggestion) {
|
|
162
|
-
super(
|
|
166
|
+
constructor(message, status, details, userMessage, suggestion, requestId) {
|
|
167
|
+
super(
|
|
168
|
+
"API_ERROR",
|
|
169
|
+
message,
|
|
170
|
+
status,
|
|
171
|
+
details,
|
|
172
|
+
userMessage,
|
|
173
|
+
suggestion,
|
|
174
|
+
requestId
|
|
175
|
+
);
|
|
163
176
|
this.name = "ApiError";
|
|
164
177
|
}
|
|
165
178
|
};
|
|
@@ -210,19 +223,43 @@ var UsageLimitError = class extends SDKError {
|
|
|
210
223
|
};
|
|
211
224
|
var AuthError = class extends SDKError {
|
|
212
225
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
213
|
-
super(
|
|
226
|
+
super(
|
|
227
|
+
"auth_error",
|
|
228
|
+
message,
|
|
229
|
+
401,
|
|
230
|
+
details,
|
|
231
|
+
userMessage,
|
|
232
|
+
suggestion,
|
|
233
|
+
requestId
|
|
234
|
+
);
|
|
214
235
|
this.name = "AuthError";
|
|
215
236
|
}
|
|
216
237
|
};
|
|
217
238
|
var PermissionError = class extends SDKError {
|
|
218
239
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
219
|
-
super(
|
|
240
|
+
super(
|
|
241
|
+
"permission_error",
|
|
242
|
+
message,
|
|
243
|
+
403,
|
|
244
|
+
details,
|
|
245
|
+
userMessage,
|
|
246
|
+
suggestion,
|
|
247
|
+
requestId
|
|
248
|
+
);
|
|
220
249
|
this.name = "PermissionError";
|
|
221
250
|
}
|
|
222
251
|
};
|
|
223
252
|
var NotFoundError = class extends SDKError {
|
|
224
253
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
225
|
-
super(
|
|
254
|
+
super(
|
|
255
|
+
"not_found",
|
|
256
|
+
message,
|
|
257
|
+
404,
|
|
258
|
+
details,
|
|
259
|
+
userMessage,
|
|
260
|
+
suggestion,
|
|
261
|
+
requestId
|
|
262
|
+
);
|
|
226
263
|
this.name = "NotFoundError";
|
|
227
264
|
}
|
|
228
265
|
};
|
|
@@ -234,7 +271,15 @@ var ConflictError = class extends SDKError {
|
|
|
234
271
|
};
|
|
235
272
|
var RateLimitError = class extends SDKError {
|
|
236
273
|
constructor(message, retryAfter, details, userMessage, suggestion, requestId) {
|
|
237
|
-
super(
|
|
274
|
+
super(
|
|
275
|
+
"rate_limit_exceeded",
|
|
276
|
+
message,
|
|
277
|
+
429,
|
|
278
|
+
details,
|
|
279
|
+
userMessage,
|
|
280
|
+
suggestion,
|
|
281
|
+
requestId
|
|
282
|
+
);
|
|
238
283
|
this.name = "RateLimitError";
|
|
239
284
|
this.retryAfter = retryAfter;
|
|
240
285
|
}
|
|
@@ -283,7 +328,7 @@ function isRateLimitError(error) {
|
|
|
283
328
|
}
|
|
284
329
|
var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
|
|
285
330
|
var createValidationError = (message, details, userMessage, suggestion, status) => new ValidationError(message, details, userMessage, suggestion, status);
|
|
286
|
-
var createApiError = (message, status, details, userMessage, suggestion) => new ApiError(message, status, details, userMessage, suggestion);
|
|
331
|
+
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
287
332
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
288
333
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
289
334
|
var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
|
|
@@ -291,7 +336,14 @@ var createAuthError = (message, details, userMessage, suggestion, requestId) =>
|
|
|
291
336
|
var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
|
|
292
337
|
var createNotFoundError = (message, details, userMessage, suggestion, requestId) => new NotFoundError(message, details, userMessage, suggestion, requestId);
|
|
293
338
|
var createConflictError = (message, details, userMessage, suggestion, requestId) => new ConflictError(message, details, userMessage, suggestion, requestId);
|
|
294
|
-
var createRateLimitError = (message, retryAfter, details, userMessage, suggestion, requestId) => new RateLimitError(
|
|
339
|
+
var createRateLimitError = (message, retryAfter, details, userMessage, suggestion, requestId) => new RateLimitError(
|
|
340
|
+
message,
|
|
341
|
+
retryAfter,
|
|
342
|
+
details,
|
|
343
|
+
userMessage,
|
|
344
|
+
suggestion,
|
|
345
|
+
requestId
|
|
346
|
+
);
|
|
295
347
|
|
|
296
348
|
// src/core/internal/utils/credentials.ts
|
|
297
349
|
function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
|
|
@@ -331,6 +383,22 @@ function debugLog(debug, type, message, data) {
|
|
|
331
383
|
console.groupEnd();
|
|
332
384
|
}
|
|
333
385
|
}
|
|
386
|
+
function redactSensitiveHeader(value) {
|
|
387
|
+
const prefix = value.toLowerCase().startsWith("bearer ") ? "Bearer " : "";
|
|
388
|
+
return value.length > 20 ? `${prefix}...****${value.slice(-8)}` : "****";
|
|
389
|
+
}
|
|
390
|
+
function redactSensitiveHeaders(headers) {
|
|
391
|
+
const redacted = Object.fromEntries(headers.entries());
|
|
392
|
+
if (redacted.authorization) {
|
|
393
|
+
redacted.authorization = redactSensitiveHeader(redacted.authorization);
|
|
394
|
+
}
|
|
395
|
+
if (redacted["x-preview-token"]) {
|
|
396
|
+
redacted["x-preview-token"] = redactSensitiveHeader(
|
|
397
|
+
redacted["x-preview-token"]
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
return redacted;
|
|
401
|
+
}
|
|
334
402
|
function getErrorSuggestion(status) {
|
|
335
403
|
if (status === 400)
|
|
336
404
|
return "The request data failed validation. Check field values and types.";
|
|
@@ -405,6 +473,12 @@ async function parseErrorBody(response) {
|
|
|
405
473
|
return fallback;
|
|
406
474
|
}
|
|
407
475
|
}
|
|
476
|
+
function getParsedErrorSuggestion(status, parsed) {
|
|
477
|
+
if (status === 403 && parsed.reason === "origin_not_allowed") {
|
|
478
|
+
return "Add the request origin to the tenant Browser API origins, then retry the browser request.";
|
|
479
|
+
}
|
|
480
|
+
return getErrorSuggestion(status);
|
|
481
|
+
}
|
|
408
482
|
async function delay(ms) {
|
|
409
483
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
410
484
|
}
|
|
@@ -418,7 +492,7 @@ function createHttpStatusError(status, parsed, details, requestId) {
|
|
|
418
492
|
...parsed.errors && { errors: parsed.errors },
|
|
419
493
|
...parsed.body && { body: parsed.body }
|
|
420
494
|
};
|
|
421
|
-
const suggestion =
|
|
495
|
+
const suggestion = getParsedErrorSuggestion(status, parsed);
|
|
422
496
|
if (status === 400 || status === 422) {
|
|
423
497
|
return attachRequestId(
|
|
424
498
|
createValidationError(
|
|
@@ -524,11 +598,7 @@ async function httpFetch(url, options) {
|
|
|
524
598
|
if (!headers.has("Content-Type") && requestInit.body && !(requestInit.body instanceof FormData)) {
|
|
525
599
|
headers.set("Content-Type", "application/json");
|
|
526
600
|
}
|
|
527
|
-
const redactedHeaders =
|
|
528
|
-
if (redactedHeaders["authorization"]) {
|
|
529
|
-
const token = redactedHeaders["authorization"];
|
|
530
|
-
redactedHeaders["authorization"] = token.length > 20 ? `Bearer ...****${token.slice(-8)}` : "****";
|
|
531
|
-
}
|
|
601
|
+
const redactedHeaders = redactSensitiveHeaders(headers);
|
|
532
602
|
debugLog(debug, "request", url, {
|
|
533
603
|
method: requestInit.method || "GET",
|
|
534
604
|
headers: redactedHeaders,
|
|
@@ -546,7 +616,7 @@ async function httpFetch(url, options) {
|
|
|
546
616
|
debugLog(debug, "response", url, {
|
|
547
617
|
status: response.status,
|
|
548
618
|
statusText: response.statusText,
|
|
549
|
-
headers:
|
|
619
|
+
headers: redactSensitiveHeaders(response.headers)
|
|
550
620
|
});
|
|
551
621
|
if (!response.ok) {
|
|
552
622
|
if (isUsageLimitExceededResponse(response)) {
|
|
@@ -979,7 +1049,7 @@ async function parseApiResponse(response, endpoint) {
|
|
|
979
1049
|
if (reason === "validation_failed") {
|
|
980
1050
|
throw attachRequestId(createValidationError(errorMessage, data, errorMessage), requestId);
|
|
981
1051
|
}
|
|
982
|
-
if (reason === "token_expired" || reason === "token_invalid" || reason === "key_invalid" || reason === "key_revoked") {
|
|
1052
|
+
if (reason === "token_expired" || reason === "token_invalid" || reason === "preview_token_invalid" || reason === "preview_token_required" || reason === "key_invalid" || reason === "key_revoked") {
|
|
983
1053
|
throw attachRequestId(createAuthError(errorMessage, data, errorMessage), requestId);
|
|
984
1054
|
}
|
|
985
1055
|
if (reason === "forbidden") {
|
|
@@ -1274,7 +1344,7 @@ var CustomerAuth = class {
|
|
|
1274
1344
|
);
|
|
1275
1345
|
return data.customer ?? null;
|
|
1276
1346
|
} catch (error) {
|
|
1277
|
-
if (error instanceof
|
|
1347
|
+
if (error instanceof SDKError && error.status === 401) {
|
|
1278
1348
|
this.setToken(null);
|
|
1279
1349
|
return null;
|
|
1280
1350
|
}
|
|
@@ -1369,51 +1439,15 @@ var CustomerAuth = class {
|
|
|
1369
1439
|
if (!headers.has("Content-Type") && init.body) {
|
|
1370
1440
|
headers.set("Content-Type", "application/json");
|
|
1371
1441
|
}
|
|
1372
|
-
const
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
} catch (error) {
|
|
1382
|
-
clearTimeout(timeoutId);
|
|
1383
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
1384
|
-
throw new TimeoutError(`Request timed out after ${DEFAULT_TIMEOUT2}ms`, {
|
|
1385
|
-
url: path,
|
|
1386
|
-
timeout: DEFAULT_TIMEOUT2
|
|
1387
|
-
});
|
|
1388
|
-
}
|
|
1389
|
-
throw new NetworkError(
|
|
1390
|
-
error instanceof Error ? error.message : "Network request failed",
|
|
1391
|
-
void 0,
|
|
1392
|
-
{ url: path },
|
|
1393
|
-
"Network connection failed.",
|
|
1394
|
-
"Please check your internet connection and try again."
|
|
1395
|
-
);
|
|
1396
|
-
}
|
|
1397
|
-
clearTimeout(timeoutId);
|
|
1398
|
-
if (!res.ok) {
|
|
1399
|
-
const body = await res.json().catch(() => ({}));
|
|
1400
|
-
throw new ApiError(
|
|
1401
|
-
body.error || `HTTP ${res.status}`,
|
|
1402
|
-
res.status,
|
|
1403
|
-
body.details,
|
|
1404
|
-
body.error
|
|
1405
|
-
);
|
|
1406
|
-
}
|
|
1407
|
-
try {
|
|
1408
|
-
return await res.json();
|
|
1409
|
-
} catch {
|
|
1410
|
-
throw new ApiError(
|
|
1411
|
-
"Invalid JSON response from server",
|
|
1412
|
-
res.status,
|
|
1413
|
-
void 0,
|
|
1414
|
-
"INVALID_RESPONSE"
|
|
1415
|
-
);
|
|
1416
|
-
}
|
|
1442
|
+
const response = await httpFetch(path, {
|
|
1443
|
+
...init,
|
|
1444
|
+
apiUrl: this.baseUrl,
|
|
1445
|
+
publishableKey: this.publishableKey,
|
|
1446
|
+
headers,
|
|
1447
|
+
timeout: DEFAULT_TIMEOUT2,
|
|
1448
|
+
retry: { maxRetries: 0 }
|
|
1449
|
+
});
|
|
1450
|
+
return parseApiResponse(response, path);
|
|
1417
1451
|
}
|
|
1418
1452
|
};
|
|
1419
1453
|
|
|
@@ -1750,7 +1784,7 @@ var ProductApi = class extends BaseApi {
|
|
|
1750
1784
|
/**
|
|
1751
1785
|
* Fetch full product detail by slug or id.
|
|
1752
1786
|
* Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
|
|
1753
|
-
* `
|
|
1787
|
+
* `feature_disabled`). For the reason behind a null,
|
|
1754
1788
|
* inspect `client.lastRequestId` against backend logs.
|
|
1755
1789
|
*/
|
|
1756
1790
|
async detail(params) {
|
|
@@ -1773,11 +1807,54 @@ var ProductApi = class extends BaseApi {
|
|
|
1773
1807
|
};
|
|
1774
1808
|
|
|
1775
1809
|
// src/core/webhook/index.ts
|
|
1810
|
+
var ORDER_CHANGED_EVENT_TYPE = "collection.orderChanged";
|
|
1776
1811
|
function isValidWebhookEvent(data) {
|
|
1777
1812
|
if (typeof data !== "object" || data === null) return false;
|
|
1778
1813
|
const obj = data;
|
|
1779
1814
|
return typeof obj.collection === "string" && typeof obj.operation === "string" && obj.operation.length > 0 && typeof obj.data === "object" && obj.data !== null;
|
|
1780
1815
|
}
|
|
1816
|
+
function isStringOrNumber(value) {
|
|
1817
|
+
return typeof value === "string" || typeof value === "number";
|
|
1818
|
+
}
|
|
1819
|
+
function isWebhookOrderScope(value) {
|
|
1820
|
+
if (!isRecord(value)) return false;
|
|
1821
|
+
if (value.kind === "collection") {
|
|
1822
|
+
return typeof value.collection === "string";
|
|
1823
|
+
}
|
|
1824
|
+
if (value.kind === "join") {
|
|
1825
|
+
return typeof value.collection === "string" && typeof value.field === "string" && isStringOrNumber(value.id);
|
|
1826
|
+
}
|
|
1827
|
+
return false;
|
|
1828
|
+
}
|
|
1829
|
+
function isWebhookOrderMoved(value) {
|
|
1830
|
+
if (!isRecord(value)) return false;
|
|
1831
|
+
return typeof value.collection === "string" && isStringOrNumber(value.id) && (value.relatedCollection === void 0 || typeof value.relatedCollection === "string") && (value.relatedId === void 0 || isStringOrNumber(value.relatedId));
|
|
1832
|
+
}
|
|
1833
|
+
function hasOptionalOrderValue(value, key) {
|
|
1834
|
+
return value[key] === void 0 || value[key] === null || typeof value[key] === "string";
|
|
1835
|
+
}
|
|
1836
|
+
function isWebhookOrderChange(value) {
|
|
1837
|
+
if (!isRecord(value)) return false;
|
|
1838
|
+
return value.type === "order" && value.source === "payload-orderable" && (value.orderableFieldName === void 0 || typeof value.orderableFieldName === "string") && hasOptionalOrderValue(value, "previousOrder") && hasOptionalOrderValue(value, "nextOrder") && isWebhookOrderScope(value.scope) && isWebhookOrderMoved(value.moved);
|
|
1839
|
+
}
|
|
1840
|
+
function isOrderChangedWebhookEvent(event) {
|
|
1841
|
+
if (!isValidWebhookEvent(event) || event.operation !== "update" || event.eventType !== ORDER_CHANGED_EVENT_TYPE || !isWebhookOrderChange(event.change)) {
|
|
1842
|
+
return false;
|
|
1843
|
+
}
|
|
1844
|
+
if (event.collection !== event.change.scope.collection) {
|
|
1845
|
+
return false;
|
|
1846
|
+
}
|
|
1847
|
+
if (event.change.scope.kind === "collection" && event.change.moved.collection !== event.change.scope.collection) {
|
|
1848
|
+
return false;
|
|
1849
|
+
}
|
|
1850
|
+
return true;
|
|
1851
|
+
}
|
|
1852
|
+
function isWebhookCollection(event, collection) {
|
|
1853
|
+
return isValidWebhookEvent(event) && event.collection === collection;
|
|
1854
|
+
}
|
|
1855
|
+
function isWebhookOperation(event, operation) {
|
|
1856
|
+
return isValidWebhookEvent(event) && event.operation === operation;
|
|
1857
|
+
}
|
|
1781
1858
|
var CUSTOMER_PASSWORD_RESET_OPERATION = "password-reset";
|
|
1782
1859
|
function isRecord(value) {
|
|
1783
1860
|
return typeof value === "object" && value !== null;
|
|
@@ -1909,6 +1986,7 @@ var INTERNAL_COLLECTIONS = [
|
|
|
1909
1986
|
"subscriptions",
|
|
1910
1987
|
"billing-history",
|
|
1911
1988
|
"inventory-reservations",
|
|
1989
|
+
"product-collection-items",
|
|
1912
1990
|
"order-status-logs",
|
|
1913
1991
|
"api-keys",
|
|
1914
1992
|
"personal-access-tokens",
|
|
@@ -1944,7 +2022,6 @@ var COLLECTIONS = [
|
|
|
1944
2022
|
"transactions",
|
|
1945
2023
|
"customers",
|
|
1946
2024
|
"customer-profiles",
|
|
1947
|
-
"customer-profile-lists",
|
|
1948
2025
|
"customer-addresses",
|
|
1949
2026
|
"carts",
|
|
1950
2027
|
"cart-items",
|
|
@@ -1992,6 +2069,7 @@ var COLLECTIONS = [
|
|
|
1992
2069
|
"reaction-types",
|
|
1993
2070
|
"bookmarks",
|
|
1994
2071
|
"post-categories",
|
|
2072
|
+
"customer-profile-lists",
|
|
1995
2073
|
// Events
|
|
1996
2074
|
"event-calendars",
|
|
1997
2075
|
"events",
|
|
@@ -2832,17 +2910,21 @@ function mediaArray(values) {
|
|
|
2832
2910
|
return values.filter(isPresentMedia);
|
|
2833
2911
|
}
|
|
2834
2912
|
function buildSelectionMedia(detail, selectedVariant, matchingVariants, selectedValues) {
|
|
2913
|
+
const selectedVariantImages = mediaArray(selectedVariant?.images);
|
|
2835
2914
|
const selectedValueImages = selectedValues.flatMap(
|
|
2836
2915
|
(value) => mediaArray(value.images)
|
|
2837
2916
|
);
|
|
2917
|
+
const matchingVariantImages = matchingVariants.flatMap(
|
|
2918
|
+
(variant) => mediaArray(variant.images)
|
|
2919
|
+
);
|
|
2838
2920
|
const selectedValuePrimary = selectedValues.map((value) => firstMedia(value.thumbnail) ?? firstMedia(value.images)).find((value) => value != null) ?? null;
|
|
2839
2921
|
const selectedVariantPrimary = firstMedia(selectedVariant?.thumbnail) ?? firstMedia(selectedVariant?.images);
|
|
2840
2922
|
const matchingVariantPrimary = matchingVariants.map(
|
|
2841
2923
|
(variant) => firstMedia(variant.thumbnail) ?? firstMedia(variant.images)
|
|
2842
2924
|
).find((value) => value != null) ?? null;
|
|
2843
2925
|
const detailImages = mediaArray(detail.images);
|
|
2844
|
-
const primaryImage = selectedVariantPrimary ?? selectedValuePrimary ?? firstMedia(detail.listing.primaryImage) ??
|
|
2845
|
-
const images =
|
|
2926
|
+
const primaryImage = selectedVariantPrimary ?? selectedValuePrimary ?? matchingVariantPrimary ?? firstMedia(detail.listing.primaryImage) ?? firstMedia(detailImages);
|
|
2927
|
+
const images = selectedVariantImages.length > 0 ? selectedVariantImages : selectedValueImages.length > 0 ? selectedValueImages : matchingVariantImages.length > 0 ? matchingVariantImages : detailImages;
|
|
2846
2928
|
return {
|
|
2847
2929
|
primaryImage,
|
|
2848
2930
|
images
|
|
@@ -3133,6 +3215,72 @@ function buildProductListingProjection(product, variants) {
|
|
|
3133
3215
|
availableForSale: availableVariants.length > 0
|
|
3134
3216
|
};
|
|
3135
3217
|
}
|
|
3218
|
+
function buildProductListingCard(item, options = {}) {
|
|
3219
|
+
const product = item.product;
|
|
3220
|
+
const groups = item.groups;
|
|
3221
|
+
const primaryImage = firstMedia(product.thumbnail) ?? firstMedia(product.images ?? null) ?? null;
|
|
3222
|
+
const priceRange = aggregateListingPriceRange(groups);
|
|
3223
|
+
const availableForSale = groups.some(
|
|
3224
|
+
(group) => group.listing.availableForSale
|
|
3225
|
+
);
|
|
3226
|
+
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
3227
|
+
return {
|
|
3228
|
+
id: String(product.id),
|
|
3229
|
+
href: buildProductHref({ slug: product.slug }, void 0, options),
|
|
3230
|
+
title: product.title,
|
|
3231
|
+
primaryImage,
|
|
3232
|
+
priceRange,
|
|
3233
|
+
availableForSale,
|
|
3234
|
+
swatches
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
function aggregateListingPriceRange(groups) {
|
|
3238
|
+
const minPrice = minOfNullable(groups.map((g) => g.listing.minPrice));
|
|
3239
|
+
const maxPrice = maxOfNullable(groups.map((g) => g.listing.maxPrice));
|
|
3240
|
+
const minCompareAtPrice = minOfNullable(
|
|
3241
|
+
groups.map((g) => g.listing.minCompareAtPrice)
|
|
3242
|
+
);
|
|
3243
|
+
const maxCompareAtPrice = maxOfNullable(
|
|
3244
|
+
groups.map((g) => g.listing.maxCompareAtPrice)
|
|
3245
|
+
);
|
|
3246
|
+
const isPriceRange = minPrice !== null && maxPrice !== null && minPrice !== maxPrice;
|
|
3247
|
+
return {
|
|
3248
|
+
minPrice,
|
|
3249
|
+
maxPrice,
|
|
3250
|
+
minCompareAtPrice,
|
|
3251
|
+
maxCompareAtPrice,
|
|
3252
|
+
isPriceRange
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
function buildListingSwatch(product, group, options) {
|
|
3256
|
+
const thumbnail = firstMedia(group.optionValueThumbnail) ?? firstMedia(group.optionValueImages) ?? null;
|
|
3257
|
+
return {
|
|
3258
|
+
optionId: group.optionId,
|
|
3259
|
+
optionValueId: group.optionValueId,
|
|
3260
|
+
label: group.optionValueLabel,
|
|
3261
|
+
swatchColor: group.optionValueSwatchColor ?? null,
|
|
3262
|
+
thumbnail,
|
|
3263
|
+
href: buildProductHref(
|
|
3264
|
+
{ slug: product.slug },
|
|
3265
|
+
{
|
|
3266
|
+
optionId: group.optionId,
|
|
3267
|
+
optionValueId: group.optionValueId,
|
|
3268
|
+
optionValueSlug: group.optionValueSlug,
|
|
3269
|
+
listing: group.listing
|
|
3270
|
+
},
|
|
3271
|
+
options
|
|
3272
|
+
),
|
|
3273
|
+
availableForSale: group.listing.availableForSale
|
|
3274
|
+
};
|
|
3275
|
+
}
|
|
3276
|
+
function minOfNullable(values) {
|
|
3277
|
+
const numbers = values.filter((v) => v !== null);
|
|
3278
|
+
return numbers.length === 0 ? null : Math.min(...numbers);
|
|
3279
|
+
}
|
|
3280
|
+
function maxOfNullable(values) {
|
|
3281
|
+
const numbers = values.filter((v) => v !== null);
|
|
3282
|
+
return numbers.length === 0 ? null : Math.max(...numbers);
|
|
3283
|
+
}
|
|
3136
3284
|
function buildProductListingGroupsByOption(args) {
|
|
3137
3285
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
3138
3286
|
if (!primaryOptionId) return [];
|