@scayle/omnichannel-nuxt 1.1.18 → 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 (108) hide show
  1. package/CHANGELOG.md +34 -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/runtime/constants/httpStatus.d.ts +632 -0
  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/runtime/error/errorHandler.d.ts +7 -0
  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 +44 -20
  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/index.d.ts +0 -2
  61. package/dist/constants/index.d.ts.map +0 -1
  62. package/dist/constants/index.js +0 -5
  63. package/dist/constants/index.js.map +0 -1
  64. package/dist/constants/omnichannel.d.ts +0 -12
  65. package/dist/constants/omnichannel.d.ts.map +0 -1
  66. package/dist/constants/omnichannel.js +0 -13
  67. package/dist/constants/omnichannel.js.map +0 -1
  68. package/dist/error/errorHandler.d.ts +0 -11
  69. package/dist/error/errorHandler.d.ts.map +0 -1
  70. package/dist/error/errorHandler.js +0 -57
  71. package/dist/error/errorHandler.js.map +0 -1
  72. package/dist/index.d.ts.map +0 -1
  73. package/dist/index.js +0 -18
  74. package/dist/index.js.map +0 -1
  75. package/dist/lib/init.d.ts +0 -11
  76. package/dist/lib/init.d.ts.map +0 -1
  77. package/dist/lib/init.js +0 -49
  78. package/dist/lib/init.js.map +0 -1
  79. package/dist/module/createOmnichannelHandler.d.ts +0 -3
  80. package/dist/module/createOmnichannelHandler.d.ts.map +0 -1
  81. package/dist/module/createOmnichannelHandler.js +0 -56
  82. package/dist/module/createOmnichannelHandler.js.map +0 -1
  83. package/dist/module/register.d.ts +0 -6
  84. package/dist/module/register.d.ts.map +0 -1
  85. package/dist/module/register.js +0 -12
  86. package/dist/module/register.js.map +0 -1
  87. package/dist/rpc/geocode.d.ts +0 -23
  88. package/dist/rpc/geocode.d.ts.map +0 -1
  89. package/dist/rpc/geocode.js +0 -46
  90. package/dist/rpc/geocode.js.map +0 -1
  91. package/dist/rpc/index.d.ts +0 -3
  92. package/dist/rpc/index.d.ts.map +0 -1
  93. package/dist/rpc/index.js +0 -6
  94. package/dist/rpc/index.js.map +0 -1
  95. package/dist/rpc/storeLocator.d.ts.map +0 -1
  96. package/dist/rpc/storeLocator.js +0 -69
  97. package/dist/rpc/storeLocator.js.map +0 -1
  98. package/dist/types/geocode.d.ts +0 -8
  99. package/dist/types/geocode.d.ts.map +0 -1
  100. package/dist/types/geocode.js +0 -3
  101. package/dist/types/geocode.js.map +0 -1
  102. package/dist/types/index.d.ts +0 -3
  103. package/dist/types/index.d.ts.map +0 -1
  104. package/dist/types/index.js +0 -6
  105. package/dist/types/index.js.map +0 -1
  106. package/dist/types/omnichannel.d.ts.map +0 -1
  107. package/dist/types/omnichannel.js +0 -3
  108. package/dist/types/omnichannel.js.map +0 -1
