@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.
Files changed (56) hide show
  1. package/README.md +160 -48
  2. package/dist/analytics/react.cjs.map +1 -1
  3. package/dist/analytics/react.js.map +1 -1
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js.map +1 -1
  6. package/dist/client.cjs +91 -62
  7. package/dist/client.cjs.map +1 -1
  8. package/dist/client.d.cts +6 -6
  9. package/dist/client.d.ts +6 -6
  10. package/dist/client.js +91 -62
  11. package/dist/client.js.map +1 -1
  12. package/dist/{collection-client-QPbwimkU.d.cts → collection-client-CORhppPb.d.cts} +3 -3
  13. package/dist/{collection-client-B9d9kr1d.d.ts → collection-client-DPGXnhoF.d.ts} +3 -3
  14. package/dist/{const-VZuk2tWc.d.cts → const-Brk2Ff0q.d.cts} +4 -4
  15. package/dist/{const-B75IFDRi.d.ts → const-DcY2_z9O.d.ts} +4 -4
  16. package/dist/{index-B2WbhEgT.d.cts → index-BGEhoDUs.d.cts} +1 -1
  17. package/dist/{index-B2WbhEgT.d.ts → index-BGEhoDUs.d.ts} +1 -1
  18. package/dist/index.cjs +214 -66
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +9 -9
  21. package/dist/index.d.ts +9 -9
  22. package/dist/index.js +214 -66
  23. package/dist/index.js.map +1 -1
  24. package/dist/{payload-types-DPjO_IbQ.d.cts → payload-types-DVK1QCeU.d.cts} +793 -531
  25. package/dist/{payload-types-DPjO_IbQ.d.ts → payload-types-DVK1QCeU.d.ts} +793 -531
  26. package/dist/query.cjs +63 -13
  27. package/dist/query.cjs.map +1 -1
  28. package/dist/query.d.cts +17 -17
  29. package/dist/query.d.ts +17 -17
  30. package/dist/query.js +63 -13
  31. package/dist/query.js.map +1 -1
  32. package/dist/realtime.cjs.map +1 -1
  33. package/dist/realtime.d.cts +2 -2
  34. package/dist/realtime.d.ts +2 -2
  35. package/dist/realtime.js.map +1 -1
  36. package/dist/server.cjs +176 -18
  37. package/dist/server.cjs.map +1 -1
  38. package/dist/server.d.cts +124 -7
  39. package/dist/server.d.ts +124 -7
  40. package/dist/server.js +176 -18
  41. package/dist/server.js.map +1 -1
  42. package/dist/{types-BwT0eeaz.d.cts → types-ByMrR_Z_.d.cts} +6 -2
  43. package/dist/{types-DuSKPiY5.d.ts → types-CAkWqIr6.d.cts} +82 -9
  44. package/dist/{types-Dlb2mwpX.d.cts → types-CYMSBkJC.d.ts} +82 -9
  45. package/dist/{types-1fBLrYU7.d.ts → types-DUPC7Xn6.d.ts} +6 -2
  46. package/dist/ui/form.d.cts +1 -1
  47. package/dist/ui/form.d.ts +1 -1
  48. package/dist/ui/video.d.cts +1 -1
  49. package/dist/ui/video.d.ts +1 -1
  50. package/dist/webhook.cjs +48 -1
  51. package/dist/webhook.cjs.map +1 -1
  52. package/dist/webhook.d.cts +73 -4
  53. package/dist/webhook.d.ts +73 -4
  54. package/dist/webhook.js +48 -1
  55. package/dist/webhook.js.map +1 -1
  56. package/package.json +3 -3
