@retailcrm/embed-ui-v1-types 0.5.2-alpha.4 → 0.5.2

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 (2) hide show
  1. package/context.d.ts +2 -98
  2. package/package.json +1 -1
package/context.d.ts CHANGED
@@ -24,12 +24,10 @@ export type ContextSchema = {
24
24
  [key: string]: Field<unknown, boolean>;
25
25
  }
26
26
 
27
- export type ContextSchemaList = {
27
+ export type ContextSchemaMap = {
28
28
  [key: string]: ContextSchema;
29
29
  }
30
30
 
31
- export type ContextSchemaMap = ContextSchemaList
32
-
33
31
  export type Context<S extends ContextSchema> = {
34
32
  [F in keyof S]: TypeOf<S[F]>;
35
33
  }
@@ -51,7 +49,7 @@ export type EventHandler<
51
49
  E extends keyof EventPayloadMap<S>
52
50
  > = (payload: EventPayloadMap<S>[E]) => void
53
51
 
54
- export type ContextAccessor<M extends ContextSchemaList = ContextSchemaList> = {
52
+ export type ContextAccessor<M extends ContextSchemaMap = ContextSchemaMap> = {
55
53
  get <
56
54
  C extends keyof M,
57
55
  F extends keyof M[C]
@@ -117,97 +115,3 @@ export interface LogicalRejection extends Rejection {
117
115
  export interface RuntimeRejection extends Rejection {
118
116
  type: 'runtime';
119
117
  }
120
-
121
- export type CustomDictionary = CustomDictionaryItem[]
122
- export type CustomDictionaryItem = {
123
- code: string;
124
- text: string;
125
- cursor: string;
126
- }
127
-
128
- export type CustomDictionaryFilter = {
129
- after?: string;
130
- first?: number;
131
- }
132
-
133
- export interface BasicCustomField<K extends string, T> {
134
- kind: K;
135
- code: string;
136
- readonly: boolean;
137
- initial: T;
138
- }
139
-
140
- export interface DictionaryCustomField extends BasicCustomField<'dictionary', string | null> {
141
- dictionaryCode: string;
142
- }
143
-
144
- export interface MultiselectDictionaryCustomField extends BasicCustomField<'multiselect_dictionary', string[]> {
145
- dictionaryCode: string;
146
- }
147
-
148
- export type CustomField<K extends CustomFieldKind = CustomFieldKind> = CustomFieldList[K]
149
-
150
- export type CustomFieldType = TypeOfCustom<CustomFieldKind>
151
- export type CustomFieldKind = keyof CustomFieldList
152
- export type CustomFieldList = {
153
- 'boolean': BasicCustomField<'boolean', boolean | null>;
154
- 'date': BasicCustomField<'date', string | null>;
155
- 'datetime': BasicCustomField<'datetime', string | null>;
156
- 'dictionary': DictionaryCustomField;
157
- 'multiselect_dictionary': MultiselectDictionaryCustomField;
158
- 'email': BasicCustomField<'email', string | null>;
159
- 'integer': BasicCustomField<'integer', number | null>;
160
- 'numeric': BasicCustomField<'numeric', number | null>;
161
- 'string': BasicCustomField<'string', string | null>;
162
- 'text': BasicCustomField<'text', string | null>;
163
- }
164
-
165
- export type TypeOfCustom<K extends string> = K extends CustomFieldKind
166
- ? CustomFieldList[K] extends BasicCustomField<string, infer T> ? T : never
167
- : unknown;
168
-
169
- export type CustomContextSchema = {
170
- entity: string;
171
- fields: CustomField[];
172
- }
173
-
174
- export type CustomContext = {
175
- [code: string]: CustomFieldType
176
- }
177
-
178
- export type CustomContextAccessor = {
179
- getCustomSchema (entity: string, onReject?: Maybe<RejectionHandler>): CustomContextSchema | null;
180
-
181
- getCustomDictionary (
182
- code: string,
183
- filter?: CustomDictionaryFilter,
184
- onReject?: Maybe<RejectionHandler>
185
- ): Promise<CustomDictionary>;
186
-
187
- getCustomField (entity: string, code: string, onReject?: Maybe<RejectionHandler>): unknown;
188
- setCustomField (
189
- entity: string,
190
- code: string,
191
- value: CustomFieldType,
192
- onReject?: Maybe<RejectionHandler>
193
- ): void;
194
-
195
- onCustomFieldChange (
196
- entity: string,
197
- code: string,
198
- handler: (value: CustomFieldType) => void,
199
- onReject?: Maybe<RejectionHandler>
200
- ): void | (() => void);
201
- }
202
-
203
- export type CustomFieldAccessor = {
204
- readonly schema: CustomContextSchema;
205
-
206
- get (code: string): unknown;
207
- set (code: string, value: CustomFieldType): void;
208
-
209
- onChange (
210
- code: string,
211
- handler: (value: CustomFieldType) => void
212
- ): void | (() => void);
213
- }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@retailcrm/embed-ui-v1-types",
3
3
  "description": "Basic types declarations for RetailCRM JS API",
4
4
  "type": "module",
5
- "version": "0.5.2-alpha.4",
5
+ "version": "0.5.2",
6
6
  "license": "MIT",
7
7
  "author": "RetailDriverLLC <integration@retailcrm.ru>",
8
8
  "repository": "git@github.com:retailcrm/embed-ui.git",