@extrahorizon/javascript-sdk 8.5.0 → 8.6.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [8.6.0]
9
+
10
+ ### Added
11
+ - Introduced methods to manage objects in arrays in the Data Service
12
+ - `exh.data.documents.appendObjectToArray`
13
+ - `exh.data.documents.updateObjectInArray`
14
+ - `exh.data.documents.removeObjectFromArray`
15
+
16
+ ### Fixed
17
+ - Added missing properties `userId` and `applicationId` for the method `sdk.payments.appStore.completeTransaction`
18
+ - Bumped Axios version to `0.30` to fix vulnerability `CVE-2025-27152`
19
+
8
20
  ## [8.5.0]
9
21
 
10
22
  ### Added
@@ -3596,6 +3596,21 @@ var documents = (client, httpAuth) => {
3596
3596
  async removeFields(schemaIdOrName, documentId, requestBody, options) {
3597
3597
  return (await client.post(httpAuth, `/${schemaIdOrName}/documents/${documentId}/deleteFields${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, requestBody, options)).data;
3598
3598
  },
3599
+ async appendObjectToArray(schemaIdOrName, documentId, arrayField, requestBody, options) {
3600
+ return (await client.post(httpAuth, `/${schemaIdOrName}/documents/${documentId}/${arrayField}/`, requestBody, {
3601
+ ...options,
3602
+ customKeys: ['*'],
3603
+ })).data;
3604
+ },
3605
+ async updateObjectInArray(schemaIdOrName, documentId, arrayField, objectId, requestBody, options) {
3606
+ return (await client.put(httpAuth, `/${schemaIdOrName}/documents/${documentId}/${arrayField}/${objectId}`, requestBody, {
3607
+ ...options,
3608
+ customRequestKeys: ['*'],
3609
+ })).data;
3610
+ },
3611
+ async removeObjectFromArray(schemaIdOrName, documentId, arrayField, objectId, options) {
3612
+ return (await client.delete(httpAuth, `/${schemaIdOrName}/documents/${documentId}/${arrayField}/${objectId}`, options)).data;
3613
+ },
3599
3614
  async transition(schemaIdOrName, documentId, requestBody, options) {
3600
3615
  return (await client.post(httpAuth, `/${schemaIdOrName}/documents/${documentId}/transition${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, requestBody, options)).data;
3601
3616
  },
@@ -5380,7 +5395,7 @@ const logsService = (httpWithAuth) => {
5380
5395
  };
5381
5396
  };
5382
5397
 
5383
- const version = '8.5.0';
5398
+ const version = '8.6.0';
5384
5399
 
5385
5400
  /**
5386
5401
  * Create ExtraHorizon client.
package/build/index.mjs CHANGED
@@ -3566,6 +3566,21 @@ var documents = (client, httpAuth) => {
3566
3566
  async removeFields(schemaIdOrName, documentId, requestBody, options) {
3567
3567
  return (await client.post(httpAuth, `/${schemaIdOrName}/documents/${documentId}/deleteFields${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, requestBody, options)).data;
3568
3568
  },
3569
+ async appendObjectToArray(schemaIdOrName, documentId, arrayField, requestBody, options) {
3570
+ return (await client.post(httpAuth, `/${schemaIdOrName}/documents/${documentId}/${arrayField}/`, requestBody, {
3571
+ ...options,
3572
+ customKeys: ['*'],
3573
+ })).data;
3574
+ },
3575
+ async updateObjectInArray(schemaIdOrName, documentId, arrayField, objectId, requestBody, options) {
3576
+ return (await client.put(httpAuth, `/${schemaIdOrName}/documents/${documentId}/${arrayField}/${objectId}`, requestBody, {
3577
+ ...options,
3578
+ customRequestKeys: ['*'],
3579
+ })).data;
3580
+ },
3581
+ async removeObjectFromArray(schemaIdOrName, documentId, arrayField, objectId, options) {
3582
+ return (await client.delete(httpAuth, `/${schemaIdOrName}/documents/${documentId}/${arrayField}/${objectId}`, options)).data;
3583
+ },
3569
3584
  async transition(schemaIdOrName, documentId, requestBody, options) {
3570
3585
  return (await client.post(httpAuth, `/${schemaIdOrName}/documents/${documentId}/transition${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, requestBody, options)).data;
3571
3586
  },
@@ -5350,7 +5365,7 @@ const logsService = (httpWithAuth) => {
5350
5365
  };
5351
5366
  };
5352
5367
 
5353
- const version = '8.5.0';
5368
+ const version = '8.6.0';
5354
5369
 
5355
5370
  /**
5356
5371
  * Create ExtraHorizon client.
@@ -129,6 +129,9 @@ export declare type MockClientOAuth1<MockFn> = {
129
129
  update: MockFn;
130
130
  remove: MockFn;
131
131
  removeFields: MockFn;
132
+ appendObjectToArray: MockFn;
133
+ updateObjectInArray: MockFn;
134
+ removeObjectFromArray: MockFn;
132
135
  transition: MockFn;
133
136
  linkGroups: MockFn;
134
137
  unlinkGroups: MockFn;
@@ -660,6 +663,9 @@ export declare type MockClientOAuth2<MockFn> = {
660
663
  update: MockFn;
661
664
  remove: MockFn;
662
665
  removeFields: MockFn;
666
+ appendObjectToArray: MockFn;
667
+ updateObjectInArray: MockFn;
668
+ removeObjectFromArray: MockFn;
663
669
  transition: MockFn;
664
670
  linkGroups: MockFn;
665
671
  unlinkGroups: MockFn;
@@ -1191,6 +1197,9 @@ export declare type MockClientProxy<MockFn> = {
1191
1197
  update: MockFn;
1192
1198
  remove: MockFn;
1193
1199
  removeFields: MockFn;
1200
+ appendObjectToArray: MockFn;
1201
+ updateObjectInArray: MockFn;
1202
+ removeObjectFromArray: MockFn;
1194
1203
  transition: MockFn;
1195
1204
  linkGroups: MockFn;
1196
1205
  unlinkGroups: MockFn;
@@ -775,6 +775,225 @@ export interface DataDocumentsService {
775
775
  removeFields(schemaIdOrName: ObjectId | string, documentId: ObjectId, requestBody: {
776
776
  fields: Array<string>;
777
777
  }, options?: OptionsWithRql): Promise<AffectedRecords>;
778
+ /**
779
+ * # Append an object to an array
780
+ *
781
+ * Append an object to an array field in the selected document.
782
+ *
783
+ * When the object is appended to the array, the object will automatically be assigned a unique `id`.
784
+ *
785
+ * ## Example
786
+ *
787
+ * For a schema with the name `daily-summary`, a document looking like:
788
+ *
789
+ * ```json
790
+ * {
791
+ * "id": "5f7b1b3b1f7b4b0001f7b4b2",
792
+ * "data": {
793
+ * "userId": "67e66ef64f0ea8488aba8f2f",
794
+ * "date": "2025-03-28",
795
+ * "hourlySummaries": [
796
+ * { "id": "6568d05351c0f5307421e196", "avg": 5, "max": 10, "min": 2 },
797
+ * { "id": "67e66793ae59de5bba4b262f", "avg": 7, "max": 15, "min": 3 }
798
+ * ]
799
+ * }
800
+ * }
801
+ * ```
802
+ *
803
+ * Appending an item to the `hourlySummaries`, looking like:
804
+ *
805
+ * ```json
806
+ * {
807
+ * "avg": 10,
808
+ * "max": 20,
809
+ * "min": 5
810
+ * }
811
+ * ```
812
+ *
813
+ * Would be done like:
814
+ *
815
+ * ```ts
816
+ * const documentId = '5f7b1b3b1f7b4b0001f7b4b2';
817
+ * const hourlySummary = { avg: 10, max: 20, min: 5 };
818
+ * await exh.data.documents.appendObjectToArray('daily-summary', documentId, 'hourlySummaries', hourlySummary);
819
+ * ```
820
+ *
821
+ * ## Access via permissions
822
+ * Regardless of how the access modes (described below) are set, a user is always able to perform an operation on a document if they are assigned a specific permission. This permission can come from a global role of the user or a staff enlistment role the user has in the group of the document.
823
+ * Permission | Scopes | Effect
824
+ * - | - | -
825
+ * `UPDATE_DOCUMENTS` | `global` | Update any document
826
+ * `UPDATE_DOCUMENTS:{SCHEMA_NAME}` | `global` | Update any document of the specified schema
827
+ * `UPDATE_DOCUMENTS` | `staff_enlistment` | Update any document belonging to the group
828
+ * `UPDATE_DOCUMENTS:{SCHEMA_NAME}` | `staff_enlistment` | Update any document of the specified schema belonging to the group
829
+ * <br>
830
+ *
831
+ * ## General access mode values
832
+ * The general access mode values determine if a user requires permission to perform the action for the Schema. A general access mode value is provided as one of the following strings.
833
+ * General updateMode value | Description
834
+ * - | -
835
+ * `"permissionRequired"` | The permissions above apply
836
+ * <br>
837
+ *
838
+ * ## Relational access mode values
839
+ * Relational access mode values are supplied as an array. When multiple relational access mode values are supplied, a user adhering to any relation in this array is allowed to perform the action on the document.
840
+ * Relational updateMode value | Description
841
+ * - | -
842
+ * `["creator"]` | The user that created the document can update the document.
843
+ * `["linkedUsers"]` | All users where their user id is in the list of userIds of the document can update the document.
844
+ * `["linkedGroupPatients"]` | All users that have a patient enlistment in a group that is in the list of groupIds of the document can update the document.
845
+ * `["linkedGroupStaff"]` | All users that have a staff enlistment in a group that is in the list of groupIds of the document can update the document.
846
+ * <br>
847
+ *
848
+ * ## Legacy access mode values
849
+ * Listed below are the deprecated values with their current equivalent
850
+ * Legacy updateMode value | Description
851
+ * - | -
852
+ * `"default"` | Translates to `["linkedUsers","linkedGroupStaff"]` relational access mode
853
+ * `"creatorOnly"` | Translates to `["creator"]` relational access mode
854
+ * `"disabled"` | Translates to the `"permissionRequired"` general access mode value
855
+ * `"linkedGroupsStaffOnly"` | Translates to `["linkedGroupStaff"]` relational access mode
856
+ */
857
+ appendObjectToArray<UpdateData = Record<string, any>>(schemaIdOrName: ObjectId | string, documentId: ObjectId, arrayField: string, requestBody: UpdateData, options?: OptionsBase): Promise<UpdateData & {
858
+ id: ObjectId;
859
+ }>;
860
+ /**
861
+ * # Update an object in an array
862
+ *
863
+ * Update an object in an array field in the selected document.
864
+ *
865
+ * ## Example
866
+ *
867
+ * For a schema with the name `daily-summary`, a document looking like:
868
+ *
869
+ * ```json
870
+ * {
871
+ * "id": "5f7b1b3b1f7b4b0001f7b4b2",
872
+ * "data": {
873
+ * "userId": "67e66ef64f0ea8488aba8f2f",
874
+ * "date": "2025-03-28",
875
+ * "hourlySummaries": [
876
+ * { "id": "6568d05351c0f5307421e196", "avg": 5, "max": 10, "min": 2 },
877
+ * { "id": "67e66793ae59de5bba4b262f", "avg": 7, "max": 15, "min": 3 }
878
+ * ]
879
+ * }
880
+ * }
881
+ * ```
882
+ *
883
+ * Updating the object with the id `67e66793ae59de5bba4b262f` in the `hourlySummaries` array would be done like:
884
+ *
885
+ * ```ts
886
+ * const documentId = '5f7b1b3b1f7b4b0001f7b4b2';
887
+ * const objectId = '67e66793ae59de5bba4b262f';
888
+ * const updateData = { avg: 8, max: 16, min: 4 };
889
+ * await exh.data.documents.updateObjectInArray('daily-summary', documentId, 'hourlySummaries', objectId, updateData);
890
+ * ```
891
+ *
892
+ * ## Access via permissions
893
+ * Regardless of how the access modes (described below) are set, a user is always able to perform an operation on a document if they are assigned a specific permission. This permission can come from a global role of the user or a staff enlistment role the user has in the group of the document.
894
+ * Permission | Scopes | Effect
895
+ * - | - | -
896
+ * `UPDATE_DOCUMENTS` | `global` | Update any document
897
+ * `UPDATE_DOCUMENTS:{SCHEMA_NAME}` | `global` | Update any document of the specified schema
898
+ * `UPDATE_DOCUMENTS` | `staff_enlistment` | Update any document belonging to the group
899
+ * `UPDATE_DOCUMENTS:{SCHEMA_NAME}` | `staff_enlistment` | Update any document of the specified schema belonging to the group
900
+ * <br>
901
+ *
902
+ * ## General access mode values
903
+ * The general access mode values determine if a user requires permission to perform the action for the Schema. A general access mode value is provided as one of the following strings.
904
+ * General updateMode value | Description
905
+ * - | -
906
+ * `"permissionRequired"` | The permissions above apply
907
+ * <br>
908
+ *
909
+ * ## Relational access mode values
910
+ * Relational access mode values are supplied as an array. When multiple relational access mode values are supplied, a user adhering to any relation in this array is allowed to perform the action on the document.
911
+ * Relational updateMode value | Description
912
+ * - | -
913
+ * `["creator"]` | The user that created the document can update the document.
914
+ * `["linkedUsers"]` | All users where their user id is in the list of userIds of the document can update the document.
915
+ * `["linkedGroupPatients"]` | All users that have a patient enlistment in a group that is in the list of groupIds of the document can update the document.
916
+ * `["linkedGroupStaff"]` | All users that have a staff enlistment in a group that is in the list of groupIds of the document can update the document.
917
+ * <br>
918
+ *
919
+ * ## Legacy access mode values
920
+ * Listed below are the deprecated values with their current equivalent
921
+ * Legacy updateMode value | Description
922
+ * - | -
923
+ * `"default"` | Translates to `["linkedUsers","linkedGroupStaff"]` relational access mode
924
+ * `"creatorOnly"` | Translates to `["creator"]` relational access mode
925
+ * `"disabled"` | Translates to the `"permissionRequired"` general access mode value
926
+ * `"linkedGroupsStaffOnly"` | Translates to `["linkedGroupStaff"]` relational access mode
927
+ */
928
+ updateObjectInArray<UpdateData = Record<string, any>>(schemaIdOrName: ObjectId | string, documentId: ObjectId, arrayField: string, objectId: ObjectId, requestBody: UpdateData, options?: OptionsBase): Promise<AffectedRecords>;
929
+ /**
930
+ * # Remove an object from an array
931
+ *
932
+ * Remove an object from an array field in the selected document.
933
+ *
934
+ * ## Example
935
+ *
936
+ * For a schema with the name `daily-summary`, a document looking like:
937
+ *
938
+ * ```json
939
+ * {
940
+ * "id": "5f7b1b3b1f7b4b0001f7b4b2",
941
+ * "data": {
942
+ * "userId": "67e66ef64f0ea8488aba8f2f",
943
+ * "date": "2025-03-28",
944
+ * "hourlySummaries": [
945
+ * { "id": "6568d05351c0f5307421e196", "avg": 5, "max": 10, "min": 2 },
946
+ * { "id": "67e66793ae59de5bba4b262f", "avg": 7, "max": 15, "min": 3 }
947
+ * ]
948
+ * }
949
+ * }
950
+ * ```
951
+ *
952
+ * Removing the object with the id `67e66793ae59de5bba4b262f` from the `hourlySummaries` array would be done like:
953
+ *
954
+ * ```ts
955
+ * const documentId = '5f7b1b3b1f7b4b0001f7b4b2';
956
+ * const objectId = '67e66793ae59de5bba4b262f';
957
+ * await exh.data.documents.removeObjectFromArray('daily-summary', documentId, 'hourlySummaries', objectId);
958
+ * ```
959
+ *
960
+ * ## Access via permissions
961
+ * Regardless of how the access modes (described below) are set, a user is always able to perform an operation on a document if they are assigned a specific permission. This permission can come from a global role of the user or a staff enlistment role the user has in the group of the document.
962
+ * Permission | Scopes | Effect
963
+ * - | - | -
964
+ * `UPDATE_DOCUMENTS` | `global` | Update any document
965
+ * `UPDATE_DOCUMENTS:{SCHEMA_NAME}` | `global` | Update any document of the specified schema
966
+ * `UPDATE_DOCUMENTS` | `staff_enlistment` | Update any document belonging to the group
967
+ * `UPDATE_DOCUMENTS:{SCHEMA_NAME}` | `staff_enlistment` | Update any document of the specified schema belonging to the group
968
+ * <br>
969
+ *
970
+ * ## General access mode values
971
+ * The general access mode values determine if a user requires permission to perform the action for the Schema. A general access mode value is provided as one of the following strings.
972
+ * General updateMode value | Description
973
+ * - | -
974
+ * `"permissionRequired"` | The permissions above apply
975
+ * <br>
976
+ *
977
+ * ## Relational access mode values
978
+ * Relational access mode values are supplied as an array. When multiple relational access mode values are supplied, a user adhering to any relation in this array is allowed to perform the action on the document.
979
+ * Relational updateMode value | Description
980
+ * - | -
981
+ * `["creator"]` | The user that created the document can update the document.
982
+ * `["linkedUsers"]` | All users where their user id is in the list of userIds of the document can update the document.
983
+ * `["linkedGroupPatients"]` | All users that have a patient enlistment in a group that is in the list of groupIds of the document can update the document.
984
+ * `["linkedGroupStaff"]` | All users that have a staff enlistment in a group that is in the list of groupIds of the document can update the document.
985
+ * <br>
986
+ *
987
+ * ## Legacy access mode values
988
+ * Listed below are the deprecated values with their current equivalent
989
+ * Legacy updateMode value | Description
990
+ * - | -
991
+ * `"default"` | Translates to `["linkedUsers","linkedGroupStaff"]` relational access mode
992
+ * `"creatorOnly"` | Translates to `["creator"]` relational access mode
993
+ * `"disabled"` | Translates to the `"permissionRequired"` general access mode value
994
+ * `"linkedGroupsStaffOnly"` | Translates to `["linkedGroupStaff"]` relational access mode
995
+ */
996
+ removeObjectFromArray(schemaIdOrName: ObjectId | string, documentId: ObjectId, arrayField: string, objectId: ObjectId, options?: OptionsBase): Promise<AffectedRecords>;
778
997
  /**
779
998
  * # Transition a document
780
999
  *
@@ -182,6 +182,14 @@ export interface TransactionCompletionDataSchema {
182
182
  * The id of the transition inside the receipt to complete
183
183
  */
184
184
  transactionId: string;
185
+ /**
186
+ * The id of the user to complete the transaction for (requires the `ASSUME_PAYMENT_ENTITY` permission)
187
+ */
188
+ userId?: ObjectId;
189
+ /**
190
+ * The id of the application to complete the transaction for (requires the `ASSUME_PAYMENT_ENTITY` permission)
191
+ */
192
+ applicationId?: ObjectId;
185
193
  }
