commerce-sdk-isomorphic 3.2.0 → 3.3.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.
@@ -49,6 +49,22 @@ interface PathParameters {
49
49
  interface QueryParameters {
50
50
  [key: string]: string | number | boolean | string[] | number[];
51
51
  }
52
+ /**
53
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
54
+ * types for query parameters for the value.
55
+ */
56
+ type CustomQueryParameters = {
57
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
58
+ };
59
+ /**
60
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
61
+ * types for the value.
62
+ */
63
+ type CustomRequestBody = {
64
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
65
+ [key: string]: unknown;
66
+ };
67
+ };
52
68
  /**
53
69
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
54
70
  * it from the `RequestInit` provided by node-fetch.
@@ -4194,6 +4210,22 @@ declare namespace ShopperBasketsTypes {
4194
4210
  * Generic interface for all parameter types.
4195
4211
  */
4196
4212
  type UrlParameters = PathParameters | QueryParameters;
4213
+ /**
4214
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
4215
+ * types for query parameters for the value.
4216
+ */
4217
+ type CustomQueryParameters = {
4218
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
4219
+ };
4220
+ /**
4221
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
4222
+ * types for the value.
4223
+ */
4224
+ type CustomRequestBody = {
4225
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
4226
+ [key: string]: unknown;
4227
+ };
4228
+ };
4197
4229
  /**
4198
4230
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
4199
4231
  * it from the `RequestInit` provided by node-fetch.
@@ -9069,6 +9101,22 @@ declare namespace ShopperContextsTypes {
9069
9101
  * Generic interface for all parameter types.
9070
9102
  */
9071
9103
  type UrlParameters = PathParameters | QueryParameters;
9104
+ /**
9105
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
9106
+ * types for query parameters for the value.
9107
+ */
9108
+ type CustomQueryParameters = {
9109
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
9110
+ };
9111
+ /**
9112
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
9113
+ * types for the value.
9114
+ */
9115
+ type CustomRequestBody = {
9116
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
9117
+ [key: string]: unknown;
9118
+ };
9119
+ };
9072
9120
  /**
9073
9121
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
9074
9122
  * it from the `RequestInit` provided by node-fetch.
@@ -12981,6 +13029,22 @@ declare namespace ShopperCustomersTypes {
12981
13029
  * Generic interface for all parameter types.
12982
13030
  */
12983
13031
  type UrlParameters = PathParameters | QueryParameters;
13032
+ /**
13033
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
13034
+ * types for query parameters for the value.
13035
+ */
13036
+ type CustomQueryParameters = {
13037
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
13038
+ };
13039
+ /**
13040
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
13041
+ * types for the value.
13042
+ */
13043
+ type CustomRequestBody = {
13044
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
13045
+ [key: string]: unknown;
13046
+ };
13047
+ };
12984
13048
  /**
12985
13049
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
12986
13050
  * it from the `RequestInit` provided by node-fetch.
@@ -16787,6 +16851,22 @@ declare namespace ShopperDiscoverySearchTypes {
16787
16851
  * Generic interface for all parameter types.
16788
16852
  */
16789
16853
  type UrlParameters = PathParameters | QueryParameters;
16854
+ /**
16855
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
16856
+ * types for query parameters for the value.
16857
+ */
16858
+ type CustomQueryParameters = {
16859
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
16860
+ };
16861
+ /**
16862
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
16863
+ * types for the value.
16864
+ */
16865
+ type CustomRequestBody = {
16866
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
16867
+ [key: string]: unknown;
16868
+ };
16869
+ };
16790
16870
  /**
16791
16871
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
16792
16872
  * it from the `RequestInit` provided by node-fetch.
@@ -17915,6 +17995,22 @@ declare namespace ShopperExperienceTypes {
17915
17995
  * Generic interface for all parameter types.
17916
17996
  */
17917
17997
  type UrlParameters = PathParameters | QueryParameters;
17998
+ /**
17999
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
18000
+ * types for query parameters for the value.
18001
+ */
18002
+ type CustomQueryParameters = {
18003
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
18004
+ };
18005
+ /**
18006
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
18007
+ * types for the value.
18008
+ */
18009
+ type CustomRequestBody = {
18010
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
18011
+ [key: string]: unknown;
18012
+ };
18013
+ };
17918
18014
  /**
17919
18015
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
17920
18016
  * it from the `RequestInit` provided by node-fetch.
@@ -18823,6 +18919,22 @@ declare namespace ShopperGiftCertificatesTypes {
18823
18919
  * Generic interface for all parameter types.
18824
18920
  */
18825
18921
  type UrlParameters = PathParameters | QueryParameters;
