|
| 1 | +export interface DatasetVersionSummary { |
| 2 | + id: number |
| 3 | + versionNumber: string |
| 4 | + summary?: Summary | SummaryStringValues |
| 5 | + contributors: string |
| 6 | + publishedOn?: string |
| 7 | +} |
| 8 | + |
| 9 | +export type Summary = { |
| 10 | + [key: string]: SummaryUpdates | SummaryUpdatesWithFields | FilesSummaryUpdates | boolean |
| 11 | +} |
| 12 | + |
| 13 | +export interface SummaryUpdates { |
| 14 | + added: string // deberia ser number chequear |
| 15 | + deleted: string |
| 16 | + changed: string |
| 17 | +} |
| 18 | + |
| 19 | +export interface SummaryUpdatesWithFields { |
| 20 | + [key: string]: SummaryUpdates |
| 21 | +} |
| 22 | + |
| 23 | +export interface FilesSummaryUpdates { |
| 24 | + added: number |
| 25 | + removed: number |
| 26 | + replaced: number |
| 27 | + changedFileMetaData: number |
| 28 | + changedVariableMetadata: number |
| 29 | +} |
| 30 | + |
| 31 | +export enum SummaryStringValues { |
| 32 | + firstPublished = 'firstPublished', |
| 33 | + firstDraft = 'firstDraft', |
| 34 | + versionDeaccessioned = 'versionDeaccessioned', |
| 35 | + previousVersionDeaccessioned = 'previousVersionDeaccessioned' |
| 36 | +} |
| 37 | + |
| 38 | +export enum SummaryKnownFields { |
| 39 | + files = 'files', |
| 40 | + termsAccessChanged = 'termsAccessChanged' |
| 41 | +} |
| 42 | + |
| 43 | +// SummaryUpdates Example: |
| 44 | +/* |
| 45 | + summary: { |
| 46 | + "Geospatial Metadata": { |
| 47 | + added: 1, |
| 48 | + deleted: 0, |
| 49 | + changed: 0 |
| 50 | + }, |
| 51 | + } |
| 52 | +*/ |
| 53 | + |
| 54 | +// SummaryUpdatesWithFields Example: |
| 55 | +/* |
| 56 | + summary: { |
| 57 | + 'Citation Metadata': { |
| 58 | + Description: { |
| 59 | + added: 0, |
| 60 | + deleted: 0, |
| 61 | + changed: 1 |
| 62 | + }, |
| 63 | + Title: { |
| 64 | + added: 0, |
| 65 | + deleted: 0, |
| 66 | + changed: 1 |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | +*/ |
| 71 | + |
| 72 | +// FilesSummaryUpdates Example: |
| 73 | +/* |
| 74 | + summary: { |
| 75 | + files: { |
| 76 | + added: 1, |
| 77 | + removed: 0, |
| 78 | + replaced: 0, |
| 79 | + changedFileMetaData: 2, |
| 80 | + changedVariableMetadata: 0 |
| 81 | + }, |
| 82 | + } |
| 83 | +*/ |
| 84 | + |
| 85 | +const version: DatasetVersionSummary = { |
| 86 | + id: 1, |
| 87 | + versionNumber: '1.0', |
| 88 | + contributors: 'John Doe', |
| 89 | + publishedOn: '2021-06-01', |
| 90 | + summary: { |
| 91 | + files: { |
| 92 | + added: 1, |
| 93 | + changedFileMetaData: 2, |
| 94 | + removed: 0, |
| 95 | + replaced: 0, |
| 96 | + changedVariableMetadata: 0 |
| 97 | + }, |
| 98 | + 'Citation Metadata': { |
| 99 | + Title: { |
| 100 | + added: '0', |
| 101 | + deleted: '0', |
| 102 | + changed: '1' |
| 103 | + } |
| 104 | + }, |
| 105 | + termsAccessChanged: true |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | +console.log({ |
| 110 | + typeof: typeof ( |
| 111 | + (version.summary as Summary)?.['Citation Metadata'] as SummaryUpdatesWithFields |
| 112 | + )?.['Title'].changed |
| 113 | +}) |
| 114 | + |
| 115 | +// console.log({ typeof: typeof (version.summary as SummaryChanges)?.['Title'].changed }) |
0 commit comments