186
194
  export declare type AppleReceiptExampleSchema = any;
187
195
  export interface ReceiptVerificationDataSchema {
@@ -350,6 +358,7 @@ export interface PaymentsAppStoreService {
350
358
  * Permission | Scope | Effect
351
359
  * - | - | -
352
360
  * none | | Everyone can use this endpoint
361
+ * `ASSUME_PAYMENT_ENTITY` | `global` | Complete a transaction for another application or user
353
362
  * @param requestBody TransactionCompletionDataSchema
354
363
  * @returns AppleReceiptExampleSchema
355
364
  * A detailed description of the data can be found in the [official App Store documentation](https://developer.apple.com/documentation/appstorereceipts/responsebody).
@@ -1 +1 @@
1
- export declare const version = "8.5.0";
1
+ export declare const version = "8.6.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/javascript-sdk",
3
- "version": "8.5.0",
3
+ "version": "8.6.0",
4
4
  "description": "This package serves as a JavaScript wrapper around all Extra Horizon cloud services.",
5
5
  "main": "build/index.cjs.js",
6
6
  "types": "build/types/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "build"
33
33
  ],
34
34
  "dependencies": {
35
- "axios": "0.28.1",
35
+ "axios": "0.30.0",
36
36
  "buffer": "6.0.3",
37
37
  "fflate": "0.8.2",
38
38
  "form-data": "4.0.0",
@@ -58,4 +58,4 @@
58
58
  "ts-jest": "^29.1.2",
59
59
  "typescript": "^4.5.5"
60
60
  }
61
- }
61
+ }