@retailcrm/embed-ui-v1-contexts 0.4.4

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.
Files changed (41) hide show
  1. package/README.md +16 -0
  2. package/dist/common/customer/card-phone.d.ts +6 -0
  3. package/dist/common/customer/card.d.ts +6 -0
  4. package/dist/common/order/card.d.ts +6 -0
  5. package/dist/common/settings.d.ts +7 -0
  6. package/dist/common/user/current.d.ts +6 -0
  7. package/dist/host.cjs +104 -0
  8. package/dist/host.d.ts +16 -0
  9. package/dist/host.js +104 -0
  10. package/dist/meta.json +442 -0
  11. package/dist/predicates.cjs.js +28 -0
  12. package/dist/predicates.d.ts +11 -0
  13. package/dist/predicates.es.js +29 -0
  14. package/dist/remote/customer/card-phone.cjs +20 -0
  15. package/dist/remote/customer/card-phone.d.ts +12 -0
  16. package/dist/remote/customer/card-phone.js +20 -0
  17. package/dist/remote/customer/card.cjs +30 -0
  18. package/dist/remote/customer/card.d.ts +12 -0
  19. package/dist/remote/customer/card.js +30 -0
  20. package/dist/remote/order/card.cjs +138 -0
  21. package/dist/remote/order/card.d.ts +12 -0
  22. package/dist/remote/order/card.js +138 -0
  23. package/dist/remote/settings.cjs +17 -0
  24. package/dist/remote/settings.d.ts +13 -0
  25. package/dist/remote/settings.js +17 -0
  26. package/dist/remote/user/current.cjs +50 -0
  27. package/dist/remote/user/current.d.ts +12 -0
  28. package/dist/remote/user/current.js +50 -0
  29. package/dist/remote.cjs +62 -0
  30. package/dist/remote.d.ts +22 -0
  31. package/dist/remote.js +62 -0
  32. package/dist/utilities.cjs.js +3 -0
  33. package/dist/utilities.d.ts +1 -0
  34. package/dist/utilities.es.js +4 -0
  35. package/package.json +106 -0
  36. package/types/customer/card-phone.d.ts +6 -0
  37. package/types/customer/card.d.ts +8 -0
  38. package/types/index.d.ts +13 -0
  39. package/types/order/card.d.ts +29 -0
  40. package/types/settings.d.ts +6 -0
  41. package/types/user/current.d.ts +12 -0
