@cmssy/core 19.14.0 → 19.16.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/{content-client-MPHJMucu.d.cts → content-client-EAeHiBv2.d.cts} +6 -2
- package/dist/{content-client-MPHJMucu.d.ts → content-client-EAeHiBv2.d.ts} +6 -2
- package/dist/{csp-DKvpTbqW.d.ts → csp-CYbG4uan.d.cts} +8 -3
- package/dist/{csp-B7EAjPSy.d.cts → csp-DE59VC7Q.d.ts} +8 -3
- package/dist/index.cjs +333 -12
- package/dist/index.d.cts +119 -10
- package/dist/index.d.ts +119 -10
- package/dist/index.js +324 -13
- package/dist/internal/locale.cjs +21 -8
- package/dist/internal/locale.d.cts +2 -2
- package/dist/internal/locale.d.ts +2 -2
- package/dist/internal/locale.js +21 -8
- package/dist/internal.cjs +45 -10
- package/dist/internal.d.cts +7 -6
- package/dist/internal.d.ts +7 -6
- package/dist/internal.js +45 -10
- package/dist/{locale-DfW5CAIM.d.cts → locale-CUk6dYTo.d.cts} +2 -2
- package/dist/{locale-B3M-PFm4.d.ts → locale-Ds2uJX5V.d.ts} +2 -2
- package/dist/preflight.cjs +1 -1
- package/dist/preflight.d.cts +2 -2
- package/dist/preflight.d.ts +2 -2
- package/dist/preflight.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary } from '@cmssy/types';
|
|
1
|
+
import { CmssyClientConfig as CmssyClientConfig$1, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary } from '@cmssy/types';
|
|
2
2
|
|
|
3
3
|
declare class CmssyRequestError extends Error {
|
|
4
4
|
readonly status: number;
|
|
@@ -37,6 +37,10 @@ declare class CmssyGraphqlError extends Error {
|
|
|
37
37
|
constructor(message: string, errors: ReadonlyArray<CmssyGraphqlErrorEntry>);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
interface CmssyClientConfig extends CmssyClientConfig$1 {
|
|
41
|
+
channel?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
|
|
41
45
|
declare function resolveApiUrl(apiUrl: string | undefined): string;
|
|
42
46
|
interface FetchLikeResponse {
|
|
@@ -68,4 +72,4 @@ declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageO
|
|
|
68
72
|
declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageMeta | null>;
|
|
69
73
|
declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
|
|
70
74
|
|
|
71
|
-
export {
|
|
75
|
+
export { type CmssyClientConfig as C, DEFAULT_CMSSY_API_URL as D, type FetchLike as F, type RetryOption as R, fetchPage as a, fetchPageById as b, fetchPageMeta as c, fetchPages as d, CMSSY_RATE_LIMIT_WINDOW_MS as e, fetchLayouts as f, CMSSY_RETRY_MODES as g, CmssyGraphqlError as h, type CmssyGraphqlErrorEntry as i, CmssyRequestError as j, type CmssyRetryMode as k, type FetchLikeResponse as l, type FetchPageOptions as m, type RetryPolicy as n, createRetryingFetch as o, isTransientRequestError as p, resolveApiUrl as r };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmssyClientConfig, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary } from '@cmssy/types';
|
|
1
|
+
import { CmssyClientConfig as CmssyClientConfig$1, CmssyLayoutGroup, CmssyPageData, CmssyPageMeta, CmssyPageSummary } from '@cmssy/types';
|
|
2
2
|
|
|
3
3
|
declare class CmssyRequestError extends Error {
|
|
4
4
|
readonly status: number;
|
|
@@ -37,6 +37,10 @@ declare class CmssyGraphqlError extends Error {
|
|
|
37
37
|
constructor(message: string, errors: ReadonlyArray<CmssyGraphqlErrorEntry>);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
interface CmssyClientConfig extends CmssyClientConfig$1 {
|
|
41
|
+
channel?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
declare const DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
|
|
41
45
|
declare function resolveApiUrl(apiUrl: string | undefined): string;
|
|
42
46
|
interface FetchLikeResponse {
|
|
@@ -68,4 +72,4 @@ declare function fetchPages(config: CmssyClientConfig, options?: Pick<FetchPageO
|
|
|
68
72
|
declare function fetchPageMeta(config: CmssyClientConfig, path: string | string[] | undefined, options?: Pick<FetchPageOptions, "fetch" | "signal" | "retry">): Promise<CmssyPageMeta | null>;
|
|
69
73
|
declare function fetchLayouts(config: CmssyClientConfig, path: string | string[] | undefined, options?: FetchPageOptions): Promise<CmssyLayoutGroup[]>;
|
|
70
74
|
|
|
71
|
-
export {
|
|
75
|
+
export { type CmssyClientConfig as C, DEFAULT_CMSSY_API_URL as D, type FetchLike as F, type RetryOption as R, fetchPage as a, fetchPageById as b, fetchPageMeta as c, fetchPages as d, CMSSY_RATE_LIMIT_WINDOW_MS as e, fetchLayouts as f, CMSSY_RETRY_MODES as g, CmssyGraphqlError as h, type CmssyGraphqlErrorEntry as i, CmssyRequestError as j, type CmssyRetryMode as k, type FetchLikeResponse as l, type FetchPageOptions as m, type RetryPolicy as n, createRetryingFetch as o, isTransientRequestError as p, resolveApiUrl as r };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LayoutRegion, BlockPropsSchema, InferBlockContent,
|
|
2
|
-
import { C as
|
|
1
|
+
import { LayoutRegion, BlockPropsSchema, InferBlockContent, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
+
import { C as CmssyClientConfig } from './content-client-EAeHiBv2.cjs';
|
|
3
|
+
import { C as CmssyOperationInput, G as GraphqlRequestOptions } from './locale-CUk6dYTo.cjs';
|
|
3
4
|
|
|
4
5
|
interface CmssyLayout<R extends readonly LayoutRegion[] = readonly LayoutRegion[]> {
|
|
5
6
|
readonly regions: R;
|
|
@@ -26,6 +27,7 @@ interface CmssyConfig<L extends CmssyLayout = CmssyLayout> {
|
|
|
26
27
|
apiUrl?: string;
|
|
27
28
|
org: string;
|
|
28
29
|
workspaceSlug: string;
|
|
30
|
+
channel?: string;
|
|
29
31
|
draftSecret: string;
|
|
30
32
|
devToken?: string;
|
|
31
33
|
editorOrigin?: string | string[];
|
|
@@ -44,9 +46,12 @@ declare function defineCmssyConfig<L extends CmssyLayout = CmssyLayout>(config:
|
|
|
44
46
|
interface QueryScopedOptions extends Omit<GraphqlRequestOptions, "public"> {
|
|
45
47
|
workspaceId?: string;
|
|
46
48
|
}
|
|
47
|
-
type
|
|
49
|
+
type WorkspaceScoped<Variables> = "workspaceId" extends keyof Variables ? Omit<Variables, "workspaceId"> & {
|
|
48
50
|
workspaceId?: string | null;
|
|
49
51
|
} : Variables;
|
|
52
|
+
type ScopedVariables<Variables> = "channel" extends keyof Variables ? Omit<WorkspaceScoped<Variables>, "channel"> & {
|
|
53
|
+
channel?: string | null;
|
|
54
|
+
} : WorkspaceScoped<Variables>;
|
|
50
55
|
type VariablesParameter<Variables, Options> = Record<string, never> extends Variables ? [variables?: Variables, options?: Options] : [variables: Variables, options?: Options];
|
|
51
56
|
interface CmssyClient {
|
|
52
57
|
readonly config: CmssyClientConfig;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LayoutRegion, BlockPropsSchema, InferBlockContent,
|
|
2
|
-
import { C as
|
|
1
|
+
import { LayoutRegion, BlockPropsSchema, InferBlockContent, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
+
import { C as CmssyClientConfig } from './content-client-EAeHiBv2.js';
|
|
3
|
+
import { C as CmssyOperationInput, G as GraphqlRequestOptions } from './locale-Ds2uJX5V.js';
|
|
3
4
|
|
|
4
5
|
interface CmssyLayout<R extends readonly LayoutRegion[] = readonly LayoutRegion[]> {
|
|
5
6
|
readonly regions: R;
|
|
@@ -26,6 +27,7 @@ interface CmssyConfig<L extends CmssyLayout = CmssyLayout> {
|
|
|
26
27
|
apiUrl?: string;
|
|
27
28
|
org: string;
|
|
28
29
|
workspaceSlug: string;
|
|
30
|
+
channel?: string;
|
|
29
31
|
draftSecret: string;
|
|
30
32
|
devToken?: string;
|
|
31
33
|
editorOrigin?: string | string[];
|
|
@@ -44,9 +46,12 @@ declare function defineCmssyConfig<L extends CmssyLayout = CmssyLayout>(config:
|
|
|
44
46
|
interface QueryScopedOptions extends Omit<GraphqlRequestOptions, "public"> {
|
|
45
47
|
workspaceId?: string;
|
|
46
48
|
}
|
|
47
|
-
type
|
|
49
|
+
type WorkspaceScoped<Variables> = "workspaceId" extends keyof Variables ? Omit<Variables, "workspaceId"> & {
|
|
48
50
|
workspaceId?: string | null;
|
|
49
51
|
} : Variables;
|
|
52
|
+
type ScopedVariables<Variables> = "channel" extends keyof Variables ? Omit<WorkspaceScoped<Variables>, "channel"> & {
|
|
53
|
+
channel?: string | null;
|
|
54
|
+
} : WorkspaceScoped<Variables>;
|
|
50
55
|
type VariablesParameter<Variables, Options> = Record<string, never> extends Variables ? [variables?: Variables, options?: Options] : [variables: Variables, options?: Options];
|
|
51
56
|
interface CmssyClient {
|
|
52
57
|
readonly config: CmssyClientConfig;
|
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.16.0" ;
|
|
229
229
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
230
230
|
|
|
231
231
|
// src/data/http.ts
|
|
@@ -452,13 +452,26 @@ function resolvePublicUrl(config) {
|
|
|
452
452
|
// src/data/graphql-request.ts
|
|
453
453
|
async function graphqlRequest(config, query, variables, options = {}, label = "request") {
|
|
454
454
|
const url = options.public ? resolvePublicUrl(config) : resolveApiUrl(config.apiUrl);
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
455
|
+
const text = documentText(query);
|
|
456
|
+
return postGraphql(
|
|
457
|
+
url,
|
|
458
|
+
text,
|
|
459
|
+
withConfigChannel(config, text, variables),
|
|
460
|
+
{
|
|
461
|
+
fetch: options.fetch,
|
|
462
|
+
signal: options.signal,
|
|
463
|
+
headers: options.headers,
|
|
464
|
+
retry: options.retry,
|
|
465
|
+
label
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
function withConfigChannel(config, document2, variables) {
|
|
470
|
+
const channel = config.channel?.trim();
|
|
471
|
+
if (!channel || !/\$channel\b/.test(document2)) return variables;
|
|
472
|
+
const current = variables ?? {};
|
|
473
|
+
if (current.channel !== void 0) return variables;
|
|
474
|
+
return { ...current, channel };
|
|
462
475
|
}
|
|
463
476
|
var SITE_CONFIG_QUERY = typedOperation(`query PublicSiteConfig($workspaceSlug: String!) {
|
|
464
477
|
public {
|
|
@@ -573,9 +586,15 @@ function createCmssyClient(input) {
|
|
|
573
586
|
|
|
574
587
|
// src/data/buyer-prices.ts
|
|
575
588
|
var CMSSY_BUYER_PRICES_MAX_ITEMS = 100;
|
|
576
|
-
var
|
|
589
|
+
var priceDisplayModeValues = ["gross", "net"];
|
|
590
|
+
var priceListSourceValues = ["MEMBER", "COMPANY", "CHANNEL"];
|
|
591
|
+
var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices(
|
|
592
|
+
$workspaceId: ID!
|
|
593
|
+
$items: [PriceQueryItem!]!
|
|
594
|
+
$channel: String
|
|
595
|
+
) {
|
|
577
596
|
account {
|
|
578
|
-
prices(workspaceId: $workspaceId, items: $items) {
|
|
597
|
+
prices(workspaceId: $workspaceId, items: $items, channel: $channel) {
|
|
579
598
|
recordId
|
|
580
599
|
variantKey
|
|
581
600
|
currency
|
|
@@ -584,6 +603,7 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
584
603
|
listed
|
|
585
604
|
basePrice
|
|
586
605
|
source
|
|
606
|
+
listSource
|
|
587
607
|
minQuantity
|
|
588
608
|
maxQuantity
|
|
589
609
|
increment
|
|
@@ -591,6 +611,23 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
591
611
|
minQty
|
|
592
612
|
price
|
|
593
613
|
}
|
|
614
|
+
displayMode
|
|
615
|
+
taxRate
|
|
616
|
+
priceAmount {
|
|
617
|
+
net
|
|
618
|
+
tax
|
|
619
|
+
gross
|
|
620
|
+
}
|
|
621
|
+
priceMaxAmount {
|
|
622
|
+
net
|
|
623
|
+
tax
|
|
624
|
+
gross
|
|
625
|
+
}
|
|
626
|
+
basePriceAmount {
|
|
627
|
+
net
|
|
628
|
+
tax
|
|
629
|
+
gross
|
|
630
|
+
}
|
|
594
631
|
}
|
|
595
632
|
}
|
|
596
633
|
}`);
|
|
@@ -613,7 +650,8 @@ async function getBuyerPrices(config, items, options) {
|
|
|
613
650
|
workspaceId: options.workspaceId,
|
|
614
651
|
items: items.map(
|
|
615
652
|
({ recordId, variantKey }) => variantKey ? { recordId, variantKey } : { recordId }
|
|
616
|
-
)
|
|
653
|
+
),
|
|
654
|
+
...channelVariable(options.channel)
|
|
617
655
|
},
|
|
618
656
|
{
|
|
619
657
|
public: true,
|
|
@@ -642,6 +680,7 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
642
680
|
$sort: BuyerCatalogSort
|
|
643
681
|
$limit: Int
|
|
644
682
|
$offset: Int
|
|
683
|
+
$channel: String
|
|
645
684
|
) {
|
|
646
685
|
account {
|
|
647
686
|
catalogPrices(
|
|
@@ -657,9 +696,11 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
657
696
|
sort: $sort
|
|
658
697
|
limit: $limit
|
|
659
698
|
offset: $offset
|
|
699
|
+
channel: $channel
|
|
660
700
|
) {
|
|
661
701
|
total
|
|
662
702
|
hasMore
|
|
703
|
+
displayMode
|
|
663
704
|
items {
|
|
664
705
|
recordId
|
|
665
706
|
currency
|
|
@@ -668,9 +709,27 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
668
709
|
listed
|
|
669
710
|
basePrice
|
|
670
711
|
source
|
|
712
|
+
listSource
|
|
671
713
|
minQuantity
|
|
672
714
|
maxQuantity
|
|
673
715
|
increment
|
|
716
|
+
displayMode
|
|
717
|
+
taxRate
|
|
718
|
+
priceAmount {
|
|
719
|
+
net
|
|
720
|
+
tax
|
|
721
|
+
gross
|
|
722
|
+
}
|
|
723
|
+
priceMaxAmount {
|
|
724
|
+
net
|
|
725
|
+
tax
|
|
726
|
+
gross
|
|
727
|
+
}
|
|
728
|
+
basePriceAmount {
|
|
729
|
+
net
|
|
730
|
+
tax
|
|
731
|
+
gross
|
|
732
|
+
}
|
|
674
733
|
}
|
|
675
734
|
}
|
|
676
735
|
}
|
|
@@ -684,7 +743,11 @@ async function getBuyerCatalogPrices(config, query, options) {
|
|
|
684
743
|
const data = await graphqlRequest(
|
|
685
744
|
config,
|
|
686
745
|
BUYER_CATALOG_PRICES_QUERY,
|
|
687
|
-
{
|
|
746
|
+
{
|
|
747
|
+
...query,
|
|
748
|
+
workspaceId: options.workspaceId,
|
|
749
|
+
...channelVariable(options.channel)
|
|
750
|
+
},
|
|
688
751
|
{
|
|
689
752
|
public: true,
|
|
690
753
|
fetch: options.fetch,
|
|
@@ -699,6 +762,229 @@ async function getBuyerCatalogPrices(config, query, options) {
|
|
|
699
762
|
);
|
|
700
763
|
return data.account.catalogPrices;
|
|
701
764
|
}
|
|
765
|
+
function channelVariable(channel) {
|
|
766
|
+
return channel === void 0 ? {} : { channel };
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// src/data/public-prices.ts
|
|
770
|
+
var CMSSY_PUBLIC_PRICES_MAX_ITEMS = 50;
|
|
771
|
+
var priceWithheldReasonValues = [
|
|
772
|
+
"MEMBERS_ONLY",
|
|
773
|
+
"COMPANY_MEMBERS_ONLY"
|
|
774
|
+
];
|
|
775
|
+
var PUBLIC_PRICES_QUERY = typedOperation(`query PublicPrices(
|
|
776
|
+
$workspaceId: String!
|
|
777
|
+
$channel: String!
|
|
778
|
+
$items: [PriceQueryItem!]!
|
|
779
|
+
$locale: String
|
|
780
|
+
) {
|
|
781
|
+
public {
|
|
782
|
+
pricing {
|
|
783
|
+
prices(
|
|
784
|
+
workspaceId: $workspaceId
|
|
785
|
+
channel: $channel
|
|
786
|
+
items: $items
|
|
787
|
+
locale: $locale
|
|
788
|
+
) {
|
|
789
|
+
displayMode
|
|
790
|
+
priceWithheld
|
|
791
|
+
nextChangeAt
|
|
792
|
+
items {
|
|
793
|
+
record {
|
|
794
|
+
id
|
|
795
|
+
modelId
|
|
796
|
+
data
|
|
797
|
+
status
|
|
798
|
+
available
|
|
799
|
+
quantityIncrement
|
|
800
|
+
variantCount
|
|
801
|
+
createdAt
|
|
802
|
+
updatedAt
|
|
803
|
+
}
|
|
804
|
+
price {
|
|
805
|
+
recordId
|
|
806
|
+
variantKey
|
|
807
|
+
currency
|
|
808
|
+
price
|
|
809
|
+
priceMax
|
|
810
|
+
listed
|
|
811
|
+
basePrice
|
|
812
|
+
source
|
|
813
|
+
listSource
|
|
814
|
+
minQuantity
|
|
815
|
+
maxQuantity
|
|
816
|
+
increment
|
|
817
|
+
tiers {
|
|
818
|
+
minQty
|
|
819
|
+
price
|
|
820
|
+
}
|
|
821
|
+
displayMode
|
|
822
|
+
taxRate
|
|
823
|
+
priceAmount {
|
|
824
|
+
net
|
|
825
|
+
tax
|
|
826
|
+
gross
|
|
827
|
+
}
|
|
828
|
+
priceMaxAmount {
|
|
829
|
+
net
|
|
830
|
+
tax
|
|
831
|
+
gross
|
|
832
|
+
}
|
|
833
|
+
basePriceAmount {
|
|
834
|
+
net
|
|
835
|
+
tax
|
|
836
|
+
gross
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
}`);
|
|
844
|
+
var PUBLIC_CATALOG_PRICES_QUERY = typedOperation(`query PublicCatalogPrices(
|
|
845
|
+
$workspaceId: String!
|
|
846
|
+
$channel: String!
|
|
847
|
+
$modelSlug: String!
|
|
848
|
+
$filter: JSON
|
|
849
|
+
$stockState: String
|
|
850
|
+
$sku: String
|
|
851
|
+
$locale: String
|
|
852
|
+
$currency: String
|
|
853
|
+
$priceMin: Int
|
|
854
|
+
$priceMax: Int
|
|
855
|
+
$sort: BuyerCatalogSort
|
|
856
|
+
$limit: Int
|
|
857
|
+
$offset: Int
|
|
858
|
+
) {
|
|
859
|
+
public {
|
|
860
|
+
pricing {
|
|
861
|
+
catalogPrices(
|
|
862
|
+
workspaceId: $workspaceId
|
|
863
|
+
channel: $channel
|
|
864
|
+
modelSlug: $modelSlug
|
|
865
|
+
filter: $filter
|
|
866
|
+
stockState: $stockState
|
|
867
|
+
sku: $sku
|
|
868
|
+
locale: $locale
|
|
869
|
+
currency: $currency
|
|
870
|
+
priceMin: $priceMin
|
|
871
|
+
priceMax: $priceMax
|
|
872
|
+
sort: $sort
|
|
873
|
+
limit: $limit
|
|
874
|
+
offset: $offset
|
|
875
|
+
) {
|
|
876
|
+
total
|
|
877
|
+
hasMore
|
|
878
|
+
displayMode
|
|
879
|
+
priceWithheld
|
|
880
|
+
nextChangeAt
|
|
881
|
+
items {
|
|
882
|
+
record {
|
|
883
|
+
id
|
|
884
|
+
modelId
|
|
885
|
+
data
|
|
886
|
+
status
|
|
887
|
+
available
|
|
888
|
+
quantityIncrement
|
|
889
|
+
variantCount
|
|
890
|
+
createdAt
|
|
891
|
+
updatedAt
|
|
892
|
+
}
|
|
893
|
+
price {
|
|
894
|
+
recordId
|
|
895
|
+
variantKey
|
|
896
|
+
currency
|
|
897
|
+
price
|
|
898
|
+
priceMax
|
|
899
|
+
listed
|
|
900
|
+
basePrice
|
|
901
|
+
source
|
|
902
|
+
listSource
|
|
903
|
+
minQuantity
|
|
904
|
+
maxQuantity
|
|
905
|
+
increment
|
|
906
|
+
tiers {
|
|
907
|
+
minQty
|
|
908
|
+
price
|
|
909
|
+
}
|
|
910
|
+
displayMode
|
|
911
|
+
taxRate
|
|
912
|
+
priceAmount {
|
|
913
|
+
net
|
|
914
|
+
tax
|
|
915
|
+
gross
|
|
916
|
+
}
|
|
917
|
+
priceMaxAmount {
|
|
918
|
+
net
|
|
919
|
+
tax
|
|
920
|
+
gross
|
|
921
|
+
}
|
|
922
|
+
basePriceAmount {
|
|
923
|
+
net
|
|
924
|
+
tax
|
|
925
|
+
gross
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}`);
|
|
933
|
+
function requireChannel(config, options, helper) {
|
|
934
|
+
const channel = (options.channel ?? config.channel)?.trim();
|
|
935
|
+
if (!channel) {
|
|
936
|
+
throw new Error(
|
|
937
|
+
`cmssy: ${helper} needs a sales channel - set channel in the client config or pass it in the options`
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
return channel;
|
|
941
|
+
}
|
|
942
|
+
async function getPublicPrices(config, items, options) {
|
|
943
|
+
const channel = requireChannel(config, options, "getPublicPrices");
|
|
944
|
+
if (items.length > CMSSY_PUBLIC_PRICES_MAX_ITEMS) {
|
|
945
|
+
throw new Error(
|
|
946
|
+
`cmssy: getPublicPrices takes at most ${CMSSY_PUBLIC_PRICES_MAX_ITEMS} items, got ${items.length} - split the request`
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
const data = await graphqlRequest(
|
|
950
|
+
config,
|
|
951
|
+
PUBLIC_PRICES_QUERY,
|
|
952
|
+
{
|
|
953
|
+
workspaceId: options.workspaceId,
|
|
954
|
+
channel,
|
|
955
|
+
items: items.map(
|
|
956
|
+
({ recordId, variantKey }) => variantKey ? { recordId, variantKey } : { recordId }
|
|
957
|
+
),
|
|
958
|
+
...options.locale ? { locale: options.locale } : {}
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
public: true,
|
|
962
|
+
fetch: options.fetch,
|
|
963
|
+
signal: options.signal,
|
|
964
|
+
retry: options.retry,
|
|
965
|
+
headers: { "x-workspace-id": options.workspaceId }
|
|
966
|
+
},
|
|
967
|
+
"channel prices"
|
|
968
|
+
);
|
|
969
|
+
return data.public.pricing.prices;
|
|
970
|
+
}
|
|
971
|
+
async function getPublicCatalogPrices(config, query, options) {
|
|
972
|
+
const channel = requireChannel(config, options, "getPublicCatalogPrices");
|
|
973
|
+
const data = await graphqlRequest(
|
|
974
|
+
config,
|
|
975
|
+
PUBLIC_CATALOG_PRICES_QUERY,
|
|
976
|
+
{ ...query, workspaceId: options.workspaceId, channel },
|
|
977
|
+
{
|
|
978
|
+
public: true,
|
|
979
|
+
fetch: options.fetch,
|
|
980
|
+
signal: options.signal,
|
|
981
|
+
retry: options.retry,
|
|
982
|
+
headers: { "x-workspace-id": options.workspaceId }
|
|
983
|
+
},
|
|
984
|
+
"channel catalogue prices"
|
|
985
|
+
);
|
|
986
|
+
return data.public.pricing.catalogPrices;
|
|
987
|
+
}
|
|
702
988
|
|
|
703
989
|
// src/data/checkout-errors.ts
|
|
704
990
|
var quantityRuleReasonValues = [
|
|
@@ -709,6 +995,7 @@ var quantityRuleReasonValues = [
|
|
|
709
995
|
var checkoutErrorReasonValues = [
|
|
710
996
|
"CART_REPRICED",
|
|
711
997
|
"CART_CURRENCY_CHANGED",
|
|
998
|
+
"BUYER_CHANGED",
|
|
712
999
|
"PRODUCT_NOT_SOLD",
|
|
713
1000
|
...quantityRuleReasonValues
|
|
714
1001
|
];
|
|
@@ -748,6 +1035,30 @@ function quantityRuleViolation(error) {
|
|
|
748
1035
|
}
|
|
749
1036
|
return void 0;
|
|
750
1037
|
}
|
|
1038
|
+
var channelRefusalReasonValues = [
|
|
1039
|
+
"UNKNOWN_CHANNEL",
|
|
1040
|
+
...priceWithheldReasonValues
|
|
1041
|
+
];
|
|
1042
|
+
var WITHHELD_REASONS = new Set(
|
|
1043
|
+
priceWithheldReasonValues
|
|
1044
|
+
);
|
|
1045
|
+
function channelRefusal(error) {
|
|
1046
|
+
if (!(error instanceof CmssyGraphqlError)) return void 0;
|
|
1047
|
+
for (const entry of error.errors) {
|
|
1048
|
+
const ext = entry.extensions;
|
|
1049
|
+
if (!ext || typeof ext.channel !== "string") continue;
|
|
1050
|
+
if (typeof ext.reason === "string" && WITHHELD_REASONS.has(ext.reason)) {
|
|
1051
|
+
return {
|
|
1052
|
+
reason: ext.reason,
|
|
1053
|
+
channel: ext.channel
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
if (ext.code === "BAD_USER_INPUT" && ext.reason === void 0) {
|
|
1057
|
+
return { reason: "UNKNOWN_CHANNEL", channel: ext.channel };
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
return void 0;
|
|
1061
|
+
}
|
|
751
1062
|
|
|
752
1063
|
// src/fields.ts
|
|
753
1064
|
function build(type, opts) {
|
|
@@ -1389,6 +1700,7 @@ exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
|
|
|
1389
1700
|
exports.CMSSY_EDIT_QUERY_PARAM = CMSSY_EDIT_QUERY_PARAM;
|
|
1390
1701
|
exports.CMSSY_EDIT_TOKEN_HEADER = CMSSY_EDIT_TOKEN_HEADER;
|
|
1391
1702
|
exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
1703
|
+
exports.CMSSY_PUBLIC_PRICES_MAX_ITEMS = CMSSY_PUBLIC_PRICES_MAX_ITEMS;
|
|
1392
1704
|
exports.CMSSY_RATE_LIMIT_WINDOW_MS = CMSSY_RATE_LIMIT_WINDOW_MS;
|
|
1393
1705
|
exports.CMSSY_RETRY_MODES = CMSSY_RETRY_MODES;
|
|
1394
1706
|
exports.CMSSY_SECRET_QUERY_PARAM = CMSSY_SECRET_QUERY_PARAM;
|
|
@@ -1398,11 +1710,15 @@ exports.CmssyWebhookError = CmssyWebhookError;
|
|
|
1398
1710
|
exports.DEFAULT_CMSSY_API_URL = DEFAULT_CMSSY_API_URL;
|
|
1399
1711
|
exports.DEFAULT_CMSSY_EDITOR_ORIGINS = DEFAULT_CMSSY_EDITOR_ORIGINS;
|
|
1400
1712
|
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
1713
|
+
exports.PUBLIC_CATALOG_PRICES_QUERY = PUBLIC_CATALOG_PRICES_QUERY;
|
|
1714
|
+
exports.PUBLIC_PRICES_QUERY = PUBLIC_PRICES_QUERY;
|
|
1401
1715
|
exports.SHORTCUT_ACTIONS = SHORTCUT_ACTIONS;
|
|
1402
1716
|
exports.applyCmssyCsp = applyCmssyCsp;
|
|
1403
1717
|
exports.blocksToMeta = blocksToMeta;
|
|
1404
1718
|
exports.blocksToSchemas = blocksToSchemas;
|
|
1405
1719
|
exports.buildBlockManifest = buildBlockManifest;
|
|
1720
|
+
exports.channelRefusal = channelRefusal;
|
|
1721
|
+
exports.channelRefusalReasonValues = channelRefusalReasonValues;
|
|
1406
1722
|
exports.checkoutErrorReason = checkoutErrorReason;
|
|
1407
1723
|
exports.checkoutErrorReasonValues = checkoutErrorReasonValues;
|
|
1408
1724
|
exports.createCmssyClient = createCmssyClient;
|
|
@@ -1412,6 +1728,8 @@ exports.defineCmssyLayout = defineCmssyLayout;
|
|
|
1412
1728
|
exports.fields = fields;
|
|
1413
1729
|
exports.getBuyerCatalogPrices = getBuyerCatalogPrices;
|
|
1414
1730
|
exports.getBuyerPrices = getBuyerPrices;
|
|
1731
|
+
exports.getPublicCatalogPrices = getPublicCatalogPrices;
|
|
1732
|
+
exports.getPublicPrices = getPublicPrices;
|
|
1415
1733
|
exports.graphqlRequest = graphqlRequest;
|
|
1416
1734
|
exports.isFormFieldRequired = isFormFieldRequired;
|
|
1417
1735
|
exports.isFormFieldVisible = isFormFieldVisible;
|
|
@@ -1431,6 +1749,9 @@ exports.orderProgress = orderProgress;
|
|
|
1431
1749
|
exports.orderProgressValues = orderProgressValues;
|
|
1432
1750
|
exports.parseEditorMessage = parseEditorMessage;
|
|
1433
1751
|
exports.postToEditor = postToEditor;
|
|
1752
|
+
exports.priceDisplayModeValues = priceDisplayModeValues;
|
|
1753
|
+
exports.priceListSourceValues = priceListSourceValues;
|
|
1754
|
+
exports.priceWithheldReasonValues = priceWithheldReasonValues;
|
|
1434
1755
|
exports.propsToSchema = propsToSchema;
|
|
1435
1756
|
exports.quantityRuleReasonValues = quantityRuleReasonValues;
|
|
1436
1757
|
exports.quantityRuleViolation = quantityRuleViolation;
|