@privateaim/core-kit 0.8.38 → 0.8.41
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 +44 -0
- package/package.json +11 -5
- package/src/domains/analysis/index.ts +2 -0
- package/src/domains/analysis/validator-image-command-argument.ts +38 -0
- package/src/domains/analysis/validator.ts +70 -0
- package/src/domains/analysis-bucket/index.ts +1 -0
- package/src/domains/analysis-bucket/validator.ts +37 -0
- package/src/domains/analysis-bucket-file/index.ts +1 -0
- package/src/domains/analysis-bucket-file/validator.ts +54 -0
- package/src/domains/analysis-node/index.ts +1 -0
- package/src/domains/analysis-node/validator.ts +55 -0
- package/src/domains/analysis-node-log/index.ts +1 -0
- package/src/domains/analysis-node-log/validator.ts +87 -0
- package/src/domains/analysis-permission/index.ts +1 -0
- package/src/domains/analysis-permission/validator.ts +36 -0
- package/src/domains/node/index.ts +1 -0
- package/src/domains/node/validator.ts +73 -0
- package/src/domains/project/index.ts +1 -0
- package/src/domains/project/validator.ts +43 -0
- package/src/domains/project-node/index.ts +1 -0
- package/src/domains/project-node/validator.ts +43 -0
- package/src/domains/registry/index.ts +1 -0
- package/src/domains/registry/validator.ts +57 -0
- package/src/domains/registry-project/index.ts +1 -0
- package/src/domains/registry-project/validator.ts +57 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.41](https://github.com/PrivateAIM/hub/compare/v0.8.40...v0.8.41) (2026-05-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* typed controller signatures, validators in kit packages, swagger via @trapi/cli ([#1590](https://github.com/PrivateAIM/hub/issues/1590)) ([74a35c8](https://github.com/PrivateAIM/hub/commit/74a35c8bed92036a00b581868589c40a192278aa))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* devDependencies
|
|
15
|
+
* @privateaim/kit bumped from ^0.8.40 to ^0.8.41
|
|
16
|
+
* @privateaim/telemetry-kit bumped from ^0.8.40 to ^0.8.41
|
|
17
|
+
* peerDependencies
|
|
18
|
+
* @privateaim/kit bumped from ^0.8.40 to ^0.8.41
|
|
19
|
+
* @privateaim/telemetry-kit bumped from ^0.8.40 to ^0.8.41
|
|
20
|
+
|
|
21
|
+
## [0.8.40](https://github.com/PrivateAIM/hub/compare/v0.8.39...v0.8.40) (2026-04-29)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
* The following workspace dependencies were updated
|
|
27
|
+
* devDependencies
|
|
28
|
+
* @privateaim/kit bumped from ^0.8.39 to ^0.8.40
|
|
29
|
+
* @privateaim/telemetry-kit bumped from ^0.8.39 to ^0.8.40
|
|
30
|
+
* peerDependencies
|
|
31
|
+
* @privateaim/kit bumped from ^0.8.39 to ^0.8.40
|
|
32
|
+
* @privateaim/telemetry-kit bumped from ^0.8.39 to ^0.8.40
|
|
33
|
+
|
|
34
|
+
## [0.8.39](https://github.com/PrivateAIM/hub/compare/v0.8.38...v0.8.39) (2026-04-29)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Dependencies
|
|
38
|
+
|
|
39
|
+
* The following workspace dependencies were updated
|
|
40
|
+
* devDependencies
|
|
41
|
+
* @privateaim/kit bumped from ^0.8.38 to ^0.8.39
|
|
42
|
+
* @privateaim/telemetry-kit bumped from ^0.8.38 to ^0.8.39
|
|
43
|
+
* peerDependencies
|
|
44
|
+
* @privateaim/kit bumped from ^0.8.38 to ^0.8.39
|
|
45
|
+
* @privateaim/telemetry-kit bumped from ^0.8.38 to ^0.8.39
|
|
46
|
+
|
|
3
47
|
## [0.8.38](https://github.com/PrivateAIM/hub/compare/v0.8.37...v0.8.38) (2026-04-23)
|
|
4
48
|
|
|
5
49
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@privateaim/core-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.41",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -23,15 +23,21 @@
|
|
|
23
23
|
"build-watch": "rimraf ./dist && tsc -p tsconfig.build.json --watch",
|
|
24
24
|
"test": "cross-env NODE_ENV=test vitest run --config test/vitest.config.ts"
|
|
25
25
|
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@ebec/http": "^2.3.0",
|
|
28
|
+
"@validup/adapter-zod": "^0.2.3",
|
|
29
|
+
"validup": "^0.2.1",
|
|
30
|
+
"zod": "^4.3.6"
|
|
31
|
+
},
|
|
26
32
|
"devDependencies": {
|
|
27
33
|
"@authup/core-kit": "^1.0.0-beta.36",
|
|
28
|
-
"@privateaim/kit": "^0.8.
|
|
29
|
-
"@privateaim/telemetry-kit": "^0.8.
|
|
34
|
+
"@privateaim/kit": "^0.8.41",
|
|
35
|
+
"@privateaim/telemetry-kit": "^0.8.41"
|
|
30
36
|
},
|
|
31
37
|
"peerDependencies": {
|
|
32
38
|
"@authup/core-kit": "^1.0.0-beta.36",
|
|
33
|
-
"@privateaim/kit": "^0.8.
|
|
34
|
-
"@privateaim/telemetry-kit": "^0.8.
|
|
39
|
+
"@privateaim/kit": "^0.8.41",
|
|
40
|
+
"@privateaim/telemetry-kit": "^0.8.41"
|
|
35
41
|
},
|
|
36
42
|
"gitHead": "5d3b6f4ce1edf2383bdfbf66e913a08c8a3a2e40",
|
|
37
43
|
"publishConfig": {
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { Container } from 'validup';
|
|
9
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import type { MasterImageCommandArgument } from '../master-image/types.ts';
|
|
12
|
+
|
|
13
|
+
export class ImageAttributeCommandArgumentsValidator extends Container<MasterImageCommandArgument> {
|
|
14
|
+
protected initialize() {
|
|
15
|
+
super.initialize();
|
|
16
|
+
|
|
17
|
+
this.mount(
|
|
18
|
+
'value',
|
|
19
|
+
createValidator(
|
|
20
|
+
z.string()
|
|
21
|
+
.min(2)
|
|
22
|
+
.max(512),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
this.mount(
|
|
27
|
+
'position',
|
|
28
|
+
{ optional: true },
|
|
29
|
+
createValidator(
|
|
30
|
+
z.literal('before')
|
|
31
|
+
.or(z.literal('after'))
|
|
32
|
+
.or(z.null())
|
|
33
|
+
.or(z.undefined())
|
|
34
|
+
.optional(),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 { BadRequestError } from '@ebec/http';
|
|
9
|
+
import { Container } from 'validup';
|
|
10
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import type { Analysis } from './entity.ts';
|
|
13
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
14
|
+
import { ImageAttributeCommandArgumentsValidator } from './validator-image-command-argument.ts';
|
|
15
|
+
|
|
16
|
+
export class AnalysisValidator extends Container<Analysis> {
|
|
17
|
+
protected initialize() {
|
|
18
|
+
super.initialize();
|
|
19
|
+
|
|
20
|
+
this.mount(
|
|
21
|
+
'project_id',
|
|
22
|
+
{ group: ValidatorGroup.CREATE },
|
|
23
|
+
createValidator(z.uuid()),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
this.mount(
|
|
27
|
+
'name',
|
|
28
|
+
{ optional: true },
|
|
29
|
+
createValidator(z.string().min(3).max(128).nullable()),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
this.mount(
|
|
33
|
+
'description',
|
|
34
|
+
{ optional: true },
|
|
35
|
+
createValidator(z.string().min(5).max(4096).nullable()),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
this.mount(
|
|
39
|
+
'master_image_id',
|
|
40
|
+
{ optional: true },
|
|
41
|
+
createValidator(z.uuid().nullable()),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
this.mount(
|
|
45
|
+
'registry_id',
|
|
46
|
+
{ optional: true },
|
|
47
|
+
createValidator(z.uuid().nullable()),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const commandArgumentValidator = new ImageAttributeCommandArgumentsValidator();
|
|
51
|
+
// image_command_executable
|
|
52
|
+
this.mount('image_command_arguments', { optional: true }, (ctx) => {
|
|
53
|
+
if (ctx.value == null) {
|
|
54
|
+
return ctx.value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!Array.isArray(ctx.value)) {
|
|
58
|
+
throw new BadRequestError('image_command_arguments must be an array.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const promises = ctx.value.map((child) => commandArgumentValidator.run(child, {
|
|
62
|
+
group: ctx.group,
|
|
63
|
+
flat: false,
|
|
64
|
+
path: ctx.path,
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
return Promise.all(promises);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 type { AnalysisBucket } from './entity.ts';
|
|
9
|
+
import { AnalysisBucketType } from './constants.ts';
|
|
10
|
+
import { Container } from 'validup';
|
|
11
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
14
|
+
|
|
15
|
+
export class AnalysisBucketValidator extends Container<AnalysisBucket> {
|
|
16
|
+
protected initialize() {
|
|
17
|
+
super.initialize();
|
|
18
|
+
|
|
19
|
+
this.mount(
|
|
20
|
+
'analysis_id',
|
|
21
|
+
{ group: ValidatorGroup.CREATE },
|
|
22
|
+
createValidator(z.uuid()),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
this.mount(
|
|
26
|
+
'bucket_id',
|
|
27
|
+
{ group: ValidatorGroup.CREATE },
|
|
28
|
+
createValidator(z.uuid()),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.mount(
|
|
32
|
+
'type',
|
|
33
|
+
{ group: ValidatorGroup.CREATE },
|
|
34
|
+
createValidator(z.enum(AnalysisBucketType)),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 { Container } from 'validup';
|
|
9
|
+
import type { AnalysisBucketFile } from './entity.ts';
|
|
10
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
13
|
+
|
|
14
|
+
export class AnalysisBucketFileValidator extends Container<AnalysisBucketFile> {
|
|
15
|
+
protected initialize() {
|
|
16
|
+
super.initialize();
|
|
17
|
+
|
|
18
|
+
this.mount(
|
|
19
|
+
'analysis_bucket_id',
|
|
20
|
+
{ group: ValidatorGroup.CREATE },
|
|
21
|
+
createValidator(z.uuid()),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const pathValidator = createValidator(z.string());
|
|
25
|
+
this.mount(
|
|
26
|
+
'path',
|
|
27
|
+
{ group: ValidatorGroup.CREATE },
|
|
28
|
+
pathValidator,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.mount(
|
|
32
|
+
'path',
|
|
33
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
34
|
+
pathValidator,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.mount(
|
|
38
|
+
'bucket_id',
|
|
39
|
+
{ group: ValidatorGroup.CREATE },
|
|
40
|
+
createValidator(z.uuid()),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
this.mount(
|
|
44
|
+
'bucket_file_id',
|
|
45
|
+
{ group: ValidatorGroup.CREATE },
|
|
46
|
+
createValidator(z.uuid()),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
this.mount(
|
|
50
|
+
'root',
|
|
51
|
+
createValidator(z.boolean().optional().default(false)),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 type { AnalysisNode } from './entity.ts';
|
|
9
|
+
import { AnalysisNodeApprovalStatus } from './constants.ts';
|
|
10
|
+
import { Container } from 'validup';
|
|
11
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { ProcessStatus, ValidatorGroup } from '@privateaim/kit';
|
|
14
|
+
|
|
15
|
+
export class AnalysisNodeValidator extends Container<AnalysisNode> {
|
|
16
|
+
protected initialize() {
|
|
17
|
+
super.initialize();
|
|
18
|
+
|
|
19
|
+
this.mount(
|
|
20
|
+
'node_id',
|
|
21
|
+
{ group: ValidatorGroup.CREATE },
|
|
22
|
+
createValidator(z.uuid()),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
this.mount(
|
|
26
|
+
'analysis_id',
|
|
27
|
+
{ group: ValidatorGroup.CREATE },
|
|
28
|
+
createValidator(z.uuid()),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.mount(
|
|
32
|
+
'execution_status',
|
|
33
|
+
{ optional: true },
|
|
34
|
+
createValidator(z.enum(ProcessStatus).nullable()),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.mount(
|
|
38
|
+
'execution_progress',
|
|
39
|
+
{ optional: true },
|
|
40
|
+
createValidator(z.number().int().min(0).max(100).nullable()),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
this.mount(
|
|
44
|
+
'approval_status',
|
|
45
|
+
{ optional: true },
|
|
46
|
+
createValidator(z.enum(AnalysisNodeApprovalStatus).nullable()),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
this.mount(
|
|
50
|
+
'comment',
|
|
51
|
+
{ optional: true },
|
|
52
|
+
createValidator(z.string().nullable()),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 zod from 'zod';
|
|
9
|
+
import { LogLevel } from '@privateaim/telemetry-kit';
|
|
10
|
+
import { Container } from 'validup';
|
|
11
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
12
|
+
import type { AnalysisNodeLog } from './entity.ts';
|
|
13
|
+
|
|
14
|
+
export class AnalysisNodeLogValidator extends Container<AnalysisNodeLog> {
|
|
15
|
+
protected initialize() {
|
|
16
|
+
super.initialize();
|
|
17
|
+
|
|
18
|
+
this.mount(
|
|
19
|
+
'node_id',
|
|
20
|
+
createValidator(
|
|
21
|
+
zod
|
|
22
|
+
.uuidv4(),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
this.mount(
|
|
27
|
+
'analysis_id',
|
|
28
|
+
createValidator(
|
|
29
|
+
zod
|
|
30
|
+
.uuidv4(),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
this.mount(
|
|
35
|
+
'status',
|
|
36
|
+
{ optional: true },
|
|
37
|
+
createValidator(
|
|
38
|
+
zod
|
|
39
|
+
.string()
|
|
40
|
+
.min(3)
|
|
41
|
+
.max(64)
|
|
42
|
+
.optional()
|
|
43
|
+
.nullable(),
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
this.mount(
|
|
48
|
+
'message',
|
|
49
|
+
createValidator(
|
|
50
|
+
zod
|
|
51
|
+
.string()
|
|
52
|
+
.min(3)
|
|
53
|
+
.max(2048),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
this.mount(
|
|
58
|
+
'code',
|
|
59
|
+
{ optional: true },
|
|
60
|
+
createValidator(
|
|
61
|
+
zod
|
|
62
|
+
.string()
|
|
63
|
+
.min(3)
|
|
64
|
+
.max(64)
|
|
65
|
+
.optional()
|
|
66
|
+
.nullable(),
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
this.mount(
|
|
71
|
+
'level',
|
|
72
|
+
createValidator(
|
|
73
|
+
zod
|
|
74
|
+
.enum(LogLevel),
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
this.mount(
|
|
79
|
+
'labels',
|
|
80
|
+
{ optional: true },
|
|
81
|
+
createValidator(
|
|
82
|
+
zod
|
|
83
|
+
.record(zod.string(), zod.string()),
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 { Container } from 'validup';
|
|
9
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
12
|
+
import type { AnalysisPermission } from './entity.ts';
|
|
13
|
+
|
|
14
|
+
export class AnalysisPermissionValidator extends Container<AnalysisPermission> {
|
|
15
|
+
protected initialize() {
|
|
16
|
+
super.initialize();
|
|
17
|
+
|
|
18
|
+
this.mount(
|
|
19
|
+
'permission_id',
|
|
20
|
+
{ group: ValidatorGroup.CREATE },
|
|
21
|
+
createValidator(z.uuid()),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
this.mount(
|
|
25
|
+
'analysis_id',
|
|
26
|
+
{ group: ValidatorGroup.CREATE },
|
|
27
|
+
createValidator(z.uuid()),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
this.mount(
|
|
31
|
+
'policy_id',
|
|
32
|
+
{ optional: true },
|
|
33
|
+
createValidator(z.uuid().nullable()),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 type { Node } from './entity.ts';
|
|
9
|
+
import { NodeType } from './constants.ts';
|
|
10
|
+
import { Container } from 'validup';
|
|
11
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
14
|
+
|
|
15
|
+
export class NodeValidator extends Container<Node> {
|
|
16
|
+
protected initialize() {
|
|
17
|
+
super.initialize();
|
|
18
|
+
|
|
19
|
+
this.mount(
|
|
20
|
+
'name',
|
|
21
|
+
{ group: ValidatorGroup.CREATE },
|
|
22
|
+
createValidator(z.string().min(3).max(128)),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
this.mount(
|
|
26
|
+
'name',
|
|
27
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
28
|
+
createValidator(z.string().min(3).max(128).nullable()),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.mount(
|
|
32
|
+
'type',
|
|
33
|
+
{ optional: true },
|
|
34
|
+
createValidator(z.enum(NodeType).nullable()),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.mount(
|
|
38
|
+
'hidden',
|
|
39
|
+
{ optional: true },
|
|
40
|
+
createValidator(z.boolean().nullable()),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
this.mount(
|
|
44
|
+
'public_key',
|
|
45
|
+
{ optional: true },
|
|
46
|
+
createValidator(z.string().min(5).max(4096).nullable()),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
this.mount(
|
|
50
|
+
'external_name',
|
|
51
|
+
{ optional: true },
|
|
52
|
+
createValidator(z.string().min(1).max(64).regex(/^[a-z0-9-_]*$/).nullable()),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
this.mount(
|
|
56
|
+
'registry_id',
|
|
57
|
+
{ optional: true },
|
|
58
|
+
createValidator(z.uuid().nullable()),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
this.mount(
|
|
62
|
+
'client_id',
|
|
63
|
+
{ optional: true },
|
|
64
|
+
createValidator(z.uuid().nullable()),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
this.mount(
|
|
68
|
+
'realm_id',
|
|
69
|
+
{ group: ValidatorGroup.CREATE, optional: true },
|
|
70
|
+
createValidator(z.uuid().nullable()),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 { Container } from 'validup';
|
|
9
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
12
|
+
import type { Project } from './entity.ts';
|
|
13
|
+
|
|
14
|
+
export class ProjectValidator extends Container<Project> {
|
|
15
|
+
protected initialize() {
|
|
16
|
+
super.initialize();
|
|
17
|
+
|
|
18
|
+
const nameValidator = createValidator(z.string().min(5).max(100));
|
|
19
|
+
this.mount(
|
|
20
|
+
'name',
|
|
21
|
+
{ group: ValidatorGroup.CREATE },
|
|
22
|
+
nameValidator,
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
this.mount(
|
|
26
|
+
'name',
|
|
27
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
28
|
+
nameValidator,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.mount(
|
|
32
|
+
'description',
|
|
33
|
+
{ optional: true },
|
|
34
|
+
createValidator(z.string().min(5).max(4096).nullable()),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.mount(
|
|
38
|
+
'master_image_id',
|
|
39
|
+
{ optional: true },
|
|
40
|
+
createValidator(z.uuid().nullable()),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 type { ProjectNode } from './entity.ts';
|
|
9
|
+
import { ProjectNodeApprovalStatus } from './constants.ts';
|
|
10
|
+
import { Container } from 'validup';
|
|
11
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
14
|
+
|
|
15
|
+
export class ProjectNodeValidator extends Container<ProjectNode> {
|
|
16
|
+
protected initialize() {
|
|
17
|
+
super.initialize();
|
|
18
|
+
|
|
19
|
+
this.mount(
|
|
20
|
+
'project_id',
|
|
21
|
+
{ group: ValidatorGroup.CREATE },
|
|
22
|
+
createValidator(z.uuid()),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
this.mount(
|
|
26
|
+
'node_id',
|
|
27
|
+
{ group: ValidatorGroup.CREATE },
|
|
28
|
+
createValidator(z.uuid()),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
this.mount(
|
|
32
|
+
'approval_status',
|
|
33
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
34
|
+
createValidator(z.enum(ProjectNodeApprovalStatus).nullable()),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
this.mount(
|
|
38
|
+
'comment',
|
|
39
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
40
|
+
createValidator(z.string().min(3).max(4096).nullable()),
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 { Container } from 'validup';
|
|
9
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
12
|
+
import type { Registry } from './entity.ts';
|
|
13
|
+
|
|
14
|
+
export class RegistryValidator extends Container<Registry> {
|
|
15
|
+
protected initialize() {
|
|
16
|
+
super.initialize();
|
|
17
|
+
|
|
18
|
+
const nameValidator = createValidator(z.string().min(3).max(128));
|
|
19
|
+
|
|
20
|
+
this.mount(
|
|
21
|
+
'name',
|
|
22
|
+
{ group: ValidatorGroup.CREATE },
|
|
23
|
+
nameValidator,
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
this.mount(
|
|
27
|
+
'name',
|
|
28
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
29
|
+
nameValidator,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const hostValidator = createValidator(z.string().min(3).max(512));
|
|
33
|
+
this.mount(
|
|
34
|
+
'host',
|
|
35
|
+
{ group: ValidatorGroup.CREATE },
|
|
36
|
+
hostValidator,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
this.mount(
|
|
40
|
+
'host',
|
|
41
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
42
|
+
hostValidator,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
this.mount(
|
|
46
|
+
'account_name',
|
|
47
|
+
{ optional: true },
|
|
48
|
+
createValidator(z.string().min(3).max(256).nullable()),
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
this.mount(
|
|
52
|
+
'account_secret',
|
|
53
|
+
{ optional: true },
|
|
54
|
+
createValidator(z.string().min(3).max(256).nullable()),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
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 type { RegistryProject } from './entity.ts';
|
|
9
|
+
import { RegistryProjectType } from './constants.ts';
|
|
10
|
+
import { Container } from 'validup';
|
|
11
|
+
import { createValidator } from '@validup/adapter-zod';
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { ValidatorGroup } from '@privateaim/kit';
|
|
14
|
+
|
|
15
|
+
export class RegistryProjectValidator extends Container<RegistryProject> {
|
|
16
|
+
protected initialize() {
|
|
17
|
+
super.initialize();
|
|
18
|
+
|
|
19
|
+
this.mount(
|
|
20
|
+
'registry_id',
|
|
21
|
+
{ group: ValidatorGroup.CREATE },
|
|
22
|
+
createValidator(z.uuid()),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const nameValidator = createValidator(z.string().min(5).max(128));
|
|
26
|
+
this.mount(
|
|
27
|
+
'name',
|
|
28
|
+
{ group: ValidatorGroup.CREATE },
|
|
29
|
+
nameValidator,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
this.mount(
|
|
33
|
+
'name',
|
|
34
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
35
|
+
nameValidator,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const externalNameValidator = createValidator(z.string().min(1).max(255).regex(/^[a-z0-9-_]*$/));
|
|
39
|
+
this.mount(
|
|
40
|
+
'external_name',
|
|
41
|
+
{ group: ValidatorGroup.CREATE },
|
|
42
|
+
externalNameValidator,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
this.mount(
|
|
46
|
+
'external_name',
|
|
47
|
+
{ group: ValidatorGroup.UPDATE, optional: true },
|
|
48
|
+
externalNameValidator,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
this.mount(
|
|
52
|
+
'type',
|
|
53
|
+
{ group: ValidatorGroup.CREATE },
|
|
54
|
+
createValidator(z.enum(RegistryProjectType)),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|