Initial Commit

This commit is contained in:
2023-07-10 10:17:17 +07:00
commit 48d1d02925
81 changed files with 24380 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
/**
* `sdk-connector` for Vue Storefront 2 integration bolierplate.
*
* @remarks
* In here you can find all references to the integration SDK connector.
*
* @packageDocumentation
*/
export * from './types';
export * from './methods';
+3
View File
@@ -0,0 +1,3 @@
import axios from 'axios';
export const client = axios.create();
+17
View File
@@ -0,0 +1,17 @@
import { client } from './client';
import { Options } from './types';
import * as methods from './methods/index';
/**
* Connector methods.
*/
type Methods = typeof methods;
/**
* Initialize the Boilerplate connector.
*/
export const boilerplateConnector = (options: Options): Methods => {
client.defaults.baseURL = options.apiUrl;
return methods;
};
+28
View File
@@ -0,0 +1,28 @@
import { boilerplateConnector } from './connector';
import type { Options } from './types';
import type { Module } from '@vue-storefront/sdk';
/**
* Boulerplate module type.
*/
export interface BoilerplateModuleType extends Module {
/**
* The connector of the Boilerplate module.
*/
connector: ReturnType<typeof boilerplateConnector>;
}
/**
* Boilerplate module.
*/
export const boilerplateModule = (options: Options): BoilerplateModuleType => ({
connector: boilerplateConnector({
apiUrl: options.apiUrl,
}),
utils: {},
subscribers: {},
});
export { client } from './client';
export * from './types';
@@ -0,0 +1,26 @@
import { client } from '../../client';
import { TODO } from '../../types';
/**
* Method summary - General information about the SDK method, usually a single sentence.
*
* @remarks
* In this section, we have been adding detailed information such as:
* * what API middleware endpoint this method is calling,
* * what SAP OCC API endpoints are being called as a result of using this method,
* * when this method can be used and when it cant (e.g. logged-in vs anonymous users),
* * simply everything what helps with understanding how it works.
*
* @param props
* Just like our API methods, our SDK connector methods accept a single props parameter which carries relevant sub-properties. Therefore, there isnt much to be described within that TSDoc section.
*
* @returns
* Human-friendly information what the SDK methods returns.
*
* @example
* A short code snippet showing how to use the method. Usually we have more than one @example. We should strive for adding as many examples as possible here, with multiple param configurations.
*/
export async function exampleMethod(props: TODO) {
const { data } = await client.post<TODO>('exampleEndpoint', props);
return data
}
@@ -0,0 +1,26 @@
import { client } from '../../client';
import { TODO } from '../../types';
/**
* Method summary - General information about the SDK method, usually a single sentence.
*
* @remarks
* In this section, we have been adding detailed information such as:
* * what API middleware endpoint this method is calling,
* * what SAP OCC API endpoints are being called as a result of using this method,
* * when this method can be used and when it cant (e.g. logged-in vs anonymous users),
* * simply everything what helps with understanding how it works.
*
* @param props
* Just like our API methods, our SDK connector methods accept a single props parameter which carries relevant sub-properties. Therefore, there isnt much to be described within that TSDoc section.
*
* @returns
* Human-friendly information what the SDK methods returns.
*
* @example
* A short code snippet showing how to use the method. Usually we have more than one @example. We should strive for adding as many examples as possible here, with multiple param configurations.
*/
export async function getProducts(props: TODO) {
const { data } = await client.post<TODO>('getProducts', props);
return data
}
+3
View File
@@ -0,0 +1,3 @@
export { exampleMethod } from './exampleMethod';
export { getProducts } from './getProducts';
+18
View File
@@ -0,0 +1,18 @@
import { AxiosRequestConfig } from 'axios';
/**
* Definition of the MethodOptions parameter.
*/
export interface MethodOptions {
/**
* {@link https://axios-http.com/docs/req_config | AxiosRequestConfig} object
* You can use it to override Axios request configuration
*/
axiosRequestConfig?: Readonly<AxiosRequestConfig>;
/**
* Additional optional fields. Its usage depends on the custom implementation.
*/
[key: string]: any;
}
+4
View File
@@ -0,0 +1,4 @@
export type TODO = any;
export type { MethodOptions } from './MethodOptions';
export type { Options } from './options';
+9
View File
@@ -0,0 +1,9 @@
/**
* Options for the SDK module.
*/
export interface Options {
/**
* The API URL of the client-side environment.
*/
apiUrl: string;
}