@icure/api 7.0.0-beta.4 → 7.0.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.
Files changed (74) hide show
  1. package/icc-api/api/IccDocumentApi.d.ts +6 -4
  2. package/icc-api/api/IccDocumentApi.js +8 -5
  3. package/icc-api/api/IccDocumentApi.js.map +1 -1
  4. package/icc-api/model/Address.d.ts +6 -0
  5. package/icc-api/model/Address.js.map +1 -1
  6. package/icc-api/model/Annotation.d.ts +18 -0
  7. package/icc-api/model/Annotation.js.map +1 -1
  8. package/icc-api/model/Content.js +1 -1
  9. package/icc-api/model/Content.js.map +1 -1
  10. package/icc-api/model/CryptoActorStub.d.ts +5 -0
  11. package/icc-api/model/CryptoActorStub.js +1 -0
  12. package/icc-api/model/CryptoActorStub.js.map +1 -1
  13. package/icc-api/model/Delegation.d.ts +3 -0
  14. package/icc-api/model/Delegation.js.map +1 -1
  15. package/icc-api/model/HealthElement.d.ts +6 -0
  16. package/icc-api/model/HealthElement.js.map +1 -1
  17. package/icc-api/model/HealthcareParty.js +1 -1
  18. package/icc-api/model/HealthcareParty.js.map +1 -1
  19. package/icc-api/model/ISO639_1.d.ts +8 -0
  20. package/icc-api/model/ISO639_1.js +3 -0
  21. package/icc-api/model/ISO639_1.js.map +1 -0
  22. package/icc-api/model/Patient.d.ts +7 -0
  23. package/icc-api/model/Patient.js +1 -1
  24. package/icc-api/model/Patient.js.map +1 -1
  25. package/icc-api/model/models.d.ts +1 -0
  26. package/icc-api/model/models.js.map +1 -1
  27. package/icc-x-api/crypto/EntitiesEncryption.d.ts +2 -1
  28. package/icc-x-api/crypto/EntitiesEncryption.js +13 -11
  29. package/icc-x-api/crypto/EntitiesEncryption.js.map +1 -1
  30. package/icc-x-api/filters/filters.d.ts +4 -0
  31. package/icc-x-api/filters/filters.js +4 -0
  32. package/icc-x-api/filters/filters.js.map +1 -1
  33. package/icc-x-api/icc-accesslog-x-api.d.ts +1 -1
  34. package/icc-x-api/icc-accesslog-x-api.js +9 -21
  35. package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
  36. package/icc-x-api/icc-calendar-item-x-api.d.ts +1 -1
  37. package/icc-x-api/icc-calendar-item-x-api.js +9 -18
  38. package/icc-x-api/icc-calendar-item-x-api.js.map +1 -1
  39. package/icc-x-api/icc-classification-x-api.js +6 -17
  40. package/icc-x-api/icc-classification-x-api.js.map +1 -1
  41. package/icc-x-api/icc-contact-x-api.d.ts +16 -1
  42. package/icc-x-api/icc-contact-x-api.js +65 -95
  43. package/icc-x-api/icc-contact-x-api.js.map +1 -1
  44. package/icc-x-api/icc-doctemplate-x-api.js +2 -13
  45. package/icc-x-api/icc-doctemplate-x-api.js.map +1 -1
  46. package/icc-x-api/icc-document-x-api.d.ts +12 -4
  47. package/icc-x-api/icc-document-x-api.js +22 -23
  48. package/icc-x-api/icc-document-x-api.js.map +1 -1
  49. package/icc-x-api/icc-form-x-api.js +6 -15
  50. package/icc-x-api/icc-form-x-api.js.map +1 -1
  51. package/icc-x-api/icc-helement-x-api.d.ts +1 -1
  52. package/icc-x-api/icc-helement-x-api.js +8 -18
  53. package/icc-x-api/icc-helement-x-api.js.map +1 -1
  54. package/icc-x-api/icc-invoice-x-api.js +6 -17
  55. package/icc-x-api/icc-invoice-x-api.js.map +1 -1
  56. package/icc-x-api/icc-maintenance-task-x-api.d.ts +1 -1
  57. package/icc-x-api/icc-maintenance-task-x-api.js +7 -13
  58. package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
  59. package/icc-x-api/icc-message-x-api.js +6 -16
  60. package/icc-x-api/icc-message-x-api.js.map +1 -1
  61. package/icc-x-api/icc-patient-x-api.d.ts +1 -1
  62. package/icc-x-api/icc-patient-x-api.js +9 -17
  63. package/icc-x-api/icc-patient-x-api.js.map +1 -1
  64. package/icc-x-api/icc-receipt-x-api.js +5 -15
  65. package/icc-x-api/icc-receipt-x-api.js.map +1 -1
  66. package/icc-x-api/icc-time-table-x-api.js +5 -15
  67. package/icc-x-api/icc-time-table-x-api.js.map +1 -1
  68. package/icc-x-api/index.d.ts +108 -2
  69. package/icc-x-api/index.js +6 -5
  70. package/icc-x-api/index.js.map +1 -1
  71. package/icc-x-api/utils/crypto-utils.d.ts +140 -11
  72. package/icc-x-api/utils/crypto-utils.js +285 -36
  73. package/icc-x-api/utils/crypto-utils.js.map +1 -1
  74. package/package.json +1 -1
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IccDoctemplateXApi = void 0;
4
4
  const icc_api_1 = require("../icc-api");
