Socket
Socket
Sign inDemoInstall

@cloudcommerce/api

Package Overview
Dependencies
Maintainers
1
Versions
406
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudcommerce/api - npm Package Compare versions

Comparing version 0.0.27 to 0.0.28

67

lib/index.js

@@ -16,21 +16,39 @@ // @ts-ignore

middleware(config) {
const headers = { ...config.headers };
if (config.accessToken) {
// eslint-disable-next-line dot-notation
headers['Authorization'] = `Bearer ${config.accessToken}`;
} else if (config.authenticationId && config.apiKey) {
const rawAuth = `${config.authenticationId}:${config.apiKey}`;
const base64Auth = typeof Buffer === 'function'
? Buffer.from(rawAuth).toString('base64') : btoa(rawAuth);
// eslint-disable-next-line dot-notation
headers['Authorization'] = `Basic ${base64Auth}`;
}
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
const storeId = config.storeId || env.ECOM_STORE_ID;
if (!storeId) {
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
const { endpoint, params } = config;
if (endpoint !== 'login'
&& endpoint !== 'authenticate'
&& endpoint !== 'ask-auth-callback'
&& endpoint !== 'check-username') {
const storeId = config.storeId || env.ECOM_STORE_ID;
if (!storeId) {
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
}
url += `/:${storeId}`;
const lang = config.lang || env.ECOM_LANG;
if (lang) {
url += `,lang:${lang}`;
}
}
url += `/:${storeId}`;
const lang = config.lang || env.ECOM_LANG;
if (lang) {
url += `,lang:${lang}`;
}
if (config.params) {
if (typeof config.params === 'string') {
url += `?${config.params}`;
url += `/${endpoint}`;
if (params) {
if (typeof params === 'string') {
url += `?${params}`;
} else {
// https://github.com/microsoft/TypeScript/issues/32951
url += `?${new URLSearchParams(config.params)}`;
url += `?${new URLSearchParams(params)}`;
}
}
return `${url}/${config.endpoint}`;
return { url, headers };
},

@@ -42,6 +60,11 @@ };

const api = async (config, retries = 0) => {
const url = def.middleware(config);
const {
method, headers, timeout = 20000, maxRetries = 3,
} = config;
const { url, headers } = def.middleware(config);
const { method, timeout = 20000, maxRetries = 3 } = config;
const bodyObject = config.body || config.data;
let body;
if (bodyObject) {
body = JSON.stringify(bodyObject);
headers['Content-Type'] = 'application/json';
headers['Content-Length'] = body.length.toString();
}
const abortController = new AbortController();

@@ -58,2 +81,3 @@ let isTimeout = false;

headers,
body,
signal: abortController.signal,

@@ -86,16 +110,19 @@ });

const get = (endpoint, config) => api({ ...config, endpoint });
const post = (endpoint, config) => api({
const post = (endpoint, body, config) => api({
...config,
method: 'post',
endpoint,
body,
});
const put = (endpoint, config) => api({
const put = (endpoint, body, config) => api({
...config,
method: 'put',
endpoint,
body,
});
const patch = (endpoint, config) => api({
const patch = (endpoint, body, config) => api({
...config,
method: 'patch',
endpoint,
body,
});

@@ -102,0 +129,0 @@ const del = (endpoint, config) => api({

@@ -11,3 +11,4 @@ import type { Products } from './types/products';

import type { Applications } from './types/applications';
declare type Resource = 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'carts' | 'orders' | 'customers' | 'stores' | 'applications';
import type { Authentications } from './types/authentications';
declare type Resource = 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'carts' | 'orders' | 'customers' | 'stores' | 'applications' | 'authentications';
declare type ResourceId = string & {

@@ -17,4 +18,5 @@ length: 24;

declare type ResourceAndId = `${Resource}/${ResourceId}`;
declare type ResourceOpQuery = Resource | `${Resource}?${string}`;
declare type EventsEndpoint = `events/${Resource}` | `events/${ResourceAndId}` | 'events/me';
declare type Endpoint = Resource | ResourceAndId | `${ResourceAndId}/${string}` | `slugs/${string}` | 'search/v1' | EventsEndpoint | 'login' | 'authenticate' | 'ask-auth-callback' | 'check-username' | `$aggregate/${Exclude<Resource, 'stores' | 'applications'>}` | `schemas/${Resource}`;
declare type Endpoint = ResourceOpQuery | ResourceAndId | `${ResourceAndId}/${string}` | `slugs/${string}` | 'search/v1' | EventsEndpoint | 'login' | 'authenticate' | 'ask-auth-callback' | 'check-username' | `$aggregate/${Exclude<Resource, 'stores' | 'applications' | 'authentications'>}` | `schemas/${Resource}`;
declare type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';

@@ -24,2 +26,5 @@ declare type Config = {

storeId?: number;
accessToken?: string;
authenticationId?: string;
apiKey?: string;
lang?: string;

@@ -29,3 +34,3 @@ method?: Method;

params?: Record<string, string | number>;
headers?: Record<string, string>;
headers?: Headers | Record<string, string>;
timeout?: number;

@@ -40,4 +45,5 @@ maxRetries?: number;

};
declare type ResourceListResult<TResource extends Resource> = {
result: TResource extends 'products' ? Products[] : TResource extends 'categories' ? Categories[] : TResource extends 'brands' ? Brands[] : TResource extends 'collections' ? Collections[] : TResource extends 'grids' ? Grids[] : TResource extends 'carts' ? Carts[] : TResource extends 'orders' ? Orders[] : TResource extends 'customers' ? Customers[] : TResource extends 'stores' ? Stores[] : TResource extends 'applications' ? Applications[] : never;
declare type ListEndpoint<TResource extends Resource> = TResource | `${TResource}?${string}`;
declare type ResourceListResult<TEndpoint extends ResourceOpQuery> = {
result: TEndpoint extends ListEndpoint<'products'> ? Products[] : TEndpoint extends ListEndpoint<'categories'> ? Categories[] : TEndpoint extends ListEndpoint<'brands'> ? Brands[] : TEndpoint extends ListEndpoint<'collections'> ? Collections[] : TEndpoint extends ListEndpoint<'grids'> ? Grids[] : TEndpoint extends ListEndpoint<'carts'> ? Carts[] : TEndpoint extends ListEndpoint<'orders'> ? Orders[] : TEndpoint extends ListEndpoint<'customers'> ? Customers[] : TEndpoint extends ListEndpoint<'stores'> ? Stores[] : TEndpoint extends ListEndpoint<'applications'> ? Applications[] : TEndpoint extends ListEndpoint<'authentications'> ? Authentications[] : never;
meta: BaseListResultMeta & {

@@ -79,5 +85,16 @@ count?: number;

};
declare type ResponseBody<TConfig extends Config> = TConfig['method'] extends 'post' ? {
declare type ResponseBody<TConfig extends Config> = TConfig['method'] extends 'post' ? TConfig['endpoint'] extends 'login' ? {
_id: ResourceId;
} : TConfig['method'] extends 'put' | 'patch' | 'delete' ? null : TConfig['endpoint'] extends `products/${ResourceId}` ? Products : TConfig['endpoint'] extends `categories/${ResourceId}` ? Categories : TConfig['endpoint'] extends `brands/${ResourceId}` ? Brands : TConfig['endpoint'] extends `collections/${ResourceId}` ? Collections : TConfig['endpoint'] extends `grids/${ResourceId}` ? Grids : TConfig['endpoint'] extends `carts/${ResourceId}` ? Carts : TConfig['endpoint'] extends `orders/${ResourceId}` ? Orders : TConfig['endpoint'] extends `customers/${ResourceId}` ? Customers : TConfig['endpoint'] extends `stores/${ResourceId}` ? Stores : TConfig['endpoint'] extends `applications/${ResourceId}` ? Applications : TConfig['endpoint'] extends Resource ? ResourceListResult<TConfig['endpoint']> : TConfig['endpoint'] extends EventsEndpoint ? EventsResult<TConfig['endpoint']> : any;
export type { Products, Categories, Brands, Collections, Grids, Carts, Orders, Customers, Stores, Applications, Resource, ResourceAndId, Endpoint, Method, Config, ResponseBody, };
store_ids: number[];
api_key: string;
} : TConfig['endpoint'] extends 'authenticate' ? {
my_id: string;
access_token: string;
expires: string;
} : {
_id: ResourceId;
} : TConfig['method'] extends 'put' | 'patch' | 'delete' ? null : TConfig['endpoint'] extends `${string}/${ResourceId}/${string}` ? any : TConfig['endpoint'] extends `products/${ResourceId}` ? Products : TConfig['endpoint'] extends `categories/${ResourceId}` ? Categories : TConfig['endpoint'] extends `brands/${ResourceId}` ? Brands : TConfig['endpoint'] extends `collections/${ResourceId}` ? Collections : TConfig['endpoint'] extends `grids/${ResourceId}` ? Grids : TConfig['endpoint'] extends `carts/${ResourceId}` ? Carts : TConfig['endpoint'] extends `orders/${ResourceId}` ? Orders : TConfig['endpoint'] extends `customers/${ResourceId}` ? Customers : TConfig['endpoint'] extends `stores/${ResourceId}` ? Stores : TConfig['endpoint'] extends `applications/${ResourceId}` ? Applications : TConfig['endpoint'] extends `authentications/${ResourceId}` ? Authentications : TConfig['endpoint'] extends ResourceOpQuery ? ResourceListResult<TConfig['endpoint']> : TConfig['endpoint'] extends EventsEndpoint ? EventsResult<TConfig['endpoint']> : any;
declare type DocSchema<Document extends any> = Omit<Document, '_id' | 'store_id' | 'store_ids' | 'created_at' | 'updated_at'>;
declare type SetDocEndpoint<TResource extends Resource> = TResource | `${TResource}/${ResourceId}`;
declare type RequestBody<TConfig extends Config> = TConfig['method'] extends undefined | 'get' | 'delete' ? undefined : TConfig['method'] extends 'patch' ? any : TConfig['endpoint'] extends SetDocEndpoint<'products'> ? DocSchema<Products> : TConfig['endpoint'] extends SetDocEndpoint<'categories'> ? DocSchema<Categories> : TConfig['endpoint'] extends SetDocEndpoint<'brands'> ? DocSchema<Brands> : TConfig['endpoint'] extends SetDocEndpoint<'collections'> ? DocSchema<Collections> : TConfig['endpoint'] extends SetDocEndpoint<'grids'> ? DocSchema<Grids> : TConfig['endpoint'] extends SetDocEndpoint<'carts'> ? DocSchema<Carts> : TConfig['endpoint'] extends SetDocEndpoint<'orders'> ? DocSchema<Orders> : TConfig['endpoint'] extends SetDocEndpoint<'customers'> ? DocSchema<Customers> : TConfig['endpoint'] extends SetDocEndpoint<'stores'> ? DocSchema<Stores> : TConfig['endpoint'] extends SetDocEndpoint<'applications'> ? DocSchema<Applications> : TConfig['endpoint'] extends SetDocEndpoint<'authentications'> ? DocSchema<Authentications> : any;
export type { Products, Categories, Brands, Collections, Grids, Carts, Orders, Customers, Stores, Applications, Resource, ResourceAndId, ResourceOpQuery, Endpoint, Method, Config, ResponseBody, RequestBody, };

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Applications {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Authentications {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Brands {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -12,3 +12,3 @@ /* tslint:disable */

export interface Carts {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -179,3 +179,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -202,3 +202,3 @@ * Kit product full name

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -205,0 +205,0 @@ * Selected variation ID (ObjectID) if any

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Categories {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Collections {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -12,3 +12,3 @@ /* tslint:disable */

export interface Customers {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -369,3 +369,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -372,0 +372,0 @@ * When order was saved, date and time in ISO 8601 standard representation

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Grids {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -12,3 +12,3 @@ /* tslint:disable */

export interface Orders {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -233,3 +233,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1234,3 +1234,3 @@ * Customer language two letter code, sometimes with region, e.g. 'pt_br', 'fr', 'en_us'

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1257,3 +1257,3 @@ * Kit product full name

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1352,3 +1352,3 @@ * Selected variation ID (ObjectID) if any

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1355,0 +1355,0 @@ * Subscription order number

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Products {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -1183,3 +1183,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1186,0 +1186,0 @@ * Product quantity

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Stores {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

{
"name": "@cloudcommerce/api",
"type": "module",
"version": "0.0.27",
"version": "0.0.28",
"description": "E-Com Plus Cloud Commerce APIs client/adapter",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

@@ -1,2 +0,8 @@

import type { Endpoint, Config, ResponseBody } from './types';
import type {
ResourceOpQuery,
Endpoint,
Config,
ResponseBody,
RequestBody,
} from './types';

@@ -24,21 +30,41 @@ // @ts-ignore

middleware(config: Config) {
const headers: Headers | Record<string, string> = { ...config.headers };
if (config.accessToken) {
// eslint-disable-next-line dot-notation
headers['Authorization'] = `Bearer ${config.accessToken}`;
} else if (config.authenticationId && config.apiKey) {
const rawAuth = `${config.authenticationId}:${config.apiKey}`;
const base64Auth = typeof Buffer === 'function'
? Buffer.from(rawAuth).toString('base64') : btoa(rawAuth);
// eslint-disable-next-line dot-notation
headers['Authorization'] = `Basic ${base64Auth}`;
}
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
const storeId = config.storeId || env.ECOM_STORE_ID;
if (!storeId) {
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
const { endpoint, params } = config;
if (
endpoint !== 'login'
&& endpoint !== 'authenticate'
&& endpoint !== 'ask-auth-callback'
&& endpoint !== 'check-username'
) {
const storeId = config.storeId || env.ECOM_STORE_ID;
if (!storeId) {
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
}
url += `/:${storeId}`;
const lang = config.lang || env.ECOM_LANG;
if (lang) {
url += `,lang:${lang}`;
}
}
url += `/:${storeId}`;
const lang = config.lang || env.ECOM_LANG;
if (lang) {
url += `,lang:${lang}`;
}
if (config.params) {
if (typeof config.params === 'string') {
url += `?${config.params}`;
url += `/${endpoint}`;
if (params) {
if (typeof params === 'string') {
url += `?${params}`;
} else {
// https://github.com/microsoft/TypeScript/issues/32951
url += `?${new URLSearchParams(config.params as Record<string, string>)}`;
url += `?${new URLSearchParams(params as Record<string, string>)}`;
}
}
return `${url}/${config.endpoint}`;
return { url, headers };
},

@@ -51,13 +77,21 @@ };

const api = async <T extends Config>(config: T, retries = 0): Promise<Response & {
const api = async <T extends Config & { body?: any, data?: any }>(config: T, retries = 0):
Promise<Response & {
config: Config,
data: ResponseBody<T>,
}> => {
const url = def.middleware(config);
const { url, headers } = def.middleware(config);
const {
method,
headers,
timeout = 20000,
maxRetries = 3,
} = config;
const bodyObject = config.body || config.data;
let body: string | undefined;
if (bodyObject) {
body = JSON.stringify(bodyObject);
headers['Content-Type'] = 'application/json';
headers['Content-Length'] = body.length.toString();
}
const abortController = new AbortController();

@@ -74,2 +108,3 @@ let isTimeout = false;

headers,
body,
signal: abortController.signal,

@@ -81,2 +116,3 @@ });

clearTimeout(timer);
if (response) {

@@ -104,2 +140,4 @@ if (response.ok) {

type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
type AbstractedAuthConfig = AbstractedConfig & { accessToken: string }
| AbstractedConfig & { authenticationId: string, apiKey: string };

@@ -114,21 +152,32 @@ const get = <E extends Endpoint, C extends AbstractedConfig>(

const post = (endpoint: Endpoint, config?: AbstractedConfig) => api({
...config,
method: 'post',
endpoint,
});
const post = <E extends Endpoint, C extends AbstractedAuthConfig>(
endpoint: E,
body: RequestBody<{ endpoint: E, method: 'post' }>,
config: E extends 'login' | 'authenticate' ? AbstractedConfig : C,
) => api({
...config,
method: 'post',
endpoint,
body,
});
const put = (endpoint: Endpoint, config?: AbstractedConfig) => api({
...config,
method: 'put',
endpoint,
});
const put = <E extends Exclude<Endpoint, ResourceOpQuery>, C extends AbstractedAuthConfig>(
endpoint: E,
body: RequestBody<{ endpoint: E, method: 'put' }>,
config: C,
) => api({
...config,
method: 'put',
endpoint,
body,
});
const patch = (endpoint: Endpoint, config?: AbstractedConfig) => api({
const patch = (endpoint: Endpoint, body: any, config: AbstractedAuthConfig) => api({
...config,
method: 'patch',
endpoint,
body,
});
const del = (endpoint: Endpoint, config?: AbstractedConfig) => api({
const del = (endpoint: Endpoint, config: AbstractedAuthConfig) => api({
...config,

@@ -135,0 +184,0 @@ method: 'delete',

@@ -11,2 +11,3 @@ import type { Products } from './types/products';

import type { Applications } from './types/applications';
import type { Authentications } from './types/authentications';

@@ -22,3 +23,4 @@ type Resource = 'products'

| 'stores'
| 'applications';
| 'applications'
| 'authentications';

@@ -29,2 +31,4 @@ type ResourceId = string & { length: 24 };

type ResourceOpQuery = Resource | `${Resource}?${string}`;
type EventsEndpoint = `events/${Resource}`

@@ -34,3 +38,3 @@ | `events/${ResourceAndId}`

type Endpoint = Resource
type Endpoint = ResourceOpQuery
| ResourceAndId

@@ -45,3 +49,3 @@ | `${ResourceAndId}/${string}`

| 'check-username'
| `$aggregate/${Exclude<Resource, 'stores' | 'applications'>}`
| `$aggregate/${Exclude<Resource, 'stores' | 'applications' | 'authentications'>}`
| `schemas/${Resource}`;

@@ -54,2 +58,5 @@

storeId?: number,
accessToken?: string,
authenticationId?: string,
apiKey?: string,
lang?: string,

@@ -59,3 +66,3 @@ method?: Method,

params?: Record<string, string | number>,
headers?: Record<string, string>,
headers?: Headers | Record<string, string>,
timeout?: number,

@@ -72,14 +79,17 @@ maxRetries?: number,

type ResourceListResult<TResource extends Resource> = {
type ListEndpoint<TResource extends Resource> = TResource | `${TResource}?${string}`;
type ResourceListResult<TEndpoint extends ResourceOpQuery> = {
result:
TResource extends 'products' ? Products[] :
TResource extends 'categories' ? Categories[] :
TResource extends 'brands' ? Brands[] :
TResource extends 'collections' ? Collections[] :
TResource extends 'grids' ? Grids[] :
TResource extends 'carts' ? Carts[] :
TResource extends 'orders' ? Orders[] :
TResource extends 'customers' ? Customers[] :
TResource extends 'stores' ? Stores[] :
TResource extends 'applications' ? Applications[] :
TEndpoint extends ListEndpoint<'products'> ? Products[] :
TEndpoint extends ListEndpoint<'categories'> ? Categories[] :
TEndpoint extends ListEndpoint<'brands'> ? Brands[] :
TEndpoint extends ListEndpoint<'collections'> ? Collections[] :
TEndpoint extends ListEndpoint<'grids'> ? Grids[] :
TEndpoint extends ListEndpoint<'carts'> ? Carts[] :
TEndpoint extends ListEndpoint<'orders'> ? Orders[] :
TEndpoint extends ListEndpoint<'customers'> ? Customers[] :
TEndpoint extends ListEndpoint<'stores'> ? Stores[] :
TEndpoint extends ListEndpoint<'applications'> ? Applications[] :
TEndpoint extends ListEndpoint<'authentications'> ? Authentications[] :
never,

@@ -128,5 +138,9 @@ meta: BaseListResultMeta & {

type ResponseBody<TConfig extends Config> =
TConfig['method'] extends 'post' ? { _id: ResourceId } :
TConfig['method'] extends 'post' ?
TConfig['endpoint'] extends 'login' ? { _id: ResourceId, store_ids: number[], api_key: string } :
TConfig['endpoint'] extends 'authenticate' ? { my_id: string, access_token: string, expires: string } :
{ _id: ResourceId } :
TConfig['method'] extends 'put' | 'patch' | 'delete' ? null :
// method?: 'get'
TConfig['endpoint'] extends `${string}/${ResourceId}/${string}` ? any :
TConfig['endpoint'] extends `products/${ResourceId}` ? Products :

@@ -142,6 +156,29 @@ TConfig['endpoint'] extends `categories/${ResourceId}` ? Categories :

TConfig['endpoint'] extends `applications/${ResourceId}` ? Applications :
TConfig['endpoint'] extends Resource ? ResourceListResult<TConfig['endpoint']> :
TConfig['endpoint'] extends `authentications/${ResourceId}` ? Authentications :
TConfig['endpoint'] extends ResourceOpQuery ? ResourceListResult<TConfig['endpoint']> :
TConfig['endpoint'] extends EventsEndpoint ? EventsResult<TConfig['endpoint']> :
any;
type DocSchema<Document extends any> =
Omit<Document, '_id' | 'store_id' | 'store_ids' | 'created_at' | 'updated_at'>;
type SetDocEndpoint<TResource extends Resource> = TResource | `${TResource}/${ResourceId}`;
type RequestBody<TConfig extends Config> =
TConfig['method'] extends undefined | 'get' | 'delete' ? undefined :
TConfig['method'] extends 'patch' ? any : // TODO: partial body
// method: 'post' | 'put'
TConfig['endpoint'] extends SetDocEndpoint<'products'> ? DocSchema<Products> :
TConfig['endpoint'] extends SetDocEndpoint<'categories'> ? DocSchema<Categories> :
TConfig['endpoint'] extends SetDocEndpoint<'brands'> ? DocSchema<Brands> :
TConfig['endpoint'] extends SetDocEndpoint<'collections'> ? DocSchema<Collections> :
TConfig['endpoint'] extends SetDocEndpoint<'grids'> ? DocSchema<Grids> :
TConfig['endpoint'] extends SetDocEndpoint<'carts'> ? DocSchema<Carts> :
TConfig['endpoint'] extends SetDocEndpoint<'orders'> ? DocSchema<Orders> :
TConfig['endpoint'] extends SetDocEndpoint<'customers'> ? DocSchema<Customers> :
TConfig['endpoint'] extends SetDocEndpoint<'stores'> ? DocSchema<Stores> :
TConfig['endpoint'] extends SetDocEndpoint<'applications'> ? DocSchema<Applications> :
TConfig['endpoint'] extends SetDocEndpoint<'authentications'> ? DocSchema<Authentications> :
any;
export type {

@@ -160,2 +197,3 @@ Products,

ResourceAndId,
ResourceOpQuery,
Endpoint,

@@ -165,2 +203,3 @@ Method,

ResponseBody,
RequestBody,
};

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Applications {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Authentications {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Brands {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -12,3 +12,3 @@ /* tslint:disable */

export interface Carts {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -179,3 +179,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -202,3 +202,3 @@ * Kit product full name

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -205,0 +205,0 @@ * Selected variation ID (ObjectID) if any

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Categories {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Collections {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -12,3 +12,3 @@ /* tslint:disable */

export interface Customers {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -369,3 +369,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -372,0 +372,0 @@ * When order was saved, date and time in ISO 8601 standard representation

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Grids {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -12,3 +12,3 @@ /* tslint:disable */

export interface Orders {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -233,3 +233,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1234,3 +1234,3 @@ * Customer language two letter code, sometimes with region, e.g. 'pt_br', 'fr', 'en_us'

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1257,3 +1257,3 @@ * Kit product full name

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1352,3 +1352,3 @@ * Selected variation ID (ObjectID) if any

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1355,0 +1355,0 @@ * Subscription order number

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Products {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -1183,3 +1183,3 @@ updated_at: string;

*/
_id: string;
_id: string & { length: 24 };
/**

@@ -1186,0 +1186,0 @@ * Product quantity

@@ -9,3 +9,3 @@ /* tslint:disable */

export interface Stores {
_id: string;
_id: string & { length: 24 };
created_at: string;

@@ -12,0 +12,0 @@ updated_at: string;

@@ -55,1 +55,17 @@ /* eslint-disable no-console, import/no-extraneous-dependencies */

});
test('401 to create category and body typecheck', async () => {
try {
const { data } = await api.post('categories', {
name: 'Test category',
}, {
accessToken: 'invalid',
});
console.log(data._id);
throw new Error('Should have thrown unauthorized');
} catch (err: any) {
const error = err as ApiError;
expect(error.statusCode).toBe(401);
expect(error.response?.status).toBe(401);
}
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc