@valtimo/resource 4.15.2-next-main.8

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 ADDED
@@ -0,0 +1,24 @@
1
+ # Upload
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.1.2.
4
+
5
+ ## Code scaffolding
6
+
7
+ Run `ng generate component component-name --project upload` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project upload`.
8
+ > Note: Don't forget to add `--project upload` or else it will be added to the default project in your `angular.json` file.
9
+
10
+ ## Build
11
+
12
+ Run `ng build upload` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+
14
+ ## Publishing
15
+
16
+ After building your library with `ng build upload`, go to the dist folder `cd dist/upload` and run `npm publish`.
17
+
18
+ ## Running unit tests
19
+
20
+ Run `ng test upload` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
+
22
+ ## Further help
23
+
24
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
@@ -0,0 +1,426 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('@valtimo/config'), require('rxjs/operators'), require('@valtimo/contract'), require('uuid'), require('ngx-logger')) :
3
+ typeof define === 'function' && define.amd ? define('@valtimo/resource', ['exports', '@angular/core', '@angular/common/http', '@valtimo/config', 'rxjs/operators', '@valtimo/contract', 'uuid', 'ngx-logger'], factory) :
4
+ (global = global || self, factory((global.valtimo = global.valtimo || {}, global.valtimo.resource = {}), global.ng.core, global.ng.common.http, global.i2, global.rxjs.operators, global.contract, global.uuid, global.i2$1));
5
+ }(this, (function (exports, i0, i1, i2, operators, contract, uuid, i2$1) { 'use strict';
6
+
7
+ /*
8
+ * Copyright 2020 Dimpact.
9
+ *
10
+ * Licensed under EUPL, Version 1.2 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
15
+ *
16
+ * Unless required by applicable law or agreed to in writing, software
17
+ * distributed under the License is distributed on an "AS IS" basis,
18
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ * See the License for the specific language governing permissions and
20
+ * limitations under the License.
21
+ */
22
+ var OpenZaakService = /** @class */ (function () {
23
+ function OpenZaakService(http, configService) {
24
+ this.http = http;
25
+ this.configService = configService;
26
+ this.valtimoApiConfig = configService.config.valtimoApi;
27
+ this.catalogus = configService.config.openZaak.catalogus;
28
+ }
29
+ OpenZaakService.prototype.getOpenZaakConfig = function () {
30
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/config");
31
+ };
32
+ OpenZaakService.prototype.getResource = function (resourceId) {
33
+ return this.http.get(this.valtimoApiConfig.endpointUri + "resource/" + resourceId);
34
+ };
35
+ OpenZaakService.prototype.createOpenZaakConfig = function (request) {
36
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/config", request);
37
+ };
38
+ OpenZaakService.prototype.modifyOpenZaakConfig = function (request) {
39
+ return this.http.put(this.valtimoApiConfig.endpointUri + "openzaak/config", request);
40
+ };
41
+ OpenZaakService.prototype.deleteOpenZaakConfig = function () {
42
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/config");
43
+ };
44
+ OpenZaakService.prototype.getZaakTypes = function () {
45
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/zaaktype");
46
+ };
47
+ OpenZaakService.prototype.getInformatieObjectTypes = function () {
48
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-typen/" + this.catalogus);
49
+ };
50
+ OpenZaakService.prototype.getZaakTypeLink = function (id) {
51
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id);
52
+ };
53
+ OpenZaakService.prototype.getInformatieObjectTypeLink = function (id) {
54
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link/" + id);
55
+ };
56
+ OpenZaakService.prototype.createZaakTypeLink = function (request) {
57
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/link", request);
58
+ };
59
+ OpenZaakService.prototype.createInformatieObjectTypeLink = function (request) {
60
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link", request);
61
+ };
62
+ OpenZaakService.prototype.deleteZaakTypeLink = function (id) {
63
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id);
64
+ };
65
+ OpenZaakService.prototype.deleteInformatieObjectTypeLink = function (id) {
66
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link/" + id);
67
+ };
68
+ OpenZaakService.prototype.getZaakTypeLinkListByProcess = function (processDefinitionKey) {
69
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/link/process/" + processDefinitionKey);
70
+ };
71
+ OpenZaakService.prototype.getStatusTypes = function (zaakTypeRequest) {
72
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/status", zaakTypeRequest);
73
+ };
74
+ OpenZaakService.prototype.getStatusResults = function (zaakTypeRequest) {
75
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/resultaat", zaakTypeRequest);
76
+ };
77
+ OpenZaakService.prototype.createServiceTaskHandler = function (id, request) {
78
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler", request);
79
+ };
80
+ OpenZaakService.prototype.modifyServiceTaskHandler = function (id, request) {
81
+ return this.http.put(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler", request);
82
+ };
83
+ OpenZaakService.prototype.deleteServiceTaskHandler = function (id, serviceTaskId) {
84
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler/" + serviceTaskId);
85
+ };
86
+ OpenZaakService.prototype.upload = function (file, documentDefinitionName) {
87
+ var formData = new FormData();
88
+ formData.append('file', file);
89
+ formData.append('documentDefinitionName', documentDefinitionName);
90
+ return this.http.post(this.valtimoApiConfig.endpointUri + "resource/upload-open-zaak", formData, {
91
+ reportProgress: true,
92
+ responseType: 'json'
93
+ });
94
+ };
95
+ return OpenZaakService;
96
+ }());
97
+ OpenZaakService.ɵprov = i0.ɵɵdefineInjectable({ factory: function OpenZaakService_Factory() { return new OpenZaakService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: OpenZaakService, providedIn: "root" });
98
+ OpenZaakService.decorators = [
99
+ { type: i0.Injectable, args: [{
100
+ providedIn: 'root'
101
+ },] }
102
+ ];
103
+ OpenZaakService.ctorParameters = function () { return [
104
+ { type: i1.HttpClient },
105
+ { type: i2.ConfigService }
106
+ ]; };
107
+
108
+ /*
109
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
110
+ *
111
+ * Licensed under EUPL, Version 1.2 (the "License");
112
+ * you may not use this file except in compliance with the License.
113
+ * You may obtain a copy of the License at
114
+ *
115
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
116
+ *
117
+ * Unless required by applicable law or agreed to in writing, software
118
+ * distributed under the License is distributed on an "AS IS" basis,
119
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120
+ * See the License for the specific language governing permissions and
121
+ * limitations under the License.
122
+ */
123
+ var OpenZaakUploadService = /** @class */ (function () {
124
+ function OpenZaakUploadService(openZaakService, http, configService) {
125
+ this.openZaakService = openZaakService;
126
+ this.http = http;
127
+ this.configService = configService;
128
+ this.valtimoApiConfig = configService.config.valtimoApi;
129
+ }
130
+ OpenZaakUploadService.prototype.uploadFile = function (file, documentDefinitionName) {
131
+ var _this = this;
132
+ return this.openZaakService.upload(new File([file], file.name, { type: file.type }), documentDefinitionName).pipe(operators.map(function (result) { return _this.getResourceFile(result); }));
133
+ };
134
+ OpenZaakUploadService.prototype.getResource = function (resourceId) {
135
+ return this.openZaakService.getResource(resourceId);
136
+ };
137
+ OpenZaakUploadService.prototype.getResourceFile = function (result) {
138
+ return {
139
+ customUpload: true,
140
+ originalName: result.name,
141
+ size: result.sizeInBytes,
142
+ url: '/api/resource/' + result.resourceId + '/download',
143
+ storage: 'openZaak',
144
+ type: result.extension,
145
+ data: {
146
+ createdOn: result.createdOn,
147
+ name: result.name,
148
+ sizeInBytes: result.sizeInBytes,
149
+ resourceId: result.resourceId,
150
+ extension: result.extension
151
+ }
152
+ };
153
+ };
154
+ return OpenZaakUploadService;
155
+ }());
156
+ OpenZaakUploadService.decorators = [
157
+ { type: i0.Injectable }
158
+ ];
159
+ OpenZaakUploadService.ctorParameters = function () { return [
160
+ { type: OpenZaakService },
161
+ { type: i1.HttpClient },
162
+ { type: i2.ConfigService }
163
+ ]; };
164
+
165
+ /*
166
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
167
+ *
168
+ * Licensed under EUPL, Version 1.2 (the "License");
169
+ * you may not use this file except in compliance with the License.
170
+ * You may obtain a copy of the License at
171
+ *
172
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
173
+ *
174
+ * Unless required by applicable law or agreed to in writing, software
175
+ * distributed under the License is distributed on an "AS IS" basis,
176
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
177
+ * See the License for the specific language governing permissions and
178
+ * limitations under the License.
179
+ */
180
+ var S3Service = /** @class */ (function () {
181
+ function S3Service(http, configService) {
182
+ this.http = http;
183
+ this.configService = configService;
184
+ this.valtimoApiConfig = configService.config.valtimoApi;
185
+ }
186
+ S3Service.prototype.getPreSignedUrl = function (fileName) {
187
+ var headers = new i1.HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
188
+ var options = { headers: headers, responseType: 'text' };
189
+ return this.http.get(this.valtimoApiConfig.endpointUri + "resource/pre-signed-url/" + fileName, options);
190
+ };
191
+ S3Service.prototype.upload = function (url, file) {
192
+ var headers = new i1.HttpHeaders()
193
+ .set('Content-Type', file.type);
194
+ return this.http.put(url.toString(), file, { headers: headers });
195
+ };
196
+ S3Service.prototype.registerResource = function (s3ResourceDTO) {
197
+ return this.http.put(this.valtimoApiConfig.endpointUri + "resource", s3ResourceDTO);
198
+ };
199
+ S3Service.prototype.get = function (resourceId) {
200
+ var headers = new i1.HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
201
+ return this.http.get(this.valtimoApiConfig.endpointUri + "resource/" + resourceId, { headers: headers });
202
+ };
203
+ S3Service.prototype.delete = function (resourceId) {
204
+ var headers = new i1.HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
205
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "resource/" + resourceId, { headers: headers });
206
+ };
207
+ return S3Service;
208
+ }());
209
+ S3Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function S3Service_Factory() { return new S3Service(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: S3Service, providedIn: "root" });
210
+ S3Service.decorators = [
211
+ { type: i0.Injectable, args: [{
212
+ providedIn: 'root'
213
+ },] }
214
+ ];
215
+ S3Service.ctorParameters = function () { return [
216
+ { type: i1.HttpClient },
217
+ { type: i2.ConfigService }
218
+ ]; };
219
+
220
+ /*
221
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
222
+ *
223
+ * Licensed under EUPL, Version 1.2 (the "License");
224
+ * you may not use this file except in compliance with the License.
225
+ * You may obtain a copy of the License at
226
+ *
227
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
228
+ *
229
+ * Unless required by applicable law or agreed to in writing, software
230
+ * distributed under the License is distributed on an "AS IS" basis,
231
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
232
+ * See the License for the specific language governing permissions and
233
+ * limitations under the License.
234
+ */
235
+ var S3UploadService = /** @class */ (function () {
236
+ function S3UploadService(s3Service) {
237
+ this.s3Service = s3Service;
238
+ }
239
+ S3UploadService.prototype.uploadFile = function (file) {
240
+ var _this = this;
241
+ var resourceUrl;
242
+ var fileName = file.name;
243
+ var splitFileName = fileName.split('.');
244
+ var fileNameWithUUID = splitFileName[0] + "-" + uuid.v4() + "." + splitFileName[1];
245
+ var renamedFile = new File([file], fileNameWithUUID, { type: file.type });
246
+ return this.s3Service.getPreSignedUrl(renamedFile.name).pipe(operators.map(function (url) { return new URL(url); }), operators.tap(function (url) { return resourceUrl = url; }), operators.switchMap(function (url) { return _this.s3Service.upload(url, renamedFile); }), operators.map(function () { return new contract.S3Resource(file, resourceUrl); }), operators.switchMap(function (s3Resource) { return _this.s3Service.registerResource(s3Resource); }), operators.switchMap(function (s3Resource) { return _this.s3Service.get(s3Resource.id); }), operators.map(function (result) { return (Object.assign(Object.assign({}, result), { originalName: file.name })); }), operators.map(function (result) { return _this.getResourceFile(result); }));
247
+ };
248
+ S3UploadService.prototype.getResource = function (resourceId) {
249
+ return this.s3Service.get(resourceId);
250
+ };
251
+ S3UploadService.prototype.getResourceFile = function (result) {
252
+ return {
253
+ customUpload: true,
254
+ originalName: result.originalName,
255
+ url: result.url,
256
+ size: result.resource.sizeInBytes,
257
+ storage: 'url',
258
+ type: result.resource.extension,
259
+ data: {
260
+ key: result.resource.key,
261
+ bucketName: result.resource.name,
262
+ createdOn: result.resource.createdOn,
263
+ name: result.originalName,
264
+ sizeInBytes: result.resource.sizeInBytes,
265
+ resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1)
266
+ }
267
+ };
268
+ };
269
+ return S3UploadService;
270
+ }());
271
+ S3UploadService.decorators = [
272
+ { type: i0.Injectable }
273
+ ];
274
+ S3UploadService.ctorParameters = function () { return [
275
+ { type: S3Service }
276
+ ]; };
277
+
278
+ /*
279
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
280
+ *
281
+ * Licensed under EUPL, Version 1.2 (the "License");
282
+ * you may not use this file except in compliance with the License.
283
+ * You may obtain a copy of the License at
284
+ *
285
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
286
+ *
287
+ * Unless required by applicable law or agreed to in writing, software
288
+ * distributed under the License is distributed on an "AS IS" basis,
289
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
290
+ * See the License for the specific language governing permissions and
291
+ * limitations under the License.
292
+ */
293
+ var UploadProviderService = /** @class */ (function () {
294
+ function UploadProviderService(configService, injector, logger) {
295
+ this.configService = configService;
296
+ this.injector = injector;
297
+ this.logger = logger;
298
+ this.uploadService = configService.config.uploadProvider === contract.UploadProvider.S3 ?
299
+ injector.get(S3UploadService)
300
+ : injector.get(OpenZaakUploadService);
301
+ this.logger.debug('Loading UploadService as', this.uploadService);
302
+ }
303
+ UploadProviderService.prototype.uploadFile = function (file, documentDefinitionName) {
304
+ return this.uploadService.uploadFile(file, documentDefinitionName);
305
+ };
306
+ UploadProviderService.prototype.getResource = function (resourceId) {
307
+ return this.uploadService.getResource(resourceId);
308
+ };
309
+ return UploadProviderService;
310
+ }());
311
+ UploadProviderService.ɵprov = i0.ɵɵdefineInjectable({ factory: function UploadProviderService_Factory() { return new UploadProviderService(i0.ɵɵinject(i2.ConfigService), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i2$1.NGXLogger)); }, token: UploadProviderService, providedIn: "root" });
312
+ UploadProviderService.decorators = [
313
+ { type: i0.Injectable, args: [{
314
+ providedIn: 'root'
315
+ },] }
316
+ ];
317
+ UploadProviderService.ctorParameters = function () { return [
318
+ { type: i2.ConfigService },
319
+ { type: i0.Injector },
320
+ { type: i2$1.NGXLogger }
321
+ ]; };
322
+
323
+ /*
324
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
325
+ *
326
+ * Licensed under EUPL, Version 1.2 (the "License");
327
+ * you may not use this file except in compliance with the License.
328
+ * You may obtain a copy of the License at
329
+ *
330
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
331
+ *
332
+ * Unless required by applicable law or agreed to in writing, software
333
+ * distributed under the License is distributed on an "AS IS" basis,
334
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
335
+ * See the License for the specific language governing permissions and
336
+ * limitations under the License.
337
+ */
338
+ var DownloadService = /** @class */ (function () {
339
+ function DownloadService(http, configService) {
340
+ this.http = http;
341
+ this.configService = configService;
342
+ }
343
+ DownloadService.prototype.downloadFile = function (url, name) {
344
+ var _this = this;
345
+ if (url.startsWith(this.configService.config.valtimoApi.endpointUri) || url.startsWith(window.location.origin)) {
346
+ // if download url is on backend use angular to get the content so access token is used
347
+ this.http.get(url, { responseType: 'blob' }).subscribe(function (content) {
348
+ var downloadUrl = window.URL.createObjectURL(content);
349
+ _this.openDownloadLink(downloadUrl, name);
350
+ });
351
+ }
352
+ else {
353
+ // download links to external services (like amazon s3) open in a new window
354
+ this.openDownloadLink(url, name);
355
+ }
356
+ };
357
+ DownloadService.prototype.openDownloadLink = function (url, name) {
358
+ var link = document.createElement('a');
359
+ link.href = url;
360
+ link.download = name;
361
+ link.target = '_blank';
362
+ link.click();
363
+ link.remove();
364
+ };
365
+ return DownloadService;
366
+ }());
367
+ DownloadService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DownloadService_Factory() { return new DownloadService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: DownloadService, providedIn: "root" });
368
+ DownloadService.decorators = [
369
+ { type: i0.Injectable, args: [{
370
+ providedIn: 'root'
371
+ },] }
372
+ ];
373
+ DownloadService.ctorParameters = function () { return [
374
+ { type: i1.HttpClient },
375
+ { type: i2.ConfigService }
376
+ ]; };
377
+
378
+ /*
379
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
380
+ *
381
+ * Licensed under EUPL, Version 1.2 (the "License");
382
+ * you may not use this file except in compliance with the License.
383
+ * You may obtain a copy of the License at
384
+ *
385
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
386
+ *
387
+ * Unless required by applicable law or agreed to in writing, software
388
+ * distributed under the License is distributed on an "AS IS" basis,
389
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
390
+ * See the License for the specific language governing permissions and
391
+ * limitations under the License.
392
+ */
393
+ var ResourceModule = /** @class */ (function () {
394
+ function ResourceModule() {
395
+ }
396
+ return ResourceModule;
397
+ }());
398
+ ResourceModule.decorators = [
399
+ { type: i0.NgModule, args: [{
400
+ declarations: [],
401
+ imports: [],
402
+ exports: [],
403
+ providers: [OpenZaakUploadService, S3UploadService, UploadProviderService, OpenZaakService, S3Service, DownloadService]
404
+ },] }
405
+ ];
406
+
407
+ /*
408
+ * Public API Surface of upload
409
+ */
410
+
411
+ /**
412
+ * Generated bundle index. Do not edit.
413
+ */
414
+
415
+ exports.DownloadService = DownloadService;
416
+ exports.OpenZaakService = OpenZaakService;
417
+ exports.ResourceModule = ResourceModule;
418
+ exports.S3Service = S3Service;
419
+ exports.UploadProviderService = UploadProviderService;
420
+ exports.ɵa = OpenZaakUploadService;
421
+ exports.ɵb = S3UploadService;
422
+
423
+ Object.defineProperty(exports, '__esModule', { value: true });
424
+
425
+ })));
426
+ //# sourceMappingURL=valtimo-resource.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"valtimo-resource.umd.js","sources":["../../../../projects/valtimo/resource/src/lib/services/open-zaak.service.ts","../../../../projects/valtimo/resource/src/lib/services/open-zaak-upload.service.ts","../../../../projects/valtimo/resource/src/lib/services/s3.service.ts","../../../../projects/valtimo/resource/src/lib/services/s3-upload.service.ts","../../../../projects/valtimo/resource/src/lib/services/upload-provider.service.ts","../../../../projects/valtimo/resource/src/lib/services/download.service.ts","../../../../projects/valtimo/resource/src/lib/resource.module.ts","../../../../projects/valtimo/resource/src/public-api.ts","../../../../projects/valtimo/resource/src/valtimo-resource.ts"],"sourcesContent":["/*\n * Copyright 2020 Dimpact.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {ConfigService} from '@valtimo/config';\nimport {Observable} from 'rxjs';\nimport {\n CreateInformatieObjectTypeLinkRequest,\n CreateOpenZaakConfigRequest,\n CreateOpenZaakConfigResult,\n CreateZaakTypeLinkRequest,\n InformatieObjectType,\n InformatieObjectTypeLink,\n ModifyOpenZaakConfigRequest,\n ModifyOpenZaakConfigResult,\n OpenZaakConfig,\n OpenZaakResource,\n ResourceDto,\n ServiceTaskHandlerRequest,\n ZaakType,\n ZaakTypeLink,\n ZaakTypeRequest\n} from '@valtimo/contract';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class OpenZaakService {\n\n private valtimoApiConfig: any;\n private catalogus: string;\n\n constructor(\n private http: HttpClient,\n private configService: ConfigService\n ) {\n this.valtimoApiConfig = configService.config.valtimoApi;\n this.catalogus = configService.config.openZaak.catalogus;\n }\n\n getOpenZaakConfig(): Observable<OpenZaakConfig> {\n return this.http.get<OpenZaakConfig>(`${this.valtimoApiConfig.endpointUri}openzaak/config`);\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.http.get<ResourceDto>(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`);\n }\n\n createOpenZaakConfig(request: CreateOpenZaakConfigRequest): Observable<CreateOpenZaakConfigResult> {\n return this.http.post<CreateOpenZaakConfigResult>(`${this.valtimoApiConfig.endpointUri}openzaak/config`, request);\n }\n\n modifyOpenZaakConfig(request: ModifyOpenZaakConfigRequest): Observable<ModifyOpenZaakConfigResult> {\n return this.http.put<ModifyOpenZaakConfigResult>(`${this.valtimoApiConfig.endpointUri}openzaak/config`, request);\n }\n\n deleteOpenZaakConfig(): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/config`);\n }\n\n getZaakTypes(): Observable<ZaakType[]> {\n return this.http.get<ZaakType[]>(`${this.valtimoApiConfig.endpointUri}openzaak/zaaktype`);\n }\n\n getInformatieObjectTypes(): Observable<InformatieObjectType[]> {\n return this.http.get<InformatieObjectType[]>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-typen/${this.catalogus}`);\n }\n\n getZaakTypeLink(id: string): Observable<ZaakTypeLink> {\n return this.http.get<ZaakTypeLink>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}`);\n }\n\n getInformatieObjectTypeLink(id: string): Observable<InformatieObjectTypeLink> {\n return this.http.get<InformatieObjectTypeLink>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link/${id}`);\n }\n\n createZaakTypeLink(request: CreateZaakTypeLinkRequest): Observable<any> {\n return this.http.post<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link`, request);\n }\n\n createInformatieObjectTypeLink(request: CreateInformatieObjectTypeLinkRequest): Observable<any> {\n return this.http.post<any>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link`, request);\n }\n\n deleteZaakTypeLink(id: string): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}`);\n }\n\n deleteInformatieObjectTypeLink(id: string): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link/${id}`);\n }\n\n getZaakTypeLinkListByProcess(processDefinitionKey: string): Observable<any> {\n return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/link/process/${processDefinitionKey}`);\n }\n\n getStatusTypes(zaakTypeRequest: ZaakTypeRequest): Observable<any> {\n return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/status`, zaakTypeRequest);\n }\n\n getStatusResults(zaakTypeRequest): Observable<any> {\n return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/resultaat`, zaakTypeRequest);\n }\n\n createServiceTaskHandler(id: string, request: ServiceTaskHandlerRequest): Observable<any> {\n return this.http.post<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler`, request);\n }\n\n modifyServiceTaskHandler(id: string, request: ServiceTaskHandlerRequest): Observable<any> {\n return this.http.put<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler`, request);\n }\n\n deleteServiceTaskHandler(id: string, serviceTaskId: string): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler/${serviceTaskId}`);\n }\n\n upload(file: File, documentDefinitionName: string): Observable<OpenZaakResource> {\n const formData: FormData = new FormData();\n formData.append('file', file);\n formData.append('documentDefinitionName', documentDefinitionName);\n\n return this.http.post<OpenZaakResource>(`${this.valtimoApiConfig.endpointUri}resource/upload-open-zaak`, formData, {\n reportProgress: true,\n responseType: 'json'\n });\n }\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {ConfigService} from '@valtimo/config';\nimport {Observable} from 'rxjs';\nimport {OpenZaakResource, ResourceFile, UploadService, ResourceDto} from '@valtimo/contract';\nimport {OpenZaakService} from './open-zaak.service';\nimport {map} from 'rxjs/operators';\n\n@Injectable()\nexport class OpenZaakUploadService implements UploadService {\n\n private valtimoApiConfig: any;\n\n constructor(\n private readonly openZaakService: OpenZaakService,\n private http: HttpClient,\n private configService: ConfigService,\n ) {\n this.valtimoApiConfig = configService.config.valtimoApi;\n }\n\n uploadFile(file: File, documentDefinitionName: string): Observable<ResourceFile> {\n return this.openZaakService.upload(new File([file], file.name, {type: file.type}), documentDefinitionName).pipe(\n map(result => this.getResourceFile(result))\n );\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.openZaakService.getResource(resourceId);\n }\n\n private getResourceFile(result: OpenZaakResource): ResourceFile {\n return {\n customUpload: true,\n originalName: result.name,\n size: result.sizeInBytes,\n url: '/api/resource/' + result.resourceId + '/download',\n storage: 'openZaak',\n type: result.extension,\n data: {\n createdOn: result.createdOn as any as string,\n name: result.name,\n sizeInBytes: result.sizeInBytes,\n resourceId: result.resourceId,\n extension: result.extension\n }\n };\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {HttpClient, HttpHeaders} from '@angular/common/http';\nimport {Observable} from 'rxjs';\nimport {ConfigService} from '@valtimo/config';\nimport {Resource, S3Resource, ResourceDto} from '@valtimo/contract';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class S3Service {\n private valtimoApiConfig: any;\n\n constructor(\n private http: HttpClient,\n private configService: ConfigService\n ) {\n this.valtimoApiConfig = configService.config.valtimoApi;\n }\n\n public getPreSignedUrl(fileName: string): Observable<string> {\n const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');\n const options = {headers, responseType: 'text' as 'text'};\n return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/pre-signed-url/${fileName}`, options);\n }\n\n public upload(url: URL, file: File): Observable<any> {\n const headers = new HttpHeaders()\n .set('Content-Type', file.type);\n return this.http.put(url.toString(), file, {headers: headers});\n }\n\n public registerResource(s3ResourceDTO: S3Resource): Observable<Resource> {\n return this.http.put<Resource>(`${this.valtimoApiConfig.endpointUri}resource`, s3ResourceDTO);\n }\n\n public get(resourceId: string): Observable<ResourceDto> {\n const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');\n return this.http.get<ResourceDto>(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, {headers: headers});\n }\n\n public delete(resourceId: string): Observable<any> {\n const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');\n return this.http.delete(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, {headers: headers});\n }\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Observable} from 'rxjs';\nimport {map, switchMap, tap} from 'rxjs/operators';\nimport {ResourceDto, ResourceFile, S3Resource, UploadService} from '@valtimo/contract';\nimport {Injectable} from '@angular/core';\nimport {v4 as uuidv4} from 'uuid';\nimport {S3Service} from './s3.service';\n\n@Injectable()\nexport class S3UploadService implements UploadService {\n\n constructor(\n private readonly s3Service: S3Service\n ) {\n }\n\n uploadFile(file: File): Observable<ResourceFile> {\n let resourceUrl: URL;\n const fileName = file.name;\n const splitFileName = fileName.split('.');\n const fileNameWithUUID = `${splitFileName[0]}-${uuidv4()}.${splitFileName[1]}`;\n const renamedFile = new File([file], fileNameWithUUID, {type: file.type});\n\n return this.s3Service.getPreSignedUrl(renamedFile.name).pipe(\n map((url) => new URL(url)),\n tap((url) => resourceUrl = url),\n switchMap((url) => this.s3Service.upload(url, renamedFile)),\n map(() => new S3Resource(file, resourceUrl)),\n switchMap((s3Resource) => this.s3Service.registerResource(s3Resource)),\n switchMap((s3Resource) => this.s3Service.get(s3Resource.id)),\n map((result) => ({...result, originalName: file.name})),\n map((result) => this.getResourceFile(result))\n );\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.s3Service.get(resourceId);\n }\n\n private getResourceFile(result: ResourceDto): ResourceFile {\n return {\n customUpload: true,\n originalName: result.originalName,\n url: result.url,\n size: result.resource.sizeInBytes,\n storage: 'url',\n type: result.resource.extension,\n data: {\n key: result.resource.key,\n bucketName: result.resource.name,\n createdOn: result.resource.createdOn as any as string,\n name: result.originalName,\n sizeInBytes: result.resource.sizeInBytes,\n resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1)\n }\n };\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable, Injector} from '@angular/core';\nimport {NGXLogger} from 'ngx-logger';\nimport {ResourceFile, UploadProvider, UploadService, ResourceDto} from '@valtimo/contract';\nimport {ConfigService} from '@valtimo/config';\nimport {Observable} from 'rxjs';\nimport {OpenZaakUploadService} from './open-zaak-upload.service';\nimport {S3UploadService} from './s3-upload.service';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class UploadProviderService implements UploadService {\n\n private readonly uploadService: UploadService;\n\n constructor(\n private configService: ConfigService,\n private injector: Injector,\n private logger: NGXLogger\n ) {\n this.uploadService = configService.config.uploadProvider === UploadProvider.S3 ?\n injector.get<UploadService>(S3UploadService)\n : injector.get<UploadService>(OpenZaakUploadService);\n this.logger.debug('Loading UploadService as', this.uploadService);\n }\n\n uploadFile(file: File, documentDefinitionName?: string): Observable<ResourceFile> {\n return this.uploadService.uploadFile(file, documentDefinitionName);\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.uploadService.getResource(resourceId);\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {ConfigService} from '@valtimo/config';\nimport {HttpClient} from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class DownloadService {\n\n constructor(\n private http: HttpClient,\n private configService: ConfigService\n ) { }\n\n downloadFile(url: string, name: string) {\n if (url.startsWith(this.configService.config.valtimoApi.endpointUri) || url.startsWith(window.location.origin)) {\n // if download url is on backend use angular to get the content so access token is used\n this.http.get(url, {responseType: 'blob'}).subscribe(content => {\n const downloadUrl = window.URL.createObjectURL(content);\n this.openDownloadLink(downloadUrl, name);\n });\n } else {\n // download links to external services (like amazon s3) open in a new window\n this.openDownloadLink(url, name);\n }\n }\n\n private openDownloadLink(url: string, name: string) {\n const link = document.createElement('a');\n link.href = url;\n link.download = name;\n link.target = '_blank';\n link.click();\n link.remove();\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NgModule} from '@angular/core';\nimport {OpenZaakUploadService} from './services/open-zaak-upload.service';\nimport {S3UploadService} from './services/s3-upload.service';\nimport {UploadProviderService} from './services/upload-provider.service';\nimport {OpenZaakService} from './services/open-zaak.service';\nimport {S3Service} from './services/s3.service';\nimport {DownloadService} from './services/download.service';\n\n@NgModule({\n declarations: [],\n imports: [\n ],\n exports: [],\n providers: [OpenZaakUploadService, S3UploadService, UploadProviderService, OpenZaakService, S3Service, DownloadService]\n})\nexport class ResourceModule { }\n","/*\n * Public API Surface of upload\n */\n\nexport * from './lib/resource.module';\nexport * from './lib/services/open-zaak.service';\nexport * from './lib/services/upload-provider.service';\nexport * from './lib/services/s3.service';\nexport * from './lib/services/download.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n\nexport {OpenZaakUploadService as ɵa} from './lib/services/open-zaak-upload.service';\nexport {S3UploadService as ɵb} from './lib/services/s3-upload.service';"],"names":["Injectable","HttpClient","ConfigService","map","HttpHeaders","uuidv4","tap","switchMap","S3Resource","UploadProvider","Injector","NGXLogger","NgModule"],"mappings":";;;;;;IAAA;;;;;;;;;;;;;;;;QA8CE,yBACU,IAAgB,EAChB,aAA4B;YAD5B,SAAI,GAAJ,IAAI,CAAY;YAChB,kBAAa,GAAb,aAAa,CAAe;YAEpC,IAAI,CAAC,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC;YACxD,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;SAC1D;QAED,2CAAiB,GAAjB;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAoB,IAAI,CAAC,gBAAgB,CAAC,WAAW,oBAAiB,CAAC,CAAC;SAC7F;QAED,qCAAW,GAAX,UAAY,UAAkB;YAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,G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AC,CAAC;aAClC;SACF;QAEO,0CAAgB,GAAhB,UAAiB,GAAW,EAAE,IAAY;YAChD,IAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;YAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;YACvB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,EAAE,CAAC;SACf;;;;;gBA9BFX,aAAU,SAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;gBAJOC,aAAU;gBADVC,gBAAa;;;ICjBrB;;;;;;;;;;;;;;;;QA+BA;;;;;gBAPCU,WAAQ,SAAC;oBACR,YAAY,EAAE,EAAE;oBAChB,OAAO,EAAE,EACR;oBACD,OAAO,EAAE,EAAE;oBACX,SAAS,EAAE,CAAC,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,CAAC;iBACxH;;;IC9BD;;;;ICAA;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("@valtimo/config"),require("rxjs/operators"),require("@valtimo/contract"),require("uuid"),require("ngx-logger")):"function"==typeof define&&define.amd?define("@valtimo/resource",["exports","@angular/core","@angular/common/http","@valtimo/config","rxjs/operators","@valtimo/contract","uuid","ngx-logger"],t):t(((e=e||self).valtimo=e.valtimo||{},e.valtimo.resource={}),e.ng.core,e.ng.common.http,e.i2,e.rxjs.operators,e.contract,e.uuid,e.i2$1)}(this,(function(e,t,i,n,o,r,p,a){"use strict";var c=function(){function e(e,t){this.http=e,this.configService=t,this.valtimoApiConfig=t.config.valtimoApi,this.catalogus=t.config.openZaak.catalogus}return e.prototype.getOpenZaakConfig=function(){return this.http.get(this.valtimoApiConfig.endpointUri+"openzaak/config")},e.prototype.getResource=function(e){return this.http.get(this.valtimoApiConfig.endpointUri+"resource/"+e)},e.prototype.createOpenZaakConfig=function(e){return this.http.post(this.valtimoApiConfig.endpointUri+"openzaak/config",e)},e.prototype.modifyOpenZaakConfig=function(e){return this.http.put(this.valtimoApiConfig.endpointUri+"openzaak/config",e)},e.prototype.deleteOpenZaakConfig=function(){return this.http.delete(this.valtimoApiConfig.endpointUri+"openzaak/config")},e.prototype.getZaakTypes=function(){return this.http.get(this.valtimoApiConfig.endpointUri+"openzaak/zaaktype")},e.prototype.getInformatieObjectTypes=function(){return this.http.get(this.valtimoApiConfig.endpointUri+"openzaak/informatie-object-typen/"+this.catalogus)},e.prototype.getZaakTypeLink=function(e){return this.http.get(this.valtimoApiConfig.endpointUri+"openzaak/link/"+e)},e.prototype.getInformatieObjectTypeLink=function(e){return this.http.get(this.valtimoApiConfig.endpointUri+"openzaak/informatie-object-type-link/"+e)},e.prototype.createZaakTypeLink=function(e){return this.http.post(this.valtimoApiConfig.endpointUri+"openzaak/link",e)},e.prototype.createInformatieObjectTypeLink=function(e){return this.http.post(this.valtimoApiConfig.endpointUri+"openzaak/informatie-object-type-link",e)},e.prototype.deleteZaakTypeLink=function(e){return this.http.delete(this.valtimoApiConfig.endpointUri+"openzaak/link/"+e)},e.prototype.deleteInformatieObjectTypeLink=function(e){return this.http.delete(this.valtimoApiConfig.endpointUri+"openzaak/informatie-object-type-link/"+e)},e.prototype.getZaakTypeLinkListByProcess=function(e){return this.http.get(this.valtimoApiConfig.endpointUri+"openzaak/link/process/"+e)},e.prototype.getStatusTypes=function(e){return this.http.post(this.valtimoApiConfig.endpointUri+"openzaak/status",e)},e.prototype.getStatusResults=function(e){return this.http.post(this.valtimoApiConfig.endpointUri+"openzaak/resultaat",e)},e.prototype.createServiceTaskHandler=function(e,t){return this.http.post(this.valtimoApiConfig.endpointUri+"openzaak/link/"+e+"/service-handler",t)},e.prototype.modifyServiceTaskHandler=function(e,t){return this.http.put(this.valtimoApiConfig.endpointUri+"openzaak/link/"+e+"/service-handler",t)},e.prototype.deleteServiceTaskHandler=function(e,t){return this.http.delete(this.valtimoApiConfig.endpointUri+"openzaak/link/"+e+"/service-handler/"+t)},e.prototype.upload=function(e,t){var i=new FormData;return i.append("file",e),i.append("documentDefinitionName",t),this.http.post(this.valtimoApiConfig.endpointUri+"resource/upload-open-zaak",i,{reportProgress:!0,responseType:"json"})},e}();c.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new c(t.ɵɵinject(i.HttpClient),t.ɵɵinject(n.ConfigService))},token:c,providedIn:"root"}),c.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],c.ctorParameters=function(){return[{type:i.HttpClient},{type:n.ConfigService}]};var s=function(){function e(e,t,i){this.openZaakService=e,this.http=t,this.configService=i,this.valtimoApiConfig=i.config.valtimoApi}return e.prototype.uploadFile=function(e,t){var i=this;return this.openZaakService.upload(new File([e],e.name,{type:e.type}),t).pipe(o.map((function(e){return i.getResourceFile(e)})))},e.prototype.getResource=function(e){return this.openZaakService.getResource(e)},e.prototype.getResourceFile=function(e){return{customUpload:!0,originalName:e.name,size:e.sizeInBytes,url:"/api/resource/"+e.resourceId+"/download",storage:"openZaak",type:e.extension,data:{createdOn:e.createdOn,name:e.name,sizeInBytes:e.sizeInBytes,resourceId:e.resourceId,extension:e.extension}}},e}();s.decorators=[{type:t.Injectable}],s.ctorParameters=function(){return[{type:c},{type:i.HttpClient},{type:n.ConfigService}]};var u=function(){function e(e,t){this.http=e,this.configService=t,this.valtimoApiConfig=t.config.valtimoApi}return e.prototype.getPreSignedUrl=function(e){var t={headers:(new i.HttpHeaders).set("Content-Type","text/plain; charset=utf-8"),responseType:"text"};return this.http.get(this.valtimoApiConfig.endpointUri+"resource/pre-signed-url/"+e,t)},e.prototype.upload=function(e,t){var n=(new i.HttpHeaders).set("Content-Type",t.type);return this.http.put(e.toString(),t,{headers:n})},e.prototype.registerResource=function(e){return this.http.put(this.valtimoApiConfig.endpointUri+"resource",e)},e.prototype.get=function(e){var t=(new i.HttpHeaders).set("Content-Type","application/json;charset=UTF-8");return this.http.get(this.valtimoApiConfig.endpointUri+"resource/"+e,{headers:t})},e.prototype.delete=function(e){var t=(new i.HttpHeaders).set("Content-Type","application/json;charset=UTF-8");return this.http.delete(this.valtimoApiConfig.endpointUri+"resource/"+e,{headers:t})},e}();u.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new u(t.ɵɵinject(i.HttpClient),t.ɵɵinject(n.ConfigService))},token:u,providedIn:"root"}),u.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],u.ctorParameters=function(){return[{type:i.HttpClient},{type:n.ConfigService}]};var l=function(){function e(e){this.s3Service=e}return e.prototype.uploadFile=function(e){var t,i=this,n=e.name.split("."),a=n[0]+"-"+p.v4()+"."+n[1],c=new File([e],a,{type:e.type});return this.s3Service.getPreSignedUrl(c.name).pipe(o.map((function(e){return new URL(e)})),o.tap((function(e){return t=e})),o.switchMap((function(e){return i.s3Service.upload(e,c)})),o.map((function(){return new r.S3Resource(e,t)})),o.switchMap((function(e){return i.s3Service.registerResource(e)})),o.switchMap((function(e){return i.s3Service.get(e.id)})),o.map((function(t){return Object.assign(Object.assign({},t),{originalName:e.name})})),o.map((function(e){return i.getResourceFile(e)})))},e.prototype.getResource=function(e){return this.s3Service.get(e)},e.prototype.getResourceFile=function(e){return{customUpload:!0,originalName:e.originalName,url:e.url,size:e.resource.sizeInBytes,storage:"url",type:e.resource.extension,data:{key:e.resource.key,bucketName:e.resource.name,createdOn:e.resource.createdOn,name:e.originalName,sizeInBytes:e.resource.sizeInBytes,resourceId:e.resource.id.split("ResourceId(id=")[1].slice(0,-1)}}},e}();l.decorators=[{type:t.Injectable}],l.ctorParameters=function(){return[{type:u}]};var f=function(){function e(e,t,i){this.configService=e,this.injector=t,this.logger=i,this.uploadService=e.config.uploadProvider===r.UploadProvider.S3?t.get(l):t.get(s),this.logger.debug("Loading UploadService as",this.uploadService)}return e.prototype.uploadFile=function(e,t){return this.uploadService.uploadFile(e,t)},e.prototype.getResource=function(e){return this.uploadService.getResource(e)},e}();f.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new f(t.ɵɵinject(n.ConfigService),t.ɵɵinject(t.INJECTOR),t.ɵɵinject(a.NGXLogger))},token:f,providedIn:"root"}),f.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],f.ctorParameters=function(){return[{type:n.ConfigService},{type:t.Injector},{type:a.NGXLogger}]};var d=function(){function e(e,t){this.http=e,this.configService=t}return e.prototype.downloadFile=function(e,t){var i=this;e.startsWith(this.configService.config.valtimoApi.endpointUri)||e.startsWith(window.location.origin)?this.http.get(e,{responseType:"blob"}).subscribe((function(e){var n=window.URL.createObjectURL(e);i.openDownloadLink(n,t)})):this.openDownloadLink(e,t)},e.prototype.openDownloadLink=function(e,t){var i=document.createElement("a");i.href=e,i.download=t,i.target="_blank",i.click(),i.remove()},e}();d.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new d(t.ɵɵinject(i.HttpClient),t.ɵɵinject(n.ConfigService))},token:d,providedIn:"root"}),d.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],d.ctorParameters=function(){return[{type:i.HttpClient},{type:n.ConfigService}]};var g=function(){};g.decorators=[{type:t.NgModule,args:[{declarations:[],imports:[],exports:[],providers:[s,l,f,c,u,d]}]}],e.DownloadService=d,e.OpenZaakService=c,e.ResourceModule=g,e.S3Service=u,e.UploadProviderService=f,e.ɵa=s,e.ɵb=l,Object.defineProperty(e,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=valtimo-resource.umd.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../projects/valtimo/resource/src/lib/services/open-zaak.service.ts","../../../../projects/valtimo/resource/src/lib/services/open-zaak-upload.service.ts","../../../../projects/valtimo/resource/src/lib/services/s3.service.ts","../../../../projects/valtimo/resource/src/lib/services/s3-upload.service.ts","../../../../projects/valtimo/resource/src/lib/services/upload-provider.service.ts","../../../../projects/valtimo/resource/src/lib/services/download.service.ts","../../../../projects/valtimo/resource/src/lib/resource.module.ts"],"names":["OpenZaakService","http","configService","this","valtimoApiConfig","config","valtimoApi","catalogus","openZaak","prototype","getOpenZaakConfig","get","endpointUri","getResource","resourceId","createOpenZaakConfig","request","post","modifyOpenZaakConfig","put","deleteOpenZaakConfig","delete","getZaakTypes","getInformatieObjectTypes","getZaakTypeLink","id","getInformatieObjectTypeLink","createZaakTypeLink","createInformatieObjectTypeLink","deleteZaakTypeLink","deleteInformatieObjectTypeLink","getZaakTypeLinkListByProcess","processDefinitionKey","getStatusTypes","zaakTypeRequest","getStatusResults","createServiceTaskHandler","modifyServiceTaskHandler","deleteServiceTaskHandler","serviceTaskId","upload","file","documentDefinitionName","formData","FormData","append","reportProgress","responseType","Injectable","args","providedIn","HttpClient","ConfigService","OpenZaakUploadService","openZaakService","uploadFile","_this","File","name","type","pipe","map","result","getResourceFile","customUpload","originalName","size","sizeInBytes","url","storage","extension","data","createdOn","S3Service","getPreSignedUrl","fileName","options","headers","HttpHeaders","set","toString","registerResource","s3ResourceDTO","S3UploadService","s3Service","resourceUrl","splitFileName","split","fileNameWithUUID","uuidv4","renamedFile","URL","tap","switchMap","S3Resource","s3Resource","Object","assign","resource","key","bucketName","slice","UploadProviderService","injector","logger","uploadService","uploadProvider","UploadProvider","S3","debug","Injector","NGXLogger","DownloadService","downloadFile","startsWith","window","location","origin","subscribe","content","downloadUrl","createObjectURL","openDownloadLink","link","document","createElement","href","download","target","click","remove","NgModule","declarations","imports","exports","providers"],"mappings":"woBA8CE,SAAAA,EACUC,EACAC,GADAC,KAAAF,KAAAA,EACAE,KAAAD,cAAAA,EAERC,KAAKC,iBAAmBF,EAAcG,OAAOC,WAC7CH,KAAKI,UAAYL,EAAcG,OAAOG,SAASD,iBAGjDP,EAAAS,UAAAC,kBAAA,WACE,OAAOP,KAAKF,KAAKU,IAAuBR,KAAKC,iBAAiBQ,YAAW,oBAG3EZ,EAAAS,UAA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AAA,gBACZC,EAAAA,8BCQN,SAAAC,EACU/G,EACAC,GADAC,KAAAF,KAAAA,EACAE,KAAAD,cAAAA,SAGV8G,EAAAvG,UAAAwG,aAAA,SAAa7C,EAAaV,GAA1B,IAAAF,EAAArD,KACMiE,EAAI8C,WAAW/G,KAAKD,cAAcG,OAAOC,WAAWM,cAAgBwD,EAAI8C,WAAWC,OAAOC,SAASC,QAErGlH,KAAKF,KAAKU,IAAIyD,EAAK,CAACrB,aAAc,SAASuE,WAAU,SAAAC,GACnD,IAAMC,EAAcL,OAAOxB,IAAI8B,gBAAgBF,GAC/C/D,EAAKkE,iBAAiBF,EAAa9D,MAIrCvD,KAAKuH,iBAAiBtD,EAAKV,IAIvBsD,EAAAvG,UAAAiH,iBAAA,SAAiBtD,EAAaV,GACpC,IAAMiE,EAAOC,SAASC,cAAc,KACpCF,EAAKG,KAAO1D,EACZuD,EAAKI,SAAWrE,EAChBiE,EAAKK,OAAS,SACdL,EAAKM,QACLN,EAAKO,oLA7BRlF,EAAAA,WAAUC,KAAA,CAAC,CACVC,WAAY,oDAHNC,EAAAA,kBADAC,EAAAA,uBCcR,iCAPC+E,EAAAA,SAAQlF,KAAA,CAAC,CACRmF,aAAc,GACdC,QAAS,GAETC,QAAS,GACTC,UAAW,CAAClF,EAAuB8B,EAAiBmB,EAAuBtG,EAAiByE,EAAWuC","sourcesContent":["/*\n * Copyright 2020 Dimpact.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {ConfigService} from '@valtimo/config';\nimport {Observable} from 'rxjs';\nimport {\n CreateInformatieObjectTypeLinkRequest,\n CreateOpenZaakConfigRequest,\n CreateOpenZaakConfigResult,\n CreateZaakTypeLinkRequest,\n InformatieObjectType,\n InformatieObjectTypeLink,\n ModifyOpenZaakConfigRequest,\n ModifyOpenZaakConfigResult,\n OpenZaakConfig,\n OpenZaakResource,\n ResourceDto,\n ServiceTaskHandlerRequest,\n ZaakType,\n ZaakTypeLink,\n ZaakTypeRequest\n} from '@valtimo/contract';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class OpenZaakService {\n\n private valtimoApiConfig: any;\n private catalogus: string;\n\n constructor(\n private http: HttpClient,\n private configService: ConfigService\n ) {\n this.valtimoApiConfig = configService.config.valtimoApi;\n this.catalogus = configService.config.openZaak.catalogus;\n }\n\n getOpenZaakConfig(): Observable<OpenZaakConfig> {\n return this.http.get<OpenZaakConfig>(`${this.valtimoApiConfig.endpointUri}openzaak/config`);\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.http.get<ResourceDto>(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`);\n }\n\n createOpenZaakConfig(request: CreateOpenZaakConfigRequest): Observable<CreateOpenZaakConfigResult> {\n return this.http.post<CreateOpenZaakConfigResult>(`${this.valtimoApiConfig.endpointUri}openzaak/config`, request);\n }\n\n modifyOpenZaakConfig(request: ModifyOpenZaakConfigRequest): Observable<ModifyOpenZaakConfigResult> {\n return this.http.put<ModifyOpenZaakConfigResult>(`${this.valtimoApiConfig.endpointUri}openzaak/config`, request);\n }\n\n deleteOpenZaakConfig(): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/config`);\n }\n\n getZaakTypes(): Observable<ZaakType[]> {\n return this.http.get<ZaakType[]>(`${this.valtimoApiConfig.endpointUri}openzaak/zaaktype`);\n }\n\n getInformatieObjectTypes(): Observable<InformatieObjectType[]> {\n return this.http.get<InformatieObjectType[]>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-typen/${this.catalogus}`);\n }\n\n getZaakTypeLink(id: string): Observable<ZaakTypeLink> {\n return this.http.get<ZaakTypeLink>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}`);\n }\n\n getInformatieObjectTypeLink(id: string): Observable<InformatieObjectTypeLink> {\n return this.http.get<InformatieObjectTypeLink>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link/${id}`);\n }\n\n createZaakTypeLink(request: CreateZaakTypeLinkRequest): Observable<any> {\n return this.http.post<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link`, request);\n }\n\n createInformatieObjectTypeLink(request: CreateInformatieObjectTypeLinkRequest): Observable<any> {\n return this.http.post<any>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link`, request);\n }\n\n deleteZaakTypeLink(id: string): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}`);\n }\n\n deleteInformatieObjectTypeLink(id: string): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/informatie-object-type-link/${id}`);\n }\n\n getZaakTypeLinkListByProcess(processDefinitionKey: string): Observable<any> {\n return this.http.get(`${this.valtimoApiConfig.endpointUri}openzaak/link/process/${processDefinitionKey}`);\n }\n\n getStatusTypes(zaakTypeRequest: ZaakTypeRequest): Observable<any> {\n return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/status`, zaakTypeRequest);\n }\n\n getStatusResults(zaakTypeRequest): Observable<any> {\n return this.http.post(`${this.valtimoApiConfig.endpointUri}openzaak/resultaat`, zaakTypeRequest);\n }\n\n createServiceTaskHandler(id: string, request: ServiceTaskHandlerRequest): Observable<any> {\n return this.http.post<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler`, request);\n }\n\n modifyServiceTaskHandler(id: string, request: ServiceTaskHandlerRequest): Observable<any> {\n return this.http.put<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler`, request);\n }\n\n deleteServiceTaskHandler(id: string, serviceTaskId: string): Observable<any> {\n return this.http.delete<any>(`${this.valtimoApiConfig.endpointUri}openzaak/link/${id}/service-handler/${serviceTaskId}`);\n }\n\n upload(file: File, documentDefinitionName: string): Observable<OpenZaakResource> {\n const formData: FormData = new FormData();\n formData.append('file', file);\n formData.append('documentDefinitionName', documentDefinitionName);\n\n return this.http.post<OpenZaakResource>(`${this.valtimoApiConfig.endpointUri}resource/upload-open-zaak`, formData, {\n reportProgress: true,\n responseType: 'json'\n });\n }\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {HttpClient} from '@angular/common/http';\nimport {ConfigService} from '@valtimo/config';\nimport {Observable} from 'rxjs';\nimport {OpenZaakResource, ResourceFile, UploadService, ResourceDto} from '@valtimo/contract';\nimport {OpenZaakService} from './open-zaak.service';\nimport {map} from 'rxjs/operators';\n\n@Injectable()\nexport class OpenZaakUploadService implements UploadService {\n\n private valtimoApiConfig: any;\n\n constructor(\n private readonly openZaakService: OpenZaakService,\n private http: HttpClient,\n private configService: ConfigService,\n ) {\n this.valtimoApiConfig = configService.config.valtimoApi;\n }\n\n uploadFile(file: File, documentDefinitionName: string): Observable<ResourceFile> {\n return this.openZaakService.upload(new File([file], file.name, {type: file.type}), documentDefinitionName).pipe(\n map(result => this.getResourceFile(result))\n );\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.openZaakService.getResource(resourceId);\n }\n\n private getResourceFile(result: OpenZaakResource): ResourceFile {\n return {\n customUpload: true,\n originalName: result.name,\n size: result.sizeInBytes,\n url: '/api/resource/' + result.resourceId + '/download',\n storage: 'openZaak',\n type: result.extension,\n data: {\n createdOn: result.createdOn as any as string,\n name: result.name,\n sizeInBytes: result.sizeInBytes,\n resourceId: result.resourceId,\n extension: result.extension\n }\n };\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {HttpClient, HttpHeaders} from '@angular/common/http';\nimport {Observable} from 'rxjs';\nimport {ConfigService} from '@valtimo/config';\nimport {Resource, S3Resource, ResourceDto} from '@valtimo/contract';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class S3Service {\n private valtimoApiConfig: any;\n\n constructor(\n private http: HttpClient,\n private configService: ConfigService\n ) {\n this.valtimoApiConfig = configService.config.valtimoApi;\n }\n\n public getPreSignedUrl(fileName: string): Observable<string> {\n const headers = new HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');\n const options = {headers, responseType: 'text' as 'text'};\n return this.http.get(`${this.valtimoApiConfig.endpointUri}resource/pre-signed-url/${fileName}`, options);\n }\n\n public upload(url: URL, file: File): Observable<any> {\n const headers = new HttpHeaders()\n .set('Content-Type', file.type);\n return this.http.put(url.toString(), file, {headers: headers});\n }\n\n public registerResource(s3ResourceDTO: S3Resource): Observable<Resource> {\n return this.http.put<Resource>(`${this.valtimoApiConfig.endpointUri}resource`, s3ResourceDTO);\n }\n\n public get(resourceId: string): Observable<ResourceDto> {\n const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');\n return this.http.get<ResourceDto>(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, {headers: headers});\n }\n\n public delete(resourceId: string): Observable<any> {\n const headers = new HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');\n return this.http.delete(`${this.valtimoApiConfig.endpointUri}resource/${resourceId}`, {headers: headers});\n }\n\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Observable} from 'rxjs';\nimport {map, switchMap, tap} from 'rxjs/operators';\nimport {ResourceDto, ResourceFile, S3Resource, UploadService} from '@valtimo/contract';\nimport {Injectable} from '@angular/core';\nimport {v4 as uuidv4} from 'uuid';\nimport {S3Service} from './s3.service';\n\n@Injectable()\nexport class S3UploadService implements UploadService {\n\n constructor(\n private readonly s3Service: S3Service\n ) {\n }\n\n uploadFile(file: File): Observable<ResourceFile> {\n let resourceUrl: URL;\n const fileName = file.name;\n const splitFileName = fileName.split('.');\n const fileNameWithUUID = `${splitFileName[0]}-${uuidv4()}.${splitFileName[1]}`;\n const renamedFile = new File([file], fileNameWithUUID, {type: file.type});\n\n return this.s3Service.getPreSignedUrl(renamedFile.name).pipe(\n map((url) => new URL(url)),\n tap((url) => resourceUrl = url),\n switchMap((url) => this.s3Service.upload(url, renamedFile)),\n map(() => new S3Resource(file, resourceUrl)),\n switchMap((s3Resource) => this.s3Service.registerResource(s3Resource)),\n switchMap((s3Resource) => this.s3Service.get(s3Resource.id)),\n map((result) => ({...result, originalName: file.name})),\n map((result) => this.getResourceFile(result))\n );\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.s3Service.get(resourceId);\n }\n\n private getResourceFile(result: ResourceDto): ResourceFile {\n return {\n customUpload: true,\n originalName: result.originalName,\n url: result.url,\n size: result.resource.sizeInBytes,\n storage: 'url',\n type: result.resource.extension,\n data: {\n key: result.resource.key,\n bucketName: result.resource.name,\n createdOn: result.resource.createdOn as any as string,\n name: result.originalName,\n sizeInBytes: result.resource.sizeInBytes,\n resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1)\n }\n };\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable, Injector} from '@angular/core';\nimport {NGXLogger} from 'ngx-logger';\nimport {ResourceFile, UploadProvider, UploadService, ResourceDto} from '@valtimo/contract';\nimport {ConfigService} from '@valtimo/config';\nimport {Observable} from 'rxjs';\nimport {OpenZaakUploadService} from './open-zaak-upload.service';\nimport {S3UploadService} from './s3-upload.service';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class UploadProviderService implements UploadService {\n\n private readonly uploadService: UploadService;\n\n constructor(\n private configService: ConfigService,\n private injector: Injector,\n private logger: NGXLogger\n ) {\n this.uploadService = configService.config.uploadProvider === UploadProvider.S3 ?\n injector.get<UploadService>(S3UploadService)\n : injector.get<UploadService>(OpenZaakUploadService);\n this.logger.debug('Loading UploadService as', this.uploadService);\n }\n\n uploadFile(file: File, documentDefinitionName?: string): Observable<ResourceFile> {\n return this.uploadService.uploadFile(file, documentDefinitionName);\n }\n\n getResource(resourceId: string): Observable<ResourceDto> {\n return this.uploadService.getResource(resourceId);\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Injectable} from '@angular/core';\nimport {ConfigService} from '@valtimo/config';\nimport {HttpClient} from '@angular/common/http';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class DownloadService {\n\n constructor(\n private http: HttpClient,\n private configService: ConfigService\n ) { }\n\n downloadFile(url: string, name: string) {\n if (url.startsWith(this.configService.config.valtimoApi.endpointUri) || url.startsWith(window.location.origin)) {\n // if download url is on backend use angular to get the content so access token is used\n this.http.get(url, {responseType: 'blob'}).subscribe(content => {\n const downloadUrl = window.URL.createObjectURL(content);\n this.openDownloadLink(downloadUrl, name);\n });\n } else {\n // download links to external services (like amazon s3) open in a new window\n this.openDownloadLink(url, name);\n }\n }\n\n private openDownloadLink(url: string, name: string) {\n const link = document.createElement('a');\n link.href = url;\n link.download = name;\n link.target = '_blank';\n link.click();\n link.remove();\n }\n}\n","/*\n * Copyright 2015-2020 Ritense BV, the Netherlands.\n *\n * Licensed under EUPL, Version 1.2 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" basis,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {NgModule} from '@angular/core';\nimport {OpenZaakUploadService} from './services/open-zaak-upload.service';\nimport {S3UploadService} from './services/s3-upload.service';\nimport {UploadProviderService} from './services/upload-provider.service';\nimport {OpenZaakService} from './services/open-zaak.service';\nimport {S3Service} from './services/s3.service';\nimport {DownloadService} from './services/download.service';\n\n@NgModule({\n declarations: [],\n imports: [\n ],\n exports: [],\n providers: [OpenZaakUploadService, S3UploadService, UploadProviderService, OpenZaakService, S3Service, DownloadService]\n})\nexport class ResourceModule { }\n"]}