@cyberismo/data-handler 0.0.14 → 0.0.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.
- package/dist/card-metadata-updater.js +8 -4
- package/dist/card-metadata-updater.js.map +1 -1
- package/dist/command-handler.d.ts +4 -0
- package/dist/command-handler.js +29 -19
- package/dist/command-handler.js.map +1 -1
- package/dist/command-manager.d.ts +25 -2
- package/dist/command-manager.js +30 -5
- package/dist/command-manager.js.map +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +45 -93
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/edit.d.ts +1 -15
- package/dist/commands/edit.js +15 -89
- package/dist/commands/edit.js.map +1 -1
- package/dist/commands/export.d.ts +11 -2
- package/dist/commands/export.js +58 -58
- package/dist/commands/export.js.map +1 -1
- package/dist/commands/import.d.ts +9 -1
- package/dist/commands/import.js +17 -11
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/move.d.ts +1 -2
- package/dist/commands/move.js +107 -146
- package/dist/commands/move.js.map +1 -1
- package/dist/commands/remove.d.ts +8 -1
- package/dist/commands/remove.js +17 -48
- package/dist/commands/remove.js.map +1 -1
- package/dist/commands/rename.d.ts +4 -9
- package/dist/commands/rename.js +34 -108
- package/dist/commands/rename.js.map +1 -1
- package/dist/commands/show.d.ts +22 -34
- package/dist/commands/show.js +103 -151
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/transition.d.ts +9 -2
- package/dist/commands/transition.js +49 -44
- package/dist/commands/transition.js.map +1 -1
- package/dist/commands/update.d.ts +18 -12
- package/dist/commands/update.js +34 -18
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/validate.d.ts +18 -10
- package/dist/commands/validate.js +101 -47
- package/dist/commands/validate.js.map +1 -1
- package/dist/containers/card-container.d.ts +87 -24
- package/dist/containers/card-container.js +183 -279
- package/dist/containers/card-container.js.map +1 -1
- package/dist/containers/project/calculation-engine.d.ts +13 -4
- package/dist/containers/project/calculation-engine.js +79 -77
- package/dist/containers/project/calculation-engine.js.map +1 -1
- package/dist/containers/project/card-cache.d.ts +146 -0
- package/dist/containers/project/card-cache.js +411 -0
- package/dist/containers/project/card-cache.js.map +1 -0
- package/dist/containers/project/project-paths.d.ts +5 -4
- package/dist/containers/project/project-paths.js +16 -12
- package/dist/containers/project/project-paths.js.map +1 -1
- package/dist/containers/project/resource-cache.d.ts +169 -0
- package/dist/containers/project/resource-cache.js +507 -0
- package/dist/containers/project/resource-cache.js.map +1 -0
- package/dist/containers/project/resource-handler.d.ts +129 -0
- package/dist/containers/project/resource-handler.js +206 -0
- package/dist/containers/project/resource-handler.js.map +1 -0
- package/dist/containers/project.d.ts +114 -195
- package/dist/containers/project.js +425 -535
- package/dist/containers/project.js.map +1 -1
- package/dist/containers/template.d.ts +22 -32
- package/dist/containers/template.js +113 -115
- package/dist/containers/template.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/folder-content-interfaces.d.ts +7 -4
- package/dist/interfaces/folder-content-interfaces.js +3 -3
- package/dist/interfaces/folder-content-interfaces.js.map +1 -1
- package/dist/interfaces/macros.d.ts +1 -0
- package/dist/interfaces/macros.js +1 -1
- package/dist/interfaces/macros.js.map +1 -1
- package/dist/interfaces/project-interfaces.d.ts +7 -5
- package/dist/interfaces/project-interfaces.js.map +1 -1
- package/dist/interfaces/resource-interfaces.d.ts +25 -22
- package/dist/interfaces/resource-interfaces.js +3 -0
- package/dist/interfaces/resource-interfaces.js.map +1 -1
- package/dist/macros/common.d.ts +10 -10
- package/dist/macros/createCards/index.d.ts +0 -13
- package/dist/macros/createCards/index.js.map +1 -1
- package/dist/macros/createCards/types.d.ts +44 -0
- package/dist/macros/createCards/types.js +15 -0
- package/dist/macros/createCards/types.js.map +1 -0
- package/dist/macros/graph/index.d.ts +2 -6
- package/dist/macros/graph/index.js +14 -28
- package/dist/macros/graph/index.js.map +1 -1
- package/dist/macros/graph/types.d.ts +23 -0
- package/dist/macros/graph/types.js +15 -0
- package/dist/macros/graph/types.js.map +1 -0
- package/dist/macros/image/index.d.ts +8 -16
- package/dist/macros/image/index.js +36 -33
- package/dist/macros/image/index.js.map +1 -1
- package/dist/macros/image/types.d.ts +38 -0
- package/dist/macros/image/types.js +15 -0
- package/dist/macros/image/types.js.map +1 -0
- package/dist/macros/include/index.d.ts +1 -6
- package/dist/macros/include/index.js +4 -7
- package/dist/macros/include/index.js.map +1 -1
- package/dist/macros/include/types.d.ts +31 -0
- package/dist/macros/include/types.js +15 -0
- package/dist/macros/include/types.js.map +1 -0
- package/dist/macros/index.d.ts +1 -1
- package/dist/macros/index.js +2 -2
- package/dist/macros/index.js.map +1 -1
- package/dist/macros/percentage/index.d.ts +0 -6
- package/dist/macros/percentage/index.js.map +1 -1
- package/dist/macros/percentage/types.d.ts +31 -0
- package/dist/macros/percentage/types.js +15 -0
- package/dist/macros/percentage/types.js.map +1 -0
- package/dist/macros/report/index.d.ts +0 -3
- package/dist/macros/report/index.js +3 -6
- package/dist/macros/report/index.js.map +1 -1
- package/dist/macros/report/types.d.ts +19 -0
- package/dist/macros/report/types.js +15 -0
- package/dist/macros/report/types.js.map +1 -0
- package/dist/macros/scoreCard/index.d.ts +0 -6
- package/dist/macros/scoreCard/index.js.map +1 -1
- package/dist/macros/scoreCard/types.d.ts +31 -0
- package/dist/macros/scoreCard/types.js +15 -0
- package/dist/macros/scoreCard/types.js.map +1 -0
- package/dist/macros/types.d.ts +25 -0
- package/dist/macros/types.js +2 -0
- package/dist/macros/types.js.map +1 -0
- package/dist/macros/vega/index.d.ts +0 -4
- package/dist/macros/vega/index.js.map +1 -1
- package/dist/macros/vega/types.d.ts +20 -0
- package/dist/macros/vega/types.js +2 -0
- package/dist/macros/vega/types.js.map +1 -0
- package/dist/macros/vegalite/index.d.ts +0 -4
- package/dist/macros/vegalite/index.js.map +1 -1
- package/dist/macros/vegalite/types.d.ts +20 -0
- package/dist/macros/vegalite/types.js +15 -0
- package/dist/macros/vegalite/types.js.map +1 -0
- package/dist/macros/xref/index.d.ts +0 -3
- package/dist/macros/xref/index.js +5 -14
- package/dist/macros/xref/index.js.map +1 -1
- package/dist/macros/xref/types.d.ts +19 -0
- package/dist/macros/xref/types.js +15 -0
- package/dist/macros/xref/types.js.map +1 -0
- package/dist/module-manager.d.ts +16 -3
- package/dist/module-manager.js +55 -23
- package/dist/module-manager.js.map +1 -1
- package/dist/project-settings.d.ts +16 -3
- package/dist/project-settings.js +79 -14
- package/dist/project-settings.js.map +1 -1
- package/dist/resources/calculation-resource.d.ts +6 -33
- package/dist/resources/calculation-resource.js +11 -60
- package/dist/resources/calculation-resource.js.map +1 -1
- package/dist/resources/card-type-resource.d.ts +10 -22
- package/dist/resources/card-type-resource.js +46 -66
- package/dist/resources/card-type-resource.js.map +1 -1
- package/dist/resources/create-defaults.d.ts +3 -2
- package/dist/resources/create-defaults.js +3 -2
- package/dist/resources/create-defaults.js.map +1 -1
- package/dist/resources/field-type-resource.d.ts +8 -22
- package/dist/resources/field-type-resource.js +35 -60
- package/dist/resources/field-type-resource.js.map +1 -1
- package/dist/resources/file-resource.d.ts +14 -35
- package/dist/resources/file-resource.js +22 -301
- package/dist/resources/file-resource.js.map +1 -1
- package/dist/resources/folder-resource.d.ts +44 -66
- package/dist/resources/folder-resource.js +102 -149
- package/dist/resources/folder-resource.js.map +1 -1
- package/dist/resources/graph-model-resource.d.ts +9 -34
- package/dist/resources/graph-model-resource.js +18 -64
- package/dist/resources/graph-model-resource.js.map +1 -1
- package/dist/resources/graph-view-resource.d.ts +9 -29
- package/dist/resources/graph-view-resource.js +13 -48
- package/dist/resources/graph-view-resource.js.map +1 -1
- package/dist/resources/link-type-resource.d.ts +9 -23
- package/dist/resources/link-type-resource.js +11 -33
- package/dist/resources/link-type-resource.js.map +1 -1
- package/dist/resources/report-resource.d.ts +10 -23
- package/dist/resources/report-resource.js +20 -67
- package/dist/resources/report-resource.js.map +1 -1
- package/dist/resources/resource-object.d.ts +143 -23
- package/dist/resources/resource-object.js +369 -48
- package/dist/resources/resource-object.js.map +1 -1
- package/dist/resources/template-resource.d.ts +10 -17
- package/dist/resources/template-resource.js +19 -27
- package/dist/resources/template-resource.js.map +1 -1
- package/dist/resources/workflow-resource.d.ts +9 -25
- package/dist/resources/workflow-resource.js +25 -55
- package/dist/resources/workflow-resource.js.map +1 -1
- package/dist/utils/card-utils.d.ts +69 -19
- package/dist/utils/card-utils.js +179 -30
- package/dist/utils/card-utils.js.map +1 -1
- package/dist/utils/clingo-fact-builder.d.ts +25 -14
- package/dist/utils/clingo-fact-builder.js +27 -5
- package/dist/utils/clingo-fact-builder.js.map +1 -1
- package/dist/utils/clingo-facts.js +14 -7
- package/dist/utils/clingo-facts.js.map +1 -1
- package/dist/utils/clingo-parser.js +1 -1
- package/dist/utils/clingo-parser.js.map +1 -1
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.js +4 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/csv.js +1 -1
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/resource-utils.d.ts +1 -0
- package/dist/utils/resource-utils.js +2 -1
- package/dist/utils/resource-utils.js.map +1 -1
- package/package.json +11 -11
- package/src/card-metadata-updater.ts +9 -7
- package/src/command-handler.ts +35 -23
- package/src/command-manager.ts +32 -19
- package/src/commands/create.ts +59 -160
- package/src/commands/edit.ts +16 -132
- package/src/commands/export.ts +71 -81
- package/src/commands/import.ts +26 -18
- package/src/commands/move.ts +143 -179
- package/src/commands/remove.ts +20 -59
- package/src/commands/rename.ts +45 -156
- package/src/commands/show.ts +153 -211
- package/src/commands/transition.ts +53 -58
- package/src/commands/update.ts +44 -23
- package/src/commands/validate.ts +108 -82
- package/src/containers/card-container.ts +200 -360
- package/src/containers/project/calculation-engine.ts +81 -105
- package/src/containers/project/card-cache.ts +497 -0
- package/src/containers/project/project-paths.ts +21 -13
- package/src/containers/project/resource-cache.ts +648 -0
- package/src/containers/project/resource-handler.ts +265 -0
- package/src/containers/project.ts +551 -693
- package/src/containers/template.ts +129 -142
- package/src/index.ts +1 -0
- package/src/interfaces/folder-content-interfaces.ts +14 -7
- package/src/interfaces/macros.ts +2 -0
- package/src/interfaces/project-interfaces.ts +14 -7
- package/src/interfaces/resource-interfaces.ts +30 -27
- package/src/macros/createCards/index.ts +1 -12
- package/src/macros/createCards/types.ts +46 -0
- package/src/macros/graph/index.ts +27 -52
- package/src/macros/graph/types.ts +24 -0
- package/src/macros/image/index.ts +50 -61
- package/src/macros/image/types.ts +39 -0
- package/src/macros/include/index.ts +6 -15
- package/src/macros/include/types.ts +32 -0
- package/src/macros/index.ts +2 -2
- package/src/macros/percentage/index.ts +1 -7
- package/src/macros/percentage/types.ts +32 -0
- package/src/macros/report/index.ts +4 -13
- package/src/macros/report/types.ts +20 -0
- package/src/macros/scoreCard/index.ts +1 -7
- package/src/macros/scoreCard/types.ts +32 -0
- package/src/macros/types.ts +48 -0
- package/src/macros/vega/index.ts +1 -4
- package/src/macros/vega/types.ts +21 -0
- package/src/macros/vegalite/index.ts +1 -4
- package/src/macros/vegalite/types.ts +22 -0
- package/src/macros/xref/index.ts +6 -20
- package/src/macros/xref/types.ts +20 -0
- package/src/module-manager.ts +79 -22
- package/src/project-settings.ts +84 -15
- package/src/resources/calculation-resource.ts +21 -91
- package/src/resources/card-type-resource.ts +74 -109
- package/src/resources/create-defaults.ts +3 -2
- package/src/resources/field-type-resource.ts +61 -104
- package/src/resources/file-resource.ts +33 -441
- package/src/resources/folder-resource.ts +130 -207
- package/src/resources/graph-model-resource.ts +36 -95
- package/src/resources/graph-view-resource.ts +28 -70
- package/src/resources/link-type-resource.ts +23 -53
- package/src/resources/report-resource.ts +34 -96
- package/src/resources/resource-object.ts +511 -66
- package/src/resources/template-resource.ts +32 -44
- package/src/resources/workflow-resource.ts +42 -85
- package/src/utils/card-utils.ts +217 -31
- package/src/utils/clingo-fact-builder.ts +28 -16
- package/src/utils/clingo-facts.ts +16 -7
- package/src/utils/clingo-parser.ts +1 -1
- package/src/utils/constants.ts +6 -0
- package/src/utils/csv.ts +1 -1
- package/src/utils/resource-utils.ts +2 -1
- package/dist/containers/project/resource-collector.d.ts +0 -87
- package/dist/containers/project/resource-collector.js +0 -337
- package/dist/containers/project/resource-collector.js.map +0 -1
- package/src/containers/project/resource-collector.ts +0 -396
|
@@ -189,7 +189,8 @@ export abstract class DefaultContent {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
|
-
* Default template content
|
|
192
|
+
* Default template content.
|
|
193
|
+
* @param templateName Template name
|
|
193
194
|
* @returns Default template content
|
|
194
195
|
*/
|
|
195
196
|
public static template(templateName: string): TemplateMetadata {
|
|
@@ -201,7 +202,7 @@ export abstract class DefaultContent {
|
|
|
201
202
|
|
|
202
203
|
/**
|
|
203
204
|
* Default content for workflow JSON values.
|
|
204
|
-
* @param
|
|
205
|
+
* @param workflowName workflow name
|
|
205
206
|
* @returns Default content for workflow JSON values.
|
|
206
207
|
*/
|
|
207
208
|
public static workflow(workflowName: string): Workflow {
|
|
@@ -11,44 +11,40 @@
|
|
|
11
11
|
License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import {
|
|
15
|
+
allowed,
|
|
16
|
+
fromDate,
|
|
17
|
+
fromNumber,
|
|
18
|
+
fromString,
|
|
19
|
+
} from '../utils/value-utils.js';
|
|
20
|
+
import { DefaultContent } from './create-defaults.js';
|
|
21
|
+
import { FileResource } from './file-resource.js';
|
|
22
|
+
import { resourceNameToString } from '../utils/resource-utils.js';
|
|
23
|
+
import { sortCards } from '../utils/card-utils.js';
|
|
24
|
+
|
|
25
|
+
import * as EmailValidator from 'email-validator';
|
|
26
|
+
|
|
14
27
|
import type {
|
|
15
|
-
Card,
|
|
16
28
|
ChangeOperation,
|
|
17
29
|
Operation,
|
|
18
|
-
Project,
|
|
19
30
|
RemoveOperation,
|
|
20
|
-
|
|
21
|
-
} from '
|
|
22
|
-
import {
|
|
23
|
-
DefaultContent,
|
|
24
|
-
FileResource,
|
|
25
|
-
ResourcesFrom,
|
|
26
|
-
resourceName,
|
|
27
|
-
resourceNameToString,
|
|
28
|
-
sortCards,
|
|
29
|
-
} from './file-resource.js';
|
|
30
|
-
|
|
31
|
+
} from './resource-object.js';
|
|
32
|
+
import type { Card } from '../interfaces/project-interfaces.js';
|
|
31
33
|
import type {
|
|
32
|
-
CardType,
|
|
33
34
|
DataType,
|
|
34
35
|
EnumDefinition,
|
|
35
36
|
FieldType,
|
|
37
|
+
UpdateKey,
|
|
36
38
|
} from '../interfaces/resource-interfaces.js';
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
allowed,
|
|
40
|
-
fromDate,
|
|
41
|
-
fromNumber,
|
|
42
|
-
fromString,
|
|
43
|
-
} from '../utils/value-utils.js';
|
|
44
|
-
import * as EmailValidator from 'email-validator';
|
|
39
|
+
import type { Project } from '../containers/project.js';
|
|
40
|
+
import type { ResourceName } from '../utils/resource-utils.js';
|
|
45
41
|
|
|
46
42
|
const SHORT_TEXT_MAX_LENGTH = 80;
|
|
47
43
|
|
|
48
44
|
/**
|
|
49
45
|
* Field type resource class.
|
|
50
46
|
*/
|
|
51
|
-
export class FieldTypeResource extends FileResource {
|
|
47
|
+
export class FieldTypeResource extends FileResource<FieldType> {
|
|
52
48
|
// Initialize data type change helpers (fromType, toType) to some values.
|
|
53
49
|
// The actual types are set, if this Field Type's dataType is changed.
|
|
54
50
|
private fromType: DataType = 'integer';
|
|
@@ -59,8 +55,6 @@ export class FieldTypeResource extends FileResource {
|
|
|
59
55
|
|
|
60
56
|
this.contentSchemaId = 'fieldTypeSchema';
|
|
61
57
|
this.contentSchema = super.contentSchemaContent(this.contentSchemaId);
|
|
62
|
-
|
|
63
|
-
this.initialize();
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
// Cards from given array that include this field type.
|
|
@@ -130,21 +124,20 @@ export class FieldTypeResource extends FileResource {
|
|
|
130
124
|
function affectedCard(card: Card): boolean {
|
|
131
125
|
if (!card.metadata) return false;
|
|
132
126
|
return cardTypesThatUseThisFieldType.some(
|
|
133
|
-
(item) => item === card.metadata
|
|
127
|
+
(item) => item === card.metadata?.cardType,
|
|
134
128
|
);
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
// First collect the cardTypes that need to be updated.
|
|
138
|
-
const cardTypes =
|
|
132
|
+
const cardTypes = this.relevantCardTypes();
|
|
139
133
|
cardTypesThatUseThisFieldType.push(...cardTypes);
|
|
140
134
|
|
|
141
135
|
// Then collect cards (both project and local template) that use those card types.
|
|
142
|
-
const projectCards =
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const templateCards = (await this.project.allTemplateCards())
|
|
136
|
+
const projectCards = this.project
|
|
137
|
+
.cards(this.project.paths.cardRootFolder)
|
|
138
|
+
.filter((card) => affectedCard(card));
|
|
139
|
+
const templateCards = this.project
|
|
140
|
+
.allTemplateCards()
|
|
148
141
|
.filter((card) => !card.path.includes('modules'))
|
|
149
142
|
.filter((card) => affectedCard(card));
|
|
150
143
|
const allCards = [...projectCards, ...templateCards];
|
|
@@ -211,11 +204,9 @@ export class FieldTypeResource extends FileResource {
|
|
|
211
204
|
if (!newValue) return;
|
|
212
205
|
|
|
213
206
|
const removedValue = (op.target as EnumDefinition).enumValue;
|
|
214
|
-
const cardTypes =
|
|
207
|
+
const cardTypes = this.relevantCardTypes();
|
|
215
208
|
const allCards = await Promise.all(
|
|
216
|
-
cardTypes.map((cardType) =>
|
|
217
|
-
this.collectCards({ metadata: true }, cardType),
|
|
218
|
-
),
|
|
209
|
+
cardTypes.map((cardType) => this.collectCards(cardType)),
|
|
219
210
|
);
|
|
220
211
|
const cardsToUpdate = allCards
|
|
221
212
|
.flat()
|
|
@@ -259,44 +250,35 @@ export class FieldTypeResource extends FileResource {
|
|
|
259
250
|
}
|
|
260
251
|
|
|
261
252
|
// Card types that use field type.
|
|
262
|
-
private
|
|
253
|
+
private relevantCardTypes(): string[] {
|
|
263
254
|
const resourceName = resourceNameToString(this.resourceName);
|
|
264
|
-
const cardTypes =
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}),
|
|
275
|
-
);
|
|
276
|
-
// Remove empty values.
|
|
277
|
-
return references.filter(Boolean);
|
|
255
|
+
const cardTypes = this.project.resources.cardTypes();
|
|
256
|
+
const references = [];
|
|
257
|
+
for (const cardType of cardTypes) {
|
|
258
|
+
const found = cardType.data?.customFields.filter(
|
|
259
|
+
(field) => field.name === resourceName,
|
|
260
|
+
);
|
|
261
|
+
if (found && found.length > 0 && cardType.data)
|
|
262
|
+
references.push(cardType.data?.name);
|
|
263
|
+
}
|
|
264
|
+
return references;
|
|
278
265
|
}
|
|
279
266
|
|
|
280
267
|
// Update dependant card types
|
|
281
268
|
private async updateCardTypes(oldName: string) {
|
|
282
|
-
const cardTypes =
|
|
269
|
+
const cardTypes = this.project.resources.cardTypes();
|
|
283
270
|
const op = {
|
|
284
271
|
name: 'change',
|
|
285
272
|
target: oldName,
|
|
286
273
|
to: this.content.name,
|
|
287
274
|
} as ChangeOperation<string>;
|
|
288
275
|
for (const cardType of cardTypes) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
);
|
|
293
|
-
const data = object.data as CardType;
|
|
294
|
-
if (data) {
|
|
295
|
-
const found = data.customFields
|
|
296
|
-
? data.customFields.find((item) => item.name === oldName)
|
|
276
|
+
if (cardType.data?.customFields) {
|
|
277
|
+
const found = cardType.data.customFields
|
|
278
|
+
? cardType.data.customFields.find((item) => item.name === oldName)
|
|
297
279
|
: undefined;
|
|
298
280
|
if (found) {
|
|
299
|
-
await
|
|
281
|
+
await cardType.update({ key: 'customFields' }, op);
|
|
300
282
|
}
|
|
301
283
|
}
|
|
302
284
|
}
|
|
@@ -322,20 +304,6 @@ export class FieldTypeResource extends FileResource {
|
|
|
322
304
|
return super.create(content);
|
|
323
305
|
}
|
|
324
306
|
|
|
325
|
-
/**
|
|
326
|
-
* Returns content data.
|
|
327
|
-
*/
|
|
328
|
-
public get data(): FieldType {
|
|
329
|
-
return super.data as FieldType;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Deletes file(s) from disk and clears out the memory resident object.
|
|
334
|
-
*/
|
|
335
|
-
public async delete() {
|
|
336
|
-
return super.delete();
|
|
337
|
-
}
|
|
338
|
-
|
|
339
307
|
/**
|
|
340
308
|
* Returns all possible field types.
|
|
341
309
|
* @returns all possible field types.
|
|
@@ -407,33 +375,29 @@ export class FieldTypeResource extends FileResource {
|
|
|
407
375
|
return this.handleNameChange(existingName);
|
|
408
376
|
}
|
|
409
377
|
|
|
410
|
-
/**
|
|
411
|
-
* Shows metadata of the resource.
|
|
412
|
-
* @returns field type metadata.
|
|
413
|
-
*/
|
|
414
|
-
public async show(): Promise<FieldType> {
|
|
415
|
-
return super.show() as Promise<FieldType>;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
378
|
/**
|
|
419
379
|
* Updates field type resource.
|
|
420
|
-
* @param
|
|
380
|
+
* @param updateKey Key to modify
|
|
421
381
|
* @param op Operation to perform on 'key'
|
|
422
382
|
* @throws
|
|
423
383
|
* - when called with unknown data type
|
|
424
384
|
* - when called with data type conversion that cannot be done
|
|
425
385
|
* - when called with unknown property to update
|
|
426
386
|
*/
|
|
427
|
-
public async update<Type
|
|
387
|
+
public async update<Type, K extends string>(
|
|
388
|
+
updateKey: UpdateKey<K>,
|
|
389
|
+
op: Operation<Type>,
|
|
390
|
+
) {
|
|
391
|
+
const { key } = updateKey;
|
|
428
392
|
const nameChange = key === 'name';
|
|
429
393
|
const typeChange = key === 'dataType';
|
|
430
394
|
const enumChange = key === 'enumValues';
|
|
431
395
|
const existingName = this.content.name;
|
|
432
|
-
const existingType =
|
|
396
|
+
const existingType = this.content.dataType;
|
|
433
397
|
|
|
434
|
-
await super.update(
|
|
398
|
+
await super.update(updateKey, op);
|
|
435
399
|
|
|
436
|
-
const content = structuredClone(this.content)
|
|
400
|
+
const content = structuredClone(this.content);
|
|
437
401
|
if (key === 'name') {
|
|
438
402
|
content.name = super.handleScalar(op) as string;
|
|
439
403
|
} else if (key === 'dataType') {
|
|
@@ -473,7 +437,7 @@ export class FieldTypeResource extends FileResource {
|
|
|
473
437
|
throw new Error(`Unknown property '${key}' for FieldType`);
|
|
474
438
|
}
|
|
475
439
|
|
|
476
|
-
await super.postUpdate(content,
|
|
440
|
+
await super.postUpdate(content, updateKey, op);
|
|
477
441
|
|
|
478
442
|
if (nameChange) {
|
|
479
443
|
// Renaming this field type causes that references to its name must be updated.
|
|
@@ -494,14 +458,14 @@ export class FieldTypeResource extends FileResource {
|
|
|
494
458
|
* @returns array of card keys, resource names and calculation filenames that refer this resource.
|
|
495
459
|
*/
|
|
496
460
|
public async usage(cards?: Card[]): Promise<string[]> {
|
|
497
|
-
const allCards = cards ??
|
|
461
|
+
const allCards = cards ?? super.cards();
|
|
498
462
|
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
463
|
+
const relevantLinkTypes = this.relevantCardTypes();
|
|
464
|
+
|
|
465
|
+
const [cardContentReferences, calculations] = await Promise.all([
|
|
466
|
+
super.usage(allCards),
|
|
467
|
+
super.calculations(),
|
|
468
|
+
]);
|
|
505
469
|
|
|
506
470
|
const cardReferences = [
|
|
507
471
|
...this.cardsWithFieldType(allCards),
|
|
@@ -513,11 +477,4 @@ export class FieldTypeResource extends FileResource {
|
|
|
513
477
|
...new Set([...cardReferences, ...relevantLinkTypes, ...calculations]),
|
|
514
478
|
];
|
|
515
479
|
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Validates the resource. If object is invalid, throws.
|
|
519
|
-
*/
|
|
520
|
-
public async validate(content?: object) {
|
|
521
|
-
return super.validate(content);
|
|
522
|
-
}
|
|
523
480
|
}
|