5
- const lodash_1 = require("lodash");
6
5
  const binary_utils_1 = require("./utils/binary-utils");
7
6
  const XHR_1 = require("../icc-api/api/XHR");
8
7
  const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
@@ -20,18 +19,8 @@ class IccDoctemplateXApi extends icc_api_1.IccDoctemplateApi {
20
19
  }
21
20
  newInstance(user, template, c) {
22
21
  return new Promise((resolve, reject) => {
23
- const documentTemplate = (0, lodash_1.extend)({
24
- id: this.crypto.primitives.randomUuid(),
25
- _type: 'org.taktik.icure.entities.DocumentTemplate',
26
- owner: user.id,
27
- created: new Date().getTime(),
28
- modified: new Date().getTime(),
29
- guid: this.crypto.primitives.randomUuid(),
30
- group: null,
31
- specialty: null,
32
- attachment: (0, binary_utils_1.string2ua)(template),
33
- mainUti: 'public.plain-text',
34
- }, c || {});
22
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
23
+ const documentTemplate = Object.assign(Object.assign({}, (c !== null && c !== void 0 ? c : {})), { _type: 'org.taktik.icure.entities.DocumentTemplate', id: (_a = c === null || c === void 0 ? void 0 : c.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), owner: (_b = c === null || c === void 0 ? void 0 : c.owner) !== null && _b !== void 0 ? _b : user.id, created: (_c = c === null || c === void 0 ? void 0 : c.created) !== null && _c !== void 0 ? _c : new Date().getTime(), modified: (_d = c === null || c === void 0 ? void 0 : c.modified) !== null && _d !== void 0 ? _d : new Date().getTime(), guid: (_e = c === null || c === void 0 ? void 0 : c.guid) !== null && _e !== void 0 ? _e : this.crypto.primitives.randomUuid(), group: (_f = c === null || c === void 0 ? void 0 : c.group) !== null && _f !== void 0 ? _f : null, specialty: (_g = c === null || c === void 0 ? void 0 : c.specialty) !== null && _g !== void 0 ? _g : null, attachment: (_h = c === null || c === void 0 ? void 0 : c.attachment) !== null && _h !== void 0 ? _h : (0, binary_utils_1.string2ua)(template), mainUti: (_j = c === null || c === void 0 ? void 0 : c.mainUti) !== null && _j !== void 0 ? _j : 'public.plain-text' });
35
24
  if (documentTemplate.group && documentTemplate.group.guid == null) {
36
25
  documentTemplate.group.guid = this.crypto.primitives.randomUuid();
37
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"icc-doctemplate-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-doctemplate-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAG9C,mCAA+B;AAG/B,uDAAgD;AAChD,4CAAwC;AACxC,0EAAgG;AAEhG,qCAAqC;AACrC,MAAa,kBAAmB,SAAQ,2BAAiB;IAKvD,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAA;QACpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,WAAW,CAAC,IAAiB,EAAE,QAAgB,EAAE,CAAM;QACrD,OAAO,I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W,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;CACF;AA5FD,gDA4FC","sourcesContent":["import { IccDoctemplateApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport { extend } from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { DocumentTemplate } from '../icc-api/model/models'\nimport { string2ua } from './utils/binary-utils'\nimport { XHR } from '../icc-api/api/XHR'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccDoctemplateXApi extends IccDoctemplateApi {\n crypto: IccCryptoXApi\n authenticationProvider: AuthenticationProvider\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.authenticationProvider = authenticationProvider\n this.fetchImpl = fetchImpl\n }\n\n newInstance(user: models.User, template: string, c: any): Promise<DocumentTemplate> {\n return new Promise<DocumentTemplate>((resolve, reject) => {\n const documentTemplate: DocumentTemplate = extend(\n {\n id: this.crypto.primitives.randomUuid(),\n _type: 'org.taktik.icure.entities.DocumentTemplate',\n owner: user.id,\n created: new Date().getTime(),\n modified: new Date().getTime(),\n guid: this.crypto.primitives.randomUuid(),\n group: null,\n specialty: null,\n attachment: string2ua(template),\n mainUti: 'public.plain-text',\n },\n c || {}\n )\n if (documentTemplate.group && documentTemplate.group.guid == null) {\n documentTemplate.group.guid = this.crypto.primitives.randomUuid()\n }\n\n //sauver l doctemplate vide\n\n if (template) {\n //save attachement\n }\n\n return resolve(documentTemplate)\n })\n }\n\n // noinspection JSUnusedLocalSymbols\n findAllByOwnerId(ownerId: string): Promise<Array<models.DocumentTemplate>> {\n return new Promise(function (resolve, reject) {\n reject(console.log('findByHCPartyPatientSecretFKeys not implemented in document API!'))\n })\n }\n\n // noinspection JSUnusedGlobalSymbols\n getAttachmentUrl(documentId: string, attachmentId: string) {\n return (\n this.host + '/doctemplate/{documentId}/attachment/{attachmentId}'.replace('{documentId}', documentId).replace('{attachmentId}', attachmentId)\n )\n }\n\n getAttachmentText(documentTemplateId: string, attachmentId: string): Promise<any | boolean> {\n const _body = null\n\n const _url =\n this.host +\n '/doctemplate/{documentTemplateId}/attachmentText/{attachmentId}'\n .replace('{documentTemplateId}', documentTemplateId + '')\n .replace('{attachmentId}', attachmentId + '') +\n '?ts=' +\n new Date().getTime()\n\n return XHR.sendCommand('GET', _url, this.headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => {\n if (doc.contentType.startsWith('application/octet-stream')) {\n const enc = new TextDecoder('utf-8')\n const arr = new Uint8Array(doc.body)\n return enc.decode(arr)\n } else if (doc.contentType.startsWith('text/plain') || doc.contentType.startsWith('text/html') || doc.contentType.startsWith('text/xml')) {\n return doc.body\n } else {\n return false\n }\n })\n .catch((err) => this.handleError(err))\n }\n}\n"]}
1
+ {"version":3,"file":"icc-doctemplate-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-doctemplate-x-api.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAM9C,uDAAgD;AAChD,4CAAwC;AACxC,0EAAgG;AAEhG,qCAAqC;AACrC,MAAa,kBAAmB,SAAQ,2BAAiB;IAKvD,YACE,IAAY,EACZ,OAAkC,EAClC,MAAqB,EACrB,yBAAiD,IAAI,iDAAwB,EAAE,EAC/E,YAA2E,OAAO,MAAM,KAAK,WAAW;QACtG,CAAC,CAAC,MAAM,CAAC,KAAK;QACd,CAAC,CAAC,OAAO,IAAI,KAAK,WAAW;YAC7B,CAAC,CAAC,IAAI,CAAC,KAAK;YACZ,CAAC,CAAC,KAAK;QAET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AAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,CAAC;aAC9H,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE;gBAC1D,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAA;gBACpC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBACpC,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;aACvB;iBAAM,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBACxI,OAAO,GAAG,CAAC,IAAI,CAAA;aAChB;iBAAM;gBACL,OAAO,KAAK,CAAA;aACb;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1C,CAAC;CACF;AA1FD,gDA0FC","sourcesContent":["import { IccDoctemplateApi } from '../icc-api'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\n\nimport { extend } from 'lodash'\nimport * as models from '../icc-api/model/models'\nimport { DocumentTemplate } from '../icc-api/model/models'\nimport { string2ua } from './utils/binary-utils'\nimport { XHR } from '../icc-api/api/XHR'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\n\n// noinspection JSUnusedGlobalSymbols\nexport class IccDoctemplateXApi extends IccDoctemplateApi {\n crypto: IccCryptoXApi\n authenticationProvider: AuthenticationProvider\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n crypto: IccCryptoXApi,\n authenticationProvider: AuthenticationProvider = new NoAuthenticationProvider(),\n fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response> = typeof window !== 'undefined'\n ? window.fetch\n : typeof self !== 'undefined'\n ? self.fetch\n : fetch\n ) {\n super(host, headers, authenticationProvider, fetchImpl)\n this.crypto = crypto\n this.authenticationProvider = authenticationProvider\n this.fetchImpl = fetchImpl\n }\n\n newInstance(user: models.User, template: string, c: any): Promise<DocumentTemplate> {\n return new Promise<DocumentTemplate>((resolve, reject) => {\n const documentTemplate: DocumentTemplate = {\n ...(c ?? {}),\n _type: 'org.taktik.icure.entities.DocumentTemplate',\n id: c?.id ?? this.crypto.primitives.randomUuid(),\n owner: c?.owner ?? user.id,\n created: c?.created ?? new Date().getTime(),\n modified: c?.modified ?? new Date().getTime(),\n guid: c?.guid ?? this.crypto.primitives.randomUuid(),\n group: c?.group ?? null,\n specialty: c?.specialty ?? null,\n attachment: c?.attachment ?? string2ua(template),\n mainUti: c?.mainUti ?? 'public.plain-text',\n }\n if (documentTemplate.group && documentTemplate.group.guid == null) {\n documentTemplate.group.guid = this.crypto.primitives.randomUuid()\n }\n\n //sauver l doctemplate vide\n\n if (template) {\n //save attachement\n }\n\n return resolve(documentTemplate)\n })\n }\n\n // noinspection JSUnusedLocalSymbols\n findAllByOwnerId(ownerId: string): Promise<Array<models.DocumentTemplate>> {\n return new Promise(function (resolve, reject) {\n reject(console.log('findByHCPartyPatientSecretFKeys not implemented in document API!'))\n })\n }\n\n // noinspection JSUnusedGlobalSymbols\n getAttachmentUrl(documentId: string, attachmentId: string) {\n return (\n this.host + '/doctemplate/{documentId}/attachment/{attachmentId}'.replace('{documentId}', documentId).replace('{attachmentId}', attachmentId)\n )\n }\n\n getAttachmentText(documentTemplateId: string, attachmentId: string): Promise<any | boolean> {\n const _body = null\n\n const _url =\n this.host +\n '/doctemplate/{documentTemplateId}/attachmentText/{attachmentId}'\n .replace('{documentTemplateId}', documentTemplateId + '')\n .replace('{attachmentId}', attachmentId + '') +\n '?ts=' +\n new Date().getTime()\n\n return XHR.sendCommand('GET', _url, this.headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())\n .then((doc) => {\n if (doc.contentType.startsWith('application/octet-stream')) {\n const enc = new TextDecoder('utf-8')\n const arr = new Uint8Array(doc.body)\n return enc.decode(arr)\n } else if (doc.contentType.startsWith('text/plain') || doc.contentType.startsWith('text/html') || doc.contentType.startsWith('text/xml')) {\n return doc.body\n } else {\n return false\n }\n })\n .catch((err) => this.handleError(err))\n }\n}\n"]}
@@ -63,32 +63,40 @@ export declare class IccDocumentXApi extends IccDocumentApi implements Encrypted
63
63
  * Adds an attachment to a document, encrypting it on client side using the encryption keys of the provided document.
64
64
  * @param document a document.
65
65
  * @param attachment a new main attachment for the document.
66
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
67
+ * overrides existing values.
66
68
  * @return the updated document.
67
69
  */
68
- encryptAndSetDocumentAttachment(document: models.Document, attachment: ArrayBuffer | Uint8Array): Promise<models.Document>;
70
+ encryptAndSetDocumentAttachment(document: models.Document, attachment: ArrayBuffer | Uint8Array, utis?: string[]): Promise<models.Document>;
69
71
  /**
70
72
  * Adds an unencrypted attachment to a document.
71
73
  * @param document a document.
72
74
  * @param attachment a new main attachment for the document.
75
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
76
+ * overrides existing values.
73
77
  * @return the updated document.
74
78
  */
75
- setClearDocumentAttachment(document: models.Document, attachment: ArrayBuffer | Uint8Array): Promise<models.Document>;
79
+ setClearDocumentAttachment(document: models.Document, attachment: ArrayBuffer | Uint8Array, utis?: string[]): Promise<models.Document>;
76
80
  /**
77
81
  * Adds a secondary attachment to a document, encrypting it on client side using the encryption keys of the provided document.
78
82
  * @param document a document.
79
83
  * @param secondaryAttachmentKey key for the secondary attachment.
80
84
  * @param attachment a new secondary attachment for the document.
85
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
86
+ * overrides existing values.
81
87
  * @return the updated document.
82
88
  */
83
- encryptAndSetSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Document>;
89
+ encryptAndSetSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, attachment: ArrayBuffer | Uint8Array, utis?: string[]): Promise<models.Document>;
84
90
  /**
85
91
  * Adds an unencrypted secondary attachment to a document.
86
92
  * @param document a document.
87
93
  * @param secondaryAttachmentKey key for the secondary attachment.
88
94
  * @param attachment a new secondary attachment for the document.
95
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
96
+ * overrides existing values.
89
97
  * @return the updated document.
90
98
  */
91
- setClearSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, attachment: ArrayBuffer | Uint8Array): Promise<models.Document>;
99
+ setClearSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, attachment: ArrayBuffer | Uint8Array, utis?: string[]): Promise<models.Document>;
92
100
  /**
93
101
  * Gets the main attachment of a document and tries to decrypt it using the encryption keys of the document, throwing an error if the operation fails.
94
102
  * @param document a document.
@@ -435,30 +435,21 @@ class IccDocumentXApi extends icc_api_1.IccDocumentApi {
435
435
  * @return a new instance of document.
436
436
  */
