@noatgnu/cupcake-vanilla 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1179 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Component } from '@angular/core';
3
+ import { BaseApiService } from '@cupcake/core';
4
+ import { from, Observable } from 'rxjs';
5
+ import { switchMap } from 'rxjs/operators';
6
+ import jsSHA from 'jssha';
7
+
8
+ var OntologyType;
9
+ (function (OntologyType) {
10
+ OntologyType["SPECIES"] = "species";
11
+ OntologyType["TISSUE"] = "tissue";
12
+ OntologyType["HUMAN_DISEASE"] = "human_disease";
13
+ OntologyType["SUBCELLULAR_LOCATION"] = "subcellular_location";
14
+ OntologyType["UNIMOD"] = "unimod";
15
+ OntologyType["NCBI_TAXONOMY"] = "ncbi_taxonomy";
16
+ OntologyType["MONDO"] = "mondo";
17
+ OntologyType["UBERON"] = "uberon";
18
+ OntologyType["CHEBI"] = "chebi";
19
+ OntologyType["CELL_ONTOLOGY"] = "cell_ontology";
20
+ OntologyType["MS_UNIQUE_VOCABULARIES"] = "ms_unique_vocabularies";
21
+ OntologyType["PSI_MS"] = "psi_ms";
22
+ })(OntologyType || (OntologyType = {}));
23
+ const OntologyTypeLabels = {
24
+ [OntologyType.SPECIES]: 'Species',
25
+ [OntologyType.TISSUE]: 'Tissue',
26
+ [OntologyType.HUMAN_DISEASE]: 'Human Disease',
27
+ [OntologyType.SUBCELLULAR_LOCATION]: 'Subcellular Location',
28
+ [OntologyType.UNIMOD]: 'Unimod Modifications',
29
+ [OntologyType.NCBI_TAXONOMY]: 'NCBI Taxonomy',
30
+ [OntologyType.MONDO]: 'MONDO Disease',
31
+ [OntologyType.UBERON]: 'UBERON Anatomy',
32
+ [OntologyType.CHEBI]: 'ChEBI',
33
+ [OntologyType.CELL_ONTOLOGY]: 'Cell Ontology',
34
+ [OntologyType.MS_UNIQUE_VOCABULARIES]: 'MS Unique Vocabularies',
35
+ [OntologyType.PSI_MS]: 'PSI-MS Controlled Vocabulary'
36
+ };
37
+ var TemplatePermissionLevel;
38
+ (function (TemplatePermissionLevel) {
39
+ TemplatePermissionLevel["READ"] = "read";
40
+ TemplatePermissionLevel["WRITE"] = "write";
41
+ TemplatePermissionLevel["ADMIN"] = "admin";
42
+ })(TemplatePermissionLevel || (TemplatePermissionLevel = {}));
43
+ const TemplatePermissionLabels = {
44
+ [TemplatePermissionLevel.READ]: 'Read Only',
45
+ [TemplatePermissionLevel.WRITE]: 'Read & Write',
46
+ [TemplatePermissionLevel.ADMIN]: 'Administrator'
47
+ };
48
+
49
+ function isUnimodFullData(suggestion) {
50
+ return suggestion &&
51
+ suggestion.ontology_type === 'unimod' &&
52
+ !!suggestion.full_data;
53
+ }
54
+ class OntologyUtils {
55
+ static getUnimodSpecifications(suggestion) {
56
+ if (!isUnimodFullData(suggestion))
57
+ return [];
58
+ return Object.entries(suggestion.full_data.specifications).map(([specNum, spec]) => ({
59
+ ...spec,
60
+ specNumber: specNum
61
+ }));
62
+ }
63
+ static getActiveUnimodSpecifications(suggestion) {
64
+ return this.getUnimodSpecifications(suggestion).filter(spec => !spec['hidden']);
65
+ }
66
+ static formatUnimodName(data) {
67
+ return `${data.name} (${data.accession})`;
68
+ }
69
+ }
70
+
71
+ // Helper constants
72
+ const TASK_TYPE_LABELS = {
73
+ 'EXPORT_EXCEL': 'Export Excel Template',
74
+ 'EXPORT_SDRF': 'Export SDRF File',
75
+ 'IMPORT_SDRF': 'Import SDRF File',
76
+ 'IMPORT_EXCEL': 'Import Excel File',
77
+ 'EXPORT_MULTIPLE_SDRF': 'Export Multiple SDRF Files',
78
+ 'EXPORT_MULTIPLE_EXCEL': 'Export Multiple Excel Templates',
79
+ 'VALIDATE_TABLE': 'Validate Metadata Table',
80
+ };
81
+ const TASK_STATUS_LABELS = {
82
+ 'QUEUED': 'Queued',
83
+ 'STARTED': 'In Progress',
84
+ 'SUCCESS': 'Completed',
85
+ 'FAILURE': 'Failed',
86
+ 'CANCELLED': 'Cancelled',
87
+ };
88
+ const TASK_STATUS_COLORS = {
89
+ 'QUEUED': 'secondary',
90
+ 'STARTED': 'primary',
91
+ 'SUCCESS': 'success',
92
+ 'FAILURE': 'danger',
93
+ 'CANCELLED': 'warning',
94
+ };
95
+
96
+ class MetadataTableService extends BaseApiService {
97
+ /**
98
+ * Get all metadata tables with optional filtering
99
+ */
100
+ getMetadataTables(params) {
101
+ const httpParams = this.buildHttpParams(params);
102
+ return this.get(`${this.apiUrl}/metadata-tables/`, { params: httpParams });
103
+ }
104
+ /**
105
+ * Get a single metadata table by ID
106
+ */
107
+ getMetadataTable(id) {
108
+ return this.get(`${this.apiUrl}/metadata-tables/${id}/`);
109
+ }
110
+ /**
111
+ * Create a new metadata table
112
+ */
113
+ createMetadataTable(table) {
114
+ return this.post(`${this.apiUrl}/metadata-tables/`, table);
115
+ }
116
+ /**
117
+ * Update an existing metadata table
118
+ */
119
+ updateMetadataTable(id, table) {
120
+ return this.put(`${this.apiUrl}/metadata-tables/${id}/`, table);
121
+ }
122
+ /**
123
+ * Partially update a metadata table
124
+ */
125
+ patchMetadataTable(id, table) {
126
+ return this.patch(`${this.apiUrl}/metadata-tables/${id}/`, table);
127
+ }
128
+ /**
129
+ * Delete a metadata table
130
+ */
131
+ deleteMetadataTable(id) {
132
+ return this.delete(`${this.apiUrl}/metadata-tables/${id}/`);
133
+ }
134
+ /**
135
+ * Add a column to the metadata table
136
+ */
137
+ addColumn(id, columnData, position) {
138
+ return this.post(`${this.apiUrl}/metadata-tables/${id}/add_column/`, {
139
+ column_data: columnData,
140
+ position
141
+ });
142
+ }
143
+ /**
144
+ * Add a column with automatic reordering
145
+ */
146
+ addColumnWithAutoReorder(id, request) {
147
+ return this.post(`${this.apiUrl}/metadata-tables/${id}/add_column_with_auto_reorder/`, request);
148
+ }
149
+ /**
150
+ * Remove a column from the metadata table
151
+ */
152
+ removeColumn(id, columnId) {
153
+ return this.post(`${this.apiUrl}/metadata-tables/${id}/remove_column/`, {
154
+ column_id: columnId
155
+ });
156
+ }
157
+ /**
158
+ * Reorder a column in the metadata table
159
+ */
160
+ reorderColumn(id, columnId, newPosition) {
161
+ return this.post(`${this.apiUrl}/metadata-tables/${id}/reorder_column/`, {
162
+ column_id: columnId,
163
+ new_position: newPosition
164
+ });
165
+ }
166
+ /**
167
+ * Normalize column positions
168
+ */
169
+ normalizeColumnPositions(id) {
170
+ return this.post(`${this.apiUrl}/metadata-tables/${id}/normalize_column_positions/`, {});
171
+ }
172
+ /**
173
+ * Get all tables (admin only)
174
+ */
175
+ getAdminAllTables() {
176
+ return this.get(`${this.apiUrl}/metadata-tables/admin_all_tables/`);
177
+ }
178
+ /**
179
+ * Search metadata tables
180
+ */
181
+ searchMetadataTables(query) {
182
+ return this.getMetadataTables({ search: query });
183
+ }
184
+ /**
185
+ * Get metadata tables by owner
186
+ */
187
+ getMetadataTablesByOwner(ownerId) {
188
+ return this.getMetadataTables({ ownerId: ownerId });
189
+ }
190
+ /**
191
+ * Get shared metadata tables
192
+ */
193
+ getSharedMetadataTables() {
194
+ return this.getMetadataTables({ showShared: true });
195
+ }
196
+ /**
197
+ * Combine columns column-wise
198
+ */
199
+ combineColumnwise(request) {
200
+ return this.post(`${this.apiUrl}/metadata-tables/combine_columnwise/`, request);
201
+ }
202
+ /**
203
+ * Combine columns row-wise
204
+ */
205
+ combineRowwise(request) {
206
+ return this.post(`${this.apiUrl}/metadata-tables/combine_rowwise/`, request);
207
+ }
208
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataTableService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
209
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataTableService, providedIn: 'root' });
210
+ }
211
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataTableService, decorators: [{
212
+ type: Injectable,
213
+ args: [{
214
+ providedIn: 'root'
215
+ }]
216
+ }] });
217
+
218
+ class MetadataColumnService extends BaseApiService {
219
+ /**
220
+ * Get all metadata columns with optional filtering
221
+ */
222
+ getMetadataColumns(params) {
223
+ const httpParams = this.buildHttpParams(params);
224
+ return this.get(`${this.apiUrl}/metadata-columns/`, { params: httpParams });
225
+ }
226
+ /**
227
+ * Get a single metadata column by ID
228
+ */
229
+ getMetadataColumn(id) {
230
+ return this.get(`${this.apiUrl}/metadata-columns/${id}/`);
231
+ }
232
+ /**
233
+ * Create a new metadata column
234
+ */
235
+ createMetadataColumn(column) {
236
+ return this.post(`${this.apiUrl}/metadata-columns/`, column);
237
+ }
238
+ /**
239
+ * Update an existing metadata column
240
+ */
241
+ updateMetadataColumn(id, column) {
242
+ return this.put(`${this.apiUrl}/metadata-columns/${id}/`, column);
243
+ }
244
+ /**
245
+ * Partially update a metadata column
246
+ */
247
+ patchMetadataColumn(id, column) {
248
+ return this.patch(`${this.apiUrl}/metadata-columns/${id}/`, column);
249
+ }
250
+ /**
251
+ * Delete a metadata column
252
+ */
253
+ deleteMetadataColumn(id) {
254
+ return this.delete(`${this.apiUrl}/metadata-columns/${id}/`);
255
+ }
256
+ /**
257
+ * Bulk create metadata columns
258
+ */
259
+ bulkCreate(request) {
260
+ return this.post(`${this.apiUrl}/metadata-columns/bulk_create/`, request);
261
+ }
262
+ /**
263
+ * Validate SDRF data
264
+ */
265
+ validateSdrfData(request) {
266
+ return this.post(`${this.apiUrl}/metadata-columns/validate_sdrf_data/`, request);
267
+ }
268
+ /**
269
+ * Get ontology suggestions for a column
270
+ */
271
+ getOntologySuggestions(params) {
272
+ const httpParams = this.buildHttpParams(params);
273
+ return this.get(`${this.apiUrl}/metadata-columns/ontology_suggestions/`, { params: httpParams });
274
+ }
275
+ /**
276
+ * Validate value against column's ontology
277
+ */
278
+ validateValue(id, request) {
279
+ return this.post(`${this.apiUrl}/metadata-columns/${id}/validate_value/`, request);
280
+ }
281
+ /**
282
+ * Update column value with automatic modifier calculation
283
+ */
284
+ updateColumnValue(id, request) {
285
+ return this.post(`${this.apiUrl}/metadata-columns/${id}/update_column_value/`, request);
286
+ }
287
+ /**
288
+ * Apply automatic ontology mapping to a column
289
+ */
290
+ applyOntologyMapping(id) {
291
+ return this.post(`${this.apiUrl}/metadata-columns/${id}/apply_ontology_mapping/`, {});
292
+ }
293
+ /**
294
+ * Detect ontology type for given column name and type
295
+ */
296
+ detectOntologyType(params) {
297
+ const httpParams = this.buildHttpParams(params);
298
+ return this.get(`${this.apiUrl}/metadata-columns/detect_ontology_type/`, { params: httpParams });
299
+ }
300
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
301
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnService, providedIn: 'root' });
302
+ }
303
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnService, decorators: [{
304
+ type: Injectable,
305
+ args: [{
306
+ providedIn: 'root'
307
+ }]
308
+ }] });
309
+
310
+ class SamplePoolService extends BaseApiService {
311
+ /**
312
+ * Get all sample pools with optional filtering
313
+ */
314
+ getSamplePools(params) {
315
+ const httpParams = this.buildHttpParams(params);
316
+ return this.get(`${this.apiUrl}/sample-pools/`, { params: httpParams });
317
+ }
318
+ /**
319
+ * Get a single sample pool by ID
320
+ */
321
+ getSamplePool(id) {
322
+ return this.get(`${this.apiUrl}/sample-pools/${id}/`);
323
+ }
324
+ /**
325
+ * Create a new sample pool
326
+ */
327
+ createSamplePool(pool) {
328
+ return this.post(`${this.apiUrl}/sample-pools/`, pool);
329
+ }
330
+ /**
331
+ * Update an existing sample pool
332
+ */
333
+ updateSamplePool(id, pool) {
334
+ return this.put(`${this.apiUrl}/sample-pools/${id}/`, pool);
335
+ }
336
+ /**
337
+ * Partially update a sample pool
338
+ */
339
+ patchSamplePool(id, pool) {
340
+ return this.patch(`${this.apiUrl}/sample-pools/${id}/`, pool);
341
+ }
342
+ /**
343
+ * Delete a sample pool
344
+ */
345
+ deleteSamplePool(id) {
346
+ return this.delete(`${this.apiUrl}/sample-pools/${id}/`);
347
+ }
348
+ /**
349
+ * Get metadata columns associated with this pool
350
+ */
351
+ getMetadataColumns(id) {
352
+ return this.get(`${this.apiUrl}/sample-pools/${id}/metadata_columns/`);
353
+ }
354
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SamplePoolService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
355
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SamplePoolService, providedIn: 'root' });
356
+ }
357
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SamplePoolService, decorators: [{
358
+ type: Injectable,
359
+ args: [{
360
+ providedIn: 'root'
361
+ }]
362
+ }] });
363
+
364
+ class MetadataTableTemplateService extends BaseApiService {
365
+ /**
366
+ * Get all metadata table templates with optional filtering
367
+ */
368
+ getMetadataTableTemplates(params) {
369
+ const httpParams = this.buildHttpParams(params);
370
+ return this.get(`${this.apiUrl}/metadata-table-templates/`, { params: httpParams });
371
+ }
372
+ /**
373
+ * Get a single metadata table template by ID
374
+ */
375
+ getMetadataTableTemplate(id) {
376
+ return this.get(`${this.apiUrl}/metadata-table-templates/${id}/`);
377
+ }
378
+ /**
379
+ * Create a new metadata table template
380
+ */
381
+ createMetadataTableTemplate(template) {
382
+ return this.post(`${this.apiUrl}/metadata-table-templates/`, template);
383
+ }
384
+ /**
385
+ * Update an existing metadata table template
386
+ */
387
+ updateMetadataTableTemplate(id, template) {
388
+ return this.put(`${this.apiUrl}/metadata-table-templates/${id}/`, template);
389
+ }
390
+ /**
391
+ * Partially update a metadata table template
392
+ */
393
+ patchMetadataTableTemplate(id, template) {
394
+ return this.patch(`${this.apiUrl}/metadata-table-templates/${id}/`, template);
395
+ }
396
+ /**
397
+ * Delete a metadata table template
398
+ */
399
+ deleteMetadataTableTemplate(id) {
400
+ return this.delete(`${this.apiUrl}/metadata-table-templates/${id}/`);
401
+ }
402
+ /**
403
+ * Add a column to the template
404
+ */
405
+ addColumn(id, request) {
406
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/add_column/`, request);
407
+ }
408
+ /**
409
+ * Remove a column from the template
410
+ */
411
+ removeColumn(id, request) {
412
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/remove_column/`, request);
413
+ }
414
+ /**
415
+ * Reorder a column within the template
416
+ */
417
+ reorderColumn(id, request) {
418
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/reorder_column/`, request);
419
+ }
420
+ /**
421
+ * Add a column with automatic reordering
422
+ */
423
+ addColumnWithAutoReorder(id, request) {
424
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/add_column_with_auto_reorder/`, request);
425
+ }
426
+ /**
427
+ * Duplicate a column within the template
428
+ */
429
+ duplicateColumn(id, request) {
430
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/duplicate_column/`, request);
431
+ }
432
+ /**
433
+ * Normalize column positions
434
+ */
435
+ normalizeColumnPositions(id) {
436
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/normalize_column_positions/`, {});
437
+ }
438
+ /**
439
+ * Apply this template to a metadata table
440
+ */
441
+ applyToMetadataTable(id, request) {
442
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/apply_to_metadata_table/`, request);
443
+ }
444
+ /**
445
+ * Update field mask for template
446
+ */
447
+ updateFieldMask(id, request) {
448
+ return this.post(`${this.apiUrl}/metadata-table-templates/${id}/update_field_mask/`, request);
449
+ }
450
+ /**
451
+ * Get field mask for template
452
+ */
453
+ getFieldMask(id) {
454
+ return this.get(`${this.apiUrl}/metadata-table-templates/${id}/get_field_mask/`);
455
+ }
456
+ /**
457
+ * Get columns with field masks
458
+ */
459
+ getColumnsWithFieldMasks(id) {
460
+ return this.get(`${this.apiUrl}/metadata-table-templates/${id}/get_columns_with_field_masks/`);
461
+ }
462
+ /**
463
+ * Get available schemas for creating templates
464
+ */
465
+ getAvailableSchemas() {
466
+ return this.get(`${this.apiUrl}/metadata-table-templates/available_schemas/`);
467
+ }
468
+ /**
469
+ * Create a new template from schema definitions
470
+ */
471
+ createFromSchema(request) {
472
+ return this.post(`${this.apiUrl}/metadata-table-templates/create_from_schema/`, request);
473
+ }
474
+ /**
475
+ * Create a new metadata table from an existing template
476
+ */
477
+ createTableFromTemplate(request) {
478
+ return this.post(`${this.apiUrl}/metadata-table-templates/create_table_from_template/`, request);
479
+ }
480
+ /**
481
+ * Create a new metadata table directly from schema definitions
482
+ */
483
+ createTableFromSchemas(request) {
484
+ return this.post(`${this.apiUrl}/metadata-table-templates/create_table_from_schemas/`, request);
485
+ }
486
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataTableTemplateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
487
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataTableTemplateService, providedIn: 'root' });
488
+ }
489
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataTableTemplateService, decorators: [{
490
+ type: Injectable,
491
+ args: [{
492
+ providedIn: 'root'
493
+ }]
494
+ }] });
495
+
496
+ class FavouriteMetadataOptionService extends BaseApiService {
497
+ /**
498
+ * Get all favourite metadata options with optional filtering
499
+ */
500
+ getFavouriteMetadataOptions(params) {
501
+ const httpParams = this.buildHttpParams(params);
502
+ return this.get(`${this.apiUrl}/favourite-metadata-options/`, { params: httpParams });
503
+ }
504
+ /**
505
+ * Get a single favourite metadata option by ID
506
+ */
507
+ getFavouriteMetadataOption(id) {
508
+ return this.get(`${this.apiUrl}/favourite-metadata-options/${id}/`);
509
+ }
510
+ /**
511
+ * Create a new favourite metadata option
512
+ */
513
+ createFavouriteMetadataOption(option) {
514
+ return this.post(`${this.apiUrl}/favourite-metadata-options/`, option);
515
+ }
516
+ /**
517
+ * Update an existing favourite metadata option
518
+ */
519
+ updateFavouriteMetadataOption(id, option) {
520
+ return this.put(`${this.apiUrl}/favourite-metadata-options/${id}/`, option);
521
+ }
522
+ /**
523
+ * Partially update a favourite metadata option
524
+ */
525
+ patchFavouriteMetadataOption(id, option) {
526
+ return this.patch(`${this.apiUrl}/favourite-metadata-options/${id}/`, option);
527
+ }
528
+ /**
529
+ * Delete a favourite metadata option
530
+ */
531
+ deleteFavouriteMetadataOption(id) {
532
+ return this.delete(`${this.apiUrl}/favourite-metadata-options/${id}/`);
533
+ }
534
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: FavouriteMetadataOptionService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
535
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: FavouriteMetadataOptionService, providedIn: 'root' });
536
+ }
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: FavouriteMetadataOptionService, decorators: [{
538
+ type: Injectable,
539
+ args: [{
540
+ providedIn: 'root'
541
+ }]
542
+ }] });
543
+
544
+ class MetadataColumnTemplateService extends BaseApiService {
545
+ /**
546
+ * Get all metadata column templates with optional filtering
547
+ */
548
+ getMetadataColumnTemplates(params) {
549
+ const httpParams = this.buildHttpParams(params);
550
+ return this.get(`${this.apiUrl}/metadata-column-templates/`, { params: httpParams });
551
+ }
552
+ /**
553
+ * Get a single metadata column template by ID
554
+ */
555
+ getMetadataColumnTemplate(id) {
556
+ return this.get(`${this.apiUrl}/metadata-column-templates/${id}/`);
557
+ }
558
+ /**
559
+ * Create a new metadata column template
560
+ */
561
+ createMetadataColumnTemplate(template) {
562
+ return this.post(`${this.apiUrl}/metadata-column-templates/`, template);
563
+ }
564
+ /**
565
+ * Update an existing metadata column template
566
+ */
567
+ updateMetadataColumnTemplate(id, template) {
568
+ return this.put(`${this.apiUrl}/metadata-column-templates/${id}/`, template);
569
+ }
570
+ /**
571
+ * Partially update a metadata column template
572
+ */
573
+ patchMetadataColumnTemplate(id, template) {
574
+ return this.patch(`${this.apiUrl}/metadata-column-templates/${id}/`, template);
575
+ }
576
+ /**
577
+ * Delete a metadata column template
578
+ */
579
+ deleteMetadataColumnTemplate(id) {
580
+ return this.delete(`${this.apiUrl}/metadata-column-templates/${id}/`);
581
+ }
582
+ /**
583
+ * Create a MetadataColumn from this template
584
+ */
585
+ createMetadataColumn(id, request) {
586
+ return this.post(`${this.apiUrl}/metadata-column-templates/${id}/create_metadata_column/`, request);
587
+ }
588
+ /**
589
+ * Share this template with another user
590
+ */
591
+ shareTemplate(id, request) {
592
+ return this.post(`${this.apiUrl}/metadata-column-templates/${id}/share_template/`, request);
593
+ }
594
+ /**
595
+ * Remove template sharing for a user
596
+ */
597
+ unshareTemplate(id, request) {
598
+ return this.delete(`${this.apiUrl}/metadata-column-templates/${id}/unshare_template/`, { body: request });
599
+ }
600
+ /**
601
+ * Get templates created by the current user
602
+ */
603
+ getMyTemplates() {
604
+ return this.get(`${this.apiUrl}/metadata-column-templates/my_templates/`);
605
+ }
606
+ /**
607
+ * Get most popular public templates
608
+ */
609
+ getPopularTemplates() {
610
+ return this.get(`${this.apiUrl}/metadata-column-templates/popular_templates/`);
611
+ }
612
+ /**
613
+ * Get ontology suggestions for this column template
614
+ */
615
+ getOntologySuggestions(params) {
616
+ const httpParams = this.buildHttpParams({
617
+ template_id: params?.templateId,
618
+ search: params?.search,
619
+ limit: params?.limit,
620
+ search_type: params?.searchType
621
+ });
622
+ return this.get(`${this.apiUrl}/metadata-column-templates/ontology_suggestions/`, { params: httpParams });
623
+ }
624
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnTemplateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
625
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnTemplateService, providedIn: 'root' });
626
+ }
627
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnTemplateService, decorators: [{
628
+ type: Injectable,
629
+ args: [{
630
+ providedIn: 'root'
631
+ }]
632
+ }] });
633
+
634
+ class MetadataColumnTemplateShareService extends BaseApiService {
635
+ /**
636
+ * Get all template shares with optional filtering
637
+ */
638
+ getMetadataColumnTemplateShares(params) {
639
+ const httpParams = this.buildHttpParams(params);
640
+ return this.get(`${this.apiUrl}/metadata-column-template-shares/`, { params: httpParams });
641
+ }
642
+ /**
643
+ * Get a single template share by ID
644
+ */
645
+ getMetadataColumnTemplateShare(id) {
646
+ return this.get(`${this.apiUrl}/metadata-column-template-shares/${id}/`);
647
+ }
648
+ /**
649
+ * Create a new template share
650
+ */
651
+ createMetadataColumnTemplateShare(share) {
652
+ return this.post(`${this.apiUrl}/metadata-column-template-shares/`, share);
653
+ }
654
+ /**
655
+ * Update an existing template share
656
+ */
657
+ updateMetadataColumnTemplateShare(id, share) {
658
+ return this.put(`${this.apiUrl}/metadata-column-template-shares/${id}/`, share);
659
+ }
660
+ /**
661
+ * Delete a template share
662
+ */
663
+ deleteMetadataColumnTemplateShare(id) {
664
+ return this.delete(`${this.apiUrl}/metadata-column-template-shares/${id}/`);
665
+ }
666
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnTemplateShareService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
667
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnTemplateShareService, providedIn: 'root' });
668
+ }
669
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataColumnTemplateShareService, decorators: [{
670
+ type: Injectable,
671
+ args: [{
672
+ providedIn: 'root'
673
+ }]
674
+ }] });
675
+
676
+ class MetadataManagementService extends BaseApiService {
677
+ /**
678
+ * Export metadata as Excel template (matching original CUPCAKE)
679
+ */
680
+ exportExcelTemplate(request) {
681
+ return this.post(`${this.apiUrl}/metadata-management/export_excel_template/`, request, { responseType: 'blob' });
682
+ }
683
+ /**
684
+ * Import metadata from SDRF file with intelligent column matching and schema organization
685
+ */
686
+ importSdrfFile(file, additionalData) {
687
+ const formData = new FormData();
688
+ formData.append('file', file);
689
+ if (additionalData) {
690
+ Object.keys(additionalData).forEach(key => {
691
+ formData.append(key, additionalData[key]);
692
+ });
693
+ }
694
+ return this.post(`${this.apiUrl}/metadata-management/import_sdrf_file/`, formData);
695
+ }
696
+ /**
697
+ * Import metadata from Excel file (matching original CUPCAKE)
698
+ */
699
+ importExcelFile(file, additionalData) {
700
+ const formData = new FormData();
701
+ formData.append('file', file);
702
+ if (additionalData) {
703
+ Object.keys(additionalData).forEach(key => {
704
+ formData.append(key, additionalData[key]);
705
+ });
706
+ }
707
+ return this.post(`${this.apiUrl}/metadata-management/import_excel_file/`, formData);
708
+ }
709
+ /**
710
+ * Collect metadata from metadata table
711
+ */
712
+ collectMetadata(params) {
713
+ const httpParams = this.buildHttpParams(params);
714
+ return this.get(`${this.apiUrl}/metadata-management/collect_metadata/`, { params: httpParams });
715
+ }
716
+ /**
717
+ * Export metadata as SDRF file (matching original CUPCAKE)
718
+ */
719
+ exportSdrfFile(request) {
720
+ return this.post(`${this.apiUrl}/metadata-management/export_sdrf_file/`, request, { responseType: 'blob' });
721
+ }
722
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataManagementService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
723
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataManagementService, providedIn: 'root' });
724
+ }
725
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: MetadataManagementService, decorators: [{
726
+ type: Injectable,
727
+ args: [{
728
+ providedIn: 'root'
729
+ }]
730
+ }] });
731
+
732
+ class OntologySearchService extends BaseApiService {
733
+ /**
734
+ * Get ontology suggestions across all sources for SDRF validation
735
+ */
736
+ suggest(params) {
737
+ const httpParams = this.buildHttpParams(params);
738
+ return this.get(`${this.apiUrl}/ontology-search/suggest/`, { params: httpParams });
739
+ }
740
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: OntologySearchService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
741
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: OntologySearchService, providedIn: 'root' });
742
+ }
743
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: OntologySearchService, decorators: [{
744
+ type: Injectable,
745
+ args: [{
746
+ providedIn: 'root'
747
+ }]
748
+ }] });
749
+
750
+ class SchemaService extends BaseApiService {
751
+ /**
752
+ * Get all schemas with optional filtering
753
+ */
754
+ getSchemas(params) {
755
+ const httpParams = this.buildHttpParams(params);
756
+ return this.get(`${this.apiUrl}/schemas/`, { params: httpParams });
757
+ }
758
+ /**
759
+ * Get a single schema by ID
760
+ */
761
+ getSchema(id) {
762
+ return this.get(`${this.apiUrl}/schemas/${id}/`);
763
+ }
764
+ /**
765
+ * Get list of available schemas for creating templates
766
+ */
767
+ getAvailableSchemas() {
768
+ return this.get(`${this.apiUrl}/schemas/available/`);
769
+ }
770
+ /**
771
+ * Sync builtin schemas from sdrf-pipelines package (admin only)
772
+ */
773
+ syncBuiltin() {
774
+ return this.post(`${this.apiUrl}/schemas/sync_builtin/`, {});
775
+ }
776
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SchemaService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
777
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SchemaService, providedIn: 'root' });
778
+ }
779
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SchemaService, decorators: [{
780
+ type: Injectable,
781
+ args: [{
782
+ providedIn: 'root'
783
+ }]
784
+ }] });
785
+
786
+ class SDRFDefaultsService extends BaseApiService {
787
+ /**
788
+ * Get all available SDRF columns with their default values
789
+ */
790
+ getColumns() {
791
+ return this.get(`${this.apiUrl}/sdrf-defaults/columns/`);
792
+ }
793
+ /**
794
+ * Get default values for a specific column
795
+ */
796
+ getColumnValues(params) {
797
+ const httpParams = this.buildHttpParams(params);
798
+ return this.get(`${this.apiUrl}/sdrf-defaults/column_values/`, { params: httpParams });
799
+ }
800
+ /**
801
+ * Search for columns containing the query string
802
+ */
803
+ searchColumns(params) {
804
+ const httpParams = this.buildHttpParams(params);
805
+ return this.get(`${this.apiUrl}/sdrf-defaults/search/`, { params: httpParams });
806
+ }
807
+ /**
808
+ * Get options for structured fields (key-value pairs)
809
+ */
810
+ getStructuredOptions(params) {
811
+ const httpParams = this.buildHttpParams(params);
812
+ return this.get(`${this.apiUrl}/sdrf-defaults/structured_options/`, { params: httpParams });
813
+ }
814
+ /**
815
+ * Get all label options (TMT, SILAC, label-free)
816
+ */
817
+ getLabels() {
818
+ return this.get(`${this.apiUrl}/sdrf-defaults/labels/`);
819
+ }
820
+ /**
821
+ * Get protein modification options (fixed and variable)
822
+ */
823
+ getModifications() {
824
+ return this.get(`${this.apiUrl}/sdrf-defaults/modifications/`);
825
+ }
826
+ /**
827
+ * Get list of common instrument models
828
+ */
829
+ getInstruments() {
830
+ return this.get(`${this.apiUrl}/sdrf-defaults/instruments/`);
831
+ }
832
+ /**
833
+ * Get cleavage agent options
834
+ */
835
+ getCleavageAgents() {
836
+ return this.get(`${this.apiUrl}/sdrf-defaults/cleavage_agents/`);
837
+ }
838
+ /**
839
+ * Get all compound fields that require special handling
840
+ */
841
+ getCompoundFields() {
842
+ return this.get(`${this.apiUrl}/sdrf-defaults/compound_fields/`);
843
+ }
844
+ /**
845
+ * Get schema for a specific compound field
846
+ */
847
+ getCompoundSchema(params) {
848
+ const httpParams = this.buildHttpParams(params);
849
+ return this.get(`${this.apiUrl}/sdrf-defaults/compound_schema/`, { params: httpParams });
850
+ }
851
+ /**
852
+ * Validate a compound field value against its schema
853
+ */
854
+ validateCompound(request) {
855
+ return this.post(`${this.apiUrl}/sdrf-defaults/validate_compound/`, request);
856
+ }
857
+ /**
858
+ * Get column name suggestions based on partial input
859
+ */
860
+ getSuggestions(params) {
861
+ const httpParams = this.buildHttpParams(params);
862
+ return this.get(`${this.apiUrl}/sdrf-defaults/suggestions/`, { params: httpParams });
863
+ }
864
+ /**
865
+ * Get quick access to commonly used value categories
866
+ */
867
+ getQuickValues() {
868
+ return this.get(`${this.apiUrl}/sdrf-defaults/quick_values/`);
869
+ }
870
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SDRFDefaultsService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
871
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SDRFDefaultsService, providedIn: 'root' });
872
+ }
873
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: SDRFDefaultsService, decorators: [{
874
+ type: Injectable,
875
+ args: [{
876
+ providedIn: 'root'
877
+ }]
878
+ }] });
879
+
880
+ class AsyncTaskService extends BaseApiService {
881
+ /**
882
+ * Get all async tasks for the current user with optional filtering
883
+ */
884
+ getAsyncTasks(params) {
885
+ const httpParams = this.buildHttpParams(params);
886
+ return this.get(`${this.apiUrl}/async-tasks/`, { params: httpParams });
887
+ }
888
+ /**
889
+ * Get a specific async task by ID
890
+ */
891
+ getAsyncTask(id) {
892
+ return this.get(`${this.apiUrl}/async-tasks/${id}/`);
893
+ }
894
+ /**
895
+ * Cancel a queued or running task
896
+ */
897
+ cancelTask(id) {
898
+ return this.delete(`${this.apiUrl}/async-tasks/${id}/cancel/`);
899
+ }
900
+ /**
901
+ * Generate a signed download URL for task result file
902
+ */
903
+ getDownloadUrl(id) {
904
+ return this.get(`${this.apiUrl}/async-tasks/${id}/download_url/`);
905
+ }
906
+ /**
907
+ * Direct download endpoint (returns blob for file download)
908
+ */
909
+ downloadTaskFile(id, token) {
910
+ const httpParams = this.buildHttpParams({ token });
911
+ return this.get(`${this.apiUrl}/async-tasks/${id}/download/`, { params: httpParams, responseType: 'blob' });
912
+ }
913
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncTaskService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
914
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncTaskService, providedIn: 'root' });
915
+ }
916
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncTaskService, decorators: [{
917
+ type: Injectable,
918
+ args: [{
919
+ providedIn: 'root'
920
+ }]
921
+ }] });
922
+
923
+ class AsyncExportService extends BaseApiService {
924
+ excelTemplate(request) {
925
+ return this.post(`${this.apiUrl}/async-export/excel_template/`, request);
926
+ }
927
+ sdrfFile(request) {
928
+ return this.post(`${this.apiUrl}/async-export/sdrf_file/`, request);
929
+ }
930
+ multipleSdrfFiles(request) {
931
+ return this.post(`${this.apiUrl}/async-export/multiple_sdrf_files/`, request);
932
+ }
933
+ multipleExcelTemplates(request) {
934
+ return this.post(`${this.apiUrl}/async-export/multiple_excel_templates/`, request);
935
+ }
936
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncExportService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
937
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncExportService, providedIn: 'root' });
938
+ }
939
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncExportService, decorators: [{
940
+ type: Injectable,
941
+ args: [{
942
+ providedIn: 'root'
943
+ }]
944
+ }] });
945
+
946
+ class AsyncImportService extends BaseApiService {
947
+ /**
948
+ * Calculate SHA256 hash of a file
949
+ */
950
+ async calculateSHA256(file) {
951
+ const buffer = await file.arrayBuffer();
952
+ const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
953
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
954
+ const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
955
+ return hashHex;
956
+ }
957
+ sdrfFile(request) {
958
+ return from(this.calculateSHA256(request.file)).pipe(switchMap(sha256Hash => {
959
+ const formData = new FormData();
960
+ formData.append('metadata_table_id', request.metadataTableId.toString());
961
+ formData.append('file', request.file);
962
+ formData.append('sha256', sha256Hash);
963
+ if (request.replaceExisting !== undefined) {
964
+ formData.append('replace_existing', request.replaceExisting.toString());
965
+ }
966
+ if (request.validateOntologies !== undefined) {
967
+ formData.append('validate_ontologies', request.validateOntologies.toString());
968
+ }
969
+ return this.post(`${this.apiUrl}/async-import/sdrf_file/`, formData);
970
+ }));
971
+ }
972
+ excelFile(request) {
973
+ const formData = new FormData();
974
+ formData.append('metadata_table_id', request.metadataTableId.toString());
975
+ formData.append('file', request.file);
976
+ if (request.replaceExisting !== undefined) {
977
+ formData.append('replace_existing', request.replaceExisting.toString());
978
+ }
979
+ if (request.validateOntologies !== undefined) {
980
+ formData.append('validate_ontologies', request.validateOntologies.toString());
981
+ }
982
+ return this.post(`${this.apiUrl}/async-import/excel_file/`, formData);
983
+ }
984
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncImportService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
985
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncImportService, providedIn: 'root' });
986
+ }
987
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncImportService, decorators: [{
988
+ type: Injectable,
989
+ args: [{
990
+ providedIn: 'root'
991
+ }]
992
+ }] });
993
+
994
+ class AsyncValidationService extends BaseApiService {
995
+ metadataTable(request) {
996
+ return this.post(`${this.apiUrl}/async-validation/metadata_table/`, request);
997
+ }
998
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncValidationService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
999
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncValidationService, providedIn: 'root' });
1000
+ }
1001
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: AsyncValidationService, decorators: [{
1002
+ type: Injectable,
1003
+ args: [{
1004
+ providedIn: 'root'
1005
+ }]
1006
+ }] });
1007
+
1008
+ class ChunkedUploadService extends BaseApiService {
1009
+ /**
1010
+ * Initialize or continue a chunked upload
1011
+ */
1012
+ uploadChunk(request, uploadId, offset, totalSize) {
1013
+ const formData = new FormData();
1014
+ formData.append('file', request.file);
1015
+ if (request.filename) {
1016
+ formData.append('filename', request.filename);
1017
+ }
1018
+ if (request.uploadSessionId) {
1019
+ formData.append('upload_session_id', request.uploadSessionId);
1020
+ }
1021
+ if (request.metadataTableId) {
1022
+ formData.append('metadata_table_id', request.metadataTableId.toString());
1023
+ }
1024
+ if (request.createPools !== undefined) {
1025
+ formData.append('create_pools', request.createPools.toString());
1026
+ }
1027
+ if (request.replaceExisting !== undefined) {
1028
+ formData.append('replace_existing', request.replaceExisting.toString());
1029
+ }
1030
+ const url = uploadId
1031
+ ? `${this.apiUrl}/chunked-upload/${uploadId}/`
1032
+ : `${this.apiUrl}/chunked-upload/`;
1033
+ // Add Content-Range header for chunked uploads
1034
+ const headers = {};
1035
+ if (offset !== undefined && totalSize !== undefined) {
1036
+ const chunkEnd = offset + request.file.size - 1;
1037
+ headers['Content-Range'] = `bytes ${offset}-${chunkEnd}/${totalSize}`;
1038
+ }
1039
+ // Use POST for first chunk, PUT for subsequent chunks
1040
+ if (uploadId) {
1041
+ return this.put(url, formData, { headers });
1042
+ }
1043
+ else {
1044
+ return this.post(url, formData, { headers });
1045
+ }
1046
+ }
1047
+ /**
1048
+ * Get chunked upload status
1049
+ */
1050
+ getUploadStatus(uploadId) {
1051
+ return this.get(`${this.apiUrl}/chunked-upload/${uploadId}/`);
1052
+ }
1053
+ /**
1054
+ * Complete the chunked upload and process the file
1055
+ */
1056
+ completeUpload(uploadId, request) {
1057
+ const formData = new FormData();
1058
+ if (request?.sha256) {
1059
+ formData.append('sha256', request.sha256);
1060
+ }
1061
+ if (request?.metadataTableId) {
1062
+ formData.append('metadata_table_id', request.metadataTableId.toString());
1063
+ }
1064
+ if (request?.createPools !== undefined) {
1065
+ formData.append('create_pools', request.createPools.toString());
1066
+ }
1067
+ if (request?.replaceExisting !== undefined) {
1068
+ formData.append('replace_existing', request.replaceExisting.toString());
1069
+ }
1070
+ return this.post(`${this.apiUrl}/chunked-upload/${uploadId}/`, formData);
1071
+ }
1072
+ /**
1073
+ * Delete/cancel a chunked upload
1074
+ */
1075
+ cancelUpload(uploadId) {
1076
+ return this.delete(`${this.apiUrl}/chunked-upload/${uploadId}/`);
1077
+ }
1078
+ /**
1079
+ * Helper method to upload a file in chunks with progress tracking
1080
+ */
1081
+ uploadFileInChunks(file, chunkSize = 1024 * 1024, // 1MB chunks by default
1082
+ options) {
1083
+ return new Observable(subscriber => {
1084
+ let uploadId;
1085
+ let offset = 0;
1086
+ const totalSize = file.size;
1087
+ const sha256 = new jsSHA('SHA-256', 'ARRAYBUFFER');
1088
+ const uploadNextChunk = () => {
1089
+ if (offset >= totalSize) {
1090
+ // Upload complete, finalize with calculated hash
1091
+ if (uploadId) {
1092
+ const calculatedHash = sha256.getHash('HEX');
1093
+ this.completeUpload(uploadId, {
1094
+ sha256: calculatedHash,
1095
+ metadataTableId: options?.metadataTableId,
1096
+ createPools: options?.createPools,
1097
+ replaceExisting: options?.replaceExisting
1098
+ }).subscribe({
1099
+ next: (result) => {
1100
+ subscriber.next(result);
1101
+ subscriber.complete();
1102
+ },
1103
+ error: (error) => subscriber.error(error)
1104
+ });
1105
+ }
1106
+ else {
1107
+ subscriber.error(new Error('Upload failed: No upload ID'));
1108
+ }
1109
+ return;
1110
+ }
1111
+ const end = Math.min(offset + chunkSize, totalSize);
1112
+ const chunk = file.slice(offset, end);
1113
+ const chunkFile = new File([chunk], file.name, { type: file.type });
1114
+ // Add chunk to hash calculation
1115
+ chunk.arrayBuffer().then(arrayBuffer => {
1116
+ sha256.update(arrayBuffer);
1117
+ this.uploadChunk({
1118
+ file: chunkFile,
1119
+ filename: file.name,
1120
+ uploadSessionId: options?.uploadSessionId,
1121
+ metadataTableId: options?.metadataTableId,
1122
+ createPools: options?.createPools,
1123
+ replaceExisting: options?.replaceExisting
1124
+ }, uploadId, offset, totalSize).subscribe({
1125
+ next: (response) => {
1126
+ uploadId = response.id;
1127
+ offset = response.offset;
1128
+ // Report progress
1129
+ const progress = (offset / totalSize) * 100;
1130
+ if (options?.onProgress) {
1131
+ options.onProgress(progress);
1132
+ }
1133
+ // Upload next chunk
1134
+ uploadNextChunk();
1135
+ },
1136
+ error: (error) => subscriber.error(error)
1137
+ });
1138
+ }).catch(error => subscriber.error(error));
1139
+ };
1140
+ uploadNextChunk();
1141
+ });
1142
+ }
1143
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ChunkedUploadService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1144
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ChunkedUploadService, providedIn: 'root' });
1145
+ }
1146
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ChunkedUploadService, decorators: [{
1147
+ type: Injectable,
1148
+ args: [{
1149
+ providedIn: 'root'
1150
+ }]
1151
+ }] });
1152
+
1153
+ class CupcakeVanilla {
1154
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CupcakeVanilla, deps: [], target: i0.ɵɵFactoryTarget.Component });
1155
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.7", type: CupcakeVanilla, isStandalone: true, selector: "ccv-cupcake-vanilla", ngImport: i0, template: `
1156
+ <p>
1157
+ cupcake-vanilla works!
1158
+ </p>
1159
+ `, isInline: true, styles: [""] });
1160
+ }
1161
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CupcakeVanilla, decorators: [{
1162
+ type: Component,
1163
+ args: [{ selector: 'ccv-cupcake-vanilla', imports: [], template: `
1164
+ <p>
1165
+ cupcake-vanilla works!
1166
+ </p>
1167
+ ` }]
1168
+ }] });
1169
+
1170
+ /*
1171
+ * Public API Surface of cupcake-vanilla
1172
+ */
1173
+
1174
+ /**
1175
+ * Generated bundle index. Do not edit.
1176
+ */
1177
+
1178
+ export { AsyncExportService, AsyncImportService, AsyncTaskService, AsyncValidationService, ChunkedUploadService, CupcakeVanilla, FavouriteMetadataOptionService, MetadataColumnService, MetadataColumnTemplateService, MetadataColumnTemplateShareService, MetadataManagementService, MetadataTableService, MetadataTableTemplateService, OntologySearchService, OntologyType, OntologyTypeLabels, OntologyUtils, SDRFDefaultsService, SamplePoolService, SchemaService, TASK_STATUS_COLORS, TASK_STATUS_LABELS, TASK_TYPE_LABELS, TemplatePermissionLabels, TemplatePermissionLevel, isUnimodFullData };
1179
+ //# sourceMappingURL=noatgnu-cupcake-vanilla.mjs.map