@cmssy/core 19.12.0 → 19.14.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/dist/index.cjs +111 -2
- package/dist/index.d.cts +56 -2
- package/dist/index.d.ts +56 -2
- package/dist/index.js +108 -3
- package/dist/internal/locale.cjs +1 -1
- package/dist/internal/locale.js +1 -1
- package/dist/internal.cjs +4 -1
- package/dist/internal.js +4 -1
- package/dist/preflight.cjs +1 -1
- package/dist/preflight.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -225,7 +225,7 @@ function documentText(document2) {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
// src/version.ts
|
|
228
|
-
var CMSSY_CORE_VERSION = "19.
|
|
228
|
+
var CMSSY_CORE_VERSION = "19.14.0" ;
|
|
229
229
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
230
230
|
|
|
231
231
|
// src/data/http.ts
|
|
@@ -584,6 +584,9 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
584
584
|
listed
|
|
585
585
|
basePrice
|
|
586
586
|
source
|
|
587
|
+
minQuantity
|
|
588
|
+
maxQuantity
|
|
589
|
+
increment
|
|
587
590
|
tiers {
|
|
588
591
|
minQty
|
|
589
592
|
price
|
|
@@ -626,13 +629,91 @@ async function getBuyerPrices(config, items, options) {
|
|
|
626
629
|
);
|
|
627
630
|
return data.account.prices;
|
|
628
631
|
}
|
|
632
|
+
var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
633
|
+
$workspaceId: ID!
|
|
634
|
+
$modelSlug: String!
|
|
635
|
+
$filter: JSON
|
|
636
|
+
$stockState: String
|
|
637
|
+
$sku: String
|
|
638
|
+
$locale: String
|
|
639
|
+
$currency: String
|
|
640
|
+
$priceMin: Int
|
|
641
|
+
$priceMax: Int
|
|
642
|
+
$sort: BuyerCatalogSort
|
|
643
|
+
$limit: Int
|
|
644
|
+
$offset: Int
|
|
645
|
+
) {
|
|
646
|
+
account {
|
|
647
|
+
catalogPrices(
|
|
648
|
+
workspaceId: $workspaceId
|
|
649
|
+
modelSlug: $modelSlug
|
|
650
|
+
filter: $filter
|
|
651
|
+
stockState: $stockState
|
|
652
|
+
sku: $sku
|
|
653
|
+
locale: $locale
|
|
654
|
+
currency: $currency
|
|
655
|
+
priceMin: $priceMin
|
|
656
|
+
priceMax: $priceMax
|
|
657
|
+
sort: $sort
|
|
658
|
+
limit: $limit
|
|
659
|
+
offset: $offset
|
|
660
|
+
) {
|
|
661
|
+
total
|
|
662
|
+
hasMore
|
|
663
|
+
items {
|
|
664
|
+
recordId
|
|
665
|
+
currency
|
|
666
|
+
price
|
|
667
|
+
priceMax
|
|
668
|
+
listed
|
|
669
|
+
basePrice
|
|
670
|
+
source
|
|
671
|
+
minQuantity
|
|
672
|
+
maxQuantity
|
|
673
|
+
increment
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}`);
|
|
678
|
+
async function getBuyerCatalogPrices(config, query, options) {
|
|
679
|
+
if (!options.accessToken) {
|
|
680
|
+
throw new Error(
|
|
681
|
+
"cmssy: getBuyerCatalogPrices needs the signed-in member's accessToken - an anonymous visitor reads the catalogue"
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
const data = await graphqlRequest(
|
|
685
|
+
config,
|
|
686
|
+
BUYER_CATALOG_PRICES_QUERY,
|
|
687
|
+
{ ...query, workspaceId: options.workspaceId },
|
|
688
|
+
{
|
|
689
|
+
public: true,
|
|
690
|
+
fetch: options.fetch,
|
|
691
|
+
signal: options.signal,
|
|
692
|
+
retry: options.retry,
|
|
693
|
+
headers: {
|
|
694
|
+
"x-workspace-id": options.workspaceId,
|
|
695
|
+
authorization: `Bearer ${options.accessToken}`
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
"buyer catalogue prices"
|
|
699
|
+
);
|
|
700
|
+
return data.account.catalogPrices;
|
|
701
|
+
}
|
|
629
702
|
|
|
630
703
|
// src/data/checkout-errors.ts
|
|
704
|
+
var quantityRuleReasonValues = [
|
|
705
|
+
"QUANTITY_BELOW_MIN",
|
|
706
|
+
"QUANTITY_ABOVE_MAX",
|
|
707
|
+
"QUANTITY_NOT_ON_STEP"
|
|
708
|
+
];
|
|
631
709
|
var checkoutErrorReasonValues = [
|
|
632
710
|
"CART_REPRICED",
|
|
633
|
-
"CART_CURRENCY_CHANGED"
|
|
711
|
+
"CART_CURRENCY_CHANGED",
|
|
712
|
+
"PRODUCT_NOT_SOLD",
|
|
713
|
+
...quantityRuleReasonValues
|
|
634
714
|
];
|
|
635
715
|
var REASONS = new Set(checkoutErrorReasonValues);
|
|
716
|
+
var QUANTITY_REASONS = new Set(quantityRuleReasonValues);
|
|
636
717
|
function checkoutErrorReason(error) {
|
|
637
718
|
if (!(error instanceof CmssyGraphqlError)) return void 0;
|
|
638
719
|
for (const entry of error.errors) {
|
|
@@ -643,6 +724,30 @@ function checkoutErrorReason(error) {
|
|
|
643
724
|
}
|
|
644
725
|
return void 0;
|
|
645
726
|
}
|
|
727
|
+
function isCount(value) {
|
|
728
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
729
|
+
}
|
|
730
|
+
function quantityRuleViolation(error) {
|
|
731
|
+
if (!(error instanceof CmssyGraphqlError)) return void 0;
|
|
732
|
+
for (const entry of error.errors) {
|
|
733
|
+
const ext = entry.extensions;
|
|
734
|
+
if (!ext || typeof ext.reason !== "string") continue;
|
|
735
|
+
if (!QUANTITY_REASONS.has(ext.reason)) continue;
|
|
736
|
+
const { quantity, minQuantity, maxQuantity, increment, itemId } = ext;
|
|
737
|
+
if (!isCount(quantity) || !isCount(minQuantity) || !isCount(maxQuantity) || !isCount(increment)) {
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
return {
|
|
741
|
+
reason: ext.reason,
|
|
742
|
+
quantity,
|
|
743
|
+
minQuantity,
|
|
744
|
+
maxQuantity,
|
|
745
|
+
increment,
|
|
746
|
+
itemId: typeof itemId === "string" ? itemId : null
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
return void 0;
|
|
750
|
+
}
|
|
646
751
|
|
|
647
752
|
// src/fields.ts
|
|
648
753
|
function build(type, opts) {
|
|
@@ -1277,6 +1382,7 @@ Object.defineProperty(exports, "mediaTypeValues", {
|
|
|
1277
1382
|
enumerable: true,
|
|
1278
1383
|
get: function () { return types.mediaTypeValues; }
|
|
1279
1384
|
});
|
|
1385
|
+
exports.BUYER_CATALOG_PRICES_QUERY = BUYER_CATALOG_PRICES_QUERY;
|
|
1280
1386
|
exports.BUYER_PRICES_QUERY = BUYER_PRICES_QUERY;
|
|
1281
1387
|
exports.CMSSY_BUYER_PRICES_MAX_ITEMS = CMSSY_BUYER_PRICES_MAX_ITEMS;
|
|
1282
1388
|
exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
|
|
@@ -1304,6 +1410,7 @@ exports.createRetryingFetch = createRetryingFetch;
|
|
|
1304
1410
|
exports.defineCmssyConfig = defineCmssyConfig;
|
|
1305
1411
|
exports.defineCmssyLayout = defineCmssyLayout;
|
|
1306
1412
|
exports.fields = fields;
|
|
1413
|
+
exports.getBuyerCatalogPrices = getBuyerCatalogPrices;
|
|
1307
1414
|
exports.getBuyerPrices = getBuyerPrices;
|
|
1308
1415
|
exports.graphqlRequest = graphqlRequest;
|
|
1309
1416
|
exports.isFormFieldRequired = isFormFieldRequired;
|
|
@@ -1325,6 +1432,8 @@ exports.orderProgressValues = orderProgressValues;
|
|
|
1325
1432
|
exports.parseEditorMessage = parseEditorMessage;
|
|
1326
1433
|
exports.postToEditor = postToEditor;
|
|
1327
1434
|
exports.propsToSchema = propsToSchema;
|
|
1435
|
+
exports.quantityRuleReasonValues = quantityRuleReasonValues;
|
|
1436
|
+
exports.quantityRuleViolation = quantityRuleViolation;
|
|
1328
1437
|
exports.registryToManifestBlocks = registryToManifestBlocks;
|
|
1329
1438
|
exports.resolveCmssyLocale = resolveCmssyLocale;
|
|
1330
1439
|
exports.resolveEditorOrigin = resolveEditorOrigin;
|
package/dist/index.d.cts
CHANGED
|
@@ -25,6 +25,9 @@ interface CmssyBuyerPrice {
|
|
|
25
25
|
listed: boolean;
|
|
26
26
|
basePrice: number;
|
|
27
27
|
source: CmssyPriceSource;
|
|
28
|
+
minQuantity: number;
|
|
29
|
+
maxQuantity: number;
|
|
30
|
+
increment: number;
|
|
28
31
|
tiers: CmssyPriceTier[];
|
|
29
32
|
}
|
|
30
33
|
interface CmssyMemberPriceList {
|
|
@@ -48,10 +51,61 @@ interface GetBuyerPricesOptions {
|
|
|
48
51
|
retry?: RetryOption;
|
|
49
52
|
}
|
|
50
53
|
declare function getBuyerPrices(config: CmssyClientConfig, items: readonly CmssyPriceQueryItem[], options: GetBuyerPricesOptions): Promise<CmssyBuyerPrice[]>;
|
|
54
|
+
type CmssyBuyerCatalogSort = "PRICE_ASC" | "PRICE_DESC";
|
|
55
|
+
interface CmssyBuyerCatalogPrice {
|
|
56
|
+
recordId: string;
|
|
57
|
+
currency: string;
|
|
58
|
+
price: number;
|
|
59
|
+
priceMax: number | null;
|
|
60
|
+
listed: boolean;
|
|
61
|
+
basePrice: number;
|
|
62
|
+
source: CmssyPriceSource;
|
|
63
|
+
minQuantity: number;
|
|
64
|
+
maxQuantity: number;
|
|
65
|
+
increment: number;
|
|
66
|
+
}
|
|
67
|
+
interface CmssyBuyerCatalogPage {
|
|
68
|
+
items: CmssyBuyerCatalogPrice[];
|
|
69
|
+
total: number;
|
|
70
|
+
hasMore: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface BuyerCatalogPricesVariables {
|
|
73
|
+
workspaceId: string;
|
|
74
|
+
modelSlug: string;
|
|
75
|
+
filter?: Record<string, unknown> | null;
|
|
76
|
+
stockState?: string | null;
|
|
77
|
+
sku?: string | null;
|
|
78
|
+
locale?: string | null;
|
|
79
|
+
currency?: string | null;
|
|
80
|
+
priceMin?: number | null;
|
|
81
|
+
priceMax?: number | null;
|
|
82
|
+
sort?: CmssyBuyerCatalogSort | null;
|
|
83
|
+
limit?: number | null;
|
|
84
|
+
offset?: number | null;
|
|
85
|
+
}
|
|
86
|
+
interface BuyerCatalogPricesResult {
|
|
87
|
+
account: {
|
|
88
|
+
catalogPrices: CmssyBuyerCatalogPage;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
declare const BUYER_CATALOG_PRICES_QUERY: CmssyOperation<BuyerCatalogPricesResult, BuyerCatalogPricesVariables>;
|
|
92
|
+
type GetBuyerCatalogPricesQuery = Omit<BuyerCatalogPricesVariables, "workspaceId">;
|
|
93
|
+
declare function getBuyerCatalogPrices(config: CmssyClientConfig, query: GetBuyerCatalogPricesQuery, options: GetBuyerPricesOptions): Promise<CmssyBuyerCatalogPage>;
|
|
51
94
|
|
|
52
|
-
declare const
|
|
95
|
+
declare const quantityRuleReasonValues: readonly ["QUANTITY_BELOW_MIN", "QUANTITY_ABOVE_MAX", "QUANTITY_NOT_ON_STEP"];
|
|
96
|
+
type CmssyQuantityRuleReason = (typeof quantityRuleReasonValues)[number];
|
|
97
|
+
declare const checkoutErrorReasonValues: readonly ["CART_REPRICED", "CART_CURRENCY_CHANGED", "PRODUCT_NOT_SOLD", "QUANTITY_BELOW_MIN", "QUANTITY_ABOVE_MAX", "QUANTITY_NOT_ON_STEP"];
|
|
53
98
|
type CmssyCheckoutErrorReason = (typeof checkoutErrorReasonValues)[number];
|
|
99
|
+
interface CmssyQuantityRuleViolation {
|
|
100
|
+
reason: CmssyQuantityRuleReason;
|
|
101
|
+
quantity: number;
|
|
102
|
+
minQuantity: number;
|
|
103
|
+
maxQuantity: number;
|
|
104
|
+
increment: number;
|
|
105
|
+
itemId: string | null;
|
|
106
|
+
}
|
|
54
107
|
declare function checkoutErrorReason(error: unknown): CmssyCheckoutErrorReason | undefined;
|
|
108
|
+
declare function quantityRuleViolation(error: unknown): CmssyQuantityRuleViolation | undefined;
|
|
55
109
|
|
|
56
110
|
/**
|
|
57
111
|
* Whether the content is guaranteed to carry the field. Only `required` says
|
|
@@ -221,4 +275,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
221
275
|
}
|
|
222
276
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
223
277
|
|
|
224
|
-
export { BUYER_PRICES_QUERY, type BlockManifest, type BlockManifestBlock, type BlockManifestSource, type BuyerPricesResult, type BuyerPricesVariables, CMSSY_BUYER_PRICES_MAX_ITEMS, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_SECRET_QUERY_PARAM, type CmssyBuyerPrice, type CmssyCheckoutErrorReason, type CmssyMemberPriceList, CmssyOperation, type CmssyOrderProgress, type CmssyOrderProgressInput, type CmssyPriceQueryItem, type CmssyPriceTier, CmssyWebhookError, type ConditionalFormField, FetchLike, type GetBuyerPricesOptions, type MediaLike, type MintCmssyEditTokenOptions, RetryOption, type VerifyCmssyEditTokenOptions, blocksToMeta, blocksToSchemas, buildBlockManifest, checkoutErrorReason, checkoutErrorReasonValues, fields, getBuyerPrices, isFormFieldRequired, isFormFieldVisible, isVerifiedEditUrl, layoutRegionsToBridge, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, orderProgress, orderProgressValues, propsToSchema, registryToManifestBlocks, verifyCmssyEditToken, verifyCmssyWebhook, visibleFormFields };
|
|
278
|
+
export { BUYER_CATALOG_PRICES_QUERY, BUYER_PRICES_QUERY, type BlockManifest, type BlockManifestBlock, type BlockManifestSource, type BuyerCatalogPricesResult, type BuyerCatalogPricesVariables, type BuyerPricesResult, type BuyerPricesVariables, CMSSY_BUYER_PRICES_MAX_ITEMS, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_SECRET_QUERY_PARAM, type CmssyBuyerCatalogPage, type CmssyBuyerCatalogPrice, type CmssyBuyerCatalogSort, type CmssyBuyerPrice, type CmssyCheckoutErrorReason, type CmssyMemberPriceList, CmssyOperation, type CmssyOrderProgress, type CmssyOrderProgressInput, type CmssyPriceQueryItem, type CmssyPriceTier, type CmssyQuantityRuleReason, type CmssyQuantityRuleViolation, CmssyWebhookError, type ConditionalFormField, FetchLike, type GetBuyerCatalogPricesQuery, type GetBuyerPricesOptions, type MediaLike, type MintCmssyEditTokenOptions, RetryOption, type VerifyCmssyEditTokenOptions, blocksToMeta, blocksToSchemas, buildBlockManifest, checkoutErrorReason, checkoutErrorReasonValues, fields, getBuyerCatalogPrices, getBuyerPrices, isFormFieldRequired, isFormFieldVisible, isVerifiedEditUrl, layoutRegionsToBridge, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, orderProgress, orderProgressValues, propsToSchema, quantityRuleReasonValues, quantityRuleViolation, registryToManifestBlocks, verifyCmssyEditToken, verifyCmssyWebhook, visibleFormFields };
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ interface CmssyBuyerPrice {
|
|
|
25
25
|
listed: boolean;
|
|
26
26
|
basePrice: number;
|
|
27
27
|
source: CmssyPriceSource;
|
|
28
|
+
minQuantity: number;
|
|
29
|
+
maxQuantity: number;
|
|
30
|
+
increment: number;
|
|
28
31
|
tiers: CmssyPriceTier[];
|
|
29
32
|
}
|
|
30
33
|
interface CmssyMemberPriceList {
|
|
@@ -48,10 +51,61 @@ interface GetBuyerPricesOptions {
|
|
|
48
51
|
retry?: RetryOption;
|
|
49
52
|
}
|
|
50
53
|
declare function getBuyerPrices(config: CmssyClientConfig, items: readonly CmssyPriceQueryItem[], options: GetBuyerPricesOptions): Promise<CmssyBuyerPrice[]>;
|
|
54
|
+
type CmssyBuyerCatalogSort = "PRICE_ASC" | "PRICE_DESC";
|
|
55
|
+
interface CmssyBuyerCatalogPrice {
|
|
56
|
+
recordId: string;
|
|
57
|
+
currency: string;
|
|
58
|
+
price: number;
|
|
59
|
+
priceMax: number | null;
|
|
60
|
+
listed: boolean;
|
|
61
|
+
basePrice: number;
|
|
62
|
+
source: CmssyPriceSource;
|
|
63
|
+
minQuantity: number;
|
|
64
|
+
maxQuantity: number;
|
|
65
|
+
increment: number;
|
|
66
|
+
}
|
|
67
|
+
interface CmssyBuyerCatalogPage {
|
|
68
|
+
items: CmssyBuyerCatalogPrice[];
|
|
69
|
+
total: number;
|
|
70
|
+
hasMore: boolean;
|
|
71
|
+
}
|
|
72
|
+
interface BuyerCatalogPricesVariables {
|
|
73
|
+
workspaceId: string;
|
|
74
|
+
modelSlug: string;
|
|
75
|
+
filter?: Record<string, unknown> | null;
|
|
76
|
+
stockState?: string | null;
|
|
77
|
+
sku?: string | null;
|
|
78
|
+
locale?: string | null;
|
|
79
|
+
currency?: string | null;
|
|
80
|
+
priceMin?: number | null;
|
|
81
|
+
priceMax?: number | null;
|
|
82
|
+
sort?: CmssyBuyerCatalogSort | null;
|
|
83
|
+
limit?: number | null;
|
|
84
|
+
offset?: number | null;
|
|
85
|
+
}
|
|
86
|
+
interface BuyerCatalogPricesResult {
|
|
87
|
+
account: {
|
|
88
|
+
catalogPrices: CmssyBuyerCatalogPage;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
declare const BUYER_CATALOG_PRICES_QUERY: CmssyOperation<BuyerCatalogPricesResult, BuyerCatalogPricesVariables>;
|
|
92
|
+
type GetBuyerCatalogPricesQuery = Omit<BuyerCatalogPricesVariables, "workspaceId">;
|
|
93
|
+
declare function getBuyerCatalogPrices(config: CmssyClientConfig, query: GetBuyerCatalogPricesQuery, options: GetBuyerPricesOptions): Promise<CmssyBuyerCatalogPage>;
|
|
51
94
|
|
|
52
|
-
declare const
|
|
95
|
+
declare const quantityRuleReasonValues: readonly ["QUANTITY_BELOW_MIN", "QUANTITY_ABOVE_MAX", "QUANTITY_NOT_ON_STEP"];
|
|
96
|
+
type CmssyQuantityRuleReason = (typeof quantityRuleReasonValues)[number];
|
|
97
|
+
declare const checkoutErrorReasonValues: readonly ["CART_REPRICED", "CART_CURRENCY_CHANGED", "PRODUCT_NOT_SOLD", "QUANTITY_BELOW_MIN", "QUANTITY_ABOVE_MAX", "QUANTITY_NOT_ON_STEP"];
|
|
53
98
|
type CmssyCheckoutErrorReason = (typeof checkoutErrorReasonValues)[number];
|
|
99
|
+
interface CmssyQuantityRuleViolation {
|
|
100
|
+
reason: CmssyQuantityRuleReason;
|
|
101
|
+
quantity: number;
|
|
102
|
+
minQuantity: number;
|
|
103
|
+
maxQuantity: number;
|
|
104
|
+
increment: number;
|
|
105
|
+
itemId: string | null;
|
|
106
|
+
}
|
|
54
107
|
declare function checkoutErrorReason(error: unknown): CmssyCheckoutErrorReason | undefined;
|
|
108
|
+
declare function quantityRuleViolation(error: unknown): CmssyQuantityRuleViolation | undefined;
|
|
55
109
|
|
|
56
110
|
/**
|
|
57
111
|
* Whether the content is guaranteed to carry the field. Only `required` says
|
|
@@ -221,4 +275,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
221
275
|
}
|
|
222
276
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
223
277
|
|
|
224
|
-
export { BUYER_PRICES_QUERY, type BlockManifest, type BlockManifestBlock, type BlockManifestSource, type BuyerPricesResult, type BuyerPricesVariables, CMSSY_BUYER_PRICES_MAX_ITEMS, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_SECRET_QUERY_PARAM, type CmssyBuyerPrice, type CmssyCheckoutErrorReason, type CmssyMemberPriceList, CmssyOperation, type CmssyOrderProgress, type CmssyOrderProgressInput, type CmssyPriceQueryItem, type CmssyPriceTier, CmssyWebhookError, type ConditionalFormField, FetchLike, type GetBuyerPricesOptions, type MediaLike, type MintCmssyEditTokenOptions, RetryOption, type VerifyCmssyEditTokenOptions, blocksToMeta, blocksToSchemas, buildBlockManifest, checkoutErrorReason, checkoutErrorReasonValues, fields, getBuyerPrices, isFormFieldRequired, isFormFieldVisible, isVerifiedEditUrl, layoutRegionsToBridge, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, orderProgress, orderProgressValues, propsToSchema, registryToManifestBlocks, verifyCmssyEditToken, verifyCmssyWebhook, visibleFormFields };
|
|
278
|
+
export { BUYER_CATALOG_PRICES_QUERY, BUYER_PRICES_QUERY, type BlockManifest, type BlockManifestBlock, type BlockManifestSource, type BuyerCatalogPricesResult, type BuyerCatalogPricesVariables, type BuyerPricesResult, type BuyerPricesVariables, CMSSY_BUYER_PRICES_MAX_ITEMS, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_SECRET_QUERY_PARAM, type CmssyBuyerCatalogPage, type CmssyBuyerCatalogPrice, type CmssyBuyerCatalogSort, type CmssyBuyerPrice, type CmssyCheckoutErrorReason, type CmssyMemberPriceList, CmssyOperation, type CmssyOrderProgress, type CmssyOrderProgressInput, type CmssyPriceQueryItem, type CmssyPriceTier, type CmssyQuantityRuleReason, type CmssyQuantityRuleViolation, CmssyWebhookError, type ConditionalFormField, FetchLike, type GetBuyerCatalogPricesQuery, type GetBuyerPricesOptions, type MediaLike, type MintCmssyEditTokenOptions, RetryOption, type VerifyCmssyEditTokenOptions, blocksToMeta, blocksToSchemas, buildBlockManifest, checkoutErrorReason, checkoutErrorReasonValues, fields, getBuyerCatalogPrices, getBuyerPrices, isFormFieldRequired, isFormFieldVisible, isVerifiedEditUrl, layoutRegionsToBridge, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, orderProgress, orderProgressValues, propsToSchema, quantityRuleReasonValues, quantityRuleViolation, registryToManifestBlocks, verifyCmssyEditToken, verifyCmssyWebhook, visibleFormFields };
|
package/dist/index.js
CHANGED
|
@@ -224,7 +224,7 @@ function documentText(document2) {
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// src/version.ts
|
|
227
|
-
var CMSSY_CORE_VERSION = "19.
|
|
227
|
+
var CMSSY_CORE_VERSION = "19.14.0" ;
|
|
228
228
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
229
229
|
|
|
230
230
|
// src/data/http.ts
|
|
@@ -583,6 +583,9 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
583
583
|
listed
|
|
584
584
|
basePrice
|
|
585
585
|
source
|
|
586
|
+
minQuantity
|
|
587
|
+
maxQuantity
|
|
588
|
+
increment
|
|
586
589
|
tiers {
|
|
587
590
|
minQty
|
|
588
591
|
price
|
|
@@ -625,13 +628,91 @@ async function getBuyerPrices(config, items, options) {
|
|
|
625
628
|
);
|
|
626
629
|
return data.account.prices;
|
|
627
630
|
}
|
|
631
|
+
var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
632
|
+
$workspaceId: ID!
|
|
633
|
+
$modelSlug: String!
|
|
634
|
+
$filter: JSON
|
|
635
|
+
$stockState: String
|
|
636
|
+
$sku: String
|
|
637
|
+
$locale: String
|
|
638
|
+
$currency: String
|
|
639
|
+
$priceMin: Int
|
|
640
|
+
$priceMax: Int
|
|
641
|
+
$sort: BuyerCatalogSort
|
|
642
|
+
$limit: Int
|
|
643
|
+
$offset: Int
|
|
644
|
+
) {
|
|
645
|
+
account {
|
|
646
|
+
catalogPrices(
|
|
647
|
+
workspaceId: $workspaceId
|
|
648
|
+
modelSlug: $modelSlug
|
|
649
|
+
filter: $filter
|
|
650
|
+
stockState: $stockState
|
|
651
|
+
sku: $sku
|
|
652
|
+
locale: $locale
|
|
653
|
+
currency: $currency
|
|
654
|
+
priceMin: $priceMin
|
|
655
|
+
priceMax: $priceMax
|
|
656
|
+
sort: $sort
|
|
657
|
+
limit: $limit
|
|
658
|
+
offset: $offset
|
|
659
|
+
) {
|
|
660
|
+
total
|
|
661
|
+
hasMore
|
|
662
|
+
items {
|
|
663
|
+
recordId
|
|
664
|
+
currency
|
|
665
|
+
price
|
|
666
|
+
priceMax
|
|
667
|
+
listed
|
|
668
|
+
basePrice
|
|
669
|
+
source
|
|
670
|
+
minQuantity
|
|
671
|
+
maxQuantity
|
|
672
|
+
increment
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}`);
|
|
677
|
+
async function getBuyerCatalogPrices(config, query, options) {
|
|
678
|
+
if (!options.accessToken) {
|
|
679
|
+
throw new Error(
|
|
680
|
+
"cmssy: getBuyerCatalogPrices needs the signed-in member's accessToken - an anonymous visitor reads the catalogue"
|
|
681
|
+
);
|
|
682
|
+
}
|
|
683
|
+
const data = await graphqlRequest(
|
|
684
|
+
config,
|
|
685
|
+
BUYER_CATALOG_PRICES_QUERY,
|
|
686
|
+
{ ...query, workspaceId: options.workspaceId },
|
|
687
|
+
{
|
|
688
|
+
public: true,
|
|
689
|
+
fetch: options.fetch,
|
|
690
|
+
signal: options.signal,
|
|
691
|
+
retry: options.retry,
|
|
692
|
+
headers: {
|
|
693
|
+
"x-workspace-id": options.workspaceId,
|
|
694
|
+
authorization: `Bearer ${options.accessToken}`
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
"buyer catalogue prices"
|
|
698
|
+
);
|
|
699
|
+
return data.account.catalogPrices;
|
|
700
|
+
}
|
|
628
701
|
|
|
629
702
|
// src/data/checkout-errors.ts
|
|
703
|
+
var quantityRuleReasonValues = [
|
|
704
|
+
"QUANTITY_BELOW_MIN",
|
|
705
|
+
"QUANTITY_ABOVE_MAX",
|
|
706
|
+
"QUANTITY_NOT_ON_STEP"
|
|
707
|
+
];
|
|
630
708
|
var checkoutErrorReasonValues = [
|
|
631
709
|
"CART_REPRICED",
|
|
632
|
-
"CART_CURRENCY_CHANGED"
|
|
710
|
+
"CART_CURRENCY_CHANGED",
|
|
711
|
+
"PRODUCT_NOT_SOLD",
|
|
712
|
+
...quantityRuleReasonValues
|
|
633
713
|
];
|
|
634
714
|
var REASONS = new Set(checkoutErrorReasonValues);
|
|
715
|
+
var QUANTITY_REASONS = new Set(quantityRuleReasonValues);
|
|
635
716
|
function checkoutErrorReason(error) {
|
|
636
717
|
if (!(error instanceof CmssyGraphqlError)) return void 0;
|
|
637
718
|
for (const entry of error.errors) {
|
|
@@ -642,6 +723,30 @@ function checkoutErrorReason(error) {
|
|
|
642
723
|
}
|
|
643
724
|
return void 0;
|
|
644
725
|
}
|
|
726
|
+
function isCount(value) {
|
|
727
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
728
|
+
}
|
|
729
|
+
function quantityRuleViolation(error) {
|
|
730
|
+
if (!(error instanceof CmssyGraphqlError)) return void 0;
|
|
731
|
+
for (const entry of error.errors) {
|
|
732
|
+
const ext = entry.extensions;
|
|
733
|
+
if (!ext || typeof ext.reason !== "string") continue;
|
|
734
|
+
if (!QUANTITY_REASONS.has(ext.reason)) continue;
|
|
735
|
+
const { quantity, minQuantity, maxQuantity, increment, itemId } = ext;
|
|
736
|
+
if (!isCount(quantity) || !isCount(minQuantity) || !isCount(maxQuantity) || !isCount(increment)) {
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
return {
|
|
740
|
+
reason: ext.reason,
|
|
741
|
+
quantity,
|
|
742
|
+
minQuantity,
|
|
743
|
+
maxQuantity,
|
|
744
|
+
increment,
|
|
745
|
+
itemId: typeof itemId === "string" ? itemId : null
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
return void 0;
|
|
749
|
+
}
|
|
645
750
|
|
|
646
751
|
// src/fields.ts
|
|
647
752
|
function build(type, opts) {
|
|
@@ -1256,4 +1361,4 @@ async function verifyCmssyWebhook(options) {
|
|
|
1256
1361
|
return parsed;
|
|
1257
1362
|
}
|
|
1258
1363
|
|
|
1259
|
-
export { BUYER_PRICES_QUERY, CMSSY_BUYER_PRICES_MAX_ITEMS, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyGraphqlError, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, blocksToMeta, blocksToSchemas, buildBlockManifest, checkoutErrorReason, checkoutErrorReasonValues, createCmssyClient, createRetryingFetch, defineCmssyConfig, defineCmssyLayout, fields, getBuyerPrices, graphqlRequest, isFormFieldRequired, isFormFieldVisible, isProtocolCompatible, isTransientRequestError, isVerifiedEditUrl, layoutRegionsToBridge, localizeHref, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, normalizeOrigin, orderProgress, orderProgressValues, parseEditorMessage, postToEditor, propsToSchema, registryToManifestBlocks, resolveCmssyLocale, resolveEditorOrigin, typedOperation, verifyCmssyEditToken, verifyCmssyWebhook, visibleFormFields };
|
|
1364
|
+
export { BUYER_CATALOG_PRICES_QUERY, BUYER_PRICES_QUERY, CMSSY_BUYER_PRICES_MAX_ITEMS, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyGraphqlError, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, blocksToMeta, blocksToSchemas, buildBlockManifest, checkoutErrorReason, checkoutErrorReasonValues, createCmssyClient, createRetryingFetch, defineCmssyConfig, defineCmssyLayout, fields, getBuyerCatalogPrices, getBuyerPrices, graphqlRequest, isFormFieldRequired, isFormFieldVisible, isProtocolCompatible, isTransientRequestError, isVerifiedEditUrl, layoutRegionsToBridge, localizeHref, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, normalizeOrigin, orderProgress, orderProgressValues, parseEditorMessage, postToEditor, propsToSchema, quantityRuleReasonValues, quantityRuleViolation, registryToManifestBlocks, resolveCmssyLocale, resolveEditorOrigin, typedOperation, verifyCmssyEditToken, verifyCmssyWebhook, visibleFormFields };
|
package/dist/internal/locale.cjs
CHANGED
package/dist/internal/locale.js
CHANGED
package/dist/internal.cjs
CHANGED
|
@@ -154,7 +154,7 @@ function documentText(document2) {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// src/version.ts
|
|
157
|
-
var CMSSY_CORE_VERSION = "19.
|
|
157
|
+
var CMSSY_CORE_VERSION = "19.14.0" ;
|
|
158
158
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
159
159
|
|
|
160
160
|
// src/data/http.ts
|
|
@@ -1347,6 +1347,9 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
1347
1347
|
listed
|
|
1348
1348
|
basePrice
|
|
1349
1349
|
source
|
|
1350
|
+
minQuantity
|
|
1351
|
+
maxQuantity
|
|
1352
|
+
increment
|
|
1350
1353
|
tiers {
|
|
1351
1354
|
minQty
|
|
1352
1355
|
price
|
package/dist/internal.js
CHANGED
|
@@ -152,7 +152,7 @@ function documentText(document2) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// src/version.ts
|
|
155
|
-
var CMSSY_CORE_VERSION = "19.
|
|
155
|
+
var CMSSY_CORE_VERSION = "19.14.0" ;
|
|
156
156
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
157
157
|
|
|
158
158
|
// src/data/http.ts
|
|
@@ -1345,6 +1345,9 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
1345
1345
|
listed
|
|
1346
1346
|
basePrice
|
|
1347
1347
|
source
|
|
1348
|
+
minQuantity
|
|
1349
|
+
maxQuantity
|
|
1350
|
+
increment
|
|
1348
1351
|
tiers {
|
|
1349
1352
|
minQty
|
|
1350
1353
|
price
|
package/dist/preflight.cjs
CHANGED
|
@@ -152,7 +152,7 @@ function documentText(document) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
// src/version.ts
|
|
155
|
-
var CMSSY_CORE_VERSION = "19.
|
|
155
|
+
var CMSSY_CORE_VERSION = "19.14.0" ;
|
|
156
156
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
157
157
|
|
|
158
158
|
// src/content/content-client.ts
|
package/dist/preflight.js
CHANGED
|
@@ -150,7 +150,7 @@ function documentText(document) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
// src/version.ts
|
|
153
|
-
var CMSSY_CORE_VERSION = "19.
|
|
153
|
+
var CMSSY_CORE_VERSION = "19.14.0" ;
|
|
154
154
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
155
155
|
|
|
156
156
|
// src/content/content-client.ts
|