jmapcloud-ng-core-types 1.1.15 → 1.1.18

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
@@ -1,4 +1,5 @@
1
1
  import { Feature, FeatureCollection, LineString, MultiLineString, Point, Polygon } from "geojson"
2
+ import { JForm as JFormJMC } from "jmapcloud-types"
2
3
  import { Store } from "redux"
3
4
 
4
5
  export interface JCoreService extends JCoreMainService {
@@ -12,13 +13,13 @@ export interface JCoreService extends JCoreMainService {
12
13
  Geolocation: JGeolocationService
13
14
  Geometry: JGeometryService
14
15
  MouseOver: JMouseOverService
16
+ Attachment: JAttachmentService
15
17
  Form: JFormService
16
18
  FormJMC: JFormJMCService
17
19
  Event: JEventService
18
20
  History: JHistoryService
19
21
  Extension: JExtensionService
20
22
  Server: JServerService
21
- Photo: JPhotoService
22
23
  Util: JUtilService
23
24
  Library: JLibraryService
24
25
  Projection: JProjectionService
@@ -138,13 +139,6 @@ export interface JLocalStorageService {
138
139
  remove(key: string): void
139
140
  }
140
141
 
141
- export interface JPhotoService {
142
- displayFeaturePhotosPopup(layerId: JId, featureId: JId): Promise<void>
143
- displayPhotosPopup(photos: JPhoto[], params?: JPhotoOpenPopupParams): void
144
- downloadById(photoId: JId): Promise<void>
145
- closePhotoPopup(): void
146
- }
147
-
148
142
  export interface JFeatureService {
149
143
  getById(layerId: JId, featureId: JId, includeAllAttributes?: boolean): Promise<GeoJSON.Feature>
150
144
  getByIds(layerId: JId, featureIds: JId[]): Promise<GeoJSON.Feature[]>
@@ -198,7 +192,6 @@ export interface JEventService {
198
192
  Map: JMapEventModule
199
193
  Geocoding: JGeocodingEventModule
200
194
  SimpleSearch: JSimpleSearchEventModule
201
- Photo: JPhotoEventModule
202
195
  Project: JProjectEventModule
203
196
  User: JUserEventModule
204
197
  Feature: JFeatureEventModule
@@ -350,12 +343,6 @@ export interface JMapEventModule extends JEventModule {
350
343
  }
351
344
  }
352
345
 
353
- export interface JPhotoEventModule extends JEventModule {
354
- on: {
355
- containerCreated(listenerId: string, fn: (params: JPhotoEventContainerCreatedParams) => void): void
356
- }
357
- }
358
-
359
346
  export interface JFeatureEventModule extends JEventModule {
360
347
  on: {
361
348
  deletion(listenerId: string, fn: (params: JFeatureEventDeleteParams) => void): void
@@ -395,7 +382,6 @@ export interface JCoreState {
395
382
  table: JTableState
396
383
  user: JUserState
397
384
  language: JLanguageState
398
- photo: JPhotoState
399
385
  geocoding: JGeocodingState
400
386
  simpleSearch: JSimpleSearchState
401
387
  geolocation: JGeolocationState
@@ -525,15 +511,6 @@ export interface JTableState {
525
511
  tables: JTable[]
526
512
  }
527
513
 
528
- export interface JPhotoState {
529
- selectedPhotoId: JId | undefined
530
- photos: JPhoto[]
531
- isPopupOpened: boolean
532
- isLoading: boolean
533
- hasLoadingError: boolean
534
- isDownloading: boolean
535
- }
536
-
537
514
  export interface JUserState extends JTokenInfo {
538
515
  isAnonymous: boolean
539
516
  anonymousOrganizationId: string
@@ -569,6 +546,16 @@ export interface JFormJMCService {
569
546
  getForm(dataSourceId: string): Promise<JFormJMC | null>
570
547
  }
571
548
 
549
+ export interface JAttachmentService {
550
+ getByItemId(dataSourceId: JId, itemId: JId): Promise<JAttachment[]>
551
+ create(dataSourceId: string, params: JCreateAttachmentParams): Promise<string>
552
+ remove(dataSourceId: string, attachmentId: string): Promise<string>
553
+ update(dataSourceId: string, attachmentId: string, params: JUpdateAttachmentParams): Promise<string>
554
+ download(dataSourceId: string, attachmentId: string): Promise<{ data: Blob; headers: any }>
555
+ downloadToDevice(attachment: JAttachmentFile, dataSourceId: string): Promise<void>
556
+ previewAttachments(attachment: JAttachmentFile, dataSourceId: string): Promise<void>
557
+ }
558
+
572
559
  export interface JFormService {
573
560
  // REPO METHODS
574
561
  getFormsMetaDataByLayerId(layerId: JId): Promise<JFormMetaData[]>
@@ -898,7 +885,7 @@ export interface JTableService {
898
885
  getTables(): JTable[]
899
886
  getTableData(tableId: JId, params: JTableDataParams): Promise<JTableData>
900
887
  getById(tableId: JId): JTable
901
- createRow(tableId: JId, row: { [key: string]: any }): Promise<void>
888
+ createRow(tableId: JId, row: { [key: string]: any }): Promise<{ id: JId; links: Array<any> }>
902
889
  updateRow(tableId: JId, rowId: number, row: { [key: string]: any }): Promise<void>
903
890
  deleteRow(tableId: JId, rowId: number): Promise<void>
904
891
  getDataSourceAttributes(tableId: JId): Promise<JDataSourceAttribute[]>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmapcloud-ng-core-types",
3
- "version": "1.1.15",
3
+ "version": "1.1.18",
4
4
  "description": "JMap Cloud specific version of JMap Cloud NG Core types and interfaces",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,6 +31,7 @@
31
31
  "@auth0/auth0-spa-js": "^2.1.3",
32
32
  "@types/geojson": "^7946.0.14",
33
33
  "geojson": "^0.5.0",
34
+ "jmapcloud-types": "../../../packages/jmapcloud-types",
34
35
  "maplibre-gl": "^4.7.1",
35
36
  "redux": "^5.0.1"
36
37
  }
package/public/core.d.ts CHANGED
@@ -201,68 +201,6 @@ declare namespace JMap {
201
201
  function getAllIdentityProvidersById(): JServerIdentityProviderById
202
202
  }
203
203
 
204
- /* **JMap.Photo**
205
- *
206
- * This is where you can find JMap photo relative methods
207
- */
208
- namespace Photo {
209
- /**
210
- * **JMap.Photo.displayFeaturePhotosPopup**
211
- *
212
- * Display the photos of a given feature of a given layer.
213
- *
214
- * @param layerId the JMap layer id
215
- * @param featureId the JMap feature id
216
- * @example
217
- * ```ts
218
- * // Display the photos of feature id="345" in layer id="4"
219
- * JMap.Photo.displayFeaturePhotosPopup(4, 345)
220
- * ```
221
- */
222
- function displayFeaturePhotosPopup(layerId: JId, featureId: JId): Promise<void>
223
-
224
- /**
225
- * **JMap.Photo.displayPhotosPopup**
226
- *
227
- * Display your custom photos.
228
- *
229
- * @param photos your custom photos
230
- * @param params optional parameters
231
- * @example
232
- * ```ts
233
- * // Display the photos of feature id="345" in layer id="4"
234
- * JMap.Photo.displayPhotosPopup(4, 345)
235
- * ```
236
- */
237
- function displayPhotosPopup(photos: JPhoto[], params?: JPhotoOpenPopupParams): void
238
-
239
- /**
240
- * **JMap.Photo.closePhotoPopup**
241
- *
242
- * If displayed, close the photo popup
243
- *
244
- * @example
245
- * ```ts
246
- * // Close the photo popup
247
- * JMap.Photo.closePhotoPopup()
248
- * ```
249
- */
250
- function closePhotoPopup(): void
251
-
252
- /**
253
- * **JMap.Photo.downloadById**
254
- *
255
- * Triggers a file download for a given photo id.
256
- *
257
- * @example
258
- * ```ts
259
- * // download photo id="3"
260
- * JMap.Photo.downloadById(3)
261
- * ```
262
- */
263
- function downloadById(photoId: JId): Promise<void>
264
- }
265
-
266
204
  /**
267
205
  * **JMap.Geocoding**
268
206
  *
@@ -10010,6 +9948,177 @@ declare namespace JMap {
10010
9948
  */
10011
9949
  function getForm(dataSourceId: JId): Promise<JFormJMC | null>
10012
9950
  }
9951
+
9952
+ /**
9953
+ * **JMap.Attachment**
9954
+ *
9955
+ * Here you'll find all attachment related methods
9956
+ */
9957
+ namespace Attachment {
9958
+ /**
9959
+ * ***JMap.Attachment.getByItemId***
9960
+ *
9961
+ * Fetches every attachment linked to a specific **item** (row) of a data source.
9962
+ *
9963
+ * @param dataSourceId the data source identifier that contains the item
9964
+ * @param itemId the identifier of the item whose attachments you want
9965
+ * @example
9966
+ * ```ts
9967
+ * JMap.Attachment
9968
+ * .getByItemId("f47ac10b-58cc-4372-a567-0e02b2c3d479", 7088)
9969
+ * .then(attachments => console.log("Attachments found:", attachments.length))
9970
+ * .catch(error => console.error("An error occurred while fetching attachments", error))
9971
+ * ```
9972
+ */
9973
+ function getByItemId(dataSourceId: JId, itemId: JId): Promise<JAttachment[]>
9974
+
9975
+ /**
9976
+ * ***JMap.Attachment.create***
9977
+ *
9978
+ * Creates a new attachment for a data source item. The payload can represent either a file upload (`file`) or a URL attachment (`url`).
9979
+ *
9980
+ * @param dataSourceId the data source identifier that will receive the attachment
9981
+ * @param params see {@link JCreateAttachmentParams} (includes the `itemId`)
9982
+ * @example
9983
+ * ```ts
9984
+ * // Upload a file attachment
9985
+ * JMap.Attachment
9986
+ * .create("f47ac10b-58cc-4372-a567-0e02b2c3d479", {
9987
+ * itemId: 7088,
9988
+ * subject: "Site photo",
9989
+ * description: "Photo taken during inspection",
9990
+ * file: new File([blob], "inspection.jpg", { type: "image/jpeg" })
9991
+ * })
9992
+ * .then(id => console.log("Attachment created with id", id))
9993
+ * .catch(error => console.error("Attachment creation failed", error))
9994
+ *
9995
+ * // Add a URL attachment
9996
+ * JMap.Attachment
9997
+ * .create("f47ac10b-58cc-4372-a567-0e02b2c3d479", {
9998
+ * itemId: 7088,
9999
+ * subject: "External link",
10000
+ * url: "https://example.com/report"
10001
+ * })
10002
+ * .then(id => console.log("Attachment created with id", id))
10003
+ * .catch(error => console.error("Attachment creation failed", error))
10004
+ * ```
10005
+ */
10006
+ function create(dataSourceId: string, params: JCreateAttachmentParams): Promise<string>
10007
+
10008
+ /**
10009
+ * ***JMap.Attachment.remove***
10010
+ *
10011
+ * Deletes an attachment previously created on a data source.
10012
+ *
10013
+ * @param dataSourceId the JMap data source id
10014
+ * @param attachmentId the attachment identifier to remove
10015
+ * @example
10016
+ * ```ts
10017
+ * JMap.Attachment
10018
+ * .remove("f47ac10b-58cc-4372-a567-0e02b2c3d479", "d9428888-122b-11e1-b85c-61cd3cbb3210")
10019
+ * .then(() => console.log("Attachment removed"))
10020
+ * .catch(error => console.error("Failed to remove attachment", error))
10021
+ * ```
10022
+ */
10023
+ function remove(dataSourceId: string, attachmentId: string): Promise<string>
10024
+
10025
+ /**
10026
+ * ***JMap.Attachment.update***
10027
+ *
10028
+ * Updates the metadata (subject, description, URL) of an existing attachment.
10029
+ *
10030
+ * @param dataSourceId the JMap data source id
10031
+ * @param attachmentId the attachment identifier to update
10032
+ * @param params partial attachment payload containing the new values
10033
+ * @example
10034
+ * ```ts
10035
+ * JMap.Attachment
10036
+ * .update(
10037
+ * "f47ac10b-58cc-4372-a567-0e02b2c3d479",
10038
+ * "d9428888-122b-11e1-b85c-61cd3cbb3210",
10039
+ * { subject: "Updated subject", description: "New details" }
10040
+ * )
10041
+ * .then(() => console.log("Attachment updated"))
10042
+ * .catch(error => console.error("Failed to update attachment", error))
10043
+ * ```
10044
+ */
10045
+ function update(dataSourceId: string, attachmentId: string, params: JUpdateAttachmentParams): Promise<string>
10046
+ /**
10047
+ * ***JMap.Attachment.download***
10048
+ *
10049
+ * Downloads an attachment and returns the raw binary data plus the HTTP headers sent by the server.
10050
+ *
10051
+ * @param dataSourceId the JMap data source id
10052
+ * @param attachmentId the attachment to download
10053
+ * @example
10054
+ * ```ts
10055
+ * JMap.Attachment
10056
+ * .download("f47ac10b-58cc-4372-a567-0e02b2c3d479", "d9428888-122b-11e1-b85c-61cd3cbb3210")
10057
+ * .then(({ data, headers }) => console.log("Downloaded attachment", headers["content-type"], data.size))
10058
+ * .catch(error => console.error("Download failed", error))
10059
+ * ```
10060
+ */
10061
+ function download(dataSourceId: string, attachmentId: string): Promise<{ data: Blob; headers: any }>
10062
+
10063
+ /**
10064
+ * ***JMap.Attachment.downloadToDevice***
10065
+ *
10066
+ * Triggers a browser download for the provided file attachment.
10067
+ *
10068
+ * @param attachment the attachment to download
10069
+ * @param dataSourceId the JMap data source id
10070
+ * @example
10071
+ * ```ts
10072
+ * JMap.Attachment
10073
+ * .downloadToDevice(
10074
+ * {
10075
+ * id: "d9428888-122b-11e1-b85c-61cd3cbb3210",
10076
+ * organizationId: "c56a4180-65aa-42ec-a945-5fd21dec0538",
10077
+ * thumbnail: "",
10078
+ * fileId: "c56a4180-65aa-42ec-a945-5fd21dec0538",
10079
+ * fileName: "inspection.jpg",
10080
+ * fileSize: 481516,
10081
+ * mimeType: "image/jpeg"
10082
+ * },
10083
+ * "f47ac10b-58cc-4372-a567-0e02b2c3d479"
10084
+ * )
10085
+ * .then(() => console.log("Download started"))
10086
+ * .catch(error => console.error("Download failed", error))
10087
+ * ```
10088
+ */
10089
+ function downloadToDevice(attachment: JAttachmentFile, dataSourceId: string): Promise<void>
10090
+
10091
+ /**
10092
+ * ***JMap.Attachment.previewAttachments***
10093
+ *
10094
+ * Opens a client-side preview modal for the provided file attachment.
10095
+ *
10096
+ * The preview currently supports standard images and 360° panoramas; other file types will fall back to a download message.
10097
+ *
10098
+ * @param attachment the attachment to download
10099
+ * @param dataSourceId the JMap data source id
10100
+ * @example
10101
+ * ```ts
10102
+ * JMap.Attachment
10103
+ * .previewAttachments(
10104
+ * {
10105
+ * id: "c56a4180-65aa-42ec-a945-5fd21dec0538",
10106
+ * organizationId: "c56a4180-65aa-42ec-a945-5fd21dec0538",
10107
+ * thumbnail: "",
10108
+ * fileId: "d9428888-122b-11e1-b85c-61cd3cbb3210",
10109
+ * fileName: "panorama.jpg",
10110
+ * fileSize: 8675309,
10111
+ * mimeType: "image/jpeg"
10112
+ * },
10113
+ * "f47ac10b-58cc-4372-a567-0e02b2c3d479"
10114
+ * )
10115
+ * .then(() => console.log("Preview opened"))
10116
+ * .catch(error => console.error("Preview failed", error))
10117
+ * ```
10118
+ */
10119
+ function previewAttachments(attachment: JAttachmentFile, dataSourceId: string): Promise<void>
10120
+ }
10121
+
10013
10122
  /**
10014
10123
  * **JMap.Form**
10015
10124
  *
@@ -12454,7 +12563,7 @@ declare namespace JMap {
12454
12563
  }
12455
12564
  namespace Table {
12456
12565
  /**
12457
- * **JMap.Layer.getTables**
12566
+ * **JMap.Table.getTables**
12458
12567
  *
12459
12568
  * Returns an array of JMap tables available in the current project.
12460
12569
  *
@@ -12465,7 +12574,7 @@ declare namespace JMap {
12465
12574
  * @example
12466
12575
  * ```ts
12467
12576
  * // Retrieves all JMap tables
12468
- * JMap.Layer.getTables();
12577
+ * JMap.Table.getTables();
12469
12578
  * ```
12470
12579
  */
12471
12580
  function getTables(): JTable[]
@@ -12521,7 +12630,7 @@ declare namespace JMap {
12521
12630
  * @param {JId} tableId - The Id of the table.
12522
12631
  * @param {{ [key: string]: any }} row - the data of the row to be updated.
12523
12632
  *
12524
- * @returns {Promise<void>}
12633
+ * @returns {Promise<{ id: JId, links: Array<any> }>} id -the id of the created row
12525
12634
  *
12526
12635
  * @example
12527
12636
  * ```ts
@@ -12529,7 +12638,7 @@ declare namespace JMap {
12529
12638
  * JMap.Table.createRow("be4552e1-d89d-48ec-a417-7b99d14b4d7b", {city: "Montreal", country: "Canada"});
12530
12639
  * ```
12531
12640
  */
12532
- function createRow(tableId: JId, row: { [key: string]: any }): Promise<void>
12641
+ function createRow(tableId: JId, row: { [key: string]: any }): Promise<{ id: JId; links: Array<any> }>
12533
12642
 
12534
12643
  /**
12535
12644
  * **JMap.Table.updateRow**
@@ -28,4 +28,9 @@ declare interface JRequestConfig {
28
28
  * To specify custom headers (Authorization, Content-type, etc) that you might want to use for external ressources.
29
29
  */
30
30
  headers?: { [key: string]: any }
31
+
32
+ /**
33
+ * Allow callers to request raw data (blob, arraybuffer, etc).
34
+ */
35
+ responseType?: "arraybuffer" | "document" | "json" | "text" | "stream" | "blob"
31
36
  }
@@ -0,0 +1,37 @@
1
+ declare interface JAttachmentBase {
2
+ id: string
3
+ organizationId: string
4
+ subject?: string
5
+ description?: string
6
+ thumbnail: string
7
+ // type: "url" | "file" | "image" // TODO
8
+ }
9
+
10
+ declare interface JAttachmentFile extends JAttachmentBase {
11
+ fileName: string
12
+ fileSize: number
13
+ fileId: string
14
+ mimeType: string
15
+ }
16
+
17
+ declare interface JAttachmentUrl extends JAttachmentBase {
18
+ url: string
19
+ }
20
+
21
+ declare type JAttachment = JAttachmentUrl | JAttachmentFile
22
+
23
+ declare type JCreateAttachmentUrlParams = {
24
+ itemId: number
25
+ } & Pick<JAttachmentUrl, "subject" | "description" | "url">
26
+
27
+ declare type JCreateAttachmentFileParams = {
28
+ itemId: number
29
+ } & Pick<JAttachmentFile, "subject" | "description"> & {
30
+ file: File
31
+ }
32
+
33
+ declare type JCreateAttachmentParams = JCreateAttachmentFileParams | JCreateAttachmentUrlParams
34
+
35
+ declare type JUpdateAttachmentParams = Partial<
36
+ Pick<JAttachmentUrl, "subject" | "description" | "url"> | Pick<JAttachmentFile, "subject" | "description">
37
+ >
@@ -31,7 +31,7 @@ declare const enum FORMSCHEMA_TYPES {
31
31
 
32
32
  declare interface JFormJMC {
33
33
  id: string
34
- name: any
34
+ name: JLocaleTranslation
35
35
  createdBy: string
36
36
  creationDate: Date
37
37
  lastModifiedBy: string
@@ -318,7 +318,7 @@ declare interface JLayer extends JLayerTreeElement {
318
318
  selectionStyleId: string
319
319
  dynamicFilter: JDynamicFilter
320
320
  allowClientSideEditing: boolean
321
- filter: string
321
+ baseFilter?: import("jmapcloud-types").JAnyFilterCondition
322
322
  }
323
323
 
324
324
  declare interface JLayerInformationReport {
@@ -629,8 +629,12 @@ declare enum ATTRIBUTE_TYPES {
629
629
  BOOLEAN = "BOOLEAN"
630
630
  }
631
631
 
632
- declare interface JValueDomain {
633
- value?: any
634
- nullValue?: boolean
635
- title: JLocaleTranslation
636
- }
632
+ declare type JValueDomain =
633
+ | {
634
+ value: string | number
635
+ title: JLocaleTranslation
636
+ }
637
+ | {
638
+ nullValue: true
639
+ title: JLocaleTranslation
640
+ }
@@ -24,6 +24,7 @@ declare interface JTable {
24
24
  dataSourceId: string
25
25
  allowClientSideEditing: boolean
26
26
  permissions: JTablePermissions
27
+ baseFilter?: import("jmapcloud-types").JAnyFilterCondition
27
28
  }
28
29
 
29
30
  declare interface JTableAttribute {
@@ -45,7 +46,7 @@ declare interface JTableData {
45
46
  declare interface JTableDataParams {
46
47
  startIndex?: number
47
48
  limit?: number
48
- filter?: string
49
+ filter?: import("jmapcloud-types").JAnyFilterCondition
49
50
  sort?: string
50
51
  }
51
52