@cloudcommerce/api 0.8.6 → 0.9.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @cloudcommerce/api@0.8.5 build /home/leo/code/ecomplus/cloud-commerce/packages/api
2
+ > @cloudcommerce/api@0.8.7 build /home/leo/code/ecomplus/cloud-commerce/packages/api
3
3
  > bash ../../scripts/build-lib.sh && cp -r src/types lib/
4
4
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @cloudcommerce/api@0.8.5 test /home/leo/code/ecomplus/cloud-commerce/packages/api
2
+ > @cloudcommerce/api@0.8.7 test /home/leo/code/ecomplus/cloud-commerce/packages/api
3
3
  > tsc -p ../../tsconfig.test.json && vitest run
4
4
 
5
5
 
6
- RUN v0.29.7 /home/leo/code/ecomplus/cloud-commerce/packages/api
6
+ RUN v0.30.0 /home/leo/code/ecomplus/cloud-commerce/packages/api
7
7
 
8
8
  ✓ tests/index.test.ts > Read product and typecheck SKU
9
9
  ✓ tests/index.test.ts > 404 with different Store ID from env
@@ -13,6 +13,6 @@
13
13
 
14
14
  Test Files 1 passed (1)
15
15
  Tests 5 passed (5)
16
- Start at 13:09:22
17
- Duration 1.13s (transform 150ms, setup 0ms, collect 133ms, tests 460ms)
16
+ Start at 04:55:11
17
+ Duration 1.42s (transform 170ms, setup 0ms, collect 121ms, tests 628ms, environment 0ms, prepare 183ms)
18
18
 
