@valtimo/resource 4.15.2-next-main.15 → 4.15.3-next-main.16

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.
@@ -4,403 +4,415 @@
4
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
5
  }(this, (function (exports, i0, i1, i2, operators, contract, uuid, i2$1) { 'use strict';
6
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.getZaakTypes = function () {
36
- return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/zaaktype");
37
- };
38
- OpenZaakService.prototype.getInformatieObjectTypes = function () {
39
- return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-typen/" + this.catalogus);
40
- };
41
- OpenZaakService.prototype.getZaakTypeLink = function (id) {
42
- return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id);
43
- };
44
- OpenZaakService.prototype.getInformatieObjectTypeLink = function (id) {
45
- return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link/" + id);
46
- };
47
- OpenZaakService.prototype.createZaakTypeLink = function (request) {
48
- return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/link", request);
49
- };
50
- OpenZaakService.prototype.createInformatieObjectTypeLink = function (request) {
51
- return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link", request);
52
- };
53
- OpenZaakService.prototype.deleteZaakTypeLink = function (id) {
54
- return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id);
55
- };
56
- OpenZaakService.prototype.deleteInformatieObjectTypeLink = function (id) {
57
- return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link/" + id);
58
- };
59
- OpenZaakService.prototype.getZaakTypeLinkListByProcess = function (processDefinitionKey) {
60
- return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/link/process/" + processDefinitionKey);
61
- };
62
- OpenZaakService.prototype.getStatusTypes = function (zaakTypeRequest) {
63
- return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/status", zaakTypeRequest);
64
- };
65
- OpenZaakService.prototype.getStatusResults = function (zaakTypeRequest) {
66
- return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/resultaat", zaakTypeRequest);
67
- };
68
- OpenZaakService.prototype.createServiceTaskHandler = function (id, request) {
69
- return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler", request);
70
- };
71
- OpenZaakService.prototype.modifyServiceTaskHandler = function (id, request) {
72
- return this.http.put(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler", request);
73
- };
74
- OpenZaakService.prototype.deleteServiceTaskHandler = function (id, processDefinitionKey, serviceTaskId) {
75
- return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler/" + processDefinitionKey + "/" + serviceTaskId);
76
- };
77
- OpenZaakService.prototype.upload = function (file, documentDefinitionName) {
78
- var formData = new FormData();
79
- formData.append('file', file);
80
- formData.append('documentDefinitionName', documentDefinitionName);
81
- return this.http.post(this.valtimoApiConfig.endpointUri + "resource/upload-open-zaak", formData, {
82
- reportProgress: true,
83
- responseType: 'json'
84
- });
85
- };
86
- return OpenZaakService;
87
- }());
88
- OpenZaakService.ɵprov = i0.ɵɵdefineInjectable({ factory: function OpenZaakService_Factory() { return new OpenZaakService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: OpenZaakService, providedIn: "root" });
89
- OpenZaakService.decorators = [
90
- { type: i0.Injectable, args: [{
91
- providedIn: 'root'
92
- },] }
93
- ];
94
- OpenZaakService.ctorParameters = function () { return [
95
- { type: i1.HttpClient },
96
- { type: i2.ConfigService }
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.getZaakTypes = function () {
36
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/zaaktype");
37
+ };
38
+ OpenZaakService.prototype.getInformatieObjectTypes = function () {
39
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-typen/" + this.catalogus);
40
+ };
41
+ OpenZaakService.prototype.getZaakTypeLink = function (id) {
42
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id);
43
+ };
44
+ OpenZaakService.prototype.getInformatieObjectTypeLink = function (id) {
45
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link/" + id);
46
+ };
47
+ OpenZaakService.prototype.createZaakTypeLink = function (request) {
48
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/link", request);
49
+ };
50
+ OpenZaakService.prototype.createInformatieObjectTypeLink = function (request) {
51
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link", request);
52
+ };
53
+ OpenZaakService.prototype.deleteZaakTypeLink = function (id) {
54
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id);
55
+ };
56
+ OpenZaakService.prototype.deleteInformatieObjectTypeLink = function (id) {
57
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/informatie-object-type-link/" + id);
58
+ };
59
+ OpenZaakService.prototype.getZaakTypeLinkListByProcess = function (processDefinitionKey) {
60
+ return this.http.get(this.valtimoApiConfig.endpointUri + "openzaak/link/process/" + processDefinitionKey);
61
+ };
62
+ OpenZaakService.prototype.getStatusTypes = function (zaakTypeRequest) {
63
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/status", zaakTypeRequest);
64
+ };
65
+ OpenZaakService.prototype.getStatusResults = function (zaakTypeRequest) {
66
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/resultaat", zaakTypeRequest);
67
+ };
68
+ OpenZaakService.prototype.createServiceTaskHandler = function (id, request) {
69
+ return this.http.post(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler", request);
70
+ };
71
+ OpenZaakService.prototype.modifyServiceTaskHandler = function (id, request) {
72
+ return this.http.put(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler", request);
73
+ };
74
+ OpenZaakService.prototype.deleteServiceTaskHandler = function (id, processDefinitionKey, serviceTaskId) {
75
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "openzaak/link/" + id + "/service-handler/" + processDefinitionKey + "/" + serviceTaskId);
76
+ };
77
+ OpenZaakService.prototype.upload = function (file, documentDefinitionName) {
78
+ var formData = new FormData();
79
+ formData.append('file', file);
80
+ formData.append('documentDefinitionName', documentDefinitionName);
81
+ return this.http.post(this.valtimoApiConfig.endpointUri + "resource/upload-open-zaak", formData, {
82
+ reportProgress: true,
83
+ responseType: 'json',
84
+ });
85
+ };
86
+ return OpenZaakService;
87
+ }());
88
+ OpenZaakService.ɵprov = i0.ɵɵdefineInjectable({ factory: function OpenZaakService_Factory() { return new OpenZaakService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: OpenZaakService, providedIn: "root" });
89
+ OpenZaakService.decorators = [
90
+ { type: i0.Injectable, args: [{
91
+ providedIn: 'root',
92
+ },] }
93
+ ];
94
+ OpenZaakService.ctorParameters = function () { return [
95
+ { type: i1.HttpClient },
96
+ { type: i2.ConfigService }
97
97
  ]; };
98
98
 
99
- /*
100
- * Copyright 2015-2020 Ritense BV, the Netherlands.
101
- *
102
- * Licensed under EUPL, Version 1.2 (the "License");
103
- * you may not use this file except in compliance with the License.
104
- * You may obtain a copy of the License at
105
- *
106
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
107
- *
108
- * Unless required by applicable law or agreed to in writing, software
109
- * distributed under the License is distributed on an "AS IS" basis,
110
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111
- * See the License for the specific language governing permissions and
112
- * limitations under the License.
113
- */
114
- var OpenZaakUploadService = /** @class */ (function () {
115
- function OpenZaakUploadService(openZaakService, http, configService) {
116
- this.openZaakService = openZaakService;
117
- this.http = http;
118
- this.configService = configService;
119
- this.valtimoApiConfig = configService.config.valtimoApi;
120
- }
121
- OpenZaakUploadService.prototype.uploadFile = function (file, documentDefinitionName) {
122
- var _this = this;
123
- return this.openZaakService.upload(new File([file], file.name, { type: file.type }), documentDefinitionName).pipe(operators.map(function (result) { return _this.getResourceFile(result); }));
124
- };
125
- OpenZaakUploadService.prototype.getResource = function (resourceId) {
126
- return this.openZaakService.getResource(resourceId);
127
- };
128
- OpenZaakUploadService.prototype.getResourceFile = function (result) {
129
- return {
130
- customUpload: true,
131
- originalName: result.name,
132
- size: result.sizeInBytes,
133
- url: '/api/resource/' + result.resourceId + '/download',
134
- storage: 'openZaak',
135
- type: result.extension,
136
- data: {
137
- createdOn: result.createdOn,
138
- name: result.name,
139
- sizeInBytes: result.sizeInBytes,
140
- resourceId: result.resourceId,
141
- extension: result.extension
142
- }
143
- };
144
- };
145
- return OpenZaakUploadService;
146
- }());
147
- OpenZaakUploadService.decorators = [
148
- { type: i0.Injectable }
149
- ];
150
- OpenZaakUploadService.ctorParameters = function () { return [
151
- { type: OpenZaakService },
152
- { type: i1.HttpClient },
153
- { type: i2.ConfigService }
99
+ /*
100
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
101
+ *
102
+ * Licensed under EUPL, Version 1.2 (the "License");
103
+ * you may not use this file except in compliance with the License.
104
+ * You may obtain a copy of the License at
105
+ *
106
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
107
+ *
108
+ * Unless required by applicable law or agreed to in writing, software
109
+ * distributed under the License is distributed on an "AS IS" basis,
110
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
111
+ * See the License for the specific language governing permissions and
112
+ * limitations under the License.
113
+ */
114
+ var OpenZaakUploadService = /** @class */ (function () {
115
+ function OpenZaakUploadService(openZaakService, http, configService) {
116
+ this.openZaakService = openZaakService;
117
+ this.http = http;
118
+ this.configService = configService;
119
+ this.valtimoApiConfig = configService.config.valtimoApi;
120
+ }
121
+ OpenZaakUploadService.prototype.uploadFile = function (file, documentDefinitionName) {
122
+ var _this = this;
123
+ return this.openZaakService
124
+ .upload(new File([file], file.name, { type: file.type }), documentDefinitionName)
125
+ .pipe(operators.map(function (result) { return _this.getResourceFile(result); }));
126
+ };
127
+ OpenZaakUploadService.prototype.getResource = function (resourceId) {
128
+ return this.openZaakService.getResource(resourceId);
129
+ };
130
+ OpenZaakUploadService.prototype.getResourceFile = function (result) {
131
+ return {
132
+ customUpload: true,
133
+ originalName: result.name,
134
+ size: result.sizeInBytes,
135
+ url: '/api/resource/' + result.resourceId + '/download',
136
+ storage: 'openZaak',
137
+ type: result.extension,
138
+ data: {
139
+ createdOn: result.createdOn,
140
+ name: result.name,
141
+ sizeInBytes: result.sizeInBytes,
142
+ resourceId: result.resourceId,
143
+ extension: result.extension,
144
+ },
145
+ };
146
+ };
147
+ return OpenZaakUploadService;
148
+ }());
149
+ OpenZaakUploadService.decorators = [
150
+ { type: i0.Injectable }
151
+ ];
152
+ OpenZaakUploadService.ctorParameters = function () { return [
153
+ { type: OpenZaakService },
154
+ { type: i1.HttpClient },
155
+ { type: i2.ConfigService }
154
156
  ]; };
155
157
 
156
- /*
157
- * Copyright 2015-2020 Ritense BV, the Netherlands.
158
- *
159
- * Licensed under EUPL, Version 1.2 (the "License");
160
- * you may not use this file except in compliance with the License.
161
- * You may obtain a copy of the License at
162
- *
163
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
164
- *
165
- * Unless required by applicable law or agreed to in writing, software
166
- * distributed under the License is distributed on an "AS IS" basis,
167
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
168
- * See the License for the specific language governing permissions and
169
- * limitations under the License.
170
- */
171
- var S3Service = /** @class */ (function () {
172
- function S3Service(http, configService) {
173
- this.http = http;
174
- this.configService = configService;
175
- this.valtimoApiConfig = configService.config.valtimoApi;
176
- }
177
- S3Service.prototype.getPreSignedUrl = function (fileName) {
178
- var headers = new i1.HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
179
- var options = { headers: headers, responseType: 'text' };
180
- return this.http.get(this.valtimoApiConfig.endpointUri + "resource/pre-signed-url/" + fileName, options);
181
- };
182
- S3Service.prototype.upload = function (url, file) {
183
- var headers = new i1.HttpHeaders()
184
- .set('Content-Type', file.type);
185
- return this.http.put(url.toString(), file, { headers: headers });
186
- };
187
- S3Service.prototype.registerResource = function (s3ResourceDTO) {
188
- return this.http.put(this.valtimoApiConfig.endpointUri + "resource", s3ResourceDTO);
189
- };
190
- S3Service.prototype.get = function (resourceId) {
191
- var headers = new i1.HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
192
- return this.http.get(this.valtimoApiConfig.endpointUri + "resource/" + resourceId, { headers: headers });
193
- };
194
- S3Service.prototype.delete = function (resourceId) {
195
- var headers = new i1.HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
196
- return this.http.delete(this.valtimoApiConfig.endpointUri + "resource/" + resourceId, { headers: headers });
197
- };
198
- return S3Service;
199
- }());
200
- S3Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function S3Service_Factory() { return new S3Service(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: S3Service, providedIn: "root" });
201
- S3Service.decorators = [
202
- { type: i0.Injectable, args: [{
203
- providedIn: 'root'
204
- },] }
205
- ];
206
- S3Service.ctorParameters = function () { return [
207
- { type: i1.HttpClient },
208
- { type: i2.ConfigService }
158
+ /*
159
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
160
+ *
161
+ * Licensed under EUPL, Version 1.2 (the "License");
162
+ * you may not use this file except in compliance with the License.
163
+ * You may obtain a copy of the License at
164
+ *
165
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
166
+ *
167
+ * Unless required by applicable law or agreed to in writing, software
168
+ * distributed under the License is distributed on an "AS IS" basis,
169
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
170
+ * See the License for the specific language governing permissions and
171
+ * limitations under the License.
172
+ */
173
+ var S3Service = /** @class */ (function () {
174
+ function S3Service(http, configService) {
175
+ this.http = http;
176
+ this.configService = configService;
177
+ this.valtimoApiConfig = configService.config.valtimoApi;
178
+ }
179
+ S3Service.prototype.getPreSignedUrl = function (fileName) {
180
+ var headers = new i1.HttpHeaders().set('Content-Type', 'text/plain; charset=utf-8');
181
+ var options = { headers: headers, responseType: 'text' };
182
+ return this.http.get(this.valtimoApiConfig.endpointUri + "resource/pre-signed-url/" + fileName, options);
183
+ };
184
+ S3Service.prototype.upload = function (url, file) {
185
+ var headers = new i1.HttpHeaders().set('Content-Type', file.type);
186
+ return this.http.put(url.toString(), file, { headers: headers });
187
+ };
188
+ S3Service.prototype.registerResource = function (s3ResourceDTO) {
189
+ return this.http.put(this.valtimoApiConfig.endpointUri + "resource", s3ResourceDTO);
190
+ };
191
+ S3Service.prototype.get = function (resourceId) {
192
+ var headers = new i1.HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
193
+ return this.http.get(this.valtimoApiConfig.endpointUri + "resource/" + resourceId, { headers: headers });
194
+ };
195
+ S3Service.prototype.delete = function (resourceId) {
196
+ var headers = new i1.HttpHeaders().set('Content-Type', 'application/json;charset=UTF-8');
197
+ return this.http.delete(this.valtimoApiConfig.endpointUri + "resource/" + resourceId, {
198
+ headers: headers,
199
+ });
200
+ };
201
+ return S3Service;
202
+ }());
203
+ S3Service.ɵprov = i0.ɵɵdefineInjectable({ factory: function S3Service_Factory() { return new S3Service(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: S3Service, providedIn: "root" });
204
+ S3Service.decorators = [
205
+ { type: i0.Injectable, args: [{
206
+ providedIn: 'root',
207
+ },] }
208
+ ];
209
+ S3Service.ctorParameters = function () { return [
210
+ { type: i1.HttpClient },
211
+ { type: i2.ConfigService }
209
212
  ]; };
210
213
 
211
- /*
212
- * Copyright 2015-2020 Ritense BV, the Netherlands.
213
- *
214
- * Licensed under EUPL, Version 1.2 (the "License");
215
- * you may not use this file except in compliance with the License.
216
- * You may obtain a copy of the License at
217
- *
218
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
219
- *
220
- * Unless required by applicable law or agreed to in writing, software
221
- * distributed under the License is distributed on an "AS IS" basis,
222
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
223
- * See the License for the specific language governing permissions and
224
- * limitations under the License.
225
- */
226
- var S3UploadService = /** @class */ (function () {
227
- function S3UploadService(s3Service) {
228
- this.s3Service = s3Service;
229
- }
230
- S3UploadService.prototype.uploadFile = function (file) {
231
- var _this = this;
232
- var resourceUrl;
233
- var fileName = file.name;
234
- var splitFileName = fileName.split('.');
235
- var fileNameWithUUID = splitFileName[0] + "-" + uuid.v4() + "." + splitFileName[1];
236
- var renamedFile = new File([file], fileNameWithUUID, { type: file.type });
237
- 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); }));
238
- };
239
- S3UploadService.prototype.getResource = function (resourceId) {
240
- return this.s3Service.get(resourceId);
241
- };
242
- S3UploadService.prototype.getResourceFile = function (result) {
243
- return {
244
- customUpload: true,
245
- originalName: result.originalName,
246
- url: result.url,
247
- size: result.resource.sizeInBytes,
248
- storage: 'url',
249
- type: result.resource.extension,
250
- data: {
251
- key: result.resource.key,
252
- bucketName: result.resource.name,
253
- createdOn: result.resource.createdOn,
254
- name: result.originalName,
255
- sizeInBytes: result.resource.sizeInBytes,
256
- resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1)
257
- }
258
- };
259
- };
260
- return S3UploadService;
261
- }());
262
- S3UploadService.decorators = [
263
- { type: i0.Injectable }
264
- ];
265
- S3UploadService.ctorParameters = function () { return [
266
- { type: S3Service }
214
+ /*
215
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
216
+ *
217
+ * Licensed under EUPL, Version 1.2 (the "License");
218
+ * you may not use this file except in compliance with the License.
219
+ * You may obtain a copy of the License at
220
+ *
221
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
222
+ *
223
+ * Unless required by applicable law or agreed to in writing, software
224
+ * distributed under the License is distributed on an "AS IS" basis,
225
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
226
+ * See the License for the specific language governing permissions and
227
+ * limitations under the License.
228
+ */
229
+ var S3UploadService = /** @class */ (function () {
230
+ function S3UploadService(s3Service) {
231
+ this.s3Service = s3Service;
232
+ }
233
+ S3UploadService.prototype.uploadFile = function (file) {
234
+ var _this = this;
235
+ var resourceUrl;
236
+ var fileName = file.name;
237
+ var splitFileName = fileName.split('.');
238
+ var fileNameWithUUID = splitFileName[0] + "-" + uuid.v4() + "." + splitFileName[1];
239
+ var renamedFile = new File([file], fileNameWithUUID, { type: file.type });
240
+ 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); }));
241
+ };
242
+ S3UploadService.prototype.getResource = function (resourceId) {
243
+ return this.s3Service.get(resourceId);
244
+ };
245
+ S3UploadService.prototype.getResourceFile = function (result) {
246
+ return {
247
+ customUpload: true,
248
+ originalName: result.originalName,
249
+ url: result.url,
250
+ size: result.resource.sizeInBytes,
251
+ storage: 'url',
252
+ type: result.resource.extension,
253
+ data: {
254
+ key: result.resource.key,
255
+ bucketName: result.resource.name,
256
+ createdOn: result.resource.createdOn,
257
+ name: result.originalName,
258
+ sizeInBytes: result.resource.sizeInBytes,
259
+ resourceId: result.resource.id.split('ResourceId(id=')[1].slice(0, -1),
260
+ },
261
+ };
262
+ };
263
+ return S3UploadService;
264
+ }());
265
+ S3UploadService.decorators = [
266
+ { type: i0.Injectable }
267
+ ];
268
+ S3UploadService.ctorParameters = function () { return [
269
+ { type: S3Service }
267
270
  ]; };
