@ws-ui/shared 0.0.30 → 0.0.31

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.
@@ -0,0 +1,26 @@
1
+ declare namespace datasources {
2
+ class EntityCacheEntry<T extends IEntity = IEntity> {
3
+ constructor(inTimeStamp: Date, inRawEntry: T, inStamp: number);
4
+ GetTimeStamp(): Date;
5
+ }
6
+
7
+ class EntityCache<T extends IEntity = IEntity> {
8
+ fMaxEntities: number;
9
+ fTimeOut: number;
10
+ fCurStamp: number;
11
+ fCache: number;
12
+
13
+ getNextStamp(): number;
14
+ makeRoomFor(nbEntites: number): void;
15
+ clear(nbToClear: number): void;
16
+ clearAll(): void;
17
+ setEntry(inKey: string, inRawEntry: T, inTimeStamp: Date);
18
+ retainEntry(inKey: string, inCacheDelay: number): T;
19
+ removeEntry(inKey: string): void;
20
+ setMaxEntries(nbentries: number, canReduce: boolean): void;
21
+ setTimeOut(inTimeout: number): void;
22
+
23
+ static cloneRawEntity(rawEntityDef: T): T;
24
+ static getTimeStamp(): Date;
25
+ }
26
+ }
@@ -0,0 +1,47 @@
1
+ declare namespace datasources {
2
+ interface IDataClassPrivate<T extends IEntity = IEntity> {
3
+ datastore: ICatalog;
4
+ className: string;
5
+ exposed?: boolean;
6
+ attributes: {
7
+ [attributeName: string]: IDataClassAttribute;
8
+ };
9
+ collectionName: string;
10
+ cache: EntityCache<T>;
11
+ keys: string[];
12
+ }
13
+
14
+ type IGetEntitySettings = Partial<{
15
+ expand: string;
16
+ filterAttributes: string;
17
+ }>;
18
+
19
+ class DataClass<T extends IEntity = IEntity> {
20
+ _private: IDataClassPrivate<T>;
21
+ constructor(rawDef: IDetailedDataClass, owner: ICatalog);
22
+ getName(): string;
23
+ getCollectionName(): string;
24
+ getDataStore(): ICatalog;
25
+ getAttribute(attname: string): IDataClassAttribute | null;
26
+ getAllAttributes(): {
27
+ [attributeName: string]: IDataClassAttribute;
28
+ };
29
+ getEntity(primKey: string, settings?: IGetEntitySettings): Promise<T>;
30
+ query(
31
+ queryStr: string,
32
+ settings?: IEntitySelectionSettings,
33
+ ): EntitySelection<T>;
34
+ getDistinctValues(
35
+ attName: string,
36
+ maxElems?: number,
37
+ queryFilter?: string,
38
+ ): Promise<string[]>;
39
+ allEntities(settings: IEntitySelectionSettings): EntitySelection<T>;
40
+ newEmptySelection(): EntitySelection<T>;
41
+ getCacheDelay(): number;
42
+ getCache(): EntityCache<T>;
43
+ getKeys(): string[];
44
+ isExposed(): boolean;
45
+ supportJSONEntityKey(): boolean;
46
+ }
47
+ }
@@ -0,0 +1,356 @@
1
+ declare namespace datasources {
2
+ type TEventData = import('~/hooks/use-events/interfaces').webforms.WEvent;
3
+ type TDatasourceType =
4
+ | 'auto'
5
+ | 'entity'
6
+ | 'entitysel'
7
+ | 'catalog'
8
+ | 'dataclass'
9
+ | 'scalar'
10
+ | 'array'
11
+ | 'object';
12
+ type TJSType = 'string' | 'number' | 'bool' | 'date' | 'object' | 'array';
13
+ type TDataType =
14
+ | 'array'
15
+ | 'bool'
16
+ | 'string'
17
+ | 'text'
18
+ | 'uuid'
19
+ | 'short'
20
+ | 'long'
21
+ | 'number'
22
+ | 'long64'
23
+ | 'duration'
24
+ | 'object'
25
+ | 'date'
26
+ | 'image';
27
+ interface IEnhancedCatalog extends ICatalog {
28
+ dataClasses: IDataClasses;
29
+ dataClassByCollectionName: IDataClasses;
30
+ }
31
+ interface ICollection<T extends IEntity = IEntity> {
32
+ __COUNT: number;
33
+ __DATACLASS: string;
34
+ __FIRST: number;
35
+ __GlobalStamp: number;
36
+ __SENT: string;
37
+ __entityModel: string;
38
+ __ENTITIES: T[];
39
+ __ENTITYSET?: string;
40
+ __MAXENTITIES?: number;
41
+ __queryPlan?: any;
42
+ __extendedQueryPlan?: any;
43
+ __extendedQueryPath?: any;
44
+ }
45
+
46
+ interface IBaseAttribute {
47
+ name: string;
48
+ kind: AttributeKind;
49
+ scope: Scope;
50
+ exposed?: boolean;
51
+ readOnly?: boolean;
52
+ }
53
+ interface ISimpleAttribute extends IBaseAttribute {
54
+ type: AttributeType;
55
+ indexed?: boolean;
56
+ identifying?: boolean;
57
+ simpleDate?: boolean;
58
+ }
59
+
60
+ interface IRelatedEntitiesAttribute extends IBaseAttribute {
61
+ kind: 'relatedEntities';
62
+ path: string;
63
+ type: AttributeType | string;
64
+ inverseName: string;
65
+ reversePath: boolean;
66
+ }
67
+
68
+ interface IRelatedEntityAttribute extends IBaseAttribute {
69
+ kind: 'relatedEntity';
70
+ type: AttributeType | string;
71
+ path: string;
72
+ foreignKey: string;
73
+ inverseName: string;
74
+ }
75
+
76
+ interface ICalculatedAttribute extends IBaseAttribute {
77
+ kind: 'calculated';
78
+ type: AttributeType | string;
79
+ foreignKey?: string;
80
+ inverseName?: string;
81
+ reversePath?: boolean;
82
+ path?: string;
83
+ behavior?: 'relatedEntities' | 'relatedEntity';
84
+ }
85
+
86
+ interface IAliasAttribute extends IBaseAttribute {
87
+ behavior?: 'relatedEntities' | 'relatedEntity';
88
+ type: AttributeType | string;
89
+ foreignKey?: string;
90
+ inverseName?: string;
91
+ reversePath?: boolean;
92
+ path?: string;
93
+ kind: 'alias';
94
+ }
95
+
96
+ type IAttribute = {
97
+ name: string;
98
+ type: string;
99
+ kind: EAttributeKind;
100
+ scope: AttributeScope;
101
+ } & Partial<{
102
+ indexKind: TIndexType;
103
+ autogenerate: boolean;
104
+ unique: boolean;
105
+ primKey: boolean;
106
+ exposed: boolean;
107
+ behavior: string;
108
+ autosequence: boolean;
109
+ reversePath: boolean;
110
+ not_null: boolean;
111
+ minValue: number;
112
+ maxValue: number;
113
+ simpleDate: boolean;
114
+ defaultValue: any;
115
+ events: any[];
116
+ path: string;
117
+ extraProperties: IAttributeProperties;
118
+ styled_text: boolean;
119
+ }>;
120
+
121
+ interface IRelatedAttribute extends IBaseAttribute {
122
+ type?: AttributeType | string;
123
+ behavior: 'relatedEntities' | 'relatedEntity';
124
+ foreignKey?: string;
125
+ inverseName?: string;
126
+ path?: string;
127
+ reversePath?: boolean;
128
+ }
129
+ interface IEntity {
130
+ __KEY?: string;
131
+ __TIMESTAMP?: Date;
132
+ __STAMP?: number;
133
+ }
134
+ interface ICatalog {
135
+ __UNIQID: string;
136
+ __BASEID: string;
137
+ methods: catalog.IMethod[];
138
+ dataClasses: IDetailedDataClass[];
139
+ }
140
+
141
+ interface IDataClass {
142
+ name: string;
143
+ uri: string;
144
+ dataURI: string;
145
+ }
146
+ interface IDetailedDataClass extends IDataClass {
147
+ className: string;
148
+ collectionName: string;
149
+ tableNumber: number;
150
+ scope: Scope;
151
+ attributes?: IAttribute[];
152
+ key: IDataClassKey[];
153
+ methods: catalog.IMethod[];
154
+ exposed?: boolean;
155
+ }
156
+
157
+ type IDataClasses = { [key: string]: IDetailedDataClass };
158
+
159
+ class AttributeFilter {
160
+ addAttribute(attname: string, subfilter?: any): void;
161
+ mergeWith(mergeWith: { filter: any }): void;
162
+ addFilterText(filterText: string, newprop: string): string;
163
+ buildString(curpath: string): String;
164
+ }
165
+
166
+ interface IDSChildren {
167
+ [datasourceName: string]: DataSource;
168
+ }
169
+
170
+ interface INameSpace {
171
+ sources: IDSChildren;
172
+ root: DataSource;
173
+ }
174
+ type ICreateDataSource =
175
+ | ICreateDataSourceScalar
176
+ | ICreateDataSourceArray
177
+ | ICreateDataSourceObject
178
+ | ICreateDataSourceEntity
179
+ | ICreateDataSourceEntitySelection;
180
+ type IEntityDatasource =
181
+ | datasources.ICreateDataSourceEntity
182
+ | datasources.ICreateDataSourceEntitySelection;
183
+
184
+ interface ICreateDataSourceCommon {
185
+ id: string;
186
+ initialValue: any;
187
+ events?: webforms.WEvent[];
188
+ namespace: string;
189
+ }
190
+
191
+ interface ICreateDataSourceScalar extends ICreateDataSourceCommon {
192
+ type: 'scalar';
193
+ initialValue?: string | boolean | number | any[] | object | null;
194
+ dataType: TJSType;
195
+ from?: string;
196
+ }
197
+
198
+ interface ICreateDataSourceArray extends ICreateDataSourceCommon {
199
+ id: string;
200
+ type: 'scalar';
201
+ initialValue: any[] | null;
202
+ dataType: 'array';
203
+ from?: string;
204
+ }
205
+ interface ICreateDataSourceObject extends ICreateDataSourceCommon {
206
+ type: 'scalar';
207
+ initialValue: object | null;
208
+ dataType: 'object';
209
+ from?: string;
210
+ }
211
+ interface ICreateDataSourceEntity extends ICreateDataSourceCommon {
212
+ type: 'entity';
213
+ initialValue: 'first' | '';
214
+ dataclass: string;
215
+ depth: number | null;
216
+ from?: string;
217
+ dataType?: string;
218
+ }
219
+ interface ICreateDataSourceEntitySelection extends ICreateDataSourceCommon {
220
+ type: 'entitysel';
221
+ initialValue: 'all' | '';
222
+ from?: string;
223
+ dataclass: string;
224
+ depth: number | null;
225
+ pageSize: number | null;
226
+ dataType?: string;
227
+ }
228
+ interface IDSMethods {
229
+ [key: string]: catalog.IMethod;
230
+ }
231
+
232
+ class DataSource {
233
+ id: string;
234
+ alias: string;
235
+ type: TDatasourceType;
236
+ namespace: string;
237
+ stamp: number;
238
+ frozenStamp: number;
239
+ inited: boolean;
240
+ beeingResolved: boolean;
241
+ fromServerStorage: boolean;
242
+ canBeUpdatedByParent: boolean;
243
+ local: boolean;
244
+ parentSource: this;
245
+ dataType: TJSType;
246
+ dataclass: datasources.DataClass;
247
+ dataclassID: string;
248
+ parendId: string;
249
+ children: IDSChildren;
250
+ initialValue: string | null;
251
+ properyInParent?: string;
252
+ filterAttributes?: AttributeFilter;
253
+ filterAttributesText?: string;
254
+
255
+ constructor(namespace: string, id: string, type: string);
256
+ static spaces: {
257
+ [namespace: string]: INameSpace;
258
+ };
259
+ static globalStamp: number;
260
+ static anonymCount: number;
261
+ static dataTypeMap: {
262
+ bool: 'bool';
263
+ string: 'string';
264
+ text: 'string';
265
+ uuid: 'string';
266
+ short: 'number';
267
+ long: 'number';
268
+ number: 'number';
269
+ long64: 'number';
270
+ duration: 'number';
271
+ object: 'object';
272
+ date: 'date';
273
+ };
274
+ static getOrBuildNameSpace(namespace?: string): INameSpace;
275
+ static getNameSpace(namespace: string): INameSpace;
276
+ static buildSource(
277
+ sourcestr: string,
278
+ initialValue: any,
279
+ ds: DataStore,
280
+ namespace: string,
281
+ ): void;
282
+ static create(
283
+ settings: ICreateDataSource,
284
+ ds: DataStore,
285
+ namespace?: string,
286
+ ): DataSource;
287
+ static getSourceAttributes(
288
+ id: string,
289
+ options?: any,
290
+ namespace?: string,
291
+ ): IDataClassAttribute[];
292
+ static buildCatalogDatasources(
293
+ datastore: datasources.DataStore,
294
+ namespace?: string,
295
+ );
296
+ isLocal(): boolean;
297
+ setLocal(local: boolean): void;
298
+ buildCallFuncURL(
299
+ methodName: string,
300
+ added: string,
301
+ ): string | Promise<string>;
302
+ buildEntitySettings(existingSettings?: any): any;
303
+ fireEvent(eventType: string, data?: any): void;
304
+ addListener(eventType: string, callback: Function): void;
305
+ removeListener(eventType: string, callback: Function): void;
306
+ getValue<T = any>(property?: string | number, settings?: any): Promise<T>;
307
+ findElementPosition(elementDataSource: DataSource): Promise<number>;
308
+ getCollection<T extends IEntity = IEntity>(
309
+ index: number,
310
+ howmany: number,
311
+ propertyStr: string,
312
+ ): Promise<T[]>;
313
+ orderBy(attrs: string): Promise<null>;
314
+ getValueAsParam(property: string, settings: any): Promise<null>;
315
+ getDataType(): null;
316
+ setValue<T = any>(
317
+ property: string | null,
318
+ value: T,
319
+ doFireEvent?: boolean,
320
+ ): Promise<void>;
321
+ setValueFromMethodResult(resp: any, doFireEvent?: boolean): Promise<void>;
322
+ clone(): null;
323
+ refresh(doFireEvent?: boolean): Promise<void>;
324
+ recompute(fireEvent?: boolean): Promise<void>;
325
+ recomputeChildren(doFireEvent?: boolean): Promise<void>;
326
+ addAttributeFilter(child: this): void;
327
+ static createRequestOptimization(ns?: string): void;
328
+ formatValue(value: any): typeof value;
329
+ getStamp(): number;
330
+ touch(): void;
331
+ getParentSource(): this;
332
+ getDataClass(): DataClass;
333
+ getProperyInParent(): string;
334
+ freezeStamp(withChildren: boolean): void;
335
+ modifiedSinceLastFreeze(): boolean;
336
+ dumpTree(curtext: string, level: number): string;
337
+ init(): void;
338
+ filterAttributesText?: string;
339
+ callAction?(action: string, meta?: any): void;
340
+ getMethods(): IDSMethods;
341
+ copyValueInto(source: any, fireEvent?: boolean): Promise<void>;
342
+ static getSource(id: string, namespace?: string): DataSource | undefined;
343
+ static getSource(id: string, namespace?: string): DataSource | undefined;
344
+ static getSourceOrBuild(
345
+ id: string | null,
346
+ initialValue: any,
347
+ ds: DataStore,
348
+ namespace?: string,
349
+ ): DataSource;
350
+ static AddAlias(id: string, datasource: DataSource, namespace?: string);
351
+ static buildDependencies(namespace?: string): void;
352
+ static computeInitialValues(namespace?: string): void;
353
+ static refreshNamespace(namespace?: string): void;
354
+ static getAllSources(namespace?: string): IDSChildren | {};
355
+ }
356
+ }
@@ -0,0 +1,61 @@
1
+ declare namespace datasources {
2
+ class ProgressIndicator {
3
+ refID: string;
4
+ started: Date;
5
+ lastChecked: number;
6
+ inited: boolean;
7
+ checkDeletedCount: number;
8
+ askedToStop: boolean;
9
+ graceFullStop: boolean;
10
+
11
+ getRefID(): string;
12
+ userAbort(): void;
13
+ stopGracefully(): void;
14
+
15
+ static InitManager(): void;
16
+ static register(progress: ProgressIndicator): void;
17
+ static unregister(progress: ProgressIndicator): void;
18
+ static getProgress(refID: string): ProgressIndicator;
19
+ static addListener(handler: Function): number;
20
+ static removeListener(id: string): void;
21
+ static tellListeners(command: string, progress: ProgressIndicator): void;
22
+ }
23
+
24
+ interface IDataStorePrivate {
25
+ uniqID: string;
26
+ dataclasses: {
27
+ [dataclassName: string]: DataClass;
28
+ };
29
+ dataclassesByCollectionName: {
30
+ [collectionName: string]: DataClass;
31
+ };
32
+ cacheDelay: number;
33
+ }
34
+
35
+ class DataStore {
36
+ _private: IDataClassPrivate;
37
+ constructor(ID: string);
38
+ fetch(): Promise<this>;
39
+ getUniqID(): string;
40
+ getBaseID(): string;
41
+ getDataClass(classname: string): DataClass;
42
+ getDataClassByCollectionName(collectionName: string): DataClass;
43
+ getCacheDelay(): number;
44
+ getDataClasses(): {
45
+ [dataclassName: string]: DataClass;
46
+ };
47
+ initProgressManager(): void;
48
+ newProgressIndicator(): ProgressIndicator;
49
+ addProgressListener(handler: Function): void;
50
+ removeProgressListener(id: string): void;
51
+ getProjectName(): string;
52
+ getMethods(): {
53
+ [key: string]: {
54
+ name: string;
55
+ exposed: boolean;
56
+ allowedOnHTTPGET: boolean;
57
+ };
58
+ };
59
+ HTMLEncode(source: string, display: boolean, tabs: number): string;
60
+ }
61
+ }
@@ -0,0 +1,68 @@
1
+ declare namespace datasources {
2
+ interface ICurrentPage<T extends IEntity = IEntity> {
3
+ first: number;
4
+ size: number;
5
+ entitiesDef: T[];
6
+ }
7
+
8
+ type IEntitySelectionSettings = Partial<{
9
+ expand: string;
10
+ relatedSelURI: string;
11
+ queryStr: string;
12
+ queryParams: string;
13
+ first: number;
14
+ pageLength: number;
15
+ filterAttributes: string;
16
+ dataSetName: string;
17
+ }>;
18
+
19
+ interface IEntitySelectionPrivate<T extends IEntity = IEntity> {
20
+ curPage: ICurrentPage<T>;
21
+ selLength: number;
22
+ maxEntities: number;
23
+ initialFirst: number;
24
+ pageLength: number;
25
+ inited: boolean;
26
+ owner: DataClass<T>;
27
+ fetching: boolean;
28
+ settings: IEntitySelectionSettings;
29
+ isRelatedSel: boolean;
30
+ relatedSelURI: string;
31
+ dataSetName: string;
32
+ filterAttributes: string;
33
+ }
34
+
35
+ interface IDescriptorAsParam {
36
+ __ENTITIES: boolean;
37
+ __DATACLASS: string;
38
+ __DATASET: string;
39
+ }
40
+
41
+ class EntitySelection<T extends IEntity = IEntity> {
42
+ constructor(
43
+ owner: DataClass<T>,
44
+ settings: IEntitySelectionSettings,
45
+ rawDef: IDataClass,
46
+ );
47
+
48
+ readonly length: number;
49
+ initAsEmpty(): void;
50
+ getLength(settings?: IEntitySelectionSettings): Promise<number>;
51
+ getMaxEntities(): number;
52
+ getDataClass(): DataClass<T>;
53
+ getDescriptorAsParam(): IDescriptorAsParam;
54
+ getComputedURL(
55
+ settings?: IEntitySelectionSettings,
56
+ forFuncCall?: boolean,
57
+ ): {
58
+ url: string;
59
+ added: string;
60
+ };
61
+ fetchPage(
62
+ first: number,
63
+ size: number,
64
+ settings?: IEntitySelectionSettings,
65
+ ): Promise<ICollection<T>>;
66
+ managePage(rawDef: ICollection<T>, nochangeInCurpage?: boolean): T[];
67
+ }
68
+ }
@@ -0,0 +1,112 @@
1
+ declare namespace catalog {
2
+ enum EAttributeKind {
3
+ STORAGE = 'storage',
4
+ RELATEDENTITY = 'relatedEntity',
5
+ RELATEDENTITIES = 'relatedEntities',
6
+ CALCULATED = 'calculated',
7
+ COMPOSITION = 'composition',
8
+ ALIAS = 'alias',
9
+ }
10
+ type AttributeType =
11
+ | 'bool'
12
+ | 'word'
13
+ | 'blob'
14
+ | 'string'
15
+ | 'text'
16
+ | 'uuid'
17
+ | 'short'
18
+ | 'long'
19
+ | 'number'
20
+ | 'byte'
21
+ | 'long64'
22
+ | 'duration'
23
+ | 'object'
24
+ | 'date'
25
+ | 'image';
26
+ type Scope = 'public' | 'publicOnServer';
27
+ type ApplyTo = 'dataClass' | 'entity' | 'entityCollection' | 'dataStore';
28
+ type AttributeKind =
29
+ | 'storage'
30
+ | 'alias'
31
+ | 'calculated'
32
+ | 'relatedEntity'
33
+ | 'relatedEntities';
34
+
35
+ type IDataClassProperties = Partial<{
36
+ panelColor: string;
37
+ position: {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ }>;
42
+ type IAttributeProperties = Partial<{}>;
43
+ interface IModelProperties
44
+ extends Partial<{
45
+ version: string;
46
+ backgroundColor: string;
47
+ backgroundImage: string;
48
+ backgroundVariant: 'dotted' | 'grid' | 'none';
49
+ zoom: number;
50
+ viewportPosition: [number, number];
51
+ }> {}
52
+ interface IMethod {
53
+ name: string;
54
+ applyTo: ApplyTo;
55
+ scope: Scope;
56
+ from: 'remoteServer';
57
+ allowedOnHTTPGET: boolean;
58
+ startingLine: number;
59
+ paramsText: string;
60
+ filePath: string;
61
+ userDefined: boolean;
62
+ endingLine: number;
63
+ exposed: boolean;
64
+ }
65
+ type IDataClass = {
66
+ name: string;
67
+ className: string;
68
+ collectionName: string;
69
+ scope: DataclassScope;
70
+ attributes: IAttribute[];
71
+ } & Partial<{
72
+ defaultTopSize: number;
73
+ leave_tag_on_delete: boolean;
74
+ prevent_journaling: boolean;
75
+ comment: string;
76
+ extraProperties: IDataClassProperties;
77
+ }>;
78
+ type IEvent = {
79
+ kind: string;
80
+ from: string;
81
+ userDefined: boolean;
82
+ };
83
+ export type AttributeIndexKind = 'btree' | 'cluster' | 'auto' | 'none';
84
+ type IAttribute = {
85
+ name: string;
86
+ type: string;
87
+ kind: AttributeKind;
88
+ scope: Scope;
89
+ } & Partial<{
90
+ indexKind?: AttributeIndexKind | null;
91
+ invalidAlias: boolean;
92
+ autogenerate: boolean;
93
+ unique: boolean;
94
+ primKey: boolean;
95
+ exposed: boolean;
96
+ behavior: string;
97
+ autosequence: boolean;
98
+ indexed: boolean;
99
+ reversePath: boolean;
100
+ keywordIndexed: boolean;
101
+ not_null: boolean; // TODO: to be renamed to mandatory
102
+ minValue: number;
103
+ maxValue: number;
104
+ simpleDate: boolean;
105
+ defaultValue: any;
106
+ events: any[];
107
+ path: string;
108
+ extraProperties: IAttributeProperties;
109
+ styled_text: boolean;
110
+ comment: string;
111
+ }>;
112
+ }
@@ -0,0 +1,88 @@
1
+ declare namespace catalog {
2
+ interface AttributeProps {
3
+ indexKind: AttributeIndexKind;
4
+ autogenerate: boolean;
5
+ unique: boolean;
6
+ primKey: boolean;
7
+ exposed: boolean;
8
+ autosequence: boolean;
9
+ keywordIndexed: boolean;
10
+ not_null: boolean; // TODO: to be renamed to mandatory
11
+ minValue: number;
12
+ maxValue: number;
13
+ simpleDate: boolean;
14
+ defaultValue: any;
15
+ extraProperties: IAttributeProperties;
16
+ styled_text: boolean;
17
+ comment: string;
18
+ events: any[];
19
+ }
20
+ interface BaseAttribute extends Partial<AttributeProps> {
21
+ /**
22
+ * name of the attribute
23
+ */
24
+ name: string;
25
+ /**
26
+ * represents the actual type of the attribute (storage, relatedentity, relatedEntities, alias, calculated);
27
+ */
28
+ kind: AttributeKind;
29
+ /**
30
+ * Scope of the attribute (publicOnServer is equivalent to private)
31
+ */
32
+ scope: Scope;
33
+ }
34
+
35
+ interface StorageAttribute extends BaseAttribute {
36
+ kind: 'storage';
37
+ type: AttributeType;
38
+ }
39
+
40
+ interface RelatedEntityAttribute extends BaseAttribute {
41
+ kind: 'relatedEntity';
42
+ /**
43
+ * the value for the type property is the name of originating dataclass.
44
+ */
45
+ type: string;
46
+ }
47
+
48
+ interface RelatedEntitiesAttribute extends BaseAttribute {
49
+ kind: 'relatedEntities';
50
+ /**
51
+ * the value for the type property is the `selection name` of originating dataclass.
52
+ */
53
+ type: string;
54
+ /**
55
+ * the path to the related attribute in the originating dataclass.
56
+ */
57
+ path: string;
58
+ reversePath?: boolean;
59
+ }
60
+
61
+ interface AliasAttribute extends BaseAttribute {
62
+ kind: 'alias';
63
+ /**
64
+ * in the case of alias, the type can be:
65
+ * - storage type. (bool, number, string, ...etc)
66
+ * - the `name` of the dataclass in case `behavior` is set to `relatedEntity`
67
+ * - the `selection name` of the dataclass in case `behavior` is set to `relatedEntities`
68
+ */
69
+ type: string;
70
+ path: string;
71
+ behavior?: 'relatedEntity' | 'relatedEntities';
72
+ reversePath?: string;
73
+ }
74
+
75
+ interface CalculatedAttribute extends BaseAttribute {
76
+ kind: 'calculated';
77
+ type: string;
78
+ path?: string;
79
+ behavior?: 'relatedEntity' | 'relatedEntities';
80
+ }
81
+
82
+ type Attribute =
83
+ | StorageAttribute
84
+ | RelatedEntityAttribute
85
+ | RelatedEntitiesAttribute
86
+ | AliasAttribute
87
+ | CalculatedAttribute;
88
+ }
@@ -0,0 +1,71 @@
1
+ declare namespace datasources {
2
+ interface IComponentAction {
3
+ [actionName: string]: {
4
+ stamp: number;
5
+ value: any;
6
+ };
7
+ }
8
+
9
+ class Utils {
10
+ static formatValue(value: number | string | Date, format: string): string;
11
+ static formatString(value: string, format: string): string;
12
+ static formatDuration(value: number): string;
13
+ static convertAs(dataType: string, value: string);
14
+ static stringToNumber(value: string): string;
15
+ static entityKeyToJSON(key: string): string;
16
+ static initFramework(): Promise<void>;
17
+ }
18
+ class Method4D {
19
+ acceptedEvents: {
20
+ [event: string]: boolean;
21
+ };
22
+ constructor(
23
+ methodName: string,
24
+ resultSource: datasources.DataSource,
25
+ paramSources: datasources.DataSource[],
26
+ owenerSource: datasources.DataSource | null,
27
+ );
28
+ static buildMethod(
29
+ component: {
30
+ methodName: string;
31
+ resultingDataSource: Partial<{
32
+ id: string;
33
+ namespace: string;
34
+ }>;
35
+ parameters: {
36
+ name: string;
37
+ namespace?: string;
38
+ isHardCoded?: boolean;
39
+ type?: 'date' | 'string' | 'object' | 'array' | 'number' | 'bool';
40
+ }[];
41
+ },
42
+ associatedData: { namespace: string },
43
+ ownerSource: DataSource | null,
44
+ ): Method4D;
45
+ static buildAction(component: { action: string }): string;
46
+ static buildEvents(component: { eventType: string }): {
47
+ [evName: string]: boolean;
48
+ };
49
+ static validEvent(event: string): boolean;
50
+ static replaceDataSources(
51
+ component: { parameters: any },
52
+ elemSource,
53
+ newid: string,
54
+ );
55
+
56
+ callServerSide(
57
+ widget: {
58
+ id?: string;
59
+ serverSideRef?: string;
60
+ },
61
+ callerType: string,
62
+ additionalData?: any,
63
+ addOwnerSourceAsParam?: boolean,
64
+ callFuncUrl?: string,
65
+ ): Promise<{
66
+ [refName: string]: IComponentAction;
67
+ __NOTIFICATION?: { message: string; type: string };
68
+ }>;
69
+ isMemberFunction(): boolean;
70
+ }
71
+ }
@@ -0,0 +1,18 @@
1
+ declare namespace datasources {
2
+ class RestError extends Error {
3
+ constructor(
4
+ public message: string,
5
+ public status: number,
6
+ public statusText?: string,
7
+ public errCode?: number | string,
8
+ );
9
+
10
+ getDescription(): string;
11
+ }
12
+
13
+ function restRequest<T>(
14
+ command: HttpMethod,
15
+ url: string,
16
+ body: any,
17
+ ): Promise<T>;
18
+ }
@@ -0,0 +1,70 @@
1
+ declare namespace http {
2
+ /**
3
+ * Hypertext Transfer Protocol (HTTP) request method names.
4
+ * @see {@link https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods}
5
+ */
6
+ enum HttpMethod {
7
+ /**
8
+ * The GET method requests a representation of the specified resource.
9
+ * Requests using GET should only retrieve data and should have no other effect.
10
+ * (This is also true of some other HTTP methods.)
11
+ *
12
+ * The W3C has published guidance principles on this distinction, saying,
13
+ * "Web application design should be informed by the above principles,
14
+ * but also by the relevant limitations.".
15
+ */
16
+ GET = 'GET',
17
+ /**
18
+ * The HEAD method asks for a response identical to that of a GET request,
19
+ * but without the response body.
20
+ *
21
+ * This is useful for retrieving meta-information written in response headers,
22
+ * without having to transport the entire content.
23
+ */
24
+ HEAD = 'HEAD',
25
+ /**
26
+ * The POST method requests that the server accept the entity enclosed in the
27
+ * request as a new subordinate of the web resource identified by the URI.
28
+ * The data POSTed might be, for example, an annotation for existing resources;
29
+ * a message for a bulletin board, newsgroup, mailing list, or comment thread;
30
+ * a block of data that is the result of submitting a web form to a
31
+ * data-handling process; or an item to add to a database.
32
+ */
33
+ POST = 'POST',
34
+ /**
35
+ * The PUT method requests that the enclosed entity be stored under the supplied
36
+ * URI.
37
+ *
38
+ * If the URI refers to an already existing resource, it is modified; if the
39
+ * URI does not point to an existing resource, then the server can create the
40
+ * resource with that URI.
41
+ */
42
+ PUT = 'PUT',
43
+ /**
44
+ * The DELETE method deletes the specified resource.
45
+ */
46
+ DELETE = 'DELETE',
47
+ /**
48
+ * The TRACE method echoes the received request so that a client can see what
49
+ * (if any) changes or additions have been made by intermediate servers.
50
+ */
51
+ TRACE = 'TRACE',
52
+ /**
53
+ * The OPTIONS method returns the HTTP methods that the server supports for
54
+ * the specified URL.
55
+ * This can be used to check the functionality of a web server by requesting '*'
56
+ * instead of a specific resource.
57
+ */
58
+ OPTIONS = 'OPTIONS',
59
+ /**
60
+ * The CONNECT method converts the request connection to a transparent TCP/IP
61
+ * tunnel, usually to facilitate SSL-encrypted communication (HTTPS) through
62
+ * an unencrypted HTTP proxy.
63
+ */
64
+ CONNECT = 'CONNECT',
65
+ /**
66
+ * The PATCH method applies partial modifications to a resource.
67
+ */
68
+ PATCH = 'PATCH',
69
+ }
70
+ }
@@ -0,0 +1,41 @@
1
+ declare var DataSource: typeof datasources.DataSource;
2
+ declare var Method4D: typeof datasources.Method4D;
3
+ declare var Utils: typeof datasources.Utils;
4
+ declare var $$datastores: {
5
+ [dsName: string]: datasources.DataStore;
6
+ };
7
+
8
+ declare module 'CustomComponents/list' {
9
+ declare var components: {
10
+ [key: string]: any;
11
+ };
12
+ }
13
+
14
+ declare module 'css-box-shadow' {
15
+ declare function parse(value: string): {
16
+ inset: 'inset' | null;
17
+ offsetX: number;
18
+ offsetY: number;
19
+ blurRadius: number;
20
+ spreadRadius: number;
21
+ color: string;
22
+ }[];
23
+ declare function stringify(args: any[]);
24
+ }
25
+
26
+ declare var dragOutData: {
27
+ dragOut: boolean;
28
+ lastNodesId: string;
29
+ } = {
30
+ dragOut: false,
31
+ lastNodesId: '',
32
+ };
33
+
34
+ declare global {
35
+ interface Window {
36
+ dragOutData: {
37
+ dragOut: boolean;
38
+ lastNodesId: string;
39
+ };
40
+ }
41
+ }
@@ -0,0 +1,223 @@
1
+ declare namespace webforms {
2
+ type ReactCSSProperties = import('react').CSSProperties;
3
+ type CraftComponent = import('@ws-ui/craftjs-core').SerializedNode;
4
+
5
+ type ComponentProps<CSSProperties = ReactCSSProperties> = {
6
+ moveable?: boolean;
7
+ deletable?: boolean;
8
+ className?: string;
9
+ role?: string;
10
+ /**
11
+ * A reference used to perform server side actions on the element based on a server call response.
12
+ */
13
+ serverSideRef?: string;
14
+ /**
15
+ * list of css properties that will be applied to the element by the user.
16
+ */
17
+ style?: CSSProperties;
18
+ /**
19
+ * Contains the list of events listeners that will be applied to the element during the runtime.
20
+ */
21
+ events?: WEvent[];
22
+ /**
23
+ * Contains list of classnames that have been applied to the element by the user
24
+ */
25
+ classNames?: string[];
26
+ /**
27
+ * Represants the main datasource for the component.
28
+ *
29
+ * It can contain multiple datasources paths separated by commas.
30
+ *
31
+ * Datasource Paths syntax: _`namespace`_ __:__ _`datasource.attribute1....attributeN`_
32
+ */
33
+ datasource?: string;
34
+ /**
35
+ * Represants the current element datasource for the component.
36
+ *
37
+ * It is usually used for items dealing with a list of items.
38
+ *
39
+ * It can only contain a single datasource path.
40
+ *
41
+ * Datasource Paths syntax: _`namespace`_ __:__ _`datasource.attribute1....attributeN`_
42
+ */
43
+ currentElement?: string;
44
+ /**
45
+ * Defines if the component is iterable.
46
+ *
47
+ * An iterable component must use the 'iterator' property.
48
+ */
49
+ iterable?: boolean;
50
+ /**
51
+ * Defines if the component is loopable.
52
+ *
53
+ * Used on Datatable component (which does not support the iterator property yet).
54
+ */
55
+ loopable?: boolean;
56
+ /**
57
+ * Represants the iterator key for the component.
58
+ *
59
+ * Used on components like Matrix & Select Box.
60
+ */
61
+ iterator?: string;
62
+ };
63
+
64
+ type Info = {
65
+ displayName: string;
66
+ icon?: React.FC<any>;
67
+ exposed?: boolean;
68
+ isCanvas?: boolean;
69
+ events: EventMeta[];
70
+ iconName?: string;
71
+ tipKey?: string;
72
+ kind?: 'user' | 'basic' | 'template';
73
+ sanityCheck?: {
74
+ keys: {
75
+ name: string | Array<ISanityCheckElement>;
76
+ isDatasource: boolean;
77
+ require: boolean;
78
+ }[];
79
+ };
80
+ };
81
+
82
+ type StyleClass = {
83
+ /**
84
+ * Unique id for the class.
85
+ */
86
+ id: string;
87
+ /**
88
+ * Scope of the classe.
89
+ * values: 'shared', 'theme', 'local'
90
+ */
91
+ scope: 'shared' | 'theme' | 'local';
92
+ /**
93
+ * Name of the class
94
+ */
95
+ name: string;
96
+ /**
97
+ * content of the class.
98
+ */
99
+ content: string;
100
+ /**
101
+ * an id of the parent class. should be null if the class is not associated with any other class.
102
+ */
103
+ parentId: string | null;
104
+ /**
105
+ * An object of linked style classes.
106
+ *
107
+ * onDrop of the class on a component, if the component has a linked node,
108
+ * it will be assigned a style class if it's type is declared in this object.
109
+ *
110
+ * key: represents the type of component to be associated with style class on drop.
111
+ *
112
+ * value: id of the associated style class.
113
+ */
114
+ children?: {
115
+ [key: string]: string;
116
+ };
117
+ /**
118
+ * defines the origin of the style class from which it was exported.
119
+ */
120
+ origin?: string;
121
+ };
122
+
123
+ type Datasources = datasources.ICreateDataSource[];
124
+
125
+ type Metadata = Partial<{
126
+ v: string;
127
+ datasources: Datasources;
128
+ styles: StyleClass[];
129
+ title: string;
130
+ }>;
131
+
132
+ type Content = {
133
+ components: Record<string, CraftComponent>;
134
+ metadata?: Metadata;
135
+ };
136
+
137
+ // ------------------ EVENTS --------------------------
138
+ type WEvent = MemberFunctionEvent | NavigationEvent | SimpleActionEvent;
139
+
140
+ interface BaseEvent {
141
+ id: string;
142
+ events: string[];
143
+ type: 'method' | 'navigation' | 'simple-action';
144
+ disabled?: boolean;
145
+ }
146
+
147
+ interface MemberFunctionEvent extends BaseEvent {
148
+ type: 'method';
149
+ method?: string;
150
+ dataclass?: string;
151
+ params: MethodParam[];
152
+ returns?: Omit<MethodParam, 'id'>;
153
+ namespace?: string;
154
+ code?: string;
155
+ feedback?: boolean;
156
+ datasource?: string;
157
+ }
158
+
159
+ interface SimpleActionEvent extends BaseEvent {
160
+ type: 'simple-action';
161
+ datasource: {
162
+ name: string;
163
+ type?: datasources.ICreateDataSource['type'] | 'unknown';
164
+ dataType?: datasources.ICreateDataSource['dataType'];
165
+ namespace?: string;
166
+ from?: string;
167
+ target?: string;
168
+ targetNamespace?: string;
169
+ targetType?: string;
170
+ };
171
+ action: string;
172
+ query?: QueryString;
173
+ orderBy?: OrderBy[];
174
+ feedback?: {
175
+ enabled?: boolean;
176
+ messages?: { onSuccess?: string; onFail?: string };
177
+ };
178
+ }
179
+
180
+ interface NavigationEvent extends BaseEvent {
181
+ type: 'navigation';
182
+ parent: string;
183
+ loader: string;
184
+ target: string;
185
+ externalLink: boolean;
186
+ }
187
+
188
+ interface EventMeta {
189
+ label: string;
190
+ value: string;
191
+ }
192
+ type HardCodedType =
193
+ | 'date'
194
+ | 'string'
195
+ | 'object'
196
+ | 'number'
197
+ | 'bool'
198
+ | 'array';
199
+ type MethodParam = {
200
+ id: string;
201
+ name?: string;
202
+ datasource?: string;
203
+ type?: string;
204
+ isHardCoded?: boolean;
205
+ hardCodedType?: HardCodedTypes;
206
+ hardCodedValue?: string;
207
+ };
208
+
209
+ type MethodReturn = Omit<MethodParam, 'name'>;
210
+
211
+ interface QueryParam extends MethodParam {}
212
+
213
+ interface OrderBy {
214
+ name: string; // replace with attribute
215
+ order: 'asc' | 'desc';
216
+ id: string;
217
+ }
218
+
219
+ interface QueryString {
220
+ query?: string; // query
221
+ params?: QueryParam[];
222
+ }
223
+ }
@@ -0,0 +1,143 @@
1
+ // Tailwind preset
2
+ module.exports = {
3
+ theme: {
4
+ extend: {
5
+ colors: {
6
+ 'fd-gray': {
7
+ lighter: '#EAEAEA',
8
+ light: '#444444',
9
+ default: '#313131',
10
+ mild: '#B3B3B3',
11
+ dark: '#222222',
12
+ darker: '#151515',
13
+ },
14
+ 'fd-blue': {
15
+ lighter: '#03bbff',
16
+ light: '#168EDB',
17
+ default: '#004289',
18
+ },
19
+ 'fd-orange': {
20
+ default: 'rgb(172, 110, 17)',
21
+ },
22
+ 'fd-custom': {
23
+ 'light-blue': '#BADFFF',
24
+ 'dark-blue': '005BA9',
25
+ },
26
+ 'fd-purple': {
27
+ lighter: '#CDB7FA',
28
+ darker: '#6A22FC',
29
+ default: '#CDB7FA',
30
+ },
31
+ grey: {
32
+ 50: '#F1F5F9',
33
+ 100: '#CCCCCC',
34
+ 200: '#888888',
35
+ 300: '#535353',
36
+ 400: '#484848',
37
+ 500: '#444444',
38
+ 600: '#3F3F3F',
39
+ 700: '#393939',
40
+ 800: '#383838',
41
+ 900: '#262626',
42
+ },
43
+ blue: {
44
+ 400: '#1D9DFF',
45
+ 900: '#074289',
46
+ },
47
+ red: {
48
+ 500: '#CE5151',
49
+ 600: '#FB7373',
50
+ },
51
+ primary: {
52
+ light: '#E8C3FF',
53
+ dark: '#B174E5',
54
+ darker: '#925FBE',
55
+ DEFAULT: '#BB0BD1',
56
+ hover: '#633A85',
57
+ },
58
+ purple: {
59
+ 50: '#F2DDFF',
60
+ 100: '#EDD0FF',
61
+ 200: '#E8C3FF',
62
+ 300: '#E3B7FF',
63
+ 400: '#D99FFD',
64
+ 500: '#C683FF',
65
+ 600: '#B174E5',
66
+ 700: '#A15FD8',
67
+ 800: '#925FBE',
68
+ 900: '#BB0BD1',
69
+ },
70
+ },
71
+ fontFamily: {
72
+ 'open-sans': ['Poppins', 'Open Sans', 'sans-serif'],
73
+ roboto: ['Roboto', 'sans-serif'],
74
+ poppins: ['Poppins', 'sans-serif'],
75
+ },
76
+ fontSize: {
77
+ xxs: '.55rem',
78
+ xs: '.65rem',
79
+ s: '.75rem',
80
+ },
81
+ cursor: {
82
+ grab: 'grab',
83
+ },
84
+ outlineWidth: {
85
+ xxs: '0.1px',
86
+ xs: '0.3px',
87
+ s: '0.5px',
88
+ },
89
+ typography: (theme) => ({
90
+ sm: {
91
+ css: {
92
+ h1: {
93
+ color: theme('colors.white'),
94
+ },
95
+ h2: {
96
+ color: theme('colors.white'),
97
+ },
98
+ h3: {
99
+ color: theme('colors.white'),
100
+ 'margin-top': '0px',
101
+ },
102
+ h4: {
103
+ color: theme('colors.white'),
104
+ },
105
+ strong: {
106
+ color: theme('colors.grey.100'),
107
+ },
108
+ a: {
109
+ color: theme('colors.blue.200'),
110
+ },
111
+ blockquote: {
112
+ color: theme('colors.grey.100'),
113
+ },
114
+ img: {
115
+ 'margin-top': '5px',
116
+ 'margin-bottom': '5px',
117
+ },
118
+ },
119
+ },
120
+ }),
121
+ borderRadius: {
122
+ DEFAULT: '4px',
123
+ },
124
+ boxShadow: {
125
+ toolbar: '0px 3px 6px #00000029',
126
+ },
127
+ minHeight: {
128
+ 6: '1.5rem',
129
+ },
130
+ height: {
131
+ 4.5: '1.125rem',
132
+ },
133
+ divideWidth: {
134
+ DEFAULT: '0.5px',
135
+ },
136
+ borderWidth: {
137
+ DEFAULT: '0.5px',
138
+ px: '1px',
139
+ },
140
+ },
141
+ },
142
+ plugins: [require('@tailwindcss/typography')],
143
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ws-ui/shared",
3
3
  "private": false,
4
- "version": "0.0.30",
4
+ "version": "0.0.31",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",