Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/dsw-tdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

### Changed

- Unified IDs (organization, document template, knowledge model)


## [4.16.0]

Expand Down
7 changes: 4 additions & 3 deletions packages/dsw-tdk/dsw/tdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
METAMODEL_VERSION = 16

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

DEFAULT_LIST_FORMAT = '{template.id:<50} {template.name:<30}'
Expand Down
14 changes: 9 additions & 5 deletions packages/dsw-tdk/dsw/tdk/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def _validate_extension(field_name: str, value) -> List[ValidationError]:
if value is not None and re.match(REGEX_ORGANIZATION_ID, value) is None:
return [ValidationError(
field_name=field_name,
message='File extension should contain only letters, numbers and dots (inside-only)',
message='File extension should contain only letters, numbers, '
'and periods (inside-only)',
)]
return []

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

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

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

Expand Down Expand Up @@ -107,7 +111,7 @@ def _validate_package_id(field_name: str, value: str) -> List[ValidationError]:
if len(parts) != 3:
res.append(ValidationError(
field_name=field_name,
message='Package ID is not valid (only {len(parts)} parts)',
message=f'Package ID is not valid (only {len(parts)} parts)',
))
if re.match(REGEX_ORGANIZATION_ID, parts[0]) is None:
res.append(ValidationError(
Expand Down
18 changes: 9 additions & 9 deletions packages/dsw-tdk/requirements.test.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
aiohappyeyeballs==2.4.4
aiohttp==3.11.11
aiohappyeyeballs==2.6.1
aiohttp==3.11.14
aiosignal==1.3.2
anyio==4.6.2.post1
attrs==24.3.0
attrs==25.3.0
click==8.1.8
colorama==0.4.6
frozenlist==1.5.0
humanize==4.11.0
humanize==4.12.1
idna==3.10
iniconfig==2.0.0
Jinja2==3.1.5
Jinja2==3.1.6
MarkupSafe==3.0.2
multidict==6.1.0
multidict==6.2.0
packaging==24.2
pathspec==0.12.1
pluggy==1.5.0
propcache==0.2.1
pytest==8.3.4
propcache==0.3.0
pytest==8.3.5
pytest-recording==0.13.2
python-dotenv==1.0.1
python-slugify==8.0.4
Expand All @@ -26,6 +26,6 @@ sniffio==1.3.1
text-unidecode==1.3
urllib3==2.3.0
vcrpy==7.0.0
watchfiles==1.0.3
watchfiles==1.0.4
wrapt==1.17.0
yarl==1.18.3
4 changes: 2 additions & 2 deletions packages/dsw-tdk/tests/fixtures/test_faulty03/template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"organizationId": "te-st",
"templateId": "example.01",
"organizationId": "te-st?test",
"templateId": "example.01:test",
"version": "not a version",
"name": null,
"description": null,
Expand Down
4 changes: 2 additions & 2 deletions packages/dsw-tdk/tests/test_cmd_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def test_verify_invalid(fixtures_path: pathlib.Path):
result = runner.invoke(main, args=['verify', template_path.as_posix()])
assert result.exit_code == 0
assert 'The template is invalid!' in result.output
assert 'template_id: Template ID may contain only letters, numbers, and dash' in result.output
assert 'organization_id: Organization ID may contain only letters, numbers, and period' in result.output
assert 'template_id: Template ID may contain only letters, numbers,' in result.output
assert 'organization_id: Organization ID may contain only letters, numbers,' in result.output
assert 'version: Version must be in semver format' in result.output
assert 'name: Missing but it is required' in result.output
assert 'description: Missing but it is required' in result.output
Expand Down
Loading