@cloudcommerce/api 0.14.0 → 0.15.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.
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +4 -4
- package/lib/api.d.ts +13 -12
- package/lib/api.js +51 -29
- package/lib/api.js.map +1 -1
- package/package.json +3 -3
- package/src/api.ts +52 -22
- package/tests/index.test.ts +18 -3
- package/{src/types → types}/brands.d.ts +1 -1
- package/{src/types → types}/carts.d.ts +5 -5
- package/{lib/types → types}/categories.d.ts +2 -2
- package/{src/types → types}/collections.d.ts +2 -2
- package/{src/types → types}/customers.d.ts +1 -1
- package/{lib/types → types}/grids.d.ts +1 -1
- package/{lib/types → types}/orders.d.ts +13 -13
- package/{lib/types → types}/products.d.ts +10 -10
- package/{src/types.ts → types.d.ts} +254 -31
- package/types.ts +1 -1
- package/lib/types/brands.d.ts +0 -157
- package/lib/types/carts.d.ts +0 -360
- package/lib/types/collections.d.ts +0 -159
- package/lib/types/customers.d.ts +0 -523
- package/lib/types.d.ts +0 -132
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/src/types/applications.d.ts +0 -165
- package/src/types/authentications.d.ts +0 -107
- package/src/types/categories.d.ts +0 -199
- package/src/types/grids.d.ts +0 -157
- package/src/types/orders.d.ts +0 -1720
- package/src/types/products.d.ts +0 -1424
- package/src/types/stores.d.ts +0 -123
- /package/{lib/types → types}/applications.d.ts +0 -0
- /package/{lib/types → types}/authentications.d.ts +0 -0
- /package/{lib/types → types}/stores.d.ts +0 -0
|
@@ -339,7 +339,7 @@ export interface Orders {
|
|
|
339
339
|
/**
|
|
340
340
|
* Shipping line ID (ObjectID) [auto]
|
|
341
341
|
*/
|
|
342
|
-
_id?: string;
|
|
342
|
+
_id?: string & { length: 24 };
|
|
343
343
|
from: Address;
|
|
344
344
|
to: Address1;
|
|
345
345
|
/**
|
|
@@ -388,7 +388,7 @@ export interface Orders {
|
|
|
388
388
|
/**
|
|
389
389
|
* Application ID (ObjectID)
|
|
390
390
|
*/
|
|
391
|
-
_id?: string;
|
|
391
|
+
_id?: string & { length: 24 };
|
|
392
392
|
/**
|
|
393
393
|
* Name of shipping method shown to customers
|
|
394
394
|
*/
|
|
@@ -688,7 +688,7 @@ export interface Orders {
|
|
|
688
688
|
/**
|
|
689
689
|
* Transaction ID (ObjectID) [auto]
|
|
690
690
|
*/
|
|
691
|
-
_id?: string;
|
|
691
|
+
_id?: string & { length: 24 };
|
|
692
692
|
/**
|
|
693
693
|
* Date and time of transaction creation, in ISO 8601 standard representation [auto]
|
|
694
694
|
*/
|
|
@@ -789,7 +789,7 @@ export interface Orders {
|
|
|
789
789
|
/**
|
|
790
790
|
* Application ID (ObjectID)
|
|
791
791
|
*/
|
|
792
|
-
_id?: string;
|
|
792
|
+
_id?: string & { length: 24 };
|
|
793
793
|
/**
|
|
794
794
|
* Name of payment method shown to customers
|
|
795
795
|
*/
|
|
@@ -1062,7 +1062,7 @@ export interface Orders {
|
|
|
1062
1062
|
/**
|
|
1063
1063
|
* Payment status ID (ObjectID) [auto]
|
|
1064
1064
|
*/
|
|
1065
|
-
_id?: string;
|
|
1065
|
+
_id?: string & { length: 24 };
|
|
1066
1066
|
/**
|
|
1067
1067
|
* ID of transaction related with this event
|
|
1068
1068
|
*/
|
|
@@ -1108,11 +1108,11 @@ export interface Orders {
|
|
|
1108
1108
|
/**
|
|
1109
1109
|
* Fulfillment status ID (ObjectID) [auto]
|
|
1110
1110
|
*/
|
|
1111
|
-
_id?: string;
|
|
1111
|
+
_id?: string & { length: 24 };
|
|
1112
1112
|
/**
|
|
1113
1113
|
* ID of shipping line related with this event
|
|
1114
1114
|
*/
|
|
1115
|
-
shipping_line_id?: string;
|
|
1115
|
+
shipping_line_id?: string & { length: 24 };
|
|
1116
1116
|
/**
|
|
1117
1117
|
* Date and time of the event, in ISO 8601 standard representation [auto]
|
|
1118
1118
|
*/
|
|
@@ -1154,15 +1154,15 @@ export interface Orders {
|
|
|
1154
1154
|
/**
|
|
1155
1155
|
* Order item ID (ObjectID) [auto]
|
|
1156
1156
|
*/
|
|
1157
|
-
_id?: string;
|
|
1157
|
+
_id?: string & { length: 24 };
|
|
1158
1158
|
/**
|
|
1159
1159
|
* Product ID
|
|
1160
1160
|
*/
|
|
1161
|
-
product_id: string;
|
|
1161
|
+
product_id: string & { length: 24 };
|
|
1162
1162
|
/**
|
|
1163
1163
|
* ID to specify the variation added to cart, if product has variations
|
|
1164
1164
|
*/
|
|
1165
|
-
variation_id?: string;
|
|
1165
|
+
variation_id?: string & { length: 24 };
|
|
1166
1166
|
/**
|
|
1167
1167
|
* Product or variation unique reference code
|
|
1168
1168
|
*/
|
|
@@ -1197,7 +1197,7 @@ export interface Orders {
|
|
|
1197
1197
|
/**
|
|
1198
1198
|
* Option ID (ObjectID) if it was predefined (not custom value created by customer)
|
|
1199
1199
|
*/
|
|
1200
|
-
_id?: string;
|
|
1200
|
+
_id?: string & { length: 24 };
|
|
1201
1201
|
/**
|
|
1202
1202
|
* Option text value displayed for the client
|
|
1203
1203
|
*/
|
|
@@ -1254,7 +1254,7 @@ export interface Orders {
|
|
|
1254
1254
|
/**
|
|
1255
1255
|
* Selected variation ID (ObjectID) if any
|
|
1256
1256
|
*/
|
|
1257
|
-
variation_id?: string;
|
|
1257
|
+
variation_id?: string & { length: 24 };
|
|
1258
1258
|
/**
|
|
1259
1259
|
* Kit item quantity
|
|
1260
1260
|
*/
|
|
@@ -1320,7 +1320,7 @@ export interface Orders {
|
|
|
1320
1320
|
/**
|
|
1321
1321
|
* Application ID (ObjectID)
|
|
1322
1322
|
*/
|
|
1323
|
-
_id?: string;
|
|
1323
|
+
_id?: string & { length: 24 };
|
|
1324
1324
|
/**
|
|
1325
1325
|
* Name of the discount rule, can be the coupon or campaign name
|
|
1326
1326
|
*/
|
|
@@ -280,7 +280,7 @@ export interface Products {
|
|
|
280
280
|
/**
|
|
281
281
|
* Brand ID (ObjectID)
|
|
282
282
|
*/
|
|
283
|
-
_id?: string;
|
|
283
|
+
_id?: string & { length: 24 };
|
|
284
284
|
/**
|
|
285
285
|
* Brand name
|
|
286
286
|
*/
|
|
@@ -333,7 +333,7 @@ export interface Products {
|
|
|
333
333
|
/**
|
|
334
334
|
* Category ID (ObjectID)
|
|
335
335
|
*/
|
|
336
|
-
_id?: string;
|
|
336
|
+
_id?: string & { length: 24 };
|
|
337
337
|
/**
|
|
338
338
|
* Category name
|
|
339
339
|
*/
|
|
@@ -366,7 +366,7 @@ export interface Products {
|
|
|
366
366
|
/**
|
|
367
367
|
* Parent category ID (ObjectID)
|
|
368
368
|
*/
|
|
369
|
-
_id?: string;
|
|
369
|
+
_id?: string & { length: 24 };
|
|
370
370
|
/**
|
|
371
371
|
* Parent category name
|
|
372
372
|
*/
|
|
@@ -423,7 +423,7 @@ export interface Products {
|
|
|
423
423
|
/**
|
|
424
424
|
* Grid ID (ObjectID)
|
|
425
425
|
*/
|
|
426
|
-
_id?: string;
|
|
426
|
+
_id?: string & { length: 24 };
|
|
427
427
|
/**
|
|
428
428
|
* Grid title
|
|
429
429
|
*/
|
|
@@ -806,7 +806,7 @@ export interface Products {
|
|
|
806
806
|
/**
|
|
807
807
|
* Picture ID (ObjectID) [auto]
|
|
808
808
|
*/
|
|
809
|
-
_id?: string;
|
|
809
|
+
_id?: string & { length: 24 };
|
|
810
810
|
/**
|
|
811
811
|
* Tag to identify object, use only lowercase letters, digits and underscore
|
|
812
812
|
*/
|
|
@@ -853,7 +853,7 @@ export interface Products {
|
|
|
853
853
|
/**
|
|
854
854
|
* Variation ID (ObjectID) [auto]
|
|
855
855
|
*/
|
|
856
|
-
_id?: string;
|
|
856
|
+
_id?: string & { length: 24 };
|
|
857
857
|
/**
|
|
858
858
|
* Item unique reference code
|
|
859
859
|
*/
|
|
@@ -1165,7 +1165,7 @@ export interface Products {
|
|
|
1165
1165
|
/**
|
|
1166
1166
|
* ID of one of the preferred product picture for this variation
|
|
1167
1167
|
*/
|
|
1168
|
-
picture_id?: string;
|
|
1168
|
+
picture_id?: string & { length: 24 };
|
|
1169
1169
|
/**
|
|
1170
1170
|
* Flags to associate additional info
|
|
1171
1171
|
*
|
|
@@ -1215,12 +1215,12 @@ export interface Products {
|
|
|
1215
1215
|
/**
|
|
1216
1216
|
* Optional variation ID (ObjectID) if `has_variations` is true
|
|
1217
1217
|
*/
|
|
1218
|
-
variation_id?: string;
|
|
1218
|
+
variation_id?: string & { length: 24 };
|
|
1219
1219
|
}[];
|
|
1220
1220
|
/**
|
|
1221
1221
|
* Parent product ID, if this product is contained or represented by another
|
|
1222
1222
|
*/
|
|
1223
|
-
parent_item_id?: string;
|
|
1223
|
+
parent_item_id?: string & { length: 24 };
|
|
1224
1224
|
/**
|
|
1225
1225
|
* Lists of related products
|
|
1226
1226
|
*
|
|
@@ -1240,7 +1240,7 @@ export interface Products {
|
|
|
1240
1240
|
*
|
|
1241
1241
|
* @maxItems 100
|
|
1242
1242
|
*/
|
|
1243
|
-
product_ids: string
|
|
1243
|
+
product_ids: Array<string & { length: 24 }>;
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Tag to identify object, use only lowercase letters, digits and underscore
|
|
1246
1246
|
*/
|
|
@@ -23,20 +23,24 @@ type Resource = 'products'
|
|
|
23
23
|
| 'authentications';
|
|
24
24
|
|
|
25
25
|
type ResourceId = string & { length: 24 };
|
|
26
|
-
|
|
27
26
|
type ResourceAndId = `${Resource}/${ResourceId}`;
|
|
28
|
-
|
|
27
|
+
type ResourceAndFind = ResourceAndId | `${Resource}/${string}:${string}`;
|
|
29
28
|
type ResourceOpQuery = Resource | `${Resource}?${string}`;
|
|
30
29
|
|
|
30
|
+
type SearchOpQuery = 'search/v1'
|
|
31
|
+
| `search/v1?${string}`
|
|
32
|
+
| 'search/_els'
|
|
33
|
+
| `search/_els?${string}`;
|
|
34
|
+
|
|
31
35
|
type EventsEndpoint = `events/${Resource}`
|
|
32
36
|
| `events/${ResourceAndId}`
|
|
33
37
|
| 'events/me';
|
|
34
38
|
|
|
35
39
|
type Endpoint = ResourceOpQuery
|
|
36
|
-
|
|
|
37
|
-
| `${
|
|
40
|
+
| ResourceAndFind
|
|
41
|
+
| `${ResourceAndFind}/${string}`
|
|
38
42
|
| `slugs/${string}`
|
|
39
|
-
|
|
|
43
|
+
| SearchOpQuery
|
|
40
44
|
| EventsEndpoint
|
|
41
45
|
| 'login'
|
|
42
46
|
| 'authenticate'
|
|
@@ -57,6 +61,14 @@ type Config = {
|
|
|
57
61
|
lang?: string,
|
|
58
62
|
method?: Method,
|
|
59
63
|
endpoint: Endpoint,
|
|
64
|
+
fields?: readonly string[],
|
|
65
|
+
sort?: readonly string[],
|
|
66
|
+
limit?: number,
|
|
67
|
+
offset?: number,
|
|
68
|
+
count?: boolean,
|
|
69
|
+
buckets?: boolean,
|
|
70
|
+
verbose?: boolean,
|
|
71
|
+
concise?: boolean,
|
|
60
72
|
params?: Record<string, string | number | boolean | string[] | number[]> | string,
|
|
61
73
|
headers?: Headers | Record<string, string>,
|
|
62
74
|
timeout?: number,
|
|
@@ -72,33 +84,156 @@ type BaseListResultMeta = {
|
|
|
72
84
|
fields: Array<string>,
|
|
73
85
|
};
|
|
74
86
|
|
|
75
|
-
type
|
|
76
|
-
type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
type
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
type DocField<T extends string> = T extends `${infer U}.${string}` ? U : T;
|
|
88
|
+
type ListResultDocs<
|
|
89
|
+
Document extends Record<string, any>,
|
|
90
|
+
Fields extends string[] | '*' = '*',
|
|
91
|
+
> = Array<Omit<(
|
|
92
|
+
Fields extends '*' ? Partial<Document> :
|
|
93
|
+
Pick<Document, Extract<keyof Document, DocField<Fields[number]>>>
|
|
94
|
+
), '_id'> & { _id: ResourceId }>;
|
|
95
|
+
|
|
96
|
+
type DefaultProductsFields = [
|
|
97
|
+
'sku',
|
|
98
|
+
'slug',
|
|
99
|
+
];
|
|
100
|
+
type ProductsList<Fields extends null | string[] | '*' = '*'> =
|
|
101
|
+
ListResultDocs<Products, Fields extends null ? DefaultProductsFields : Fields>;
|
|
102
|
+
|
|
103
|
+
type DefaultCategoriesFields = [
|
|
104
|
+
'name',
|
|
105
|
+
'slug',
|
|
106
|
+
'parent',
|
|
107
|
+
'icon',
|
|
108
|
+
'pictures.0',
|
|
109
|
+
];
|
|
110
|
+
type CategoriesList<Fields extends null | string[] | '*' = '*'> =
|
|
111
|
+
ListResultDocs<Categories, Fields extends null ? DefaultCategoriesFields : Fields>;
|
|
112
|
+
|
|
113
|
+
type DefaultBrandsFields = [
|
|
114
|
+
'name',
|
|
115
|
+
'slug',
|
|
116
|
+
'logo',
|
|
117
|
+
'pictures.0',
|
|
118
|
+
];
|
|
119
|
+
type BrandsList<Fields extends null | string[] | '*' = '*'> =
|
|
120
|
+
ListResultDocs<Brands, Fields extends null ? DefaultBrandsFields : Fields>;
|
|
121
|
+
|
|
122
|
+
type DefaultCollectionsFields = [
|
|
123
|
+
'name',
|
|
124
|
+
'slug',
|
|
125
|
+
'products',
|
|
126
|
+
'pictures.0',
|
|
127
|
+
];
|
|
128
|
+
type CollectionsList<Fields extends null | string[] | '*' = '*'> =
|
|
129
|
+
ListResultDocs<Collections, Fields extends null ? DefaultCollectionsFields : Fields>;
|
|
130
|
+
|
|
131
|
+
type DefaultGridsFields = [
|
|
132
|
+
'title',
|
|
133
|
+
'grid_id',
|
|
134
|
+
'options.text',
|
|
135
|
+
'options.colors',
|
|
136
|
+
];
|
|
137
|
+
type GridsList<Fields extends null | string[] | '*' = '*'> =
|
|
138
|
+
ListResultDocs<Grids, Fields extends null ? DefaultGridsFields : Fields>;
|
|
139
|
+
|
|
140
|
+
type DefaultCartsFields = [
|
|
141
|
+
'available',
|
|
142
|
+
'completed',
|
|
143
|
+
'permalink',
|
|
144
|
+
'status',
|
|
145
|
+
'customers',
|
|
146
|
+
'other_customers',
|
|
147
|
+
'items.product_id',
|
|
148
|
+
'items.sku',
|
|
149
|
+
'items.name',
|
|
150
|
+
'items.quantity',
|
|
151
|
+
'items.final_price',
|
|
152
|
+
'subtotal',
|
|
153
|
+
];
|
|
154
|
+
type CartsList<Fields extends null | string[] | '*' = '*'> =
|
|
155
|
+
ListResultDocs<Carts, Fields extends null ? DefaultCartsFields : Fields>;
|
|
156
|
+
|
|
157
|
+
type DefaultOrdersFields = [
|
|
158
|
+
'channel_id',
|
|
159
|
+
'number',
|
|
160
|
+
'code',
|
|
161
|
+
'status',
|
|
162
|
+
'financial_status.updated_at',
|
|
163
|
+
'financial_status.current',
|
|
164
|
+
'fulfillment_status.updated_at',
|
|
165
|
+
'fulfillment_status.current',
|
|
166
|
+
'amount',
|
|
167
|
+
'payment_method_label',
|
|
168
|
+
'shipping_method_label',
|
|
169
|
+
'buyers._id',
|
|
170
|
+
'buyers.main_email',
|
|
171
|
+
'buyers.display_name',
|
|
172
|
+
'items.product_id',
|
|
173
|
+
'items.sku',
|
|
174
|
+
'items.name',
|
|
175
|
+
'items.quantity',
|
|
176
|
+
];
|
|
177
|
+
type OrdersList<Fields extends null | string[] | '*' = '*'> =
|
|
178
|
+
ListResultDocs<Orders, Fields extends null ? DefaultOrdersFields : Fields>;
|
|
179
|
+
|
|
180
|
+
type DefaultCustomersFields = [
|
|
181
|
+
'state',
|
|
182
|
+
'enabled',
|
|
183
|
+
'login',
|
|
184
|
+
'status',
|
|
185
|
+
'main_email',
|
|
186
|
+
'accepts_marketing',
|
|
187
|
+
'display_name',
|
|
188
|
+
'orders_count',
|
|
189
|
+
'orders_total_value',
|
|
190
|
+
];
|
|
191
|
+
type CustomersList<Fields extends null | string[] | '*' = '*'> =
|
|
192
|
+
ListResultDocs<Customers, Fields extends null ? DefaultCustomersFields : Fields>;
|
|
193
|
+
|
|
194
|
+
type DefaultStoresFields = [
|
|
195
|
+
'store_id',
|
|
196
|
+
'name',
|
|
197
|
+
'domain',
|
|
198
|
+
];
|
|
199
|
+
type StoresList<Fields extends null | string[] | '*' = '*'> =
|
|
200
|
+
ListResultDocs<Stores, Fields extends null ? DefaultStoresFields : Fields>;
|
|
201
|
+
|
|
202
|
+
type DefaultApplicationsFields = [
|
|
203
|
+
'app_id',
|
|
204
|
+
'title',
|
|
205
|
+
'state',
|
|
206
|
+
'version',
|
|
207
|
+
'type',
|
|
208
|
+
];
|
|
209
|
+
type ApplicationsList<Fields extends null | string[] | '*' = '*'> =
|
|
210
|
+
ListResultDocs<Applications, Fields extends null ? DefaultApplicationsFields : Fields>;
|
|
211
|
+
|
|
212
|
+
type DefaultAuthenticationsFields = [
|
|
213
|
+
'username',
|
|
214
|
+
'email',
|
|
215
|
+
'app',
|
|
216
|
+
];
|
|
217
|
+
type AuthenticationsList<Fields extends null | string[] | '*' = '*'> =
|
|
218
|
+
ListResultDocs<Authentications, Fields extends null ? DefaultAuthenticationsFields : Fields>;
|
|
87
219
|
|
|
88
220
|
type ListEndpoint<TResource extends Resource> = TResource | `${TResource}?${string}`;
|
|
89
|
-
type ResourceListResult<
|
|
221
|
+
type ResourceListResult<
|
|
222
|
+
TEndpoint extends ResourceOpQuery,
|
|
223
|
+
Fields extends string[] | null = TEndpoint extends Resource ? null : '*',
|
|
224
|
+
> = {
|
|
90
225
|
result:
|
|
91
|
-
TEndpoint extends ListEndpoint<'products'> ? ProductsList :
|
|
92
|
-
TEndpoint extends ListEndpoint<'categories'> ? CategoriesList :
|
|
93
|
-
TEndpoint extends ListEndpoint<'brands'> ? BrandsList :
|
|
94
|
-
TEndpoint extends ListEndpoint<'collections'> ? CollectionsList :
|
|
95
|
-
TEndpoint extends ListEndpoint<'grids'> ? GridsList :
|
|
96
|
-
TEndpoint extends ListEndpoint<'carts'> ? CartsList :
|
|
97
|
-
TEndpoint extends ListEndpoint<'orders'> ? OrdersList :
|
|
98
|
-
TEndpoint extends ListEndpoint<'customers'> ? CustomersList :
|
|
99
|
-
TEndpoint extends ListEndpoint<'stores'> ? StoresList :
|
|
100
|
-
TEndpoint extends ListEndpoint<'applications'> ? ApplicationsList :
|
|
101
|
-
TEndpoint extends ListEndpoint<'authentications'> ? AuthenticationsList :
|
|
226
|
+
TEndpoint extends ListEndpoint<'products'> ? ProductsList<Fields> :
|
|
227
|
+
TEndpoint extends ListEndpoint<'categories'> ? CategoriesList<Fields> :
|
|
228
|
+
TEndpoint extends ListEndpoint<'brands'> ? BrandsList<Fields> :
|
|
229
|
+
TEndpoint extends ListEndpoint<'collections'> ? CollectionsList<Fields> :
|
|
230
|
+
TEndpoint extends ListEndpoint<'grids'> ? GridsList<Fields> :
|
|
231
|
+
TEndpoint extends ListEndpoint<'carts'> ? CartsList<Fields> :
|
|
232
|
+
TEndpoint extends ListEndpoint<'orders'> ? OrdersList<Fields> :
|
|
233
|
+
TEndpoint extends ListEndpoint<'customers'> ? CustomersList<Fields> :
|
|
234
|
+
TEndpoint extends ListEndpoint<'stores'> ? StoresList<Fields> :
|
|
235
|
+
TEndpoint extends ListEndpoint<'applications'> ? ApplicationsList<Fields> :
|
|
236
|
+
TEndpoint extends ListEndpoint<'authentications'> ? AuthenticationsList<Fields> :
|
|
102
237
|
never,
|
|
103
238
|
meta: BaseListResultMeta & {
|
|
104
239
|
count?: number,
|
|
@@ -110,6 +245,83 @@ type ResourceListResult<TEndpoint extends ResourceOpQuery> = {
|
|
|
110
245
|
},
|
|
111
246
|
};
|
|
112
247
|
|
|
248
|
+
interface SearchProducts extends Products {
|
|
249
|
+
has_variations: boolean;
|
|
250
|
+
_score: number;
|
|
251
|
+
}
|
|
252
|
+
type DefaultSearchFields = [
|
|
253
|
+
'sku',
|
|
254
|
+
'name',
|
|
255
|
+
'slug',
|
|
256
|
+
'available',
|
|
257
|
+
'visible',
|
|
258
|
+
'price',
|
|
259
|
+
'base_price',
|
|
260
|
+
'quantity',
|
|
261
|
+
'min_quantity',
|
|
262
|
+
'inventory',
|
|
263
|
+
'measurement',
|
|
264
|
+
'condition',
|
|
265
|
+
'warranty',
|
|
266
|
+
'pictures.normal',
|
|
267
|
+
'has_variations',
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
type SearchItem<Fields extends null | string[] | '*' = '*'> = Omit<(
|
|
271
|
+
Fields extends '*' ? Partial<SearchProducts> :
|
|
272
|
+
Pick<
|
|
273
|
+
SearchProducts,
|
|
274
|
+
Extract<keyof SearchProducts,
|
|
275
|
+
DocField<Fields extends null ? DefaultSearchFields[number] : Fields[number]>>
|
|
276
|
+
>
|
|
277
|
+
), '_id' | '_score'> & {
|
|
278
|
+
_id: ResourceId,
|
|
279
|
+
_score: number,
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
type SearchResult<
|
|
283
|
+
TEndpoint extends SearchOpQuery | 'v1' | 'els',
|
|
284
|
+
Fields extends string[] | null = TEndpoint extends 'search/v1' | 'v1' ? null : '*',
|
|
285
|
+
> =
|
|
286
|
+
TEndpoint extends 'search/v1' | `search/v1?${string}` | 'v1' ? {
|
|
287
|
+
result: SearchItem<Fields>[],
|
|
288
|
+
meta: BaseListResultMeta & {
|
|
289
|
+
count?: number,
|
|
290
|
+
sort: Array<{
|
|
291
|
+
field: string,
|
|
292
|
+
order: 1 | -1,
|
|
293
|
+
}>,
|
|
294
|
+
query: { [key: string]: any },
|
|
295
|
+
buckets?: {
|
|
296
|
+
prices?: Array<{
|
|
297
|
+
min: null | number,
|
|
298
|
+
max: null | number,
|
|
299
|
+
avg: null | number,
|
|
300
|
+
count: number,
|
|
301
|
+
}>,
|
|
302
|
+
'brands/name'?: {
|
|
303
|
+
[key: string]: number,
|
|
304
|
+
},
|
|
305
|
+
'categories/name'?: {
|
|
306
|
+
[key: string]: number,
|
|
307
|
+
},
|
|
308
|
+
specs?: {
|
|
309
|
+
[key: string]: number,
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
} :
|
|
314
|
+
TEndpoint extends 'search/_els' | `search/_els?${string}` | 'els' ? {
|
|
315
|
+
hits: {
|
|
316
|
+
hits: SearchItem<'*'>[],
|
|
317
|
+
total: number,
|
|
318
|
+
max_score: null,
|
|
319
|
+
},
|
|
320
|
+
aggregations: Record<string, any>,
|
|
321
|
+
took: number,
|
|
322
|
+
} :
|
|
323
|
+
never;
|
|
324
|
+
|
|
113
325
|
type EventFieldsByEndpoint<TEndpoint extends EventsEndpoint> =
|
|
114
326
|
TEndpoint extends `events/${Resource}` ? {
|
|
115
327
|
resource_id: ResourceId,
|
|
@@ -141,7 +353,14 @@ type EventsResult<TEndpoint extends EventsEndpoint> = {
|
|
|
141
353
|
meta: BaseListResultMeta,
|
|
142
354
|
};
|
|
143
355
|
|
|
144
|
-
type ResponseBody<
|
|
356
|
+
type ResponseBody<
|
|
357
|
+
TConfig extends Config,
|
|
358
|
+
ListFields extends string[] | null = TConfig['endpoint'] extends Resource
|
|
359
|
+
? TConfig['params']['fields'] extends string ? '*'
|
|
360
|
+
: TConfig['fields'] extends readonly string[] ? TConfig['fields']
|
|
361
|
+
: null
|
|
362
|
+
: '*',
|
|
363
|
+
> =
|
|
145
364
|
TConfig['method'] extends 'post' ?
|
|
146
365
|
TConfig['endpoint'] extends 'login' ? { _id: ResourceId, store_ids: number[], api_key: string } :
|
|
147
366
|
TConfig['endpoint'] extends 'authenticate' ? { my_id: string, access_token: string, expires: string } :
|
|
@@ -160,7 +379,8 @@ type ResponseBody<TConfig extends Config> =
|
|
|
160
379
|
TConfig['endpoint'] extends `stores/${ResourceId}` ? Stores :
|
|
161
380
|
TConfig['endpoint'] extends `applications/${ResourceId}` ? Applications :
|
|
162
381
|
TConfig['endpoint'] extends `authentications/${ResourceId}` ? Authentications :
|
|
163
|
-
TConfig['endpoint'] extends ResourceOpQuery ? ResourceListResult<TConfig['endpoint']> :
|
|
382
|
+
TConfig['endpoint'] extends ResourceOpQuery ? ResourceListResult<TConfig['endpoint'], ListFields> :
|
|
383
|
+
TConfig['endpoint'] extends SearchOpQuery ? SearchResult<TConfig['endpoint'], ListFields> :
|
|
164
384
|
TConfig['endpoint'] extends EventsEndpoint ? EventsResult<TConfig['endpoint']> :
|
|
165
385
|
any;
|
|
166
386
|
|
|
@@ -245,11 +465,14 @@ export type {
|
|
|
245
465
|
Resource,
|
|
246
466
|
ResourceId,
|
|
247
467
|
ResourceAndId,
|
|
468
|
+
ResourceAndFind,
|
|
248
469
|
ResourceOpQuery,
|
|
249
470
|
Endpoint,
|
|
250
471
|
Method,
|
|
251
472
|
Config,
|
|
252
473
|
ResourceListResult,
|
|
474
|
+
SearchItem,
|
|
475
|
+
SearchResult,
|
|
253
476
|
EventsResult,
|
|
254
477
|
ResponseBody,
|
|
255
478
|
RequestBody,
|
package/types.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './types.d';
|
package/lib/types/brands.d.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export interface Brands {
|
|
9
|
-
_id: string & { length: 24 };
|
|
10
|
-
created_at: string;
|
|
11
|
-
updated_at: string;
|
|
12
|
-
store_id: number;
|
|
13
|
-
/**
|
|
14
|
-
* @maxItems 10
|
|
15
|
-
*/
|
|
16
|
-
channel_ids?: string[];
|
|
17
|
-
/**
|
|
18
|
-
* Brand full name
|
|
19
|
-
*/
|
|
20
|
-
name: string;
|
|
21
|
-
/**
|
|
22
|
-
* Slug to complete page URL, starting with number or lowercase letter
|
|
23
|
-
*/
|
|
24
|
-
slug?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Short brand description in plain text
|
|
27
|
-
*/
|
|
28
|
-
short_description?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Full brand description, may use HTML tags
|
|
31
|
-
*/
|
|
32
|
-
body_html?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Full brand description, plain text only
|
|
35
|
-
*/
|
|
36
|
-
body_text?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Title tag for page SEO
|
|
39
|
-
*/
|
|
40
|
-
meta_title?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Meta description tag for page SEO
|
|
43
|
-
*/
|
|
44
|
-
meta_description?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Text translations for internationalization
|
|
47
|
-
*/
|
|
48
|
-
i18n?: {
|
|
49
|
-
/**
|
|
50
|
-
* Language specific text fields
|
|
51
|
-
*
|
|
52
|
-
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
53
|
-
* via the `patternProperty` "^[a-z]{2}(_[a-z]{2})?$".
|
|
54
|
-
*/
|
|
55
|
-
[k: string]: {
|
|
56
|
-
/**
|
|
57
|
-
* Brand full name
|
|
58
|
-
*/
|
|
59
|
-
name?: string;
|
|
60
|
-
/**
|
|
61
|
-
* Short brand description in plain text
|
|
62
|
-
*/
|
|
63
|
-
short_description?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Full brand description, may use HTML tags
|
|
66
|
-
*/
|
|
67
|
-
body_html?: string;
|
|
68
|
-
/**
|
|
69
|
-
* Full brand description, plain text only
|
|
70
|
-
*/
|
|
71
|
-
body_text?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Title tag for page SEO
|
|
74
|
-
*/
|
|
75
|
-
meta_title?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Meta description tag for page SEO
|
|
78
|
-
*/
|
|
79
|
-
meta_description?: string;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Brand logo
|
|
84
|
-
*/
|
|
85
|
-
logo?: {
|
|
86
|
-
/**
|
|
87
|
-
* Image link
|
|
88
|
-
*/
|
|
89
|
-
url: string;
|
|
90
|
-
/**
|
|
91
|
-
* Image size (width x height) in px, such as 100x50 (100px width, 50px height)
|
|
92
|
-
*/
|
|
93
|
-
size?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Alternative text, HTML alt tag (important for SEO)
|
|
96
|
-
*/
|
|
97
|
-
alt?: string;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* List of brand images
|
|
101
|
-
*
|
|
102
|
-
* @maxItems 50
|
|
103
|
-
*/
|
|
104
|
-
pictures?: {
|
|
105
|
-
/**
|
|
106
|
-
* Picture ID (ObjectID) [auto]
|
|
107
|
-
*/
|
|
108
|
-
_id?: string;
|
|
109
|
-
/**
|
|
110
|
-
* Tag to identify object, use only lowercase letters, digits and underscore
|
|
111
|
-
*/
|
|
112
|
-
tag?: string;
|
|
113
|
-
/**
|
|
114
|
-
* Image link
|
|
115
|
-
*/
|
|
116
|
-
url: string;
|
|
117
|
-
/**
|
|
118
|
-
* Image size (width x height) in px, such as 100x50 (100px width, 50px height)
|
|
119
|
-
*/
|
|
120
|
-
size?: string;
|
|
121
|
-
/**
|
|
122
|
-
* Alternative text, HTML alt tag (important for SEO)
|
|
123
|
-
*/
|
|
124
|
-
alt?: string;
|
|
125
|
-
}[];
|
|
126
|
-
/**
|
|
127
|
-
* List of custom attributes
|
|
128
|
-
*
|
|
129
|
-
* @maxItems 100
|
|
130
|
-
*/
|
|
131
|
-
metafields?: {
|
|
132
|
-
/**
|
|
133
|
-
* String to help distinguish who (or which app) created and can use the metafield
|
|
134
|
-
*/
|
|
135
|
-
namespace?: string;
|
|
136
|
-
/**
|
|
137
|
-
* Field name
|
|
138
|
-
*/
|
|
139
|
-
field?: string;
|
|
140
|
-
/**
|
|
141
|
-
* Custom property value
|
|
142
|
-
*/
|
|
143
|
-
value: {
|
|
144
|
-
[k: string]: unknown;
|
|
145
|
-
};
|
|
146
|
-
}[];
|
|
147
|
-
/**
|
|
148
|
-
* Flags to associate additional info
|
|
149
|
-
*
|
|
150
|
-
* @maxItems 10
|
|
151
|
-
*/
|
|
152
|
-
flags?: string[];
|
|
153
|
-
/**
|
|
154
|
-
* Optional notes with additional info about this brand
|
|
155
|
-
*/
|
|
156
|
-
notes?: string;
|
|
157
|
-
}
|