jmapcloud-ng-core-types 1.0.0 → 1.0.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.
package/index.ts CHANGED
@@ -25,6 +25,7 @@ export interface JCoreService extends JCoreMainService {
25
25
  Projection: JProjectionService
26
26
  MapContext: JMapContextService
27
27
  UI: JUIService
28
+ SimpleSearch: JSimpleSearchService
28
29
  }
29
30
 
30
31
  export interface JUIService {
@@ -35,6 +36,12 @@ export interface JUIService {
35
36
  getContainerHeight(): number
36
37
  }
37
38
 
39
+ export interface JSimpleSearchService {
40
+ getInvalidQueryStringCharacters(): string
41
+ setQueryString(queryString: string): void
42
+ getMinimumQueryStringLength(): number
43
+ }
44
+
38
45
  export interface JLibraryService {
39
46
  maplibregl(): any
40
47
  html2canvas(): any
@@ -142,8 +149,11 @@ export interface JFeatureService {
142
149
  getById(layerId: JId, featureId: JId): Promise<GeoJSON.Feature>
143
150
  getByIds(layerId: JId, featureIds: JId[]): Promise<GeoJSON.Feature[]>
144
151
  geometryUpdateById(params: JFeatureGeometryUpdateParams): Promise<GeoJSON.Feature>
145
- deleteById(layerId: JId, featureId: JId): Promise<GeoJSON.Feature>
146
- deleteByIds(layerId: JId, featureIds: JId[]): Promise<JFeatureDeleteByIdsResult>
152
+ deleteById(layerId: JId, featureId: JId): Promise<JId>
153
+ // deleteByIds(layerId: JId, featureIds: JId[]): Promise<JFeatureDeleteByIdsResult>
154
+ // TODO: see if the future endpoint will return detail about individual deleted features success or failure
155
+ // https://k2geospatial.atlassian.net/browse/JMAP8-1589
156
+ deleteByIds(layerId: JId, featureIds: JId[]): Promise<JId[]>
147
157
  }
148
158
 
149
159
  export interface JCoreMainService {
@@ -196,6 +206,7 @@ export interface JEventService {
196
206
  Language: JLanguageEventModule
197
207
  Map: JMapEventModule
198
208
  Geocoding: JGeocodingEventModule
209
+ SimpleSearch: JSimpleSearchEventModule
199
210
  Photo: JPhotoEventModule
200
211
  Project: JProjectEventModule
201
212
  User: JUserEventModule
@@ -296,6 +307,13 @@ export interface JGeocodingEventModule extends JEventModule {
296
307
  }
297
308
  }
298
309
 
310
+ export interface JSimpleSearchEventModule extends JEventModule {
311
+ on: {
312
+ success(listenerId: string, fn: (params: JSimpleSearchSuccessEventParams) => void): void
313
+ error(listenerId: string, fn: (params: JSimpleSearchErrorEventParams) => void): void
314
+ }
315
+ }
316
+
299
317
  export interface JLayerEventModule extends JEventModule {
300
318
  on: {
301
319
  layersChange(listenerId: string, fn: (params: JLayerEventChangeParams) => void): void
@@ -396,6 +414,7 @@ export interface JCoreState {
396
414
  photo: JPhotoState
397
415
  query: JQueryState
398
416
  geocoding: JGeocodingState
417
+ simpleSearch: JSimpleSearchState
399
418
  geolocation: JGeolocationState
400
419
  form: JFormState
401
420
  server: JServerState
@@ -448,6 +467,14 @@ export interface JGeocodingState {
448
467
  results: JGeocodingResult[]
449
468
  }
450
469
 
470
+ export interface JSimpleSearchState {
471
+ isLoadPending: boolean
472
+ isLoading: boolean
473
+ hasLoadingError: boolean
474
+ queryString: string
475
+ results: JSimpleSearchResult
476
+ }
477
+
451
478
  export interface JGeolocationState {
452
479
  isLocationDisplayed: boolean
453
480
  isEnabled: boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmapcloud-ng-core-types",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "JMap Cloud specific version of JMap Cloud NG Core types and interfaces",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/public/core.d.ts CHANGED
@@ -566,11 +566,11 @@ declare namespace JMap {
566
566
  * // deletes the feature id="4" on layer id="3"
567
567
  * JMap.Feature
568
568
  * .deleteById(3, 4)
569
- * .then(deletedFeature => console.info("Feature has been deleted", deletedFeature))
569
+ * .then(deletedFeatureId => console.info("Feature id=" + deletedFeatureId + " has been deleted"))
570
570
  * .catch(error => console.error("An error occured", error))
571
571
  * ```
572
572
  */
573
- function deleteById(layerId: JId, featureId: JId): Promise<GeoJSON.Feature>
573
+ function deleteById(layerId: JId, featureId: JId): Promise<JId>
574
574
 
575
575
  /**
576
576
  * **JMap.Feature.deleteByIds**
@@ -589,7 +589,11 @@ declare namespace JMap {
589
589
  * .catch(error => console.error("An error occured", error))
590
590
  * ```
591
591
  */
592
- function deleteByIds(layerId: JId, featureIds: JId[]): Promise<JFeatureDeleteByIdsResult>
592
+
593
+ // deleteByIds(layerId: JId, featureIds: JId[]): Promise<JFeatureDeleteByIdsResult>
594
+ // TODO: see if the future endpoint will return detail about individual deleted features success or failure
595
+ // https://k2geospatial.atlassian.net/browse/JMAP8-1589
596
+ function deleteByIds(layerId: JId, featureIds: JId[]): Promise<JId[]>
593
597
  }
594
598
 
595
599
  /**
@@ -6789,6 +6793,64 @@ declare namespace JMap {
6789
6793
  function getDateFnsDateFormat(): string
6790
6794
  }
6791
6795
 
6796
+ /**
6797
+ * **JMap.SimpleSearch**
6798
+ *
6799
+ * A search mechanism that let the user find features on any layer that has been indexed.
6800
+ *
6801
+ * The JMap Cloud administrator is responsible for specifying which attributes of which spatial data sources are indexed. Once indices are set, a global search can be made over a whole project to find features based on those indexed attributes.
6802
+ *
6803
+ * JMap Cloud implements the OpenSearch standard. For more details, see {@link https://opensearch.org/docs/latest/ the official documentation}
6804
+ *
6805
+ */
6806
+
6807
+ namespace SimpleSearch {
6808
+ /**
6809
+ * ***JMap.SimpleSearch.setQueryString***
6810
+ *
6811
+ * Executes a "query string" search on all layers of the current project using the passed string as the query. See {@link https://opensearch.org/docs/latest/query-dsl/full-text/query-string/#query-string-syntax here} for details.
6812
+ *
6813
+ * All query_string reserved characters are escaped, and the following characters can't be used: "<>"
6814
+ *
6815
+ * This method will fetch a result object indicating all matches found.
6816
+ *
6817
+ * @throws if no project is loaded, if the passed search string is not a string or if it contains invalid characters.
6818
+ * @param queryString the search string to be used
6819
+ * @example ```ts
6820
+ *
6821
+ * ```
6822
+ */
6823
+ function setQueryString(queryString: string): void
6824
+
6825
+ /**
6826
+ * **JMap.SimpleSearch.getMinimumQueryStringLength**
6827
+ *
6828
+ * Returns the query string length required to trigger a simple search
6829
+ *
6830
+ * @example ```ts
6831
+ *
6832
+ * // returns the minimum search string length
6833
+ * JMap.SimpleSearch.getMinimumQueryStringLength()
6834
+ * // 1
6835
+ * ```
6836
+ */
6837
+ function getMinimumQueryStringLength(): number
6838
+
6839
+ /**
6840
+ * **JMap.SimpleSearch.getInvalidQueryStringCharacters**
6841
+ *
6842
+ * Returns a string composed of all forbidden characters in simple search strings.
6843
+ *
6844
+ * @example ```ts
6845
+ *
6846
+ * // returns the invalid characters
6847
+ * JMap.SimpleSearch.getInvalidQueryStringCharacters()
6848
+ * // "<>"
6849
+ * ```
6850
+ */
6851
+ function getInvalidQueryStringCharacters(): string
6852
+ }
6853
+
6792
6854
  /**
6793
6855
  * **JMap.Query**
6794
6856
  *
@@ -7348,6 +7410,112 @@ declare namespace JMap {
7348
7410
  function remove(listenerId: string): void
7349
7411
  }
7350
7412
 
7413
+ /**
7414
+ * ***JMap.Event.SimpleSearch***
7415
+ *
7416
+ * Here you can manage all simple search event listeners.
7417
+ *
7418
+ * Click to see all events available: ***{@link JMap.Event.SimpleSearch.on}***.
7419
+ */
7420
+ namespace SimpleSearch {
7421
+ /**
7422
+ * ***JMap.Event.SimpleSearch.on***
7423
+ *
7424
+ * Here you have all JMap Cloud NG Core simple search events on which you can attach a listener.
7425
+ */
7426
+ namespace on {
7427
+ /**
7428
+ * ***JMap.Event.SimpleSearch.on.success***
7429
+ *
7430
+ * This event is triggered when a simple search has been completed.
7431
+ *
7432
+ * @param listenerId Your listener id (must be unique)
7433
+ * @param fn Your listener function
7434
+ * @example ```ts
7435
+ *
7436
+ * // log a message in the console once the simple search has been completed
7437
+ * JMap.Event.SimpleSearch.on.success(
7438
+ * "custom-simple-search-success",
7439
+ * params => console.log("A simple search has been completed", params.results)
7440
+ * )
7441
+ * ```
7442
+ */
7443
+ function success(listenerId: string, fn: (params: JSimpleSearchSuccessEventParams) => void): void
7444
+
7445
+ /**
7446
+ * ***JMap.Event.SimpleSearch.on.error***
7447
+ *
7448
+ * This event is triggered when a simple search has been processed, but an error occured.
7449
+ *
7450
+ * @param listenerId Your listener id (must be unique)
7451
+ * @param fn Your listener function
7452
+ * @example ```ts
7453
+ *
7454
+ * // log a message in the console if a simple search error occured
7455
+ * JMap.Event.SimpleSearch.on.error(
7456
+ * "custom-simple-search-error",
7457
+ * params => console.log("A simple search has failed", params)
7458
+ * )
7459
+ * ```
7460
+ */
7461
+ function error(listenerId: string, fn: (params: JSimpleSearchErrorEventParams) => void): void
7462
+ }
7463
+
7464
+ /**
7465
+ * ***JMap.Event.SimpleSearch.activate***
7466
+ *
7467
+ * Activate the listener.
7468
+ *
7469
+ * If the listener is already active, do nothing.
7470
+ *
7471
+ * If the listener is inactive, it will be reactivated and will be called again ...
7472
+ *
7473
+ * @param listenerId The listener id
7474
+ * @example ```ts
7475
+ *
7476
+ * // activate the listener "my-simple-search-listener"
7477
+ * JMap.Event.SimpleSearch.activate("my-simple-search-listener")
7478
+ * ```
7479
+ */
7480
+ function activate(listenerId: string): void
7481
+
7482
+ /**
7483
+ * ***JMap.Event.SimpleSearch.deactivate***
7484
+ *
7485
+ * Deactivate the listener.
7486
+ *
7487
+ * If the listener id doesn't exists or if the listener is already inactive, do nothing.
7488
+ *
7489
+ * If the listener is active, it will be deactivated and will be ignored ...
7490
+ *
7491
+ * @param listenerId The listener id
7492
+ * @example ```ts
7493
+ *
7494
+ * // deactivate the listener "my-simple-search-listener"
7495
+ * JMap.Event.SimpleSearch.deactivate("my-simple-search-listener")
7496
+ * ```
7497
+ */
7498
+ function deactivate(listenerId: string): void
7499
+
7500
+ /**
7501
+ * ***JMap.Event.SimpleSearch.remove***
7502
+ *
7503
+ * Remove the listener.
7504
+ *
7505
+ * If the listener doesn't exist, do nothing.
7506
+ *
7507
+ * Remove the listener from JMap Cloud NG Core library. The listener is deleted and never called again after that.
7508
+ *
7509
+ * @param listenerId The listener id
7510
+ * @example ```ts
7511
+ *
7512
+ * // remove the listener "my-simple-search-listener"
7513
+ * JMap.Event.SimpleSearch.remove("my-simple-search-listener")
7514
+ * ```
7515
+ */
7516
+ function remove(listenerId: string): void
7517
+ }
7518
+
7351
7519
  namespace Server {
7352
7520
  /**
7353
7521
  * ***JMap.Event.Server.on***
@@ -12178,13 +12346,17 @@ declare namespace JMap {
12178
12346
  *
12179
12347
  * Parameters initialWidth and initialHeight are in pixels.
12180
12348
  *
12349
+ * Embedding a page that sets the `X-Frame-Options` or `Content-Security-Policy: frame-ancestors` headers in an incompatible way may cause the display of the page to fail.
12350
+ *
12351
+ * See {@linkcode https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options here} and {@linkcode https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors here} for details
12352
+ *
12181
12353
  * @throws Error if invalid parameters are passed
12182
12354
  * @param params parameters needed to open the iframe popup
12183
12355
  * @example ```ts
12184
12356
  *
12185
12357
  * // Open an embedded popup of k2geospatial website
12186
12358
  * JMap.UI.openIFramePopup({
12187
- * src: "https://k2geospatial.com/",
12359
+ * src: "https://my.web.site.com/",
12188
12360
  * initialPosition: { x: 400, y: 250 },
12189
12361
  * initialWidth: 400,
12190
12362
  * initialHeight: 250,
@@ -0,0 +1,42 @@
1
+ declare interface JSimpleSearchQueryString {
2
+ query: {
3
+ query_string: {
4
+ query: string
5
+ }
6
+ }
7
+ }
8
+
9
+ declare interface JSimpleSearchResult {
10
+ took: number
11
+ timedOut: boolean
12
+ shards: {
13
+ total: number
14
+ successful: number
15
+ skipped: number
16
+ failed: number
17
+ }
18
+ hits: {
19
+ total: {
20
+ value: number
21
+ relation: string
22
+ }
23
+ maxScore: number
24
+ hits: JSimpleSearchResultHit[]
25
+ }
26
+ }
27
+
28
+ declare interface JSimpleSearchResultHit {
29
+ _index: string
30
+ _source: { [attributeName: string]: any }
31
+ _id: JId
32
+ _score: number
33
+ highlight?: { [attributeName: string]: string[] }
34
+ }
35
+
36
+ declare interface JSimpleSearchSuccessEventParams {
37
+ result: JSimpleSearchResult
38
+ }
39
+
40
+ declare interface JSimpleSearchErrorEventParams {
41
+ error: any
42
+ }