jmapcloud-ng-core-types 0.0.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.
@@ -0,0 +1,590 @@
1
+ // ALL_FORM_TYPES in all-enum.ts
2
+ declare const enum JFORM_TYPES {
3
+ DEPRECATED = "DEPRECATED_FORM",
4
+ ATTRIBUTE = "LAYER_ATTRIBUTES_FORM",
5
+ ATTRIBUTE_SUB_FORM = "LAYER_ATTRIBUTES_SUB_FORM",
6
+ EXTERNAL = "EXTERNAL_ATTRIBUTES_FORM",
7
+ EXTERNAL_SUB_FORM = "EXTERNAL_ATTRIBUTES_SUB_FORM"
8
+ }
9
+
10
+ // ALL_FORM_UI_CONTROL_ALIGNMENTS in all-enum.ts
11
+ declare const enum JFORM_UI_CONTROL_ALIGNMENTS {
12
+ LEFT = "LEFT",
13
+ CENTER = "CENTER",
14
+ RIGHT = "RIGHT"
15
+ }
16
+
17
+ // ALL_FORM_WIDGET_TYPES in all-enum.ts
18
+ declare const enum JFORM_WIDGET_TYPES {
19
+ INPUT = "input",
20
+ RANGE = "range",
21
+ SWITCH = "switch",
22
+ SELECT = "select",
23
+ DATE = "date",
24
+ PHOTO = "photo",
25
+ TREE = "tree",
26
+ LABEL = "label",
27
+ SPAN = "span",
28
+ TABLE = "table"
29
+ }
30
+
31
+ // ALL_JSON_SCHEMA_TYPES in all-enum.ts
32
+ declare const enum JJSON_SCHEMA_TYPES {
33
+ STRING = "string",
34
+ NUMBER = "number",
35
+ INTEGER = "integer",
36
+ BOOLEAN = "boolean",
37
+ ARRAY = "array",
38
+ OBJECT = "object"
39
+ }
40
+
41
+ // ALL_FORM_OPERATION_TYPES in all-enum.ts
42
+ declare const enum JFORM_OPERATION_TYPES {
43
+ CREATION = "creation",
44
+ UPDATE = "update",
45
+ DELETE = "delete"
46
+ }
47
+
48
+ // FORM METADATA
49
+
50
+ declare interface JFormFieldValidationRuleByAttributeName {
51
+ [fieldName: string]: any
52
+ }
53
+
54
+ declare interface JFormValidationRules {
55
+ globalRules: JFormGlobalValidationRule[]
56
+ requiredRuleByAttributeName?: JFormFieldValidationRuleByAttributeName
57
+ readonlyRuleByAttributeName?: JFormFieldValidationRuleByAttributeName
58
+ calculatedRuleByAttributeName?: JFormFieldValidationRuleByAttributeName
59
+ visibleRuleByAttributeName?: JFormFieldValidationRuleByAttributeName
60
+ }
61
+
62
+ declare interface JFormGlobalValidationRule {
63
+ id: string
64
+ expression: any
65
+ name: string
66
+ message: string
67
+ }
68
+
69
+ declare interface JFormPermissions {
70
+ editLayerAttributeValues: boolean
71
+ addExternalFormAttributeValues: boolean
72
+ deleteExternalFormAttributeValues: boolean
73
+ editExternalFormAttributeValues: boolean
74
+ }
75
+
76
+ declare interface JFormMetaData {
77
+ id: JId
78
+ type: JFORM_TYPES
79
+ name: string
80
+ schema: JFormSchema
81
+ uiSchema: JFormUISchema
82
+ validationRules: JFormValidationRules
83
+ idAttributeName: string | null
84
+ hasPhoto: boolean
85
+ readOnly: boolean
86
+ isDeleteSupported: boolean
87
+ isCreateSupported: boolean
88
+ isUpdateSupported: boolean
89
+ areAllInputControlsReadOnly: boolean
90
+ isFakeAttributeForm?: boolean // in JMap7 attribute form is optional
91
+ permissions: JFormPermissions
92
+ }
93
+
94
+ declare interface JFormSchema {
95
+ $id: string
96
+ type: "object"
97
+ $schema: "http://json-schema.org/draft-07/schema#"
98
+ definitions: {}
99
+ properties: JFormSchemaProperties
100
+ required: string[]
101
+ }
102
+
103
+ declare interface JFormSchemaProperties {
104
+ [name: string]: JFormSchemaProperty
105
+ }
106
+
107
+ declare interface JFormSchemaProperty {
108
+ title: string
109
+ type: JJSON_SCHEMA_TYPES
110
+ description: string
111
+ isRequired: boolean
112
+ items?: {
113
+ // used if property type = "array"
114
+ type: JJSON_SCHEMA_TYPES // here only number or string
115
+ }
116
+ readOnly?: boolean
117
+ format?: string
118
+ pattern?: string
119
+ minimum?: number
120
+ maximum?: number
121
+ minLength?: number // used for required (because required check only if object has attribute)
122
+ maxLength?: number
123
+ enum?: string[] | number[] | boolean[]
124
+ enumNames?: string[]
125
+ parents?: Array<string | undefined> | Array<string | undefined>
126
+ default?: any
127
+ }
128
+
129
+ // FORM METADATA UI
130
+
131
+ declare type JFormUISchema = JFormUITab[]
132
+
133
+ declare interface JFormUITab {
134
+ type: "Tab"
135
+ title: string
136
+ controls: JFormUIControl[]
137
+ }
138
+
139
+ declare interface JFormUIControl {
140
+ type: "Control"
141
+ id: string
142
+ widget: JFORM_WIDGET_TYPES
143
+ colSpan?: number // the layout grid has 12 columns
144
+ fontBold?: boolean
145
+ fontItalic?: boolean
146
+ ruleCalculated?: object
147
+ ruleReadOnly?: object
148
+ ruleRequired?: object
149
+ ruleVisible?: object // not yet implemented server side
150
+ scope?: string // use with attribute related controls. Ex of scope : "#/properties/done"
151
+ multi?: boolean // for select control
152
+ align?: JFORM_UI_CONTROL_ALIGNMENTS
153
+ rows?: number // for multiline input control
154
+ label?: string
155
+ tooltip?: string
156
+ date?: boolean
157
+ dateNow?: boolean // for date control : current date as default value
158
+ dateTime?: boolean // for date control
159
+ dateFormat?: string // for date control
160
+ onlyLeafSelection?: boolean // for tree control
161
+ tree?: JFormUIControlTreeElement[]
162
+ entries?: JFormUIControlEntry[]
163
+ parentAttributeName?: string // used for select that change following parent value
164
+ mask?: string
165
+ layerId?: JId // for table control
166
+ subFormId?: JId // for table control
167
+ tableAttributes?: JFormAttribute[] // for table control
168
+ deleteWithElement?: boolean // for photo control
169
+ }
170
+
171
+ declare interface JFormUIControlEntry {
172
+ label: string
173
+ value: number | string
174
+ parentValue: string | undefined
175
+ }
176
+
177
+ declare interface JFormUIControlTreeElement extends JFormUIControlEntry {
178
+ children: undefined | JFormUIControlTreeElement[]
179
+ }
180
+
181
+ // BELOW ALL OLD FORM TYPES RECEIVED FROM SERVERS IN JMAP 7
182
+
183
+ // ALL_FORM_FIELD_TYPES in all-enum.ts
184
+ declare const enum JFORM_FIELD_TYPES {
185
+ EMPTY = "TYPE_EMPTY",
186
+ COLUMN_SPAN = "TYPE_COLUMN_SPAN",
187
+ LABEL = "TYPE_LABEL",
188
+ TEXT = "TYPE_INPUT_TEXT",
189
+ RANGE = "TYPE_INPUT_RANGE",
190
+ SELECT_ONE = "TYPE_SELECT_ONE",
191
+ SELECT_MANY = "TYPE_SELECT_MANY",
192
+ DATE = "TYPE_INPUT_DATE",
193
+ BOOLEAN = "TYPE_SELECT_BOOLEAN",
194
+ GROUP_PANEL = "TYPE_GROUP_PANEL",
195
+ DOCUMENT = "TYPE_DOCUMENT",
196
+ TREE = "TYPE_TREE",
197
+ TABLE = "TYPE_TABLE"
198
+ }
199
+
200
+ declare interface JFormSection {
201
+ name: string
202
+ index: number
203
+ nbCol: number
204
+ rows: JFormRow[]
205
+ }
206
+
207
+ declare interface JFormRow {
208
+ sectionIndex: number
209
+ sectionName: string
210
+ index: number
211
+ fields: JFormField[]
212
+ }
213
+
214
+ declare type JFormField =
215
+ | JFormFieldLabel
216
+ | JFormFieldEmpty
217
+ | JFormFieldInput
218
+ | JFormFieldInputText
219
+ | JFormFieldDate
220
+ | JFormFieldRange
221
+ | JFormFieldCheckBox
222
+ | JFormFieldSelectOne
223
+ | JFormFieldSelectBase
224
+ | JFormFieldSelectTree
225
+ | JFormFieldPhoto
226
+
227
+ declare interface JFormFieldBase {
228
+ id: string
229
+ type: JFORM_FIELD_TYPES
230
+ tooltip: string
231
+ align: JFORM_UI_CONTROL_ALIGNMENTS
232
+ }
233
+
234
+ declare interface JFormFieldEmpty extends JFormFieldBase {
235
+ type: JFORM_FIELD_TYPES.EMPTY
236
+ }
237
+
238
+ declare interface JFormFieldPhoto extends JFormFieldBase {
239
+ label: string
240
+ deleteWithElement: boolean
241
+ }
242
+
243
+ declare interface JFormFieldLabel extends JFormFieldBase {
244
+ text: string
245
+ }
246
+
247
+ declare interface JFormFieldColumnSpan extends JFormFieldBase {
248
+ id: string
249
+ }
250
+
251
+ declare interface JFormFieldInput extends JFormFieldBase {
252
+ required: boolean
253
+ readOnly: boolean
254
+ defaultValue: string
255
+ labelPrefix: string
256
+ labelSuffix: string
257
+ attribute: JFormFieldAttribute
258
+ parentAttribute: string
259
+ ruleCalculated?: string
260
+ ruleReadOnly?: string
261
+ ruleRequired?: string
262
+ ruleVisible?: string
263
+ }
264
+
265
+ declare interface JFormFieldAttribute {
266
+ name: string
267
+ type: number
268
+ }
269
+
270
+ declare interface JFormFieldDate extends JFormFieldInput {
271
+ dateFormat: string
272
+ }
273
+
274
+ declare interface JFormFieldInputText extends JFormFieldInput {
275
+ range: null | { min: number; max: number }
276
+ multiLine: boolean
277
+ maxNumberCharacter: number
278
+ maskFormatter: string
279
+ }
280
+
281
+ declare interface JFormFieldRange extends JFormFieldInput {
282
+ type: JFORM_FIELD_TYPES.RANGE
283
+ }
284
+
285
+ declare interface JFormFieldCheckBox extends JFormFieldInput {
286
+ checkedValue: string
287
+ uncheckedValue: string
288
+ }
289
+
290
+ declare interface JFormFieldTreeEntry {
291
+ parentValue: string
292
+ label: string
293
+ value: string
294
+ }
295
+
296
+ declare interface JFormFieldSelectBase extends JFormFieldInput {
297
+ selectEntries: JFormFieldTreeEntry[]
298
+ }
299
+
300
+ declare interface JFormFieldSelectOne extends JFormFieldSelectBase {
301
+ canAddNewValue: boolean
302
+ autoSelectUniqueValue: boolean
303
+ }
304
+
305
+ declare interface JFormFieldSelectTree extends JFormFieldSelectBase {
306
+ onlyLeafSelection: boolean
307
+ }
308
+
309
+ declare interface JFormAttribute {
310
+ id: string
311
+ label: string
312
+ type: JLAYER_ATTRIBUTE_TYPES
313
+ readOnly: boolean
314
+ nullable: boolean
315
+ isSystem: boolean
316
+ displayFormat: string
317
+ isShowInTable: boolean
318
+ formatPattern: string
319
+ }
320
+
321
+ declare interface JFormFieldTable extends JFormFieldBase {
322
+ label: string
323
+ subFormId: JId
324
+ attributes: JFormAttribute[]
325
+ }
326
+
327
+ // FORM DATA
328
+
329
+ declare interface JFormElementData {
330
+ attributeValueByName: JAttributeValueByName
331
+ }
332
+
333
+ declare interface JFormElement extends JFormElementData {
334
+ /**
335
+ * undefined if element, set if it's an entry
336
+ */
337
+ parentId: JId
338
+ id: JId
339
+ /**
340
+ * empty object if element, set if it's an entry
341
+ */
342
+ parentAttributeValueByName: JAttributeValueByName
343
+ /**
344
+ * undefined if element, set if it's an entry
345
+ */
346
+ elementId?: JId
347
+ /**
348
+ * used to replace new created element temp id by new real id
349
+ */
350
+ tempId?: JId
351
+ }
352
+
353
+ // Used only for JMap 7 Rest API
354
+ declare interface JFormExternalAttribute {
355
+ type: number
356
+ name: string
357
+ }
358
+
359
+ declare interface JFormPhotoData {
360
+ isLoading: boolean
361
+ hasLoadingError: boolean
362
+ hasChange: boolean
363
+ initialPhotos: JPhoto[]
364
+ photos: JPhoto[]
365
+ }
366
+
367
+ declare interface JFormPhotoUpdate {
368
+ photoId: JId
369
+ title?: string
370
+ comment?: string
371
+ }
372
+
373
+ declare interface JForm extends JFormElementData {
374
+ id: JId
375
+ layerId: JId
376
+ initialAttributeValueByName: JAttributeValueByName
377
+ metaData: JFormMetaData
378
+ parent: JForm | undefined
379
+ elements: JFormElement[]
380
+ fetchElementsFromServerFailed: boolean
381
+ errors: { [attributeName: string]: any }
382
+ hasChange: boolean
383
+ hasAttributeValueChange: boolean
384
+ isMultiple: boolean
385
+ isCreation: boolean
386
+ isAttributeForm: boolean
387
+ isExternalForm: boolean
388
+ isSubForm: boolean
389
+ isReadOnly: boolean
390
+ isReadOnlyEditOwn: boolean
391
+ canCreate: boolean
392
+ canUpdate: boolean
393
+ canDelete: boolean
394
+ photoData: JFormPhotoData
395
+ geometry?: GeoJSON.Geometry // required for attribute forms
396
+ subFormDataBySubFormId?: JSubFormDataBySubFormId // required for table support
397
+ }
398
+
399
+ declare interface JFormMetaDataById {
400
+ [formId: string]: JFormMetaData
401
+ }
402
+
403
+ declare interface JFormId {
404
+ layerId: JId
405
+ formId: JId
406
+ }
407
+
408
+ declare interface JFormElementId extends JFormId {
409
+ elementId: JId
410
+ }
411
+
412
+ declare interface JFormGetEntriesParams extends JFormId {
413
+ elementId: JId
414
+ parentId: JId
415
+ parentFormAttributesValuesByName: JAttributeValueByName
416
+ idAttributeName?: string
417
+ }
418
+
419
+ declare interface JFormElementIds extends JFormId {
420
+ elementIds: JId[]
421
+ }
422
+
423
+ declare interface JFormElements extends JFormId {
424
+ elements: JFormElement[]
425
+ }
426
+
427
+ declare interface JFormCreateAttributeFormElementParams extends JFormElementData, JFormId {
428
+ geometry: GeoJSON.Geometry
429
+ tempId?: JId // used to replace tempId by real one in external forms
430
+ }
431
+
432
+ declare interface JFormCreateElementParams extends JFormElement, JFormId {
433
+ idAttributeName: JId
434
+ }
435
+
436
+ declare interface JFormUpdateElementsParams extends JFormElements {
437
+ // nothing
438
+ }
439
+
440
+ declare interface JFormResult {
441
+ elementId: JId
442
+ success: boolean
443
+ }
444
+
445
+ declare interface JFormCreateParams extends JFormId {
446
+ geometry?: GeoJSON.Geometry
447
+ }
448
+
449
+ declare interface JFormEditParams extends JFormId {
450
+ elements: JFormElement[]
451
+ }
452
+
453
+ declare interface JFormOperation {
454
+ formType: JFORM_TYPES
455
+ layerId: JId
456
+ formId: JId
457
+ formName: string
458
+ isAttributeForm: boolean
459
+ isExternalForm: boolean
460
+ isSubForm: boolean
461
+ isPhoto: boolean
462
+ operationType: JFORM_OPERATION_TYPES
463
+ layerElementId: JId
464
+ id: JId
465
+ }
466
+
467
+ declare interface JFormAttributeOperation extends JFormOperation {
468
+ formType: JFORM_TYPES.ATTRIBUTE
469
+ isAttributeForm: true
470
+ isExternalForm: false
471
+ isSubForm: false
472
+ isPhoto: false
473
+ attributeValueByName: JAttributeValueByName
474
+ }
475
+
476
+ declare interface JFormExternalOperation extends JFormOperation {
477
+ formType: JFORM_TYPES.EXTERNAL
478
+ isAttributeForm: false
479
+ isExternalForm: true
480
+ isSubForm: false
481
+ isPhoto: false
482
+ idAttributeName: string
483
+ attributeValueByName: JAttributeValueByName
484
+ parentAttributeValueByName: JAttributeValueByName
485
+ }
486
+
487
+ declare interface JFormSubFormOperation extends JFormOperation {
488
+ formType: JFORM_TYPES.ATTRIBUTE_SUB_FORM | JFORM_TYPES.EXTERNAL_SUB_FORM
489
+ isAttributeForm: false
490
+ isExternalForm: false
491
+ isSubForm: true
492
+ isPhoto: false
493
+ idAttributeName: string
494
+ attributeValueByName: JAttributeValueByName
495
+ parentId: JId
496
+ parentAttributeValueByName: JAttributeValueByName
497
+ }
498
+
499
+ declare interface JFormPhotoOperation extends JFormOperation {
500
+ parentId: JId
501
+ photo: JPhoto
502
+ isPhoto: true
503
+ }
504
+
505
+ declare interface JFormSubmitResult {
506
+ successMessages: string[]
507
+ errorMessages: string[]
508
+ operations: JFormOperation[]
509
+ featureCreation?: {
510
+ layerId: JId
511
+ featureId: JId
512
+ geometry: GeoJSON.Geometry
513
+ properties: JAttributeValueByName
514
+ }
515
+ deletedFeatureIds?: JId[]
516
+ }
517
+
518
+ declare interface JFormDeleteResult extends JFeatureDeleteByIdsResult {
519
+ // nothing to add
520
+ }
521
+
522
+ declare interface JFormErrors {
523
+ [key: string]: string
524
+ }
525
+
526
+ declare interface JFormSubmitEventParams extends JFormSubmitResult {
527
+ // nothing to add
528
+ }
529
+
530
+ declare interface JFormBeforeSubmitEventParams {
531
+ layerId: JId
532
+ formId: JId
533
+ isAttributeForm: boolean
534
+ isExternalForm: boolean
535
+ isSubForm: boolean
536
+ isCreation: boolean
537
+ getFormData(): JAttributeValueByName
538
+ setFormData(attributeValueByName: JAttributeValueByName): void
539
+ /**
540
+ * Set only for attribute form creation
541
+ */
542
+ getGeometry?(): GeoJSON.Geometry
543
+ /**
544
+ * Set only for attribute form creation
545
+ */
546
+ setGeometry?(geometry: GeoJSON.Geometry): void
547
+ }
548
+
549
+ interface JFormDialogEventParams {
550
+ layerId: JId
551
+ }
552
+
553
+ declare interface JFormLayerDialogOpenEventParams extends JFormDialogEventParams {
554
+ attributeForm: JForm
555
+ externalForms: JForm[]
556
+ }
557
+
558
+ declare interface JFormLayerDialogCloseEventParams extends JFormDialogEventParams {
559
+ // nothing to add
560
+ }
561
+
562
+ declare interface JFormSubFormDialogOpenEventParams extends JFormDialogEventParams {
563
+ subForm: JForm
564
+ }
565
+
566
+ declare interface JFormSubFormDialogCloseEventParams extends JFormDialogEventParams {
567
+ // nothing to add
568
+ }
569
+
570
+ declare interface JSubFormDataBySubFormId {
571
+ [subFormId: string]: JSubFormData
572
+ }
573
+
574
+ declare interface JSubFormData {
575
+ parentForm: JForm
576
+ subFormId: JId
577
+ isLoadingEntries: boolean
578
+ hasLoadingError: boolean
579
+ idAttributeName: string
580
+ subFormEntries: JFormElement[]
581
+ }
582
+
583
+ declare interface JDeleteEntriesResult {
584
+ inSuccessLayerElementIds: JId[]
585
+ inErrorLayerElementIds: JId[]
586
+ }
587
+
588
+ declare interface JFormSubmitParams {
589
+ avoidClosePopupOnSuccess?: boolean
590
+ }
@@ -0,0 +1,33 @@
1
+ declare interface JGeocodingOptions {
2
+ /**
3
+ * if true, returns all match that would begin with the search string
4
+ */
5
+ autoComplete?: boolean
6
+ /**
7
+ * if true, proceeds with a fuzzy search (ex: "montan" will match "montain")
8
+ */
9
+ fuzzyMatch?: boolean
10
+ /**
11
+ * a JLocation object, or null. If not specified, it is by default set to the map's extent center. If you want to disable proximity bias, pass null for this option.
12
+ */
13
+ proximity?: JLocation | null | undefined
14
+ }
15
+
16
+ declare interface JGeocodingResult {
17
+ id: string
18
+ location: GeoJSON.Feature<GeoJSON.Point>
19
+ boundingBox?:GeoJSON.Feature<GeoJSON.Polygon>
20
+ query: string
21
+ relevance: number
22
+ title: string
23
+ placeName: string
24
+ attribution: string
25
+ }
26
+
27
+ declare interface JGeocodingSuccessEventParams {
28
+ results: JGeocodingResult[]
29
+ }
30
+
31
+ declare interface JGeocodingErrorEventParams {
32
+ error: any
33
+ }
@@ -0,0 +1,44 @@
1
+ // ALL_GEOMETRY_UNITS in all-enum.ts
2
+ declare const enum JGEOMETRY_UNITS {
3
+ KILOMETERS = "kilometers",
4
+ MILES = "miles",
5
+ DEGREES = "degrees",
6
+ RADIANS = "radians"
7
+ }
8
+
9
+ declare interface JBounds {
10
+ x1: number
11
+ x2: number
12
+ y1: number
13
+ y2: number
14
+ }
15
+
16
+ declare interface JBoundaryBox {
17
+ sw: JLocation
18
+ ne: JLocation
19
+ }
20
+
21
+ declare interface JLocation {
22
+ x: number
23
+ y: number
24
+ }
25
+
26
+ declare type JPoint = [number, number] | [number, number, number]
27
+
28
+ declare type JLine = JPoint[]
29
+
30
+ declare type JPolygon = JPoint[]
31
+
32
+ declare interface JCircle {
33
+ center: JLocation
34
+ /**
35
+ * With mapbox the radius unit is kilometer
36
+ */
37
+ radius: number
38
+ }
39
+
40
+ declare interface JObjectId {
41
+ project: string
42
+ layer: string
43
+ element: string
44
+ }
@@ -0,0 +1,38 @@
1
+ // ALL_LOCALES in all-enum.ts
2
+ declare const enum JLOCALES {
3
+ FR = "fr",
4
+ EN = "en",
5
+ ES = "es"
6
+ }
7
+
8
+ declare interface JLocaleTranslation {
9
+ [key: string]: string
10
+ }
11
+
12
+ declare interface JTranslationItem {
13
+ key: string
14
+ bundleId: string
15
+ }
16
+
17
+ interface JTranslateParams extends JTranslationItem {
18
+ params?: (string | number) | Array<string | number>
19
+ locale?: JLOCALES
20
+ }
21
+
22
+ declare interface JTranslationsByLocale {
23
+ [locale: string]: JLocaleTranslation
24
+ }
25
+
26
+ declare interface JTranslationBundle {
27
+ id: string
28
+ translationsByLocale: JTranslationsByLocale
29
+ defaultLocale?: JLOCALES
30
+ }
31
+
32
+ declare interface JTranslationBundleById {
33
+ [bundleId: string]: JTranslationBundle
34
+ }
35
+
36
+ declare interface JLanguageEventLocaleChangeParams {
37
+ locale: JLOCALES
38
+ }