package/dist/meta.json ADDED
@@ -0,0 +1,442 @@
1
+ {
2
+ "customer/card": {
3
+ "fields": [
4
+ {
5
+ "name": "id",
6
+ "type": "number | null",
7
+ "description": {
8
+ "en-GB": "Customer ID",
9
+ "es-ES": "ID del cliente",
10
+ "ru-RU": "ID клиента"
11
+ },
12
+ "readonly": true
13
+ },
14
+ {
15
+ "name": "externalId",
16
+ "type": "string",
17
+ "description": {
18
+ "en-GB": "Customer external ID",
19
+ "es-ES": "ID externo del cliente",
20
+ "ru-RU": "Внешний ID клиента"
21
+ },
22
+ "readonly": true
23
+ },
24
+ {
25
+ "name": "email",
26
+ "type": "string",
27
+ "description": {
28
+ "en-GB": "Customer email",
29
+ "es-ES": "Correo electrónico del cliente",
30
+ "ru-RU": "Email клиента"
31
+ },
32
+ "readonly": true
33
+ },
34
+ {
35
+ "name": "phones",
36
+ "type": "Array<string>",
37
+ "description": {
38
+ "en-GB": "Customer phone list",
39
+ "es-ES": "Lista de teléfonos del cliente",
40
+ "ru-RU": "Список телефонов клиента"
41
+ },
42
+ "readonly": true
43
+ }
44
+ ],
45
+ "usage": {
46
+ "import": "import { useContext } from '@retailcrm/embed-ui-v1-contexts/remote/customer/card'",
47
+ "call": "const customer = useContext()"
48
+ }
49
+ },
50
+ "customer/card:phone": {
51
+ "fields": [
52
+ {
53
+ "name": "value",
54
+ "type": "string",
55
+ "description": {
56
+ "en-GB": "Customer phone",
57
+ "es-ES": "Teléfono del cliente",
58
+ "ru-RU": "Телефон клиента"
59
+ },
60
+ "readonly": true
61
+ },
62
+ {
63
+ "name": "index",
64
+ "type": "number",
65
+ "description": {
66
+ "en-GB": "Serial number of the phone in the list",
67
+ "es-ES": "Número de serie del teléfono en la lista",
68
+ "ru-RU": "Порядковый номер телефона в списке"
69
+ },
70
+ "readonly": true
71
+ }
72
+ ],
73
+ "usage": {
74
+ "import": "import { useContext } from '@retailcrm/embed-ui-v1-contexts/remote/customer/card-phone'",
75
+ "call": "const phone = useContext()"
76
+ }
77
+ },
78
+ "order/card": {
79
+ "fields": [
80
+ {
81
+ "name": "id",
82
+ "type": "number | null",
83
+ "description": {
84
+ "en-GB": "Order ID in CRM",
85
+ "es-ES": "ID del pedido en CRM",
86
+ "ru-RU": "Идентификатор заказа в CRM"
87
+ },
88
+ "readonly": true
89
+ },
90
+ {
91
+ "name": "externalId",
92
+ "type": "string | null",
93
+ "description": {
94
+ "en-GB": "The order ID in the external source system",
95
+ "es-ES": "El ID del pedido en el sistema de origen externo",
96
+ "ru-RU": "Идентифкатор заказа во внешней системе источника"
97
+ },
98
+ "readonly": true
99
+ },
100
+ {
101
+ "name": "type",
102
+ "type": "string | null",
103
+ "description": {
104
+ "en-GB": "Order type code",
105
+ "es-ES": "Código del tipo de pedido",
106
+ "ru-RU": "Код типа заказа"
107
+ },
108
+ "readonly": true
109
+ },
110
+ {
111
+ "name": "site",
112
+ "type": "string | null",
113
+ "description": {
114
+ "en-GB": "Store code associated with the order",
115
+ "es-ES": "Código de la tienda asociado al pedido",
116
+ "ru-RU": "Код магазина, к которому относится заказ"
117
+ },
118
+ "readonly": true
119
+ },
120
+ {
121
+ "name": "number",
122
+ "type": "string | null",
123
+ "description": {
124
+ "en-GB": "Displayed order number",
125
+ "es-ES": "Número de pedido mostrado",
126
+ "ru-RU": "Отображаемый номер заказа"
127
+ },
128
+ "readonly": true
129
+ },
130
+ {
131
+ "name": "customer.type",
132
+ "type": "\"customer\" | \"customer_corporate\"",
133
+ "description": {
134
+ "en-GB": "Client type",
135
+ "es-ES": "Tipo de cliente",
136
+ "ru-RU": "Тип клиента"
137
+ },
138
+ "readonly": true
139
+ },
140
+ {
141
+ "name": "customer.lastName",
142
+ "type": "string | null",
143
+ "description": {
144
+ "en-GB": "Client last name",
145
+ "es-ES": "Apellido del cliente",
146
+ "ru-RU": "Фамилия клиента"
147
+ },
148
+ "readonly": false
149
+ },
150
+ {
151
+ "name": "customer.firstName",
152
+ "type": "string | null",
153
+ "description": {
154
+ "en-GB": "Client name",
155
+ "es-ES": "Nombre del cliente",
156
+ "ru-RU": "Имя клиента"
157
+ },
158
+ "readonly": false
159
+ },
160
+ {
161
+ "name": "customer.patronymic",
162
+ "type": "string | null",
163
+ "description": {
164
+ "en-GB": "Patronymic of the client",
165
+ "es-ES": "Patronímico del cliente",
166
+ "ru-RU": "Отчество клиента"
167
+ },
168
+ "readonly": false
169
+ },
170
+ {
171
+ "name": "customer.phone",
172
+ "type": "string | null",
173
+ "description": {
174
+ "en-GB": "Customer phone",
175
+ "es-ES": "Teléfono del cliente",
176
+ "ru-RU": "Телефон клиента"
177
+ },
178
+ "readonly": false
179
+ },
180
+ {
181
+ "name": "customer.email",
182
+ "type": "string | null",
183
+ "description": {
184
+ "en-GB": "Customer email",
185
+ "es-ES": "Correo electrónico del cliente",
186
+ "ru-RU": "Email клиента"
187
+ },
188
+ "readonly": false
189
+ },
190
+ {
191
+ "name": "country",
192
+ "type": "string | null",
193
+ "description": {
194
+ "en-GB": "Character code of the country",
195
+ "es-ES": "Código de caracteres del país",
196
+ "ru-RU": "Символьный код страны"
197
+ },
198
+ "readonly": true
199
+ },
200
+ {
201
+ "name": "currency",
202
+ "type": "string",
203
+ "description": {
204
+ "en-GB": "Currency code",
205
+ "es-ES": "Código de moneda",
206
+ "ru-RU": "Символьный код валюты"
207
+ },
208
+ "readonly": true
209
+ },
210
+ {
211
+ "name": "status",
212
+ "type": "string",
213
+ "description": {
214
+ "en-GB": "Order status",
215
+ "es-ES": "Estado del pedido",
216
+ "ru-RU": "Статус заказа"
217
+ },
218
+ "readonly": true
219
+ },
220
+ {
221
+ "name": "company.name",
222
+ "type": "string | null",
223
+ "description": {
224
+ "en-GB": "Company's name",
225
+ "es-ES": "Nombre de la empresa",
226
+ "ru-RU": "Название компании"
227
+ },
228
+ "readonly": false
229
+ },
230
+ {
231
+ "name": "company.legalName",
232
+ "type": "string | null",
233
+ "description": {
234
+ "en-GB": "Full name of the company",
235
+ "es-ES": "Nombre completo de la empresa",
236
+ "ru-RU": "Полное наименование компании"
237
+ },
238
+ "readonly": false
239
+ },
240
+ {
241
+ "name": "company.legalAddress",
242
+ "type": "string | null",
243
+ "description": {
244
+ "en-GB": "Company's registration address",
245
+ "es-ES": "Dirección de registro de la empresa",
246
+ "ru-RU": "Адрес регистрации компании"
247
+ },
248
+ "readonly": false
249
+ },
250
+ {
251
+ "name": "company.INN",
252
+ "type": "string | null",
253
+ "description": {
254
+ "en-GB": "Counterparty's INN",
255
+ "es-ES": "INN del contraparte",
256
+ "ru-RU": "ИНН контрагента"
257
+ },
258
+ "readonly": false
259
+ },
260
+ {
261
+ "name": "company.OKPO",
262
+ "type": "string | null",
263
+ "description": {
264
+ "en-GB": "OKPO of the counterparty",
265
+ "es-ES": "OKPO del contraparte",
266
+ "ru-RU": "ОКПО контрагента"
267
+ },
268
+ "readonly": false
269
+ },
270
+ {
271
+ "name": "company.BIK",
272
+ "type": "string | null",
273
+ "description": {
274
+ "en-GB": "Counterparty's BIC",
275
+ "es-ES": "BIC del contraparte",
276
+ "ru-RU": "БИК контрагента"
277
+ },
278
+ "readonly": false
279
+ },
280
+ {
281
+ "name": "company.bank",
282
+ "type": "string | null",
283
+ "description": {
284
+ "en-GB": "Counterparty's bank",
285
+ "es-ES": "Banco del contraparte",
286
+ "ru-RU": "Банк контрагента"
287
+ },
288
+ "readonly": false
289
+ },
290
+ {
291
+ "name": "company.bankAddress",
292
+ "type": "string | null",
293
+ "description": {
294
+ "en-GB": "The address of the counterparty's bank",
295
+ "es-ES": "Dirección del banco del contraparte",
296
+ "ru-RU": "Адрес банка контрагента"
297
+ },
298
+ "readonly": false
299
+ },
300
+ {
301
+ "name": "company.corrAccount",
302
+ "type": "string | null",
303
+ "description": {
304
+ "en-GB": "Correspondent account of the counterparty",
305
+ "es-ES": "Cuenta corresponsal del contraparte",
306
+ "ru-RU": "Корреспондентский счет контрагента"
307
+ },
308
+ "readonly": false
309
+ },
310
+ {
311
+ "name": "company.bankAccount",
312
+ "type": "string | null",
313
+ "description": {
314
+ "en-GB": "Counterparty's current account",
315
+ "es-ES": "Cuenta corriente del contraparte",
316
+ "ru-RU": "Расчетный счет контрагента"
317
+ },
318
+ "readonly": false
319
+ },
320
+ {
321
+ "name": "delivery.address",
322
+ "type": "string | null",
323
+ "description": {
324
+ "en-GB": "Delivery address",
325
+ "es-ES": "Dirección de entrega",
326
+ "ru-RU": "Адрес доставки"
327
+ },
328
+ "readonly": false
329
+ }
330
+ ],
331
+ "usage": {
332
+ "import": "import { useContext } from '@retailcrm/embed-ui-v1-contexts/remote/order/card'",
333
+ "call": "const order = useContext()"
334
+ }
335
+ },
336
+ "user/current": {
337
+ "fields": [
338
+ {
339
+ "name": "id",
340
+ "type": "number | null",
341
+ "description": {
342
+ "en-GB": "User ID",
343
+ "es-ES": "ID del usuario",
344
+ "ru-RU": "ID пользователя"
345
+ },
346
+ "readonly": true
347
+ },
348
+ {
349
+ "name": "email",
350
+ "type": "string",
351
+ "description": {
352
+ "en-GB": "User email",
353
+ "es-ES": "Correo electrónico del usuario",
354
+ "ru-RU": "Email пользователя"
355
+ },
356
+ "readonly": true
357
+ },
358
+ {
359
+ "name": "firstName",
360
+ "type": "string | null",
361
+ "description": {
362
+ "en-GB": "User name",
363
+ "es-ES": "Nombre del usuario",
364
+ "ru-RU": "Имя пользователя"
365
+ },
366
+ "readonly": true
367
+ },
368
+ {
369
+ "name": "lastName",
370
+ "type": "string | null",
371
+ "description": {
372
+ "en-GB": "User last name",
373
+ "es-ES": "Apellido del usuario",
374
+ "ru-RU": "Фамилия пользователя"
375
+ },
376
+ "readonly": true
377
+ },
378
+ {
379
+ "name": "patronymic",
380
+ "type": "string | null",
381
+ "description": {
382
+ "en-GB": "Patronymic of the user",
383
+ "es-ES": "Patronímico del usuario",
384
+ "ru-RU": "Отчество пользователя"
385
+ },
386
+ "readonly": true
387
+ },
388
+ {
389
+ "name": "photo",
390
+ "type": "string | null",
391
+ "description": {
392
+ "en-GB": "User photo",
393
+ "es-ES": "Foto del usuario",
394
+ "ru-RU": "Фото пользователя"
395
+ },
396
+ "readonly": true
397
+ },
398
+ {
399
+ "name": "groups",
400
+ "type": "Array<string>",
401
+ "description": {
402
+ "en-GB": "Symbolic codes of the groups the user belongs to",
403
+ "es-ES": "Códigos simbólicos de los grupos a los que pertenece el usuario",
404
+ "ru-RU": "Символьные коды групп, в которых состоит пользователь"
405
+ },
406
+ "readonly": true
407
+ },
408
+ {
409
+ "name": "permissions",
410
+ "type": "Array<string>",
411
+ "description": {
412
+ "en-GB": "Character codes of available user permissions",
413
+ "es-ES": "Códigos de caracteres de los permisos disponibles para el usuario",
414
+ "ru-RU": "Символьные коды доступных пользователю разрешений"
415
+ },
416
+ "readonly": true
417
+ }
418
+ ],
419
+ "usage": {
420
+ "import": "import { useContext } from '@retailcrm/embed-ui-v1-contexts/remote/user/current'",
421
+ "call": "const user = useContext()"
422
+ }
423
+ },
424
+ "settings": {
425
+ "fields": [
426
+ {
427
+ "name": "system.locale",
428
+ "type": "\"en-GB\" | \"es-ES\" | \"ru-RU\"",
429
+ "description": {
430
+ "en-GB": "Current system's locale",
431
+ "es-ES": "Configuración regional actual del sistema",
432
+ "ru-RU": "Текущая локаль системы"
433
+ },
434
+ "readonly": true
435
+ }
436
+ ],
437
+ "usage": {
438
+ "import": "import { useContext } from '@retailcrm/embed-ui-v1-contexts/remote/settings'",
439
+ "call": "const settings = useContext()"
440
+ }
441
+ }
442
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ const withMeta = (predicate, type) => {
3
+ return Object.assign(predicate, { type });
4
+ };
5
+ const isExactly = (expected) => {
6
+ return withMeta((value) => value === expected, JSON.stringify(expected));
7
+ };
8
+ const isNull = withMeta((value) => value === null, "null");
9
+ const isNumber = withMeta((value) => typeof value === "number", "number");
10
+ const isString = withMeta((value) => typeof value === "string", "string");
11
+ const arrayOf = (predicate) => withMeta(
12
+ (value) => {
13
+ return Array.isArray(value) && value.every(predicate);
14
+ },
15
+ `Array<${predicate.type}>`
16
+ );
17
+ const oneOf = (...predicates) => withMeta(
18
+ (value) => {
19
+ return predicates.some((predicate) => predicate(value));
20
+ },
21
+ predicates.map((p) => p.type).join(" | ")
22
+ );
23
+ exports.arrayOf = arrayOf;
24
+ exports.isExactly = isExactly;
25
+ exports.isNull = isNull;
26
+ exports.isNumber = isNumber;
27
+ exports.isString = isString;
28
+ exports.oneOf = oneOf;
@@ -0,0 +1,11 @@
1
+ export type Predicate<T = unknown> = (value: unknown) => value is T;
2
+ export type PredicateWithMeta<T = unknown> = Predicate<T> & {
3
+ type: string;
4
+ };
5
+ export declare const withMeta: <T>(predicate: Predicate<T>, type: string) => PredicateWithMeta<T>;
6
+ export declare const isExactly: <T extends string | number>(expected: T) => PredicateWithMeta<T>;
7
+ export declare const isNull: PredicateWithMeta<null>;
8
+ export declare const isNumber: PredicateWithMeta<number>;
9
+ export declare const isString: PredicateWithMeta<string>;
10
+ export declare const arrayOf: <T>(predicate: PredicateWithMeta<T>) => PredicateWithMeta<T[]>;
11
+ export declare const oneOf: (...predicates: PredicateWithMeta[]) => PredicateWithMeta<unknown>;
@@ -0,0 +1,29 @@
1
+ const withMeta = (predicate, type) => {
2
+ return Object.assign(predicate, { type });
3
+ };
4
+ const isExactly = (expected) => {
5
+ return withMeta((value) => value === expected, JSON.stringify(expected));
6
+ };
7
+ const isNull = withMeta((value) => value === null, "null");
8
+ const isNumber = withMeta((value) => typeof value === "number", "number");
9
+ const isString = withMeta((value) => typeof value === "string", "string");
10
+ const arrayOf = (predicate) => withMeta(
11
+ (value) => {
12
+ return Array.isArray(value) && value.every(predicate);
13
+ },
14
+ `Array<${predicate.type}>`
15
+ );
16
+ const oneOf = (...predicates) => withMeta(
17
+ (value) => {
18
+ return predicates.some((predicate) => predicate(value));
19
+ },
20
+ predicates.map((p) => p.type).join(" | ")
21
+ );
22
+ export {
23
+ arrayOf as a,
24
+ isNull as b,
25
+ isNumber as c,
26
+ isExactly as d,
27
+ isString as i,
28
+ oneOf as o
29
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const remote = require("../../remote.cjs");
4
+ const predicates = require("../../predicates.cjs.js");
5
+ const id = "customer/card:phone";
6
+ const schema = {
7
+ value: {
8
+ accepts: predicates.isString,
9
+ defaults: () => "",
10
+ readonly: true
11
+ },
12
+ index: {
13
+ accepts: predicates.isNumber,
14
+ defaults: () => 0,
15
+ readonly: true
16
+ }
17
+ };
18
+ const useContext = remote.defineContext(id, schema);
19
+ exports.schema = schema;
20
+ exports.useContext = useContext;
@@ -0,0 +1,12 @@
1
+ import { schema } from '../../common/customer/card-phone';
2
+ import { StoreDefinition } from 'pinia';
3
+ import { Context, TypeOf, RejectionHandler } from '@retailcrm/embed-ui-v1-types/context';
4
+ import { Schema } from '../../../types/customer/card-phone';
5
+ import { Maybe } from '@retailcrm/embed-ui-v1-types/scaffolding';
6
+ export { schema };
7
+ export declare const useContext: StoreDefinition<"customer/card:phone", Context<Schema>, {
8
+ schema: () => Schema;
9
+ }, {
10
+ initialize(): Promise<void>;
11
+ set<F extends never>(field: F, value: TypeOf< Schema[F]>, onReject?: Maybe<RejectionHandler>): void;
12
+ }>;
@@ -0,0 +1,20 @@
1
+ import { defineContext } from "../../remote.js";
2
+ import { i as isString, c as isNumber } from "../../predicates.es.js";
3
+ const id = "customer/card:phone";
4
+ const schema = {
5
+ value: {
6
+ accepts: isString,
7
+ defaults: () => "",
8
+ readonly: true
9
+ },
10
+ index: {
11
+ accepts: isNumber,
12
+ defaults: () => 0,
13
+ readonly: true
14
+ }
15
+ };
16
+ const useContext = defineContext(id, schema);
17
+ export {
18
+ schema,
19
+ useContext
20
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const remote = require("../../remote.cjs");
4
+ const predicates = require("../../predicates.cjs.js");
5
+ const id = "customer/card";
6
+ const schema = {
7
+ "id": {
8
+ accepts: predicates.oneOf(predicates.isNumber, predicates.isNull),
9
+ defaults: () => null,
10
+ readonly: true
11
+ },
12
+ "externalId": {
13
+ accepts: predicates.isString,
14
+ defaults: () => null,
15
+ readonly: true
16
+ },
17
+ "email": {
18
+ accepts: predicates.isString,
19
+ defaults: () => "",
20
+ readonly: true
21
+ },
22
+ "phones": {
23
+ accepts: predicates.arrayOf(predicates.isString),
24
+ defaults: () => [],
25
+ readonly: true
26
+ }
27
+ };
28
+ const useContext = remote.defineContext(id, schema);
29
+ exports.schema = schema;
30
+ exports.useContext = useContext;
@@ -0,0 +1,12 @@
1
+ import { schema } from '../../common/customer/card';
2
+ import { StoreDefinition } from 'pinia';
3
+ import { Context, TypeOf, RejectionHandler } from '@retailcrm/embed-ui-v1-types/context';
4
+ import { Schema } from '../../../types/customer/card';
5
+ import { Maybe } from '@retailcrm/embed-ui-v1-types/scaffolding';
6
+ export { schema };
7
+ export declare const useContext: StoreDefinition<"customer/card", Context<Schema>, {
8
+ schema: () => Schema;
9
+ }, {
10
+ initialize(): Promise<void>;
11
+ set<F extends never>(field: F, value: TypeOf< Schema[F]>, onReject?: Maybe<RejectionHandler>): void;
12
+ }>;
@@ -0,0 +1,30 @@
1
+ import { defineContext } from "../../remote.js";
2
+ import { o as oneOf, i as isString, a as arrayOf, b as isNull, c as isNumber } from "../../predicates.es.js";
3
+ const id = "customer/card";
4
+ const schema = {
5
+ "id": {
6
+ accepts: oneOf(isNumber, isNull),
7
+ defaults: () => null,
8
+ readonly: true
9
+ },
10
+ "externalId": {
11
+ accepts: isString,
12
+ defaults: () => null,
13
+ readonly: true
14
+ },
15
+ "email": {
16
+ accepts: isString,
17
+ defaults: () => "",
18
+ readonly: true
19
+ },
20
+ "phones": {
21
+ accepts: arrayOf(isString),
22
+ defaults: () => [],
23
+ readonly: true
24
+ }
25
+ };
26
+ const useContext = defineContext(id, schema);
27
+ export {
28
+ schema,
29
+ useContext
30
+ };