@privateaim/core-kit 0.8.20 → 0.8.22
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/CHANGELOG.md +48 -0
- package/dist/domains/analysis/constants.d.ts +5 -41
- package/dist/domains/analysis/constants.d.ts.map +1 -1
- package/dist/domains/analysis/entity.d.ts +32 -5
- package/dist/domains/analysis/entity.d.ts.map +1 -1
- package/dist/domains/analysis/error.d.ts +6 -1
- package/dist/domains/analysis/error.d.ts.map +1 -1
- package/dist/domains/analysis/helpers/builder.d.ts +16 -0
- package/dist/domains/analysis/helpers/builder.d.ts.map +1 -0
- package/dist/domains/analysis/helpers/configurator.d.ts +16 -0
- package/dist/domains/analysis/helpers/configurator.d.ts.map +1 -0
- package/dist/domains/analysis/helpers/distributor.d.ts +16 -0
- package/dist/domains/analysis/helpers/distributor.d.ts.map +1 -0
- package/dist/domains/analysis/helpers/index.d.ts +4 -0
- package/dist/domains/analysis/helpers/index.d.ts.map +1 -0
- package/dist/domains/analysis-bucket/entity.d.ts +3 -3
- package/dist/domains/analysis-bucket/entity.d.ts.map +1 -1
- package/dist/domains/analysis-bucket-file/entity.d.ts +7 -5
- package/dist/domains/analysis-bucket-file/entity.d.ts.map +1 -1
- package/dist/domains/analysis-node/constants.d.ts +0 -9
- package/dist/domains/analysis-node/constants.d.ts.map +1 -1
- package/dist/domains/analysis-node/entity.d.ts +4 -2
- package/dist/domains/analysis-node/entity.d.ts.map +1 -1
- package/dist/domains/analysis-permission/entity.d.ts +2 -2
- package/dist/domains/analysis-permission/entity.d.ts.map +1 -1
- package/dist/domains/master-image/entity.d.ts +3 -0
- package/dist/domains/master-image/entity.d.ts.map +1 -1
- package/dist/domains/node/entity.d.ts +5 -1
- package/dist/domains/node/entity.d.ts.map +1 -1
- package/dist/index.mjs +129 -187
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -12
- package/rollup.config.mjs +1 -6
- package/src/domains/analysis/constants.ts +4 -63
- package/src/domains/analysis/entity.ts +44 -9
- package/src/domains/analysis/error.ts +19 -1
- package/src/domains/analysis/helpers/builder.ts +61 -0
- package/src/domains/analysis/helpers/configurator.ts +68 -0
- package/src/domains/analysis/helpers/distributor.ts +40 -0
- package/src/domains/analysis/helpers/index.ts +10 -0
- package/src/domains/analysis-bucket/entity.ts +7 -5
- package/src/domains/analysis-bucket-file/entity.ts +11 -5
- package/src/domains/analysis-node/constants.ts +0 -15
- package/src/domains/analysis-node/entity.ts +5 -2
- package/src/domains/analysis-permission/entity.ts +2 -2
- package/src/domains/master-image/entity.ts +5 -0
- package/src/domains/node/entity.ts +6 -1
- package/dist/domains/analysis/helpers.d.ts +0 -15
- package/dist/domains/analysis/helpers.d.ts.map +0 -1
- package/dist/index.cjs +0 -591
- package/dist/index.cjs.map +0 -1
- package/src/domains/analysis/helpers.ts +0 -157
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025.
|
|
3
|
-
* Author Peter Placzek (tada5hi)
|
|
4
|
-
* For the full copyright and license information,
|
|
5
|
-
* view the LICENSE file that was distributed with this source code.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { AnalysisAPICommand, AnalysisBuildStatus } from './constants';
|
|
9
|
-
import type { Analysis } from './entity';
|
|
10
|
-
import { AnalysisError } from './error';
|
|
11
|
-
|
|
12
|
-
type CanResult = {
|
|
13
|
-
success: boolean,
|
|
14
|
-
message: string,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Check if an analysis can be build based on analysis attributes (build_status, configuration_locked, ...)
|
|
19
|
-
*
|
|
20
|
-
* @param entity
|
|
21
|
-
* @param command
|
|
22
|
-
*/
|
|
23
|
-
export function isAnalysisAPICommandExecutable(
|
|
24
|
-
entity: Analysis,
|
|
25
|
-
command: `${AnalysisAPICommand}`,
|
|
26
|
-
) : CanResult {
|
|
27
|
-
const output : CanResult = {
|
|
28
|
-
success: false,
|
|
29
|
-
message: `The analysis command ${command} cannot be executed.`,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
switch (command) {
|
|
33
|
-
case AnalysisAPICommand.BUILD_START: {
|
|
34
|
-
if (!entity.configuration_locked) {
|
|
35
|
-
output.success = false;
|
|
36
|
-
output.message = 'The analysis configuration must be locked before starting the build.';
|
|
37
|
-
return output;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!entity.build_status) {
|
|
41
|
-
output.success = true;
|
|
42
|
-
return output;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
entity.build_status === AnalysisBuildStatus.FAILED ||
|
|
47
|
-
entity.build_status === AnalysisBuildStatus.STOPPED
|
|
48
|
-
) {
|
|
49
|
-
output.success = true;
|
|
50
|
-
return output;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
output.message = `The current analysis build status "${entity.build_status}" does not allow a build start.`;
|
|
54
|
-
return output;
|
|
55
|
-
}
|
|
56
|
-
case AnalysisAPICommand.BUILD_STOP: {
|
|
57
|
-
if (!entity.configuration_locked) {
|
|
58
|
-
output.message = 'The analysis configuration must be locked before stopping the build.';
|
|
59
|
-
return output;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!entity.build_status) {
|
|
63
|
-
output.message = 'The analysis build process has not been initialized.';
|
|
64
|
-
return output;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (entity.build_status === AnalysisBuildStatus.STOPPING ||
|
|
68
|
-
entity.build_status === AnalysisBuildStatus.STARTED ||
|
|
69
|
-
entity.build_status === AnalysisBuildStatus.STARTING
|
|
70
|
-
) {
|
|
71
|
-
output.success = true;
|
|
72
|
-
return output;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
output.message = `The current analysis build status "${entity.build_status}" does not allow a build stop.`;
|
|
76
|
-
return output;
|
|
77
|
-
}
|
|
78
|
-
case AnalysisAPICommand.BUILD_STATUS: {
|
|
79
|
-
if (!entity.configuration_locked) {
|
|
80
|
-
output.message = 'The analysis configuration must be locked before checking the build status.';
|
|
81
|
-
return output;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (!entity.build_status) {
|
|
85
|
-
output.message = 'The analysis build process has not been initialized.';
|
|
86
|
-
return output;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (entity.build_status === AnalysisBuildStatus.FINISHED) {
|
|
90
|
-
output.message = 'The analysis build process has already been successfully completed.';
|
|
91
|
-
return output;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
output.success = true;
|
|
95
|
-
return output;
|
|
96
|
-
}
|
|
97
|
-
case AnalysisAPICommand.CONFIGURATION_LOCK: {
|
|
98
|
-
if (entity.configuration_locked) {
|
|
99
|
-
const error = AnalysisError.configurationLocked();
|
|
100
|
-
output.message = error.message;
|
|
101
|
-
return output;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (entity.build_status) {
|
|
105
|
-
const error = AnalysisError.buildInitialized();
|
|
106
|
-
output.message = error.message;
|
|
107
|
-
return output;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!entity.configuration_node_default_valid) {
|
|
111
|
-
const error = AnalysisError.defaultNodeRequired();
|
|
112
|
-
output.message = error.message;
|
|
113
|
-
return output;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (!entity.configuration_node_aggregator_valid) {
|
|
117
|
-
const error = AnalysisError.aggregatorNodeRequired();
|
|
118
|
-
output.message = error.message;
|
|
119
|
-
return output;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (!entity.configuration_image_valid) {
|
|
123
|
-
const error = AnalysisError.imageAssignmentRequired();
|
|
124
|
-
output.message = error.message;
|
|
125
|
-
return output;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
output.success = true;
|
|
129
|
-
return output;
|
|
130
|
-
}
|
|
131
|
-
case AnalysisAPICommand.CONFIGURATION_UNLOCK: {
|
|
132
|
-
if (!entity.configuration_locked) {
|
|
133
|
-
output.message = 'The analysis configuration is already unlocked.';
|
|
134
|
-
return output;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (!entity.build_status) {
|
|
138
|
-
output.success = true;
|
|
139
|
-
return output;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
entity.build_status === AnalysisBuildStatus.FAILED ||
|
|
144
|
-
entity.build_status === AnalysisBuildStatus.STOPPED ||
|
|
145
|
-
entity.build_status === AnalysisBuildStatus.STOPPING
|
|
146
|
-
) {
|
|
147
|
-
output.success = true;
|
|
148
|
-
return output;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
output.message = `The current analysis build status "${entity.build_status}" does not allow unlocking the configuration.`;
|
|
152
|
-
return output;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return output;
|
|
157
|
-
}
|