@cloudcommerce/api 0.0.126 → 0.0.128

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.0.125 build /home/leo/code/ecomplus/cloud-commerce/packages/api
2
+ > @cloudcommerce/api@0.0.127 build /home/leo/code/ecomplus/cloud-commerce/packages/api
3
3
  > sh ../../scripts/build-lib.sh && cp -r src/types lib/
4
4
 
@@ -1,20 +1,20 @@
1
1
 
2
- > @cloudcommerce/api@0.0.125 test /home/leo/code/ecomplus/cloud-commerce/packages/api
2
+ > @cloudcommerce/api@0.0.127 test /home/leo/code/ecomplus/cloud-commerce/packages/api
3
3
  > tsc -p ../../tsconfig.test.json && vitest run
4
4
 
5
- c
6
- RUN v0.24.5 /home/leo/code/ecomplus/cloud-commerce/packages/api
5
+
6
+ RUN v0.25.3 /home/leo/code/ecomplus/cloud-commerce/packages/api
7
7
 
8
8
  ✓ tests/index.test.ts > Read product and typecheck SKU
9
- (node:31375) [https://github.com/node-fetch/node-fetch/issues/1000 (response)] DeprecationWarning: data doesn't exist, use json(), text(), arrayBuffer(), or body instead
9
+ (node:82622) [https://github.com/node-fetch/node-fetch/issues/1000 (response)] DeprecationWarning: data doesn't exist, use json(), text(), arrayBuffer(), or body instead
10
10
  (Use `node --trace-deprecation ...` to show where the warning was created)
11
11
  ✓ tests/index.test.ts > 404 with different Store ID from env
12
12
  ✓ tests/index.test.ts > List categories and typecheck result
13
13
  ✓ tests/index.test.ts > 401 trying to list API events
14
14
  ✓ tests/index.test.ts > 401 to create category and body typecheck
15
15
 
16
- Test Files 1 passed (1)
17
- Tests 5 passed (5)
18
- Start at 01:13:38
19
- Duration 2.56s (transform 822ms, setup 0ms, collect 160ms, tests 1.01s)
16
+ Test Files 1 passed (1)
17
+ Tests 5 passed (5)
18
+ Start at 23:08:50
19
+ Duration 3.36s (transform 1.20s, setup 0ms, collect 214ms, tests 910ms)
20
20
 
package/lib/api.d.ts CHANGED
@@ -70,7 +70,7 @@ declare const api: {
70
70
  data: null;
71
71
  }>;
72
72
  };
73
- declare type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
73
+ type AbstractedConfig = Omit<Config, 'endpoint' | 'method'>;
74
74
  declare const get: <E extends Endpoint, C extends AbstractedConfig>(endpoint: E, config?: C | undefined) => Promise<Response & {
75
75
  config: Config;
76
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;
@@ -103,6 +103,6 @@ declare const del: (endpoint: Endpoint, config?: AbstractedConfig) => Promise<Re
103
103
  }>;
104
104
  export default api;
105
105
  export { setMiddleware, get, post, put, patch, del, ApiError, };
106
- export declare type ApiEndpoint = Endpoint;
107
- export declare type ApiConfig = Config;
108
- export declare type ApiErrorBody = ErrorBody;
106
+ export type ApiEndpoint = Endpoint;
107
+ export type ApiConfig = Config;
108
+ export type ApiErrorBody = ErrorBody;
package/lib/types.d.ts CHANGED
@@ -9,16 +9,16 @@ import type { Customers } from './types/customers';
9
9
  import type { Stores } from './types/stores';
10
10
  import type { Applications } from './types/applications';
11
11
  import type { Authentications } from './types/authentications';
12
- declare type Resource = 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'carts' | 'orders' | 'customers' | 'stores' | 'applications' | 'authentications';
13
- declare type ResourceId = string & {
12
+ type Resource = 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'carts' | 'orders' | 'customers' | 'stores' | 'applications' | 'authentications';
13
+ type ResourceId = string & {
14
14
  length: 24;
15
15
  };
16
- declare type ResourceAndId = `${Resource}/${ResourceId}`;
17
- declare type ResourceOpQuery = Resource | `${Resource}?${string}`;
18
- declare type EventsEndpoint = `events/${Resource}` | `events/${ResourceAndId}` | 'events/me';
19
- 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}`;
20
- declare type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
21
- declare type Config = {
16
+ type ResourceAndId = `${Resource}/${ResourceId}`;
17
+ type ResourceOpQuery = Resource | `${Resource}?${string}`;
18
+ type EventsEndpoint = `events/${Resource}` | `events/${ResourceAndId}` | 'events/me';
19
+ 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}`;
20
+ type Method = 'get' | 'post' | 'put' | 'patch' | 'delete';
21
+ type Config = {
22
22
  baseUrl?: string;
23
23
  storeId?: number;
24
24
  accessToken?: string;
@@ -36,27 +36,27 @@ declare type Config = {
36
36
  cacheMaxAge?: number;
37
37
  fetch?: typeof fetch;
38
38
  };
39
- declare type BaseListResultMeta = {
39
+ type BaseListResultMeta = {
40
40
  offset: number;
41
41
  limit: number;
42
42
  fields: Array<string>;
43
43
  };
44
- declare type ListResultDocs<Document extends any> = Array<Partial<Document> & {
44
+ type ListResultDocs<Document extends any> = Array<Partial<Document> & {
45
45
  _id: ResourceId;
46
46
  }>;
47
- declare type ProductsList = ListResultDocs<Products>;
48
- declare type CategoriesList = ListResultDocs<Categories>;
49
- declare type BrandsList = ListResultDocs<Brands>;
50
- declare type CollectionsList = ListResultDocs<Collections>;
51
- declare type GridsList = ListResultDocs<Grids>;
52
- declare type CartsList = ListResultDocs<Carts>;
53
- declare type OrdersList = ListResultDocs<Orders>;
54
- declare type CustomersList = ListResultDocs<Customers>;
55
- declare type StoresList = ListResultDocs<Stores>;
56
- declare type ApplicationsList = ListResultDocs<Applications>;
57
- declare type AuthenticationsList = ListResultDocs<Authentications>;
58
- declare type ListEndpoint<TResource extends Resource> = TResource | `${TResource}?${string}`;
59
- declare type ResourceListResult<TEndpoint extends ResourceOpQuery> = {
47
+ type ProductsList = ListResultDocs<Products>;
48
+ type CategoriesList = ListResultDocs<Categories>;
49
+ type BrandsList = ListResultDocs<Brands>;
50
+ type CollectionsList = ListResultDocs<Collections>;
51
+ type GridsList = ListResultDocs<Grids>;
52
+ type CartsList = ListResultDocs<Carts>;
53
+ type OrdersList = ListResultDocs<Orders>;
54
+ type CustomersList = ListResultDocs<Customers>;
55
+ type StoresList = ListResultDocs<Stores>;
56
+ type ApplicationsList = ListResultDocs<Applications>;
57
+ type AuthenticationsList = ListResultDocs<Authentications>;
58
+ type ListEndpoint<TResource extends Resource> = TResource | `${TResource}?${string}`;
59
+ type ResourceListResult<TEndpoint extends ResourceOpQuery> = {
60
60
  result: TEndpoint extends ListEndpoint<'products'> ? ProductsList : TEndpoint extends ListEndpoint<'categories'> ? CategoriesList : TEndpoint extends ListEndpoint<'brands'> ? BrandsList : TEndpoint extends ListEndpoint<'collections'> ? CollectionsList : TEndpoint extends ListEndpoint<'grids'> ? GridsList : TEndpoint extends ListEndpoint<'carts'> ? CartsList : TEndpoint extends ListEndpoint<'orders'> ? OrdersList : TEndpoint extends ListEndpoint<'customers'> ? CustomersList : TEndpoint extends ListEndpoint<'stores'> ? StoresList : TEndpoint extends ListEndpoint<'applications'> ? ApplicationsList : TEndpoint extends ListEndpoint<'authentications'> ? AuthenticationsList : never;
61
61
  meta: BaseListResultMeta & {
62
62
  count?: number;
@@ -69,7 +69,7 @@ declare type ResourceListResult<TEndpoint extends ResourceOpQuery> = {
69
69
  };
70
70
  };
71
71
  };
72
- declare type EventFieldsByEndpoint<TEndpoint extends EventsEndpoint> = TEndpoint extends `events/${Resource}` ? {
72
+ type EventFieldsByEndpoint<TEndpoint extends EventsEndpoint> = TEndpoint extends `events/${Resource}` ? {
73
73
  resource_id: ResourceId;
74
74
  authentication_id: ResourceId | null;
75
75
  } : TEndpoint extends `events/${ResourceAndId}` ? {
@@ -78,7 +78,7 @@ declare type EventFieldsByEndpoint<TEndpoint extends EventsEndpoint> = TEndpoint
78
78
  resource: Resource;
79
79
  resource_id: ResourceId;
80
80
  } : never;
81
- declare type EventsResult<TEndpoint extends EventsEndpoint> = {
81
+ type EventsResult<TEndpoint extends EventsEndpoint> = {
82
82
  result: Array<{
83
83
  timestamp: string;
84
84
  store_id?: number;
@@ -94,7 +94,7 @@ declare type EventsResult<TEndpoint extends EventsEndpoint> = {
94
94
  } & EventFieldsByEndpoint<TEndpoint>>;
95
95
  meta: BaseListResultMeta;
96
96
  };
97
- declare type ResponseBody<TConfig extends Config> = TConfig['method'] extends 'post' ? TConfig['endpoint'] extends 'login' ? {
97
+ type ResponseBody<TConfig extends Config> = TConfig['method'] extends 'post' ? TConfig['endpoint'] extends 'login' ? {
98
98
  _id: ResourceId;
99
99
  store_ids: number[];
100
100
  api_key: string;
@@ -105,21 +105,21 @@ declare type ResponseBody<TConfig extends Config> = TConfig['method'] extends 'p
105
105
  } : {
106
106
  _id: ResourceId;
107
107
  } : 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;
108
- declare type DocSchema<Document extends any> = Omit<Document, '_id' | 'store_id' | 'store_ids' | 'created_at' | 'updated_at'>;
109
- declare type CustomerSet = DocSchema<Customers>;
110
- declare type OrderSet = DocSchema<Orders>;
111
- declare type CartSet = DocSchema<Carts>;
112
- declare type ProductSet = DocSchema<Products>;
113
- declare type CategorySet = DocSchema<Categories>;
114
- declare type BrandSet = DocSchema<Brands>;
115
- declare type CollectionSet = DocSchema<Collections>;
116
- declare type GridSet = DocSchema<Grids>;
117
- declare type StoreSet = DocSchema<Stores>;
118
- declare type ApplicationSet = DocSchema<Applications>;
119
- declare type AuthenticationSet = DocSchema<Authentications>;
120
- declare type SetDocEndpoint<TResource extends Resource> = TResource | `${TResource}/${ResourceId}`;
121
- declare type RequestBody<TConfig extends Config> = TConfig['method'] extends undefined | 'get' | 'delete' ? undefined : TConfig['method'] extends 'patch' ? any : TConfig['endpoint'] extends SetDocEndpoint<'products'> ? ProductSet : TConfig['endpoint'] extends SetDocEndpoint<'categories'> ? CategorySet : TConfig['endpoint'] extends SetDocEndpoint<'brands'> ? BrandSet : TConfig['endpoint'] extends SetDocEndpoint<'collections'> ? CollectionSet : TConfig['endpoint'] extends SetDocEndpoint<'grids'> ? GridSet : TConfig['endpoint'] extends SetDocEndpoint<'carts'> ? CartSet : TConfig['endpoint'] extends SetDocEndpoint<'orders'> ? OrderSet : TConfig['endpoint'] extends SetDocEndpoint<'customers'> ? CustomerSet : TConfig['endpoint'] extends SetDocEndpoint<'stores'> ? StoreSet : TConfig['endpoint'] extends SetDocEndpoint<'applications'> ? ApplicationSet : TConfig['endpoint'] extends SetDocEndpoint<'authentications'> ? AuthenticationSet : any;
122
- declare type ErrorBody = {
108
+ type DocSchema<Document extends any> = Omit<Document, '_id' | 'store_id' | 'store_ids' | 'created_at' | 'updated_at'>;
109
+ type CustomerSet = DocSchema<Customers>;
110
+ type OrderSet = DocSchema<Orders>;
111
+ type CartSet = DocSchema<Carts>;
112
+ type ProductSet = DocSchema<Products>;
113
+ type CategorySet = DocSchema<Categories>;
114
+ type BrandSet = DocSchema<Brands>;
115
+ type CollectionSet = DocSchema<Collections>;
116
+ type GridSet = DocSchema<Grids>;
117
+ type StoreSet = DocSchema<Stores>;
118
+ type ApplicationSet = DocSchema<Applications>;
119
+ type AuthenticationSet = DocSchema<Authentications>;
120
+ type SetDocEndpoint<TResource extends Resource> = TResource | `${TResource}/${ResourceId}`;
121
+ type RequestBody<TConfig extends Config> = TConfig['method'] extends undefined | 'get' | 'delete' ? undefined : TConfig['method'] extends 'patch' ? any : TConfig['endpoint'] extends SetDocEndpoint<'products'> ? ProductSet : TConfig['endpoint'] extends SetDocEndpoint<'categories'> ? CategorySet : TConfig['endpoint'] extends SetDocEndpoint<'brands'> ? BrandSet : TConfig['endpoint'] extends SetDocEndpoint<'collections'> ? CollectionSet : TConfig['endpoint'] extends SetDocEndpoint<'grids'> ? GridSet : TConfig['endpoint'] extends SetDocEndpoint<'carts'> ? CartSet : TConfig['endpoint'] extends SetDocEndpoint<'orders'> ? OrderSet : TConfig['endpoint'] extends SetDocEndpoint<'customers'> ? CustomerSet : TConfig['endpoint'] extends SetDocEndpoint<'stores'> ? StoreSet : TConfig['endpoint'] extends SetDocEndpoint<'applications'> ? ApplicationSet : TConfig['endpoint'] extends SetDocEndpoint<'authentications'> ? AuthenticationSet : any;
122
+ type ErrorBody = {
123
123
  status: number;
124
124
  error_code: number;
125
125
  message: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/api",
3
3
  "type": "module",
4
- "version": "0.0.126",
4
+ "version": "0.0.128",
5
5
  "description": "E-Com Plus Cloud Commerce APIs client/adapter",
6
6
  "main": "lib/api.js",
7
7
  "types": "lib/api.d.ts",