@cmssy/core 19.15.0 → 19.17.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 +312 -14
- package/dist/index.d.cts +113 -10
- package/dist/index.d.ts +113 -10
- package/dist/index.js +301 -16
- 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 +29 -12
- package/dist/internal.d.cts +7 -6
- package/dist/internal.d.ts +7 -6
- package/dist/internal.js +29 -12
- 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.17.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 {
|
|
@@ -570,13 +583,16 @@ function createCmssyClient(input) {
|
|
|
570
583
|
};
|
|
571
584
|
return client;
|
|
572
585
|
}
|
|
573
|
-
|
|
574
|
-
// src/data/buyer-prices.ts
|
|
575
586
|
var CMSSY_BUYER_PRICES_MAX_ITEMS = 100;
|
|
576
587
|
var priceDisplayModeValues = ["gross", "net"];
|
|
577
|
-
var
|
|
588
|
+
var priceListSourceValues = ["MEMBER", "COMPANY", "CHANNEL"];
|
|
589
|
+
var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices(
|
|
590
|
+
$workspaceId: ID!
|
|
591
|
+
$items: [PriceQueryItem!]!
|
|
592
|
+
$channel: String
|
|
593
|
+
) {
|
|
578
594
|
account {
|
|
579
|
-
prices(workspaceId: $workspaceId, items: $items) {
|
|
595
|
+
prices(workspaceId: $workspaceId, items: $items, channel: $channel) {
|
|
580
596
|
recordId
|
|
581
597
|
variantKey
|
|
582
598
|
currency
|
|
@@ -585,6 +601,7 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
585
601
|
listed
|
|
586
602
|
basePrice
|
|
587
603
|
source
|
|
604
|
+
listSource
|
|
588
605
|
minQuantity
|
|
589
606
|
maxQuantity
|
|
590
607
|
increment
|
|
@@ -594,6 +611,7 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
594
611
|
}
|
|
595
612
|
displayMode
|
|
596
613
|
taxRate
|
|
614
|
+
taxTreatmentKind
|
|
597
615
|
priceAmount {
|
|
598
616
|
net
|
|
599
617
|
tax
|
|
@@ -631,7 +649,8 @@ async function getBuyerPrices(config, items, options) {
|
|
|
631
649
|
workspaceId: options.workspaceId,
|
|
632
650
|
items: items.map(
|
|
633
651
|
({ recordId, variantKey }) => variantKey ? { recordId, variantKey } : { recordId }
|
|
634
|
-
)
|
|
652
|
+
),
|
|
653
|
+
...channelVariable(options.channel)
|
|
635
654
|
},
|
|
636
655
|
{
|
|
637
656
|
public: true,
|
|
@@ -660,6 +679,7 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
660
679
|
$sort: BuyerCatalogSort
|
|
661
680
|
$limit: Int
|
|
662
681
|
$offset: Int
|
|
682
|
+
$channel: String
|
|
663
683
|
) {
|
|
664
684
|
account {
|
|
665
685
|
catalogPrices(
|
|
@@ -675,10 +695,19 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
675
695
|
sort: $sort
|
|
676
696
|
limit: $limit
|
|
677
697
|
offset: $offset
|
|
698
|
+
channel: $channel
|
|
678
699
|
) {
|
|
679
700
|
total
|
|
680
701
|
hasMore
|
|
681
702
|
displayMode
|
|
703
|
+
taxTreatment {
|
|
704
|
+
kind
|
|
705
|
+
legalNote
|
|
706
|
+
buyerVatId
|
|
707
|
+
buyerVatCountry
|
|
708
|
+
sellerCountry
|
|
709
|
+
shipToCountry
|
|
710
|
+
}
|
|
682
711
|
items {
|
|
683
712
|
recordId
|
|
684
713
|
currency
|
|
@@ -687,11 +716,13 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
687
716
|
listed
|
|
688
717
|
basePrice
|
|
689
718
|
source
|
|
719
|
+
listSource
|
|
690
720
|
minQuantity
|
|
691
721
|
maxQuantity
|
|
692
722
|
increment
|
|
693
723
|
displayMode
|
|
694
724
|
taxRate
|
|
725
|
+
taxTreatmentKind
|
|
695
726
|
priceAmount {
|
|
696
727
|
net
|
|
697
728
|
tax
|
|
@@ -720,7 +751,11 @@ async function getBuyerCatalogPrices(config, query, options) {
|
|
|
720
751
|
const data = await graphqlRequest(
|
|
721
752
|
config,
|
|
722
753
|
BUYER_CATALOG_PRICES_QUERY,
|
|
723
|
-
{
|
|
754
|
+
{
|
|
755
|
+
...query,
|
|
756
|
+
workspaceId: options.workspaceId,
|
|
757
|
+
...channelVariable(options.channel)
|
|
758
|
+
},
|
|
724
759
|
{
|
|
725
760
|
public: true,
|
|
726
761
|
fetch: options.fetch,
|
|
@@ -735,6 +770,231 @@ async function getBuyerCatalogPrices(config, query, options) {
|
|
|
735
770
|
);
|
|
736
771
|
return data.account.catalogPrices;
|
|
737
772
|
}
|
|
773
|
+
function channelVariable(channel) {
|
|
774
|
+
return channel === void 0 ? {} : { channel };
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// src/data/public-prices.ts
|
|
778
|
+
var CMSSY_PUBLIC_PRICES_MAX_ITEMS = 50;
|
|
779
|
+
var priceWithheldReasonValues = [
|
|
780
|
+
"MEMBERS_ONLY",
|
|
781
|
+
"COMPANY_MEMBERS_ONLY"
|
|
782
|
+
];
|
|
783
|
+
var PUBLIC_PRICES_QUERY = typedOperation(`query PublicPrices(
|
|
784
|
+
$workspaceId: String!
|
|
785
|
+
$channel: String!
|
|
786
|
+
$items: [PriceQueryItem!]!
|
|
787
|
+
$locale: String
|
|
788
|
+
) {
|
|
789
|
+
public {
|
|
790
|
+
pricing {
|
|
791
|
+
prices(
|
|
792
|
+
workspaceId: $workspaceId
|
|
793
|
+
channel: $channel
|
|
794
|
+
items: $items
|
|
795
|
+
locale: $locale
|
|
796
|
+
) {
|
|
797
|
+
displayMode
|
|
798
|
+
priceWithheld
|
|
799
|
+
nextChangeAt
|
|
800
|
+
items {
|
|
801
|
+
record {
|
|
802
|
+
id
|
|
803
|
+
modelId
|
|
804
|
+
data
|
|
805
|
+
status
|
|
806
|
+
available
|
|
807
|
+
quantityIncrement
|
|
808
|
+
variantCount
|
|
809
|
+
createdAt
|
|
810
|
+
updatedAt
|
|
811
|
+
}
|
|
812
|
+
price {
|
|
813
|
+
recordId
|
|
814
|
+
variantKey
|
|
815
|
+
currency
|
|
816
|
+
price
|
|
817
|
+
priceMax
|
|
818
|
+
listed
|
|
819
|
+
basePrice
|
|
820
|
+
source
|
|
821
|
+
listSource
|
|
822
|
+
minQuantity
|
|
823
|
+
maxQuantity
|
|
824
|
+
increment
|
|
825
|
+
tiers {
|
|
826
|
+
minQty
|
|
827
|
+
price
|
|
828
|
+
}
|
|
829
|
+
displayMode
|
|
830
|
+
taxRate
|
|
831
|
+
taxTreatmentKind
|
|
832
|
+
priceAmount {
|
|
833
|
+
net
|
|
834
|
+
tax
|
|
835
|
+
gross
|
|
836
|
+
}
|
|
837
|
+
priceMaxAmount {
|
|
838
|
+
net
|
|
839
|
+
tax
|
|
840
|
+
gross
|
|
841
|
+
}
|
|
842
|
+
basePriceAmount {
|
|
843
|
+
net
|
|
844
|
+
tax
|
|
845
|
+
gross
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}`);
|
|
853
|
+
var PUBLIC_CATALOG_PRICES_QUERY = typedOperation(`query PublicCatalogPrices(
|
|
854
|
+
$workspaceId: String!
|
|
855
|
+
$channel: String!
|
|
856
|
+
$modelSlug: String!
|
|
857
|
+
$filter: JSON
|
|
858
|
+
$stockState: String
|
|
859
|
+
$sku: String
|
|
860
|
+
$locale: String
|
|
861
|
+
$currency: String
|
|
862
|
+
$priceMin: Int
|
|
863
|
+
$priceMax: Int
|
|
864
|
+
$sort: BuyerCatalogSort
|
|
865
|
+
$limit: Int
|
|
866
|
+
$offset: Int
|
|
867
|
+
) {
|
|
868
|
+
public {
|
|
869
|
+
pricing {
|
|
870
|
+
catalogPrices(
|
|
871
|
+
workspaceId: $workspaceId
|
|
872
|
+
channel: $channel
|
|
873
|
+
modelSlug: $modelSlug
|
|
874
|
+
filter: $filter
|
|
875
|
+
stockState: $stockState
|
|
876
|
+
sku: $sku
|
|
877
|
+
locale: $locale
|
|
878
|
+
currency: $currency
|
|
879
|
+
priceMin: $priceMin
|
|
880
|
+
priceMax: $priceMax
|
|
881
|
+
sort: $sort
|
|
882
|
+
limit: $limit
|
|
883
|
+
offset: $offset
|
|
884
|
+
) {
|
|
885
|
+
total
|
|
886
|
+
hasMore
|
|
887
|
+
displayMode
|
|
888
|
+
priceWithheld
|
|
889
|
+
nextChangeAt
|
|
890
|
+
items {
|
|
891
|
+
record {
|
|
892
|
+
id
|
|
893
|
+
modelId
|
|
894
|
+
data
|
|
895
|
+
status
|
|
896
|
+
available
|
|
897
|
+
quantityIncrement
|
|
898
|
+
variantCount
|
|
899
|
+
createdAt
|
|
900
|
+
updatedAt
|
|
901
|
+
}
|
|
902
|
+
price {
|
|
903
|
+
recordId
|
|
904
|
+
variantKey
|
|
905
|
+
currency
|
|
906
|
+
price
|
|
907
|
+
priceMax
|
|
908
|
+
listed
|
|
909
|
+
basePrice
|
|
910
|
+
source
|
|
911
|
+
listSource
|
|
912
|
+
minQuantity
|
|
913
|
+
maxQuantity
|
|
914
|
+
increment
|
|
915
|
+
tiers {
|
|
916
|
+
minQty
|
|
917
|
+
price
|
|
918
|
+
}
|
|
919
|
+
displayMode
|
|
920
|
+
taxRate
|
|
921
|
+
taxTreatmentKind
|
|
922
|
+
priceAmount {
|
|
923
|
+
net
|
|
924
|
+
tax
|
|
925
|
+
gross
|
|
926
|
+
}
|
|
927
|
+
priceMaxAmount {
|
|
928
|
+
net
|
|
929
|
+
tax
|
|
930
|
+
gross
|
|
931
|
+
}
|
|
932
|
+
basePriceAmount {
|
|
933
|
+
net
|
|
934
|
+
tax
|
|
935
|
+
gross
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}`);
|
|
943
|
+
function requireChannel(config, options, helper) {
|
|
944
|
+
const channel = (options.channel ?? config.channel)?.trim();
|
|
945
|
+
if (!channel) {
|
|
946
|
+
throw new Error(
|
|
947
|
+
`cmssy: ${helper} needs a sales channel - set channel in the client config or pass it in the options`
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
return channel;
|
|
951
|
+
}
|
|
952
|
+
async function getPublicPrices(config, items, options) {
|
|
953
|
+
const channel = requireChannel(config, options, "getPublicPrices");
|
|
954
|
+
if (items.length > CMSSY_PUBLIC_PRICES_MAX_ITEMS) {
|
|
955
|
+
throw new Error(
|
|
956
|
+
`cmssy: getPublicPrices takes at most ${CMSSY_PUBLIC_PRICES_MAX_ITEMS} items, got ${items.length} - split the request`
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
const data = await graphqlRequest(
|
|
960
|
+
config,
|
|
961
|
+
PUBLIC_PRICES_QUERY,
|
|
962
|
+
{
|
|
963
|
+
workspaceId: options.workspaceId,
|
|
964
|
+
channel,
|
|
965
|
+
items: items.map(
|
|
966
|
+
({ recordId, variantKey }) => variantKey ? { recordId, variantKey } : { recordId }
|
|
967
|
+
),
|
|
968
|
+
...options.locale ? { locale: options.locale } : {}
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
public: true,
|
|
972
|
+
fetch: options.fetch,
|
|
973
|
+
signal: options.signal,
|
|
974
|
+
retry: options.retry,
|
|
975
|
+
headers: { "x-workspace-id": options.workspaceId }
|
|
976
|
+
},
|
|
977
|
+
"channel prices"
|
|
978
|
+
);
|
|
979
|
+
return data.public.pricing.prices;
|
|
980
|
+
}
|
|
981
|
+
async function getPublicCatalogPrices(config, query, options) {
|
|
982
|
+
const channel = requireChannel(config, options, "getPublicCatalogPrices");
|
|
983
|
+
const data = await graphqlRequest(
|
|
984
|
+
config,
|
|
985
|
+
PUBLIC_CATALOG_PRICES_QUERY,
|
|
986
|
+
{ ...query, workspaceId: options.workspaceId, channel },
|
|
987
|
+
{
|
|
988
|
+
public: true,
|
|
989
|
+
fetch: options.fetch,
|
|
990
|
+
signal: options.signal,
|
|
991
|
+
retry: options.retry,
|
|
992
|
+
headers: { "x-workspace-id": options.workspaceId }
|
|
993
|
+
},
|
|
994
|
+
"channel catalogue prices"
|
|
995
|
+
);
|
|
996
|
+
return data.public.pricing.catalogPrices;
|
|
997
|
+
}
|
|
738
998
|
|
|
739
999
|
// src/data/checkout-errors.ts
|
|
740
1000
|
var quantityRuleReasonValues = [
|
|
@@ -747,6 +1007,7 @@ var checkoutErrorReasonValues = [
|
|
|
747
1007
|
"CART_CURRENCY_CHANGED",
|
|
748
1008
|
"BUYER_CHANGED",
|
|
749
1009
|
"PRODUCT_NOT_SOLD",
|
|
1010
|
+
"TAX_TREATMENT_CHANGED",
|
|
750
1011
|
...quantityRuleReasonValues
|
|
751
1012
|
];
|
|
752
1013
|
var REASONS = new Set(checkoutErrorReasonValues);
|
|
@@ -785,6 +1046,30 @@ function quantityRuleViolation(error) {
|
|
|
785
1046
|
}
|
|
786
1047
|
return void 0;
|
|
787
1048
|
}
|
|
1049
|
+
var channelRefusalReasonValues = [
|
|
1050
|
+
"UNKNOWN_CHANNEL",
|
|
1051
|
+
...priceWithheldReasonValues
|
|
1052
|
+
];
|
|
1053
|
+
var WITHHELD_REASONS = new Set(
|
|
1054
|
+
priceWithheldReasonValues
|
|
1055
|
+
);
|
|
1056
|
+
function channelRefusal(error) {
|
|
1057
|
+
if (!(error instanceof CmssyGraphqlError)) return void 0;
|
|
1058
|
+
for (const entry of error.errors) {
|
|
1059
|
+
const ext = entry.extensions;
|
|
1060
|
+
if (!ext || typeof ext.channel !== "string") continue;
|
|
1061
|
+
if (typeof ext.reason === "string" && WITHHELD_REASONS.has(ext.reason)) {
|
|
1062
|
+
return {
|
|
1063
|
+
reason: ext.reason,
|
|
1064
|
+
channel: ext.channel
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
if (ext.code === "BAD_USER_INPUT" && ext.reason === void 0) {
|
|
1068
|
+
return { reason: "UNKNOWN_CHANNEL", channel: ext.channel };
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return void 0;
|
|
1072
|
+
}
|
|
788
1073
|
|
|
789
1074
|
// src/fields.ts
|
|
790
1075
|
function build(type, opts) {
|
|
@@ -1419,6 +1704,10 @@ Object.defineProperty(exports, "mediaTypeValues", {
|
|
|
1419
1704
|
enumerable: true,
|
|
1420
1705
|
get: function () { return types.mediaTypeValues; }
|
|
1421
1706
|
});
|
|
1707
|
+
Object.defineProperty(exports, "taxTreatmentKindValues", {
|
|
1708
|
+
enumerable: true,
|
|
1709
|
+
get: function () { return types.taxTreatmentKindValues; }
|
|
1710
|
+
});
|
|
1422
1711
|
exports.BUYER_CATALOG_PRICES_QUERY = BUYER_CATALOG_PRICES_QUERY;
|
|
1423
1712
|
exports.BUYER_PRICES_QUERY = BUYER_PRICES_QUERY;
|
|
1424
1713
|
exports.CMSSY_BUYER_PRICES_MAX_ITEMS = CMSSY_BUYER_PRICES_MAX_ITEMS;
|
|
@@ -1426,6 +1715,7 @@ exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
|
|
|
1426
1715
|
exports.CMSSY_EDIT_QUERY_PARAM = CMSSY_EDIT_QUERY_PARAM;
|
|
1427
1716
|
exports.CMSSY_EDIT_TOKEN_HEADER = CMSSY_EDIT_TOKEN_HEADER;
|
|
1428
1717
|
exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
1718
|
+
exports.CMSSY_PUBLIC_PRICES_MAX_ITEMS = CMSSY_PUBLIC_PRICES_MAX_ITEMS;
|
|
1429
1719
|
exports.CMSSY_RATE_LIMIT_WINDOW_MS = CMSSY_RATE_LIMIT_WINDOW_MS;
|
|
1430
1720
|
exports.CMSSY_RETRY_MODES = CMSSY_RETRY_MODES;
|
|
1431
1721
|
exports.CMSSY_SECRET_QUERY_PARAM = CMSSY_SECRET_QUERY_PARAM;
|
|
@@ -1435,11 +1725,15 @@ exports.CmssyWebhookError = CmssyWebhookError;
|
|
|
1435
1725
|
exports.DEFAULT_CMSSY_API_URL = DEFAULT_CMSSY_API_URL;
|
|
1436
1726
|
exports.DEFAULT_CMSSY_EDITOR_ORIGINS = DEFAULT_CMSSY_EDITOR_ORIGINS;
|
|
1437
1727
|
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
1728
|
+
exports.PUBLIC_CATALOG_PRICES_QUERY = PUBLIC_CATALOG_PRICES_QUERY;
|
|
1729
|
+
exports.PUBLIC_PRICES_QUERY = PUBLIC_PRICES_QUERY;
|
|
1438
1730
|
exports.SHORTCUT_ACTIONS = SHORTCUT_ACTIONS;
|
|
1439
1731
|
exports.applyCmssyCsp = applyCmssyCsp;
|
|
1440
1732
|
exports.blocksToMeta = blocksToMeta;
|
|
1441
1733
|
exports.blocksToSchemas = blocksToSchemas;
|
|
1442
1734
|
exports.buildBlockManifest = buildBlockManifest;
|
|
1735
|
+
exports.channelRefusal = channelRefusal;
|
|
1736
|
+
exports.channelRefusalReasonValues = channelRefusalReasonValues;
|
|
1443
1737
|
exports.checkoutErrorReason = checkoutErrorReason;
|
|
1444
1738
|
exports.checkoutErrorReasonValues = checkoutErrorReasonValues;
|
|
1445
1739
|
exports.createCmssyClient = createCmssyClient;
|
|
@@ -1449,6 +1743,8 @@ exports.defineCmssyLayout = defineCmssyLayout;
|
|
|
1449
1743
|
exports.fields = fields;
|
|
1450
1744
|
exports.getBuyerCatalogPrices = getBuyerCatalogPrices;
|
|
1451
1745
|
exports.getBuyerPrices = getBuyerPrices;
|
|
1746
|
+
exports.getPublicCatalogPrices = getPublicCatalogPrices;
|
|
1747
|
+
exports.getPublicPrices = getPublicPrices;
|
|
1452
1748
|
exports.graphqlRequest = graphqlRequest;
|
|
1453
1749
|
exports.isFormFieldRequired = isFormFieldRequired;
|
|
1454
1750
|
exports.isFormFieldVisible = isFormFieldVisible;
|
|
@@ -1469,6 +1765,8 @@ exports.orderProgressValues = orderProgressValues;
|
|
|
1469
1765
|
exports.parseEditorMessage = parseEditorMessage;
|
|
1470
1766
|
exports.postToEditor = postToEditor;
|
|
1471
1767
|
exports.priceDisplayModeValues = priceDisplayModeValues;
|
|
1768
|
+
exports.priceListSourceValues = priceListSourceValues;
|
|
1769
|
+
exports.priceWithheldReasonValues = priceWithheldReasonValues;
|
|
1472
1770
|
exports.propsToSchema = propsToSchema;
|
|
1473
1771
|
exports.quantityRuleReasonValues = quantityRuleReasonValues;
|
|
1474
1772
|
exports.quantityRuleViolation = quantityRuleViolation;
|