@scayle/omnichannel-nuxt 1.1.19 → 2.0.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +23 -35
  3. package/dist/chunks/createOmnichannelHandler.mjs +790 -0
  4. package/dist/index.d.mts +40 -0
  5. package/dist/index.d.ts +40 -9
  6. package/dist/index.mjs +96 -0
  7. package/dist/module.cjs +5 -0
  8. package/dist/module.d.mts +6 -0
  9. package/dist/module.d.ts +6 -0
  10. package/dist/module.json +4 -0
  11. package/dist/module.mjs +36 -0
  12. package/dist/runtime/composables/useStoreLocator.d.ts +9 -0
  13. package/dist/runtime/composables/useStoreLocator.mjs +18 -0
  14. package/dist/{composables → runtime/composables}/useStoreVariantById.d.ts +1 -2
  15. package/dist/runtime/composables/useStoreVariantById.mjs +20 -0
  16. package/dist/runtime/composables/useStores.d.ts +6 -0
  17. package/dist/runtime/composables/useStores.mjs +14 -0
  18. package/dist/runtime/composables/useVariantStores.d.ts +6 -0
  19. package/dist/runtime/composables/useVariantStores.mjs +14 -0
  20. package/dist/{constants → runtime/constants}/httpStatus.d.ts +1 -2
  21. package/dist/runtime/constants/httpStatus.mjs +629 -0
  22. package/dist/runtime/constants/index.d.ts +1 -0
  23. package/dist/runtime/constants/index.mjs +1 -0
  24. package/dist/{error → runtime/error}/errorHandler.d.ts +0 -1
  25. package/dist/runtime/error/errorHandler.mjs +20 -0
  26. package/dist/runtime/handler.d.ts +2 -0
  27. package/dist/runtime/handler.mjs +48 -0
  28. package/dist/runtime/lib/init.d.ts +26 -0
  29. package/dist/runtime/lib/init.mjs +72 -0
  30. package/dist/{rpc → runtime/rpc}/storeLocator.d.ts +4 -11
  31. package/dist/runtime/rpc/storeLocator.mjs +32 -0
  32. package/dist/{types/omnichannel.d.ts → shared/omnichannel-nuxt.9b492196.d.mts} +25 -24
  33. package/dist/shared/omnichannel-nuxt.9b492196.d.ts +146 -0
  34. package/dist/types.d.mts +8 -0
  35. package/dist/types.d.ts +8 -0
  36. package/package.json +42 -17
  37. package/dist/composables/sharedRef.d.ts +0 -3
  38. package/dist/composables/sharedRef.d.ts.map +0 -1
  39. package/dist/composables/sharedRef.js +0 -16
  40. package/dist/composables/sharedRef.js.map +0 -1
  41. package/dist/composables/useGeocode.d.ts +0 -7
  42. package/dist/composables/useGeocode.d.ts.map +0 -1
  43. package/dist/composables/useGeocode.js +0 -17
  44. package/dist/composables/useGeocode.js.map +0 -1
  45. package/dist/composables/useStoreLocator.d.ts +0 -10
  46. package/dist/composables/useStoreLocator.d.ts.map +0 -1
  47. package/dist/composables/useStoreLocator.js +0 -17
  48. package/dist/composables/useStoreLocator.js.map +0 -1
  49. package/dist/composables/useStoreVariantById.d.ts.map +0 -1
  50. package/dist/composables/useStoreVariantById.js +0 -20
  51. package/dist/composables/useStoreVariantById.js.map +0 -1
  52. package/dist/composables/useStores.d.ts +0 -7
  53. package/dist/composables/useStores.d.ts.map +0 -1
  54. package/dist/composables/useStores.js +0 -17
  55. package/dist/composables/useStores.js.map +0 -1
  56. package/dist/composables/useVariantStores.d.ts +0 -7
  57. package/dist/composables/useVariantStores.d.ts.map +0 -1
  58. package/dist/composables/useVariantStores.js +0 -17
  59. package/dist/composables/useVariantStores.js.map +0 -1
  60. package/dist/constants/httpStatus.d.ts.map +0 -1
  61. package/dist/constants/httpStatus.js +0 -634
  62. package/dist/constants/httpStatus.js.map +0 -1
  63. package/dist/constants/index.d.ts +0 -2
  64. package/dist/constants/index.d.ts.map +0 -1
  65. package/dist/constants/index.js +0 -5
  66. package/dist/constants/index.js.map +0 -1
  67. package/dist/constants/omnichannel.d.ts +0 -12
  68. package/dist/constants/omnichannel.d.ts.map +0 -1
  69. package/dist/constants/omnichannel.js +0 -13
  70. package/dist/constants/omnichannel.js.map +0 -1
  71. package/dist/error/errorHandler.d.ts.map +0 -1
  72. package/dist/error/errorHandler.js +0 -27
  73. package/dist/error/errorHandler.js.map +0 -1
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/index.js +0 -18
  76. package/dist/index.js.map +0 -1
  77. package/dist/lib/init.d.ts +0 -11
  78. package/dist/lib/init.d.ts.map +0 -1
  79. package/dist/lib/init.js +0 -49
  80. package/dist/lib/init.js.map +0 -1
  81. package/dist/module/createOmnichannelHandler.d.ts +0 -3
  82. package/dist/module/createOmnichannelHandler.d.ts.map +0 -1
  83. package/dist/module/createOmnichannelHandler.js +0 -56
  84. package/dist/module/createOmnichannelHandler.js.map +0 -1
  85. package/dist/module/register.d.ts +0 -6
  86. package/dist/module/register.d.ts.map +0 -1
  87. package/dist/module/register.js +0 -12
  88. package/dist/module/register.js.map +0 -1
  89. package/dist/rpc/geocode.d.ts +0 -23
  90. package/dist/rpc/geocode.d.ts.map +0 -1
  91. package/dist/rpc/geocode.js +0 -46
  92. package/dist/rpc/geocode.js.map +0 -1
  93. package/dist/rpc/index.d.ts +0 -3
  94. package/dist/rpc/index.d.ts.map +0 -1
  95. package/dist/rpc/index.js +0 -6
  96. package/dist/rpc/index.js.map +0 -1
  97. package/dist/rpc/storeLocator.d.ts.map +0 -1
  98. package/dist/rpc/storeLocator.js +0 -69
  99. package/dist/rpc/storeLocator.js.map +0 -1
  100. package/dist/types/geocode.d.ts +0 -8
  101. package/dist/types/geocode.d.ts.map +0 -1
  102. package/dist/types/geocode.js +0 -3
  103. package/dist/types/geocode.js.map +0 -1
  104. package/dist/types/index.d.ts +0 -3
  105. package/dist/types/index.d.ts.map +0 -1
  106. package/dist/types/index.js +0 -6
  107. package/dist/types/index.js.map +0 -1
  108. package/dist/types/omnichannel.d.ts.map +0 -1
  109. package/dist/types/omnichannel.js +0 -3
  110. package/dist/types/omnichannel.js.map +0 -1
