@01.software/sdk 0.30.1 → 0.31.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 +74 -20
- package/dist/client.cjs +81 -16
- 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 +81 -16
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-B9d9kr1d.d.ts → collection-client-ByzY3hWK.d.ts} +3 -3
- package/dist/{collection-client-QPbwimkU.d.cts → collection-client-DFXXz0vk.d.cts} +3 -3
- package/dist/{const-VZuk2tWc.d.cts → const-AytzliEu.d.cts} +4 -4
- package/dist/{const-B75IFDRi.d.ts → const-BGCP-OJL.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 +156 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +156 -19
- package/dist/index.js.map +1 -1
- package/dist/{payload-types-DPjO_IbQ.d.cts → payload-types-Wa4-eC6x.d.cts} +790 -534
- package/dist/{payload-types-DPjO_IbQ.d.ts → payload-types-Wa4-eC6x.d.ts} +790 -534
- package/dist/query.cjs +63 -13
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +6 -6
- package/dist/query.d.ts +6 -6
- package/dist/query.js +63 -13
- package/dist/query.js.map +1 -1
- package/dist/realtime.d.cts +2 -2
- package/dist/realtime.d.ts +2 -2
- package/dist/server.cjs +142 -17
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +32 -7
- package/dist/server.d.ts +32 -7
- package/dist/server.js +142 -17
- package/dist/server.js.map +1 -1
- package/dist/{types-Dlb2mwpX.d.cts → types-BX2mqDf6.d.ts} +46 -6
- package/dist/{types-1fBLrYU7.d.ts → types-CVA10VC-.d.ts} +6 -2
- package/dist/{types-BwT0eeaz.d.cts → types-CmLG-7RL.d.cts} +6 -2
- package/dist/{types-DuSKPiY5.d.ts → types-DChFjQGz.d.cts} +46 -6
- 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.d.cts +3 -3
- package/dist/webhook.d.ts +3 -3
- package/package.json +1 -1
|
@@ -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-BX2mqDf6.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-BGCP-OJL.js';
|
|
4
|
+
import { C as CollectionType } from './types-CVA10VC-.js';
|
|
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-DChFjQGz.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-AytzliEu.cjs';
|
|
4
|
+
import { C as CollectionType } from './types-CmLG-7RL.cjs';
|
|
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-Wa4-eC6x.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-Wa4-eC6x.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
|
@@ -53,6 +53,7 @@ __export(src_exports, {
|
|
|
53
53
|
UsageLimitError: () => UsageLimitError,
|
|
54
54
|
ValidationError: () => ValidationError,
|
|
55
55
|
buildProductHref: () => buildProductHref,
|
|
56
|
+
buildProductListingCard: () => buildProductListingCard,
|
|
56
57
|
buildProductListingGroupsByOption: () => buildProductListingGroupsByOption,
|
|
57
58
|
buildProductListingProjection: () => buildProductListingProjection,
|
|
58
59
|
buildProductOptionMatrix: () => buildProductOptionMatrix,
|
|
@@ -158,8 +159,16 @@ var ValidationError = class extends SDKError {
|
|
|
158
159
|
}
|
|
159
160
|
};
|
|
160
161
|
var ApiError = class extends SDKError {
|
|
161
|
-
constructor(message, status, details, userMessage, suggestion) {
|
|
162
|
-
super(
|
|
162
|
+
constructor(message, status, details, userMessage, suggestion, requestId) {
|
|
163
|
+
super(
|
|
164
|
+
"API_ERROR",
|
|
165
|
+
message,
|
|
166
|
+
status,
|
|
167
|
+
details,
|
|
168
|
+
userMessage,
|
|
169
|
+
suggestion,
|
|
170
|
+
requestId
|
|
171
|
+
);
|
|
163
172
|
this.name = "ApiError";
|
|
164
173
|
}
|
|
165
174
|
};
|
|
@@ -210,19 +219,43 @@ var UsageLimitError = class extends SDKError {
|
|
|
210
219
|
};
|
|
211
220
|
var AuthError = class extends SDKError {
|
|
212
221
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
213
|
-
super(
|
|
222
|
+
super(
|
|
223
|
+
"auth_error",
|
|
224
|
+
message,
|
|
225
|
+
401,
|
|
226
|
+
details,
|
|
227
|
+
userMessage,
|
|
228
|
+
suggestion,
|
|
229
|
+
requestId
|
|
230
|
+
);
|
|
214
231
|
this.name = "AuthError";
|
|
215
232
|
}
|
|
216
233
|
};
|
|
217
234
|
var PermissionError = class extends SDKError {
|
|
218
235
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
219
|
-
super(
|
|
236
|
+
super(
|
|
237
|
+
"permission_error",
|
|
238
|
+
message,
|
|
239
|
+
403,
|
|
240
|
+
details,
|
|
241
|
+
userMessage,
|
|
242
|
+
suggestion,
|
|
243
|
+
requestId
|
|
244
|
+
);
|
|
220
245
|
this.name = "PermissionError";
|
|
221
246
|
}
|
|
222
247
|
};
|
|
223
248
|
var NotFoundError = class extends SDKError {
|
|
224
249
|
constructor(message, details, userMessage, suggestion, requestId) {
|
|
225
|
-
super(
|
|
250
|
+
super(
|
|
251
|
+
"not_found",
|
|
252
|
+
message,
|
|
253
|
+
404,
|
|
254
|
+
details,
|
|
255
|
+
userMessage,
|
|
256
|
+
suggestion,
|
|
257
|
+
requestId
|
|
258
|
+
);
|
|
226
259
|
this.name = "NotFoundError";
|
|
227
260
|
}
|
|
228
261
|
};
|
|
@@ -234,7 +267,15 @@ var ConflictError = class extends SDKError {
|
|
|
234
267
|
};
|
|
235
268
|
var RateLimitError = class extends SDKError {
|
|
236
269
|
constructor(message, retryAfter, details, userMessage, suggestion, requestId) {
|
|
237
|
-
super(
|
|
270
|
+
super(
|
|
271
|
+
"rate_limit_exceeded",
|
|
272
|
+
message,
|
|
273
|
+
429,
|
|
274
|
+
details,
|
|
275
|
+
userMessage,
|
|
276
|
+
suggestion,
|
|
277
|
+
requestId
|
|
278
|
+
);
|
|
238
279
|
this.name = "RateLimitError";
|
|
239
280
|
this.retryAfter = retryAfter;
|
|
240
281
|
}
|
|
@@ -283,7 +324,7 @@ function isRateLimitError(error) {
|
|
|
283
324
|
}
|
|
284
325
|
var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
|
|
285
326
|
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);
|
|
327
|
+
var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
|
|
287
328
|
var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
|
|
288
329
|
var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
|
|
289
330
|
var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
|
|
@@ -291,7 +332,14 @@ var createAuthError = (message, details, userMessage, suggestion, requestId) =>
|
|
|
291
332
|
var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
|
|
292
333
|
var createNotFoundError = (message, details, userMessage, suggestion, requestId) => new NotFoundError(message, details, userMessage, suggestion, requestId);
|
|
293
334
|
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(
|
|
335
|
+
var createRateLimitError = (message, retryAfter, details, userMessage, suggestion, requestId) => new RateLimitError(
|
|
336
|
+
message,
|
|
337
|
+
retryAfter,
|
|
338
|
+
details,
|
|
339
|
+
userMessage,
|
|
340
|
+
suggestion,
|
|
341
|
+
requestId
|
|
342
|
+
);
|
|
295
343
|
|
|
296
344
|
// src/core/internal/utils/credentials.ts
|
|
297
345
|
function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
|
|
@@ -331,6 +379,22 @@ function debugLog(debug, type, message, data) {
|
|
|
331
379
|
console.groupEnd();
|
|
332
380
|
}
|
|
333
381
|
}
|
|
382
|
+
function redactSensitiveHeader(value) {
|
|
383
|
+
const prefix = value.toLowerCase().startsWith("bearer ") ? "Bearer " : "";
|
|
384
|
+
return value.length > 20 ? `${prefix}...****${value.slice(-8)}` : "****";
|
|
385
|
+
}
|
|
386
|
+
function redactSensitiveHeaders(headers) {
|
|
387
|
+
const redacted = Object.fromEntries(headers.entries());
|
|
388
|
+
if (redacted.authorization) {
|
|
389
|
+
redacted.authorization = redactSensitiveHeader(redacted.authorization);
|
|
390
|
+
}
|
|
391
|
+
if (redacted["x-preview-token"]) {
|
|
392
|
+
redacted["x-preview-token"] = redactSensitiveHeader(
|
|
393
|
+
redacted["x-preview-token"]
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return redacted;
|
|
397
|
+
}
|
|
334
398
|
function getErrorSuggestion(status) {
|
|
335
399
|
if (status === 400)
|
|
336
400
|
return "The request data failed validation. Check field values and types.";
|
|
@@ -405,6 +469,12 @@ async function parseErrorBody(response) {
|
|
|
405
469
|
return fallback;
|
|
406
470
|
}
|
|
407
471
|
}
|
|
472
|
+
function getParsedErrorSuggestion(status, parsed) {
|
|
473
|
+
if (status === 403 && parsed.reason === "origin_not_allowed") {
|
|
474
|
+
return "Add the request origin to the tenant Browser API origins, then retry the browser request.";
|
|
475
|
+
}
|
|
476
|
+
return getErrorSuggestion(status);
|
|
477
|
+
}
|
|
408
478
|
async function delay(ms) {
|
|
409
479
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
410
480
|
}
|
|
@@ -418,7 +488,7 @@ function createHttpStatusError(status, parsed, details, requestId) {
|
|
|
418
488
|
...parsed.errors && { errors: parsed.errors },
|
|
419
489
|
...parsed.body && { body: parsed.body }
|
|
420
490
|
};
|
|
421
|
-
const suggestion =
|
|
491
|
+
const suggestion = getParsedErrorSuggestion(status, parsed);
|
|
422
492
|
if (status === 400 || status === 422) {
|
|
423
493
|
return attachRequestId(
|
|
424
494
|
createValidationError(
|
|
@@ -524,11 +594,7 @@ async function httpFetch(url, options) {
|
|
|
524
594
|
if (!headers.has("Content-Type") && requestInit.body && !(requestInit.body instanceof FormData)) {
|
|
525
595
|
headers.set("Content-Type", "application/json");
|
|
526
596
|
}
|
|
527
|
-
const redactedHeaders =
|
|
528
|
-
if (redactedHeaders["authorization"]) {
|
|
529
|
-
const token = redactedHeaders["authorization"];
|
|
530
|
-
redactedHeaders["authorization"] = token.length > 20 ? `Bearer ...****${token.slice(-8)}` : "****";
|
|
531
|
-
}
|
|
597
|
+
const redactedHeaders = redactSensitiveHeaders(headers);
|
|
532
598
|
debugLog(debug, "request", url, {
|
|
533
599
|
method: requestInit.method || "GET",
|
|
534
600
|
headers: redactedHeaders,
|
|
@@ -546,7 +612,7 @@ async function httpFetch(url, options) {
|
|
|
546
612
|
debugLog(debug, "response", url, {
|
|
547
613
|
status: response.status,
|
|
548
614
|
statusText: response.statusText,
|
|
549
|
-
headers:
|
|
615
|
+
headers: redactSensitiveHeaders(response.headers)
|
|
550
616
|
});
|
|
551
617
|
if (!response.ok) {
|
|
552
618
|
if (isUsageLimitExceededResponse(response)) {
|
|
@@ -979,7 +1045,7 @@ async function parseApiResponse(response, endpoint) {
|
|
|
979
1045
|
if (reason === "validation_failed") {
|
|
980
1046
|
throw attachRequestId(createValidationError(errorMessage, data, errorMessage), requestId);
|
|
981
1047
|
}
|
|
982
|
-
if (reason === "token_expired" || reason === "token_invalid" || reason === "key_invalid" || reason === "key_revoked") {
|
|
1048
|
+
if (reason === "token_expired" || reason === "token_invalid" || reason === "preview_token_invalid" || reason === "preview_token_required" || reason === "key_invalid" || reason === "key_revoked") {
|
|
983
1049
|
throw attachRequestId(createAuthError(errorMessage, data, errorMessage), requestId);
|
|
984
1050
|
}
|
|
985
1051
|
if (reason === "forbidden") {
|
|
@@ -1909,6 +1975,7 @@ var INTERNAL_COLLECTIONS = [
|
|
|
1909
1975
|
"subscriptions",
|
|
1910
1976
|
"billing-history",
|
|
1911
1977
|
"inventory-reservations",
|
|
1978
|
+
"product-collection-items",
|
|
1912
1979
|
"order-status-logs",
|
|
1913
1980
|
"api-keys",
|
|
1914
1981
|
"personal-access-tokens",
|
|
@@ -1944,7 +2011,6 @@ var COLLECTIONS = [
|
|
|
1944
2011
|
"transactions",
|
|
1945
2012
|
"customers",
|
|
1946
2013
|
"customer-profiles",
|
|
1947
|
-
"customer-profile-lists",
|
|
1948
2014
|
"customer-addresses",
|
|
1949
2015
|
"carts",
|
|
1950
2016
|
"cart-items",
|
|
@@ -1992,6 +2058,7 @@ var COLLECTIONS = [
|
|
|
1992
2058
|
"reaction-types",
|
|
1993
2059
|
"bookmarks",
|
|
1994
2060
|
"post-categories",
|
|
2061
|
+
"customer-profile-lists",
|
|
1995
2062
|
// Events
|
|
1996
2063
|
"event-calendars",
|
|
1997
2064
|
"events",
|
|
@@ -2832,17 +2899,21 @@ function mediaArray(values) {
|
|
|
2832
2899
|
return values.filter(isPresentMedia);
|
|
2833
2900
|
}
|
|
2834
2901
|
function buildSelectionMedia(detail, selectedVariant, matchingVariants, selectedValues) {
|
|
2902
|
+
const selectedVariantImages = mediaArray(selectedVariant?.images);
|
|
2835
2903
|
const selectedValueImages = selectedValues.flatMap(
|
|
2836
2904
|
(value) => mediaArray(value.images)
|
|
2837
2905
|
);
|
|
2906
|
+
const matchingVariantImages = matchingVariants.flatMap(
|
|
2907
|
+
(variant) => mediaArray(variant.images)
|
|
2908
|
+
);
|
|
2838
2909
|
const selectedValuePrimary = selectedValues.map((value) => firstMedia(value.thumbnail) ?? firstMedia(value.images)).find((value) => value != null) ?? null;
|
|
2839
2910
|
const selectedVariantPrimary = firstMedia(selectedVariant?.thumbnail) ?? firstMedia(selectedVariant?.images);
|
|
2840
2911
|
const matchingVariantPrimary = matchingVariants.map(
|
|
2841
2912
|
(variant) => firstMedia(variant.thumbnail) ?? firstMedia(variant.images)
|
|
2842
2913
|
).find((value) => value != null) ?? null;
|
|
2843
2914
|
const detailImages = mediaArray(detail.images);
|
|
2844
|
-
const primaryImage = selectedVariantPrimary ?? selectedValuePrimary ?? firstMedia(detail.listing.primaryImage) ??
|
|
2845
|
-
const images =
|
|
2915
|
+
const primaryImage = selectedVariantPrimary ?? selectedValuePrimary ?? matchingVariantPrimary ?? firstMedia(detail.listing.primaryImage) ?? firstMedia(detailImages);
|
|
2916
|
+
const images = selectedVariantImages.length > 0 ? selectedVariantImages : selectedValueImages.length > 0 ? selectedValueImages : matchingVariantImages.length > 0 ? matchingVariantImages : detailImages;
|
|
2846
2917
|
return {
|
|
2847
2918
|
primaryImage,
|
|
2848
2919
|
images
|
|
@@ -3133,6 +3204,72 @@ function buildProductListingProjection(product, variants) {
|
|
|
3133
3204
|
availableForSale: availableVariants.length > 0
|
|
3134
3205
|
};
|
|
3135
3206
|
}
|
|
3207
|
+
function buildProductListingCard(item, options = {}) {
|
|
3208
|
+
const product = item.product;
|
|
3209
|
+
const groups = item.groups;
|
|
3210
|
+
const primaryImage = firstMedia(product.thumbnail) ?? firstMedia(product.images ?? null) ?? null;
|
|
3211
|
+
const priceRange = aggregateListingPriceRange(groups);
|
|
3212
|
+
const availableForSale = groups.some(
|
|
3213
|
+
(group) => group.listing.availableForSale
|
|
3214
|
+
);
|
|
3215
|
+
const swatches = groups.length > 1 ? groups.map((group) => buildListingSwatch(product, group, options)) : [];
|
|
3216
|
+
return {
|
|
3217
|
+
id: String(product.id),
|
|
3218
|
+
href: buildProductHref({ slug: product.slug }, void 0, options),
|
|
3219
|
+
title: product.title,
|
|
3220
|
+
primaryImage,
|
|
3221
|
+
priceRange,
|
|
3222
|
+
availableForSale,
|
|
3223
|
+
swatches
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
function aggregateListingPriceRange(groups) {
|
|
3227
|
+
const minPrice = minOfNullable(groups.map((g) => g.listing.minPrice));
|
|
3228
|
+
const maxPrice = maxOfNullable(groups.map((g) => g.listing.maxPrice));
|
|
3229
|
+
const minCompareAtPrice = minOfNullable(
|
|
3230
|
+
groups.map((g) => g.listing.minCompareAtPrice)
|
|
3231
|
+
);
|
|
3232
|
+
const maxCompareAtPrice = maxOfNullable(
|
|
3233
|
+
groups.map((g) => g.listing.maxCompareAtPrice)
|
|
3234
|
+
);
|
|
3235
|
+
const isPriceRange = minPrice !== null && maxPrice !== null && minPrice !== maxPrice;
|
|
3236
|
+
return {
|
|
3237
|
+
minPrice,
|
|
3238
|
+
maxPrice,
|
|
3239
|
+
minCompareAtPrice,
|
|
3240
|
+
maxCompareAtPrice,
|
|
3241
|
+
isPriceRange
|
|
3242
|
+
};
|
|
3243
|
+
}
|
|
3244
|
+
function buildListingSwatch(product, group, options) {
|
|
3245
|
+
const thumbnail = firstMedia(group.optionValueThumbnail) ?? firstMedia(group.optionValueImages) ?? null;
|
|
3246
|
+
return {
|
|
3247
|
+
optionId: group.optionId,
|
|
3248
|
+
optionValueId: group.optionValueId,
|
|
3249
|
+
label: group.optionValueLabel,
|
|
3250
|
+
swatchColor: group.optionValueSwatchColor ?? null,
|
|
3251
|
+
thumbnail,
|
|
3252
|
+
href: buildProductHref(
|
|
3253
|
+
{ slug: product.slug },
|
|
3254
|
+
{
|
|
3255
|
+
optionId: group.optionId,
|
|
3256
|
+
optionValueId: group.optionValueId,
|
|
3257
|
+
optionValueSlug: group.optionValueSlug,
|
|
3258
|
+
listing: group.listing
|
|
3259
|
+
},
|
|
3260
|
+
options
|
|
3261
|
+
),
|
|
3262
|
+
availableForSale: group.listing.availableForSale
|
|
3263
|
+
};
|
|
3264
|
+
}
|
|
3265
|
+
function minOfNullable(values) {
|
|
3266
|
+
const numbers = values.filter((v) => v !== null);
|
|
3267
|
+
return numbers.length === 0 ? null : Math.min(...numbers);
|
|
3268
|
+
}
|
|
3269
|
+
function maxOfNullable(values) {
|
|
3270
|
+
const numbers = values.filter((v) => v !== null);
|
|
3271
|
+
return numbers.length === 0 ? null : Math.max(...numbers);
|
|
3272
|
+
}
|
|
3136
3273
|
function buildProductListingGroupsByOption(args) {
|
|
3137
3274
|
const primaryOptionId = args.primaryOptionId ?? void 0;
|
|
3138
3275
|
if (!primaryOptionId) return [];
|