@retailcrm/embed-ui 0.4.1-alpha.13 → 0.4.1-alpha.15
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/CHANGELOG.md +6 -0
- package/dist/index.cjs +17 -11
- package/dist/index.mjs +17 -11
- package/dist/meta.json +78 -68
- package/index.d.ts +6 -3
- package/package.json +1 -1
- package/types/context/order/card.d.ts +1 -1
- package/types/context/settings.d.ts +0 -3
- package/types/context/user/current.d.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
## [0.4.1-alpha.15](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.14...v0.4.1-alpha.15) (2024-11-26)
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* Types across schemas, removed artifacts from unsuccessful rebase ([d34514d](https://github.com/retailcrm/embed-ui/commit/d34514df0e6fcdd9b0e9a1a2e9c909e299138284))
|
|
9
|
+
## [0.4.1-alpha.14](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.13...v0.4.1-alpha.14) (2024-11-26)
|
|
4
10
|
## [0.4.1-alpha.13](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.12...v0.4.1-alpha.13) (2024-11-26)
|
|
5
11
|
## [0.4.1-alpha.12](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.11...v0.4.1-alpha.12) (2024-11-26)
|
|
6
12
|
## [0.4.1-alpha.11](https://github.com/retailcrm/embed-ui/compare/v0.4.1-alpha.10...v0.4.1-alpha.11) (2024-11-26)
|
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,9 @@ const defineContext = (id, schema2) => {
|
|
|
56
56
|
const withMeta = (predicate, type) => {
|
|
57
57
|
return Object.assign(predicate, { type });
|
|
58
58
|
};
|
|
59
|
+
const isExactly = (expected) => {
|
|
60
|
+
return withMeta((value) => value === expected, JSON.stringify(expected));
|
|
61
|
+
};
|
|
59
62
|
const isNull = withMeta((value) => value === null, "null");
|
|
60
63
|
const isNumber = withMeta((value) => typeof value === "number", "number");
|
|
61
64
|
const isString = withMeta((value) => typeof value === "string", "string");
|
|
@@ -97,6 +100,11 @@ const schema$4 = {
|
|
|
97
100
|
defaults: () => null,
|
|
98
101
|
readonly: true
|
|
99
102
|
},
|
|
103
|
+
"groups": {
|
|
104
|
+
accepts: arrayOf(isString),
|
|
105
|
+
defaults: () => [],
|
|
106
|
+
readonly: true
|
|
107
|
+
},
|
|
100
108
|
"permissions": {
|
|
101
109
|
accepts: arrayOf(isString),
|
|
102
110
|
defaults: () => [],
|
|
@@ -157,9 +165,12 @@ const schema$1 = {
|
|
|
157
165
|
readonly: true
|
|
158
166
|
},
|
|
159
167
|
"customer.type": {
|
|
160
|
-
accepts: oneOf(
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
accepts: oneOf(
|
|
169
|
+
isExactly("customer"),
|
|
170
|
+
isExactly("customer_corporate")
|
|
171
|
+
),
|
|
172
|
+
defaults: () => "customer",
|
|
173
|
+
readonly: true
|
|
163
174
|
},
|
|
164
175
|
"customer.lastName": {
|
|
165
176
|
accepts: oneOf(isString, isNull),
|
|
@@ -259,13 +270,9 @@ const schema$1 = {
|
|
|
259
270
|
};
|
|
260
271
|
const useContext$1 = defineContext("order/card", schema$1);
|
|
261
272
|
const locales = ["en-GB", "es-ES", "ru-RU"];
|
|
262
|
-
const isLocale = withMeta(
|
|
263
|
-
(value) => locales.includes(value),
|
|
264
|
-
locales.map((l) => `'${l}'`).join(" | ")
|
|
265
|
-
);
|
|
266
273
|
const schema = {
|
|
267
274
|
"system.locale": {
|
|
268
|
-
accepts:
|
|
275
|
+
accepts: oneOf(...locales.map(isExactly)),
|
|
269
276
|
defaults: () => "en-GB",
|
|
270
277
|
readonly: true
|
|
271
278
|
}
|
|
@@ -275,11 +282,10 @@ const useField = (store, field) => {
|
|
|
275
282
|
if (store.schema[field].readonly) {
|
|
276
283
|
return vue.computed(() => store[field]);
|
|
277
284
|
}
|
|
285
|
+
const set = store.set;
|
|
278
286
|
return vue.computed({
|
|
279
287
|
get: () => store[field],
|
|
280
|
-
set: (value) =>
|
|
281
|
-
store.set(field, value);
|
|
282
|
-
}
|
|
288
|
+
set: (value) => set(field, value)
|
|
283
289
|
});
|
|
284
290
|
};
|
|
285
291
|
const useInternal = pinia.defineStore("@retailcrm/embed-ui/_internal", {});
|
package/dist/index.mjs
CHANGED
|
@@ -54,6 +54,9 @@ const defineContext = (id, schema2) => {
|
|
|
54
54
|
const withMeta = (predicate, type) => {
|
|
55
55
|
return Object.assign(predicate, { type });
|
|
56
56
|
};
|
|
57
|
+
const isExactly = (expected) => {
|
|
58
|
+
return withMeta((value) => value === expected, JSON.stringify(expected));
|
|
59
|
+
};
|
|
57
60
|
const isNull = withMeta((value) => value === null, "null");
|
|
58
61
|
const isNumber = withMeta((value) => typeof value === "number", "number");
|
|
59
62
|
const isString = withMeta((value) => typeof value === "string", "string");
|
|
@@ -95,6 +98,11 @@ const schema$4 = {
|
|
|
95
98
|
defaults: () => null,
|
|
96
99
|
readonly: true
|
|
97
100
|
},
|
|
101
|
+
"groups": {
|
|
102
|
+
accepts: arrayOf(isString),
|
|
103
|
+
defaults: () => [],
|
|
104
|
+
readonly: true
|
|
105
|
+
},
|
|
98
106
|
"permissions": {
|
|
99
107
|
accepts: arrayOf(isString),
|
|
100
108
|
defaults: () => [],
|
|
@@ -155,9 +163,12 @@ const schema$1 = {
|
|
|
155
163
|
readonly: true
|
|
156
164
|
},
|
|
157
165
|
"customer.type": {
|
|
158
|
-
accepts: oneOf(
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
accepts: oneOf(
|
|
167
|
+
isExactly("customer"),
|
|
168
|
+
isExactly("customer_corporate")
|
|
169
|
+
),
|
|
170
|
+
defaults: () => "customer",
|
|
171
|
+
readonly: true
|
|
161
172
|
},
|
|
162
173
|
"customer.lastName": {
|
|
163
174
|
accepts: oneOf(isString, isNull),
|
|
@@ -257,13 +268,9 @@ const schema$1 = {
|
|
|
257
268
|
};
|
|
258
269
|
const useContext$1 = defineContext("order/card", schema$1);
|
|
259
270
|
const locales = ["en-GB", "es-ES", "ru-RU"];
|
|
260
|
-
const isLocale = withMeta(
|
|
261
|
-
(value) => locales.includes(value),
|
|
262
|
-
locales.map((l) => `'${l}'`).join(" | ")
|
|
263
|
-
);
|
|
264
271
|
const schema = {
|
|
265
272
|
"system.locale": {
|
|
266
|
-
accepts:
|
|
273
|
+
accepts: oneOf(...locales.map(isExactly)),
|
|
267
274
|
defaults: () => "en-GB",
|
|
268
275
|
readonly: true
|
|
269
276
|
}
|
|
@@ -273,11 +280,10 @@ const useField = (store, field) => {
|
|
|
273
280
|
if (store.schema[field].readonly) {
|
|
274
281
|
return computed(() => store[field]);
|
|
275
282
|
}
|
|
283
|
+
const set = store.set;
|
|
276
284
|
return computed({
|
|
277
285
|
get: () => store[field],
|
|
278
|
-
set: (value) =>
|
|
279
|
-
store.set(field, value);
|
|
280
|
-
}
|
|
286
|
+
set: (value) => set(field, value)
|
|
281
287
|
});
|
|
282
288
|
};
|
|
283
289
|
const useInternal = defineStore("@retailcrm/embed-ui/_internal", {});
|
package/dist/meta.json
CHANGED
|
@@ -1,67 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contexts": {
|
|
3
|
-
"user/current": [
|
|
4
|
-
{
|
|
5
|
-
"name": "id",
|
|
6
|
-
"type": "number | null",
|
|
7
|
-
"description": {
|
|
8
|
-
"en-GB": "User ID",
|
|
9
|
-
"es-ES": "ID del usuario",
|
|
10
|
-
"ru-RU": "ID пользователя"
|
|
11
|
-
},
|
|
12
|
-
"readonly": true
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"name": "email",
|
|
16
|
-
"type": "string",
|
|
17
|
-
"description": {
|
|
18
|
-
"en-GB": "User email",
|
|
19
|
-
"es-ES": "Correo electrónico del usuario",
|
|
20
|
-
"ru-RU": "Email пользователя"
|
|
21
|
-
},
|
|
22
|
-
"readonly": true
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "firstName",
|
|
26
|
-
"type": "string | null",
|
|
27
|
-
"description": {
|
|
28
|
-
"en-GB": "User name",
|
|
29
|
-
"es-ES": "Nombre del usuario",
|
|
30
|
-
"ru-RU": "Имя пользователя"
|
|
31
|
-
},
|
|
32
|
-
"readonly": true
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"name": "lastName",
|
|
36
|
-
"type": "string | null",
|
|
37
|
-
"description": {
|
|
38
|
-
"en-GB": "User last name",
|
|
39
|
-
"es-ES": "Apellido del usuario",
|
|
40
|
-
"ru-RU": "Фамилия пользователя"
|
|
41
|
-
},
|
|
42
|
-
"readonly": true
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"name": "patronymic",
|
|
46
|
-
"type": "string | null",
|
|
47
|
-
"description": {
|
|
48
|
-
"en-GB": "Patronymic of the user",
|
|
49
|
-
"es-ES": "Patronímico del usuario",
|
|
50
|
-
"ru-RU": "Отчество пользователя"
|
|
51
|
-
},
|
|
52
|
-
"readonly": true
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"name": "permissions",
|
|
56
|
-
"type": "Array<string>",
|
|
57
|
-
"description": {
|
|
58
|
-
"en-GB": "Character codes of available user permissions",
|
|
59
|
-
"es-ES": "Códigos de caracteres de los permisos disponibles para el usuario",
|
|
60
|
-
"ru-RU": "Символьные коды доступных пользователю разрешений"
|
|
61
|
-
},
|
|
62
|
-
"readonly": true
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
3
|
"customer/card": [
|
|
66
4
|
{
|
|
67
5
|
"name": "id",
|
|
@@ -159,13 +97,13 @@
|
|
|
159
97
|
},
|
|
160
98
|
{
|
|
161
99
|
"name": "customer.type",
|
|
162
|
-
"type": "
|
|
100
|
+
"type": "\"customer\" | \"customer_corporate\"",
|
|
163
101
|
"description": {
|
|
164
102
|
"en-GB": "Client type",
|
|
165
103
|
"es-ES": "Tipo de cliente",
|
|
166
104
|
"ru-RU": "Тип клиента"
|
|
167
105
|
},
|
|
168
|
-
"readonly":
|
|
106
|
+
"readonly": true
|
|
169
107
|
},
|
|
170
108
|
{
|
|
171
109
|
"name": "customer.lastName",
|
|
@@ -358,10 +296,82 @@
|
|
|
358
296
|
"readonly": false
|
|
359
297
|
}
|
|
360
298
|
],
|
|
299
|
+
"user/current": [
|
|
300
|
+
{
|
|
301
|
+
"name": "id",
|
|
302
|
+
"type": "number | null",
|
|
303
|
+
"description": {
|
|
304
|
+
"en-GB": "User ID",
|
|
305
|
+
"es-ES": "ID del usuario",
|
|
306
|
+
"ru-RU": "ID пользователя"
|
|
307
|
+
},
|
|
308
|
+
"readonly": true
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"name": "email",
|
|
312
|
+
"type": "string",
|
|
313
|
+
"description": {
|
|
314
|
+
"en-GB": "User email",
|
|
315
|
+
"es-ES": "Correo electrónico del usuario",
|
|
316
|
+
"ru-RU": "Email пользователя"
|
|
317
|
+
},
|
|
318
|
+
"readonly": true
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"name": "firstName",
|
|
322
|
+
"type": "string | null",
|
|
323
|
+
"description": {
|
|
324
|
+
"en-GB": "User name",
|
|
325
|
+
"es-ES": "Nombre del usuario",
|
|
326
|
+
"ru-RU": "Имя пользователя"
|
|
327
|
+
},
|
|
328
|
+
"readonly": true
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"name": "lastName",
|
|
332
|
+
"type": "string | null",
|
|
333
|
+
"description": {
|
|
334
|
+
"en-GB": "User last name",
|
|
335
|
+
"es-ES": "Apellido del usuario",
|
|
336
|
+
"ru-RU": "Фамилия пользователя"
|
|
337
|
+
},
|
|
338
|
+
"readonly": true
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "patronymic",
|
|
342
|
+
"type": "string | null",
|
|
343
|
+
"description": {
|
|
344
|
+
"en-GB": "Patronymic of the user",
|
|
345
|
+
"es-ES": "Patronímico del usuario",
|
|
346
|
+
"ru-RU": "Отчество пользователя"
|
|
347
|
+
},
|
|
348
|
+
"readonly": true
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"name": "groups",
|
|
352
|
+
"type": "Array<string>",
|
|
353
|
+
"description": {
|
|
354
|
+
"en-GB": "Symbolic codes of the groups the user belongs to",
|
|
355
|
+
"es-ES": "Códigos simbólicos de los grupos a los que pertenece el usuario",
|
|
356
|
+
"ru-RU": "Символьные коды групп, в которых состоит пользователь"
|
|
357
|
+
},
|
|
358
|
+
"readonly": true
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"name": "permissions",
|
|
362
|
+
"type": "Array<string>",
|
|
363
|
+
"description": {
|
|
364
|
+
"en-GB": "Character codes of available user permissions",
|
|
365
|
+
"es-ES": "Códigos de caracteres de los permisos disponibles para el usuario",
|
|
366
|
+
"ru-RU": "Символьные коды доступных пользователю разрешений"
|
|
367
|
+
},
|
|
368
|
+
"readonly": true
|
|
369
|
+
}
|
|
370
|
+
],
|
|
361
371
|
"settings": [
|
|
362
372
|
{
|
|
363
373
|
"name": "system.locale",
|
|
364
|
-
"type": "
|
|
374
|
+
"type": "\"en-GB\" | \"es-ES\" | \"ru-RU\"",
|
|
365
375
|
"description": {
|
|
366
376
|
"en-GB": "Current system's locale",
|
|
367
377
|
"es-ES": "Configuración regional actual del sistema",
|
|
@@ -507,9 +517,9 @@
|
|
|
507
517
|
"ru-RU": "Виджет для списка позиций заказа"
|
|
508
518
|
},
|
|
509
519
|
"location": {
|
|
510
|
-
"en-GB": "
|
|
511
|
-
"es-ES": "
|
|
512
|
-
"ru-RU": "
|
|
520
|
+
"en-GB": "Section start, right above the input fields",
|
|
521
|
+
"es-ES": "Inicio de la sección, justo encima de los campos de entrada",
|
|
522
|
+
"ru-RU": "Начало секции, над полями ввода"
|
|
513
523
|
},
|
|
514
524
|
"contexts": [
|
|
515
525
|
"order/card",
|
package/index.d.ts
CHANGED
|
@@ -18,7 +18,10 @@ import type { TypeOf } from './types/context/schema'
|
|
|
18
18
|
import type { WidgetRunner } from './types/widget'
|
|
19
19
|
import type { WritableComputedRef } from 'vue'
|
|
20
20
|
|
|
21
|
-
declare type Computed<
|
|
21
|
+
declare type Computed<
|
|
22
|
+
S extends ContextSchema,
|
|
23
|
+
F extends keyof S
|
|
24
|
+
> = IsReadonly<S[F]> extends true ? ComputedRef<TypeOf<S[F]>> : WritableComputedRef<TypeOf<S[F]>>;
|
|
22
25
|
|
|
23
26
|
export declare const createWidgetEndpoint: (
|
|
24
27
|
widget: WidgetRunner,
|
|
@@ -42,7 +45,7 @@ export type ContextStoreDefinition<
|
|
|
42
45
|
Id extends string,
|
|
43
46
|
S extends ContextSchema
|
|
44
47
|
> = StoreDefinition<Id, Context<S>, {
|
|
45
|
-
schema
|
|
48
|
+
schema(): S;
|
|
46
49
|
}, {
|
|
47
50
|
initialize(): Promise<void>;
|
|
48
51
|
set<F extends keyof S>(field: F, value: TypeOf<S[F]>): void;
|
|
@@ -51,7 +54,7 @@ export type ContextStoreDefinition<
|
|
|
51
54
|
export declare const useCustomerCardContext: ContextStoreDefinition<'customer/card', CustomerCardSchema>
|
|
52
55
|
export declare const useCustomerCardPhoneContext: ContextStoreDefinition<'customer/card:phone', CustomerCardPhoneSchema>
|
|
53
56
|
export declare const useOrderCardContext: ContextStoreDefinition<'order/card', OrderCardSchema>
|
|
54
|
-
export declare const useCurrentUserContext
|
|
57
|
+
export declare const useCurrentUserContext: ContextStoreDefinition<'user/current', CurrentUserSchema>
|
|
55
58
|
export declare const useSettingsContext: ContextStoreDefinition<'settings', SettingsSchema>
|
|
56
59
|
|
|
57
60
|
export declare const useField: <S extends ContextSchema, F extends keyof S>(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retailcrm/embed-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.1-alpha.
|
|
4
|
+
"version": "0.4.1-alpha.15",
|
|
5
5
|
"description": "API and components for creating RetailCRM UI extensions",
|
|
6
6
|
"repository": "git@github.com:retailcrm/embed-ui.git",
|
|
7
7
|
"author": "RetailDriverLLC <integration@retailcrm.ru>",
|
|
@@ -4,7 +4,7 @@ export type Schema = {
|
|
|
4
4
|
'id': ReadonlyField<number | null>;
|
|
5
5
|
'externalId': ReadonlyField<string | null>;
|
|
6
6
|
'number': ReadonlyField<string | null>;
|
|
7
|
-
'customer.type': ReadonlyField<
|
|
7
|
+
'customer.type': ReadonlyField<'customer' | 'customer_corporate'>;
|
|
8
8
|
'customer.lastName': Field<string | null>;
|
|
9
9
|
'customer.firstName': Field<string | null>;
|
|
10
10
|
'customer.patronymic': Field<string | null>;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { ReadonlyField } from './schema'
|
|
2
2
|
|
|
3
3
|
export type Locale = 'en-GB' | 'es-ES' | 'ru-RU'
|
|
4
|
-
|
|
5
4
|
export type Schema = {
|
|
6
|
-
'order.templates.number.api': ReadonlyField<string>;
|
|
7
|
-
'order.templates.number.crm': ReadonlyField<string>;
|
|
8
5
|
'system.locale': ReadonlyField<Locale>;
|
|
9
6
|
}
|
|
@@ -3,8 +3,9 @@ import type { ReadonlyField } from '../schema'
|
|
|
3
3
|
export type Schema = {
|
|
4
4
|
'id': ReadonlyField<number | null>;
|
|
5
5
|
'email': ReadonlyField<string>;
|
|
6
|
-
'firstName': ReadonlyField<
|
|
6
|
+
'firstName': ReadonlyField<string | null>;
|
|
7
7
|
'lastName': ReadonlyField<string | null>;
|
|
8
|
-
'patronymic': ReadonlyField<
|
|
8
|
+
'patronymic': ReadonlyField<string | null>;
|
|
9
|
+
'groups': ReadonlyField<string[]>;
|
|
9
10
|
'permissions': ReadonlyField<string[]>;
|
|
10
11
|
}
|