268
271
 
269
- /*
270
- * Copyright 2015-2020 Ritense BV, the Netherlands.
271
- *
272
- * Licensed under EUPL, Version 1.2 (the "License");
273
- * you may not use this file except in compliance with the License.
274
- * You may obtain a copy of the License at
275
- *
276
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
277
- *
278
- * Unless required by applicable law or agreed to in writing, software
279
- * distributed under the License is distributed on an "AS IS" basis,
280
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
281
- * See the License for the specific language governing permissions and
282
- * limitations under the License.
283
- */
284
- var UploadProviderService = /** @class */ (function () {
285
- function UploadProviderService(configService, injector, logger) {
286
- this.configService = configService;
287
- this.injector = injector;
288
- this.logger = logger;
289
- this.uploadService = configService.config.uploadProvider === contract.UploadProvider.S3 ?
290
- injector.get(S3UploadService)
291
- : injector.get(OpenZaakUploadService);
292
- this.logger.debug('Loading UploadService as', this.uploadService);
293
- }
294
- UploadProviderService.prototype.uploadFile = function (file, documentDefinitionName) {
295
- return this.uploadService.uploadFile(file, documentDefinitionName);
296
- };
297
- UploadProviderService.prototype.getResource = function (resourceId) {
298
- return this.uploadService.getResource(resourceId);
299
- };
300
- return UploadProviderService;
301
- }());
302
- 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" });
303
- UploadProviderService.decorators = [
304
- { type: i0.Injectable, args: [{
305
- providedIn: 'root'
306
- },] }
307
- ];
308
- UploadProviderService.ctorParameters = function () { return [
309
- { type: i2.ConfigService },
310
- { type: i0.Injector },
311
- { type: i2$1.NGXLogger }
272
+ /*
273
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
274
+ *
275
+ * Licensed under EUPL, Version 1.2 (the "License");
276
+ * you may not use this file except in compliance with the License.
277
+ * You may obtain a copy of the License at
278
+ *
279
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
280
+ *
281
+ * Unless required by applicable law or agreed to in writing, software
282
+ * distributed under the License is distributed on an "AS IS" basis,
283
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
+ * See the License for the specific language governing permissions and
285
+ * limitations under the License.
286
+ */
287
+ var UploadProviderService = /** @class */ (function () {
288
+ function UploadProviderService(configService, injector, logger) {
289
+ this.configService = configService;
290
+ this.injector = injector;
291
+ this.logger = logger;
292
+ this.uploadService =
293
+ configService.config.uploadProvider === contract.UploadProvider.S3
294
+ ? injector.get(S3UploadService)
295
+ : injector.get(OpenZaakUploadService);
296
+ this.logger.debug('Loading UploadService as', this.uploadService);
297
+ }
298
+ UploadProviderService.prototype.uploadFile = function (file, documentDefinitionName) {
299
+ return this.uploadService.uploadFile(file, documentDefinitionName);
300
+ };
301
+ UploadProviderService.prototype.getResource = function (resourceId) {
302
+ return this.uploadService.getResource(resourceId);
303
+ };
304
+ return UploadProviderService;
305
+ }());
306
+ 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" });
307
+ UploadProviderService.decorators = [
308
+ { type: i0.Injectable, args: [{
309
+ providedIn: 'root',
310
+ },] }
311
+ ];
312
+ UploadProviderService.ctorParameters = function () { return [
313
+ { type: i2.ConfigService },
314
+ { type: i0.Injector },
315
+ { type: i2$1.NGXLogger }
312
316
  ]; };
313
317
 
314
- /*
315
- * Copyright 2015-2020 Ritense BV, the Netherlands.
316
- *
317
- * Licensed under EUPL, Version 1.2 (the "License");
318
- * you may not use this file except in compliance with the License.
319
- * You may obtain a copy of the License at
320
- *
321
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
322
- *
323
- * Unless required by applicable law or agreed to in writing, software
324
- * distributed under the License is distributed on an "AS IS" basis,
325
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
326
- * See the License for the specific language governing permissions and
327
- * limitations under the License.
328
- */
329
- var DownloadService = /** @class */ (function () {
330
- function DownloadService(http, configService) {
331
- this.http = http;
332
- this.configService = configService;
333
- }
334
- DownloadService.prototype.downloadFile = function (url, name) {
335
- var _this = this;
336
- if (url.startsWith(this.configService.config.valtimoApi.endpointUri) || url.startsWith(window.location.origin)) {
337
- // if download url is on backend use angular to get the content so access token is used
338
- this.http.get(url, { responseType: 'blob' }).subscribe(function (content) {
339
- var downloadUrl = window.URL.createObjectURL(content);
340
- _this.openDownloadLink(downloadUrl, name);
341
- });
342
- }
343
- else {
344
- // download links to external services (like amazon s3) open in a new window
345
- this.openDownloadLink(url, name);
346
- }
347
- };
348
- DownloadService.prototype.openDownloadLink = function (url, name) {
349
- var link = document.createElement('a');
350
- link.href = url;
351
- link.download = name;
352
- link.target = '_blank';
353
- link.click();
354
- link.remove();
355
- };
356
- return DownloadService;
357
- }());
358
- DownloadService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DownloadService_Factory() { return new DownloadService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: DownloadService, providedIn: "root" });
359
- DownloadService.decorators = [
360
- { type: i0.Injectable, args: [{
361
- providedIn: 'root'
362
- },] }
363
- ];
364
- DownloadService.ctorParameters = function () { return [
365
- { type: i1.HttpClient },
366
- { type: i2.ConfigService }
318
+ /*
319
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
320
+ *
321
+ * Licensed under EUPL, Version 1.2 (the "License");
322
+ * you may not use this file except in compliance with the License.
323
+ * You may obtain a copy of the License at
324
+ *
325
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
326
+ *
327
+ * Unless required by applicable law or agreed to in writing, software
328
+ * distributed under the License is distributed on an "AS IS" basis,
329
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
330
+ * See the License for the specific language governing permissions and
331
+ * limitations under the License.
332
+ */
333
+ var DownloadService = /** @class */ (function () {
334
+ function DownloadService(http, configService) {
335
+ this.http = http;
336
+ this.configService = configService;
337
+ }
338
+ DownloadService.prototype.downloadFile = function (url, name) {
339
+ var _this = this;
340
+ if (url.startsWith(this.configService.config.valtimoApi.endpointUri) ||
341
+ url.startsWith(window.location.origin)) {
342
+ // if download url is on backend use angular to get the content so access token is used
343
+ this.http.get(url, { responseType: 'blob' }).subscribe(function (content) {
344
+ var downloadUrl = window.URL.createObjectURL(content);
345
+ _this.openDownloadLink(downloadUrl, name);
346
+ });
347
+ }
348
+ else {
349
+ // download links to external services (like amazon s3) open in a new window
350
+ this.openDownloadLink(url, name);
351
+ }
352
+ };
353
+ DownloadService.prototype.openDownloadLink = function (url, name) {
354
+ var link = document.createElement('a');
355
+ link.href = url;
356
+ link.download = name;
357
+ link.target = '_blank';
358
+ link.click();
359
+ link.remove();
360
+ };
361
+ return DownloadService;
362
+ }());
363
+ DownloadService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DownloadService_Factory() { return new DownloadService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i2.ConfigService)); }, token: DownloadService, providedIn: "root" });
364
+ DownloadService.decorators = [
365
+ { type: i0.Injectable, args: [{
366
+ providedIn: 'root',
367
+ },] }
368
+ ];
369
+ DownloadService.ctorParameters = function () { return [
370
+ { type: i1.HttpClient },
371
+ { type: i2.ConfigService }
367
372
  ]; };