package/dist/server.d.cts CHANGED
@@ -1,10 +1,10 @@
1
- import { S as ServerCollectionClient } from './collection-client-QPbwimkU.cjs';
2
- export { C as CollectionClient } from './collection-client-QPbwimkU.cjs';
3
- import { B as BaseApi, aJ as ServerApiOptions, aM as StockCheckParams, aN as StockCheckResponse, Y as ListingGroupsParams, am as ProductListingGroupsResponse, ab as ProductDetailParams, a2 as ProductDetail, bc as ProductUpsertParams, bd as ProductUpsertResponse, k as AddItemParams, aQ as UpdateItemParams, aE as RemoveItemParams, l as ApplyDiscountParams, aD as RemoveDiscountParams, t as ClearCartParams, s as CheckoutParams, G as CreateOrderParams, aR as UpdateOrderParams, aU as UpdateTransactionParams, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, aP as UpdateFulfillmentParams, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, H as CreateReturnParams, aT as UpdateReturnParams, aI as ReturnWithRefundParams, aV as ValidateDiscountParams, aW as ValidateDiscountResult, o as CalculateShippingParams, p as CalculateShippingResult, a as CommunityClient, c as ClientState, be as ClientServerConfig } from './types-Dlb2mwpX.cjs';
4
- import { h as Cart, i as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-DPjO_IbQ.cjs';
1
+ import { S as ServerCollectionClient } from './collection-client-CORhppPb.cjs';
2
+ export { C as CollectionClient } from './collection-client-CORhppPb.cjs';
3
+ import { B as BaseApi, aQ as ServerApiOptions, aT as StockCheckParams, aU as StockCheckResponse, _ as ListingGroupsParams, as as ProductListingGroupsResponse, ad as ProductDetailParams, a4 as ProductDetail, bk as ProductDetailPreviewParams, bl as ProductDetailPreviewOptions, bm as ProductUpsertParams, bn as ProductUpsertResponse, k as AddItemParams, aX as UpdateItemParams, aL as RemoveItemParams, l as ApplyDiscountParams, aK as RemoveDiscountParams, t as ClearCartParams, s as CheckoutParams, H as CreateOrderParams, aY as UpdateOrderParams, a$ as UpdateTransactionParams, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, aW as UpdateFulfillmentParams, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, I as CreateReturnParams, a_ as UpdateReturnParams, aP as ReturnWithRefundParams, b0 as ValidateDiscountParams, b1 as ValidateDiscountResult, o as CalculateShippingParams, p as CalculateShippingResult, a as CommunityClient, c as ClientState, bo as ClientServerConfig } from './types-CAkWqIr6.cjs';
4
+ import { i as Cart, j as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-DVK1QCeU.cjs';
5
5
  import './metadata.cjs';
6
- import './const-VZuk2tWc.cjs';
7
- import './types-BwT0eeaz.cjs';
6
+ import './const-Brk2Ff0q.cjs';
7
+ import './types-ByMrR_Z_.cjs';
8
8
 
9
9
  type ModerationApiOptions = ServerApiOptions;
10
10
  interface CommunityBan {
@@ -45,6 +45,7 @@ declare class ServerCommerceClient {
45
45
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
46
46
  listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
47
47
  detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
48
+ previewDetail: (params: ProductDetailPreviewParams, options: ProductDetailPreviewOptions) => Promise<ProductDetail | null>;
48
49
  upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
49
50
  };
50
51
  readonly cart: {
@@ -85,8 +86,121 @@ declare class ServerCommerceClient {
85
86
  constructor(options: ServerCommerceClientOptions);
86
87
  }
87
88
 
89
+ type TenantIntrospectionApiOptions = ServerApiOptions;
90
+ type TenantFeatureProgressFeature = 'ecommerce';
91
+ interface TenantFeatureProgressInput {
92
+ feature: TenantFeatureProgressFeature;
93
+ includeEvidence?: boolean;
94
+ }
95
+ type TenantFeatureProgressStatus = 'ready' | 'attention' | 'blocked';
96
+ type TenantFeatureProgressItemState = 'complete' | 'incomplete' | 'blocked' | 'attention' | 'optional' | 'unknown' | 'manual' | 'not-applicable';
97
+ type TenantFeatureProgressSeverity = 'required' | 'recommended' | 'optional';
98
+ type TenantFeatureProgressEvidenceValue = string | number | boolean | null;
99
+ interface TenantFeatureProgressItem {
100
+ id: string;
101
+ title: string;
102
+ state: TenantFeatureProgressItemState;
103
+ severity: TenantFeatureProgressSeverity;
104
+ summary: string;
105
+ evidence?: Record<string, TenantFeatureProgressEvidenceValue>;
106
+ }
107
+ interface TenantFeatureProgressGroup {
108
+ id: string;
109
+ title: string;
110
+ summary?: string;
111
+ items: TenantFeatureProgressItem[];
112
+ }
113
+ interface TenantFeatureProgressResponse {
114
+ schemaVersion: 1;
115
+ feature: TenantFeatureProgressFeature;
116
+ status: TenantFeatureProgressStatus;
117
+ generatedAt: string;
118
+ tenant: {
119
+ id: string;
120
+ name: string;
121
+ plan: string;
122
+ };
123
+ capability: {
124
+ effectiveFeatures: string[];
125
+ planBlocked: string[];
126
+ closureAdded: string[];
127
+ };
128
+ summary: {
129
+ complete: number;
130
+ total: number;
131
+ blocking: number;
132
+ manual: number;
133
+ unknown: number;
134
+ };
135
+ groups: TenantFeatureProgressGroup[];
136
+ }
137
+ interface CollectionFieldSchema {
138
+ name: string;
139
+ path: string;
140
+ type: string;
141
+ required?: true;
142
+ unique?: true;
143
+ hasMany?: true;
144
+ relationTo?: string | string[];
145
+ options?: Array<{
146
+ label: string;
147
+ value: string;
148
+ }>;
149
+ hidden?: true;
150
+ systemManaged?: true;
151
+ writable?: boolean;
152
+ fields?: CollectionFieldSchema[];
153
+ }
154
+ interface CollectionSchemaResponse {
155
+ contractVersion: 1;
156
+ mode: 'effective';
157
+ collection: {
158
+ slug: string;
159
+ timestamps: boolean;
160
+ alwaysActive: boolean;
161
+ feature: string | null;
162
+ systemFields: string[];
163
+ visibility: {
164
+ collectionHidden: boolean;
165
+ hiddenFields: string[];
166
+ };
167
+ fields: CollectionFieldSchema[];
168
+ };
169
+ }
170
+ interface TenantIntrospectionClient {
171
+ collectionSchema: (collection: string) => Promise<CollectionSchemaResponse>;
172
+ featureProgress: (params: TenantFeatureProgressInput) => Promise<TenantFeatureProgressResponse>;
173
+ }
174
+ declare class TenantIntrospectionApi extends BaseApi implements TenantIntrospectionClient {
175
+ constructor(options: TenantIntrospectionApiOptions);
176
+ collectionSchema(collection: string): Promise<CollectionSchemaResponse>;
177
+ featureProgress(params: TenantFeatureProgressInput): Promise<TenantFeatureProgressResponse>;
178
+ }
179
+
180
+ type PreviewDetailParams = {
181
+ collection: string;
182
+ id: string;
183
+ };
184
+ type PreviewDetailOptions = {
185
+ previewToken: string;
186
+ };
187
+ /**
188
+ * Server-side client for the generic preview detail endpoint
189
+ * (`POST /api/preview/detail`). Returns `null` on 404 so callers can
190
+ * branch on missing previews without try/catch noise.
191
+ *
192
+ * Auth uses the standard server credentials (`secretKey` +
193
+ * `publishableKey`) plus the short-lived `X-Preview-Token` header issued
194
+ * by the Console preview start endpoint.
195
+ */
196
+ declare class ServerPreviewClient extends BaseApi {
197
+ constructor(options: ServerApiOptions);
198
+ detail<T = unknown>(params: PreviewDetailParams, options: PreviewDetailOptions): Promise<T | null>;
199
+ }
200
+
88
201
  declare class ServerClient {
89
202
  commerce: ServerCommerceClient;
203
+ tenant: TenantIntrospectionClient;
90
204
  community: CommunityClient & {
91
205
  moderation: {
92
206
  banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
@@ -95,6 +209,9 @@ declare class ServerClient {
95
209
  }>;
96
210
  };
97
211
  };
212
+ preview: {
213
+ detail: <T = unknown>(params: PreviewDetailParams, options: PreviewDetailOptions) => Promise<T | null>;
214
+ };
98
215
  collections: ServerCollectionClient;
99
216
  lastRequestId: string | null;
100
217
  protected state: ClientState;
@@ -109,4 +226,4 @@ declare class ServerClient {
109
226
  */
110
227
  declare function createServerClient(options: ClientServerConfig): ServerClient;
111
228
 
112
- export { ClientServerConfig, CommunityClient, ModerationApi, ServerClient, ServerCollectionClient, ServerCommerceClient, createServerClient };
229
+ export { ClientServerConfig, type CollectionFieldSchema, type CollectionSchemaResponse, CommunityClient, ModerationApi, type PreviewDetailOptions, type PreviewDetailParams, ServerClient, ServerCollectionClient, ServerCommerceClient, ServerPreviewClient, type TenantFeatureProgressEvidenceValue, type TenantFeatureProgressFeature, type TenantFeatureProgressGroup, type TenantFeatureProgressInput, type TenantFeatureProgressItem, type TenantFeatureProgressItemState, type TenantFeatureProgressResponse, type TenantFeatureProgressSeverity, type TenantFeatureProgressStatus, TenantIntrospectionApi, type TenantIntrospectionApiOptions, type TenantIntrospectionClient, createServerClient };
package/dist/server.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { S as ServerCollectionClient } from './collection-client-B9d9kr1d.js';
2
- export { C as CollectionClient } from './collection-client-B9d9kr1d.js';
3
- import { B as BaseApi, aJ as ServerApiOptions, aM as StockCheckParams, aN as StockCheckResponse, Y as ListingGroupsParams, am as ProductListingGroupsResponse, ab as ProductDetailParams, a2 as ProductDetail, bc as ProductUpsertParams, bd as ProductUpsertResponse, k as AddItemParams, aQ as UpdateItemParams, aE as RemoveItemParams, l as ApplyDiscountParams, aD as RemoveDiscountParams, t as ClearCartParams, s as CheckoutParams, G as CreateOrderParams, aR as UpdateOrderParams, aU as UpdateTransactionParams, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, aP as UpdateFulfillmentParams, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, H as CreateReturnParams, aT as UpdateReturnParams, aI as ReturnWithRefundParams, aV as ValidateDiscountParams, aW as ValidateDiscountResult, o as CalculateShippingParams, p as CalculateShippingResult, a as CommunityClient, c as ClientState, be as ClientServerConfig } from './types-DuSKPiY5.js';
4
- import { h as Cart, i as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-DPjO_IbQ.js';
1
+ import { S as ServerCollectionClient } from './collection-client-DPGXnhoF.js';
2
+ export { C as CollectionClient } from './collection-client-DPGXnhoF.js';
3
+ import { B as BaseApi, aQ as ServerApiOptions, aT as StockCheckParams, aU as StockCheckResponse, _ as ListingGroupsParams, as as ProductListingGroupsResponse, ad as ProductDetailParams, a4 as ProductDetail, bk as ProductDetailPreviewParams, bl as ProductDetailPreviewOptions, bm as ProductUpsertParams, bn as ProductUpsertResponse, k as AddItemParams, aX as UpdateItemParams, aL as RemoveItemParams, l as ApplyDiscountParams, aK as RemoveDiscountParams, t as ClearCartParams, s as CheckoutParams, H as CreateOrderParams, aY as UpdateOrderParams, a$ as UpdateTransactionParams, y as ConfirmPaymentParams, z as ConfirmPaymentResponse, F as CreateFulfillmentParams, aW as UpdateFulfillmentParams, m as BulkImportFulfillmentsParams, n as BulkImportFulfillmentsResponse, I as CreateReturnParams, a_ as UpdateReturnParams, aP as ReturnWithRefundParams, b0 as ValidateDiscountParams, b1 as ValidateDiscountResult, o as CalculateShippingParams, p as CalculateShippingResult, a as CommunityClient, c as ClientState, bo as ClientServerConfig } from './types-CYMSBkJC.js';
4
+ import { i as Cart, j as CartItem, O as Order, m as Transaction, n as Fulfillment, o as Return } from './payload-types-DVK1QCeU.js';
5
5
  import './metadata.js';
6
- import './const-B75IFDRi.js';
7
- import './types-1fBLrYU7.js';
6
+ import './const-DcY2_z9O.js';
7
+ import './types-DUPC7Xn6.js';
8
8
 
9
9
  type ModerationApiOptions = ServerApiOptions;
10
10
  interface CommunityBan {
@@ -45,6 +45,7 @@ declare class ServerCommerceClient {
45
45
  stockCheck: (params: StockCheckParams) => Promise<StockCheckResponse>;
46
46
  listingGroups: (params: ListingGroupsParams) => Promise<ProductListingGroupsResponse>;
47
47
  detail: (params: ProductDetailParams) => Promise<ProductDetail | null>;
48
+ previewDetail: (params: ProductDetailPreviewParams, options: ProductDetailPreviewOptions) => Promise<ProductDetail | null>;
48
49
  upsert: (params: ProductUpsertParams) => Promise<ProductUpsertResponse>;
49
50
  };
50
51
  readonly cart: {
@@ -85,8 +86,121 @@ declare class ServerCommerceClient {
85
86
  constructor(options: ServerCommerceClientOptions);
86
87
  }
87
88
 
89
+ type TenantIntrospectionApiOptions = ServerApiOptions;
90
+ type TenantFeatureProgressFeature = 'ecommerce';
91
+ interface TenantFeatureProgressInput {
92
+ feature: TenantFeatureProgressFeature;
93
+ includeEvidence?: boolean;
94
+ }
95
+ type TenantFeatureProgressStatus = 'ready' | 'attention' | 'blocked';
96
+ type TenantFeatureProgressItemState = 'complete' | 'incomplete' | 'blocked' | 'attention' | 'optional' | 'unknown' | 'manual' | 'not-applicable';
97
+ type TenantFeatureProgressSeverity = 'required' | 'recommended' | 'optional';
98
+ type TenantFeatureProgressEvidenceValue = string | number | boolean | null;
99
+ interface TenantFeatureProgressItem {
100
+ id: string;
101
+ title: string;
102
+ state: TenantFeatureProgressItemState;
103
+ severity: TenantFeatureProgressSeverity;
104
+ summary: string;
105
+ evidence?: Record<string, TenantFeatureProgressEvidenceValue>;
106
+ }
107
+ interface TenantFeatureProgressGroup {
108
+ id: string;
109
+ title: string;
110
+ summary?: string;
111
+ items: TenantFeatureProgressItem[];
112
+ }
113
+ interface TenantFeatureProgressResponse {
114
+ schemaVersion: 1;
115
+ feature: TenantFeatureProgressFeature;
116
+ status: TenantFeatureProgressStatus;
117
+ generatedAt: string;
118
+ tenant: {
119
+ id: string;
120
+ name: string;
121
+ plan: string;
122
+ };
123
+ capability: {
124
+ effectiveFeatures: string[];
125
+ planBlocked: string[];
126
+ closureAdded: string[];
127
+ };
128
+ summary: {
129
+ complete: number;
130
+ total: number;
131
+ blocking: number;
132
+ manual: number;
133
+ unknown: number;
134
+ };
135
+ groups: TenantFeatureProgressGroup[];
136
+ }
137
+ interface CollectionFieldSchema {
138
+ name: string;
139
+ path: string;
140
+ type: string;
141
+ required?: true;
142
+ unique?: true;
143
+ hasMany?: true;
144
+ relationTo?: string | string[];
145
+ options?: Array<{
146
+ label: string;
147
+ value: string;
148
+ }>;
149
+ hidden?: true;
150
+ systemManaged?: true;
151
+ writable?: boolean;
152
+ fields?: CollectionFieldSchema[];
153
+ }
154
+ interface CollectionSchemaResponse {
155
+ contractVersion: 1;
156
+ mode: 'effective';
157
+ collection: {
158
+ slug: string;
159
+ timestamps: boolean;
160
+ alwaysActive: boolean;
161
+ feature: string | null;
162
+ systemFields: string[];
163
+ visibility: {
164
+ collectionHidden: boolean;
165
+ hiddenFields: string[];
166
+ };
167
+ fields: CollectionFieldSchema[];
168
+ };
169
+ }
170
+ interface TenantIntrospectionClient {
171
+ collectionSchema: (collection: string) => Promise<CollectionSchemaResponse>;
172
+ featureProgress: (params: TenantFeatureProgressInput) => Promise<TenantFeatureProgressResponse>;
173
+ }
174
+ declare class TenantIntrospectionApi extends BaseApi implements TenantIntrospectionClient {
175
+ constructor(options: TenantIntrospectionApiOptions);
176
+ collectionSchema(collection: string): Promise<CollectionSchemaResponse>;
177
+ featureProgress(params: TenantFeatureProgressInput): Promise<TenantFeatureProgressResponse>;
178
+ }
179
+
180
+ type PreviewDetailParams = {
181
+ collection: string;
182
+ id: string;
183
+ };
184
+ type PreviewDetailOptions = {
185
+ previewToken: string;
186
+ };
187
+ /**
188
+ * Server-side client for the generic preview detail endpoint
189
+ * (`POST /api/preview/detail`). Returns `null` on 404 so callers can
190
+ * branch on missing previews without try/catch noise.
191
+ *
192
+ * Auth uses the standard server credentials (`secretKey` +
193
+ * `publishableKey`) plus the short-lived `X-Preview-Token` header issued
194
+ * by the Console preview start endpoint.
195
+ */
196
+ declare class ServerPreviewClient extends BaseApi {
197
+ constructor(options: ServerApiOptions);
198
+ detail<T = unknown>(params: PreviewDetailParams, options: PreviewDetailOptions): Promise<T | null>;
199
+ }
200
+
88
201
  declare class ServerClient {
89
202
  commerce: ServerCommerceClient;
203
+ tenant: TenantIntrospectionClient;
90
204
  community: CommunityClient & {
91
205
  moderation: {
92
206
  banCustomer: (p: BanCustomerParams) => Promise<CommunityBan>;
@@ -95,6 +209,9 @@ declare class ServerClient {
95
209
  }>;
96
210
  };
97
211
  };
212
+ preview: {
213
+ detail: <T = unknown>(params: PreviewDetailParams, options: PreviewDetailOptions) => Promise<T | null>;
214
+ };
98
215
  collections: ServerCollectionClient;
99
216
  lastRequestId: string | null;
100
217
  protected state: ClientState;
@@ -109,4 +226,4 @@ declare class ServerClient {
109
226
  */
110
227
  declare function createServerClient(options: ClientServerConfig): ServerClient;
111
228
 
112
- export { ClientServerConfig, CommunityClient, ModerationApi, ServerClient, ServerCollectionClient, ServerCommerceClient, createServerClient };
229
+ export { ClientServerConfig, type CollectionFieldSchema, type CollectionSchemaResponse, CommunityClient, ModerationApi, type PreviewDetailOptions, type PreviewDetailParams, ServerClient, ServerCollectionClient, ServerCommerceClient, ServerPreviewClient, type TenantFeatureProgressEvidenceValue, type TenantFeatureProgressFeature, type TenantFeatureProgressGroup, type TenantFeatureProgressInput, type TenantFeatureProgressItem, type TenantFeatureProgressItemState, type TenantFeatureProgressResponse, type TenantFeatureProgressSeverity, type TenantFeatureProgressStatus, TenantIntrospectionApi, type TenantIntrospectionApiOptions, type TenantIntrospectionClient, createServerClient };
package/dist/server.js CHANGED
@@ -45,8 +45,16 @@ var ValidationError = class extends SDKError {
45
45
  }
46
46
  };
47
47
  var ApiError = class extends SDKError {
48
- constructor(message, status, details, userMessage, suggestion) {
49
- super("API_ERROR", message, status, details, userMessage, suggestion);
48
+ constructor(message, status, details, userMessage, suggestion, requestId) {
49
+ super(
50
+ "API_ERROR",
51
+ message,
52
+ status,
53
+ details,
54
+ userMessage,
55
+ suggestion,
56
+ requestId
57
+ );
50
58
  this.name = "ApiError";
51
59
  }
52
60
  };
@@ -77,19 +85,43 @@ var UsageLimitError = class extends SDKError {
77
85
  };
78
86
  var AuthError = class extends SDKError {
79
87
  constructor(message, details, userMessage, suggestion, requestId) {
80
- super("auth_error", message, 401, details, userMessage, suggestion, requestId);
88
+ super(
89
+ "auth_error",
90
+ message,
91
+ 401,
92
+ details,
93
+ userMessage,
94
+ suggestion,
95
+ requestId
96
+ );
81
97
  this.name = "AuthError";
82
98
  }
83
99
  };
84
100
  var PermissionError = class extends SDKError {
85
101
  constructor(message, details, userMessage, suggestion, requestId) {
86
- super("permission_error", message, 403, details, userMessage, suggestion, requestId);
102
+ super(
103
+ "permission_error",
104
+ message,
105
+ 403,
106
+ details,
107
+ userMessage,
108
+ suggestion,
109
+ requestId
110
+ );
87
111
  this.name = "PermissionError";
88
112
  }
89
113
  };
90
114
  var NotFoundError = class extends SDKError {
91
115
  constructor(message, details, userMessage, suggestion, requestId) {
92
- super("not_found", message, 404, details, userMessage, suggestion, requestId);
116
+ super(
117
+ "not_found",
118
+ message,
119
+ 404,
120
+ details,
121
+ userMessage,
122
+ suggestion,
123
+ requestId
124
+ );
93
125
  this.name = "NotFoundError";
94
126
  }
95
127
  };
@@ -101,14 +133,22 @@ var ConflictError = class extends SDKError {
101
133
  };
102
134
  var RateLimitError = class extends SDKError {
103
135
  constructor(message, retryAfter, details, userMessage, suggestion, requestId) {
104
- super("rate_limit_exceeded", message, 429, details, userMessage, suggestion, requestId);
136
+ super(
137
+ "rate_limit_exceeded",
138
+ message,
139
+ 429,
140
+ details,
141
+ userMessage,
142
+ suggestion,
143
+ requestId
144
+ );
105
145
  this.name = "RateLimitError";
106
146
  this.retryAfter = retryAfter;
107
147
  }
108
148
  };
109
149
  var createNetworkError = (message, status, details, userMessage, suggestion) => new NetworkError(message, status, details, userMessage, suggestion);
110
150
  var createValidationError = (message, details, userMessage, suggestion, status) => new ValidationError(message, details, userMessage, suggestion, status);
111
- var createApiError = (message, status, details, userMessage, suggestion) => new ApiError(message, status, details, userMessage, suggestion);
151
+ var createApiError = (message, status, details, userMessage, suggestion, requestId) => new ApiError(message, status, details, userMessage, suggestion, requestId);
112
152
  var createConfigError = (message, details, userMessage, suggestion) => new ConfigError(message, details, userMessage, suggestion);
113
153
  var createTimeoutError = (message, details, userMessage, suggestion) => new TimeoutError(message, details, userMessage, suggestion);
114
154
  var createUsageLimitError = (message, usage, details, userMessage, suggestion) => new UsageLimitError(message, usage, details, userMessage, suggestion);
@@ -116,7 +156,14 @@ var createAuthError = (message, details, userMessage, suggestion, requestId) =>
116
156
  var createPermissionError = (message, details, userMessage, suggestion, requestId) => new PermissionError(message, details, userMessage, suggestion, requestId);
117
157
  var createNotFoundError = (message, details, userMessage, suggestion, requestId) => new NotFoundError(message, details, userMessage, suggestion, requestId);
118
158
  var createConflictError = (message, details, userMessage, suggestion, requestId) => new ConflictError(message, details, userMessage, suggestion, requestId);
119
- var createRateLimitError = (message, retryAfter, details, userMessage, suggestion, requestId) => new RateLimitError(message, retryAfter, details, userMessage, suggestion, requestId);
159
+ var createRateLimitError = (message, retryAfter, details, userMessage, suggestion, requestId) => new RateLimitError(
160
+ message,
161
+ retryAfter,
162
+ details,
163
+ userMessage,
164
+ suggestion,
165
+ requestId
166
+ );
120
167
 
121
168
  // src/core/internal/utils/credentials.ts
122
169
  function requirePublishableKeyForSecret(apiName, publishableKey, secretKey) {
@@ -156,6 +203,22 @@ function debugLog(debug, type, message, data) {
156
203
  console.groupEnd();
157
204
  }
158
205
  }
206
+ function redactSensitiveHeader(value) {
207
+ const prefix = value.toLowerCase().startsWith("bearer ") ? "Bearer " : "";
208
+ return value.length > 20 ? `${prefix}...****${value.slice(-8)}` : "****";
209
+ }
210
+ function redactSensitiveHeaders(headers) {
211
+ const redacted = Object.fromEntries(headers.entries());
212
+ if (redacted.authorization) {
213
+ redacted.authorization = redactSensitiveHeader(redacted.authorization);
214
+ }
215
+ if (redacted["x-preview-token"]) {
216
+ redacted["x-preview-token"] = redactSensitiveHeader(
217
+ redacted["x-preview-token"]
218
+ );
219
+ }
220
+ return redacted;
221
+ }
159
222
  function getErrorSuggestion(status) {
160
223
  if (status === 400)
161
224
  return "The request data failed validation. Check field values and types.";
@@ -230,6 +293,12 @@ async function parseErrorBody(response) {
230
293
  return fallback;
231
294
  }
232
295
  }
296
+ function getParsedErrorSuggestion(status, parsed) {
297
+ if (status === 403 && parsed.reason === "origin_not_allowed") {
298
+ return "Add the request origin to the tenant Browser API origins, then retry the browser request.";
299
+ }
300
+ return getErrorSuggestion(status);
301
+ }
233
302
  async function delay(ms) {
234
303
  return new Promise((resolve) => setTimeout(resolve, ms));
235
304
  }
@@ -243,7 +312,7 @@ function createHttpStatusError(status, parsed, details, requestId) {
243
312
  ...parsed.errors && { errors: parsed.errors },
244
313
  ...parsed.body && { body: parsed.body }
245
314
  };
246
- const suggestion = getErrorSuggestion(status);
315
+ const suggestion = getParsedErrorSuggestion(status, parsed);
247
316
  if (status === 400 || status === 422) {
248
317
  return attachRequestId(
249
318
  createValidationError(
@@ -349,11 +418,7 @@ async function httpFetch(url, options) {
349
418
  if (!headers.has("Content-Type") && requestInit.body && !(requestInit.body instanceof FormData)) {
350
419
  headers.set("Content-Type", "application/json");
351
420
  }
352
- const redactedHeaders = Object.fromEntries(headers.entries());
353
- if (redactedHeaders["authorization"]) {
354
- const token = redactedHeaders["authorization"];
355
- redactedHeaders["authorization"] = token.length > 20 ? `Bearer ...****${token.slice(-8)}` : "****";
356
- }
421
+ const redactedHeaders = redactSensitiveHeaders(headers);
357
422
  debugLog(debug, "request", url, {
358
423
  method: requestInit.method || "GET",
359
424
  headers: redactedHeaders,
@@ -371,7 +436,7 @@ async function httpFetch(url, options) {
371
436
  debugLog(debug, "response", url, {
372
437
  status: response.status,
373
438
  statusText: response.statusText,
374
- headers: Object.fromEntries(response.headers.entries())
439
+ headers: redactSensitiveHeaders(response.headers)
375
440
  });
376
441
  if (!response.ok) {
377
442
  if (isUsageLimitExceededResponse(response)) {
@@ -1020,7 +1085,7 @@ async function parseApiResponse(response, endpoint) {
1020
1085
  if (reason === "validation_failed") {
1021
1086
  throw attachRequestId(createValidationError(errorMessage, data, errorMessage), requestId);
1022
1087
  }
1023
- if (reason === "token_expired" || reason === "token_invalid" || reason === "key_invalid" || reason === "key_revoked") {
1088
+ if (reason === "token_expired" || reason === "token_invalid" || reason === "preview_token_invalid" || reason === "preview_token_required" || reason === "key_invalid" || reason === "key_revoked") {
1024
1089
  throw attachRequestId(createAuthError(errorMessage, data, errorMessage), requestId);
1025
1090
  }
1026
1091
  if (reason === "forbidden") {
@@ -1357,7 +1422,7 @@ var ProductApi = class extends BaseApi {
1357
1422
  /**
1358
1423
  * Fetch full product detail by slug or id.
1359
1424
  * Returns `null` on 404 regardless of reason (`not_found` / `not_published` /
1360
- * `tenant_mismatch` / `feature_disabled`). For the reason behind a null,
1425
+ * `feature_disabled`). For the reason behind a null,
1361
1426
  * inspect `client.lastRequestId` against backend logs.
1362
1427
  */
1363
1428
  async detail(params) {
@@ -1449,7 +1514,61 @@ var OrderApi = class extends BaseApi {
1449
1514
  }
1450
1515
  };
1451
1516
 
1517
+ // src/core/preview/server-preview-client.ts
1518
+ var ServerPreviewClient = class extends BaseApi {
1519
+ constructor(options) {
1520
+ super("ServerPreviewClient", options);
1521
+ }
1522
+ async detail(params, options) {
1523
+ let response;
1524
+ try {
1525
+ response = await httpFetch("/api/preview/detail", {
1526
+ method: "POST",
1527
+ apiUrl: this.apiUrl,
1528
+ publishableKey: this.publishableKey,
1529
+ secretKey: this.secretKey,
1530
+ body: JSON.stringify(params),
1531
+ headers: { "X-Preview-Token": options.previewToken }
1532
+ });
1533
+ } catch (err) {
1534
+ const id = err instanceof SDKError ? err.requestId ?? null : null;
1535
+ this.onRequestId?.(id);
1536
+ if (err instanceof NotFoundError) return null;
1537
+ throw err;
1538
+ }
1539
+ const requestId = response.headers.get("x-request-id") ?? null;
1540
+ this.onRequestId?.(requestId);
1541
+ try {
1542
+ return await response.json();
1543
+ } catch (err) {
1544
+ if (err instanceof SyntaxError) {
1545
+ throw createApiError(
1546
+ "Invalid JSON response from /api/preview/detail",
1547
+ 200,
1548
+ void 0,
1549
+ "Server returned an invalid response.",
1550
+ "Check if the API endpoint is available.",
1551
+ requestId ?? void 0
1552
+ );
1553
+ }
1554
+ throw err;
1555
+ }
1556
+ }
1557
+ };
1558
+
1452
1559
  // src/core/commerce/server-commerce-client.ts
1560
+ var PreviewProductApi = class extends ProductApi {
1561
+ constructor(options) {
1562
+ super(options);
1563
+ this.previewApi = new ServerPreviewClient(options);
1564
+ }
1565
+ async previewDetail(params, options) {
1566
+ return this.previewApi.detail(
1567
+ { collection: "products", id: params.id },
1568
+ options
1569
+ );
1570
+ }
1571
+ };
1453
1572
  var ServerCommerceClient = class {
1454
1573
  constructor(options) {
1455
1574
  const publishableKey = requirePublishableKeyForSecret(
@@ -1463,7 +1582,7 @@ var ServerCommerceClient = class {
1463
1582
  apiUrl: options.apiUrl,
1464
1583
  onRequestId: options.onRequestId
1465
1584
  };
1466
- const productApi = new ProductApi(serverOptions);
1585
+ const productApi = new PreviewProductApi(serverOptions);
1467
1586
  const cartApi = new CartApi(serverOptions);
1468
1587
  const discountApi = new DiscountApi(serverOptions);
1469
1588
  const shippingApi = new ShippingApi(serverOptions);
@@ -1472,6 +1591,7 @@ var ServerCommerceClient = class {
1472
1591
  stockCheck: productApi.stockCheck.bind(productApi),
1473
1592
  listingGroups: productApi.listingGroups.bind(productApi),
1474
1593
  detail: productApi.detail.bind(productApi),
1594
+ previewDetail: productApi.previewDetail.bind(productApi),
1475
1595
  upsert: productApi.upsert.bind(productApi)
1476
1596
  };
1477
1597
  this.cart = {
@@ -1505,6 +1625,29 @@ var ServerCommerceClient = class {
1505
1625
  }
1506
1626
  };
1507
1627
 
1628
+ // src/core/api/tenant-introspection-api.ts
1629
+ var TenantIntrospectionApi = class extends BaseApi {
1630
+ constructor(options) {
1631
+ super("TenantIntrospectionApi", options);
1632
+ }
1633
+ collectionSchema(collection) {
1634
+ return this.request(
1635
+ `/api/tenants/schema/${encodeURIComponent(collection)}`,
1636
+ void 0,
1637
+ { method: "GET" }
1638
+ );
1639
+ }
1640
+ featureProgress(params) {
1641
+ const search = new URLSearchParams({ feature: params.feature });
1642
+ if (params.includeEvidence) search.set("includeEvidence", "true");
1643
+ return this.request(
1644
+ `/api/tenants/feature-progress?${search.toString()}`,
1645
+ void 0,
1646
+ { method: "GET" }
1647
+ );
1648
+ }
1649
+ };
1650
+
1508
1651
  // src/core/client/client.server.ts
1509
1652
  var ServerClient = class {
1510
1653
  constructor(options) {
@@ -1538,6 +1681,19 @@ var ServerClient = class {
1538
1681
  onRequestId
1539
1682
  };
1540
1683
  this.commerce = new ServerCommerceClient(serverOptions);
1684
+ const tenantIntrospectionApi = new TenantIntrospectionApi(serverOptions);
1685
+ this.tenant = {
1686
+ collectionSchema: tenantIntrospectionApi.collectionSchema.bind(
1687
+ tenantIntrospectionApi
1688
+ ),
1689
+ featureProgress: tenantIntrospectionApi.featureProgress.bind(
1690
+ tenantIntrospectionApi
1691
+ )
1692
+ };
1693
+ const previewApi = new ServerPreviewClient(serverOptions);
1694
+ this.preview = {
1695
+ detail: previewApi.detail.bind(previewApi)
1696
+ };
1541
1697
  const communityClient = new CommunityClient(serverOptions);
1542
1698
  const moderationApi = new ModerationApi(serverOptions);
1543
1699
  this.community = Object.assign(communityClient, {
@@ -1573,6 +1729,8 @@ export {
1573
1729
  ServerClient,
1574
1730
  ServerCollectionClient,
1575
1731
  ServerCommerceClient,
1732
+ ServerPreviewClient,
1733
+ TenantIntrospectionApi,
1576
1734
  createServerClient
1577
1735
  };
1578
1736
  //# sourceMappingURL=server.js.map