@@ -0,0 +1,40 @@
1
+ import { S as StoreLocationResponse, a as StoreLocatorSearchParams, b as StoreAvailabilityCheck, V as VariantLocation, c as VariantLocatorSearchParams } from './shared/omnichannel-nuxt.9b492196.mjs';
2
+ export { F as FiltersAddressParams, r as FiltersCoordinatesParams, G as GeoPoint, m as OmnichannelLinks, l as OmnichannelMeta, e as OpeningTimeException, O as OpeningTimeInterval, j as OpeningTimes, k as Store, g as StoreAddress, p as StoreAvailabilityCheckResponse, f as StoreImage, i as StoreItem, h as StoreItemVariant, n as StoreLocation, d as StoreLocatorConfig, o as StoreVariantLocation, q as VariantLocationResponse } from './shared/omnichannel-nuxt.9b492196.mjs';
3
+ import { ValuesType } from 'utility-types';
4
+
5
+ declare const _default$3: (key?: string) => {
6
+ data: globalThis.ComputedRef<StoreLocationResponse | null>;
7
+ getData: (searchParams: StoreLocatorSearchParams) => Promise<void>;
8
+ };
9
+
10
+ declare const _default$2: (key?: string) => {
11
+ data: globalThis.ComputedRef<StoreAvailabilityCheck | null>;
12
+ getData: (variantId: number, storeId: number) => Promise<void>;
13
+ };
14
+
15
+ declare const _default$1: (key?: string) => {
16
+ data: globalThis.ComputedRef<VariantLocation | null>;
17
+ getData: (searchParams: VariantLocatorSearchParams) => Promise<void>;
18
+ };
19
+
20
+ declare const _default: (key?: string) => {
21
+ storesData: globalThis.ComputedRef<StoreLocationResponse | null>;
22
+ refreshStores: (searchParams: StoreLocatorSearchParams) => Promise<void>;
23
+ storeVariantData: globalThis.ComputedRef<StoreAvailabilityCheck | null>;
24
+ refreshStoreVariant: (variantId: number, storeId: number) => Promise<void>;
25
+ variantStoresData: globalThis.ComputedRef<VariantLocation | null>;
26
+ refreshVariantStores: (searchParams: VariantLocatorSearchParams) => Promise<void>;
27
+ };
28
+
29
+ declare const OpeningTime: {
30
+ readonly MONDAY: "mon";
31
+ readonly TUESDAY: "tue";
32
+ readonly WEDNESDAY: "wed";
33
+ readonly THURSDAY: "thu";
34
+ readonly FRIDAY: "fri";
35
+ readonly SATURDAY: "sat";
36
+ readonly SUNDAY: "sun";
37
+ };
38
+ type OpeningTime = ValuesType<typeof OpeningTime>;
39
+
40
+ export { OpeningTime, StoreAvailabilityCheck, StoreLocationResponse, StoreLocatorSearchParams, VariantLocation, VariantLocatorSearchParams, _default as useStoreLocator, _default$2 as useStoreVariantById, _default$3 as useStores, _default$1 as useVariantStores };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,40 @@
1
- export { default as useStores } from './composables/useStores';
2
- export { default as useStoreVariantById } from './composables/useStoreVariantById';
3
- export { default as useVariantStores } from './composables/useVariantStores';
4
- export { default as useStoreLocator } from './composables/useStoreLocator';
5
- export { default as useGeocode } from './composables/useGeocode';
6
- export * from './constants/index';
7
- export * from './rpc/index';
8
- export * from './types/index';
9
- //# sourceMappingURL=index.d.ts.map
1
+ import { S as StoreLocationResponse, a as StoreLocatorSearchParams, b as StoreAvailabilityCheck, V as VariantLocation, c as VariantLocatorSearchParams } from './shared/omnichannel-nuxt.9b492196.js';
2
+ export { F as FiltersAddressParams, r as FiltersCoordinatesParams, G as GeoPoint, m as OmnichannelLinks, l as OmnichannelMeta, e as OpeningTimeException, O as OpeningTimeInterval, j as OpeningTimes, k as Store, g as StoreAddress, p as StoreAvailabilityCheckResponse, f as StoreImage, i as StoreItem, h as StoreItemVariant, n as StoreLocation, d as StoreLocatorConfig, o as StoreVariantLocation, q as VariantLocationResponse } from './shared/omnichannel-nuxt.9b492196.js';
3
+ import { ValuesType } from 'utility-types';
4
+
5
+ declare const _default$3: (key?: string) => {
6
+ data: globalThis.ComputedRef<StoreLocationResponse | null>;
7
+ getData: (searchParams: StoreLocatorSearchParams) => Promise<void>;
8
+ };
9
+
10
+ declare const _default$2: (key?: string) => {
11
+ data: globalThis.ComputedRef<StoreAvailabilityCheck | null>;
12
+ getData: (variantId: number, storeId: number) => Promise<void>;
13
+ };
14
+
15
+ declare const _default$1: (key?: string) => {
16
+ data: globalThis.ComputedRef<VariantLocation | null>;
17
+ getData: (searchParams: VariantLocatorSearchParams) => Promise<void>;
18
+ };
19
+
20
+ declare const _default: (key?: string) => {
21
+ storesData: globalThis.ComputedRef<StoreLocationResponse | null>;
22
+ refreshStores: (searchParams: StoreLocatorSearchParams) => Promise<void>;
23
+ storeVariantData: globalThis.ComputedRef<StoreAvailabilityCheck | null>;
24
+ refreshStoreVariant: (variantId: number, storeId: number) => Promise<void>;
25
+ variantStoresData: globalThis.ComputedRef<VariantLocation | null>;
26
+ refreshVariantStores: (searchParams: VariantLocatorSearchParams) => Promise<void>;
27
+ };
28
+
29
+ declare const OpeningTime: {
30
+ readonly MONDAY: "mon";
31
+ readonly TUESDAY: "tue";
32
+ readonly WEDNESDAY: "wed";
33
+ readonly THURSDAY: "thu";
34
+ readonly FRIDAY: "fri";
35
+ readonly SATURDAY: "sat";
36
+ readonly SUNDAY: "sun";
37
+ };
38
+ type OpeningTime = ValuesType<typeof OpeningTime>;
39
+
40
+ export { OpeningTime, StoreAvailabilityCheck, StoreLocationResponse, StoreLocatorSearchParams, VariantLocation, VariantLocatorSearchParams, _default as useStoreLocator, _default$2 as useStoreVariantById, _default$3 as useStores, _default$1 as useVariantStores };
package/dist/index.mjs ADDED
@@ -0,0 +1,96 @@
1
+ import { useContext, ssrRef, computed } from '@nuxtjs/composition-api';
2
+
3
+ function sharedRef(value, key) {
4
+ const context = useContext();
5
+ const { $sharedRefsMap } = context;
6
+ if ($sharedRefsMap.has(key)) {
7
+ return $sharedRefsMap.get(key);
8
+ }
9
+ const newRef = ssrRef(value, key);
10
+ $sharedRefsMap.set(key, newRef);
11
+ return newRef;
12
+ }
13
+
14
+ const useStores = (key = "useStores") => {
15
+ const response = sharedRef(null, key);
16
+ const getData = async (searchParams) => {
17
+ response.value = await fetch("/api/omnichannel/stores", {
18
+ body: JSON.stringify(searchParams),
19
+ method: "POST",
20
+ headers: {
21
+ "Content-Type": "application/json"
22
+ }
23
+ }).then(async (res) => await res.json());
24
+ };
25
+ return {
26
+ data: computed(() => response.value),
27
+ getData
28
+ };
29
+ };
30
+
31
+ const useStoreVariantById = (key = "useStoreVariantById") => {
32
+ const response = sharedRef(null, key);
33
+ const getData = async (variantId, storeId) => {
34
+ response.value = (await fetch("/api/omnichannel/storeVariantById", {
35
+ body: JSON.stringify({
36
+ storeId,
37
+ variantId
38
+ }),
39
+ method: "POST",
40
+ headers: {
41
+ "Content-Type": "application/json"
42
+ }
43
+ }).then(
44
+ async (res) => await res.json()
45
+ )).data;
46
+ };
47
+ return {
48
+ data: computed(() => response.value),
49
+ getData
50
+ };
51
+ };
52
+
53
+ const useVariantStores = (key = "useVariantStores") => {
54
+ const response = sharedRef(null, key);
55
+ const getData = async (searchParams) => {
56
+ response.value = (await fetch("/api/omnichannel/variantStores", {
57
+ body: JSON.stringify(searchParams),
58
+ method: "POST",
59
+ headers: {
60
+ "Content-Type": "application/json"
61
+ }
62
+ }).then(async (res) => await res.json())).data;
63
+ };
64
+ return {
65
+ data: computed(() => response.value),
66
+ getData
67
+ };
68
+ };
69
+
70
+ const useStoreLocator = (key = "useStoreLocator") => {
71
+ const { data: storesData, getData: refreshStores } = useStores(
72
+ `${key}-stores`
73
+ );
74
+ const { data: variantStoresData, getData: refreshVariantStores } = useVariantStores(`${key}-variant-stores`);
75
+ const { data: storeVariantData, getData: refreshStoreVariant } = useStoreVariantById(`${key}-variant-by-id`);
76
+ return {
77
+ storesData,
78
+ refreshStores,
79
+ storeVariantData,
80
+ refreshStoreVariant,
81
+ variantStoresData,
82
+ refreshVariantStores
83
+ };
84
+ };
85
+
86
+ const OpeningTime = {
87
+ MONDAY: "mon",
88
+ TUESDAY: "tue",
89
+ WEDNESDAY: "wed",
90
+ THURSDAY: "thu",
91
+ FRIDAY: "fri",
92
+ SATURDAY: "sat",
93
+ SUNDAY: "sun"
94
+ };
95
+
96
+ export { OpeningTime, useStoreLocator, useStoreVariantById, useStores, useVariantStores };
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,6 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { d as StoreLocatorConfig } from './shared/omnichannel-nuxt.9b492196.mjs';
3
+
4
+ declare const _default: _nuxt_schema.NuxtModule<StoreLocatorConfig>;
5
+
6
+ export { _default as default };
@@ -0,0 +1,6 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { d as StoreLocatorConfig } from './shared/omnichannel-nuxt.9b492196.js';
3
+
4
+ declare const _default: _nuxt_schema.NuxtModule<StoreLocatorConfig>;
5
+
6
+ export { _default as default };
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "@scayle/omnichannel-nuxt",
3
+ "version": "1.1.19"
4
+ }
@@ -0,0 +1,36 @@
1
+ import { defineNuxtModule, isNuxt2, createResolver, addServerHandler, addImportsDir } from '@nuxt/kit';
2
+
3
+ const module = defineNuxtModule({
4
+ meta: {},
5
+ async setup(moduleOptions, nuxt) {
6
+ if (isNuxt2()) {
7
+ const createOmnichannelHandler = await import('./chunks/createOmnichannelHandler.mjs');
8
+ nuxt.options.serverMiddleware.push({
9
+ route: "/api/omnichannel",
10
+ handler: createOmnichannelHandler.default(moduleOptions)
11
+ });
12
+ } else {
13
+ const { resolve } = createResolver(import.meta.url);
14
+ addServerHandler({
15
+ route: `/api/omnichannel/**`,
16
+ handler: resolve("./runtime/handler"),
17
+ method: "post"
18
+ });
19
+ nuxt.hooks.hook("nitro:config", (nitroConfig) => {
20
+ nitroConfig.externals = nitroConfig.externals || {};
21
+ nitroConfig.externals.inline = nitroConfig.externals.inline || [];
22
+ nitroConfig.externals.inline.push(resolve("./runtime/rpc/storeLocator"));
23
+ nitroConfig.externals.inline.push(resolve("./runtime/lib/init"));
24
+ nitroConfig.externals.inline.push(
25
+ resolve("./runtime/error/errorHandler")
26
+ );
27
+ nitroConfig.externals.inline.push(
28
+ resolve("./runtime/constants/httpStatus")
29
+ );
30
+ });
31
+ addImportsDir(resolve("runtime/composables"));
32
+ }
33
+ }
34
+ });
35
+
36
+ export { module as default };
@@ -0,0 +1,9 @@
1
+ declare const _default: (key?: string) => {
2
+ storesData: any;
3
+ refreshStores: (searchParams: import("../../types").StoreLocatorSearchParams) => Promise<void>;
4
+ storeVariantData: any;
5
+ refreshStoreVariant: (variantId: number, storeId: number) => Promise<void>;
6
+ variantStoresData: any;
7
+ refreshVariantStores: (searchParams: import("../../types").VariantLocatorSearchParams) => Promise<void>;
8
+ };
9
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import useStoreVariantById from "./useStoreVariantById.mjs";
2
+ import useStores from "./useStores.mjs";
3
+ import useVariantStores from "./useVariantStores.mjs";
4
+ export default (key = "useStoreLocator") => {
5
+ const { data: storesData, getData: refreshStores } = useStores(
6
+ `${key}-stores`
7
+ );
8
+ const { data: variantStoresData, getData: refreshVariantStores } = useVariantStores(`${key}-variant-stores`);
9
+ const { data: storeVariantData, getData: refreshStoreVariant } = useStoreVariantById(`${key}-variant-by-id`);
10
+ return {
11
+ storesData,
12
+ refreshStores,
13
+ storeVariantData,
14
+ refreshStoreVariant,
15
+ variantStoresData,
16
+ refreshVariantStores
17
+ };
18
+ };
@@ -1,6 +1,5 @@
1
1
  declare const _default: (key?: string) => {
2
- data: import("@nuxtjs/composition-api").ComputedRef<any>;
2
+ data: any;
3
3
  getData: (variantId: number, storeId: number) => Promise<void>;
4
4
  };