18922
+ /**
18923
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
18924
+ * types for query parameters for the value.
18925
+ */
18926
+ type CustomQueryParameters = {
18927
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
18928
+ };
18929
+ /**
18930
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
18931
+ * types for the value.
18932
+ */
18933
+ type CustomRequestBody = {
18934
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
18935
+ [key: string]: unknown;
18936
+ };
18937
+ };
18826
18938
  /**
18827
18939
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
18828
18940
  * it from the `RequestInit` provided by node-fetch.
@@ -20582,6 +20694,22 @@ declare namespace ShopperOrdersTypes {
20582
20694
  * Generic interface for all parameter types.
20583
20695
  */
20584
20696
  type UrlParameters = PathParameters | QueryParameters;
20697
+ /**
20698
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
20699
+ * types for query parameters for the value.
20700
+ */
20701
+ type CustomQueryParameters = {
20702
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
20703
+ };
20704
+ /**
20705
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
20706
+ * types for the value.
20707
+ */
20708
+ type CustomRequestBody = {
20709
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
20710
+ [key: string]: unknown;
20711
+ };
20712
+ };
20585
20713
  /**
20586
20714
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
20587
20715
  * it from the `RequestInit` provided by node-fetch.
@@ -22917,6 +23045,22 @@ declare namespace ShopperProductsTypes {
22917
23045
  * Generic interface for all parameter types.
22918
23046
  */
22919
23047
  type UrlParameters = PathParameters | QueryParameters;
23048
+ /**
23049
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
23050
+ * types for query parameters for the value.
23051
+ */
23052
+ type CustomQueryParameters = {
23053
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
23054
+ };
23055
+ /**
23056
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
23057
+ * types for the value.
23058
+ */
23059
+ type CustomRequestBody = {
23060
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
23061
+ [key: string]: unknown;
23062
+ };
23063
+ };
22920
23064
  /**
22921
23065
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
22922
23066
  * it from the `RequestInit` provided by node-fetch.
@@ -24280,6 +24424,22 @@ declare namespace ShopperPromotionsTypes {
24280
24424
  * Generic interface for all parameter types.
24281
24425
  */
24282
24426
  type UrlParameters = PathParameters | QueryParameters;
24427
+ /**
24428
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
24429
+ * types for query parameters for the value.
24430
+ */
24431
+ type CustomQueryParameters = {
24432
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
24433
+ };
24434
+ /**
24435
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
24436
+ * types for the value.
24437
+ */
24438
+ type CustomRequestBody = {
24439
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
24440
+ [key: string]: unknown;
24441
+ };
24442
+ };
24283
24443
  /**
24284
24444
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
24285
24445
  * it from the `RequestInit` provided by node-fetch.
@@ -25503,6 +25663,22 @@ declare namespace ShopperSearchTypes {
25503
25663
  * Generic interface for all parameter types.
25504
25664
  */
25505
25665
  type UrlParameters = PathParameters | QueryParameters;
25666
+ /**
25667
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
25668
+ * types for query parameters for the value.
25669
+ */
25670
+ type CustomQueryParameters = {
25671
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
25672
+ };
25673
+ /**
25674
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
25675
+ * types for the value.
25676
+ */
25677
+ type CustomRequestBody = {
25678
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
25679
+ [key: string]: unknown;
25680
+ };
25681
+ };
25506
25682
  /**
25507
25683
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
25508
25684
  * it from the `RequestInit` provided by node-fetch.
@@ -26650,6 +26826,22 @@ declare namespace ShopperSeoTypes {
26650
26826
  * Generic interface for all parameter types.
26651
26827
  */
26652
26828
  type UrlParameters = PathParameters | QueryParameters;
26829
+ /**
26830
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
26831
+ * types for query parameters for the value.
26832
+ */
26833
+ type CustomQueryParameters = {
26834
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
26835
+ };
26836
+ /**
26837
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
26838
+ * types for the value.
26839
+ */
26840
+ type CustomRequestBody = {
26841
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
26842
+ [key: string]: unknown;
26843
+ };
26844
+ };
26653
26845
  /**
26654
26846
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
26655
26847
  * it from the `RequestInit` provided by node-fetch.
@@ -27591,6 +27783,22 @@ declare namespace ShopperStoresTypes {
27591
27783
  * Generic interface for all parameter types.
27592
27784
  */
27593
27785
  type UrlParameters = PathParameters | QueryParameters;
27786
+ /**
27787
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
27788
+ * types for query parameters for the value.
27789
+ */
27790
+ type CustomQueryParameters = {
27791
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
27792
+ };
27793
+ /**
27794
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
27795
+ * types for the value.
27796
+ */
27797
+ type CustomRequestBody = {
27798
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
27799
+ [key: string]: unknown;
27800
+ };
27801
+ };
27594
27802
  /**
27595
27803
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
27596
27804
  * it from the `RequestInit` provided by node-fetch.
@@ -29821,6 +30029,22 @@ declare namespace ShopperLoginTypes {
29821
30029
  * Generic interface for all parameter types.
29822
30030
  */
