@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.
- package/CHANGELOG.md +34 -0
- package/README.md +23 -35
- package/dist/chunks/createOmnichannelHandler.mjs +790 -0
- package/dist/index.d.mts +40 -0
- package/dist/index.d.ts +40 -9
- package/dist/index.mjs +96 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +6 -0
- package/dist/module.d.ts +6 -0
- package/dist/module.json +4 -0
- package/dist/module.mjs +36 -0
- package/dist/runtime/composables/useStoreLocator.d.ts +9 -0
- package/dist/runtime/composables/useStoreLocator.mjs +18 -0
- package/dist/{composables → runtime/composables}/useStoreVariantById.d.ts +1 -2
- package/dist/runtime/composables/useStoreVariantById.mjs +20 -0
- package/dist/runtime/composables/useStores.d.ts +6 -0
- package/dist/runtime/composables/useStores.mjs +14 -0
- package/dist/runtime/composables/useVariantStores.d.ts +6 -0
- package/dist/runtime/composables/useVariantStores.mjs +14 -0
- package/dist/runtime/constants/httpStatus.d.ts +632 -0
- package/dist/runtime/constants/httpStatus.mjs +629 -0
- package/dist/runtime/constants/index.d.ts +1 -0
- package/dist/runtime/constants/index.mjs +1 -0
- package/dist/runtime/error/errorHandler.d.ts +7 -0
- package/dist/runtime/error/errorHandler.mjs +20 -0
- package/dist/runtime/handler.d.ts +2 -0
- package/dist/runtime/handler.mjs +48 -0
- package/dist/runtime/lib/init.d.ts +26 -0
- package/dist/runtime/lib/init.mjs +72 -0
- package/dist/{rpc → runtime/rpc}/storeLocator.d.ts +4 -11
- package/dist/runtime/rpc/storeLocator.mjs +32 -0
- package/dist/{types/omnichannel.d.ts → shared/omnichannel-nuxt.9b492196.d.mts} +25 -24
- package/dist/shared/omnichannel-nuxt.9b492196.d.ts +146 -0
- package/dist/types.d.mts +8 -0
- package/dist/types.d.ts +8 -0
- package/package.json +44 -20
- package/dist/composables/sharedRef.d.ts +0 -3
- package/dist/composables/sharedRef.d.ts.map +0 -1
- package/dist/composables/sharedRef.js +0 -16
- package/dist/composables/sharedRef.js.map +0 -1
- package/dist/composables/useGeocode.d.ts +0 -7
- package/dist/composables/useGeocode.d.ts.map +0 -1
- package/dist/composables/useGeocode.js +0 -17
- package/dist/composables/useGeocode.js.map +0 -1
- package/dist/composables/useStoreLocator.d.ts +0 -10
- package/dist/composables/useStoreLocator.d.ts.map +0 -1
- package/dist/composables/useStoreLocator.js +0 -17
- package/dist/composables/useStoreLocator.js.map +0 -1
- package/dist/composables/useStoreVariantById.d.ts.map +0 -1
- package/dist/composables/useStoreVariantById.js +0 -20
- package/dist/composables/useStoreVariantById.js.map +0 -1
- package/dist/composables/useStores.d.ts +0 -7
- package/dist/composables/useStores.d.ts.map +0 -1
- package/dist/composables/useStores.js +0 -17
- package/dist/composables/useStores.js.map +0 -1
- package/dist/composables/useVariantStores.d.ts +0 -7
- package/dist/composables/useVariantStores.d.ts.map +0 -1
- package/dist/composables/useVariantStores.js +0 -17
- package/dist/composables/useVariantStores.js.map +0 -1
- package/dist/constants/index.d.ts +0 -2
- package/dist/constants/index.d.ts.map +0 -1
- package/dist/constants/index.js +0 -5
- package/dist/constants/index.js.map +0 -1
- package/dist/constants/omnichannel.d.ts +0 -12
- package/dist/constants/omnichannel.d.ts.map +0 -1
- package/dist/constants/omnichannel.js +0 -13
- package/dist/constants/omnichannel.js.map +0 -1
- package/dist/error/errorHandler.d.ts +0 -11
- package/dist/error/errorHandler.d.ts.map +0 -1
- package/dist/error/errorHandler.js +0 -57
- package/dist/error/errorHandler.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -18
- package/dist/index.js.map +0 -1
- package/dist/lib/init.d.ts +0 -11
- package/dist/lib/init.d.ts.map +0 -1
- package/dist/lib/init.js +0 -49
- package/dist/lib/init.js.map +0 -1
- package/dist/module/createOmnichannelHandler.d.ts +0 -3
- package/dist/module/createOmnichannelHandler.d.ts.map +0 -1
- package/dist/module/createOmnichannelHandler.js +0 -56
- package/dist/module/createOmnichannelHandler.js.map +0 -1
- package/dist/module/register.d.ts +0 -6
- package/dist/module/register.d.ts.map +0 -1
- package/dist/module/register.js +0 -12
- package/dist/module/register.js.map +0 -1
- package/dist/rpc/geocode.d.ts +0 -23
- package/dist/rpc/geocode.d.ts.map +0 -1
- package/dist/rpc/geocode.js +0 -46
- package/dist/rpc/geocode.js.map +0 -1
- package/dist/rpc/index.d.ts +0 -3
- package/dist/rpc/index.d.ts.map +0 -1
- package/dist/rpc/index.js +0 -6
- package/dist/rpc/index.js.map +0 -1
- package/dist/rpc/storeLocator.d.ts.map +0 -1
- package/dist/rpc/storeLocator.js +0 -69
- package/dist/rpc/storeLocator.js.map +0 -1
- package/dist/types/geocode.d.ts +0 -8
- package/dist/types/geocode.d.ts.map +0 -1
- package/dist/types/geocode.js +0 -3
- package/dist/types/geocode.js.map +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -6
- package/dist/types/index.js.map +0 -1
- package/dist/types/omnichannel.d.ts.map +0 -1
- package/dist/types/omnichannel.js +0 -3
- 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 {
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
1
|
+
interface StoreLocatorConfig {
|
|
2
2
|
token: string;
|
|
3
3
|
host: string;
|
|
4
4
|
companyId?: number;
|
|
5
5
|
googleApiKey?: string;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
interface GeoPoint {
|
|
8
8
|
lat: number;
|
|
9
9
|
lng: number;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
interface OpeningTimeInterval {
|
|
12
12
|
timeFrom: string;
|
|
13
13
|
timeUntil: string;
|
|
14
14
|
}
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
+
interface StoreItemVariant {
|
|
37
37
|
variantId: number;
|
|
38
38
|
variantReferenceKey: string;
|
|
39
39
|
quantity: number;
|
|
40
40
|
}
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
95
|
+
interface StoreLocation extends Store {
|
|
96
96
|
distance: number;
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
interface StoreLocationResponse {
|
|
99
99
|
data: StoreLocation[];
|
|
100
100
|
meta: {
|
|
101
101
|
searchAddress: GeoPoint;
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
interface StoreVariantLocation extends StoreLocation {
|
|
105
105
|
quantity: number;
|
|
106
106
|
}
|
|
107
|
-
|
|
107
|
+
interface StoreAvailabilityCheck extends Store {
|
|
108
108
|
items: StoreItem[];
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
interface StoreAvailabilityCheckResponse {
|
|
111
111
|
data: StoreAvailabilityCheck;
|
|
112
112
|
meta: OmnichannelMeta;
|
|
113
113
|
}
|
|
114
|
-
|
|
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
|
-
|
|
124
|
+
interface VariantLocationResponse {
|
|
125
125
|
data: VariantLocation;
|
|
126
126
|
meta: OmnichannelMeta;
|
|
127
127
|
}
|
|
128
|
-
|
|
128
|
+
interface FiltersAddressParams {
|
|
129
129
|
address: string;
|
|
130
130
|
radius: number;
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
interface FiltersCoordinatesParams {
|
|
133
133
|
geoPoint: GeoPoint;
|
|
134
134
|
radius: number;
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
interface StoreLocatorSearchParams {
|
|
137
137
|
filters: FiltersAddressParams | FiltersCoordinatesParams;
|
|
138
138
|
perPage?: number;
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
interface VariantLocatorSearchParams {
|
|
141
141
|
variantId: number;
|
|
142
142
|
filters: FiltersAddressParams | FiltersCoordinatesParams;
|
|
143
143
|
perPage?: number;
|
|
144
144
|
}
|
|
145
|
-
|
|
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 };
|
package/dist/types.d.mts
ADDED
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/omnichannel-nuxt",
|
|
3
|
-
"version": "
|
|
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
|
-
"
|
|
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": "
|
|
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,33 +53,34 @@
|
|
|
30
53
|
},
|
|
31
54
|
"peerDependencies": {
|
|
32
55
|
"@nuxtjs/composition-api": "0.33.1",
|
|
33
|
-
"
|
|
56
|
+
"express": "4.18.2"
|
|
34
57
|
},
|
|
35
58
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@scayle/storefront-core": "7.24.0",
|
|
38
|
-
"axios": "0.27.2",
|
|
59
|
+
"@nuxt/kit": "^3.9.3",
|
|
39
60
|
"body-parser": "1.20.2",
|
|
40
|
-
"express": "4.18.2",
|
|
41
61
|
"qs": "6.11.2",
|
|
42
|
-
"utility-types": "3.
|
|
62
|
+
"utility-types": "3.11.0"
|
|
43
63
|
},
|
|
44
64
|
"devDependencies": {
|
|
65
|
+
"@nuxt/module-builder": "0.5.5",
|
|
66
|
+
"@nuxt/schema": "3.9.3",
|
|
45
67
|
"@nuxt/types": "2.17.1",
|
|
46
|
-
"@
|
|
68
|
+
"@nuxtjs/composition-api": "0.33.1",
|
|
69
|
+
"@scayle/eslint-config-storefront": "3.2.6",
|
|
47
70
|
"@scayle/prettier-config-storefront": "2.0.2",
|
|
48
|
-
"@types/body-parser": "1.19.
|
|
49
|
-
"@types/express": "4.17.
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"
|
|
53
|
-
"eslint": "
|
|
54
|
-
"
|
|
71
|
+
"@types/body-parser": "1.19.5",
|
|
72
|
+
"@types/express": "4.17.21",
|
|
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",
|
|
55
79
|
"prettier": "3.0.0",
|
|
56
|
-
"typescript": "5.
|
|
57
|
-
"vue": "2.7.
|
|
80
|
+
"typescript": "5.3.3",
|
|
81
|
+
"vue": "2.7.16"
|
|
58
82
|
},
|
|
59
83
|
"volta": {
|
|
60
|
-
"node": "20.
|
|
84
|
+
"node": "20.11.0"
|
|
61
85
|
}
|
|
62
86
|
}
|
|
@@ -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"}
|