@valtimo/resource 0.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.
- package/README.md +31 -0
- package/fesm2022/valtimo-resource.mjs +674 -0
- package/fesm2022/valtimo-resource.mjs.map +1 -0
- package/index.d.ts +6 -0
- package/lib/models/index.d.ts +4 -0
- package/lib/models/index.d.ts.map +1 -0
- package/lib/models/open-zaak.model.d.ts +137 -0
- package/lib/models/open-zaak.model.d.ts.map +1 -0
- package/lib/models/upload.model.d.ts +41 -0
- package/lib/models/upload.model.d.ts.map +1 -0
- package/lib/models/uploader.model.d.ts +32 -0
- package/lib/models/uploader.model.d.ts.map +1 -0
- package/lib/resource-permissions.d.ts +12 -0
- package/lib/resource-permissions.d.ts.map +1 -0
- package/lib/resource.module.d.ts +7 -0
- package/lib/resource.module.d.ts.map +1 -0
- package/lib/services/download.service.d.ts +20 -0
- package/lib/services/download.service.d.ts.map +1 -0
- package/lib/services/open-zaak-upload.service.d.ts +26 -0
- package/lib/services/open-zaak-upload.service.d.ts.map +1 -0
- package/lib/services/open-zaak.service.d.ts +33 -0
- package/lib/services/open-zaak.service.d.ts.map +1 -0
- package/lib/services/s3-upload.service.d.ts +14 -0
- package/lib/services/s3-upload.service.d.ts.map +1 -0
- package/lib/services/s3.service.d.ts +19 -0
- package/lib/services/s3.service.d.ts.map +1 -0
- package/lib/services/upload-provider.service.d.ts +25 -0
- package/lib/services/upload-provider.service.d.ts.map +1 -0
- package/package.json +24 -0
- package/public-api.d.ts +8 -0
- package/public-api.d.ts.map +1 -0
- package/valtimo-resource.d.ts.map +1 -0
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, NgModule } from '@angular/core';
|
|
3
|
+
import { map, tap, switchMap } from 'rxjs/operators';
|
|
4
|
+
import * as i1 from '@angular/common/http';
|
|
5
|
+
import { HttpHeaders } from '@angular/common/http';
|
|
6
|
+
import * as i2 from '@valtimo/shared';
|
|
7
|
+
import { UploadProvider } from '@valtimo/shared';
|
|
8
|
+
import { v4 } from 'uuid';
|
|
9
|
+
import { of, Subject } from 'rxjs';
|
|
10
|
+
import * as i2$1 from 'ngx-logger';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
14
|
+
*
|
|
15
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
30
|
+
*
|
|
31
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
32
|
+
* you may not use this file except in compliance with the License.
|
|
33
|
+
* You may obtain a copy of the License at
|
|
34
|
+
*
|
|
35
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
36
|
+
*
|
|
37
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
39
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
+
* See the License for the specific language governing permissions and
|
|
41
|
+
* limitations under the License.
|
|
42
|
+
*/
|
|
43
|
+
class S3Resource {
|
|
44
|
+
constructor(file, preSignedUrl, documentId) {
|
|
45
|
+
this.id = null;
|
|
46
|
+
this.extension = null;
|
|
47
|
+
this.createdOn = null;
|
|
48
|
+
this.key = decodeURIComponent(preSignedUrl.pathname.substring(1));
|
|
49
|
+
this.name = file.name;
|
|
50
|
+
this.sizeInBytes = file.size;
|
|
51
|
+
if (!documentId) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.documentId = documentId;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
60
|
+
*
|
|
61
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
62
|
+
* you may not use this file except in compliance with the License.
|
|
63
|
+
* You may obtain a copy of the License at
|
|
64
|
+
*
|
|
65
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
66
|
+
*
|
|
67
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
68
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
69
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
70
|
+
* See the License for the specific language governing permissions and
|
|
71
|
+
* limitations under the License.
|
|
72
|
+
*/
|
|
73
|
+
class OpenZaakConfig {
|
|
74
|
+
}
|
|
75
|
+
var Archiefnominatie;
|
|
76
|
+
(function (Archiefnominatie) {
|
|
77
|
+
Archiefnominatie["blijvend_bewaren"] = "blijven_bewaren";
|
|
78
|
+
Archiefnominatie["vernietigen"] = "vernietigen";
|
|
79
|
+
})(Archiefnominatie || (Archiefnominatie = {}));
|
|
80
|
+
var Afleidingswijze;
|
|
81
|
+
(function (Afleidingswijze) {
|
|
82
|
+
Afleidingswijze["afgehandeld"] = "afgehandeld";
|
|
83
|
+
Afleidingswijze["ander_datumkenmerk"] = "ander_datumkenmerk";
|
|
84
|
+
Afleidingswijze["eigenschap"] = "eigenschap";
|
|
85
|
+
Afleidingswijze["gerelateerde_zaak"] = "gerelateerde_zaak";
|
|
86
|
+
Afleidingswijze["hoofdzaak"] = "hoofdzaak";
|
|
87
|
+
Afleidingswijze["ingangsdatum_besluit"] = "ingangsdatum_besluit";
|
|
88
|
+
Afleidingswijze["termijn"] = "termijn";
|
|
89
|
+
Afleidingswijze["vervaldatum_besluit"] = "vervaldatum_besluit";
|
|
90
|
+
Afleidingswijze["zaakobject"] = "zaakobject";
|
|
91
|
+
})(Afleidingswijze || (Afleidingswijze = {}));
|
|
92
|
+
var Objecttype;
|
|
93
|
+
(function (Objecttype) {
|
|
94
|
+
Objecttype["adres"] = "adres";
|
|
95
|
+
Objecttype["besluit"] = "besluit";
|
|
96
|
+
Objecttype["buurt"] = "buurt";
|
|
97
|
+
Objecttype["enkelvoudig_document"] = "enkelvoudig_document";
|
|
98
|
+
Objecttype["gemeente"] = "gemeente";
|
|
99
|
+
Objecttype["gemeentelijke_openbare_ruimte"] = "gemeentelijke_openbare_ruimte";
|
|
100
|
+
Objecttype["huishouden"] = "huishouden";
|
|
101
|
+
Objecttype["inrichtingselement"] = "inrichtingselement";
|
|
102
|
+
Objecttype["kadastrale_onroerende_zaak"] = "kadastrale_onroerende_zaak";
|
|
103
|
+
Objecttype["kunstwerkdeel"] = "kunstwerkdeel";
|
|
104
|
+
Objecttype["maatschappelijke_activiteit"] = "maatschappelijke_activiteit";
|
|
105
|
+
Objecttype["medewerker"] = "medewerker";
|
|
106
|
+
Objecttype["natuurlijk_persoon"] = "natuurlijk_persoon";
|
|
107
|
+
Objecttype["niet_natuurlijk_persoon"] = "niet_natuurlijk_persoon";
|
|
108
|
+
Objecttype["openbare_ruimte"] = "openbare_ruimte";
|
|
109
|
+
Objecttype["organisatorische_eenheid"] = "organisatorische_eenheid";
|
|
110
|
+
Objecttype["pand"] = "pand";
|
|
111
|
+
Objecttype["spoorbaandeel"] = "spoorbaandeel";
|
|
112
|
+
Objecttype["status"] = "status";
|
|
113
|
+
Objecttype["terreindeel"] = "terreindeel";
|
|
114
|
+
Objecttype["terrein_gebouwd_object"] = "terrein_gebouwd_object";
|
|
115
|
+
Objecttype["vestiging"] = "vestiging";
|
|
116
|
+
Objecttype["waterdeel"] = "waterdeel";
|
|
117
|
+
Objecttype["wegdeel"] = "wegdeel";
|
|
118
|
+
Objecttype["wijk"] = "wijk";
|
|
119
|
+
Objecttype["woonplaats"] = "woonplaats";
|
|
120
|
+
Objecttype["woz_deelobject"] = "woz_deelobject";
|
|
121
|
+
Objecttype["woz_object"] = "woz_object";
|
|
122
|
+
Objecttype["woz_waarde"] = "woz_waarde";
|
|
123
|
+
Objecttype["zakelijk_recht"] = "zakelijk_recht";
|
|
124
|
+
Objecttype["overige"] = "overige";
|
|
125
|
+
})(Objecttype || (Objecttype = {}));
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
129
|
+
*
|
|
130
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
131
|
+
* you may not use this file except in compliance with the License.
|
|
132
|
+
* You may obtain a copy of the License at
|
|
133
|
+
*
|
|
134
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
135
|
+
*
|
|
136
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
137
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
138
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
139
|
+
* See the License for the specific language governing permissions and
|
|
140
|
+
* limitations under the License.
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
145
|
+
*
|
|
146
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
147
|
+
* you may not use this file except in compliance with the License.
|
|
148
|
+
* You may obtain a copy of the License at
|
|
149
|
+
*
|
|
150
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
151
|
+
*
|
|
152
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
153
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
154
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
155
|
+
* See the License for the specific language governing permissions and
|
|
156
|
+
* limitations under the License.
|
|
157
|
+
*/
|
|
158
|
+
class OpenZaakService {
|
|
159
|
+
constructor(http, configService) {
|
|
160
|
+
this.http = http;
|
|
161
|
+
this.configService = configService;
|
|
162
|
+
this.valtimoApiConfig = this.configService.config.valtimoApi;
|
|
163
|
+
this.catalogus = this.configService.config.openZaak.catalogus;
|
|
164
|
+
}
|
|
165
|
+
getOpenZaakConfig() {
|
|
166
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}v1/openzaak/config`);
|
|
167
|
+
}
|
|
168
|
+
getResource(resourceId) {
|
|
169
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}v1/resource/${resourceId}`);
|
|
170
|
+
}
|
|
171
|
+
getZaakTypes() {
|
|
172
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}management/v1/zgw/zaaktype`);
|
|
173
|
+
}
|
|
174
|
+
getBesluittypen() {
|
|
175
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}v1/besluittype`);
|
|
176
|
+
}
|
|
177
|
+
getInformatieObjectTypes() {
|
|
178
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}v1/openzaak/informatie-object-typen/${this.catalogus}`);
|
|
179
|
+
}
|
|
180
|
+
getZaakTypeLink(caseDefinitionKey, caseVersionTag) {
|
|
181
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}management/v1/case-definition/${caseDefinitionKey}/version/${caseVersionTag}/zaak-type-link`);
|
|
182
|
+
}
|
|
183
|
+
createZaakTypeLink(request) {
|
|
184
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}management/v1/case-definition/${request.caseDefinitionKey}/version/${request.caseVersionTag}/zaak-type-link`, request);
|
|
185
|
+
}
|
|
186
|
+
deleteZaakTypeLink(caseDefinitionKey, caseVersionTag) {
|
|
187
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}management/v1/case-definition/${caseDefinitionKey}/version/${caseVersionTag}/zaak-type-link`);
|
|
188
|
+
}
|
|
189
|
+
getZaakTypeLinkListByProcess(processDefinitionKey) {
|
|
190
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}management/v1/zaak-type-link/process/${processDefinitionKey}`);
|
|
191
|
+
}
|
|
192
|
+
getStatusTypes(zaakTypeRequest) {
|
|
193
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}v1/openzaak/status`, zaakTypeRequest);
|
|
194
|
+
}
|
|
195
|
+
getStatusResults(zaakTypeRequest) {
|
|
196
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}v1/openzaak/resultaat`, zaakTypeRequest);
|
|
197
|
+
}
|
|
198
|
+
upload(file, documentDefinitionName) {
|
|
199
|
+
const formData = new FormData();
|
|
200
|
+
formData.append('file', file);
|
|
201
|
+
formData.append('documentDefinitionName', documentDefinitionName);
|
|
202
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}v1/resource/upload-open-zaak`, formData, {
|
|
203
|
+
reportProgress: true,
|
|
204
|
+
responseType: 'json',
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
uploadWithMetadata(file, documentId, metadata) {
|
|
208
|
+
const formData = new FormData();
|
|
209
|
+
formData.append('file', file);
|
|
210
|
+
formData.append('documentId', documentId);
|
|
211
|
+
Object.keys(metadata).forEach(metaDataKey => {
|
|
212
|
+
const metadataValue = metadata[metaDataKey];
|
|
213
|
+
if (metadataValue) {
|
|
214
|
+
formData.append(metaDataKey, metadataValue);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}v1/resource/temp`, formData, {
|
|
218
|
+
reportProgress: true,
|
|
219
|
+
responseType: 'json',
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
uploadTempFileWithMetadata(file, metadata) {
|
|
223
|
+
const formData = new FormData();
|
|
224
|
+
formData.append('file', file);
|
|
225
|
+
Object.keys(metadata).forEach(metaDataKey => {
|
|
226
|
+
const metadataValue = metadata[metaDataKey];
|
|
227
|
+
if (metadataValue) {
|
|
228
|
+
formData.append(metaDataKey, metadataValue);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return this.http.post(`${this.valtimoApiConfig.endpointUri}v1/resource/temp`, formData, {
|
|
232
|
+
reportProgress: true,
|
|
233
|
+
responseType: 'json',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: OpenZaakService, deps: [{ token: i1.HttpClient }, { token: i2.ConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
237
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: OpenZaakService, providedIn: 'root' }); }
|
|
238
|
+
}
|
|
239
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: OpenZaakService, decorators: [{
|
|
240
|
+
type: Injectable,
|
|
241
|
+
args: [{
|
|
242
|
+
providedIn: 'root',
|
|
243
|
+
}]
|
|
244
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.ConfigService }] });
|
|
245
|
+
|
|
246
|
+
/*
|
|
247
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
248
|
+
*
|
|
249
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
250
|
+
* you may not use this file except in compliance with the License.
|
|
251
|
+
* You may obtain a copy of the License at
|
|
252
|
+
*
|
|
253
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
254
|
+
*
|
|
255
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
256
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
257
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
258
|
+
* See the License for the specific language governing permissions and
|
|
259
|
+
* limitations under the License.
|
|
260
|
+
*/
|
|
261
|
+
class OpenZaakUploadService {
|
|
262
|
+
constructor(openZaakService, http, configService) {
|
|
263
|
+
this.openZaakService = openZaakService;
|
|
264
|
+
this.http = http;
|
|
265
|
+
this.configService = configService;
|
|
266
|
+
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
267
|
+
}
|
|
268
|
+
uploadFile(file, documentDefinitionName) {
|
|
269
|
+
return this.openZaakService
|
|
270
|
+
.upload(new File([file], file.name, { type: file.type }), documentDefinitionName)
|
|
271
|
+
.pipe(map(result => this.getResourceFile(result)));
|
|
272
|
+
}
|
|
273
|
+
uploadFileWithMetadata(file, documentId, metadata) {
|
|
274
|
+
return this.openZaakService.uploadWithMetadata(new File([file], metadata?.bestandsnaam || file.name, { type: file.type }), documentId, metadata);
|
|
275
|
+
}
|
|
276
|
+
uploadTempFileWithMetadata(file, metadata) {
|
|
277
|
+
return this.openZaakService.uploadTempFileWithMetadata(new File([file], metadata?.bestandsnaam || file.name, { type: file.type }), metadata);
|
|
278
|
+
}
|
|
279
|
+
getResource(resourceId) {
|
|
280
|
+
return this.openZaakService.getResource(resourceId);
|
|
281
|
+
}
|
|
282
|
+
checkUploadProcessLink(caseDefinitionKey) {
|
|
283
|
+
return this.http
|
|
284
|
+
.get(`${this.valtimoApiConfig.endpointUri}v1/uploadprocess/case/${caseDefinitionKey}/check-link`)
|
|
285
|
+
.pipe(map(res => res.processCaseLinkExists));
|
|
286
|
+
}
|
|
287
|
+
getResourceFile(result) {
|
|
288
|
+
return {
|
|
289
|
+
customUpload: true,
|
|
290
|
+
originalName: result.name,
|
|
291
|
+
size: result.sizeInBytes,
|
|
292
|
+
url: '/api/resource/' + result.resourceId + '/download',
|
|
293
|
+
storage: 'openZaak',
|
|
294
|
+
type: result.extension,
|
|
295
|
+
data: {
|
|
296
|
+
createdOn: result.createdOn,
|
|
297
|
+
name: result.name,
|
|
298
|
+
sizeInBytes: result.sizeInBytes,
|
|
299
|
+
resourceId: result.resourceId,
|
|
300
|
+
extension: result.extension,
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: OpenZaakUploadService, deps: [{ token: OpenZaakService }, { token: i1.HttpClient }, { token: i2.ConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
305
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: OpenZaakUploadService }); }
|
|
306
|
+
}
|
|
307
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: OpenZaakUploadService, decorators: [{
|
|
308
|
+
type: Injectable
|
|
309
|
+
}], ctorParameters: () => [{ type: OpenZaakService }, { type: i1.HttpClient }, { type: i2.ConfigService }] });
|
|
310
|
+
|
|
311
|
+
/*
|
|
312
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
313
|
+
*
|
|
314
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
315
|
+
* you may not use this file except in compliance with the License.
|
|
316
|
+
* You may obtain a copy of the License at
|
|
317
|
+
*
|
|
318
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
319
|
+
*
|
|
320
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
321
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
322
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
323
|
+
* See the License for the specific language governing permissions and
|
|
324
|
+
* limitations under the License.
|
|
325
|
+
*/
|
|
326
|
+
class S3Service {
|
|
327
|
+
constructor(http, configService) {
|
|
328
|
+
this.http = http;
|
|
329
|
+
this.configService = configService;
|
|
330
|
+
this.valtimoApiConfig = configService.config.valtimoApi;
|
|
331
|
+
}
|
|
332
|
+
getPreSignedUrl(fileName) {
|
|
333
|
+
const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
|
|
334
|
+
const options = { headers, responseType: 'text' };
|
|
335
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}v1/resource/pre-signed-url/${fileName}`, options);
|
|
336
|
+
}
|
|
337
|
+
upload(url, file) {
|
|
338
|
+
const headers = new HttpHeaders().set('Content-Type', file.type);
|
|
339
|
+
return this.http.put(url.toString(), file, { headers });
|
|
340
|
+
}
|
|
341
|
+
registerResource(s3ResourceDTO) {
|
|
342
|
+
return this.http.put(`${this.valtimoApiConfig.endpointUri}v1/resource`, s3ResourceDTO);
|
|
343
|
+
}
|
|
344
|
+
get(resourceId) {
|
|
345
|
+
const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
|
|
346
|
+
return this.http.get(`${this.valtimoApiConfig.endpointUri}v1/resource/${resourceId}`, { headers });
|
|
347
|
+
}
|
|
348
|
+
delete(resourceId) {
|
|
349
|
+
const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
|
|
350
|
+
return this.http.delete(`${this.valtimoApiConfig.endpointUri}v1/resource/${resourceId}`, {
|
|
351
|
+
headers,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: S3Service, deps: [{ token: i1.HttpClient }, { token: i2.ConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
355
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: S3Service, providedIn: 'root' }); }
|
|
356
|
+
}
|
|
357
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: S3Service, decorators: [{
|
|
358
|
+
type: Injectable,
|
|
359
|
+
args: [{
|
|
360
|
+
providedIn: 'root',
|
|
361
|
+
}]
|
|
362
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.ConfigService }] });
|
|
363
|
+
|
|
364
|
+
class S3UploadService {
|
|
365
|
+
constructor(s3Service) {
|
|
366
|
+
this.s3Service = s3Service;
|
|
367
|
+
}
|
|
368
|
+
uploadFile(file, _, documentId) {
|
|
369
|
+
let resourceUrl;
|
|
370
|
+
const fileName = file.name;
|
|
371
|
+
const splitFileName = fileName.split('.');
|
|
372
|
+
const fileNameWithUUID = `${splitFileName[0]}-${v4()}.${splitFileName[1]}`;
|
|
373
|
+
const renamedFile = new File([file], fileNameWithUUID, { type: file.type });
|
|
374
|
+
return this.s3Service.getPreSignedUrl(renamedFile.name).pipe(map(url => new URL(url)), tap(url => (resourceUrl = url)), switchMap(url => this.s3Service.upload(url, renamedFile)), map(() => new S3Resource(file, resourceUrl, documentId)), switchMap(s3Resource => this.s3Service.registerResource(s3Resource)), switchMap(s3Resource => this.s3Service.get(s3Resource.id)), map(result => ({ ...result, originalName: file.name })), map(result => this.getResourceFile(result)));
|
|
375
|
+
}
|
|
376
|
+
getResource(resourceId) {
|
|
377
|
+
return this.s3Service.get(resourceId);
|
|
378
|
+
}
|
|
379
|
+
getResourceFile(result) {
|
|
380
|
+
return {
|
|
381
|
+
customUpload: true,
|
|
382
|
+
originalName: result.originalName,
|
|
383
|
+
url: result.url,
|
|
384
|
+
size: result.resource.sizeInBytes,
|
|
385
|
+
storage: 'url',
|
|
386
|
+
type: result.resource.extension,
|
|
387
|
+
data: {
|
|
388
|
+
key: result.resource.key,
|
|
389
|
+
bucketName: result.resource.name,
|
|
390
|
+
createdOn: result.resource.createdOn,
|
|
391
|
+
name: result.originalName,
|
|
392
|
+
sizeInBytes: result.resource.sizeInBytes,
|
|
393
|
+
resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1),
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: S3UploadService, deps: [{ token: S3Service }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
398
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: S3UploadService }); }
|
|
399
|
+
}
|
|
400
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: S3UploadService, decorators: [{
|
|
401
|
+
type: Injectable
|
|
402
|
+
}], ctorParameters: () => [{ type: S3Service }] });
|
|
403
|
+
|
|
404
|
+
/*
|
|
405
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
406
|
+
*
|
|
407
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
408
|
+
* you may not use this file except in compliance with the License.
|
|
409
|
+
* You may obtain a copy of the License at
|
|
410
|
+
*
|
|
411
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
412
|
+
*
|
|
413
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
414
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
415
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
416
|
+
* See the License for the specific language governing permissions and
|
|
417
|
+
* limitations under the License.
|
|
418
|
+
*/
|
|
419
|
+
class UploadProviderService {
|
|
420
|
+
constructor(configService, injector, logger) {
|
|
421
|
+
this.configService = configService;
|
|
422
|
+
this.injector = injector;
|
|
423
|
+
this.logger = logger;
|
|
424
|
+
let uploadService;
|
|
425
|
+
switch (configService.config.uploadProvider) {
|
|
426
|
+
case UploadProvider.S3:
|
|
427
|
+
uploadService = injector.get(S3UploadService);
|
|
428
|
+
break;
|
|
429
|
+
case UploadProvider.OPEN_ZAAK:
|
|
430
|
+
uploadService = injector.get(OpenZaakUploadService);
|
|
431
|
+
break;
|
|
432
|
+
case UploadProvider.DOCUMENTEN_API:
|
|
433
|
+
uploadService = injector.get(OpenZaakUploadService);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
this.uploadService = uploadService;
|
|
437
|
+
this.logger.debug('Loading UploadService as', this.uploadService);
|
|
438
|
+
}
|
|
439
|
+
uploadFile(file, documentDefinitionName, documentId) {
|
|
440
|
+
return this.uploadService.uploadFile(file, documentDefinitionName, documentId);
|
|
441
|
+
}
|
|
442
|
+
getResource(resourceId) {
|
|
443
|
+
return this.uploadService.getResource(resourceId);
|
|
444
|
+
}
|
|
445
|
+
checkUploadProcessLink(caseDefinitionKey) {
|
|
446
|
+
if (this.uploadService.checkUploadProcessLink) {
|
|
447
|
+
return this.uploadService.checkUploadProcessLink(caseDefinitionKey);
|
|
448
|
+
}
|
|
449
|
+
return of(false);
|
|
450
|
+
}
|
|
451
|
+
uploadFileWithMetadata(file, documentId, metadata) {
|
|
452
|
+
if (this.uploadService.uploadFileWithMetadata) {
|
|
453
|
+
return this.uploadService.uploadFileWithMetadata(file, documentId, metadata);
|
|
454
|
+
}
|
|
455
|
+
return of(null);
|
|
456
|
+
}
|
|
457
|
+
uploadTempFileWithMetadata(file, metadata) {
|
|
458
|
+
if (this.uploadService.uploadTempFileWithMetadata) {
|
|
459
|
+
return this.uploadService.uploadTempFileWithMetadata(file, metadata);
|
|
460
|
+
}
|
|
461
|
+
return of(null);
|
|
462
|
+
}
|
|
463
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: UploadProviderService, deps: [{ token: i2.ConfigService }, { token: i0.Injector }, { token: i2$1.NGXLogger }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
464
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: UploadProviderService, providedIn: 'root' }); }
|
|
465
|
+
}
|
|
466
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: UploadProviderService, decorators: [{
|
|
467
|
+
type: Injectable,
|
|
468
|
+
args: [{
|
|
469
|
+
providedIn: 'root',
|
|
470
|
+
}]
|
|
471
|
+
}], ctorParameters: () => [{ type: i2.ConfigService }, { type: i0.Injector }, { type: i2$1.NGXLogger }] });
|
|
472
|
+
|
|
473
|
+
/*
|
|
474
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
475
|
+
*
|
|
476
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
477
|
+
* you may not use this file except in compliance with the License.
|
|
478
|
+
* You may obtain a copy of the License at
|
|
479
|
+
*
|
|
480
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
481
|
+
*
|
|
482
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
483
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
484
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
485
|
+
* See the License for the specific language governing permissions and
|
|
486
|
+
* limitations under the License.
|
|
487
|
+
*/
|
|
488
|
+
class DownloadService {
|
|
489
|
+
constructor(http, configService) {
|
|
490
|
+
this.http = http;
|
|
491
|
+
this.configService = configService;
|
|
492
|
+
}
|
|
493
|
+
downloadFile(url, name, forceDownload) {
|
|
494
|
+
const finishedSubject$ = new Subject();
|
|
495
|
+
if (url.startsWith(this.configService.config.valtimoApi.endpointUri) ||
|
|
496
|
+
url.startsWith(window.location.origin) ||
|
|
497
|
+
url.startsWith('/api/')) {
|
|
498
|
+
// if download url is on backend use angular to get the content so access token is used
|
|
499
|
+
this.http.get(url, { responseType: 'blob' }).subscribe(content => {
|
|
500
|
+
const downloadUrl = window.URL.createObjectURL(content);
|
|
501
|
+
if (!this.isFileTypeSupportedForNewWindow(name) || forceDownload) {
|
|
502
|
+
this.openDownloadLink(downloadUrl, name);
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
this.openBlobInNewTab(downloadUrl, name);
|
|
506
|
+
}
|
|
507
|
+
finishedSubject$.next(null);
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
// download links to external services (like amazon s3) open in a new window
|
|
512
|
+
this.openDownloadLink(url, name);
|
|
513
|
+
finishedSubject$.next(null);
|
|
514
|
+
}
|
|
515
|
+
return finishedSubject$;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* A window.open won't work for blobs because ad blocker extensions will immediately
|
|
519
|
+
* close the tab again. The method used below will prevent this from happening.
|
|
520
|
+
*/
|
|
521
|
+
openBlobInNewTab(url, name) {
|
|
522
|
+
const newWindow = window.open('/');
|
|
523
|
+
// newWindow will be null if the browser blocks the opening of a new tab.
|
|
524
|
+
if (newWindow != null) {
|
|
525
|
+
newWindow.location = url;
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
// In case the tab is blocked it will just download the file.
|
|
529
|
+
this.openDownloadLink(url, name);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
openDownloadLink(url, name) {
|
|
533
|
+
const link = document.createElement('a');
|
|
534
|
+
link.href = url;
|
|
535
|
+
link.download = name;
|
|
536
|
+
link.target = '_blank';
|
|
537
|
+
link.click();
|
|
538
|
+
link.remove();
|
|
539
|
+
}
|
|
540
|
+
isFileTypeSupportedForNewWindow(name) {
|
|
541
|
+
const supportedFileTypes = this.configService?.config
|
|
542
|
+
?.supportedDocumentFileTypesToViewInBrowser || ['pdf', 'jpg', 'png', 'svg'];
|
|
543
|
+
return supportedFileTypes.some(function (suffix) {
|
|
544
|
+
return name.toUpperCase().endsWith(suffix.toUpperCase());
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: DownloadService, deps: [{ token: i1.HttpClient }, { token: i2.ConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
548
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: DownloadService, providedIn: 'root' }); }
|
|
549
|
+
}
|
|
550
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: DownloadService, decorators: [{
|
|
551
|
+
type: Injectable,
|
|
552
|
+
args: [{
|
|
553
|
+
providedIn: 'root',
|
|
554
|
+
}]
|
|
555
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.ConfigService }] });
|
|
556
|
+
|
|
557
|
+
/*
|
|
558
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
559
|
+
*
|
|
560
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
561
|
+
* you may not use this file except in compliance with the License.
|
|
562
|
+
* You may obtain a copy of the License at
|
|
563
|
+
*
|
|
564
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
565
|
+
*
|
|
566
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
567
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
568
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
569
|
+
* See the License for the specific language governing permissions and
|
|
570
|
+
* limitations under the License.
|
|
571
|
+
*/
|
|
572
|
+
class ResourceModule {
|
|
573
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ResourceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
574
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.17", ngImport: i0, type: ResourceModule }); }
|
|
575
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ResourceModule, providers: [
|
|
576
|
+
OpenZaakUploadService,
|
|
577
|
+
S3UploadService,
|
|
578
|
+
UploadProviderService,
|
|
579
|
+
OpenZaakService,
|
|
580
|
+
S3Service,
|
|
581
|
+
DownloadService,
|
|
582
|
+
] }); }
|
|
583
|
+
}
|
|
584
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.17", ngImport: i0, type: ResourceModule, decorators: [{
|
|
585
|
+
type: NgModule,
|
|
586
|
+
args: [{
|
|
587
|
+
declarations: [],
|
|
588
|
+
imports: [],
|
|
589
|
+
exports: [],
|
|
590
|
+
providers: [
|
|
591
|
+
OpenZaakUploadService,
|
|
592
|
+
S3UploadService,
|
|
593
|
+
UploadProviderService,
|
|
594
|
+
OpenZaakService,
|
|
595
|
+
S3Service,
|
|
596
|
+
DownloadService,
|
|
597
|
+
],
|
|
598
|
+
}]
|
|
599
|
+
}] });
|
|
600
|
+
|
|
601
|
+
/*
|
|
602
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
603
|
+
*
|
|
604
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
605
|
+
* you may not use this file except in compliance with the License.
|
|
606
|
+
* You may obtain a copy of the License at
|
|
607
|
+
*
|
|
608
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
609
|
+
*
|
|
610
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
611
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
612
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
613
|
+
* See the License for the specific language governing permissions and
|
|
614
|
+
* limitations under the License.
|
|
615
|
+
*/
|
|
616
|
+
var PERMISSION_ACTION;
|
|
617
|
+
(function (PERMISSION_ACTION) {
|
|
618
|
+
PERMISSION_ACTION["view"] = "view";
|
|
619
|
+
PERMISSION_ACTION["view_list"] = "view_list";
|
|
620
|
+
PERMISSION_ACTION["create"] = "create";
|
|
621
|
+
PERMISSION_ACTION["modify"] = "modify";
|
|
622
|
+
PERMISSION_ACTION["delete"] = "delete";
|
|
623
|
+
})(PERMISSION_ACTION || (PERMISSION_ACTION = {}));
|
|
624
|
+
var RESOURCE_PERMISSION_RESOURCE;
|
|
625
|
+
(function (RESOURCE_PERMISSION_RESOURCE) {
|
|
626
|
+
RESOURCE_PERMISSION_RESOURCE["resourcePermission"] = "com.ritense.resource.authorization.ResourcePermission";
|
|
627
|
+
RESOURCE_PERMISSION_RESOURCE["jsonSchemaDocument"] = "com.ritense.document.domain.impl.JsonSchemaDocument";
|
|
628
|
+
})(RESOURCE_PERMISSION_RESOURCE || (RESOURCE_PERMISSION_RESOURCE = {}));
|
|
629
|
+
const CAN_VIEW_RESOURCE_PERMISSION = {
|
|
630
|
+
action: PERMISSION_ACTION.view,
|
|
631
|
+
resource: RESOURCE_PERMISSION_RESOURCE.resourcePermission,
|
|
632
|
+
};
|
|
633
|
+
const CAN_VIEW_LIST_RESOURCE_PERMISSION = {
|
|
634
|
+
action: PERMISSION_ACTION.view_list,
|
|
635
|
+
resource: RESOURCE_PERMISSION_RESOURCE.resourcePermission,
|
|
636
|
+
};
|
|
637
|
+
const CAN_CREATE_RESOURCE_PERMISSION = {
|
|
638
|
+
action: PERMISSION_ACTION.create,
|
|
639
|
+
resource: RESOURCE_PERMISSION_RESOURCE.resourcePermission,
|
|
640
|
+
};
|
|
641
|
+
const CAN_MODIFY_RESOURCE_PERMISSION = {
|
|
642
|
+
action: PERMISSION_ACTION.modify,
|
|
643
|
+
resource: RESOURCE_PERMISSION_RESOURCE.resourcePermission,
|
|
644
|
+
};
|
|
645
|
+
const CAN_DELETE_RESOURCE_PERMISSION = {
|
|
646
|
+
action: PERMISSION_ACTION.delete,
|
|
647
|
+
resource: RESOURCE_PERMISSION_RESOURCE.resourcePermission,
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
/*
|
|
651
|
+
* Copyright 2015-2025 Ritense BV, the Netherlands.
|
|
652
|
+
*
|
|
653
|
+
* Licensed under EUPL, Version 1.2 (the "License");
|
|
654
|
+
* you may not use this file except in compliance with the License.
|
|
655
|
+
* You may obtain a copy of the License at
|
|
656
|
+
*
|
|
657
|
+
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
658
|
+
*
|
|
659
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
660
|
+
* distributed under the License is distributed on an "AS IS" basis,
|
|
661
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
662
|
+
* See the License for the specific language governing permissions and
|
|
663
|
+
* limitations under the License.
|
|
664
|
+
*/
|
|
665
|
+
/*
|
|
666
|
+
* Public API Surface of upload
|
|
667
|
+
*/
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Generated bundle index. Do not edit.
|
|
671
|
+
*/
|
|
672
|
+
|
|
673
|
+
export { Afleidingswijze, Archiefnominatie, CAN_CREATE_RESOURCE_PERMISSION, CAN_DELETE_RESOURCE_PERMISSION, CAN_MODIFY_RESOURCE_PERMISSION, CAN_VIEW_LIST_RESOURCE_PERMISSION, CAN_VIEW_RESOURCE_PERMISSION, DownloadService, Objecttype, OpenZaakConfig, OpenZaakService, RESOURCE_PERMISSION_RESOURCE, ResourceModule, S3Resource, S3Service, UploadProviderService };
|
|
674
|
+
//# sourceMappingURL=valtimo-resource.mjs.map
|