29823
30031
  type UrlParameters = PathParameters | QueryParameters;
30032
+ /**
30033
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
30034
+ * types for query parameters for the value.
30035
+ */
30036
+ type CustomQueryParameters = {
30037
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
30038
+ };
30039
+ /**
30040
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
30041
+ * types for the value.
30042
+ */
30043
+ type CustomRequestBody = {
30044
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
30045
+ [key: string]: unknown;
30046
+ };
30047
+ };
29824
30048
  /**
29825
30049
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
29826
30050
  * it from the `RequestInit` provided by node-fetch.
@@ -31680,6 +31904,22 @@ declare namespace helpers {
31680
31904
  * Generic interface for all parameter types.
31681
31905
  */
31682
31906
  type UrlParameters = PathParameters | QueryParameters;
31907
+ /**
31908
+ * Custom query parameter type with any string prefixed with `c_` as the key and the allowed
31909
+ * types for query parameters for the value.
31910
+ */
31911
+ type CustomQueryParameters = {
31912
+ [key in `c_${string}`]: string | number | boolean | string[] | number[];
31913
+ };
31914
+ /**
31915
+ * Custom body request type with any string prefixed with `c_` as the key and the allowed
31916
+ * types for the value.
31917
+ */
31918
+ type CustomRequestBody = {
31919
+ [key in `c_${string}`]: string | number | boolean | string[] | number[] | {
31920
+ [key: string]: unknown;
31921
+ };
31922
+ };
31683
31923
  /**
31684
31924
  * Alias for `RequestInit` from TypeScript's DOM lib, to more clearly differentiate
31685
31925
  * it from the `RequestInit` provided by node-fetch.
@@ -33492,10 +33732,11 @@ declare namespace helpers {
33492
33732
  * Wrapper for the authorization endpoint. For federated login (3rd party IDP non-guest), the caller should redirect the user to the url in the url field of the returned object. The url will be the login page for the 3rd party IDP and the user will be sent to the redirectURI on success. Guest sessions return the code and usid directly with no need to redirect.
33493
33733
  * @param slasClient a configured instance of the ShopperLogin SDK client
33494
33734
  * @param codeVerifier - random string created by client app to use as a secret in the request
33495
- * @param parameters - Request parameters used by the `authorizeCustomer` endpoint.
33735
+ * @param parameters - Request parameters used by the `authorizeCustomer` endpoint. Custom parameters can be passed on by adding a property on the `parameters` object starting with `c_`
33496
33736
  * @param parameters.redirectURI - the location the client will be returned to after successful login with 3rd party IDP. Must be registered in SLAS.
33497
33737
  * @param parameters.hint? - optional string to hint at a particular IDP. Guest sessions are created by setting this to 'guest'
33498
33738
  * @param parameters.usid? - optional saved SLAS user id to link the new session to a previous session
33739
+ * @param privateClient? - flag to indicate if the client is private or not. Defaults to false.
33499
33740
  * @returns login url, user id and authorization code if available
33500
33741
  */
