@icure/api 8.2.8 → 8.3.1
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/icc-api/api/IccUserApi.d.ts +1 -0
- package/icc-api/api/IccUserApi.js +10 -0
- package/icc-api/api/IccUserApi.js.map +1 -1
- package/icc-api/model/TimeTable.d.ts +0 -29
- package/icc-api/model/TimeTable.js.map +1 -1
- package/icc-x-api/icc-accesslog-x-api.js +4 -4
- package/icc-x-api/icc-accesslog-x-api.js.map +1 -1
- package/icc-x-api/icc-classification-x-api.js +2 -2
- package/icc-x-api/icc-classification-x-api.js.map +1 -1
- package/icc-x-api/icc-document-x-api.js +2 -2
- package/icc-x-api/icc-document-x-api.js.map +1 -1
- package/icc-x-api/icc-form-x-api.js +2 -2
- package/icc-x-api/icc-form-x-api.js.map +1 -1
- package/icc-x-api/icc-invoice-x-api.js +2 -2
- package/icc-x-api/icc-invoice-x-api.js.map +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js +1 -1
- package/icc-x-api/icc-maintenance-task-x-api.js.map +1 -1
- package/icc-x-api/icc-patient-x-api.js +2 -2
- package/icc-x-api/icc-patient-x-api.js.map +1 -1
- package/icc-x-api/icc-receipt-x-api.js +2 -2
- package/icc-x-api/icc-receipt-x-api.js.map +1 -1
- package/icc-x-api/icc-topic-x-api.js +1 -1
- package/icc-x-api/icc-topic-x-api.js.map +1 -1
- package/icc-x-api/index.d.ts +2 -4
- package/icc-x-api/index.js +1 -3
- package/icc-x-api/index.js.map +1 -1
- package/package.json +1 -1
- package/test/icc-x-api/crud/entities-crud-test-interface.js +4 -11
- package/test/icc-x-api/crud/entities-crud-test-interface.js.map +1 -1
- package/test/icc-x-api/icc-helement-x-api-test.js +1 -1
- package/test/icc-x-api/icc-helement-x-api-test.js.map +1 -1
- package/test/icc-x-api/icc-time-table-x-api.js +2 -20
- package/test/icc-x-api/icc-time-table-x-api.js.map +1 -1
- package/icc-x-api/icc-time-table-x-api.d.ts +0 -115
- package/icc-x-api/icc-time-table-x-api.js +0 -150
- package/icc-x-api/icc-time-table-x-api.js.map +0 -1
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.IccTimeTableXApi = void 0;
|
|
13
|
-
const i18n = require("./rsrc/contact.i18n");
|
|
14
|
-
const icc_api_1 = require("../icc-api");
|
|
15
|
-
const models = require("../icc-api/model/models");
|
|
16
|
-
const AuthenticationProvider_1 = require("./auth/AuthenticationProvider");
|
|
17
|
-
const ShareMetadataBehaviour_1 = require("./crypto/ShareMetadataBehaviour");
|
|
18
|
-
const SecureDelegation_1 = require("../icc-api/model/SecureDelegation");
|
|
19
|
-
var AccessLevelEnum = SecureDelegation_1.SecureDelegation.AccessLevelEnum;
|
|
20
|
-
const utils_1 = require("./utils");
|
|
21
|
-
class IccTimeTableXApi extends icc_api_1.IccTimeTableApi {
|
|
22
|
-
get headers() {
|
|
23
|
-
return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, utils_1.EntityWithDelegationTypeName.TimeTable));
|
|
24
|
-
}
|
|
25
|
-
constructor(host, headers, crypto, dataOwnerApi, autofillAuthor, authenticationProvider = new AuthenticationProvider_1.NoAuthenticationProvider(), fetchImpl = typeof window !== 'undefined'
|
|
26
|
-
? window.fetch
|
|
27
|
-
: typeof self !== 'undefined'
|
|
28
|
-
? self.fetch
|
|
29
|
-
: fetch) {
|
|
30
|
-
super(host, headers, authenticationProvider, fetchImpl);
|
|
31
|
-
this.crypto = crypto;
|
|
32
|
-
this.dataOwnerApi = dataOwnerApi;
|
|
33
|
-
this.autofillAuthor = autofillAuthor;
|
|
34
|
-
this.i18n = i18n;
|
|
35
|
-
this.crypto = crypto;
|
|
36
|
-
this.dataOwnerApi = dataOwnerApi;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new instance of timetable with initialised encryption metadata (not in the database).
|
|
40
|
-
* @param user the current user.
|
|
41
|
-
* @param tt initialised data for the timetable. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
|
|
42
|
-
* other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
|
|
43
|
-
* @param options optional parameters:
|
|
44
|
-
* - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
|
|
45
|
-
* auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
|
|
46
|
-
* auto-delegations, in such case the access level specified here will be used.
|
|
47
|
-
* - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates
|
|
48
|
-
* - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,
|
|
49
|
-
* and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
|
|
50
|
-
* @return a new instance of timetable.
|
|
51
|
-
*/
|
|
52
|
-
newInstance(user_1, tt_1) {
|
|
53
|
-
return __awaiter(this, arguments, void 0, function* (user, tt, options = {}) {
|
|
54
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
55
|
-
const timeTable = Object.assign(Object.assign({}, (tt !== null && tt !== void 0 ? tt : {})), { id: (_a = tt === null || tt === void 0 ? void 0 : tt.id) !== null && _a !== void 0 ? _a : this.crypto.primitives.randomUuid(), created: (_b = tt === null || tt === void 0 ? void 0 : tt.created) !== null && _b !== void 0 ? _b : new Date().getTime(), modified: (_c = tt === null || tt === void 0 ? void 0 : tt.modified) !== null && _c !== void 0 ? _c : new Date().getTime(), responsible: (_d = tt === null || tt === void 0 ? void 0 : tt.responsible) !== null && _d !== void 0 ? _d : (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined), author: (_e = tt === null || tt === void 0 ? void 0 : tt.author) !== null && _e !== void 0 ? _e : (this.autofillAuthor ? user.id : undefined), codes: (_f = tt === null || tt === void 0 ? void 0 : tt.codes) !== null && _f !== void 0 ? _f : [], tags: (_g = tt === null || tt === void 0 ? void 0 : tt.tags) !== null && _g !== void 0 ? _g : [] });
|
|
56
|
-
const extraDelegations = Object.assign(Object.assign({}, (options.ignoreAutoDelegations == true
|
|
57
|
-
? Object.fromEntries([...((_j = (_h = user.autoDelegations) === null || _h === void 0 ? void 0 : _h.all) !== null && _j !== void 0 ? _j : []), ...((_l = (_k = user.autoDelegations) === null || _k === void 0 ? void 0 : _k.administrativeData) !== null && _l !== void 0 ? _l : [])].map((d) => [d, AccessLevelEnum.WRITE]))
|
|
58
|
-
: {})), ((_m = options === null || options === void 0 ? void 0 : options.additionalDelegates) !== null && _m !== void 0 ? _m : {}));
|
|
59
|
-
return new models.TimeTable(yield this.crypto.xapi
|
|
60
|
-
.entityWithInitialisedEncryptedMetadata(timeTable, utils_1.EntityWithDelegationTypeName.TimeTable, undefined, undefined, true, extraDelegations, options.alternateRootDelegation)
|
|
61
|
-
.then((x) => x.updatedEntity));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @return if the logged data owner has write access to the content of the given time table
|
|
66
|
-
*/
|
|
67
|
-
hasWriteAccess(timeTable) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
return this.crypto.xapi.hasWriteAccess({ entity: timeTable, type: utils_1.EntityWithDelegationTypeName.TimeTable });
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
74
|
-
* the encrypted content, with read-only or read-write permissions.
|
|
75
|
-
* @param delegateId the id of the data owner which will be granted access to the time table.
|
|
76
|
-
* @param timeTable the time table to share.
|
|
77
|
-
* @param options optional parameters to customize the sharing behaviour:
|
|
78
|
-
* - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared
|
|
79
|
-
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
80
|
-
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
81
|
-
* time table does not have encrypted content.
|
|
82
|
-
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
83
|
-
* @return the updated entity
|
|
84
|
-
*/
|
|
85
|
-
shareWith(delegateId_1, timeTable_1) {
|
|
86
|
-
return __awaiter(this, arguments, void 0, function* (delegateId, timeTable, options = {}) {
|
|
87
|
-
return this.shareWithMany(timeTable, { [delegateId]: options });
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
92
|
-
* the encrypted content, with read-only or read-write permissions.
|
|
93
|
-
* @param timeTable the time table to share.
|
|
94
|
-
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
95
|
-
* - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared
|
|
96
|
-
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
97
|
-
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
98
|
-
* time table does not have encrypted content.
|
|
99
|
-
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
100
|
-
* @return the updated entity
|
|
101
|
-
*/
|
|
102
|
-
shareWithMany(timeTable, delegates) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
return (yield this.tryShareWithMany(timeTable, delegates)).updatedEntityOrThrow;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also
|
|
109
|
-
* the encrypted content, with read-only or read-write permissions.
|
|
110
|
-
* @param timeTable the time table to share.
|
|
111
|
-
* @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
|
|
112
|
-
* - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared
|
|
113
|
-
* - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
|
|
114
|
-
* content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
|
|
115
|
-
* time table does not have encrypted content.
|
|
116
|
-
* - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
|
|
117
|
-
* @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if
|
|
118
|
-
* the operation failed.
|
|
119
|
-
*/
|
|
120
|
-
tryShareWithMany(timeTable, delegates) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
// All entities should have an encryption key.
|
|
123
|
-
const entityWithEncryptionKey = yield this.crypto.xapi.ensureEncryptionKeysInitialised(timeTable, utils_1.EntityWithDelegationTypeName.TimeTable);
|
|
124
|
-
const updatedEntity = entityWithEncryptionKey ? yield this.modifyTimeTable(entityWithEncryptionKey) : timeTable;
|
|
125
|
-
return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata({
|
|
126
|
-
entity: updatedEntity,
|
|
127
|
-
type: utils_1.EntityWithDelegationTypeName.TimeTable,
|
|
128
|
-
}, Object.fromEntries(Object.entries(delegates).map(([delegateId, options]) => [
|
|
129
|
-
delegateId,
|
|
130
|
-
{
|
|
131
|
-
requestedPermissions: options.requestedPermissions,
|
|
132
|
-
shareEncryptionKeys: options.shareEncryptionKey,
|
|
133
|
-
shareOwningEntityIds: ShareMetadataBehaviour_1.ShareMetadataBehaviour.NEVER,
|
|
134
|
-
shareSecretIds: options.shareSecretIds,
|
|
135
|
-
},
|
|
136
|
-
])), (x) => this.bulkShareTimeTable(x));
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
getDataOwnersWithAccessTo(entity) {
|
|
140
|
-
return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: utils_1.EntityWithDelegationTypeName.TimeTable });
|
|
141
|
-
}
|
|
142
|
-
getEncryptionKeysOf(entity) {
|
|
143
|
-
return this.crypto.xapi.encryptionKeysOf({ entity, type: utils_1.EntityWithDelegationTypeName.TimeTable }, undefined);
|
|
144
|
-
}
|
|
145
|
-
createDelegationDeAnonymizationMetadata(entity, delegates) {
|
|
146
|
-
return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo({ entity, type: utils_1.EntityWithDelegationTypeName.TimeTable }, delegates);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
exports.IccTimeTableXApi = IccTimeTableXApi;
|
|
150
|
-
//# sourceMappingURL=icc-time-table-x-api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icc-time-table-x-api.js","sourceRoot":"","sources":["../../icc-x-api/icc-time-table-x-api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA2C;AAG3C,wCAA4C;AAK5C,kDAAiD;AACjD,0EAAgG;AAChG,4EAAwE;AAIxE,wEAAoE;AACpE,IAAO,eAAe,GAAG,mCAAgB,CAAC,eAAe,CAAA;AAIzD,mCAAsD;AAEtD,MAAa,gBAAiB,SAAQ,yBAAe;IAGnD,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M,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;gBACvD,UAAU;gBACV;oBACE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;oBAClD,mBAAmB,EAAE,OAAO,CAAC,kBAAkB;oBAC/C,oBAAoB,EAAE,+CAAsB,CAAC,KAAK;oBAClD,cAAc,EAAE,OAAO,CAAC,cAAc;iBACvC;aACF,CAAC,CACH,EACD,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAClC,CAAA;QACH,CAAC;KAAA;IAED,yBAAyB,CACvB,MAAwB;QAExB,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,yBAAyB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,SAAS,EAAE,CAAC,CAAA;IACnI,CAAC;IAED,mBAAmB,CAAC,MAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAA;IAC/G,CAAC;IAED,uCAAuC,CAAC,MAAwB,EAAE,SAAmB;QACnF,OAAO,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,iCAAiC,CAC7E,EAAE,MAAM,EAAE,IAAI,EAAE,oCAA4B,CAAC,SAAS,EAAE,EACxD,SAAS,CACV,CAAA;IACH,CAAC;CACF;AA1MD,4CA0MC","sourcesContent":["import * as i18n from './rsrc/contact.i18n'\n\nimport * as _ from 'lodash'\nimport { IccTimeTableApi } from '../icc-api'\nimport { User } from '../icc-api/model/User'\nimport { TimeTable } from '../icc-api/model/TimeTable'\nimport { IccCryptoXApi } from './icc-crypto-x-api'\nimport { IccDataOwnerXApi } from './icc-data-owner-x-api'\nimport * as models from '../icc-api/model/models'\nimport { AuthenticationProvider, NoAuthenticationProvider } from './auth/AuthenticationProvider'\nimport { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour'\nimport { ShareResult } from './utils/ShareResult'\nimport { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest'\nimport RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum\nimport { SecureDelegation } from '../icc-api/model/SecureDelegation'\nimport AccessLevelEnum = SecureDelegation.AccessLevelEnum\nimport { XHR } from '../icc-api/api/XHR'\nimport { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi'\nimport { MaintenanceTask } from '../icc-api/model/models'\nimport { EntityWithDelegationTypeName } from './utils'\n\nexport class IccTimeTableXApi extends IccTimeTableApi implements EncryptedEntityXApi<models.TimeTable> {\n i18n: any = i18n\n\n get headers(): Promise<Array<XHR.Header>> {\n return super.headers.then((h) => this.crypto.accessControlKeysHeaders.addAccessControlKeysHeaders(h, EntityWithDelegationTypeName.TimeTable))\n }\n\n constructor(\n host: string,\n headers: { [key: string]: string },\n private readonly crypto: IccCryptoXApi,\n private readonly dataOwnerApi: IccDataOwnerXApi,\n private readonly autofillAuthor: boolean,\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.dataOwnerApi = dataOwnerApi\n }\n\n /**\n * Creates a new instance of timetable with initialised encryption metadata (not in the database).\n * @param user the current user.\n * @param tt initialised data for the timetable. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify\n * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.\n * @param options optional parameters:\n * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the\n * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with\n * auto-delegations, in such case the access level specified here will be used.\n * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates\n * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,\n * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.\n * @return a new instance of timetable.\n */\n async newInstance(\n user: User,\n tt: TimeTable,\n options: {\n additionalDelegates?: { [dataOwnerId: string]: AccessLevelEnum }\n ignoreAutoDelegations?: boolean\n alternateRootDelegation?: string\n } = {}\n ) {\n const timeTable: TimeTable = {\n ...(tt ?? {}),\n id: tt?.id ?? this.crypto.primitives.randomUuid(),\n created: tt?.created ?? new Date().getTime(),\n modified: tt?.modified ?? new Date().getTime(),\n responsible: tt?.responsible ?? (this.autofillAuthor ? this.dataOwnerApi.getDataOwnerIdOf(user) : undefined),\n author: tt?.author ?? (this.autofillAuthor ? user.id : undefined),\n codes: tt?.codes ?? [],\n tags: tt?.tags ?? [],\n }\n\n const extraDelegations = {\n ...(options.ignoreAutoDelegations == true\n ? Object.fromEntries(\n [...(user.autoDelegations?.all ?? []), ...(user.autoDelegations?.administrativeData ?? [])].map((d) => [d, AccessLevelEnum.WRITE])\n )\n : {}),\n ...(options?.additionalDelegates ?? {}),\n }\n\n return new models.TimeTable(\n await this.crypto.xapi\n .entityWithInitialisedEncryptedMetadata(\n timeTable,\n EntityWithDelegationTypeName.TimeTable,\n undefined,\n undefined,\n true,\n extraDelegations,\n options.alternateRootDelegation\n )\n .then((x) => x.updatedEntity)\n )\n }\n\n /**\n * @return if the logged data owner has write access to the content of the given time table\n */\n async hasWriteAccess(timeTable: models.TimeTable): Promise<boolean> {\n return this.crypto.xapi.hasWriteAccess({ entity: timeTable, type: EntityWithDelegationTypeName.TimeTable })\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param delegateId the id of the data owner which will be granted access to the time table.\n * @param timeTable the time table to share.\n * @param options optional parameters to customize the sharing behaviour:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWith(\n delegateId: string,\n timeTable: models.TimeTable,\n options: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n } = {}\n ): Promise<models.TimeTable> {\n return this.shareWithMany(timeTable, { [delegateId]: options })\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param timeTable the time table to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return the updated entity\n */\n async shareWithMany(\n timeTable: models.TimeTable,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<models.TimeTable> {\n return (await this.tryShareWithMany(timeTable, delegates)).updatedEntityOrThrow\n }\n\n /**\n * Share an existing time table with other data owners, allowing them to access the non-encrypted data of the time table and optionally also\n * the encrypted content, with read-only or read-write permissions.\n * @param timeTable the time table to share.\n * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:\n * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared\n * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted\n * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a\n * time table does not have encrypted content.\n * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.\n * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if\n * the operation failed.\n */\n async tryShareWithMany(\n timeTable: models.TimeTable,\n delegates: {\n [delegateId: string]: {\n shareSecretIds?: string[]\n requestedPermissions?: RequestedPermissionEnum\n shareEncryptionKey?: ShareMetadataBehaviour // Defaults to ShareMetadataBehaviour.IF_AVAILABLE\n }\n }\n ): Promise<ShareResult<models.TimeTable>> {\n // All entities should have an encryption key.\n const entityWithEncryptionKey = await this.crypto.xapi.ensureEncryptionKeysInitialised(timeTable, EntityWithDelegationTypeName.TimeTable)\n const updatedEntity = entityWithEncryptionKey ? await this.modifyTimeTable(entityWithEncryptionKey) : timeTable\n return this.crypto.xapi.simpleShareOrUpdateEncryptedEntityMetadata(\n {\n entity: updatedEntity,\n type: EntityWithDelegationTypeName.TimeTable,\n },\n Object.fromEntries(\n Object.entries(delegates).map(([delegateId, options]) => [\n delegateId,\n {\n requestedPermissions: options.requestedPermissions,\n shareEncryptionKeys: options.shareEncryptionKey,\n shareOwningEntityIds: ShareMetadataBehaviour.NEVER,\n shareSecretIds: options.shareSecretIds,\n },\n ])\n ),\n (x) => this.bulkShareTimeTable(x)\n )\n }\n\n getDataOwnersWithAccessTo(\n entity: models.TimeTable\n ): Promise<{ permissionsByDataOwnerId: { [p: string]: AccessLevelEnum }; hasUnknownAnonymousDataOwners: boolean }> {\n return this.crypto.delegationsDeAnonymization.getDataOwnersWithAccessTo({ entity, type: EntityWithDelegationTypeName.TimeTable })\n }\n\n getEncryptionKeysOf(entity: models.TimeTable): Promise<string[]> {\n return this.crypto.xapi.encryptionKeysOf({ entity, type: EntityWithDelegationTypeName.TimeTable }, undefined)\n }\n\n createDelegationDeAnonymizationMetadata(entity: models.TimeTable, delegates: string[]): Promise<void> {\n return this.crypto.delegationsDeAnonymization.createOrUpdateDeAnonymizationInfo(\n { entity, type: EntityWithDelegationTypeName.TimeTable },\n delegates\n )\n }\n}\n"]}
|