@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.
@@ -1,523 +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
- /**
9
- * Customer object model
10
- */
11
- export interface Customers {
12
- _id: string & { length: 24 };
13
- created_at: string;
14
- updated_at: string;
15
- store_id: number;
16
- /**
17
- * Whether customer was registered by staff and is trusted
18
- */
19
- staff_signature?: boolean;
20
- /**
21
- * The state of registration, if completed, invited and waiting, or declined by customer
22
- */
23
- state?: 'invited' | 'registered' | 'declined';
24
- /**
25
- * Whether customer account is enabled to make orders
26
- */
27
- enabled?: boolean;
28
- /**
29
- * Whether the customer can sign in to the store with this account
30
- */
31
- login?: boolean;
32
- /**
33
- * Status defined by seller, such as active or blocked
34
- */
35
- status?: string;
36
- /**
37
- * Code to identify the affiliate that referred the customer
38
- */
39
- affiliate_code?: string;
40
- /**
41
- * UTM campaign HTTP parameters associated with this customer's first access
42
- */
43
- utm?: {
44
- /**
45
- * Parameter 'utm_source', the referrer: (e.g. 'google', 'newsletter')
46
- */
47
- source?: string;
48
- /**
49
- * Parameter 'utm_medium', the marketing medium: (e.g. 'cpc', 'banner', 'email')
50
- */
51
- medium?: string;
52
- /**
53
- * Parameter 'utm_campaign', the product, promo code, or slogan (e.g. 'spring_sale')
54
- */
55
- campaign?: string;
56
- /**
57
- * Parameter 'utm_term', identifies the paid keywords
58
- */
59
- term?: string;
60
- /**
61
- * Parameter 'utm_content', used to differentiate ads
62
- */
63
- content?: string;
64
- };
65
- /**
66
- * Providers for OAuth authentication
67
- *
68
- * @maxItems 20
69
- */
70
- oauth_providers?: {
71
- /**
72
- * The provider with which the user authenticated, e.g.: 'facebook'
73
- */
74
- provider: string;
75
- /**
76
- * Unique ID for the user generated by the service provider
77
- */
78
- user_id: string;
79
- }[];
80
- /**
81
- * Customer language two letters code, sometimes with region, e.g.: 'pt_br', 'fr', 'en_us'
82
- */
83
- locale?: string;
84
- /**
85
- * Customer main email address
86
- */
87
- main_email: string;
88
- /**
89
- * Customer email addresses list
90
- *
91
- * @maxItems 20
92
- */
93
- emails?: {
94
- /**
95
- * The actual email address
96
- */
97
- address: string;
98
- /**
99
- * The type of email
100
- */
101
- type?: 'home' | 'personal' | 'work' | 'other';
102
- /**
103
- * States whether or not the email address has been verified
104
- */
105
- verified?: boolean;
106
- }[];
107
- /**
108
- * Indicates whether customer would like to receive email updates from the shop
109
- */
110
- accepts_marketing?: boolean;
111
- /**
112
- * The name of this Customer, suitable for display
113
- */
114
- display_name: string;
115
- /**
116
- * Customer name object
117
- */
118
- name?: {
119
- /**
120
- * The family name of this user, or "last name"
121
- */
122
- family_name?: string;
123
- /**
124
- * The "first name" of this user
125
- */
126
- given_name?: string;
127
- /**
128
- * The middle name(s) of this user
129
- */
130
- middle_name?: string;
131
- };
132
- /**
133
- * Date of customer birth
134
- */
135
- birth_date?: {
136
- /**
137
- * Day of birth
138
- */
139
- day?: number;
140
- /**
141
- * Number of month of birth
142
- */
143
- month?: number;
144
- /**
145
- * Year of birth
146
- */
147
- year?: number;
148
- };
149
- /**
150
- * Customer preferred pronoun
151
- */
152
- pronoun?: 'he' | 'she';
153
- /**
154
- * User profile pictures
155
- *
156
- * @maxItems 20
157
- */
158
- photos?: string[];
159
- /**
160
- * List of customer phone numbers
161
- *
162
- * @maxItems 20
163
- */
164
- phones?: {
165
- /**
166
- * Country calling code (without +), defined by standards E.123 and E.164
167
- */
168
- country_code?: number;
169
- /**
170
- * The actual phone number, digits only
171
- */
172
- number: string;
173
- /**
174
- * The type of phone
175
- */
176
- type?: 'home' | 'personal' | 'work' | 'other';
177
- }[];
178
- /**
179
- * Physical or juridical (company) person
180
- */
181
- registry_type?: 'p' | 'j';
182
- /**
183
- * Country of document origin, an ISO 3166-2 code
184
- */
185
- doc_country?: string;
186
- /**
187
- * Responsible person or organization document number (only numbers)
188
- */
189
- doc_number?: string;
190
- /**
191
- * Municipal or state registration if exists
192
- */
193
- inscription_type?: 'State' | 'Municipal';
194
- /**
195
- * Municipal or state registration number (with characters) if exists
196
- */
197
- inscription_number?: string;
198
- /**
199
- * Registered company name or responsible fullname
200
- */
201
- corporate_name?: string;
202
- /**
203
- * List of customer shipping addresses
204
- *
205
- * @maxItems 40
206
- */
207
- addresses?: {
208
- /**
209
- * ZIP (CEP, postal...) code
210
- */
211
- zip: string;
212
- /**
213
- * Street or public place name
214
- */
215
- street?: string;
216
- /**
217
- * House or building street number
218
- */
219
- number?: number;
220
- /**
221
- * Address complement or second line, such as apartment number
222
- */
223
- complement?: string;
224
- /**
225
- * Borough name
226
- */
227
- borough?: string;
228
- /**
229
- * Some optional other reference for this address
230
- */
231
- near_to?: string;
232
- /**
233
- * Full in line mailing address, should include street, number and borough
234
- */
235
- line_address?: string;
236
- /**
237
- * City name
238
- */
239
- city?: string;
240
- /**
241
- * Country name
242
- */
243
- country?: string;
244
- /**
245
- * An ISO 3166-2 country code
246
- */
247
- country_code?: string;
248
- /**
249
- * Province or state name
250
- */
251
- province?: string;
252
- /**
253
- * The two-letter code for the province or state
254
- */
255
- province_code?: string;
256
- /**
257
- * The name of recipient, generally is the customer's name
258
- */
259
- name?: string;
260
- /**
261
- * The recipient's last name
262
- */
263
- last_name?: string;
264
- /**
265
- * Customer phone number for this mailing address
266
- */
267
- phone?: {
268
- /**
269
- * Country calling code (without +), defined by standards E.123 and E.164
270
- */
271
- country_code?: number;
272
- /**
273
- * The actual phone number, digits only
274
- */
275
- number: string;
276
- };
277
- /**
278
- * Indicates whether this address is the default address for the customer
279
- */
280
- default?: boolean;
281
- }[];
282
- /**
283
- * Products marked as favorites
284
- *
285
- * @maxItems 3000
286
- */
287
- favorites?: string[];
288
- /**
289
- * Last products visited by the customer
290
- *
291
- * @maxItems 100
292
- */
293
- last_visited_products?: string[];
294
- /**
295
- * Last terms searched on shop by the customer
296
- *
297
- * @maxItems 100
298
- */
299
- last_searched_terms?: string[];
300
- /**
301
- * Default currency for the user, designator according to ISO 4217 (3 uppercase letters)
302
- */
303
- currency_id?: string;
304
- /**
305
- * Graphic symbol used as a shorthand for currency's name
306
- */
307
- currency_symbol?: string;
308
- /**
309
- * Total number of orders completed by this customer
310
- */
311
- orders_count?: number;
312
- /**
313
- * The total amount in orders completed by this customer
314
- */
315
- orders_total_value?: number;
316
- /**
317
- * List of customer accumulated loyalty points by program and expiration
318
- *
319
- * @maxItems 1000
320
- */
321
- loyalty_points_entries?: {
322
- /**
323
- * The name of the loyalty points program
324
- */
325
- name?: string;
326
- /**
327
- * Unique identifier, program name using only lowercase, numbers and underscore
328
- */
329
- program_id: string;
330
- /**
331
- * Number of loyalty points earned
332
- */
333
- earned_points?: number;
334
- /**
335
- * Number of active (not yet used) loyalty points
336
- */
337
- active_points: number;
338
- /**
339
- * The ratio of a point when converted to currency
340
- */
341
- ratio?: number;
342
- /**
343
- * Validity of the points entry, until this date the active points can be converted
344
- */
345
- valid_thru?: string;
346
- /**
347
- * Points origin order ID (ObjectID)
348
- */
349
- order_id?: string;
350
- }[];
351
- /**
352
- * The total amount of money that this customer has spent at the store
353
- */
354
- total_spent?: number;
355
- /**
356
- * The total amount in cancelled orders
357
- */
358
- total_cancelled?: number;
359
- /**
360
- * List of customer orders
361
- *
362
- * @maxItems 1000
363
- */
364
- orders?: {
365
- /**
366
- * Order ID (ObjectID)
367
- */
368
- _id: string & { length: 24 };
369
- /**
370
- * When order was saved, date and time in ISO 8601 standard representation
371
- */
372
- created_at?: string;
373
- /**
374
- * Auto incremented order number
375
- */
376
- number?: number;
377
- /**
378
- * Designator of currency according to ISO 4217 (3 uppercase letters)
379
- */
380
- currency_id?: string;
381
- /**
382
- * Graphic symbol used as a shorthand for currency's name
383
- */
384
- currency_symbol?: string;
385
- /**
386
- * Object with sums of values
387
- */
388
- amount?: {
389
- /**
390
- * Order total amount
391
- */
392
- total: number;
393
- /**
394
- * The sum of all items prices
395
- */
396
- subtotal?: number;
397
- /**
398
- * Order freight cost
399
- */
400
- freight?: number;
401
- /**
402
- * Applied discount value
403
- */
404
- discount?: number;
405
- /**
406
- * Value deducted via balance in wallet or loyalty points
407
- */
408
- balance?: number;
409
- /**
410
- * The sum of all the taxes applied to the order
411
- */
412
- tax?: number;
413
- /**
414
- * Sum of optional extra costs applied
415
- */
416
- extra?: number;
417
- };
418
- /**
419
- * Name or summary of order payment method(s)
420
- */
421
- payment_method_label?: string;
422
- /**
423
- * Name of order shipping method(s)
424
- */
425
- shipping_method_label?: string;
426
- }[];
427
- /**
428
- * List of customer saved credit cards
429
- *
430
- * @maxItems 40
431
- */
432
- credit_cards?: {
433
- /**
434
- * Full name of the holder, as it is on the credit card
435
- */
436
- holder_name?: string;
437
- /**
438
- * Issuer identification number (IIN), known as bank identification number (BIN)
439
- */
440
- bin?: number;
441
- /**
442
- * Credit card issuer name, eg.: Visa, American Express, MasterCard
443
- */
444
- company?: string;
445
- /**
446
- * Last digits (up to 4) of credit card number
447
- */
448
- last_digits: string;
449
- /**
450
- * Unique credit card token
451
- */
452
- token: string;
453
- /**
454
- * Payment intermediator
455
- */
456
- intermediator: {
457
- /**
458
- * Gateway name standardized as identification code
459
- */
460
- code: string;
461
- /**
462
- * ID of respective customer account in the intermediator
463
- */
464
- buyer_id?: string;
465
- };
466
- }[];
467
- /**
468
- * List of custom attributes
469
- *
470
- * @maxItems 100
471
- */
472
- metafields?: {
473
- /**
474
- * String to help distinguish who (or which app) created and can use the metafield
475
- */
476
- namespace?: string;
477
- /**
478
- * Field name
479
- */
480
- field?: string;
481
- /**
482
- * Custom property value
483
- */
484
- value: {
485
- [k: string]: unknown;
486
- };
487
- }[];
488
- /**
489
- * List of custom attributes
490
- *
491
- * @maxItems 100
492
- */
493
- hidden_metafields?: {
494
- /**
495
- * String to help distinguish who (or which app) created and can use the metafield
496
- */
497
- namespace?: string;
498
- /**
499
- * Field name
500
- */
501
- field?: string;
502
- /**
503
- * Custom property value
504
- */
505
- value: {
506
- [k: string]: unknown;
507
- };
508
- }[];
509
- /**
510
- * Flags to associate additional info
511
- *
512
- * @maxItems 10
513
- */
514
- flags?: string[];
515
- /**
516
- * Optional notes with additional info about this customer
517
- */
518
- notes?: string;
519
- /**
520
- * Description and notes about this customer, available only for shop administrators
521
- */
522
- staff_notes?: string;
523
- }
package/lib/types.d.ts DELETED
@@ -1,132 +0,0 @@
1
- import type { Products } from './types/products';
2
- import type { Categories } from './types/categories';
3
- import type { Brands } from './types/brands';
4
- import type { Collections } from './types/collections';
5
- import type { Grids } from './types/grids';
6
- import type { Carts } from './types/carts';
7
- import type { Orders } from './types/orders';
8
- import type { Customers } from './types/customers';
9
- import type { Stores } from './types/stores';
10
- import type { Applications } from './types/applications';
11
- import type { Authentications } from './types/authentications';
12
- type Resource = 'products' | 'categories' | 'brands' | 'collections' | 'grids' | 'carts' | 'orders' | 'customers' | 'stores' | 'applications' | 'authentications';
13
- type ResourceId = string & {
14
- length: 24;
15
- };
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
- baseUrl?: string;
23
- storeId?: number;
24
- accessToken?: string;
25
- authenticationId?: string;
26
- apiKey?: string;
27
- isNoAuth?: boolean;
28
- lang?: string;
29
- method?: Method;
30
- endpoint: Endpoint;
31
- params?: Record<string, string | number | boolean | string[] | number[]> | string;
32
- headers?: Headers | Record<string, string>;
33
- timeout?: number;
34
- maxRetries?: number;
35
- canCache?: boolean;
36
- cacheMaxAge?: number;
37
- fetch?: typeof fetch;
38
- };
39
- type BaseListResultMeta = {
40
- offset: number;
41
- limit: number;
42
- fields: Array<string>;
43
- };
44
- type ListResultDocs<Document extends any> = Array<Partial<Document> & {
45
- _id: ResourceId;
46
- }>;
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
- 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
- meta: BaseListResultMeta & {
62
- count?: number;
63
- sort: Array<{
64
- field: string;
65
- order: 1 | -1;
66
- }>;
67
- query: {
68
- [key: string]: any;
69
- };
70
- };
71
- };
72
- type EventFieldsByEndpoint<TEndpoint extends EventsEndpoint> = TEndpoint extends `events/${Resource}` ? {
73
- resource_id: ResourceId;
74
- authentication_id: ResourceId | null;
75
- } : TEndpoint extends `events/${ResourceAndId}` ? {
76
- authentication_id: ResourceId | null;
77
- } : TEndpoint extends 'events/me' ? {
78
- resource: Resource;
79
- resource_id: ResourceId;
80
- } : never;
81
- type EventsResult<TEndpoint extends EventsEndpoint> = {
82
- result: Array<{
83
- timestamp: string;
84
- store_id?: number;
85
- resource?: string;
86
- authentication_id?: ResourceId | null;
87
- resource_id?: ResourceId;
88
- action: string;
89
- modified_fields: string[];
90
- method?: number | undefined;
91
- endpoint?: string;
92
- body?: any;
93
- ip?: string;
94
- } & EventFieldsByEndpoint<TEndpoint>>;
95
- meta: BaseListResultMeta;
96
- };
97
- type ResponseBody<TConfig extends Config> = TConfig['method'] extends 'post' ? TConfig['endpoint'] extends 'login' ? {
98
- _id: ResourceId;
99
- store_ids: number[];
100
- api_key: string;
101
- } : TConfig['endpoint'] extends 'authenticate' ? {
102
- my_id: string;
103
- access_token: string;
104
- expires: string;
105
- } : {
106
- _id: ResourceId;
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
- 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
- status: number;
124
- error_code: number;
125
- message: string;
126
- user_message?: {
127
- en_us: string;
128
- pt_br: string;
129
- };
130
- more_info?: string;
131
- };
132
- export type { Products, Categories, Brands, Collections, Grids, Carts, Orders, Customers, Stores, Applications, Authentications, ProductSet, CategorySet, BrandSet, CollectionSet, GridSet, CartSet, OrderSet, CustomerSet, StoreSet, ApplicationSet, AuthenticationSet, ProductsList, CategoriesList, BrandsList, CollectionsList, GridsList, CartsList, OrdersList, CustomersList, StoresList, ApplicationsList, AuthenticationsList, Resource, ResourceId, ResourceAndId, ResourceOpQuery, Endpoint, Method, Config, ResourceListResult, EventsResult, ResponseBody, RequestBody, ErrorBody, };
package/lib/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- // # sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}