@01.software/sdk 0.35.0 → 0.37.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 +71 -6
- package/dist/analytics/react.cjs +33 -9
- package/dist/analytics/react.cjs.map +1 -1
- package/dist/analytics/react.d.cts +1 -1
- package/dist/analytics/react.d.ts +1 -1
- package/dist/analytics/react.js +33 -9
- package/dist/analytics/react.js.map +1 -1
- package/dist/analytics.cjs +30 -8
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +6 -0
- package/dist/analytics.d.ts +6 -0
- package/dist/analytics.js +30 -8
- package/dist/analytics.js.map +1 -1
- package/dist/client.cjs +94 -114
- 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 +94 -114
- package/dist/client.js.map +1 -1
- package/dist/{collection-client-DkREjhQ9.d.ts → collection-client-DyELGUcL.d.ts} +3 -3
- package/dist/{collection-client-CR2B8c1v.d.cts → collection-client-zOmnxwdA.d.cts} +3 -3
- package/dist/{const-CdqCauHQ.d.ts → const-CK_FPaIn.d.cts} +3 -3
- package/dist/{const-BTvdrXtY.d.cts → const-Dqz05oaG.d.ts} +3 -3
- package/dist/{image-BDz2-AaO.d.cts → image-BDjHp03R.d.cts} +13 -9
- package/dist/{image-BDz2-AaO.d.ts → image-BDjHp03R.d.ts} +13 -9
- package/dist/{index-DK8_NXkh.d.ts → index-DRJs7QIh.d.cts} +9 -6
- package/dist/{index-CjA3U6X3.d.cts → index-DTqoUZk_.d.ts} +9 -6
- package/dist/index.cjs +229 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +229 -136
- package/dist/index.js.map +1 -1
- package/dist/metadata.cjs +5 -3
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.js +5 -3
- package/dist/metadata.js.map +1 -1
- package/dist/{payload-types-C7tb7Xbs.d.cts → payload-types-CREOjFNT.d.cts} +281 -128
- package/dist/{payload-types-C7tb7Xbs.d.ts → payload-types-CREOjFNT.d.ts} +281 -128
- package/dist/query.cjs +5 -3
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +5 -5
- package/dist/query.d.ts +5 -5
- package/dist/query.js +5 -3
- 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 +99 -69
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.js +99 -69
- package/dist/server.js.map +1 -1
- package/dist/{types-DDhtZI6E.d.cts → types-BWMUr3Zw.d.cts} +274 -84
- package/dist/{types-Bx558PU6.d.cts → types-BkZNhuBh.d.cts} +1 -1
- package/dist/{types-1ylMrCuW.d.ts → types-CxzWHspI.d.ts} +1 -1
- package/dist/{types-Byo_Rty4.d.ts → types-DMvVHdb1.d.ts} +274 -84
- package/dist/ui/canvas.cjs +15 -5
- package/dist/ui/canvas.cjs.map +1 -1
- package/dist/ui/canvas.d.cts +1 -1
- package/dist/ui/canvas.d.ts +1 -1
- package/dist/ui/canvas.js +15 -5
- package/dist/ui/canvas.js.map +1 -1
- package/dist/ui/form.d.cts +1 -1
- package/dist/ui/form.d.ts +1 -1
- package/dist/ui/image.cjs +15 -5
- package/dist/ui/image.cjs.map +1 -1
- package/dist/ui/image.d.cts +1 -1
- package/dist/ui/image.d.ts +1 -1
- package/dist/ui/image.js +15 -5
- package/dist/ui/image.js.map +1 -1
- package/dist/ui/video.d.cts +1 -1
- package/dist/ui/video.d.ts +1 -1
- package/dist/webhook.cjs +5 -1
- package/dist/webhook.cjs.map +1 -1
- package/dist/webhook.d.cts +4 -4
- package/dist/webhook.d.ts +4 -4
- package/dist/webhook.js +5 -1
- package/dist/webhook.js.map +1 -1
- package/package.json +3 -3
package/dist/server.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { S as ServerCollectionClient } from './collection-client-
|
|
2
|
-
export { C as CollectionClient } from './collection-client-
|
|
3
|
-
import { B as BaseApi, l as ServerApiOptions, m as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, n as BanCustomerParams, o as CommunityBan, U as UnbanCustomerParams, c as ClientState, p as ClientServerConfig, E as EventsClient, q as RootServerClientWithEvents } from './types-
|
|
4
|
-
export { r as CollectionFieldSchema, s as CollectionSchemaResponse, t as EventGuestCancelParams, u as EventGuestRegistration, v as EventGuestRegistrationResponse, w as EventRegistrationAnswerInput, x as EventRegistrationAttendeeInput, y as EventRegistrationPublic, z as EventRegistrationRegisterParams, F as EventRegistrationRegisterResponse, G as EventsCalendarItem, H as EventsClientOptions, I as EventsDateParam, J as EventsExternalSource, K as EventsLocation, L as EventsOccurrenceLocation, M as EventsRangeEvent, N as EventsRangeOccurrence, O as EventsRangeParams, Q as EventsRangeResponse, V as EventsTaxonomyItem, X as ModerationApi, Y as RootServerClient, Z as TenantFeatureProgressEvidenceValue, _ as TenantFeatureProgressFeature, $ as TenantFeatureProgressGroup, a0 as TenantFeatureProgressInput, a1 as TenantFeatureProgressItem, a2 as TenantFeatureProgressItemState, a3 as TenantFeatureProgressResponse, a4 as TenantFeatureProgressSeverity, a5 as TenantFeatureProgressStatus, a6 as TenantIntrospectionApi, a7 as TenantIntrospectionApiOptions } from './types-
|
|
5
|
-
import './payload-types-
|
|
1
|
+
import { S as ServerCollectionClient } from './collection-client-zOmnxwdA.cjs';
|
|
2
|
+
export { C as CollectionClient } from './collection-client-zOmnxwdA.cjs';
|
|
3
|
+
import { B as BaseApi, l as ServerApiOptions, m as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, n as BanCustomerParams, o as CommunityBan, U as UnbanCustomerParams, c as ClientState, p as ClientServerConfig, E as EventsClient, q as RootServerClientWithEvents } from './types-BWMUr3Zw.cjs';
|
|
4
|
+
export { r as CollectionFieldSchema, s as CollectionSchemaResponse, t as EventGuestCancelParams, u as EventGuestRegistration, v as EventGuestRegistrationResponse, w as EventRegistrationAnswerInput, x as EventRegistrationAttendeeInput, y as EventRegistrationPublic, z as EventRegistrationRegisterParams, F as EventRegistrationRegisterResponse, G as EventsCalendarItem, H as EventsClientOptions, I as EventsDateParam, J as EventsExternalSource, K as EventsLocation, L as EventsOccurrenceLocation, M as EventsRangeEvent, N as EventsRangeOccurrence, O as EventsRangeParams, Q as EventsRangeResponse, V as EventsTaxonomyItem, X as ModerationApi, Y as RootServerClient, Z as TenantFeatureProgressEvidenceValue, _ as TenantFeatureProgressFeature, $ as TenantFeatureProgressGroup, a0 as TenantFeatureProgressInput, a1 as TenantFeatureProgressItem, a2 as TenantFeatureProgressItemState, a3 as TenantFeatureProgressResponse, a4 as TenantFeatureProgressSeverity, a5 as TenantFeatureProgressStatus, a6 as TenantIntrospectionApi, a7 as TenantIntrospectionApiOptions } from './types-BWMUr3Zw.cjs';
|
|
5
|
+
import './payload-types-CREOjFNT.cjs';
|
|
6
6
|
import './metadata.cjs';
|
|
7
|
-
import './const-
|
|
8
|
-
import './types-
|
|
7
|
+
import './const-CK_FPaIn.cjs';
|
|
8
|
+
import './types-BkZNhuBh.cjs';
|
|
9
9
|
|
|
10
10
|
type PreviewDetailParams = {
|
|
11
11
|
collection: string;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { S as ServerCollectionClient } from './collection-client-
|
|
2
|
-
export { C as CollectionClient } from './collection-client-
|
|
3
|
-
import { B as BaseApi, l as ServerApiOptions, m as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, n as BanCustomerParams, o as CommunityBan, U as UnbanCustomerParams, c as ClientState, p as ClientServerConfig, E as EventsClient, q as RootServerClientWithEvents } from './types-
|
|
4
|
-
export { r as CollectionFieldSchema, s as CollectionSchemaResponse, t as EventGuestCancelParams, u as EventGuestRegistration, v as EventGuestRegistrationResponse, w as EventRegistrationAnswerInput, x as EventRegistrationAttendeeInput, y as EventRegistrationPublic, z as EventRegistrationRegisterParams, F as EventRegistrationRegisterResponse, G as EventsCalendarItem, H as EventsClientOptions, I as EventsDateParam, J as EventsExternalSource, K as EventsLocation, L as EventsOccurrenceLocation, M as EventsRangeEvent, N as EventsRangeOccurrence, O as EventsRangeParams, Q as EventsRangeResponse, V as EventsTaxonomyItem, X as ModerationApi, Y as RootServerClient, Z as TenantFeatureProgressEvidenceValue, _ as TenantFeatureProgressFeature, $ as TenantFeatureProgressGroup, a0 as TenantFeatureProgressInput, a1 as TenantFeatureProgressItem, a2 as TenantFeatureProgressItemState, a3 as TenantFeatureProgressResponse, a4 as TenantFeatureProgressSeverity, a5 as TenantFeatureProgressStatus, a6 as TenantIntrospectionApi, a7 as TenantIntrospectionApiOptions } from './types-
|
|
5
|
-
import './payload-types-
|
|
1
|
+
import { S as ServerCollectionClient } from './collection-client-DyELGUcL.js';
|
|
2
|
+
export { C as CollectionClient } from './collection-client-DyELGUcL.js';
|
|
3
|
+
import { B as BaseApi, l as ServerApiOptions, m as ServerCommerceClient, T as TenantIntrospectionClient, a as CommunityClient, n as BanCustomerParams, o as CommunityBan, U as UnbanCustomerParams, c as ClientState, p as ClientServerConfig, E as EventsClient, q as RootServerClientWithEvents } from './types-DMvVHdb1.js';
|
|
4
|
+
export { r as CollectionFieldSchema, s as CollectionSchemaResponse, t as EventGuestCancelParams, u as EventGuestRegistration, v as EventGuestRegistrationResponse, w as EventRegistrationAnswerInput, x as EventRegistrationAttendeeInput, y as EventRegistrationPublic, z as EventRegistrationRegisterParams, F as EventRegistrationRegisterResponse, G as EventsCalendarItem, H as EventsClientOptions, I as EventsDateParam, J as EventsExternalSource, K as EventsLocation, L as EventsOccurrenceLocation, M as EventsRangeEvent, N as EventsRangeOccurrence, O as EventsRangeParams, Q as EventsRangeResponse, V as EventsTaxonomyItem, X as ModerationApi, Y as RootServerClient, Z as TenantFeatureProgressEvidenceValue, _ as TenantFeatureProgressFeature, $ as TenantFeatureProgressGroup, a0 as TenantFeatureProgressInput, a1 as TenantFeatureProgressItem, a2 as TenantFeatureProgressItemState, a3 as TenantFeatureProgressResponse, a4 as TenantFeatureProgressSeverity, a5 as TenantFeatureProgressStatus, a6 as TenantIntrospectionApi, a7 as TenantIntrospectionApiOptions } from './types-DMvVHdb1.js';
|
|
5
|
+
import './payload-types-CREOjFNT.js';
|
|
6
6
|
import './metadata.js';
|
|
7
|
-
import './const-
|
|
8
|
-
import './types-
|
|
7
|
+
import './const-Dqz05oaG.js';
|
|
8
|
+
import './types-CxzWHspI.js';
|
|
9
9
|
|
|
10
10
|
type PreviewDetailParams = {
|
|
11
11
|
collection: string;
|
package/dist/server.js
CHANGED
|
@@ -745,13 +745,15 @@ var HttpClient = class {
|
|
|
745
745
|
};
|
|
746
746
|
|
|
747
747
|
// src/utils/types.ts
|
|
748
|
-
|
|
748
|
+
function resolveRelation(ref) {
|
|
749
749
|
if (typeof ref === "string" || typeof ref === "number" || ref === null || ref === void 0)
|
|
750
750
|
return null;
|
|
751
751
|
return ref;
|
|
752
|
-
}
|
|
752
|
+
}
|
|
753
753
|
|
|
754
754
|
// src/core/metadata/index.ts
|
|
755
|
+
var OPEN_GRAPH_IMAGE_SIZE = "1200";
|
|
756
|
+
var LEGACY_OPEN_GRAPH_IMAGE_SIZE = "1536";
|
|
755
757
|
function extractSeo(doc) {
|
|
756
758
|
const seo = doc.seo ?? {};
|
|
757
759
|
const og = seo.openGraph ?? {};
|
|
@@ -795,7 +797,7 @@ function generateMetadata(input, options) {
|
|
|
795
797
|
function resolveMetaImage(ref) {
|
|
796
798
|
const image = resolveRelation(ref);
|
|
797
799
|
if (!image) return null;
|
|
798
|
-
const sized = image.sizes?.[
|
|
800
|
+
const sized = image.sizes?.[OPEN_GRAPH_IMAGE_SIZE] ?? image.sizes?.[LEGACY_OPEN_GRAPH_IMAGE_SIZE];
|
|
799
801
|
const url = sized?.url || image.url;
|
|
800
802
|
if (!url) return null;
|
|
801
803
|
const width = sized?.url ? sized.width : image.width;
|
|
@@ -1153,13 +1155,16 @@ async function parseApiResponse(response, endpoint) {
|
|
|
1153
1155
|
return data;
|
|
1154
1156
|
}
|
|
1155
1157
|
|
|
1156
|
-
// src/core/
|
|
1157
|
-
var
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1158
|
+
// src/core/api/customer-scoped-api.ts
|
|
1159
|
+
var CustomerScopedApi = class {
|
|
1160
|
+
constructor(apiName, options) {
|
|
1161
|
+
if (options.requiresCredential !== false && !options.secretKey && !options.customerToken) {
|
|
1162
|
+
throw createConfigError(
|
|
1163
|
+
`Either secretKey or customerToken is required for ${apiName}.`
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1161
1166
|
this.publishableKey = requirePublishableKeyForSecret(
|
|
1162
|
-
|
|
1167
|
+
apiName,
|
|
1163
1168
|
options.publishableKey,
|
|
1164
1169
|
options.secretKey
|
|
1165
1170
|
);
|
|
@@ -1169,6 +1174,44 @@ var CommunityClient = class {
|
|
|
1169
1174
|
this.onUnauthorized = options.onUnauthorized;
|
|
1170
1175
|
this.onRequestId = options.onRequestId;
|
|
1171
1176
|
}
|
|
1177
|
+
async request(endpoint, options) {
|
|
1178
|
+
const token = typeof this.customerToken === "function" ? this.customerToken() : this.customerToken;
|
|
1179
|
+
try {
|
|
1180
|
+
const response = await httpFetch(endpoint, {
|
|
1181
|
+
method: options.method,
|
|
1182
|
+
apiUrl: this.apiUrl,
|
|
1183
|
+
publishableKey: this.publishableKey,
|
|
1184
|
+
secretKey: this.secretKey,
|
|
1185
|
+
customerToken: token ?? void 0,
|
|
1186
|
+
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1187
|
+
...options.body !== void 0 && {
|
|
1188
|
+
body: JSON.stringify(options.body)
|
|
1189
|
+
},
|
|
1190
|
+
...options.headers && { headers: options.headers }
|
|
1191
|
+
});
|
|
1192
|
+
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1193
|
+
return parseApiResponse(response, endpoint);
|
|
1194
|
+
} catch (err) {
|
|
1195
|
+
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1196
|
+
this.onRequestId?.(id);
|
|
1197
|
+
throw err;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
// src/core/community/community-client.ts
|
|
1203
|
+
var DEFAULT_POST_LIST_SORT = "-lastActivityAt";
|
|
1204
|
+
var DEFAULT_COMMENT_LIST_SORT = "-createdAt";
|
|
1205
|
+
function unwrapPayloadDoc(value) {
|
|
1206
|
+
if (value && typeof value === "object" && "doc" in value) {
|
|
1207
|
+
return value.doc;
|
|
1208
|
+
}
|
|
1209
|
+
return value;
|
|
1210
|
+
}
|
|
1211
|
+
var CommunityClient = class extends CustomerScopedApi {
|
|
1212
|
+
constructor(options) {
|
|
1213
|
+
super("CommunityClient", { ...options, requiresCredential: false });
|
|
1214
|
+
}
|
|
1172
1215
|
buildQuery(params) {
|
|
1173
1216
|
if (!params) return "";
|
|
1174
1217
|
const entries = Object.entries(params).filter((e) => e[1] !== void 0).map(([k, v]) => [k, String(v)]);
|
|
@@ -1209,27 +1252,14 @@ var CommunityClient = class {
|
|
|
1209
1252
|
return `/api/comments?${urlParams.toString()}`;
|
|
1210
1253
|
}
|
|
1211
1254
|
async execute(endpoint, method, body) {
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
publishableKey: this.publishableKey,
|
|
1218
|
-
secretKey: this.secretKey,
|
|
1219
|
-
customerToken: token ?? void 0,
|
|
1220
|
-
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1221
|
-
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1222
|
-
});
|
|
1223
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1224
|
-
return parseApiResponse(response, endpoint);
|
|
1225
|
-
} catch (err) {
|
|
1226
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1227
|
-
this.onRequestId?.(id);
|
|
1228
|
-
throw err;
|
|
1229
|
-
}
|
|
1255
|
+
return this.request(endpoint, { method, body });
|
|
1256
|
+
}
|
|
1257
|
+
async executeDoc(endpoint, method, body) {
|
|
1258
|
+
const response = await this.execute(endpoint, method, body);
|
|
1259
|
+
return unwrapPayloadDoc(response);
|
|
1230
1260
|
}
|
|
1231
1261
|
createPost(params) {
|
|
1232
|
-
return this.
|
|
1262
|
+
return this.executeDoc("/api/posts", "POST", params);
|
|
1233
1263
|
}
|
|
1234
1264
|
/**
|
|
1235
1265
|
* Public post feed. Server applies the same visibility contract as
|
|
@@ -1286,7 +1316,7 @@ var CommunityClient = class {
|
|
|
1286
1316
|
if (parentId !== void 0) {
|
|
1287
1317
|
body.parent = parentId;
|
|
1288
1318
|
}
|
|
1289
|
-
return this.
|
|
1319
|
+
return this.executeDoc("/api/comments", "POST", body);
|
|
1290
1320
|
}
|
|
1291
1321
|
/**
|
|
1292
1322
|
* List comments for a post.
|
|
@@ -1324,7 +1354,7 @@ var CommunityClient = class {
|
|
|
1324
1354
|
}
|
|
1325
1355
|
updateComment(params) {
|
|
1326
1356
|
const { commentId, body } = params;
|
|
1327
|
-
return this.
|
|
1357
|
+
return this.executeDoc(
|
|
1328
1358
|
`/api/comments/${commentId}`,
|
|
1329
1359
|
"PATCH",
|
|
1330
1360
|
{ body }
|
|
@@ -1355,7 +1385,7 @@ var CommunityClient = class {
|
|
|
1355
1385
|
400
|
|
1356
1386
|
);
|
|
1357
1387
|
}
|
|
1358
|
-
return this.
|
|
1388
|
+
return this.executeDoc("/api/reactions", "POST", {
|
|
1359
1389
|
post: postId,
|
|
1360
1390
|
type: reactionType
|
|
1361
1391
|
});
|
|
@@ -1377,7 +1407,7 @@ var CommunityClient = class {
|
|
|
1377
1407
|
400
|
|
1378
1408
|
);
|
|
1379
1409
|
}
|
|
1380
|
-
return this.
|
|
1410
|
+
return this.executeDoc("/api/reactions", "POST", {
|
|
1381
1411
|
comment: commentId,
|
|
1382
1412
|
type: reactionType
|
|
1383
1413
|
});
|
|
@@ -1409,7 +1439,7 @@ var CommunityClient = class {
|
|
|
1409
1439
|
}
|
|
1410
1440
|
// Bookmarks
|
|
1411
1441
|
addBookmark(params) {
|
|
1412
|
-
return this.
|
|
1442
|
+
return this.executeDoc("/api/bookmarks", "POST", {
|
|
1413
1443
|
post: params.postId
|
|
1414
1444
|
});
|
|
1415
1445
|
}
|
|
@@ -1504,43 +1534,12 @@ var ModerationApi = class extends BaseApi {
|
|
|
1504
1534
|
};
|
|
1505
1535
|
|
|
1506
1536
|
// src/core/api/cart-api.ts
|
|
1507
|
-
var CartApi = class {
|
|
1537
|
+
var CartApi = class extends CustomerScopedApi {
|
|
1508
1538
|
constructor(options) {
|
|
1509
|
-
|
|
1510
|
-
throw createConfigError(
|
|
1511
|
-
"Either secretKey or customerToken is required for CartApi."
|
|
1512
|
-
);
|
|
1513
|
-
}
|
|
1514
|
-
this.publishableKey = requirePublishableKeyForSecret(
|
|
1515
|
-
"CartApi",
|
|
1516
|
-
options.publishableKey,
|
|
1517
|
-
options.secretKey
|
|
1518
|
-
);
|
|
1519
|
-
this.secretKey = options.secretKey;
|
|
1520
|
-
this.apiUrl = options.apiUrl;
|
|
1521
|
-
this.customerToken = options.customerToken;
|
|
1522
|
-
this.onUnauthorized = options.onUnauthorized;
|
|
1523
|
-
this.onRequestId = options.onRequestId;
|
|
1539
|
+
super("CartApi", options);
|
|
1524
1540
|
}
|
|
1525
1541
|
async execute(endpoint, method, body) {
|
|
1526
|
-
|
|
1527
|
-
try {
|
|
1528
|
-
const response = await httpFetch(endpoint, {
|
|
1529
|
-
method,
|
|
1530
|
-
apiUrl: this.apiUrl,
|
|
1531
|
-
publishableKey: this.publishableKey,
|
|
1532
|
-
secretKey: this.secretKey,
|
|
1533
|
-
customerToken: token ?? void 0,
|
|
1534
|
-
...token && this.onUnauthorized && { onUnauthorized: this.onUnauthorized },
|
|
1535
|
-
...body !== void 0 && { body: JSON.stringify(body) }
|
|
1536
|
-
});
|
|
1537
|
-
this.onRequestId?.(response.headers.get("x-request-id") ?? null);
|
|
1538
|
-
return parseApiResponse(response, endpoint);
|
|
1539
|
-
} catch (err) {
|
|
1540
|
-
const id = err instanceof SDKError ? err.requestId ?? null : null;
|
|
1541
|
-
this.onRequestId?.(id);
|
|
1542
|
-
throw err;
|
|
1543
|
-
}
|
|
1542
|
+
return this.request(endpoint, { method, body });
|
|
1544
1543
|
}
|
|
1545
1544
|
getCart(cartId) {
|
|
1546
1545
|
return this.execute(`/api/carts/${cartId}`, "GET");
|
|
@@ -1740,15 +1739,24 @@ function splitIdempotencyKey(params) {
|
|
|
1740
1739
|
const { idempotencyKey, ...body } = params;
|
|
1741
1740
|
return { body, idempotencyKey };
|
|
1742
1741
|
}
|
|
1742
|
+
function normalizeCreateOrderBody(params) {
|
|
1743
|
+
if (params.items !== void 0) {
|
|
1744
|
+
const { idempotencyKey: _idempotencyKey2, items, ...rest } = params;
|
|
1745
|
+
return { ...rest, orderItems: items };
|
|
1746
|
+
}
|
|
1747
|
+
const { idempotencyKey: _idempotencyKey, ...body } = params;
|
|
1748
|
+
return body;
|
|
1749
|
+
}
|
|
1743
1750
|
var OrderApi = class extends BaseApi {
|
|
1744
1751
|
constructor(options) {
|
|
1745
1752
|
super("OrderApi", options);
|
|
1746
1753
|
}
|
|
1747
1754
|
createOrder(params) {
|
|
1748
|
-
const {
|
|
1755
|
+
const { idempotencyKey } = params;
|
|
1756
|
+
const normalizedBody = normalizeCreateOrderBody(params);
|
|
1749
1757
|
return this.request(
|
|
1750
1758
|
"/api/orders/create",
|
|
1751
|
-
|
|
1759
|
+
normalizedBody,
|
|
1752
1760
|
idempotencyRequestOptions(idempotencyKey)
|
|
1753
1761
|
);
|
|
1754
1762
|
}
|
|
@@ -1780,6 +1788,20 @@ var OrderApi = class extends BaseApi {
|
|
|
1780
1788
|
idempotencyKey ? { headers: { "X-Idempotency-Key": idempotencyKey } } : void 0
|
|
1781
1789
|
);
|
|
1782
1790
|
}
|
|
1791
|
+
resolveCancelRefund(params) {
|
|
1792
|
+
return this.request(
|
|
1793
|
+
"/api/orders/resolve-cancel-refund",
|
|
1794
|
+
{
|
|
1795
|
+
orderNumber: params.orderNumber,
|
|
1796
|
+
idempotencyKey: params.idempotencyKey,
|
|
1797
|
+
outcome: params.outcome,
|
|
1798
|
+
refundedAmount: params.refundedAmount,
|
|
1799
|
+
pgProvider: params.pgProvider,
|
|
1800
|
+
...params.pgRefundId ? { pgRefundId: params.pgRefundId } : {}
|
|
1801
|
+
},
|
|
1802
|
+
idempotencyRequestOptions(params.idempotencyKey)
|
|
1803
|
+
);
|
|
1804
|
+
}
|
|
1783
1805
|
checkout(params) {
|
|
1784
1806
|
const { body, idempotencyKey } = splitIdempotencyKey(params);
|
|
1785
1807
|
return this.request(
|
|
@@ -1796,6 +1818,12 @@ var OrderApi = class extends BaseApi {
|
|
|
1796
1818
|
idempotencyRequestOptions(idempotencyKey)
|
|
1797
1819
|
);
|
|
1798
1820
|
}
|
|
1821
|
+
prepareFulfillmentOrder(params) {
|
|
1822
|
+
return this.request(
|
|
1823
|
+
"/api/fulfillment-orders/prepare-fulfillment-order",
|
|
1824
|
+
params
|
|
1825
|
+
);
|
|
1826
|
+
}
|
|
1799
1827
|
updateFulfillment(params) {
|
|
1800
1828
|
return this.request("/api/orders/update-fulfillment", params);
|
|
1801
1829
|
}
|
|
@@ -1922,7 +1950,9 @@ var ServerCommerceClient = class {
|
|
|
1922
1950
|
updateTransaction: orderApi.updateTransaction.bind(orderApi),
|
|
1923
1951
|
confirmPayment: orderApi.confirmPayment.bind(orderApi),
|
|
1924
1952
|
cancelOrder: orderApi.cancelOrder.bind(orderApi),
|
|
1953
|
+
resolveCancelRefund: orderApi.resolveCancelRefund.bind(orderApi),
|
|
1925
1954
|
createFulfillment: orderApi.createFulfillment.bind(orderApi),
|
|
1955
|
+
prepareFulfillmentOrder: orderApi.prepareFulfillmentOrder.bind(orderApi),
|
|
1926
1956
|
updateFulfillment: orderApi.updateFulfillment.bind(orderApi),
|
|
1927
1957
|
bulkImportFulfillments: orderApi.bulkImportFulfillments.bind(orderApi),
|
|
1928
1958
|
createReturn: orderApi.createReturn.bind(orderApi),
|