@blackfisk/blackfisk-vue-storefront-api 1.0.2
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/lib/api/exampleEndpoint/index.d.ts +3 -0
- package/lib/api/exampleEndpoint/index.d.ts.map +1 -0
- package/lib/api/getPageContent/index.d.ts +15 -0
- package/lib/api/getPageContent/index.d.ts.map +1 -0
- package/lib/api/getProductCollection/index.d.ts +12 -0
- package/lib/api/getProductCollection/index.d.ts.map +1 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/index.cjs.js +2 -0
- package/lib/index.cjs.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.es.js +2 -0
- package/lib/index.es.js.map +1 -0
- package/lib/index.server.d.ts +3 -0
- package/lib/index.server.d.ts.map +1 -0
- package/lib/types/api/endpoints.d.ts +16 -0
- package/lib/types/api/endpoints.d.ts.map +1 -0
- package/lib/types/api/index.d.ts +2 -0
- package/lib/types/api/index.d.ts.map +1 -0
- package/lib/types/config/index.d.ts +15 -0
- package/lib/types/config/index.d.ts.map +1 -0
- package/lib/types/context/index.d.ts +14 -0
- package/lib/types/context/index.d.ts.map +1 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.d.ts.map +1 -0
- package/package.json +32 -0
- package/server/api/exampleEndpoint/index.d.ts +3 -0
- package/server/api/exampleEndpoint/index.d.ts.map +1 -0
- package/server/api/getPageContent/index.d.ts +15 -0
- package/server/api/getPageContent/index.d.ts.map +1 -0
- package/server/api/getProductCollection/index.d.ts +12 -0
- package/server/api/getProductCollection/index.d.ts.map +1 -0
- package/server/api/index.d.ts +4 -0
- package/server/api/index.d.ts.map +1 -0
- package/server/index.d.ts +10 -0
- package/server/index.d.ts.map +1 -0
- package/server/index.js +100 -0
- package/server/index.js.map +1 -0
- package/server/index.server.d.ts +3 -0
- package/server/index.server.d.ts.map +1 -0
- package/server/types/api/endpoints.d.ts +16 -0
- package/server/types/api/endpoints.d.ts.map +1 -0
- package/server/types/api/index.d.ts +2 -0
- package/server/types/api/index.d.ts.map +1 -0
- package/server/types/config/index.d.ts +15 -0
- package/server/types/config/index.d.ts.map +1 -0
- package/server/types/context/index.d.ts +14 -0
- package/server/types/context/index.d.ts.map +1 -0
- package/server/types/index.d.ts +12 -0
- package/server/types/index.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/exampleEndpoint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,iBAAiB,CASxD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Endpoints } from '../../types';
|
|
2
|
+
export interface getPageContentParams {
|
|
3
|
+
typeId: number;
|
|
4
|
+
referenceId: string;
|
|
5
|
+
collectionId: number;
|
|
6
|
+
slug: string;
|
|
7
|
+
}
|
|
8
|
+
export interface getPageContentResponse {
|
|
9
|
+
data: {
|
|
10
|
+
content: {};
|
|
11
|
+
meta: {};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const getPageContent: Endpoints['getPageContent'];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/getPageContent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,EAAE,EAAE,CAAC;KACV,CAAC;CACH;AACD,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,gBAAgB,CAkBtD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Endpoints } from '../../types';
|
|
2
|
+
export interface getProductCollectionParams {
|
|
3
|
+
collectionId: number | string;
|
|
4
|
+
}
|
|
5
|
+
export interface getProductCollectionResponse {
|
|
6
|
+
data: {
|
|
7
|
+
content: {};
|
|
8
|
+
meta: {};
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare const getProductCollection: Endpoints['getProductCollection'];
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/getProductCollection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AACD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,EAAE,EAAE,CAAC;KACV,CAAC;CACH;AACD,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAAC,sBAAsB,CAqBlE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/lib/index.cjs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC"}
|
package/lib/index.es.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":"AAsCA,QAAA,MAAQ,eAAe,kEAGrB,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BfskIntegrationContext, TODO } from '..';
|
|
2
|
+
import { getPageContentParams, getPageContentResponse } from '../../api/getPageContent/index';
|
|
3
|
+
import { getProductCollectionParams, getProductCollectionResponse } from '../../api/getProductCollection/index';
|
|
4
|
+
/**
|
|
5
|
+
* Definition of all API-client methods available in {@link https://docs.vuestorefront.io/v2/advanced/context.html#context-api | context}.
|
|
6
|
+
*/
|
|
7
|
+
export interface Endpoints {
|
|
8
|
+
/**
|
|
9
|
+
* Here you can find an example endpoint definition. Based on this example, you should define how your endpoint will look like.
|
|
10
|
+
* This description will appear in the API extractor, so try to document all endpoints added here.
|
|
11
|
+
*/
|
|
12
|
+
exampleEndpoint(context: BfskIntegrationContext, params: TODO): Promise<TODO>;
|
|
13
|
+
getPageContent(context: BfskIntegrationContext, params: getPageContentParams): Promise<getPageContentResponse>;
|
|
14
|
+
getProductCollection(context: BfskIntegrationContext, params: getProductCollectionParams): Promise<getProductCollectionResponse>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/types/api/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AAE/G;;GAEG;AACH,MAAM,WAAW,SAAS;IAExB;;;OAGG;IACH,eAAe,CACb,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,IAAI,GACX,OAAO,CAAC,IAAI,CAAC,CAAC;IACf,cAAc,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/G,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACpI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings to be provided in the `middleware.config.js` file.
|
|
3
|
+
*/
|
|
4
|
+
interface ApiMiddlewareConfig {
|
|
5
|
+
url: string;
|
|
6
|
+
auth_jwt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MiddlewareConfig {
|
|
9
|
+
accountId: number;
|
|
10
|
+
channelId: number;
|
|
11
|
+
accountSiteId: number;
|
|
12
|
+
api: ApiMiddlewareConfig;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,mBAAmB,CAAC;CAC1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IntegrationContext } from '@vue-storefront/middleware';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import { MiddlewareConfig, ContextualizedEndpoints } from '../index';
|
|
4
|
+
/**
|
|
5
|
+
* Runtime integration context, which includes API client instance, settings, and endpoints that will be passed via middleware server.
|
|
6
|
+
**/
|
|
7
|
+
export declare type BfskIntegrationContext = IntegrationContext<AxiosInstance, MiddlewareConfig, ContextualizedEndpoints>;
|
|
8
|
+
/**
|
|
9
|
+
* Global context of the application which includes runtime integration context.
|
|
10
|
+
**/
|
|
11
|
+
export interface Context {
|
|
12
|
+
$bfsk: BfskIntegrationContext;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAErE;;IAEI;AACJ,oBAAY,sBAAsB,GAAG,kBAAkB,CACrD,aAAa,EACb,gBAAgB,EAChB,uBAAuB,CACxB,CAAC;AAEF;;IAEI;AACJ,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,sBAAsB,CAAC;CAC/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Endpoints } from './api';
|
|
2
|
+
/**
|
|
3
|
+
* All available API Endpoints without first argument - `context`, because this prop is set automatically.
|
|
4
|
+
*/
|
|
5
|
+
export declare type ContextualizedEndpoints = {
|
|
6
|
+
[T in keyof Endpoints]: Endpoints[T] extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
7
|
+
};
|
|
8
|
+
export declare type TODO = any;
|
|
9
|
+
export * from './api';
|
|
10
|
+
export * from './config';
|
|
11
|
+
export * from './context';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;GAEG;AACH,oBAAY,uBAAuB,GAAG;KACnC,CAAC,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAC,EAAE,GAAG,EACN,GAAG,IAAI,EAAE,MAAM,CAAC,KACb,MAAM,CAAC,GACR,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACjB,KAAK;CACV,CAAC;AAEF,oBAAY,IAAI,GAAG,GAAG,CAAC;AAEvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@blackfisk/blackfisk-vue-storefront-api",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"server": "server/index.js",
|
|
6
|
+
"main": "lib/index.cjs.js",
|
|
7
|
+
"module": "lib/index.es.js",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
9
|
+
"license": "VSFEL",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=16.x"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "rimraf lib server && rollup -c",
|
|
15
|
+
"dev": "rollup -c -w",
|
|
16
|
+
"test": "cross-env APP_ENV=test jest",
|
|
17
|
+
"prepublish": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@vue-storefront/middleware": "3.0.0-rc.2",
|
|
21
|
+
"axios": "^0.21.1",
|
|
22
|
+
"consola": "^3.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"jsdom": "^17.0.0"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"lib/**/*",
|
|
29
|
+
"server/**/*"
|
|
30
|
+
],
|
|
31
|
+
"gitHead": "90beb5104539291e597a9e1ca339c7ec8fa54c46"
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/exampleEndpoint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,iBAAiB,CASxD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Endpoints } from '../../types';
|
|
2
|
+
export interface getPageContentParams {
|
|
3
|
+
typeId: number;
|
|
4
|
+
referenceId: string;
|
|
5
|
+
collectionId: number;
|
|
6
|
+
slug: string;
|
|
7
|
+
}
|
|
8
|
+
export interface getPageContentResponse {
|
|
9
|
+
data: {
|
|
10
|
+
content: {};
|
|
11
|
+
meta: {};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare const getPageContent: Endpoints['getPageContent'];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/getPageContent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,EAAE,EAAE,CAAC;KACV,CAAC;CACH;AACD,eAAO,MAAM,cAAc,EAAE,SAAS,CAAC,gBAAgB,CAkBtD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Endpoints } from '../../types';
|
|
2
|
+
export interface getProductCollectionParams {
|
|
3
|
+
collectionId: number | string;
|
|
4
|
+
}
|
|
5
|
+
export interface getProductCollectionResponse {
|
|
6
|
+
data: {
|
|
7
|
+
content: {};
|
|
8
|
+
meta: {};
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare const getProductCollection: Endpoints['getProductCollection'];
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/getProductCollection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AACD,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE,CAAC;QACZ,IAAI,EAAE,EAAE,CAAC;KACV,CAAC;CACH;AACD,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAAC,sBAAsB,CAqBlE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,SAAS,CAAC"}
|
package/server/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var axios = require('axios');
|
|
6
|
+
var middleware = require('@vue-storefront/middleware');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
11
|
+
|
|
12
|
+
const exampleEndpoint = async (context, params) => {
|
|
13
|
+
console.log('exampleEndpoint has been called');
|
|
14
|
+
// Example request could look like this:
|
|
15
|
+
// return await context.client.get(`example-url?id=${params.id}`);
|
|
16
|
+
return { data: 'Hello, Vue Storefront Integrator!' };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getPageContent = async (context, params) => {
|
|
20
|
+
console.log('getPageContent has been called. It\'s now updated.');
|
|
21
|
+
const RequestURL = new URL('v2/vsf/cms/pageContent', context.config.api.url);
|
|
22
|
+
for (const param in params) {
|
|
23
|
+
RequestURL.searchParams.set(param, params[param]);
|
|
24
|
+
}
|
|
25
|
+
console.log({ RequestURL });
|
|
26
|
+
const { data, status } = await context.client.request({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
url: RequestURL.href,
|
|
29
|
+
});
|
|
30
|
+
console.log({ status, PageContentResponse: data });
|
|
31
|
+
const PageContent = data?.data?.[0] ?? {};
|
|
32
|
+
console.log({ PageContent });
|
|
33
|
+
return { data: PageContent };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getProductCollection = async (context, params) => {
|
|
37
|
+
console.log('getProductCollection has been called. It\'s now updated.');
|
|
38
|
+
const RequestURL = new URL('v2/vsf/productCollection', context.config.api.url);
|
|
39
|
+
if (!('collectionId' in params)) {
|
|
40
|
+
params['collectionId'] = 145;
|
|
41
|
+
}
|
|
42
|
+
for (const param in params) {
|
|
43
|
+
RequestURL.searchParams.set(param, params[param]);
|
|
44
|
+
}
|
|
45
|
+
console.log({ RequestURL });
|
|
46
|
+
const { data, status } = await context.client.request({
|
|
47
|
+
method: 'GET',
|
|
48
|
+
url: RequestURL.href,
|
|
49
|
+
});
|
|
50
|
+
console.log({ status, PageContentResponse: data });
|
|
51
|
+
const PageContent = data?.data?.[0] ?? {};
|
|
52
|
+
console.log({ PageContent });
|
|
53
|
+
return { data: PageContent };
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var apiEndpoints = /*#__PURE__*/Object.freeze({
|
|
57
|
+
__proto__: null,
|
|
58
|
+
exampleEndpoint: exampleEndpoint,
|
|
59
|
+
getPageContent: getPageContent,
|
|
60
|
+
getProductCollection: getProductCollection
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* In here you should create the client you'll use to communicate with the backend.
|
|
65
|
+
* Axios is just an example.
|
|
66
|
+
*/
|
|
67
|
+
const buildClient = (settings) => {
|
|
68
|
+
const defaultSettings = {
|
|
69
|
+
accountId: 0,
|
|
70
|
+
channelId: 0,
|
|
71
|
+
accountSiteId: 0,
|
|
72
|
+
baseURL: '',
|
|
73
|
+
};
|
|
74
|
+
const axiosInstance = axios__default["default"].create({
|
|
75
|
+
baseURL: settings.api.url || defaultSettings.baseURL,
|
|
76
|
+
// baseURL: settings.api.url,
|
|
77
|
+
headers: {
|
|
78
|
+
'X-Account-Id': settings.accountId || defaultSettings.accountId,
|
|
79
|
+
'X-Channel-Id': settings.channelId || defaultSettings.channelId,
|
|
80
|
+
'X-Site-Id': settings.accountSiteId || defaultSettings.accountSiteId,
|
|
81
|
+
authorization: `${settings.api.auth_jwt || process.env.SECURITY_TOKEN || ''}`
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
return axiosInstance;
|
|
85
|
+
};
|
|
86
|
+
const onCreate = (settings) => {
|
|
87
|
+
console.log({ settings });
|
|
88
|
+
const client = buildClient(settings);
|
|
89
|
+
return {
|
|
90
|
+
config: settings,
|
|
91
|
+
client
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
const { createApiClient } = middleware.apiClientFactory({
|
|
95
|
+
onCreate,
|
|
96
|
+
api: apiEndpoints,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
exports.createApiClient = createApiClient;
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/api/exampleEndpoint/index.ts","../src/api/getPageContent/index.ts","../src/api/getProductCollection/index.ts","../src/index.server.ts"],"sourcesContent":["import { Endpoints } from '../../types';\n\nexport const exampleEndpoint: Endpoints['exampleEndpoint'] = async (\n context,\n params\n) => {\n console.log('exampleEndpoint has been called');\n\n // Example request could look like this:\n // return await context.client.get(`example-url?id=${params.id}`);\n return { data: 'Hello, Vue Storefront Integrator!' };\n};\n","import { Endpoints } from '../../types';\nexport interface getPageContentParams {\n typeId: number,\n referenceId: string,\n collectionId: number,\n slug: string,\n}\nexport interface getPageContentResponse {\n data: {\n content: {},\n meta: {},\n },\n}\nexport const getPageContent: Endpoints['getPageContent'] = async (\n context,\n params: getPageContentParams\n) => {\n console.log('getPageContent has been called. It\\'s now updated.');\n const RequestURL = new URL('v2/vsf/cms/pageContent', context.config.api.url);\n for (const param in params) {\n RequestURL.searchParams.set(param, params[param]);\n }\n console.log({RequestURL})\n const { data, status } = await context.client.request({\n method: 'GET',\n url: RequestURL.href,\n })\n console.log({status, PageContentResponse: data})\n const PageContent = data?.data?.[0] ?? {}\n console.log({PageContent})\n return { data: PageContent };\n};\n","import { Endpoints } from '../../types';\nexport interface getProductCollectionParams {\n collectionId: number | string,\n}\nexport interface getProductCollectionResponse {\n data: {\n content: {},\n meta: {},\n },\n}\nexport const getProductCollection: Endpoints['getProductCollection'] = async (\n context,\n params: getProductCollectionParams\n) => {\n console.log('getProductCollection has been called. It\\'s now updated.');\n const RequestURL = new URL('v2/vsf/productCollection', context.config.api.url);\n if (!('collectionId' in params)) {\n params['collectionId'] = 145\n }\n for (const param in params) {\n RequestURL.searchParams.set(param, params[param]);\n }\n console.log({RequestURL})\n const { data, status } = await context.client.request({\n method: 'GET',\n url: RequestURL.href,\n })\n console.log({status, PageContentResponse: data})\n const PageContent = data?.data?.[0] ?? {}\n console.log({PageContent})\n return { data: PageContent };\n};\n","import axios from 'axios';\nimport { apiClientFactory } from '@vue-storefront/middleware';\nimport { MiddlewareConfig } from './index';\nimport * as apiEndpoints from './api';\n\n/**\n * In here you should create the client you'll use to communicate with the backend.\n * Axios is just an example.\n */\nconst buildClient = (settings: MiddlewareConfig) => {\n const defaultSettings = {\n accountId: 0,\n channelId: 0,\n accountSiteId: 0,\n baseURL: '',\n }\n const axiosInstance = axios.create({\n baseURL: settings.api.url || defaultSettings.baseURL,\n // baseURL: settings.api.url,\n headers: {\n 'X-Account-Id': settings.accountId || defaultSettings.accountId,\n 'X-Channel-Id': settings.channelId || defaultSettings.channelId,\n 'X-Site-Id': settings.accountSiteId || defaultSettings.accountSiteId,\n authorization: `${settings.api.auth_jwt || process.env.SECURITY_TOKEN || ''}`\n },\n });\n return axiosInstance\n}\n\nconst onCreate = (settings: MiddlewareConfig) => {\n console.log({settings});\n const client = buildClient(settings);\n return {\n config: settings,\n client\n };\n};\n\nconst { createApiClient } = apiClientFactory<any, any>({\n onCreate,\n api: apiEndpoints,\n});\n\nexport { createApiClient };\n"],"names":["axios","apiClientFactory"],"mappings":";;;;;;;;;;;AAEO,MAAM,eAAe,GAAiC,OAC3D,OAAO,EACP,MAAM,KACJ;AACF,IAAA,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;;;AAI/C,IAAA,O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AQ,CAAC,SAAS,IAAI,eAAe,CAAC,SAAS;AAC/D,YAAA,cAAc,EAAE,QAAQ,CAAC,SAAS,IAAI,eAAe,CAAC,SAAS;AAC/D,YAAA,WAAW,EAAE,QAAQ,CAAC,aAAa,IAAI,eAAe,CAAC,aAAa;AACpE,YAAA,aAAa,EAAE,CAAA,EAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAE,CAAA;AAC9E,SAAA;AACF,KAAA,CAAC,CAAC;AACH,IAAA,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,QAA0B,KAAI;AAC9C,IAAA,OAAO,CAAC,GAAG,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC;AACxB,IAAA,MAAM,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO;AACL,QAAA,MAAM,EAAE,QAAQ;QAChB,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,EAAE,eAAe,EAAE,GAAGC,2BAAgB,CAAW;IACrD,QAAQ;AACR,IAAA,GAAG,EAAE,YAAY;AAClB,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.d.ts","sourceRoot":"","sources":["../src/index.server.ts"],"names":[],"mappings":"AAsCA,QAAA,MAAQ,eAAe,kEAGrB,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BfskIntegrationContext, TODO } from '..';
|
|
2
|
+
import { getPageContentParams, getPageContentResponse } from '../../api/getPageContent/index';
|
|
3
|
+
import { getProductCollectionParams, getProductCollectionResponse } from '../../api/getProductCollection/index';
|
|
4
|
+
/**
|
|
5
|
+
* Definition of all API-client methods available in {@link https://docs.vuestorefront.io/v2/advanced/context.html#context-api | context}.
|
|
6
|
+
*/
|
|
7
|
+
export interface Endpoints {
|
|
8
|
+
/**
|
|
9
|
+
* Here you can find an example endpoint definition. Based on this example, you should define how your endpoint will look like.
|
|
10
|
+
* This description will appear in the API extractor, so try to document all endpoints added here.
|
|
11
|
+
*/
|
|
12
|
+
exampleEndpoint(context: BfskIntegrationContext, params: TODO): Promise<TODO>;
|
|
13
|
+
getPageContent(context: BfskIntegrationContext, params: getPageContentParams): Promise<getPageContentResponse>;
|
|
14
|
+
getProductCollection(context: BfskIntegrationContext, params: getProductCollectionParams): Promise<getProductCollectionResponse>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoints.d.ts","sourceRoot":"","sources":["../../../src/types/api/endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA;AAE/G;;GAEG;AACH,MAAM,WAAW,SAAS;IAExB;;;OAGG;IACH,eAAe,CACb,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,IAAI,GACX,OAAO,CAAC,IAAI,CAAC,CAAC;IACf,cAAc,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/G,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACpI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings to be provided in the `middleware.config.js` file.
|
|
3
|
+
*/
|
|
4
|
+
interface ApiMiddlewareConfig {
|
|
5
|
+
url: string;
|
|
6
|
+
auth_jwt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MiddlewareConfig {
|
|
9
|
+
accountId: number;
|
|
10
|
+
channelId: number;
|
|
11
|
+
accountSiteId: number;
|
|
12
|
+
api: ApiMiddlewareConfig;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/config/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,UAAU,mBAAmB;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,mBAAmB,CAAC;CAC1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IntegrationContext } from '@vue-storefront/middleware';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import { MiddlewareConfig, ContextualizedEndpoints } from '../index';
|
|
4
|
+
/**
|
|
5
|
+
* Runtime integration context, which includes API client instance, settings, and endpoints that will be passed via middleware server.
|
|
6
|
+
**/
|
|
7
|
+
export declare type BfskIntegrationContext = IntegrationContext<AxiosInstance, MiddlewareConfig, ContextualizedEndpoints>;
|
|
8
|
+
/**
|
|
9
|
+
* Global context of the application which includes runtime integration context.
|
|
10
|
+
**/
|
|
11
|
+
export interface Context {
|
|
12
|
+
$bfsk: BfskIntegrationContext;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAErE;;IAEI;AACJ,oBAAY,sBAAsB,GAAG,kBAAkB,CACrD,aAAa,EACb,gBAAgB,EAChB,uBAAuB,CACxB,CAAC;AAEF;;IAEI;AACJ,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,sBAAsB,CAAC;CAC/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Endpoints } from './api';
|
|
2
|
+
/**
|
|
3
|
+
* All available API Endpoints without first argument - `context`, because this prop is set automatically.
|
|
4
|
+
*/
|
|
5
|
+
export declare type ContextualizedEndpoints = {
|
|
6
|
+
[T in keyof Endpoints]: Endpoints[T] extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
7
|
+
};
|
|
8
|
+
export declare type TODO = any;
|
|
9
|
+
export * from './api';
|
|
10
|
+
export * from './config';
|
|
11
|
+
export * from './context';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;GAEG;AACH,oBAAY,uBAAuB,GAAG;KACnC,CAAC,IAAI,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAC,EAAE,GAAG,EACN,GAAG,IAAI,EAAE,MAAM,CAAC,KACb,MAAM,CAAC,GACR,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GACjB,KAAK;CACV,CAAC;AAEF,oBAAY,IAAI,GAAG,GAAG,CAAC;AAEvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
|