@cmssy/core 19.15.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 +295 -12
- package/dist/index.d.cts +100 -9
- package/dist/index.d.ts +100 -9
- package/dist/index.js +287 -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 +28 -10
- package/dist/internal.d.cts +7 -6
- package/dist/internal.d.ts +7 -6
- package/dist/internal.js +28 -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 {
|
|
@@ -574,9 +587,14 @@ function createCmssyClient(input) {
|
|
|
574
587
|
// src/data/buyer-prices.ts
|
|
575
588
|
var CMSSY_BUYER_PRICES_MAX_ITEMS = 100;
|
|
576
589
|
var priceDisplayModeValues = ["gross", "net"];
|
|
577
|
-
var
|
|
590
|
+
var priceListSourceValues = ["MEMBER", "COMPANY", "CHANNEL"];
|
|
591
|
+
var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices(
|
|
592
|
+
$workspaceId: ID!
|
|
593
|
+
$items: [PriceQueryItem!]!
|
|
594
|
+
$channel: String
|
|
595
|
+
) {
|
|
578
596
|
account {
|
|
579
|
-
prices(workspaceId: $workspaceId, items: $items) {
|
|
597
|
+
prices(workspaceId: $workspaceId, items: $items, channel: $channel) {
|
|
580
598
|
recordId
|
|
581
599
|
variantKey
|
|
582
600
|
currency
|
|
@@ -585,6 +603,7 @@ var BUYER_PRICES_QUERY = typedOperation(`query BuyerPrices($workspaceId: ID!, $i
|
|
|
585
603
|
listed
|
|
586
604
|
basePrice
|
|
587
605
|
source
|
|
606
|
+
listSource
|
|
588
607
|
minQuantity
|
|
589
608
|
maxQuantity
|
|
590
609
|
increment
|
|
@@ -631,7 +650,8 @@ async function getBuyerPrices(config, items, options) {
|
|
|
631
650
|
workspaceId: options.workspaceId,
|
|
632
651
|
items: items.map(
|
|
633
652
|
({ recordId, variantKey }) => variantKey ? { recordId, variantKey } : { recordId }
|
|
634
|
-
)
|
|
653
|
+
),
|
|
654
|
+
...channelVariable(options.channel)
|
|
635
655
|
},
|
|
636
656
|
{
|
|
637
657
|
public: true,
|
|
@@ -660,6 +680,7 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
660
680
|
$sort: BuyerCatalogSort
|
|
661
681
|
$limit: Int
|
|
662
682
|
$offset: Int
|
|
683
|
+
$channel: String
|
|
663
684
|
) {
|
|
664
685
|
account {
|
|
665
686
|
catalogPrices(
|
|
@@ -675,6 +696,7 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
675
696
|
sort: $sort
|
|
676
697
|
limit: $limit
|
|
677
698
|
offset: $offset
|
|
699
|
+
channel: $channel
|
|
678
700
|
) {
|
|
679
701
|
total
|
|
680
702
|
hasMore
|
|
@@ -687,6 +709,7 @@ var BUYER_CATALOG_PRICES_QUERY = typedOperation(`query BuyerCatalogPrices(
|
|
|
687
709
|
listed
|
|
688
710
|
basePrice
|
|
689
711
|
source
|
|
712
|
+
listSource
|
|
690
713
|
minQuantity
|
|
691
714
|
maxQuantity
|
|
692
715
|
increment
|
|
@@ -720,7 +743,11 @@ async function getBuyerCatalogPrices(config, query, options) {
|
|
|
720
743
|
const data = await graphqlRequest(
|
|
721
744
|
config,
|
|
722
745
|
BUYER_CATALOG_PRICES_QUERY,
|
|
723
|
-
{
|
|
746
|
+
{
|
|
747
|
+
...query,
|
|
748
|
+
workspaceId: options.workspaceId,
|
|
749
|
+
...channelVariable(options.channel)
|
|
750
|
+
},
|
|
724
751
|
{
|
|
725
752
|
public: true,
|
|
726
753
|
fetch: options.fetch,
|
|
@@ -735,6 +762,229 @@ async function getBuyerCatalogPrices(config, query, options) {
|
|
|
735
762
|
);
|
|
736
763
|
return data.account.catalogPrices;
|
|
737
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
|
+
}
|
|
738
988
|
|
|
739
989
|
// src/data/checkout-errors.ts
|
|
740
990
|
var quantityRuleReasonValues = [
|
|
@@ -785,6 +1035,30 @@ function quantityRuleViolation(error) {
|
|
|
785
1035
|
}
|
|
786
1036
|
return void 0;
|
|
787
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
|
+
}
|
|
788
1062
|
|
|
789
1063
|
// src/fields.ts
|
|
790
1064
|
function build(type, opts) {
|
|
@@ -1426,6 +1700,7 @@ exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
|
|
|
1426
1700
|
exports.CMSSY_EDIT_QUERY_PARAM = CMSSY_EDIT_QUERY_PARAM;
|
|
1427
1701
|
exports.CMSSY_EDIT_TOKEN_HEADER = CMSSY_EDIT_TOKEN_HEADER;
|
|
1428
1702
|
exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
1703
|
+
exports.CMSSY_PUBLIC_PRICES_MAX_ITEMS = CMSSY_PUBLIC_PRICES_MAX_ITEMS;
|
|
1429
1704
|
exports.CMSSY_RATE_LIMIT_WINDOW_MS = CMSSY_RATE_LIMIT_WINDOW_MS;
|
|
1430
1705
|
exports.CMSSY_RETRY_MODES = CMSSY_RETRY_MODES;
|
|
1431
1706
|
exports.CMSSY_SECRET_QUERY_PARAM = CMSSY_SECRET_QUERY_PARAM;
|
|
@@ -1435,11 +1710,15 @@ exports.CmssyWebhookError = CmssyWebhookError;
|
|
|
1435
1710
|
exports.DEFAULT_CMSSY_API_URL = DEFAULT_CMSSY_API_URL;
|
|
1436
1711
|
exports.DEFAULT_CMSSY_EDITOR_ORIGINS = DEFAULT_CMSSY_EDITOR_ORIGINS;
|
|
1437
1712
|
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
1713
|
+
exports.PUBLIC_CATALOG_PRICES_QUERY = PUBLIC_CATALOG_PRICES_QUERY;
|
|
1714
|
+
exports.PUBLIC_PRICES_QUERY = PUBLIC_PRICES_QUERY;
|
|
1438
1715
|
exports.SHORTCUT_ACTIONS = SHORTCUT_ACTIONS;
|
|
1439
1716
|
exports.applyCmssyCsp = applyCmssyCsp;
|
|
1440
1717
|
exports.blocksToMeta = blocksToMeta;
|
|
1441
1718
|
exports.blocksToSchemas = blocksToSchemas;
|
|
1442
1719
|
exports.buildBlockManifest = buildBlockManifest;
|
|
1720
|
+
exports.channelRefusal = channelRefusal;
|
|
1721
|
+
exports.channelRefusalReasonValues = channelRefusalReasonValues;
|
|
1443
1722
|
exports.checkoutErrorReason = checkoutErrorReason;
|
|
1444
1723
|
exports.checkoutErrorReasonValues = checkoutErrorReasonValues;
|
|
1445
1724
|
exports.createCmssyClient = createCmssyClient;
|
|
@@ -1449,6 +1728,8 @@ exports.defineCmssyLayout = defineCmssyLayout;
|
|
|
1449
1728
|
exports.fields = fields;
|
|
1450
1729
|
exports.getBuyerCatalogPrices = getBuyerCatalogPrices;
|
|
1451
1730
|
exports.getBuyerPrices = getBuyerPrices;
|
|
1731
|
+
exports.getPublicCatalogPrices = getPublicCatalogPrices;
|
|
1732
|
+
exports.getPublicPrices = getPublicPrices;
|
|
1452
1733
|
exports.graphqlRequest = graphqlRequest;
|
|
1453
1734
|
exports.isFormFieldRequired = isFormFieldRequired;
|
|
1454
1735
|
exports.isFormFieldVisible = isFormFieldVisible;
|
|
@@ -1469,6 +1750,8 @@ exports.orderProgressValues = orderProgressValues;
|
|
|
1469
1750
|
exports.parseEditorMessage = parseEditorMessage;
|
|
1470
1751
|
exports.postToEditor = postToEditor;
|
|
1471
1752
|
exports.priceDisplayModeValues = priceDisplayModeValues;
|
|
1753
|
+
exports.priceListSourceValues = priceListSourceValues;
|
|
1754
|
+
exports.priceWithheldReasonValues = priceWithheldReasonValues;
|
|
1472
1755
|
exports.propsToSchema = propsToSchema;
|
|
1473
1756
|
exports.quantityRuleReasonValues = quantityRuleReasonValues;
|
|
1474
1757
|
exports.quantityRuleViolation = quantityRuleViolation;
|