368
373
 
369
- /*
370
- * Copyright 2015-2020 Ritense BV, the Netherlands.
371
- *
372
- * Licensed under EUPL, Version 1.2 (the "License");
373
- * you may not use this file except in compliance with the License.
374
- * You may obtain a copy of the License at
375
- *
376
- * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
377
- *
378
- * Unless required by applicable law or agreed to in writing, software
379
- * distributed under the License is distributed on an "AS IS" basis,
380
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
381
- * See the License for the specific language governing permissions and
382
- * limitations under the License.
383
- */
384
- var ResourceModule = /** @class */ (function () {
385
- function ResourceModule() {
386
- }
387
- return ResourceModule;
388
- }());
389
- ResourceModule.decorators = [
390
- { type: i0.NgModule, args: [{
391
- declarations: [],
392
- imports: [],
393
- exports: [],
394
- providers: [OpenZaakUploadService, S3UploadService, UploadProviderService, OpenZaakService, S3Service, DownloadService]
395
- },] }
374
+ /*
375
+ * Copyright 2015-2020 Ritense BV, the Netherlands.
376
+ *
377
+ * Licensed under EUPL, Version 1.2 (the "License");
378
+ * you may not use this file except in compliance with the License.
379
+ * You may obtain a copy of the License at
380
+ *
381
+ * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
382
+ *
383
+ * Unless required by applicable law or agreed to in writing, software
384
+ * distributed under the License is distributed on an "AS IS" basis,
385
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
386
+ * See the License for the specific language governing permissions and
387
+ * limitations under the License.
388
+ */
389
+ var ResourceModule = /** @class */ (function () {
390
+ function ResourceModule() {
391
+ }
392
+ return ResourceModule;
393
+ }());
394
+ ResourceModule.decorators = [
395
+ { type: i0.NgModule, args: [{
396
+ declarations: [],
397
+ imports: [],
398
+ exports: [],
399
+ providers: [
400
+ OpenZaakUploadService,
401
+ S3UploadService,
402
+ UploadProviderService,
403
+ OpenZaakService,
404
+ S3Service,
405
+ DownloadService,
406
+ ],
407
+ },] }
396
408
  ];
397
409
 
398
- /*
399
- * Public API Surface of upload
410
+ /*
411
+ * Public API Surface of upload
400
412
  */
401
413
 
402
- /**
403
- * Generated bundle index. Do not edit.
414
+ /**
415
+ * Generated bundle index. Do not edit.
404
416
  */
405
417
 
406
418
  exports.DownloadService = DownloadService;