33501
33742
  function authorize(slasClient: ShopperLogin<{
@@ -33507,7 +33748,7 @@ declare namespace helpers {
33507
33748
  redirectURI: string;
33508
33749
  hint?: string;
33509
33750
  usid?: string;
33510
- }, privateClient?: boolean): Promise<{
33751
+ } & CustomQueryParameters, privateClient?: boolean): Promise<{
33511
33752
  code: string;
33512
33753
  url: string;
33513
33754
  usid: string;
@@ -33515,7 +33756,7 @@ declare namespace helpers {
33515
33756
  /**
33516
33757
  * Function to return the URL of the authorization endpoint. The url will redirect to the login page for the 3rd party IDP and the user will be sent to the redirectURI on success. Guest sessions return the code and usid directly with no need to redirect.
33517
33758
  * @param slasClient a configured instance of the ShopperLogin SDK client
33518
- * @param parameters - Request parameters used by the `authorizeCustomer` endpoint.
33759
+ * @param parameters - Request parameters used by the `authorizeCustomer` endpoint. Custom parameters can be passed on by adding a property on the `parameters` object starting with `c_`
33519
33760
  * @param parameters.redirectURI - the location the client will be returned to after successful login with 3rd party IDP. Must be registered in SLAS.
33520
33761
  * @param parameters.hint - string to hint at a particular IDP. Required for 3rd party IDP login.
33521
33762
  * @param parameters.usid? - optional saved SLAS user id to link the new session to a previous session
@@ -33532,7 +33773,7 @@ declare namespace helpers {
33532
33773
  redirectURI: string;
33533
33774
  hint: string;
33534
33775
  usid?: string;
33535
- }, privateClient?: boolean): Promise<{
33776
+ } & CustomQueryParameters, privateClient?: boolean): Promise<{
33536
33777
  url: string;
33537
33778
  codeVerifier: string;
33538
33779
  }>;
@@ -33588,7 +33829,7 @@ declare namespace helpers {
33588
33829
  /**
33589
33830
  * A single function to execute the ShopperLogin Public Client Guest Login with proof key for code exchange flow as described in the [API documentation](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=shopper-login:Summary).
33590
33831
  * @param slasClient a configured instance of the ShopperLogin SDK client.
33591
- * @param parameters - parameters to pass in the API calls.
33832
+ * @param parameters - parameters to pass in the API calls. Custom parameters can be passed on by adding a property on the `parameters` object starting with `c_`, and they will be passed on the `authorizeCustomer` call.
33592
33833
  * @param parameters.redirectURI - Per OAuth standard, a valid app route. Must be listed in your SLAS configuration. On server, this will not be actually called. On browser, this will be called, but ignored.
33593
33834
  * @param parameters.usid? - Unique Shopper Identifier to enable personalization.
33594
33835
  * @param parameters.dnt? - Optional parameter to enable Do Not Track (DNT) for the user.
@@ -33603,7 +33844,7 @@ declare namespace helpers {
33603
33844
  redirectURI: string;
33604
33845
  usid?: string;
33605
33846
  dnt?: boolean;
33606
- }): Promise<TokenResponse>;
33847
+ } & CustomQueryParameters): Promise<TokenResponse>;
33607
33848
  /**
33608
33849
  * A single function to execute the ShopperLogin Public Client Registered User B2C Login with proof key for code exchange flow as described in the [API documentation](https://developer.salesforce.com/docs/commerce/commerce-api/references?meta=shopper-login:Summary).
33609
33850
  * **Note**: this func can run on client side. Only use private slas when the slas client secret is secured.
@@ -33616,6 +33857,8 @@ declare namespace helpers {
33616
33857
  * @param parameters.redirectURI - Per OAuth standard, a valid app route. Must be listed in your SLAS configuration. On server, this will not be actually called. On browser, this will be called, but ignored.
33617
33858
  * @param parameters.usid? - Unique Shopper Identifier to enable personalization.
33618
33859
  * @param parameters.dnt? - Optional parameter to enable Do Not Track (DNT) for the user.
33860
+ * @para options? - options to pass in the ShopperLogin 'authenticateCustomer' method
33861
+ * @param options.body - optional body parameters to pass in the ShopperLogin 'authenticateCustomer' method.
33619
33862
  * @returns TokenResponse
33620
33863
  */
33621
33864
  function loginRegisteredUserB2C(slasClient: ShopperLogin<{
@@ -33631,6 +33874,8 @@ declare namespace helpers {
33631
33874
  redirectURI: string;
33632
33875
  usid?: string;
33633
33876
  dnt?: boolean;
33877
+ }, options?: {
33878
+ body?: CustomRequestBody;
33634
33879
  }): Promise<TokenResponse>;
33635
33880
  /* Function to send passwordless login token
33636
33881
  * **Note** At the moment, passwordless is only supported on private client
@@ -33795,6 +34040,13 @@ declare namespace helpers {
33795
34040
  }) | undefined;
33796
34041
  body?: BodyInit | globalThis.BodyInit | unknown;
33797
34042
  } | undefined, clientConfig?: ClientConfigInit<Params> | undefined, rawResponse?: boolean | undefined) => Promise<Response | unknown>;
34043
+ /**
34044
+ * Single encodes SCAPI specific special characters (percentage sign `%` and comma `,`) in the given string in UTF-8
34045
+ * Does not encode any other special characters in the string
34046
+ * @param str - The string to encode
34047
+ * @returns The encoded string
34048
+ */
34049
+ const encodeSCAPISpecialCharacters: (str: string) => string;
33798
34050
  }
33799
34051
  export { ShopperBaskets, ShopperContexts, ShopperCustomers, ShopperDiscoverySearch, ShopperExperience, ShopperGiftCertificates, ShopperOrders, ShopperProducts, ShopperPromotions, ShopperSearch, ShopperSeo, ShopperStores, ShopperLogin, ClientConfig, TemplateURL, helpers };
33800
34052
  export type { ShopperBasketsTypes, ShopperContextsTypes, ShopperCustomersTypes, ShopperDiscoverySearchTypes, ShopperExperienceTypes, ShopperGiftCertificatesTypes, ShopperOrdersTypes, ShopperProductsTypes, ShopperPromotionsTypes, ShopperSearchTypes, ShopperSeoTypes, ShopperStoresTypes, ShopperLoginTypes, ClientConfigInit };