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

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,403 @@
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.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 }
154
154
  ]; };
155
155
 
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 }
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 }
209
209
  ]; };
210
210
 
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 }
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 }
267
267
  ]; };
268
268
 
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 }
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 }
312
312
  ]; };
313
313
 
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 }
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 }
367
367
  ]; };
368
368
 
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
- },] }
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
+ },] }
396
396
  ];
397
397
 
398
- /*
399
- * Public API Surface of upload
398
+ /*
399
+ * Public API Surface of upload
400
400
  */
401
401
 
402
- /**
403
- * Generated bundle index. Do not edit.
402
+ /**
403
+ * Generated bundle index. Do not edit.
404
404
  */
405
405
 
406
406
  exports.DownloadService = DownloadService;