swell-js 5.9.3 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swell-js",
3
- "version": "5.9.3",
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';
@@ -499,6 +501,15 @@ export interface SwellClient<C extends 'snake' | 'camel' = 'snake'> {
499
501
  setCookie(value: string): void;
500
502
  };
501
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
+
502
513
  functions: {
503
514
  request<T>(
504
515
  method: string,