437
437
  newInstance(user, message, c = {}, options = {}) {
438
- var _a, _b, _c, _d, _e, _f;
438
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
439
439
  return __awaiter(this, void 0, void 0, function* () {
440
440
  if (!message && options.preferredSfk)
441
441
  throw new Error('You need to specify parent message in order to use secret foreign keys.');
442
- const document = _.extend({
443
- id: this.crypto.primitives.randomUuid(),
444
- _type: 'org.taktik.icure.entities.Document',
445
- created: new Date().getTime(),
446
- modified: new Date().getTime(),
447
- responsible: this.dataOwnerApi.getDataOwnerIdOf(user),
448
- author: user.id,
449
- codes: [],
450
- tags: [],
451
- }, c);
442
+ const document = Object.assign(Object.assign({}, (c !== null && c !== void 0 ? c : {})), { _type: 'org.taktik.icure.entities.Document', id: (_a = c === null || c === void 0 ? void 0 : c.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = c === null || c === void 0 ? void 0 : c.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = c === null || c === void 0 ? void 0 : c.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = c === null || c === void 0 ? void 0 : c.responsible) !== null && _d !== void 0 ? _d : this.dataOwnerApi.getDataOwnerIdOf(user), author: (_e = c === null || c === void 0 ? void 0 : c.author) !== null && _e !== void 0 ? _e : user.id, codes: (_f = c === null || c === void 0 ? void 0 : c.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = c === null || c === void 0 ? void 0 : c.tags) !== null && _g !== void 0 ? _g : [] });
452
443
  const ownerId = this.dataOwnerApi.getDataOwnerIdOf(user);
453
444
  if (ownerId !== (yield this.dataOwnerApi.getCurrentDataOwnerId()))
454
445
  throw new Error('Can only initialise entities as current data owner.');
455
- const sfk = message ? (_a = options.preferredSfk) !== null && _a !== void 0 ? _a : (yield this.crypto.confidential.getAnySecretIdSharedWithParents(message)) : undefined;
446
+ const sfk = message ? (_h = options.preferredSfk) !== null && _h !== void 0 ? _h : (yield this.crypto.confidential.getAnySecretIdSharedWithParents(message)) : undefined;
456
447
  if (message && !sfk)
457
448
  throw new Error(`Couldn't find any sfk of parent message ${message.id}`);
458
449
  const extraDelegations = [
459
- ...Object.keys((_b = options.additionalDelegates) !== null && _b !== void 0 ? _b : {}),
460
- ...((_d = (_c = user.autoDelegations) === null || _c === void 0 ? void 0 : _c.all) !== null && _d !== void 0 ? _d : []),
461
- ...((_f = (_e = user.autoDelegations) === null || _e === void 0 ? void 0 : _e.medicalInformation) !== null && _f !== void 0 ? _f : []),
450
+ ...Object.keys((_j = options.additionalDelegates) !== null && _j !== void 0 ? _j : {}),
451
+ ...((_l = (_k = user.autoDelegations) === null || _k === void 0 ? void 0 : _k.all) !== null && _l !== void 0 ? _l : []),
452
+ ...((_o = (_m = user.autoDelegations) === null || _m === void 0 ? void 0 : _m.medicalInformation) !== null && _o !== void 0 ? _o : []),
462
453
  ];
463
454
  return new models.Document(yield this.crypto.entities
464
455
  .entityWithInitialisedEncryptedMetadata(document, message === null || message === void 0 ? void 0 : message.id, sfk, true, extraDelegations)
@@ -555,23 +546,27 @@ class IccDocumentXApi extends icc_api_1.IccDocumentApi {
555
546
  * Adds an attachment to a document, encrypting it on client side using the encryption keys of the provided document.
556
547
  * @param document a document.
557
548
  * @param attachment a new main attachment for the document.
549
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
550
+ * overrides existing values.
558
551
  * @return the updated document.
559
552
  */
560
- encryptAndSetDocumentAttachment(document, attachment) {
553
+ encryptAndSetDocumentAttachment(document, attachment, utis) {
561
554
  return __awaiter(this, void 0, void 0, function* () {
562
555
  const encryptedData = yield this.crypto.entities.encryptDataOf(document, attachment);
563
- return yield this.setDocumentAttachment(document.id, undefined, encryptedData);
556
+ return yield this.setDocumentAttachment(document.id, undefined, encryptedData, utis);
564
557
  });
565
558
  }
566
559
  /**
567
560
  * Adds an unencrypted attachment to a document.
568
561
  * @param document a document.
569
562
  * @param attachment a new main attachment for the document.
563
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
564
+ * overrides existing values.
570
565
  * @return the updated document.
571
566
  */
572
- setClearDocumentAttachment(document, attachment) {
567
+ setClearDocumentAttachment(document, attachment, utis) {
573
568
  return __awaiter(this, void 0, void 0, function* () {
574
- return yield this.setDocumentAttachment(document.id, undefined, attachment);
569
+ return yield this.setDocumentAttachment(document.id, undefined, attachment, utis);
575
570
  });
576
571
  }
577
572
  /**
@@ -579,12 +574,14 @@ class IccDocumentXApi extends icc_api_1.IccDocumentApi {
579
574
  * @param document a document.
580
575
  * @param secondaryAttachmentKey key for the secondary attachment.
581
576
  * @param attachment a new secondary attachment for the document.
577
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
578
+ * overrides existing values.
582
579
  * @return the updated document.
583
580
  */
584
- encryptAndSetSecondaryDocumentAttachment(document, secondaryAttachmentKey, attachment) {
581
+ encryptAndSetSecondaryDocumentAttachment(document, secondaryAttachmentKey, attachment, utis) {
585
582
  return __awaiter(this, void 0, void 0, function* () {
586
583
  const encryptedData = yield this.crypto.entities.encryptDataOf(document, attachment);
587
- return yield this.setSecondaryAttachment(document.id, secondaryAttachmentKey, document.rev, encryptedData);
584
+ return yield this.setSecondaryAttachment(document.id, secondaryAttachmentKey, document.rev, encryptedData, utis);
588
585
  });
589
586
  }
590
587
  /**
@@ -592,11 +589,13 @@ class IccDocumentXApi extends icc_api_1.IccDocumentApi {
592
589
  * @param document a document.
593
590
  * @param secondaryAttachmentKey key for the secondary attachment.
594
591
  * @param attachment a new secondary attachment for the document.
592
+ * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
593
+ * overrides existing values.
595
594
  * @return the updated document.
596
595
  */
597
- setClearSecondaryDocumentAttachment(document, secondaryAttachmentKey, attachment) {
596
+ setClearSecondaryDocumentAttachment(document, secondaryAttachmentKey, attachment, utis) {
598
597
  return __awaiter(this, void 0, void 0, function* () {
599
- return yield this.setSecondaryAttachment(document.id, secondaryAttachmentKey, document.rev, attachment);
598
+ return yield this.setSecondaryAttachment(document.id, secondaryAttachmentKey, document.rev, attachment, utis);
600
599
  });
601
600
  }
602
601
  /**