New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cloudcommerce

Package Overview
Dependencies
Maintainers
1
Versions
449
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudcommerce - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.eslintrc.cjs

3

.github/renovate.json

@@ -11,3 +11,4 @@ {

],
"dependencyDashboard": false
"dependencyDashboard": false,
"ignoreDeps": ["node", "pnpm"]
}

@@ -5,2 +5,15 @@ # Changelog

### [0.0.3](https://github.com/ecomplus/cloud-commerce/compare/v0.0.2...v0.0.3) (2022-06-14)
### Features
* **api:** Add `timeout` req option with 20s default ([9544225](https://github.com/ecomplus/cloud-commerce/commit/954422567d1e77c95522e7c02758cb4fda6cbfd0))
* **api:** Set response body type for each resource on read by id ([7330537](https://github.com/ecomplus/cloud-commerce/commit/733053770cd62a7f07ee6753e06b461e168e25da))
### Bug Fixes
* **api:** Fix success payload with full fetch response object ([083b51d](https://github.com/ecomplus/cloud-commerce/commit/083b51da0864c040b323b26d5635b574bbbb26bf))
### [0.0.2](https://github.com/ecomplus/cloud-commerce/compare/v0.0.2-alpha.0...v0.0.2) (2022-06-11)

@@ -7,0 +20,0 @@

{
"name": "cloudcommerce",
"version": "0.0.2",
"version": "0.0.3",
"description": "Open fair-code headless commerce platform: API-first, microservices based, event driven and cloud native",

@@ -15,2 +15,3 @@ "main": "src/index.js",

"build": "turbo run build",
"test": "turbo run test",
"release": "pnpm build && standard-version --commit-all",

@@ -28,5 +29,5 @@ "postpublish": "zx scripts/release.mjs --publish"

"@commitlint/rules": "^17.0.0",
"@types/node": "^17.0.41",
"@typescript-eslint/eslint-plugin": "^5.27.1",
"@typescript-eslint/parser": "^5.27.1",
"@types/node": "^17.0.42",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"esbuild": "^0.14.43",

@@ -36,3 +37,3 @@ "eslint": "^8.17.0",

"eslint-plugin-import": "^2.26.0",
"eslint-plugin-vue": "^9.1.0",
"eslint-plugin-vue": "^9.1.1",
"husky": "^8.0.1",

@@ -42,4 +43,4 @@ "standard-version": "^9.5.0",

"typescript": "^4.7.3",
"zx": "^6.2.4"
"zx": "^6.2.5"
}
}

@@ -6,11 +6,11 @@ // @ts-ignore

const def = {
middleware(options) {
let url = options.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
middleware(config) {
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
if (!url) {
const storeId = options.storeId || env.ECOM_STORE_ID;
const storeId = config.storeId || env.ECOM_STORE_ID;
if (!storeId) {
throw new Error('`storeId` must be set in options or `ECOM_STORE_ID` env var');
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
}
url += `/:${storeId}`;
const lang = options.lang || env.ECOM_LANG;
const lang = config.lang || env.ECOM_LANG;
if (lang) {

@@ -20,12 +20,12 @@ url += `,lang:${lang}`;

}
if (options.params) {
if (typeof options.params === 'string') {
url += `?${options.params}`;
if (config.params) {
if (typeof config.params === 'string') {
url += `?${config.params}`;
}
else {
// https://github.com/microsoft/TypeScript/issues/32951
url += `?${new URLSearchParams(options.params)}`;
url += `?${new URLSearchParams(config.params)}`;
}
}
return `${url}/${options.endpoint}`;
return `${url}/${config.endpoint}`;
},

@@ -37,29 +37,47 @@ };

};
const callApi = (options) => {
const url = def.middleware(options);
const { method, headers } = options;
return fetch(url, { method, headers });
const callApi = async (config) => {
const url = def.middleware(config);
const { method, headers, timeout = 20000 } = config;
const abortController = new AbortController();
const timer = setTimeout(() => abortController.abort(), timeout);
const response = await fetch(url, {
method,
headers,
signal: abortController.signal,
});
clearTimeout(timer);
if (response.ok) {
return {
...response,
config,
data: await response.json(),
};
}
const error = new Error(response.statusText);
error.config = config;
error.response = response;
throw error;
};
const get = (endpoint, options) => callApi({
...options,
const get = (endpoint, config) => callApi({
...config,
method: 'get',
endpoint,
});
const post = (endpoint, options) => callApi({
...options,
const post = (endpoint, config) => callApi({
...config,
method: 'post',
endpoint,
});
const put = (endpoint, options) => callApi({
...options,
const put = (endpoint, config) => callApi({
...config,
method: 'put',
endpoint,
});
const patch = (endpoint, options) => callApi({
...options,
const patch = (endpoint, config) => callApi({
...config,
method: 'patch',
endpoint,
});
const del = (endpoint, options) => callApi({
...options,
const del = (endpoint, config) => callApi({
...config,
method: 'delete',

@@ -66,0 +84,0 @@ endpoint,

{
"name": "@cloudcommerce/api",
"version": "0.0.2",
"version": "0.0.3",
"description": "E-Com Plus Cloud Commerce APIs client/adapter",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {

@@ -18,4 +19,5 @@ "type": "git",

"scripts": {
"build": "tsc --build"
"build": "zx scripts/build.mjs",
"test": "tsc --noEmit --noImplicitAny"
}
}

@@ -1,26 +0,3 @@

type Resource = 'products'
| 'categories'
| 'brands'
| 'collections'
| 'grids'
| 'carts'
| 'orders'
| 'customers'
| 'stores'
| 'applications';
import type { Endpoint, Config, ResponseBody } from './types';
type Endpoint = Resource | `${Resource}/${string}`;
type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
type ReqOptions = {
baseUrl?: string,
storeId?: number,
lang?: string,
method: Method,
endpoint: Endpoint,
params?: Record<string, string | number>,
headers?: Record<string, string>,
};
// @ts-ignore

@@ -32,11 +9,11 @@ const env: { [key: string]: string } = (typeof window === 'object' && window)

const def = {
middleware(options: ReqOptions) {
let url = options.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
middleware(config: Config) {
let url = config.baseUrl || env.API_BASE_URL || 'https://ecomplus.io/v2';
if (!url) {
const storeId = options.storeId || env.ECOM_STORE_ID;
const storeId = config.storeId || env.ECOM_STORE_ID;
if (!storeId) {
throw new Error('`storeId` must be set in options or `ECOM_STORE_ID` env var');
throw new Error('`storeId` must be set in config or `ECOM_STORE_ID` env var');
}
url += `/:${storeId}`;
const lang = options.lang || env.ECOM_LANG;
const lang = config.lang || env.ECOM_LANG;
if (lang) {

@@ -46,11 +23,11 @@ url += `,lang:${lang}`;

}
if (options.params) {
if (typeof options.params === 'string') {
url += `?${options.params}`;
if (config.params) {
if (typeof config.params === 'string') {
url += `?${config.params}`;
} else {
// https://github.com/microsoft/TypeScript/issues/32951
url += `?${new URLSearchParams(options.params as Record<string, string>)}`;
url += `?${new URLSearchParams(config.params as Record<string, string>)}`;
}
}
return `${url}/${options.endpoint}`;
return `${url}/${config.endpoint}`;
},

@@ -64,10 +41,31 @@ };

const callApi = (options: ReqOptions) => {
const url = def.middleware(options);
const { method, headers } = options;
return fetch(url, { method, headers });
const callApi = async <T extends Config>(config: T): Promise<Response & {
config: Config,
data: ResponseBody<T>,
}> => {
const url = def.middleware(config);
const { method, headers, timeout = 20000 } = config;
const abortController = new AbortController();
const timer = setTimeout(() => abortController.abort(), timeout);
const response = await fetch(url, {
method,
headers,
signal: abortController.signal,
});
clearTimeout(timer);
if (response.ok) {
return {
...response,
config,
data: await response.json(),
};
}
const error: any = new Error(response.statusText);
error.config = config;
error.response = response;
throw error;
};
const get = (endpoint: Endpoint, options: Exclude<ReqOptions, 'method'>) => callApi({
...options,
const get = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
...config,
method: 'get',

@@ -77,4 +75,4 @@ endpoint,

const post = (endpoint: Endpoint, options: Exclude<ReqOptions, 'method'>) => callApi({
...options,
const post = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
...config,
method: 'post',

@@ -84,4 +82,4 @@ endpoint,

const put = (endpoint: Endpoint, options: Exclude<ReqOptions, 'method'>) => callApi({
...options,
const put = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
...config,
method: 'put',

@@ -91,4 +89,4 @@ endpoint,

const patch = (endpoint: Endpoint, options: Exclude<ReqOptions, 'method'>) => callApi({
...options,
const patch = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
...config,
method: 'patch',

@@ -98,4 +96,4 @@ endpoint,

const del = (endpoint: Endpoint, options: Exclude<ReqOptions, 'method'>) => callApi({
...options,
const del = (endpoint: Endpoint, config: Exclude<Config, 'method'>) => callApi({
...config,
method: 'delete',

@@ -122,8 +120,1 @@ endpoint,

};
export type {
Resource,
Endpoint,
Method,
ReqOptions,
};
{
"name": "@cloudcommerce/app-discounts",
"version": "0.0.2",
"version": "0.0.3",
"description": "E-Com Plus Cloud Commerce app for complex discount rules",

@@ -5,0 +5,0 @@ "main": "functions/dist/index.js",

{
"name": "@cloudcommerce/storefront",
"version": "0.0.2",
"version": "0.0.3",
"description": "E-Com Plus Cloud Commerce storefront with Astro",

@@ -5,0 +5,0 @@ "main": "src/index.js",

# E-Com Plus Open Cloud Commerce
Open fair-code eCommerce platform to use on top of headless commerce APIs, it includes:
- High performant Astro PWA & Jamstack storefront;
- High performant [Astro](https://astro.build/) + [Vue](https://vuejs.org/) PWA & Jamstack storefront;
- Storefront CMS and page builder;
- Integrations for payments, shipping, ERPs, CRMs and others.
Easy deployment on Firebase, plug & play with [E-Com Plus APIs](https://developers.e-com.plus/).
Easy deployment on [Firebase](https://firebase.google.com/), plug & play with **[E-Com Plus APIs](https://developers.e-com.plus/)**.

@@ -10,0 +10,0 @@ ## Concepts

@@ -12,4 +12,7 @@ {

]
},
"test": {
"outputs": []
}
}
}

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