package/lib/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ResourceOpQuery, Endpoint, Config, ResponseBody, RequestBody, ErrorBody } from './types';
1
+ import type { Endpoint, Config, ResponseBody, RequestBody, ErrorBody } from './types';
2
2
  declare global {
3
3
  var __apiCache: Record<string, {
4
4
  timestamp: number;
@@ -37,15 +37,20 @@ declare const api: {
37
37
  }>;
38
38
  get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
39
39
  config: Config;
40
- data: E extends `${string}/${string}/${string}` ? any : E extends `products/${string}` ? import("./types").Products : E extends `categories/${string}` ? import("./types").Categories : E extends `brands/${string}` ? import("./types").Brands : E extends `collections/${string}` ? import("./types").Collections : E extends `grids/${string}` ? import("./types").Grids : E extends `carts/${string}` ? import("./types").Carts : E extends `orders/${string}` ? import("./types").Orders : E extends `customers/${string}` ? import("./types").Customers : E extends `stores/${string}` ? import("./types").Stores : E extends `applications/${string}` ? import("./types").Applications : E extends `authentications/${string}` ? import("./types").Authentications : E extends ResourceOpQuery ? import("./types").ResourceListResult<E> : E extends "events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me" ? import("./types").EventsResult<E> : any;
40
+ data: ResponseBody<{
41
+ endpoint: E;
42
+ }>;
41
43
  }>;
42
- post: <E_1 extends Endpoint, C_1 extends AbstractedConfig>(endpoint: E_1, body: E_1 extends "products" | `products/${string}` ? import("./types").ProductSet : E_1 extends "categories" | `categories/${string}` ? import("./types").CategorySet : E_1 extends "brands" | `brands/${string}` ? import("./types").BrandSet : E_1 extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E_1 extends "grids" | `grids/${string}` ? import("./types").GridSet : E_1 extends "carts" | `carts/${string}` ? import("./types").CartSet : E_1 extends "orders" | `orders/${string}` ? import("./types").OrderSet : E_1 extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E_1 extends "stores" | `stores/${string}` ? import("./types").StoreSet : E_1 extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E_1 extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: (E_1 extends "login" | "authenticate" ? AbstractedConfig : C_1) | undefined) => Promise<Response & {
44
+ post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
45
+ endpoint: E;
46
+ method: 'post';
47
+ }>, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
43
48
  config: Config;
44
- data: E_1 extends "login" ? {
49
+ data: E extends "login" ? {
45
50
  _id: import("./types").ResourceId;
46
51
  store_ids: number[];
47
52
  api_key: string;
48
- } : E_1 extends "authenticate" ? {
53
+ } : E extends "authenticate" ? {
49
54
  my_id: string;
50
55
  access_token: string;
51
56
  expires: string;
@@ -53,7 +58,10 @@ declare const api: {
53
58
  _id: import("./types").ResourceId;
54
59
  };
55
60
  }>;
56
- put: <E_2 extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C_2 extends AbstractedConfig>(endpoint: E_2, body: E_2 extends "products" | `products/${string}` ? import("./types").ProductSet : E_2 extends "categories" | `categories/${string}` ? import("./types").CategorySet : E_2 extends "brands" | `brands/${string}` ? import("./types").BrandSet : E_2 extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E_2 extends "grids" | `grids/${string}` ? import("./types").GridSet : E_2 extends "carts" | `carts/${string}` ? import("./types").CartSet : E_2 extends "orders" | `orders/${string}` ? import("./types").OrderSet : E_2 extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E_2 extends "stores" | `stores/${string}` ? import("./types").StoreSet : E_2 extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E_2 extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: C_2 | undefined) => Promise<Response & {
61
+ put: <E_1 extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C_1 extends AbstractedConfig>(endpoint: E_1, body: RequestBody<{
62
+ endpoint: E_1;
63
+ method: 'put';
64
+ }>, config?: C_1 | undefined) => Promise<Response & {
57
65
  config: Config;
58
66
  data: null;
59
67
  }>;
@@ -73,15 +81,20 @@ declare const api: {
73
81
  type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
74
82
  declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
75
83
  config: Config;
76
- data: E extends `${string}/${string}/${string}` ? any : E extends `products/${string}` ? import("./types").Products : E extends `categories/${string}` ? import("./types").Categories : E extends `brands/${string}` ? import("./types").Brands : E extends `collections/${string}` ? import("./types").Collections : E extends `grids/${string}` ? import("./types").Grids : E extends `carts/${string}` ? import("./types").Carts : E extends `orders/${string}` ? import("./types").Orders : E extends `customers/${string}` ? import("./types").Customers : E extends `stores/${string}` ? import("./types").Stores : E extends `applications/${string}` ? import("./types").Applications : E extends `authentications/${string}` ? import("./types").Authentications : E extends ResourceOpQuery ? import("./types").ResourceListResult<E> : E extends "events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me" ? import("./types").EventsResult<E> : any;
84
+ data: ResponseBody<{
85
+ endpoint: E;
86
+ }>;
77
87
  }>;
78
- declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: E extends "products" | `products/${string}` ? import("./types").ProductSet : E extends "categories" | `categories/${string}` ? import("./types").CategorySet : E extends "brands" | `brands/${string}` ? import("./types").BrandSet : E extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E extends "grids" | `grids/${string}` ? import("./types").GridSet : E extends "carts" | `carts/${string}` ? import("./types").CartSet : E extends "orders" | `orders/${string}` ? import("./types").OrderSet : E extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E extends "stores" | `stores/${string}` ? import("./types").StoreSet : E extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
88
+ declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
89
+ endpoint: E;
90
+ method: 'post';
91
+ }>, config?: (E extends "login" | "authenticate" ? AbstractedConfig : C) | undefined) => Promise<Response & {
79
92
  config: Config;
80
- data: E_1 extends "login" ? {
93
+ data: E extends "login" ? {
81
94
  _id: import("./types").ResourceId;
82
95
  store_ids: number[];
83
96
  api_key: string;
84
- } : E_1 extends "authenticate" ? {
97
+ } : E extends "authenticate" ? {
85
98
  my_id: string;
86
99
  access_token: string;
87
100
  expires: string;
@@ -89,7 +102,10 @@ declare const post: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E
89
102
  _id: import("./types").ResourceId;
90
103
  };
91
104
  }>;
92
- declare const put: <E extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C extends AbstractedConfig>(endpoint: E, body: E extends "products" | `products/${string}` ? import("./types").ProductSet : E extends "categories" | `categories/${string}` ? import("./types").CategorySet : E extends "brands" | `brands/${string}` ? import("./types").BrandSet : E extends "collections" | `collections/${string}` ? import("./types").CollectionSet : E extends "grids" | `grids/${string}` ? import("./types").GridSet : E extends "carts" | `carts/${string}` ? import("./types").CartSet : E extends "orders" | `orders/${string}` ? import("./types").OrderSet : E extends "customers" | `customers/${string}` ? import("./types").CustomerSet : E extends "stores" | `stores/${string}` ? import("./types").StoreSet : E extends "applications" | `applications/${string}` ? import("./types").ApplicationSet : E extends "authentications" | `authentications/${string}` ? import("./types").AuthenticationSet : any, config?: C | undefined) => Promise<Response & {
105
+ declare const put: <E extends `products/${string}` | `categories/${string}` | `brands/${string}` | `collections/${string}` | `grids/${string}` | `carts/${string}` | `orders/${string}` | `customers/${string}` | `stores/${string}` | `applications/${string}` | `authentications/${string}` | ("events/products" | "events/categories" | "events/brands" | "events/collections" | "events/grids" | "events/carts" | "events/orders" | "events/customers" | "events/stores" | "events/applications" | "events/authentications" | `events/products/${string}` | `events/categories/${string}` | `events/brands/${string}` | `events/collections/${string}` | `events/grids/${string}` | `events/carts/${string}` | `events/orders/${string}` | `events/customers/${string}` | `events/stores/${string}` | `events/applications/${string}` | `events/authentications/${string}` | "events/me") | `products/${string}/${string}` | `categories/${string}/${string}` | `brands/${string}/${string}` | `collections/${string}/${string}` | `grids/${string}/${string}` | `carts/${string}/${string}` | `orders/${string}/${string}` | `customers/${string}/${string}` | `stores/${string}/${string}` | `applications/${string}/${string}` | `authentications/${string}/${string}` | `slugs/${string}` | "$aggregate/products" | "$aggregate/categories" | "$aggregate/brands" | "$aggregate/collections" | "$aggregate/grids" | "$aggregate/carts" | "$aggregate/orders" | "$aggregate/customers" | "schemas/products" | "schemas/categories" | "schemas/brands" | "schemas/collections" | "schemas/grids" | "schemas/carts" | "schemas/orders" | "schemas/customers" | "schemas/stores" | "schemas/applications" | "schemas/authentications" | "search/v1" | "login" | "authenticate" | "ask-auth-callback" | "check-username", C extends AbstractedConfig>(endpoint: E, body: RequestBody<{
106
+ endpoint: E;
107
+ method: 'put';
108
+ }>, config?: C | undefined) => Promise<Response & {
93
109
  config: Config;
94
110
  data: null;
95
111
  }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.8.6",
4
+ "version": "0.9.0",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",