swell-js 5.9.2 → 5.9.4

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.
@@ -1,5 +1,5 @@
1
1
  export { f as find, P as findIndex, g as get, Q as stringifyQuery, t as toNumber } from '../find.ba551a2e.mjs';
2
- export { o as base64Encode, f as camelCase, c as cloneDeep, d as defaultMethods, q as getLocationParams, k as isEmpty, h as isEqual, j as isFunction, n as isLiveMode, e as isObject, i as isServer, l as loadScript, C as map, m as merge, p as pick, r as reduce, w as removeUrlParams, s as set, g as snakeCase, t as toCamel, a as toCamelPath, B as toLower, b as toSnake, A as trimBoth, x as trimEnd, z as trimStart, u as uniq, v as vaultRequest } from '../index.3949a230.mjs';
2
+ export { o as base64Encode, f as camelCase, c as cloneDeep, d as defaultMethods, q as getLocationParams, k as isEmpty, h as isEqual, j as isFunction, n as isLiveMode, e as isObject, i as isServer, l as loadScript, C as map, m as merge, p as pick, r as reduce, w as removeUrlParams, s as set, g as snakeCase, t as toCamel, a as toCamelPath, B as toLower, b as toSnake, A as trimBoth, x as trimEnd, z as trimStart, u as uniq, v as vaultRequest } from '../index.76eb52e5.mjs';
3
3
  export { r as round } from '../round.c68b8be5.mjs';
4
4
  import 'deepmerge';
5
5
  import 'fast-case';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swell-js",
3
- "version": "5.9.2",
3
+ "version": "5.9.4",
4
4
  "description": "Swell JS library for client-side stores",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -0,0 +1,17 @@
1
+ import type { ConvertSnakeToCamelCase } from '../index.js';
2
+ import type { Replace } from '../utils.js';
3
+
4
+ import type { Consent, ConsentEffective, ConsentInput } from './snake.js';
5
+
6
+ export type ConsentInputCamel = ConvertSnakeToCamelCase<ConsentInput>;
7
+
8
+ export type ConsentEffectiveCamel = ConvertSnakeToCamelCase<ConsentEffective>;
9
+
10
+ export type ConsentCamel = ConvertSnakeToCamelCase<
11
+ Replace<
12
+ Consent,
13
+ {
14
+ effective: ConsentEffectiveCamel;
15
+ }
16
+ >
17
+ >;
@@ -0,0 +1,21 @@
1
+ import type { MakeCase } from '../utils.js';
2
+
3
+ import type { Consent, ConsentEffective, ConsentInput } from './snake.js';
4
+ import type {
5
+ ConsentCamel,
6
+ ConsentEffectiveCamel,
7
+ ConsentInputCamel,
8
+ } from './camel.js';
9
+
10
+ export type ConsentCase = MakeCase<Consent, ConsentCamel>;
11
+
12
+ export type ConsentInputCase = MakeCase<ConsentInput, ConsentInputCamel>;
13
+
14
+ export type {
15
+ Consent,
16
+ ConsentEffective,
17
+ ConsentInput,
18
+ ConsentCamel,
19
+ ConsentEffectiveCamel,
20
+ ConsentInputCamel,
21
+ };
@@ -0,0 +1,22 @@
1
+ /** The shopper's answers; purposes left out stay as they are */
2
+ export interface ConsentInput {
3
+ analytics?: boolean;
4
+ marketing?: boolean;
5
+ sale_of_data?: boolean;
6
+ }
7
+
8
+ /** What the answers allow, after the region's rule and GPC */
9
+ export interface ConsentEffective {
10
+ analytics: boolean;
11
+ marketing: boolean;
12
+ sale_of_data: boolean;
13
+ }
14
+
15
+ export interface Consent {
16
+ analytics: boolean | null;
17
+ marketing: boolean | null;
18
+ sale_of_data: boolean | null;
19
+ gpc: boolean;
20
+ rule: 'opt_in' | 'opt_out' | null;
21
+ effective: ConsentEffective;
22
+ }
package/types/index.d.cts CHANGED
@@ -82,6 +82,14 @@ declare namespace swell {
82
82
  export type CategoryCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).CategoryCase;
83
83
  export type Category = import('./index.js', { with: { 'resolution-mode': 'import' } }).Category;
84
84
  export type CategoryCamel = import('./index.js', { with: { 'resolution-mode': 'import' } }).CategoryCamel;
85
+ export type ConsentCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentCase;
86
+ export type ConsentInputCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentInputCase;
87
+ export type Consent = import('./index.js', { with: { 'resolution-mode': 'import' } }).Consent;
88
+ export type ConsentEffective = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentEffective;
89
+ export type ConsentInput = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentInput;
90
+ export type ConsentCamel = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentCamel;
91
+ export type ConsentEffectiveCamel = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentEffectiveCamel;
92
+ export type ConsentInputCamel = import('./index.js', { with: { 'resolution-mode': 'import' } }).ConsentInputCamel;
85
93
  export type ContentCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).ContentCase;
86
94
  export type ContentSectionCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).ContentSectionCase;
87
95
  export type ContentPageCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).ContentPageCase;
package/types/index.d.ts CHANGED
@@ -17,6 +17,7 @@ import type {
17
17
  } from './card/index.js';
18
18
  import type { CartCase, CartItemCase } from './cart/index.js';
19
19
  import type { CategoryCase } from './category/index.js';
20
+ import type { ConsentCase, ConsentInputCase } from './consent/index.js';
20
21
  import type { ContentCase } from './content/index.js';
21
22
  import type {
22
23
  SelectCurrencyReturnCase,
@@ -53,6 +54,7 @@ export type * from './billing/index.js';
53
54
  export type * from './card/index.js';
54
55
  export type * from './cart/index.js';
55
56
  export type * from './category/index.js';
57
+ export type * from './consent/index.js';
56
58
  export type * from './content/index.js';
57
59
  export type * from './coupon/index.js';
58
60
  export type * from './currency/index.js';
@@ -127,6 +129,13 @@ export interface InitOptions<C extends 'snake' | 'camel' = 'snake'> {
127
129
  * and payment integrations such as Google Pay and Apple Pay.
128
130
  */
129
131
  updateCart?: (input: object) => Promise<CartCase[C] | null>;
132
+ /**
133
+ * Returns a captcha token to attach to create-intent requests. The host
134
+ * owns the captcha widget and the token's lifecycle; swell-js only forwards
135
+ * the resolved token. Reject (or throw) to abort the intent, e.g. when the
136
+ * challenge times out or fails.
137
+ */
138
+ getCaptchaToken?: () => Promise<string | null | undefined>;
130
139
  }
131
140
 
132
141
  export interface InitOptionsCamel extends InitOptions<'camel'> {
@@ -492,6 +501,15 @@ export interface SwellClient<C extends 'snake' | 'camel' = 'snake'> {
492
501
  setCookie(value: string): void;
493
502
  };
494
503
 
504
+ consent: {
505
+ /**
506
+ * Records the shopper's consent for attribution. Call it from the
507
+ * storefront's consent banner; purposes left out stay as they are.
508
+ * Browser only: it calls the storefront's own origin.
509
+ */
510
+ set(consent?: ConsentInputCase[C]): Promise<ConsentCase[C]>;
511
+ };
512
+
495
513
  functions: {
496
514
  request<T>(
497
515
  method: string,