5
5
  export default _default;
6
- //# sourceMappingURL=useStoreVariantById.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { computed, useState } from "#imports";
2
+ export default (key = "useStoreVariantById") => {
3
+ const response = useState(key, () => null);
4
+ const getData = async (variantId, storeId) => {
5
+ response.value = (await $fetch(
6
+ "/api/omnichannel/storeVariantById",
7
+ {
8
+ body: {
9
+ storeId,
10
+ variantId
11
+ },
12
+ method: "POST"
13
+ }
14
+ )).data;
15
+ };
16
+ return {
17
+ data: computed(() => response.value),
18
+ getData
19
+ };
20
+ };
@@ -0,0 +1,6 @@
1
+ import type { StoreLocatorSearchParams } from '../../types';
2
+ declare const _default: (key?: string) => {
3
+ data: any;
4
+ getData: (searchParams: StoreLocatorSearchParams) => Promise<void>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { useState, computed } from "#imports";
2
+ export default (key = "useStores") => {
3
+ const response = useState(key, () => null);
4
+ const getData = async (searchParams) => {
5
+ response.value = await $fetch(
6
+ "/api/omnichannel/stores",
7
+ { body: searchParams, method: "POST" }
8
+ );
9
+ };
10
+ return {
11
+ data: computed(() => response.value?.data),
12
+ getData
13
+ };
14
+ };
@@ -0,0 +1,6 @@
1
+ import type { VariantLocatorSearchParams } from '../../types';
2
+ declare const _default: (key?: string) => {
3
+ data: any;
4
+ getData: (searchParams: VariantLocatorSearchParams) => Promise<void>;
5
+ };
6
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { useState, computed } from "#imports";
2
+ export default (key = "useVariantStores") => {
3
+ const response = useState(key, () => null);
4
+ const getData = async (searchParams) => {
5
+ response.value = (await $fetch("/api/omnichannel/variantStores", {
6
+ body: searchParams,
7
+ method: "POST"
8
+ })).data;
9
+ };
10
+ return {
11
+ data: computed(() => response.value),
12
+ getData
13
+ };
14
+ };