@dutchiesdk/ecommerce-extensions-sdk 0.10.1 → 0.12.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.
@@ -1,14 +1,5 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
3
  (()=>{
13
4
  __webpack_require__.d = (exports1, definition)=>{
14
5
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
@@ -38,7 +29,6 @@ __webpack_require__.d(__webpack_exports__, {
38
29
  });
39
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
40
31
  const external_react_namespaceObject = require("react");
41
- var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
42
32
  const ecommerce_data_bridge_cjs_namespaceObject = require("../context/ecommerce-data-bridge.cjs");
43
33
  const withRemoteBoundary = (WrappedComponent)=>{
44
34
  function WithRemoteBoundaryComponent({ data }) {
@@ -52,7 +42,7 @@ const withRemoteBoundary = (WrappedComponent)=>{
52
42
  };
53
43
  function createLazyRemoteBoundaryComponent(importFn, options = {}) {
54
44
  const { fallback, onError } = options;
55
- const LazyComponent = /*#__PURE__*/ external_react_default().lazy(async ()=>{
45
+ const LazyComponent = /*#__PURE__*/ (0, external_react_namespaceObject.lazy)(async ()=>{
56
46
  try {
57
47
  const module = await importFn();
58
48
  const WrappedComponent = withRemoteBoundary(module.default);
@@ -1,18 +1,18 @@
1
- import React from 'react';
2
- import type { RemoteBoundaryComponent, RemoteModuleRegistry } from '../types/ecommerce-extension';
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import type { RemoteBoundaryComponent } from '../types/ecommerce-extension';
3
3
  import type { CommerceComponentsDataInterface } from '../types/interface';
4
- export type { RemoteBoundaryComponent, RemoteModuleRegistry };
5
4
  type WithRemoteBoundaryProps = {
6
5
  data?: CommerceComponentsDataInterface;
7
6
  };
8
- export declare const withRemoteBoundary: (WrappedComponent: React.ComponentType) => {
7
+ export declare const withRemoteBoundary: (WrappedComponent: ComponentType) => {
9
8
  ({ data }: WithRemoteBoundaryProps): import("react/jsx-runtime").JSX.Element;
10
9
  DataBridgeVersion: string;
11
10
  };
12
11
  interface LazyRemoteBoundaryOptions {
13
- fallback?: React.ReactNode;
12
+ fallback?: ReactNode;
14
13
  onError?: (error: Error) => void;
15
14
  }
16
15
  export declare function createLazyRemoteBoundaryComponent<P extends WithRemoteBoundaryProps = WithRemoteBoundaryProps>(importFn: () => Promise<{
17
- default: React.ComponentType;
16
+ default: ComponentType;
18
17
  }>, options?: LazyRemoteBoundaryOptions): RemoteBoundaryComponent<P>;
18
+ export {};
@@ -30,19 +30,20 @@ __webpack_require__.d(__webpack_exports__, {
30
30
  useDataBridge: ()=>useDataBridge
31
31
  });
32
32
  const external_react_namespaceObject = require("react");
33
- const DataBridgeVersion = '0.10.1';
33
+ const DataBridgeVersion = '0.12.0';
34
34
  const DataBridgeContext = (0, external_react_namespaceObject.createContext)(void 0);
35
35
  const useDataBridge = ()=>{
36
36
  const context = (0, external_react_namespaceObject.useContext)(DataBridgeContext);
37
37
  if (void 0 === context) throw new Error('useDataBridge must be used within a DataBridgeProvider');
38
38
  return context;
39
39
  };
40
- const useAsyncLoader = (fn)=>{
40
+ const useAsyncLoader = (fn, params)=>{
41
41
  const [data, setData] = (0, external_react_namespaceObject.useState)(null);
42
42
  (0, external_react_namespaceObject.useEffect)(()=>{
43
- fn().then(setData);
43
+ fn(params).then(setData);
44
44
  }, [
45
- fn
45
+ fn,
46
+ params
46
47
  ]);
47
48
  return {
48
49
  data,
@@ -23,9 +23,10 @@ export declare const useDataBridge: () => CommerceComponentsDataInterface;
23
23
  * A hook to load data asynchronously.
24
24
  *
25
25
  * @param fn - The function to load the data.
26
+ * @param params - Optional parameters to pass to the function.
26
27
  * @returns The data and a boolean indicating if the data is loading.
27
28
  */
28
- export declare const useAsyncLoader: <S>(fn: () => Promise<S>) => {
29
+ export declare const useAsyncLoader: <S, P = void>(fn: (params: P) => Promise<S>, params?: P) => {
29
30
  data: S | null;
30
31
  isLoading: boolean;
31
32
  };
@@ -1,18 +1,18 @@
1
- import React from 'react';
2
- import type { RemoteBoundaryComponent, RemoteModuleRegistry } from '../types/ecommerce-extension';
1
+ import { type ComponentType, type ReactNode } from 'react';
2
+ import type { RemoteBoundaryComponent } from '../types/ecommerce-extension';
3
3
  import type { CommerceComponentsDataInterface } from '../types/interface';
4
- export type { RemoteBoundaryComponent, RemoteModuleRegistry };
5
4
  type WithRemoteBoundaryProps = {
6
5
  data?: CommerceComponentsDataInterface;
7
6
  };
8
- export declare const withRemoteBoundary: (WrappedComponent: React.ComponentType) => {
7
+ export declare const withRemoteBoundary: (WrappedComponent: ComponentType) => {
9
8
  ({ data }: WithRemoteBoundaryProps): import("react/jsx-runtime").JSX.Element;
10
9
  DataBridgeVersion: string;
11
10
  };
12
11
  interface LazyRemoteBoundaryOptions {
13
- fallback?: React.ReactNode;
12
+ fallback?: ReactNode;
14
13
  onError?: (error: Error) => void;
15
14
  }
16
15
  export declare function createLazyRemoteBoundaryComponent<P extends WithRemoteBoundaryProps = WithRemoteBoundaryProps>(importFn: () => Promise<{
17
- default: React.ComponentType;
16
+ default: ComponentType;
18
17
  }>, options?: LazyRemoteBoundaryOptions): RemoteBoundaryComponent<P>;
18
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import external_react_default, { Suspense } from "react";
2
+ import { Suspense, lazy } from "react";
3
3
  import { DataBridgeContext, DataBridgeVersion } from "../context/ecommerce-data-bridge.js";
4
4
  const withRemoteBoundary = (WrappedComponent)=>{
5
5
  function WithRemoteBoundaryComponent({ data }) {
@@ -13,7 +13,7 @@ const withRemoteBoundary = (WrappedComponent)=>{
13
13
  };
14
14
  function createLazyRemoteBoundaryComponent(importFn, options = {}) {
15
15
  const { fallback, onError } = options;
16
- const LazyComponent = /*#__PURE__*/ external_react_default.lazy(async ()=>{
16
+ const LazyComponent = /*#__PURE__*/ lazy(async ()=>{
17
17
  try {
18
18
  const module = await importFn();
19
19
  const WrappedComponent = withRemoteBoundary(module.default);
@@ -23,9 +23,10 @@ export declare const useDataBridge: () => CommerceComponentsDataInterface;
23
23
  * A hook to load data asynchronously.
24
24
  *
25
25
  * @param fn - The function to load the data.
26
+ * @param params - Optional parameters to pass to the function.
26
27
  * @returns The data and a boolean indicating if the data is loading.
27
28
  */
28
- export declare const useAsyncLoader: <S>(fn: () => Promise<S>) => {
29
+ export declare const useAsyncLoader: <S, P = void>(fn: (params: P) => Promise<S>, params?: P) => {
29
30
  data: S | null;
30
31
  isLoading: boolean;
31
32
  };
@@ -1,17 +1,18 @@
1
1
  import { createContext, useContext, useEffect, useState } from "react";
2
- const DataBridgeVersion = '0.10.1';
2
+ const DataBridgeVersion = '0.12.0';
3
3
  const DataBridgeContext = createContext(void 0);
4
4
  const useDataBridge = ()=>{
5
5
  const context = useContext(DataBridgeContext);
6
6
  if (void 0 === context) throw new Error('useDataBridge must be used within a DataBridgeProvider');
7
7
  return context;
8
8
  };
9
- const useAsyncLoader = (fn)=>{
9
+ const useAsyncLoader = (fn, params)=>{
10
10
  const [data, setData] = useState(null);
11
11
  useEffect(()=>{
12
- fn().then(setData);
12
+ fn(params).then(setData);
13
13
  }, [
14
- fn
14
+ fn,
15
+ params
15
16
  ]);
16
17
  return {
17
18
  data,
@@ -1,18 +1,26 @@
1
1
  import type { CartItem } from './data';
2
+ type QueryParameter = string;
3
+ type AdditionalRoutableParameters = {
4
+ query?: QueryParameter;
5
+ };
6
+ type GoToIdOrCnameParameters = {
7
+ cname?: string;
8
+ id?: string;
9
+ } & AdditionalRoutableParameters;
2
10
  type AuthenticationActions = {
3
11
  /**
4
12
  * Navigate to login
5
13
  */
6
14
  goToLogin: () => void;
15
+ /**
16
+ * Navigate to loyalty. Redirects to the homepage if the user is not logged in.
17
+ */
18
+ goToLoyalty: () => void;
7
19
  /**
8
20
  * Navigate to registration
9
21
  */
10
22
  goToRegister: () => void;
11
23
  };
12
- type GoToIdOrCnameParameters = {
13
- cname?: string;
14
- id?: string;
15
- };
16
24
  type CartActions = {
17
25
  /**
18
26
  * Add product to cart
@@ -29,7 +37,7 @@ type CartActions = {
29
37
  /**
30
38
  * Navigate to checkout
31
39
  */
32
- goToCheckout: () => void;
40
+ goToCheckout: (params?: AdditionalRoutableParameters) => void;
33
41
  /**
34
42
  * Remove product from cart
35
43
  */
@@ -54,16 +62,17 @@ type ComponentActions = {
54
62
  /**
55
63
  * Navigate to search
56
64
  * @param query - The search query
65
+ * @param params - Additional params
57
66
  */
58
- goToSearch: (query?: string) => void;
67
+ goToSearch: (query?: string, params?: AdditionalRoutableParameters) => void;
59
68
  /**
60
69
  * Navigate to store browser
61
70
  */
62
- goToStoreBrowser: () => void;
71
+ goToStoreBrowser: (params?: AdditionalRoutableParameters) => void;
63
72
  /**
64
73
  * Navigate to store locator
65
74
  */
66
- goToStoreLocator: () => void;
75
+ goToStoreLocator: (params?: AdditionalRoutableParameters) => void;
67
76
  };
68
77
  type DetailPageActions = {
69
78
  /**
@@ -87,7 +96,7 @@ type ListPageActions = {
87
96
  /**
88
97
  * Navigate to brand list
89
98
  */
90
- goToBrandList: () => void;
99
+ goToBrandList: (params?: AdditionalRoutableParameters) => void;
91
100
  /**
92
101
  * Navigate to product list
93
102
  * @param brandCname - The brand CNAME
@@ -96,34 +105,31 @@ type ListPageActions = {
96
105
  * @param categoryId - The category ID
97
106
  * @param collectionCname - The collection CNAME
98
107
  * @param collectionId - The collection ID
108
+ * @param query - The query param to append
99
109
  */
100
- goToProductList: ({ brandCname, brandId, categoryCname, categoryId, collectionCname, collectionId, }: {
110
+ goToProductList: ({ brandCname, brandId, categoryCname, categoryId, collectionCname, collectionId, query, }: {
101
111
  brandCname?: string;
102
112
  brandId?: string;
103
113
  categoryCname?: string;
104
114
  categoryId?: string;
105
115
  collectionCname?: string;
106
116
  collectionId?: string;
117
+ query?: QueryParameter;
107
118
  }) => void;
108
119
  };
109
120
  type NavigationActions = {
110
121
  /**
111
122
  * Navigate to store info
112
123
  */
113
- goToInfoPage: () => void;
124
+ goToInfoPage: (params?: AdditionalRoutableParameters) => void;
114
125
  /**
115
- * Navigate to specific store
116
- * @param cname - The store CNAME
117
- * @param id - The store ID
126
+ * Navigate to specific store. Only one parameter is required.
118
127
  */
119
- goToStore: ({ cname, id }: {
120
- cname?: string;
121
- id?: string;
122
- }) => void;
128
+ goToStore: (params: GoToIdOrCnameParameters) => void;
123
129
  /**
124
130
  * Navigate to store front
125
131
  */
126
- goToStoreFront: () => void;
132
+ goToStoreFront: (params?: AdditionalRoutableParameters) => void;
127
133
  };
128
134
  export type Actions = AuthenticationActions & CartActions & ComponentActions & DetailPageActions & ListPageActions & NavigationActions;
129
135
  export {};
@@ -51,10 +51,12 @@ export type Dispensary = {
51
51
  website: string;
52
52
  storeFrontRoot: string;
53
53
  };
54
+ medDispensary: boolean;
54
55
  name: string;
55
56
  orderTypes: DispensaryOrderTypes;
56
57
  orderTypesConfig: OrderTypesConfig;
57
58
  phone: string;
59
+ recDispensary: boolean;
58
60
  status: string;
59
61
  };
60
62
  export type DispensaryAddress = {
@@ -91,6 +93,7 @@ export type HoursSettingsForOrderType = {
91
93
  };
92
94
  enabled: boolean;
93
95
  };
96
+ export type IntegrationValue = string | undefined;
94
97
  export type OrderTypeConfig = {
95
98
  enableAfterHoursOrdering?: boolean;
96
99
  enableASAPOrdering?: boolean;
@@ -138,6 +141,10 @@ export type DataLoaders = {
138
141
  * Product collections
139
142
  */
140
143
  collections: () => Promise<Collection[] | []>;
144
+ /**
145
+ * Integration value
146
+ */
147
+ integrationValue: (key: string) => Promise<IntegrationValue>;
141
148
  /**
142
149
  * All dispensary locations of the chain
143
150
  */
@@ -1,18 +1,26 @@
1
1
  import type { CartItem } from './data';
2
+ type QueryParameter = string;
3
+ type AdditionalRoutableParameters = {
4
+ query?: QueryParameter;
5
+ };
6
+ type GoToIdOrCnameParameters = {
7
+ cname?: string;
8
+ id?: string;
9
+ } & AdditionalRoutableParameters;
2
10
  type AuthenticationActions = {
3
11
  /**
4
12
  * Navigate to login
5
13
  */
6
14
  goToLogin: () => void;
15
+ /**
16
+ * Navigate to loyalty. Redirects to the homepage if the user is not logged in.
17
+ */
18
+ goToLoyalty: () => void;
7
19
  /**
8
20
  * Navigate to registration
9
21
  */
10
22
  goToRegister: () => void;
11
23
  };
12
- type GoToIdOrCnameParameters = {
13
- cname?: string;
14
- id?: string;
15
- };
16
24
  type CartActions = {
17
25
  /**
18
26
  * Add product to cart
@@ -29,7 +37,7 @@ type CartActions = {
29
37
  /**
30
38
  * Navigate to checkout
31
39
  */
32
- goToCheckout: () => void;
40
+ goToCheckout: (params?: AdditionalRoutableParameters) => void;
33
41
  /**
34
42
  * Remove product from cart
35
43
  */
@@ -54,16 +62,17 @@ type ComponentActions = {
54
62
  /**
55
63
  * Navigate to search
56
64
  * @param query - The search query
65
+ * @param params - Additional params
57
66
  */
58
- goToSearch: (query?: string) => void;
67
+ goToSearch: (query?: string, params?: AdditionalRoutableParameters) => void;
59
68
  /**
60
69
  * Navigate to store browser
61
70
  */
62
- goToStoreBrowser: () => void;
71
+ goToStoreBrowser: (params?: AdditionalRoutableParameters) => void;
63
72
  /**
64
73
  * Navigate to store locator
65
74
  */
66
- goToStoreLocator: () => void;
75
+ goToStoreLocator: (params?: AdditionalRoutableParameters) => void;
67
76
  };
68
77
  type DetailPageActions = {
69
78
  /**
@@ -87,7 +96,7 @@ type ListPageActions = {
87
96
  /**
88
97
  * Navigate to brand list
89
98
  */
90
- goToBrandList: () => void;
99
+ goToBrandList: (params?: AdditionalRoutableParameters) => void;
91
100
  /**
92
101
  * Navigate to product list
93
102
  * @param brandCname - The brand CNAME
@@ -96,34 +105,31 @@ type ListPageActions = {
96
105
  * @param categoryId - The category ID
97
106
  * @param collectionCname - The collection CNAME
98
107
  * @param collectionId - The collection ID
108
+ * @param query - The query param to append
99
109
  */
100
- goToProductList: ({ brandCname, brandId, categoryCname, categoryId, collectionCname, collectionId, }: {
110
+ goToProductList: ({ brandCname, brandId, categoryCname, categoryId, collectionCname, collectionId, query, }: {
101
111
  brandCname?: string;
102
112
  brandId?: string;
103
113
  categoryCname?: string;
104
114
  categoryId?: string;
105
115
  collectionCname?: string;
106
116
  collectionId?: string;
117
+ query?: QueryParameter;
107
118
  }) => void;
108
119
  };
109
120
  type NavigationActions = {
110
121
  /**
111
122
  * Navigate to store info
112
123
  */
113
- goToInfoPage: () => void;
124
+ goToInfoPage: (params?: AdditionalRoutableParameters) => void;
114
125
  /**
115
- * Navigate to specific store
116
- * @param cname - The store CNAME
117
- * @param id - The store ID
126
+ * Navigate to specific store. Only one parameter is required.
118
127
  */
119
- goToStore: ({ cname, id }: {
120
- cname?: string;
121
- id?: string;
122
- }) => void;
128
+ goToStore: (params: GoToIdOrCnameParameters) => void;
123
129
  /**
124
130
  * Navigate to store front
125
131
  */
126
- goToStoreFront: () => void;
132
+ goToStoreFront: (params?: AdditionalRoutableParameters) => void;
127
133
  };
128
134
  export type Actions = AuthenticationActions & CartActions & ComponentActions & DetailPageActions & ListPageActions & NavigationActions;
129
135
  export {};
@@ -51,10 +51,12 @@ export type Dispensary = {
51
51
  website: string;
52
52
  storeFrontRoot: string;
53
53
  };
54
+ medDispensary: boolean;
54
55
  name: string;
55
56
  orderTypes: DispensaryOrderTypes;
56
57
  orderTypesConfig: OrderTypesConfig;
57
58
  phone: string;
59
+ recDispensary: boolean;
58
60
  status: string;
59
61
  };
60
62
  export type DispensaryAddress = {
@@ -91,6 +93,7 @@ export type HoursSettingsForOrderType = {
91
93
  };
92
94
  enabled: boolean;
93
95
  };
96
+ export type IntegrationValue = string | undefined;
94
97
  export type OrderTypeConfig = {
95
98
  enableAfterHoursOrdering?: boolean;
96
99
  enableASAPOrdering?: boolean;
@@ -138,6 +141,10 @@ export type DataLoaders = {
138
141
  * Product collections
139
142
  */
140
143
  collections: () => Promise<Collection[] | []>;
144
+ /**
145
+ * Integration value
146
+ */
147
+ integrationValue: (key: string) => Promise<IntegrationValue>;
141
148
  /**
142
149
  * All dispensary locations of the chain
143
150
  */
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.10.1",
7
+ "version": "0.12.0",
8
8
  "license": "MIT",
9
9
  "type": "module",
10
10
  "module": "./dist/esm/index.js",