Skip to content

Commit 9a7f6f3

Browse files
committed
Resolve IDs
1 parent fa00b33 commit 9a7f6f3

File tree

6 files changed

+30
-21
lines changed

6 files changed

+30
-21
lines changed

packages/dsw-tdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Add check for no matching files (warning and use of defaults)
1313

14+
### Changed
15+
16+
- Unified IDs (organization, document template, knowledge model)
17+
1418

1519
## [4.16.0]
1620

packages/dsw-tdk/dsw/tdk/consts.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
METAMODEL_VERSION = 16
99

1010
REGEX_SEMVER = re.compile(r'^[0-9]+\.[0-9]+\.[0-9]+$')
11-
REGEX_ORGANIZATION_ID = re.compile(r'^(?![.])(?!.*[.]$)[a-zA-Z0-9.]+$')
12-
REGEX_TEMPLATE_ID = re.compile(r'^(?![-])(?!.*[-]$)[a-zA-Z0-9-]+$')
13-
REGEX_KM_ID = REGEX_TEMPLATE_ID
11+
REGEX_WIZARD_ID = re.compile(r'^[a-zA-Z0-9-_.]+$')
12+
REGEX_ORGANIZATION_ID = REGEX_WIZARD_ID
13+
REGEX_TEMPLATE_ID = REGEX_WIZARD_ID
14+
REGEX_KM_ID = REGEX_WIZARD_ID
1415
REGEX_MIME_TYPE = re.compile(r'^(?![-])(?!.*[-]$)[-\w.]+/[-\w.]+$')
1516

1617
DEFAULT_LIST_FORMAT = '{template.id:<50} {template.name:<30}'

packages/dsw-tdk/dsw/tdk/validation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def _validate_extension(field_name: str, value) -> List[ValidationError]:
4444
if value is not None and re.match(REGEX_ORGANIZATION_ID, value) is None:
4545
return [ValidationError(
4646
field_name=field_name,
47-
message='File extension should contain only letters, numbers and dots (inside-only)',
47+
message='File extension should contain only letters, numbers, '
48+
'and periods (inside-only)',
4849
)]
4950
return []
5051

@@ -53,7 +54,8 @@ def _validate_organization_id(field_name: str, value) -> List[ValidationError]:
5354
if value is not None and re.match(REGEX_ORGANIZATION_ID, value) is None:
5455
return [ValidationError(
5556
field_name=field_name,
56-
message='Organization ID may contain only letters, numbers, and period (inside-only)',
57+
message='Organization ID may contain only letters, numbers, '
58+
'periods, dashes, and underscores',
5759
)]
5860
return []
5961

@@ -62,7 +64,8 @@ def _validate_template_id(field_name: str, value) -> List[ValidationError]:
6264
if value is not None and re.match(REGEX_TEMPLATE_ID, value) is None:
6365
return [ValidationError(
6466
field_name=field_name,
65-
message='Template ID may contain only letters, numbers, and dash (inside-only)',
67+
message='Template ID may contain only letters, numbers, '
68+
'periods, dashes, and underscores',
6669
)]
6770
return []
6871

@@ -71,7 +74,8 @@ def _validate_km_id(field_name: str, value) -> List[ValidationError]:
7174
if value is not None and re.match(REGEX_KM_ID, value) is None:
7275
return [ValidationError(
7376
field_name=field_name,
74-
message='KM ID may contain only letters, numbers, and dash (inside-only)',
77+
message='KM ID may contain only letters, numbers, '
78+
'periods, dashes, and underscores',
7579
)]
7680
return []
7781

@@ -107,7 +111,7 @@ def _validate_package_id(field_name: str, value: str) -> List[ValidationError]:
107111
if len(parts) != 3:
108112
res.append(ValidationError(
109113
field_name=field_name,
110-
message='Package ID is not valid (only {len(parts)} parts)',
114+
message=f'Package ID is not valid (only {len(parts)} parts)',
111115
))
112116
if re.match(REGEX_ORGANIZATION_ID, parts[0]) is None:
113117
res.append(ValidationError(
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
aiohappyeyeballs==2.4.4
2-
aiohttp==3.11.11
1+
aiohappyeyeballs==2.6.1
2+
aiohttp==3.11.14
33
aiosignal==1.3.2
44
anyio==4.6.2.post1
5-
attrs==24.3.0
5+
attrs==25.3.0
66
click==8.1.8
77
colorama==0.4.6
88
frozenlist==1.5.0
9-
humanize==4.11.0
9+
humanize==4.12.1
1010
idna==3.10
1111
iniconfig==2.0.0
12-
Jinja2==3.1.5
12+
Jinja2==3.1.6
1313
MarkupSafe==3.0.2
14-
multidict==6.1.0
14+
multidict==6.2.0
1515
packaging==24.2
1616
pathspec==0.12.1
1717
pluggy==1.5.0
18-
propcache==0.2.1
19-
pytest==8.3.4
18+
propcache==0.3.0
19+
pytest==8.3.5
2020
pytest-recording==0.13.2
2121
python-dotenv==1.0.1
2222
python-slugify==8.0.4
@@ -26,6 +26,6 @@ sniffio==1.3.1
2626
text-unidecode==1.3
2727
urllib3==2.3.0
2828
vcrpy==7.0.0
29-
watchfiles==1.0.3
29+
watchfiles==1.0.4
3030
wrapt==1.17.0
3131
yarl==1.18.3

packages/dsw-tdk/tests/fixtures/test_faulty03/template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"organizationId": "te-st",
3-
"templateId": "example.01",
2+
"organizationId": "te-st?test",
3+
"templateId": "example.01:test",
44
"version": "not a version",
55
"name": null,
66
"description": null,

packages/dsw-tdk/tests/test_cmd_verify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_verify_invalid(fixtures_path: pathlib.Path):
3838
result = runner.invoke(main, args=['verify', template_path.as_posix()])
3939
assert result.exit_code == 0
4040
assert 'The template is invalid!' in result.output
41-
assert 'template_id: Template ID may contain only letters, numbers, and dash' in result.output
42-
assert 'organization_id: Organization ID may contain only letters, numbers, and period' in result.output
41+
assert 'template_id: Template ID may contain only letters, numbers,' in result.output
42+
assert 'organization_id: Organization ID may contain only letters, numbers,' in result.output
4343
assert 'version: Version must be in semver format' in result.output
4444
assert 'name: Missing but it is required' in result.output
4545
assert 'description: Missing but it is required' in result.output

0 commit comments

Comments
 (0)