@@ -0,0 +1,48 @@
1
+ import { defineEventHandler, readBody, setResponseStatus } from "h3";
2
+ import { HttpStatusCode } from "./constants/httpStatus.mjs";
3
+ import {
4
+ getStores,
5
+ getStoreVariantById,
6
+ getStoresForVariant
7
+ } from "./rpc/storeLocator.mjs";
8
+ import { parseErrorData } from "./error/errorHandler.mjs";
9
+ import { useRuntimeConfig } from "#imports";
10
+ export default defineEventHandler(async (event) => {
11
+ const path = event.path.split("/").reverse()[0];
12
+ const runtimeConfig = useRuntimeConfig();
13
+ const config = runtimeConfig.omnichannel;
14
+ if (!config.apiHost || !config.apiToken) {
15
+ setResponseStatus(event, HttpStatusCode.INTERNAL_SERVER_ERROR);
16
+ return {
17
+ statusCode: HttpStatusCode.INTERNAL_SERVER_ERROR,
18
+ message: "Token and host must be set for the omnichannel"
19
+ };
20
+ }
21
+ const options = {
22
+ host: config.apiHost,
23
+ token: config.apiToken
24
+ };
25
+ try {
26
+ switch (path) {
27
+ case "stores": {
28
+ const body = await readBody(event);
29
+ return await getStores(body, options);
30
+ }
31
+ case "storeVariantById": {
32
+ const body = await readBody(event);
33
+ return await getStoreVariantById(body, options);
34
+ }
35
+ case "variantStores": {
36
+ const body = await readBody(event);
37
+ return await getStoresForVariant(body, options);
38
+ }
39
+ default: {
40
+ setResponseStatus(event, 404);
41
+ }
42
+ }
43
+ } catch (e) {
44
+ const parsedError = parseErrorData(e);
45
+ setResponseStatus(event, parsedError.statusCode);
46
+ return { ...parsedError };
47
+ }
48
+ });
@@ -0,0 +1,26 @@
1
+ import type { StoreLocation, StoreLocatorSearchParams, StoreAvailabilityCheckResponse, VariantLocationResponse } from '../types';
2
+ import type { FetchOptions, FetchStoreVariantByIdParams } from '../rpc/storeLocator';
3
+ export interface PaginatedResponse<DataType> {
4
+ nextPage: null;
5
+ data: DataType;
6
+ }
7
+ /**
8
+ * A custom Error type for errors that occur in a fetch() request
9
+ * Contains the Response object from the request, and optionally the response data
10
+ */
11
+ export declare class FetchError extends Error {
12
+ response: Response;
13
+ data?: unknown;
14
+ constructor(response: Response, data?: unknown);
15
+ }
16
+ export declare class OmnichannelClient {
17
+ private readonly host;
18
+ private readonly token;
19
+ constructor(host: string, token: string);
20
+ get headers(): HeadersInit;
21
+ private handleResponse;
22
+ getStores(options: StoreLocatorSearchParams): Promise<PaginatedResponse<StoreLocation[]>>;
23
+ getStoresForVariant(options: FetchOptions): Promise<PaginatedResponse<VariantLocationResponse>>;
24
+ getStoreVariantById(options: FetchStoreVariantByIdParams): Promise<StoreAvailabilityCheckResponse>;
25
+ }
26
+ export declare const init: (config?: any) => OmnichannelClient | null;
@@ -0,0 +1,72 @@
1
+ import qs from "qs";
2
+ import { DEFAULT_SEARCH_RADIUS } from "../constants/index.mjs";
3
+ export class FetchError extends Error {
4
+ response;
5
+ data;
6
+ constructor(response, data) {
7
+ const message = `Failed to fetch ${response.url}. ${response.status} ${response.statusText}`;
8
+ super(message);
9
+ this.response = response;
10
+ this.data = data;
11
+ this.name = "FetchError";
12
+ this.message = message;
13
+ }
14
+ }
15
+ export class OmnichannelClient {
16
+ host;
17
+ token;
18
+ constructor(host, token) {
19
+ this.host = host;
20
+ this.token = token;
21
+ }
22
+ get headers() {
23
+ return {
24
+ Authorization: `Bearer ${this.token}`,
25
+ Accept: "application/json",
26
+ "Content-Type": "application/json"
27
+ };
28
+ }
29
+ async handleResponse(response) {
30
+ if (!response.ok) {
31
+ throw new FetchError(response);
32
+ }
33
+ return await response.json();
34
+ }
35
+ async getStores(options) {
36
+ const params = qs.stringify(options, { arrayFormat: "brackets" });
37
+ const response = await fetch(`${this.host}/stores/locator?${params}`, {
38
+ headers: this.headers
39
+ });
40
+ return await this.handleResponse(
41
+ response
42
+ );
43
+ }
44
+ async getStoresForVariant(options) {
45
+ const fetchOptions = {
46
+ filters: {
47
+ address: options.filters.address,
48
+ radius: options.filters.radius ?? DEFAULT_SEARCH_RADIUS
49
+ },
50
+ variantId: options.variantId,
51
+ perPage: 10
52
+ };
53
+ const params = qs.stringify(fetchOptions, { arrayFormat: "brackets" });
54
+ const response = await fetch(`${this.host}/variants/locator?${params}`, {
55
+ headers: this.headers
56
+ });
57
+ return await this.handleResponse(response);
58
+ }
59
+ async getStoreVariantById(options) {
60
+ const response = await fetch(
61
+ `${this.host}/stores/${options.storeId}/variants/${options.variantId}`,
62
+ { headers: this.headers }
63
+ );
64
+ return await this.handleResponse(response);
65
+ }
66
+ }
67
+ export const init = (config) => {
68
+ if (config) {
69
+ return new OmnichannelClient(config.host, config.token);
70
+ }
71
+ return null;
72
+ };
@@ -1,4 +1,4 @@
1
- import { StoreAvailabilityCheck, StoreLocation, StoreLocatorConfig, StoreLocatorSearchParams, VariantLocation } from '../types';
1
+ import type { StoreLocatorConfig, StoreLocatorSearchParams } from '../../types';
2
2
  export interface FetchStoresForVariantParams {
3
3
  variantId: number;
4
4
  filters: {
@@ -19,13 +19,6 @@ export interface FetchOptions {
19
19
  variantId?: number;
20
20
  perPage: number;
21
21
  }
22
- export declare const getStores: (options: StoreLocatorSearchParams, storeLocator: StoreLocatorConfig) => Promise<{
23
- data: StoreLocation[];
24
- nextPage: null;
25
- }>;
26
- export declare const getStoresForVariant: (options: FetchStoresForVariantParams, storeLocator: StoreLocatorConfig) => Promise<{
27
- data: VariantLocation;
28
- nextPage: null;
29
- }>;
30
- export declare const getStoreVariantById: (options: FetchStoreVariantByIdParams, storeLocator: StoreLocatorConfig) => Promise<StoreAvailabilityCheck>;
31
- //# sourceMappingURL=storeLocator.d.ts.map
22
+ export declare const getStores: (options: StoreLocatorSearchParams, storeLocator: StoreLocatorConfig) => Promise<import("../lib/init").PaginatedResponse<StoreLocation[]>>;
23
+ export declare const getStoresForVariant: (options: FetchStoresForVariantParams, storeLocator: StoreLocatorConfig) => Promise<import("../lib/init").PaginatedResponse<VariantLocationResponse>>;
24
+ export declare const getStoreVariantById: (options: FetchStoreVariantByIdParams, storeLocator: StoreLocatorConfig) => Promise<StoreAvailabilityCheckResponse>;
@@ -0,0 +1,32 @@
1
+ import { init } from "../lib/init.mjs";
2
+ import { DEFAULT_SEARCH_RADIUS } from "../constants/index.mjs";
3
+ const noClientMessage = "Client not configured";
4
+ export const getStores = async function getStores2(options, storeLocator) {
5
+ const omnichannelClient = init(storeLocator);
6
+ if (!omnichannelClient) {
7
+ throw new Error(noClientMessage);
8
+ }
9
+ return await omnichannelClient.getStores(options);
10
+ };
11
+ export const getStoresForVariant = async function getStoresForVariant2(options, storeLocator) {
12
+ const fetchOptions = {
13
+ filters: {
14
+ address: options.filters.address,
15
+ radius: options.filters.radius ?? DEFAULT_SEARCH_RADIUS
16
+ },
17
+ variantId: options.variantId,
18
+ perPage: 10
19
+ };
20
+ const omnichannelClient = init(storeLocator);
21
+ if (!omnichannelClient) {
22
+ throw new Error(noClientMessage);
23
+ }
24
+ return await omnichannelClient.getStoresForVariant(fetchOptions);
25
+ };
26
+ export const getStoreVariantById = async function getStoreVariantById2(options, storeLocator) {
27
+ const omnichannelClient = init(storeLocator);
28
+ if (!omnichannelClient) {
29
+ throw new Error(noClientMessage);
30
+ }
31
+ return await omnichannelClient.getStoreVariantById(options);
32
+ };
@@ -1,51 +1,51 @@
1
- export interface StoreLocatorConfig {
1
+ interface StoreLocatorConfig {
2
2
  token: string;
3
3
  host: string;
4
4
  companyId?: number;
5
5
  googleApiKey?: string;
6
6
  }
7
- export interface GeoPoint {
7
+ interface GeoPoint {
8
8
  lat: number;
9
9
  lng: number;
10
10
  }
11
- export interface OpeningTimeInterval {
11
+ interface OpeningTimeInterval {
12
12
  timeFrom: string;
13
13
  timeUntil: string;
14
14
  }
15
- export interface OpeningTimeException {
15
+ interface OpeningTimeException {
16
16
  exceptionDate: string;
17
17
  exceptionName: string;
18
18
  exceptionType: 'open' | 'closed';
19
19
  timeFrom: string;
20
20
  timeUntil: string;
21
21
  }
22
- export interface StoreImage {
22
+ interface StoreImage {
23
23
  id: number;
24
24
  name: string;
25
25
  damKey: string;
26
26
  url: string;
27
27
  customData: object;
28
28
  }
29
- export interface StoreAddress {
29
+ interface StoreAddress {
30
30
  street: string;
31
31
  houseNumber: string;
32
32
  zipCode: string;
33
33
  city: string;
34
34
  countryCode: string;
35
35
  }
36
- export interface StoreItemVariant {
36
+ interface StoreItemVariant {
37
37
  variantId: number;
38
38
  variantReferenceKey: string;
39
39
  quantity: number;
40
40
  }
41
- export interface StoreItem {
41
+ interface StoreItem {
42
42
  productId: number;
43
43
  productReferenceKey: string;
44
44
  name: object;
45
45
  image: string;
46
46
  variants: StoreItemVariant[];
47
47
  }
48
- export interface OpeningTimes {
48
+ interface OpeningTimes {
49
49
  mon: OpeningTimeInterval[];
50
50
  tue: OpeningTimeInterval[];
51
51
  wed: OpeningTimeInterval[];
@@ -57,7 +57,7 @@ export interface OpeningTimes {
57
57
  currentlyOpen: boolean;
58
58
  minutesUntilClosed: number;
59
59
  }
60
- export interface Store {
60
+ interface Store {
61
61
  id: number;
62
62
  referenceKey: string;
63
63
  name: string;
@@ -73,7 +73,7 @@ export interface Store {
73
73
  isActive: boolean;
74
74
  images: StoreImage;
75
75
  }
76
- export interface OmnichannelMeta {
76
+ interface OmnichannelMeta {
77
77
  path: string;
78
78
  currentPage: number;
79
79
  lastPage: number;
@@ -86,32 +86,32 @@ export interface OmnichannelMeta {
86
86
  prevPageUrl: string | null;
87
87
  nextPageUrl: string | null;
88
88
  }
89
- export interface OmnichannelLinks {
89
+ interface OmnichannelLinks {
90
90
  first: string | null;
91
91
  last: string | null;
92
92
  prev: string | null;
93
93
  next: string | null;
94
94
  }
95
- export interface StoreLocation extends Store {
95
+ interface StoreLocation extends Store {
96
96
  distance: number;
97
97
  }
98
- export interface StoreLocationResponse {
98
+ interface StoreLocationResponse {
99
99
  data: StoreLocation[];
100
100
  meta: {
101
101
  searchAddress: GeoPoint;
102
102
  };
103
103
  }
104
- export interface StoreVariantLocation extends StoreLocation {
104
+ interface StoreVariantLocation extends StoreLocation {
105
105
  quantity: number;
106
106
  }
107
- export interface StoreAvailabilityCheck extends Store {
107
+ interface StoreAvailabilityCheck extends Store {
108
108
  items: StoreItem[];
109
109
  }
110
- export interface StoreAvailabilityCheckResponse {
110
+ interface StoreAvailabilityCheckResponse {
111
111
  data: StoreAvailabilityCheck;
112
112
  meta: OmnichannelMeta;
113
113
  }
114
- export interface VariantLocation {
114
+ interface VariantLocation {
115
115
  name: object;
116
116
  productId: number;
117
117
  variantId: number;
@@ -121,25 +121,26 @@ export interface VariantLocation {
121
121
  additionalData: object;
122
122
  stores: StoreVariantLocation[];
123
123
  }
124
- export interface VariantLocationResponse {
124
+ interface VariantLocationResponse {
125
125
  data: VariantLocation;
126
126
  meta: OmnichannelMeta;
127
127
  }
128
- export interface FiltersAddressParams {
128
+ interface FiltersAddressParams {
129
129
  address: string;
130
130
  radius: number;
131
131
  }
132
- export interface FiltersCoordinatesParams {
132
+ interface FiltersCoordinatesParams {
133
133
  geoPoint: GeoPoint;
134
134
  radius: number;
135
135
  }
136
- export interface StoreLocatorSearchParams {
136
+ interface StoreLocatorSearchParams {
137
137
  filters: FiltersAddressParams | FiltersCoordinatesParams;
138
138
  perPage?: number;
139
139
  }
140
- export interface VariantLocatorSearchParams {
140
+ interface VariantLocatorSearchParams {
141
141
  variantId: number;
142
142
  filters: FiltersAddressParams | FiltersCoordinatesParams;
143
143
  perPage?: number;
144
144
  }
145
- //# sourceMappingURL=omnichannel.d.ts.map
145
+
146
+ export type { FiltersAddressParams as F, GeoPoint as G, OpeningTimeInterval as O, StoreLocationResponse as S, VariantLocation as V, StoreLocatorSearchParams as a, StoreAvailabilityCheck as b, VariantLocatorSearchParams as c, StoreLocatorConfig as d, OpeningTimeException as e, StoreImage as f, StoreAddress as g, StoreItemVariant as h, StoreItem as i, OpeningTimes as j, Store as k, OmnichannelMeta as l, OmnichannelLinks as m, StoreLocation as n, StoreVariantLocation as o, StoreAvailabilityCheckResponse as p, VariantLocationResponse as q, FiltersCoordinatesParams as r };
@@ -0,0 +1,146 @@
1
+ interface StoreLocatorConfig {
2
+ token: string;
3
+ host: string;
4
+ companyId?: number;
5
+ googleApiKey?: string;
6
+ }
7
+ interface GeoPoint {
8
+ lat: number;
9
+ lng: number;
10
+ }
11
+ interface OpeningTimeInterval {
12
+ timeFrom: string;
13
+ timeUntil: string;
14
+ }
15
+ interface OpeningTimeException {
16
+ exceptionDate: string;
17
+ exceptionName: string;
18
+ exceptionType: 'open' | 'closed';
19
+ timeFrom: string;
20
+ timeUntil: string;
21
+ }
22
+ interface StoreImage {
23
+ id: number;
24
+ name: string;
25
+ damKey: string;
26
+ url: string;
27
+ customData: object;
28
+ }
29
+ interface StoreAddress {
30
+ street: string;
31
+ houseNumber: string;
32
+ zipCode: string;
33
+ city: string;
34
+ countryCode: string;
35
+ }
36
+ interface StoreItemVariant {
37
+ variantId: number;
38
+ variantReferenceKey: string;
39
+ quantity: number;
40
+ }
41
+ interface StoreItem {
42
+ productId: number;
43
+ productReferenceKey: string;
44
+ name: object;
45
+ image: string;
46
+ variants: StoreItemVariant[];
47
+ }
48
+ interface OpeningTimes {
49
+ mon: OpeningTimeInterval[];
50
+ tue: OpeningTimeInterval[];
51
+ wed: OpeningTimeInterval[];
52
+ thu: OpeningTimeInterval[];
53
+ fri: OpeningTimeInterval[];
54
+ sat: OpeningTimeInterval[];
55
+ sun: OpeningTimeInterval[];
56
+ exceptions: OpeningTimeException[];
57
+ currentlyOpen: boolean;
58
+ minutesUntilClosed: number;
59
+ }
60
+ interface Store {
61
+ id: number;
62
+ referenceKey: string;
63
+ name: string;
64
+ email: string;
65
+ address: StoreAddress;
66
+ openingTimes: OpeningTimes;
67
+ geoPoint: GeoPoint;
68
+ customData: object;
69
+ settings: {
70
+ shipFromStore: boolean;
71
+ clickAndCollect: boolean;
72
+ };
73
+ isActive: boolean;
74
+ images: StoreImage;
75
+ }
76
+ interface OmnichannelMeta {
77
+ path: string;
78
+ currentPage: number;
79
+ lastPage: number;
80
+ from: number;
81
+ to: number;
82
+ perPage: number;
83
+ total: number;
84
+ firstPageUrl: string;
85
+ lastPageUrl: string;
86
+ prevPageUrl: string | null;
87
+ nextPageUrl: string | null;
88
+ }
89
+ interface OmnichannelLinks {
90
+ first: string | null;
91
+ last: string | null;
92
+ prev: string | null;
93
+ next: string | null;
94
+ }
95
+ interface StoreLocation extends Store {
96
+ distance: number;
97
+ }
98
+ interface StoreLocationResponse {
99
+ data: StoreLocation[];
100
+ meta: {
101
+ searchAddress: GeoPoint;
102
+ };
103
+ }
104
+ interface StoreVariantLocation extends StoreLocation {
105
+ quantity: number;
106
+ }
107
+ interface StoreAvailabilityCheck extends Store {
108
+ items: StoreItem[];
109
+ }
110
+ interface StoreAvailabilityCheckResponse {
111
+ data: StoreAvailabilityCheck;
112
+ meta: OmnichannelMeta;
113
+ }
114
+ interface VariantLocation {
115
+ name: object;
116
+ productId: number;
117
+ variantId: number;
118
+ productReferenceKey: string;
119
+ variantReferenceKey: string;
120
+ image: string;
121
+ additionalData: object;
122
+ stores: StoreVariantLocation[];
123
+ }
124
+ interface VariantLocationResponse {
125
+ data: VariantLocation;
126
+ meta: OmnichannelMeta;
127
+ }
128
+ interface FiltersAddressParams {
129
+ address: string;
130
+ radius: number;
131
+ }
132
+ interface FiltersCoordinatesParams {
133
+ geoPoint: GeoPoint;
134
+ radius: number;
135
+ }
136
+ interface StoreLocatorSearchParams {
137
+ filters: FiltersAddressParams | FiltersCoordinatesParams;
138
+ perPage?: number;
139
+ }
140
+ interface VariantLocatorSearchParams {
141
+ variantId: number;
142
+ filters: FiltersAddressParams | FiltersCoordinatesParams;
143
+ perPage?: number;
144
+ }
145
+
146
+ export type { FiltersAddressParams as F, GeoPoint as G, OpeningTimeInterval as O, StoreLocationResponse as S, VariantLocation as V, StoreLocatorSearchParams as a, StoreAvailabilityCheck as b, VariantLocatorSearchParams as c, StoreLocatorConfig as d, OpeningTimeException as e, StoreImage as f, StoreAddress as g, StoreItemVariant as h, StoreItem as i, OpeningTimes as j, Store as k, OmnichannelMeta as l, OmnichannelLinks as m, StoreLocation as n, StoreVariantLocation as o, StoreAvailabilityCheckResponse as p, VariantLocationResponse as q, FiltersCoordinatesParams as r };
@@ -0,0 +1,8 @@
1
+
2
+ import type { } from './module.js'
3
+
4
+
5
+
6
+
7
+
8
+ export type { default } from './module.js'
@@ -0,0 +1,8 @@
1
+
2
+ import type { } from './module'
3
+
4
+
5
+
6
+
7
+
8
+ export type { default } from './module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/omnichannel-nuxt",
3
- "version": "1.1.19",
3
+ "version": "2.0.0",
4
4
  "description": "Collection of essential utilities to work with omnichannel",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -8,7 +8,19 @@
8
8
  "access": "public",
9
9
  "registry": "https://registry.npmjs.org/"
10
10
  },
11
- "main": "./dist/index.js",
11
+ "exports": {
12
+ "./module": {
13
+ "types": "./dist/module.d.ts",
14
+ "require": "./dist/module.cjs",
15
+ "import": "./dist/module.mjs"
16
+ },
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.mjs"
20
+ }
21
+ },
22
+ "main": "./dist/index.mjs",
23
+ "type": "module",
12
24
  "types": "./dist/index.d.ts",
13
25
  "files": [
14
26
  "CHANGELOG.md",
@@ -17,9 +29,20 @@
17
29
  "engines": {
18
30
  "node": ">= 18.15.0"
19
31
  },
32
+ "build": {
33
+ "entries": [
34
+ "./src/index"
35
+ ]
36
+ },
37
+ "compatibility": {
38
+ "nuxt": "^2.17.3 || ^3.9.0"
39
+ },
20
40
  "scripts": {
21
41
  "clean": "rimraf ./dist",
22
- "build": "tsc -p tsconfig.build.json",
42
+ "build": "nuxt-module-build build",
43
+ "dev": "nuxi dev playground",
44
+ "dev:build": "nuxi build playground",
45
+ "prep": "nuxi prepare playground",
23
46
  "format": "prettier --ignore-unknown --log-level warn --check .",
24
47
  "format:fix": "prettier --ignore-unknown --log-level warn --write .",
25
48
  "lint": "eslint . --format gitlab",
@@ -30,32 +53,34 @@
30
53
  },
31
54
  "peerDependencies": {
32
55
  "@nuxtjs/composition-api": "0.33.1",
33
- "axios": "0.27.2"
56
+ "express": "4.18.2"
34
57
  },
35
58
  "dependencies": {
36
- "@nuxtjs/composition-api": "0.33.1",
37
- "axios": "0.27.2",
59
+ "@nuxt/kit": "^3.9.3",
38
60
  "body-parser": "1.20.2",
39
- "express": "4.18.2",
40
61
  "qs": "6.11.2",
41
- "utility-types": "3.10.0"
62
+ "utility-types": "3.11.0"
42
63
  },
43
64
  "devDependencies": {
65
+ "@nuxt/module-builder": "0.5.5",
66
+ "@nuxt/schema": "3.9.3",
44
67
  "@nuxt/types": "2.17.1",
45
- "@scayle/eslint-config-storefront": "3.2.5",
68
+ "@nuxtjs/composition-api": "0.33.1",
69
+ "@scayle/eslint-config-storefront": "3.2.6",
46
70
  "@scayle/prettier-config-storefront": "2.0.2",
47
71
  "@types/body-parser": "1.19.5",
48
72
  "@types/express": "4.17.21",
49
- "@types/express-serve-static-core": "4.17.39",
50
- "@types/node": "20.8.10",
51
- "@types/qs": "6.9.9",
52
- "eslint": "8.53.0",
53
- "eslint-formatter-gitlab": "5.0.0",
73
+ "@types/node": "20.11.16",
74
+ "@types/qs": "6.9.11",
75
+ "eslint": "8.56.0",
76
+ "eslint-formatter-gitlab": "5.1.0",
77
+ "h3": "1.10.1",
78
+ "nuxi": "3.10.0",
54
79
  "prettier": "3.0.0",
55
- "typescript": "5.2.2",
56
- "vue": "2.7.15"
80
+ "typescript": "5.3.3",
81
+ "vue": "2.7.16"
57
82
  },
58
83
  "volta": {
59
- "node": "20.9.0"
84
+ "node": "20.11.0"
60
85
  }
61
86
  }
@@ -1,3 +0,0 @@
1
- import { Ref } from '@nuxtjs/composition-api';
2
- export declare function sharedRef<T>(value: T, key: string): Ref<T>;
3
- //# sourceMappingURL=sharedRef.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sharedRef.d.ts","sourceRoot":"","sources":["../../src/composables/sharedRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAsB,MAAM,yBAAyB,CAAA;AAEjE,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAa1D"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sharedRef = void 0;
4
- const composition_api_1 = require("@nuxtjs/composition-api");
5
- function sharedRef(value, key) {
6
- const context = (0, composition_api_1.useContext)();
7
- const { $sharedRefsMap } = context;
8
- if ($sharedRefsMap.has(key)) {
9
- return $sharedRefsMap.get(key);
10
- }
11
- const newRef = (0, composition_api_1.ssrRef)(value, key);
12
- $sharedRefsMap.set(key, newRef);
13
- return newRef;
14
- }
15
- exports.sharedRef = sharedRef;
16
- //# sourceMappingURL=sharedRef.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sharedRef.js","sourceRoot":"","sources":["../../src/composables/sharedRef.ts"],"names":[],"mappings":";;;AAAA,6DAAiE;AAEjE,SAAgB,SAAS,CAAI,KAAQ,EAAE,GAAW;IAChD,MAAM,OAAO,GAAQ,IAAA,4BAAU,GAAE,CAAA;IACjC,MAAM,EAAE,cAAc,EAAE,GAAG,OAAc,CAAA;IAEzC,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC3B,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;KAC/B;IAED,MAAM,MAAM,GAAG,IAAA,wBAAM,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAEjC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAE/B,OAAO,MAAM,CAAA;AACf,CAAC;AAbD,8BAaC"}
@@ -1,7 +0,0 @@
1
- import { GeocodeSearchParams, GeocodeCoordinatesParams } from '../types';
2
- declare const _default: (key?: string) => {
3
- data: import("@nuxtjs/composition-api").ComputedRef<any>;
4
- getData: (searchParams: GeocodeSearchParams | GeocodeCoordinatesParams) => Promise<void>;
5
- };
6
- export default _default;
7
- //# sourceMappingURL=useGeocode.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useGeocode.d.ts","sourceRoot":"","sources":["../../src/composables/useGeocode.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;;;4BAOtD,mBAAmB,GAAG,wBAAwB;;AAJhE,wBAaC"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const axios_1 = tslib_1.__importDefault(require("axios"));
5
- const composition_api_1 = require("@nuxtjs/composition-api");
6
- const sharedRef_1 = require("./sharedRef");
7
- exports.default = (key = 'useGeocode') => {
8
- const response = (0, sharedRef_1.sharedRef)(null, key);
9
- const getData = async (searchParams) => {
10
- response.value = await axios_1.default.post('/api/omnichannel/geocode', searchParams);
11
- };
12
- return {
13
- data: (0, composition_api_1.computed)(() => { var _a; return (_a = response.value) === null || _a === void 0 ? void 0 : _a.data; }),
14
- getData,
15
- };
16
- };
17
- //# sourceMappingURL=useGeocode.js.map