arky-sdk 0.7.21 → 0.7.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-Cjdv3omy.d.cts → index-BzBZVueX.d.cts} +0 -16
- package/dist/{index-UQfW3UpN.d.ts → index-CkyDsYWA.d.ts} +0 -16
- package/dist/index.cjs +219 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -5
- package/dist/index.d.ts +114 -5
- package/dist/index.js +216 -13
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +51 -46
- package/dist/types.d.ts +51 -46
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,26 +18,10 @@ declare function nameToKey(name: string): string;
|
|
|
18
18
|
interface VariantWithInventory {
|
|
19
19
|
inventory: InventoryLevel[];
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Get total available stock across all locations for a variant
|
|
23
|
-
*/
|
|
24
21
|
declare function getAvailableStock(variant: VariantWithInventory): number;
|
|
25
|
-
/**
|
|
26
|
-
* Get total reserved stock across all locations for a variant
|
|
27
|
-
*/
|
|
28
22
|
declare function getReservedStock(variant: VariantWithInventory): number;
|
|
29
|
-
/**
|
|
30
|
-
* Check if variant has any available stock
|
|
31
|
-
*/
|
|
32
23
|
declare function hasStock(variant: VariantWithInventory, quantity?: number): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Get inventory level at a specific location
|
|
35
|
-
*/
|
|
36
24
|
declare function getInventoryAt(variant: VariantWithInventory, locationId: string): InventoryLevel | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Get the first location with available stock
|
|
39
|
-
* Returns the locationId of the first location that has stock
|
|
40
|
-
*/
|
|
41
25
|
declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
|
|
42
26
|
|
|
43
27
|
export { formatMinor as a, getCurrencyName as b, getAvailableStock as c, getReservedStock as d, getInventoryAt as e, formatPayment as f, getCurrencySymbol as g, hasStock as h, isValidKey as i, getFirstAvailableFCId as j, convertToMajor as k, convertToMinor as l, nameToKey as n, toKey as t, validateKey as v };
|
|
@@ -18,26 +18,10 @@ declare function nameToKey(name: string): string;
|
|
|
18
18
|
interface VariantWithInventory {
|
|
19
19
|
inventory: InventoryLevel[];
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Get total available stock across all locations for a variant
|
|
23
|
-
*/
|
|
24
21
|
declare function getAvailableStock(variant: VariantWithInventory): number;
|
|
25
|
-
/**
|
|
26
|
-
* Get total reserved stock across all locations for a variant
|
|
27
|
-
*/
|
|
28
22
|
declare function getReservedStock(variant: VariantWithInventory): number;
|
|
29
|
-
/**
|
|
30
|
-
* Check if variant has any available stock
|
|
31
|
-
*/
|
|
32
23
|
declare function hasStock(variant: VariantWithInventory, quantity?: number): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Get inventory level at a specific location
|
|
35
|
-
*/
|
|
36
24
|
declare function getInventoryAt(variant: VariantWithInventory, locationId: string): InventoryLevel | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Get the first location with available stock
|
|
39
|
-
* Returns the locationId of the first location that has stock
|
|
40
|
-
*/
|
|
41
25
|
declare function getFirstAvailableFCId(variant: VariantWithInventory, quantity?: number): string | undefined;
|
|
42
26
|
|
|
43
27
|
export { formatMinor as a, getCurrencyName as b, getAvailableStock as c, getReservedStock as d, getInventoryAt as e, formatPayment as f, getCurrencySymbol as g, hasStock as h, isValidKey as i, getFirstAvailableFCId as j, convertToMajor as k, convertToMinor as l, nameToKey as n, toKey as t, validateKey as v };
|
package/dist/index.cjs
CHANGED
|
@@ -379,7 +379,6 @@ var createBusinessApi = (apiConfig) => {
|
|
|
379
379
|
options
|
|
380
380
|
);
|
|
381
381
|
},
|
|
382
|
-
// ── Integration CRUD ──
|
|
383
382
|
async listIntegrations(params, options) {
|
|
384
383
|
return apiConfig.httpClient.get(
|
|
385
384
|
`/v1/businesses/${params.businessId}/integrations`,
|
|
@@ -414,7 +413,6 @@ var createBusinessApi = (apiConfig) => {
|
|
|
414
413
|
options
|
|
415
414
|
);
|
|
416
415
|
},
|
|
417
|
-
// ── Webhook CRUD ──
|
|
418
416
|
async listWebhooks(params, options) {
|
|
419
417
|
return apiConfig.httpClient.get(
|
|
420
418
|
`/v1/businesses/${params.businessId}/webhooks`,
|
|
@@ -1115,6 +1113,79 @@ var createLocationApi = (apiConfig) => {
|
|
|
1115
1113
|
`/v1/platform/countries/${countryCode}`,
|
|
1116
1114
|
options
|
|
1117
1115
|
);
|
|
1116
|
+
},
|
|
1117
|
+
// Business location CRUD. Locations are now first-class entities (their own
|
|
1118
|
+
// table) and are no longer embedded in BusinessConfigs. Reads and writes go
|
|
1119
|
+
// through these endpoints.
|
|
1120
|
+
async list(options) {
|
|
1121
|
+
return apiConfig.httpClient.get(
|
|
1122
|
+
`/v1/businesses/${apiConfig.businessId}/locations`,
|
|
1123
|
+
options
|
|
1124
|
+
);
|
|
1125
|
+
},
|
|
1126
|
+
async get(id, options) {
|
|
1127
|
+
return apiConfig.httpClient.get(
|
|
1128
|
+
`/v1/businesses/${apiConfig.businessId}/locations/${id}`,
|
|
1129
|
+
options
|
|
1130
|
+
);
|
|
1131
|
+
},
|
|
1132
|
+
async create(params, options) {
|
|
1133
|
+
return apiConfig.httpClient.post(
|
|
1134
|
+
`/v1/businesses/${apiConfig.businessId}/locations`,
|
|
1135
|
+
{ ...params, businessId: apiConfig.businessId },
|
|
1136
|
+
options
|
|
1137
|
+
);
|
|
1138
|
+
},
|
|
1139
|
+
async update(params, options) {
|
|
1140
|
+
return apiConfig.httpClient.put(
|
|
1141
|
+
`/v1/businesses/${apiConfig.businessId}/locations/${params.id}`,
|
|
1142
|
+
{ ...params, businessId: apiConfig.businessId },
|
|
1143
|
+
options
|
|
1144
|
+
);
|
|
1145
|
+
},
|
|
1146
|
+
async delete(params, options) {
|
|
1147
|
+
return apiConfig.httpClient.delete(
|
|
1148
|
+
`/v1/businesses/${apiConfig.businessId}/locations/${params.id}`,
|
|
1149
|
+
options
|
|
1150
|
+
);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
// src/api/zone.ts
|
|
1156
|
+
var createZoneApi = (apiConfig) => {
|
|
1157
|
+
return {
|
|
1158
|
+
async list(options) {
|
|
1159
|
+
return apiConfig.httpClient.get(
|
|
1160
|
+
`/v1/businesses/${apiConfig.businessId}/zones`,
|
|
1161
|
+
options
|
|
1162
|
+
);
|
|
1163
|
+
},
|
|
1164
|
+
async get(id, options) {
|
|
1165
|
+
return apiConfig.httpClient.get(
|
|
1166
|
+
`/v1/businesses/${apiConfig.businessId}/zones/${id}`,
|
|
1167
|
+
options
|
|
1168
|
+
);
|
|
1169
|
+
},
|
|
1170
|
+
async create(params, options) {
|
|
1171
|
+
return apiConfig.httpClient.post(
|
|
1172
|
+
`/v1/businesses/${apiConfig.businessId}/zones`,
|
|
1173
|
+
{ ...params, businessId: apiConfig.businessId },
|
|
1174
|
+
options
|
|
1175
|
+
);
|
|
1176
|
+
},
|
|
1177
|
+
async update(params, options) {
|
|
1178
|
+
return apiConfig.httpClient.put(
|
|
1179
|
+
`/v1/businesses/${apiConfig.businessId}/zones/${params.id}`,
|
|
1180
|
+
{ ...params, businessId: apiConfig.businessId },
|
|
1181
|
+
options
|
|
1182
|
+
);
|
|
1183
|
+
},
|
|
1184
|
+
async delete(params, options) {
|
|
1185
|
+
return apiConfig.httpClient.delete(
|
|
1186
|
+
`/v1/businesses/${apiConfig.businessId}/zones/${params.id}`,
|
|
1187
|
+
options
|
|
1188
|
+
);
|
|
1118
1189
|
}
|
|
1119
1190
|
};
|
|
1120
1191
|
};
|
|
@@ -1122,7 +1193,6 @@ var createLocationApi = (apiConfig) => {
|
|
|
1122
1193
|
// src/api/crm.ts
|
|
1123
1194
|
var createCustomerApi = (apiConfig) => {
|
|
1124
1195
|
return {
|
|
1125
|
-
// Auth methods
|
|
1126
1196
|
async requestCode(params, options) {
|
|
1127
1197
|
const businessId = params.businessId || apiConfig.businessId;
|
|
1128
1198
|
return apiConfig.httpClient.post(
|
|
@@ -1153,7 +1223,6 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1153
1223
|
options
|
|
1154
1224
|
);
|
|
1155
1225
|
},
|
|
1156
|
-
// CRUD methods
|
|
1157
1226
|
async create(params, options) {
|
|
1158
1227
|
return apiConfig.httpClient.post(
|
|
1159
1228
|
`/v1/businesses/${params.businessId || apiConfig.businessId}/customers`,
|
|
@@ -1229,7 +1298,6 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1229
1298
|
options
|
|
1230
1299
|
);
|
|
1231
1300
|
},
|
|
1232
|
-
// Audiences
|
|
1233
1301
|
audiences: {
|
|
1234
1302
|
async create(params, options) {
|
|
1235
1303
|
return apiConfig.httpClient.post(
|
|
@@ -1310,6 +1378,145 @@ var createCustomerApi = (apiConfig) => {
|
|
|
1310
1378
|
};
|
|
1311
1379
|
};
|
|
1312
1380
|
|
|
1381
|
+
// src/api/reaction.ts
|
|
1382
|
+
var DEFAULT_REACTION_KINDS = [
|
|
1383
|
+
"like",
|
|
1384
|
+
"love",
|
|
1385
|
+
"laugh",
|
|
1386
|
+
"wow",
|
|
1387
|
+
"sad",
|
|
1388
|
+
"insightful",
|
|
1389
|
+
"review",
|
|
1390
|
+
"comment",
|
|
1391
|
+
"star_1",
|
|
1392
|
+
"star_2",
|
|
1393
|
+
"star_3",
|
|
1394
|
+
"star_4",
|
|
1395
|
+
"star_5"
|
|
1396
|
+
];
|
|
1397
|
+
var REACTION_KIND_REGEX = /^[a-z0-9_]{1,32}$/;
|
|
1398
|
+
function isValidReactionKind(kind) {
|
|
1399
|
+
return REACTION_KIND_REGEX.test(kind);
|
|
1400
|
+
}
|
|
1401
|
+
function computeAverageStars(counts) {
|
|
1402
|
+
let total = 0;
|
|
1403
|
+
let weighted = 0;
|
|
1404
|
+
for (let i = 1; i <= 5; i++) {
|
|
1405
|
+
const c = counts[`star_${i}`] ?? 0;
|
|
1406
|
+
total += c;
|
|
1407
|
+
weighted += c * i;
|
|
1408
|
+
}
|
|
1409
|
+
return {
|
|
1410
|
+
average: total > 0 ? weighted / total : 0,
|
|
1411
|
+
count: total
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
var createReactionApi = (apiConfig) => {
|
|
1415
|
+
const base = (businessId) => `/v1/businesses/${businessId || apiConfig.businessId}/reactions`;
|
|
1416
|
+
return {
|
|
1417
|
+
DEFAULT_REACTION_KINDS,
|
|
1418
|
+
isValidReactionKind,
|
|
1419
|
+
computeAverageStars,
|
|
1420
|
+
async create(params, options) {
|
|
1421
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1422
|
+
return apiConfig.httpClient.post(
|
|
1423
|
+
base(businessId),
|
|
1424
|
+
{
|
|
1425
|
+
businessId,
|
|
1426
|
+
target: params.target,
|
|
1427
|
+
kind: params.kind,
|
|
1428
|
+
blocks: params.blocks || [],
|
|
1429
|
+
parentId: params.parentId,
|
|
1430
|
+
taxonomies: params.taxonomies || []
|
|
1431
|
+
},
|
|
1432
|
+
options
|
|
1433
|
+
);
|
|
1434
|
+
},
|
|
1435
|
+
async get(params, options) {
|
|
1436
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1437
|
+
return apiConfig.httpClient.get(
|
|
1438
|
+
`${base(businessId)}/${params.id}`,
|
|
1439
|
+
options
|
|
1440
|
+
);
|
|
1441
|
+
},
|
|
1442
|
+
async find(params, options) {
|
|
1443
|
+
const businessId = params?.businessId || apiConfig.businessId;
|
|
1444
|
+
const queryParams = {};
|
|
1445
|
+
if (params?.targetType) queryParams.targetType = params.targetType;
|
|
1446
|
+
if (params?.targetId) queryParams.targetId = params.targetId;
|
|
1447
|
+
if (params?.parentId) queryParams.parentId = params.parentId;
|
|
1448
|
+
if (params?.customerId) queryParams.customerId = params.customerId;
|
|
1449
|
+
if (params?.kind) queryParams.kind = params.kind;
|
|
1450
|
+
if (params?.status) queryParams.status = params.status;
|
|
1451
|
+
if (params?.contentOnly !== void 0)
|
|
1452
|
+
queryParams.contentOnly = params.contentOnly;
|
|
1453
|
+
if (params?.limit !== void 0) queryParams.limit = params.limit;
|
|
1454
|
+
if (params?.cursor) queryParams.cursor = params.cursor;
|
|
1455
|
+
return apiConfig.httpClient.get(
|
|
1456
|
+
base(businessId),
|
|
1457
|
+
{ ...options, params: queryParams }
|
|
1458
|
+
);
|
|
1459
|
+
},
|
|
1460
|
+
async update(params, options) {
|
|
1461
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1462
|
+
return apiConfig.httpClient.put(
|
|
1463
|
+
`${base(businessId)}/${params.id}`,
|
|
1464
|
+
{
|
|
1465
|
+
id: params.id,
|
|
1466
|
+
businessId,
|
|
1467
|
+
blocks: params.blocks,
|
|
1468
|
+
taxonomies: params.taxonomies
|
|
1469
|
+
},
|
|
1470
|
+
options
|
|
1471
|
+
);
|
|
1472
|
+
},
|
|
1473
|
+
async remove(params, options) {
|
|
1474
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1475
|
+
return apiConfig.httpClient.delete(
|
|
1476
|
+
`${base(businessId)}/${params.id}`,
|
|
1477
|
+
options
|
|
1478
|
+
);
|
|
1479
|
+
},
|
|
1480
|
+
async moderate(params, options) {
|
|
1481
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1482
|
+
return apiConfig.httpClient.post(
|
|
1483
|
+
`${base(businessId)}/${params.id}/moderate`,
|
|
1484
|
+
{
|
|
1485
|
+
id: params.id,
|
|
1486
|
+
businessId,
|
|
1487
|
+
status: params.status
|
|
1488
|
+
},
|
|
1489
|
+
options
|
|
1490
|
+
);
|
|
1491
|
+
},
|
|
1492
|
+
async listAdmin(params, options) {
|
|
1493
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1494
|
+
const queryParams = { businessId };
|
|
1495
|
+
if (params.limit !== void 0) queryParams.limit = params.limit;
|
|
1496
|
+
if (params.cursor) queryParams.cursor = params.cursor;
|
|
1497
|
+
return apiConfig.httpClient.get(
|
|
1498
|
+
`${base(businessId)}/admin`,
|
|
1499
|
+
{ ...options, params: queryParams }
|
|
1500
|
+
);
|
|
1501
|
+
},
|
|
1502
|
+
async summary(params, options) {
|
|
1503
|
+
const businessId = params.businessId || apiConfig.businessId;
|
|
1504
|
+
return apiConfig.httpClient.get(
|
|
1505
|
+
`${base(businessId)}/summary`,
|
|
1506
|
+
{
|
|
1507
|
+
...options,
|
|
1508
|
+
params: {
|
|
1509
|
+
businessId,
|
|
1510
|
+
targetType: params.targetType,
|
|
1511
|
+
targetId: params.targetId,
|
|
1512
|
+
parentId: params.parentId
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1313
1520
|
// src/api/network.ts
|
|
1314
1521
|
var createNetworkApi = (apiConfig) => {
|
|
1315
1522
|
return {
|
|
@@ -1423,9 +1630,6 @@ var createPlatformApi = (apiConfig) => {
|
|
|
1423
1630
|
// src/api/shipping.ts
|
|
1424
1631
|
var createShippingApi = (apiConfig) => {
|
|
1425
1632
|
return {
|
|
1426
|
-
/**
|
|
1427
|
-
* Get available shipping rates for a shipment
|
|
1428
|
-
*/
|
|
1429
1633
|
async getRates(params, options) {
|
|
1430
1634
|
const { orderId, ...payload } = params;
|
|
1431
1635
|
return apiConfig.httpClient.post(
|
|
@@ -1434,9 +1638,6 @@ var createShippingApi = (apiConfig) => {
|
|
|
1434
1638
|
options
|
|
1435
1639
|
);
|
|
1436
1640
|
},
|
|
1437
|
-
/**
|
|
1438
|
-
* Ship items: creates shipment + purchases label atomically
|
|
1439
|
-
*/
|
|
1440
1641
|
async ship(params, options) {
|
|
1441
1642
|
const { orderId, ...payload } = params;
|
|
1442
1643
|
return apiConfig.httpClient.post(
|
|
@@ -2037,7 +2238,7 @@ function getFirstAvailableFCId(variant, quantity = 1) {
|
|
|
2037
2238
|
}
|
|
2038
2239
|
|
|
2039
2240
|
// src/index.ts
|
|
2040
|
-
var SDK_VERSION = "0.
|
|
2241
|
+
var SDK_VERSION = "0.7.26";
|
|
2041
2242
|
var SUPPORTED_FRAMEWORKS = [
|
|
2042
2243
|
"astro",
|
|
2043
2244
|
"react",
|
|
@@ -2084,7 +2285,9 @@ async function createArkySDK(config) {
|
|
|
2084
2285
|
eshop: createEshopApi(apiConfig),
|
|
2085
2286
|
booking: createBookingApi(apiConfig),
|
|
2086
2287
|
location: createLocationApi(apiConfig),
|
|
2288
|
+
zone: createZoneApi(apiConfig),
|
|
2087
2289
|
crm: createCustomerApi(apiConfig),
|
|
2290
|
+
reaction: createReactionApi(apiConfig),
|
|
2088
2291
|
network: createNetworkApi(apiConfig),
|
|
2089
2292
|
workflow: createWorkflowApi(apiConfig),
|
|
2090
2293
|
shipping: createShippingApi(apiConfig),
|
|
@@ -2153,9 +2356,13 @@ async function createArkySDK(config) {
|
|
|
2153
2356
|
return sdk;
|
|
2154
2357
|
}
|
|
2155
2358
|
|
|
2359
|
+
exports.DEFAULT_REACTION_KINDS = DEFAULT_REACTION_KINDS;
|
|
2156
2360
|
exports.PaymentMethodType = PaymentMethodType;
|
|
2361
|
+
exports.REACTION_KIND_REGEX = REACTION_KIND_REGEX;
|
|
2157
2362
|
exports.SDK_VERSION = SDK_VERSION;
|
|
2158
2363
|
exports.SUPPORTED_FRAMEWORKS = SUPPORTED_FRAMEWORKS;
|
|
2364
|
+
exports.computeAverageStars = computeAverageStars;
|
|
2159
2365
|
exports.createArkySDK = createArkySDK;
|
|
2366
|
+
exports.isValidReactionKind = isValidReactionKind;
|
|
2160
2367
|
//# sourceMappingURL=index.cjs.map
|
|
2161
2368
|
//# sourceMappingURL=index.cjs.map
|