@api-client/core 0.19.11 → 0.19.13
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/build/src/browser.d.ts +3 -1
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +2 -0
- package/build/src/browser.js.map +1 -1
- package/build/src/index.d.ts +3 -1
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -0
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/ApiValidation.d.ts +26 -0
- package/build/src/modeling/ApiValidation.d.ts.map +1 -0
- package/build/src/modeling/ApiValidation.js +73 -0
- package/build/src/modeling/ApiValidation.js.map +1 -0
- package/build/src/modeling/DomainValidation.d.ts +10 -4
- package/build/src/modeling/DomainValidation.d.ts.map +1 -1
- package/build/src/modeling/DomainValidation.js +55 -72
- package/build/src/modeling/DomainValidation.js.map +1 -1
- package/build/src/modeling/ExposedEntity.js +4 -4
- package/build/src/modeling/ExposedEntity.js.map +1 -1
- package/build/src/modeling/validation/api_model_rules.d.ts +1 -2
- package/build/src/modeling/validation/api_model_rules.d.ts.map +1 -1
- package/build/src/modeling/validation/api_model_rules.js +3 -29
- package/build/src/modeling/validation/api_model_rules.js.map +1 -1
- package/build/src/modeling/validation/association_validation.d.ts +4 -4
- package/build/src/modeling/validation/association_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/association_validation.js.map +1 -1
- package/build/src/modeling/validation/entity_validation.d.ts +6 -6
- package/build/src/modeling/validation/entity_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/entity_validation.js.map +1 -1
- package/build/src/modeling/validation/property_validation.d.ts +3 -3
- package/build/src/modeling/validation/property_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/property_validation.js.map +1 -1
- package/build/src/modeling/validation/rules.d.ts +2 -2
- package/build/src/modeling/validation/rules.d.ts.map +1 -1
- package/build/src/modeling/validation/rules.js.map +1 -1
- package/build/src/modeling/validation/semantic_validation.d.ts +2 -2
- package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -1
- package/build/src/modeling/validation/semantic_validation.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/modeling/ApiValidation.ts +86 -0
- package/src/modeling/DomainValidation.ts +57 -74
- package/src/modeling/ExposedEntity.ts +4 -4
- package/src/modeling/validation/api_model_rules.ts +4 -34
- package/src/modeling/validation/association_validation.ts +6 -6
- package/src/modeling/validation/entity_validation.ts +11 -11
- package/src/modeling/validation/property_validation.ts +4 -4
- package/src/modeling/validation/rules.ts +6 -3
- package/src/modeling/validation/semantic_validation.ts +11 -11
- package/tests/unit/modeling/domain_validation.spec.ts +7 -13
- package/tests/unit/modeling/exposed_entity.spec.ts +5 -5
- package/tests/unit/modeling/exposed_entity_setter_validation.spec.ts +5 -5
- package/tests/unit/modeling/validation/api_model_rules.spec.ts +24 -9
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DataDomainKind } from '../models/kinds.js';
|
|
2
1
|
import { AssociationValidation } from './validation/association_validation.js';
|
|
3
2
|
import { EntityValidation } from './validation/entity_validation.js';
|
|
4
3
|
import { PropertyValidation } from './validation/property_validation.js';
|
|
@@ -73,9 +72,32 @@ import { SemanticValidation } from './validation/semantic_validation.js';
|
|
|
73
72
|
* @see {@link SemanticValidation} for detailed semantic validation rules
|
|
74
73
|
*/
|
|
75
74
|
export class DomainValidation {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
domain;
|
|
76
|
+
report = [];
|
|
77
|
+
#infoCount = 0;
|
|
78
|
+
#warningCount = 0;
|
|
79
|
+
#errorCount = 0;
|
|
80
|
+
#counted = false;
|
|
81
|
+
get infoCount() {
|
|
82
|
+
if (!this.#counted) {
|
|
83
|
+
this.computeIssueCounters();
|
|
84
|
+
}
|
|
85
|
+
return this.#infoCount;
|
|
86
|
+
}
|
|
87
|
+
get warningCount() {
|
|
88
|
+
if (!this.#counted) {
|
|
89
|
+
this.computeIssueCounters();
|
|
90
|
+
}
|
|
91
|
+
return this.#warningCount;
|
|
92
|
+
}
|
|
93
|
+
get errorCount() {
|
|
94
|
+
if (!this.#counted) {
|
|
95
|
+
this.computeIssueCounters();
|
|
96
|
+
}
|
|
97
|
+
return this.#errorCount;
|
|
98
|
+
}
|
|
99
|
+
constructor(domain) {
|
|
100
|
+
this.domain = domain;
|
|
79
101
|
}
|
|
80
102
|
/**
|
|
81
103
|
* Performs comprehensive validation on the entire data domain.
|
|
@@ -87,91 +109,52 @@ export class DomainValidation {
|
|
|
87
109
|
* @returns A comprehensive validation report with all issues found
|
|
88
110
|
*/
|
|
89
111
|
validate() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const entityValidator = new EntityValidation(this.root);
|
|
97
|
-
const propertyValidator = new PropertyValidation(this.root);
|
|
98
|
-
const associationValidator = new AssociationValidation(this.root);
|
|
99
|
-
const semanticValidator = new SemanticValidation(this.root);
|
|
112
|
+
this.#counted = false;
|
|
113
|
+
this.report = [];
|
|
114
|
+
const entityValidator = new EntityValidation(this.domain);
|
|
115
|
+
const propertyValidator = new PropertyValidation(this.domain);
|
|
116
|
+
const associationValidator = new AssociationValidation(this.domain);
|
|
117
|
+
const semanticValidator = new SemanticValidation(this.domain);
|
|
100
118
|
let hasEntities = false;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (entity.domain.key !== this.root.key) {
|
|
119
|
+
for (const entity of this.domain.listEntities()) {
|
|
120
|
+
if (entity.domain.key !== this.domain.key) {
|
|
104
121
|
// we don't need to validate foreign entities
|
|
105
122
|
continue;
|
|
106
123
|
}
|
|
107
124
|
hasEntities = true;
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
const blocking = item.severity === 'error';
|
|
111
|
-
result.canProceed = result.canProceed && !blocking;
|
|
112
|
-
result.impact.push({
|
|
113
|
-
key: item.key,
|
|
114
|
-
kind: item.kind,
|
|
115
|
-
type: 'publish',
|
|
116
|
-
impact: item.message,
|
|
117
|
-
resolution: item.help,
|
|
118
|
-
severity: item.severity,
|
|
119
|
-
parent: item.parent,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
125
|
+
const entities = entityValidator.validate(entity);
|
|
126
|
+
this.report.push(...entities);
|
|
122
127
|
for (const property of entity.properties) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
result.canProceed = result.canProceed && !blocking;
|
|
127
|
-
result.impact.push({
|
|
128
|
-
key: item.key,
|
|
129
|
-
kind: item.kind,
|
|
130
|
-
type: 'publish',
|
|
131
|
-
impact: item.message,
|
|
132
|
-
resolution: item.help,
|
|
133
|
-
severity: item.severity,
|
|
134
|
-
parent: item.parent,
|
|
135
|
-
});
|
|
128
|
+
if (property.domain.key !== this.domain.key) {
|
|
129
|
+
// we don't need to validate foreign properties
|
|
130
|
+
continue;
|
|
136
131
|
}
|
|
132
|
+
const properties = propertyValidator.validate(property);
|
|
133
|
+
this.report.push(...properties);
|
|
137
134
|
}
|
|
138
135
|
for (const association of entity.associations) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
result.canProceed = result.canProceed && !blocking;
|
|
143
|
-
result.impact.push({
|
|
144
|
-
key: item.key,
|
|
145
|
-
kind: item.kind,
|
|
146
|
-
type: 'publish',
|
|
147
|
-
impact: item.message,
|
|
148
|
-
resolution: item.help,
|
|
149
|
-
severity: item.severity,
|
|
150
|
-
parent: item.parent,
|
|
151
|
-
});
|
|
136
|
+
if (association.domain.key !== this.domain.key) {
|
|
137
|
+
// we don't need to validate foreign properties
|
|
138
|
+
continue;
|
|
152
139
|
}
|
|
140
|
+
const associations = associationValidator.validate(association);
|
|
141
|
+
this.report.push(...associations);
|
|
153
142
|
}
|
|
154
143
|
}
|
|
155
144
|
if (!hasEntities) {
|
|
156
145
|
// no entities, no need to validate anything else
|
|
157
|
-
return
|
|
146
|
+
return this.report;
|
|
158
147
|
}
|
|
159
148
|
// Validate semantics
|
|
160
149
|
const semanticReport = semanticValidator.validate();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
resolution: item.help,
|
|
170
|
-
severity: item.severity,
|
|
171
|
-
parent: item.parent,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return result;
|
|
150
|
+
this.report.push(...semanticReport);
|
|
151
|
+
return this.report;
|
|
152
|
+
}
|
|
153
|
+
computeIssueCounters() {
|
|
154
|
+
this.#infoCount = this.report.filter((validation) => validation.severity === 'info').length;
|
|
155
|
+
this.#warningCount = this.report.filter((validation) => validation.severity === 'warning').length;
|
|
156
|
+
this.#errorCount = this.report.filter((validation) => validation.severity === 'error').length;
|
|
157
|
+
this.#counted = true;
|
|
175
158
|
}
|
|
176
159
|
}
|
|
177
160
|
//# sourceMappingURL=DomainValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainValidation.js","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAY;IAExB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ;QACN,MAAM,MAAM,GAAuB;YACjC,GAAG,EAAE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B,QAAQ,EAAE,IAAI,CAAC,QAAQ;wBACvB,MAAM,EAAE,IAAI,CAAC,MAAM;qBACpB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,iDAAiD;YACjD,OAAO,MAAM,CAAA;QACf,CAAC;QACD,qBAAqB;QACrB,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAA;QACnD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;YAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,KAAK,OAAO,CAAA;YAC1C,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,CAAC,QAAQ,CAAA;YAClD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,IAAI,CAAC,OAAO;gBACpB,UAAU,EAAE,IAAI,CAAC,IAAI;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { DataDomainKind } from '../models/kinds.js'\nimport { DataDomain } from './DataDomain.js'\nimport type { DomainImpactReport } from './types.js'\nimport { AssociationValidation } from './validation/association_validation.js'\nimport { EntityValidation } from './validation/entity_validation.js'\nimport { PropertyValidation } from './validation/property_validation.js'\nimport { SemanticValidation } from './validation/semantic_validation.js'\n\n/**\n * DomainValidation performs comprehensive validation on a data domain and its components.\n *\n * This class orchestrates validation across all domain elements including entities, properties,\n * associations, and semantics. It ensures that the data domain is well-formed and follows\n * established conventions before it can be published or used in API generation.\n *\n * ## Validation Scope\n *\n * The validation process covers:\n * - **Entities**: Structure, naming, primary keys, and inheritance\n * - **Properties**: Naming conventions, data types, and constraints\n * - **Associations**: Relationships, targets, and naming\n * - **Semantics**: Recommended patterns and best practices\n *\n * ## Validation Severity Levels\n *\n * - **Error**: Blocking issues that prevent domain publication\n * - **Warning**: Issues that may cause problems but don't block publication\n * - **Info**: Recommendations for best practices\n *\n * ## Usage\n *\n * ```typescript\n * const domain = new DataDomain()\n * // ... add entities, properties, associations\n *\n * const validator = new DomainValidation(domain)\n * const report = validator.validate()\n *\n * if (report.canProceed) {\n * // Domain is valid and can be published\n * } else {\n * // Handle validation errors\n * console.log(report.impact)\n * }\n * ```\n *\n * ## Validation Rules\n *\n * ### Entity Validation Rules\n * - **Primary Key**: Each entity must have a primary key (can be inherited)\n * - **Minimum Properties**: Entities should have properties or associations (can be inherited)\n * - **Naming**: Entity names must follow PostgreSQL naming conventions\n * - **Uniqueness**: Entity names must be unique within the domain\n *\n * ### Property Validation Rules\n * - **Naming**: Properties must follow PostgreSQL column naming conventions\n * - **Length**: Names must be 2-59 characters long\n * - **Format**: Names must start with letter/underscore, contain only alphanumeric/underscore\n * - **Reserved Words**: Names cannot be PostgreSQL reserved keywords\n * - **Case**: Snake case is recommended (lowercase with underscores)\n *\n * ### Association Validation Rules\n * - **Targets**: Associations must have at least one target entity\n * - **Target Existence**: Target entities must exist in the domain\n * - **Naming**: Same rules as properties\n *\n * ### Semantic Validation Rules\n * - **User Entity**: Recommended to have at least one entity with User semantic\n * - **Timestamps**: Recommended to have CreatedTimestamp and UpdatedTimestamp properties\n * - **Soft Delete**: Recommended to have soft delete capability for entities\n * - **Data Types**: Semantic-specific data type validation\n *\n * @see {@link EntityValidation} for detailed entity validation rules\n * @see {@link PropertyValidation} for detailed property validation rules\n * @see {@link AssociationValidation} for detailed association validation rules\n * @see {@link SemanticValidation} for detailed semantic validation rules\n */\nexport class DomainValidation {\n private root: DataDomain\n\n constructor(root: DataDomain) {\n this.root = root\n }\n\n /**\n * Performs comprehensive validation on the entire data domain.\n *\n * This method validates all entities, properties, associations, and semantics\n * in the domain. It returns a detailed report of all validation issues found,\n * categorized by severity level.\n *\n * @returns A comprehensive validation report with all issues found\n */\n validate(): DomainImpactReport {\n const result: DomainImpactReport = {\n key: '',\n kind: DataDomainKind,\n impact: [],\n canProceed: true,\n }\n const entityValidator = new EntityValidation(this.root)\n const propertyValidator = new PropertyValidation(this.root)\n const associationValidator = new AssociationValidation(this.root)\n const semanticValidator = new SemanticValidation(this.root)\n\n let hasEntities = false\n // Validate entities, properties, and associations\n for (const entity of this.root.listEntities()) {\n if (entity.domain.key !== this.root.key) {\n // we don't need to validate foreign entities\n continue\n }\n hasEntities = true\n const report = entityValidator.validate(entity)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n for (const property of entity.properties) {\n const report = propertyValidator.validate(property)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n for (const association of entity.associations) {\n const report = associationValidator.validate(association)\n for (const item of report) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n }\n }\n if (!hasEntities) {\n // no entities, no need to validate anything else\n return result\n }\n // Validate semantics\n const semanticReport = semanticValidator.validate()\n for (const item of semanticReport) {\n const blocking = item.severity === 'error'\n result.canProceed = result.canProceed && !blocking\n result.impact.push({\n key: item.key,\n kind: item.kind,\n type: 'publish',\n impact: item.message,\n resolution: item.help,\n severity: item.severity,\n parent: item.parent,\n })\n }\n\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainValidation.js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C/C,SAAQ;gBACV,CAAC;gBACD,MAAM,YAAY,GAAG,oBAAoB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;gBAC/D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;QACD,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,iDAAiD;YACjD,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QACD,qBAAqB;QACrB,MAAM,cAAc,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAA;QACnD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAA;QACnC,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,oBAAoB;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,MAAM,CAAA;QAC3F,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,MAAM,CAAA;QACjG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,MAAM,CAAA;QAC7F,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;IACtB,CAAC;CACF","sourcesContent":["import { DataDomain } from './DataDomain.js'\nimport { AssociationValidation } from './validation/association_validation.js'\nimport { EntityValidation } from './validation/entity_validation.js'\nimport { PropertyValidation } from './validation/property_validation.js'\nimport { DomainValidationSchema } from './validation/rules.js'\nimport { SemanticValidation } from './validation/semantic_validation.js'\n\n/**\n * DomainValidation performs comprehensive validation on a data domain and its components.\n *\n * This class orchestrates validation across all domain elements including entities, properties,\n * associations, and semantics. It ensures that the data domain is well-formed and follows\n * established conventions before it can be published or used in API generation.\n *\n * ## Validation Scope\n *\n * The validation process covers:\n * - **Entities**: Structure, naming, primary keys, and inheritance\n * - **Properties**: Naming conventions, data types, and constraints\n * - **Associations**: Relationships, targets, and naming\n * - **Semantics**: Recommended patterns and best practices\n *\n * ## Validation Severity Levels\n *\n * - **Error**: Blocking issues that prevent domain publication\n * - **Warning**: Issues that may cause problems but don't block publication\n * - **Info**: Recommendations for best practices\n *\n * ## Usage\n *\n * ```typescript\n * const domain = new DataDomain()\n * // ... add entities, properties, associations\n *\n * const validator = new DomainValidation(domain)\n * const report = validator.validate()\n *\n * if (report.canProceed) {\n * // Domain is valid and can be published\n * } else {\n * // Handle validation errors\n * console.log(report.impact)\n * }\n * ```\n *\n * ## Validation Rules\n *\n * ### Entity Validation Rules\n * - **Primary Key**: Each entity must have a primary key (can be inherited)\n * - **Minimum Properties**: Entities should have properties or associations (can be inherited)\n * - **Naming**: Entity names must follow PostgreSQL naming conventions\n * - **Uniqueness**: Entity names must be unique within the domain\n *\n * ### Property Validation Rules\n * - **Naming**: Properties must follow PostgreSQL column naming conventions\n * - **Length**: Names must be 2-59 characters long\n * - **Format**: Names must start with letter/underscore, contain only alphanumeric/underscore\n * - **Reserved Words**: Names cannot be PostgreSQL reserved keywords\n * - **Case**: Snake case is recommended (lowercase with underscores)\n *\n * ### Association Validation Rules\n * - **Targets**: Associations must have at least one target entity\n * - **Target Existence**: Target entities must exist in the domain\n * - **Naming**: Same rules as properties\n *\n * ### Semantic Validation Rules\n * - **User Entity**: Recommended to have at least one entity with User semantic\n * - **Timestamps**: Recommended to have CreatedTimestamp and UpdatedTimestamp properties\n * - **Soft Delete**: Recommended to have soft delete capability for entities\n * - **Data Types**: Semantic-specific data type validation\n *\n * @see {@link EntityValidation} for detailed entity validation rules\n * @see {@link PropertyValidation} for detailed property validation rules\n * @see {@link AssociationValidation} for detailed association validation rules\n * @see {@link SemanticValidation} for detailed semantic validation rules\n */\nexport class DomainValidation {\n report: DomainValidationSchema[] = []\n #infoCount = 0\n #warningCount = 0\n #errorCount = 0\n #counted = false\n\n get infoCount(): number {\n if (!this.#counted) {\n this.computeIssueCounters()\n }\n return this.#infoCount\n }\n\n get warningCount(): number {\n if (!this.#counted) {\n this.computeIssueCounters()\n }\n return this.#warningCount\n }\n\n get errorCount(): number {\n if (!this.#counted) {\n this.computeIssueCounters()\n }\n return this.#errorCount\n }\n\n constructor(protected domain: DataDomain) {}\n\n /**\n * Performs comprehensive validation on the entire data domain.\n *\n * This method validates all entities, properties, associations, and semantics\n * in the domain. It returns a detailed report of all validation issues found,\n * categorized by severity level.\n *\n * @returns A comprehensive validation report with all issues found\n */\n validate(): DomainValidationSchema[] {\n this.#counted = false\n this.report = []\n const entityValidator = new EntityValidation(this.domain)\n const propertyValidator = new PropertyValidation(this.domain)\n const associationValidator = new AssociationValidation(this.domain)\n const semanticValidator = new SemanticValidation(this.domain)\n\n let hasEntities = false\n for (const entity of this.domain.listEntities()) {\n if (entity.domain.key !== this.domain.key) {\n // we don't need to validate foreign entities\n continue\n }\n hasEntities = true\n const entities = entityValidator.validate(entity)\n this.report.push(...entities)\n for (const property of entity.properties) {\n if (property.domain.key !== this.domain.key) {\n // we don't need to validate foreign properties\n continue\n }\n const properties = propertyValidator.validate(property)\n this.report.push(...properties)\n }\n for (const association of entity.associations) {\n if (association.domain.key !== this.domain.key) {\n // we don't need to validate foreign properties\n continue\n }\n const associations = associationValidator.validate(association)\n this.report.push(...associations)\n }\n }\n if (!hasEntities) {\n // no entities, no need to validate anything else\n return this.report\n }\n // Validate semantics\n const semanticReport = semanticValidator.validate()\n this.report.push(...semanticReport)\n return this.report\n }\n\n computeIssueCounters(): void {\n this.#infoCount = this.report.filter((validation) => validation.severity === 'info').length\n this.#warningCount = this.report.filter((validation) => validation.severity === 'warning').length\n this.#errorCount = this.report.filter((validation) => validation.severity === 'error').length\n this.#counted = true\n }\n}\n"]}
|
|
@@ -326,9 +326,9 @@ let ExposedEntity = (() => {
|
|
|
326
326
|
}
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
|
-
// No collection: allow
|
|
330
|
-
if (segments.length !==
|
|
331
|
-
throw new Error(`Resource path must contain exactly
|
|
329
|
+
// No collection: allow exactly one segment
|
|
330
|
+
if (segments.length !== 1) {
|
|
331
|
+
throw new Error(`Resource path must contain exactly one segment when no collection is present. Received: "${cleaned}"`);
|
|
332
332
|
}
|
|
333
333
|
// Check for collision if this is a root entity (singleton case)
|
|
334
334
|
if (this.isRoot) {
|
|
@@ -338,7 +338,7 @@ let ExposedEntity = (() => {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
if (this.resourcePath !== cleaned) {
|
|
341
|
-
this.resourcePath = `/${segments[0]}
|
|
341
|
+
this.resourcePath = `/${segments[0]}`;
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExposedEntity.js","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAE5E,OAAO,EAAsB,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AAGhF;;;;;;;;;;;;;GAaG;IACU,aAAa;sBAAS,WAAW;;;;;;;;;;;;;;;;;;;iBAAjC,aAAc,SAAQ,WAAW;;;kCAe3C,QAAQ,EAAE;0CAeV,QAAQ,EAAE;wCAMV,QAA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import { nanoid } from '../nanoid.js'\nimport { Action } from './actions/Action.js'\nimport { restoreAction } from './actions/index.js'\nimport type { ApiModel } from './ApiModel.js'\nimport { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js'\nimport { AccessRule } from './rules/AccessRule.js'\nimport { type RateLimitRule, restoreAccessRule } from './rules/index.js'\nimport { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js'\nimport type { AssociationTarget, ExposeOptions, ExposeParentRef, ExposedEntitySchema } from './types.js'\n\n/**\n * A class that specializes in representing an exposed Data Entity within an API Model.\n *\n * ## Design Note\n * This class enforces strict path constraints (e.g., single-segment collection paths like `/users`,\n * two-segment resource paths like `/users/{id}`).\n * This is an intentional design choice to support a UI paradigm for non-technical users, ensuring that\n * path segments are configured individually at each level of the exposure hierarchy.\n *\n * Flexibility is achieved by chaining exposed entities (parent/child relationships), where the final\n * absolute path is composed of all ancestral paths. See `getAbsoluteResourcePath()` and `getAbsoluteCollectionPath()`.\n *\n * @fires change - Emitted when the exposed entity has changed.\n */\nexport class ExposedEntity extends EventTarget {\n /**\n * The exposed entity kind recognizable by the ecosystem.\n */\n kind: typeof ExposedEntityKind\n\n /**\n * The unique key of the exposed entity.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * A pointer to a Data Entity from the Data Domain.\n */\n @observed() accessor entity: AssociationTarget\n\n /**\n * Indicates whether this exposure has a collection endpoint.\n * A collection endpoint is optional for nested exposures where the association is 1:1\n * and the schema is embedded directly under the parent resource.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n hasCollection: boolean\n\n /**\n * Path to the collection endpoint for this exposure.\n * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.\n */\n @observed() accessor collectionPath: string | undefined\n\n /**\n * Path to the resource endpoint for this exposure.\n * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.\n */\n @observed() accessor resourcePath: string\n\n /**\n * Whether this exposure is a root exposure (top-level collection).\n * If this is set then the `parent` reference must be populated.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n parent?: ExposeParentRef\n\n /**\n * Expose-time config used to create this exposure (persisted for auditing/UI).\n * This is only populated for the root exposure. All children exposures inherit this config.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n @observed({ deep: true }) accessor actions: Action[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n @observed({ deep: true }) accessor accessRule: AccessRule[] | undefined\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n\n /**\n * When true, generation for this exposure hit configured limits\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n truncated?: boolean\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n /**\n * A reference to the parent API Model instance.\n */\n api: ApiModel\n\n static createSchema(input: Partial<ExposedEntitySchema> = {}): ExposedEntitySchema {\n const {\n key = nanoid(),\n entity = { key: '' },\n collectionPath,\n resourcePath = '/',\n hasCollection = true,\n isRoot,\n parent,\n exposeOptions,\n actions = [],\n accessRule,\n rateLimiting,\n truncated,\n } = input\n const result: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key,\n entity: { ...entity },\n hasCollection,\n resourcePath,\n actions: actions.map((a) => ({ ...a })),\n }\n if (collectionPath !== undefined) {\n result.collectionPath = collectionPath\n }\n if (isRoot !== undefined) {\n result.isRoot = isRoot\n }\n if (parent !== undefined) {\n result.parent = { ...parent }\n }\n if (exposeOptions !== undefined) {\n result.exposeOptions = { ...exposeOptions }\n }\n if (Array.isArray(accessRule)) {\n result.accessRule = accessRule.map((ar) => ({ ...ar }))\n }\n if (rateLimiting !== undefined) {\n result.rateLimiting = { ...rateLimiting }\n }\n if (truncated !== undefined) {\n result.truncated = truncated\n }\n return result\n }\n\n constructor(model: ApiModel, state?: Partial<ExposedEntitySchema>) {\n super()\n this.api = model\n const init = ExposedEntity.createSchema(state)\n this.kind = init.kind\n this.key = init.key\n this.entity = init.entity\n this.hasCollection = init.hasCollection\n this.collectionPath = init.collectionPath\n this.resourcePath = init.resourcePath\n this.isRoot = init.isRoot\n this.parent = init.parent\n this.exposeOptions = init.exposeOptions\n this.actions = init.actions ? init.actions.map((a) => restoreAction(this, a)) : []\n this.accessRule = init.accessRule ? init.accessRule.map((ar) => restoreAccessRule(ar)) : []\n this.rateLimiting = init.rateLimiting ? new RateLimitingConfiguration(init.rateLimiting) : undefined\n this.truncated = init.truncated\n this.#initializing = false\n }\n\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n toJSON(): ExposedEntitySchema {\n const result: ExposedEntitySchema = {\n kind: this.kind,\n key: this.key,\n entity: { ...this.entity },\n resourcePath: this.resourcePath,\n actions: this.actions.map((a) => a.toJSON()),\n hasCollection: this.hasCollection,\n }\n if (this.collectionPath !== undefined) {\n result.collectionPath = this.collectionPath\n }\n if (this.isRoot !== undefined) {\n result.isRoot = this.isRoot\n }\n if (this.parent !== undefined) {\n result.parent = { ...this.parent }\n }\n if (this.exposeOptions !== undefined) {\n result.exposeOptions = { ...this.exposeOptions }\n }\n if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((ar) => ar.toJSON())\n }\n if (this.rateLimiting !== undefined) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n if (this.truncated !== undefined) {\n result.truncated = this.truncated\n }\n return result\n }\n\n /**\n * Sets a new collection path for this exposed entity.\n *\n * It:\n * - updates the collectionPath property\n * - updates the absoluteCollectionPath property accordingly\n * - updates the resourcePath accordingly.\n * @param path The new path to set.\n */\n setCollectionPath(path: string) {\n if (!this.hasCollection) {\n throw new Error(`Cannot set collection path on an exposure that does not have a collection`)\n }\n const cleaned = ensureLeadingSlash(path)\n // Ensure exactly one non-empty segment\n const segments = cleaned.split('/').filter(Boolean)\n if (segments.length !== 1) {\n throw new Error(`Collection path must contain exactly one segment. Received: \"${path}\"`)\n }\n const normalizedCollection = `/${segments[0]}`\n\n // Check for collision if this is a root entity\n if (this.isRoot) {\n const collision = this.api.findCollectionPathCollision(normalizedCollection, this.key)\n if (collision) {\n throw new Error(`Collection path \"${normalizedCollection}\" is already in use by another root entity.`)\n }\n }\n\n // Preserve current parameter name if present, otherwise default to {id}\n let param = '{id}'\n if (this.resourcePath) {\n const curSegments = this.resourcePath.split('/').filter(Boolean)\n const maybeParam = curSegments[1]\n if (maybeParam && /^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(maybeParam)) {\n param = maybeParam\n }\n }\n const nextResource = `${normalizedCollection}/${param}`\n this.collectionPath = normalizedCollection\n this.resourcePath = nextResource\n // rely on ApiModel.exposes deep observation to notify on property sets\n }\n\n /**\n * Sets a new resource path for this exposed entity.\n *\n * Rules:\n * - Must start with '/'.\n * - If this exposure has a collection, the path must be exactly the collection path plus a single\n * parameter segment (e.g. `/products/{productId}`) and only the parameter name may vary.\n * - If this exposure does NOT have a collection, the path can be any two segments (e.g. `/profile/{id}` or `/a/b`).\n */\n setResourcePath(path: string) {\n const cleaned = ensureLeadingSlash(path)\n const segments = cleaned.split('/').filter(Boolean)\n\n if (this.hasCollection) {\n if (!this.collectionPath) {\n throw new Error('Cannot set resource path: missing collection path for this exposure')\n }\n const colSegments = this.collectionPath.split('/').filter(Boolean)\n if (colSegments.length !== 1) {\n throw new Error(`Invalid stored collection path \"${this.collectionPath}\"`)\n }\n if (segments.length !== 2) {\n throw new Error(`Resource path must be exactly two segments (collection + parameter). Received: \"${cleaned}\"`)\n }\n const [s1, s2] = segments\n if (s1 !== colSegments[0]) {\n throw new Error(`Resource path must start with the collection segment \"${colSegments[0]}\". Received: \"${s1}\"`)\n }\n // s2 must be a parameter segment {name}\n if (!/^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(s2)) {\n throw new Error(`The second segment must be a parameter in braces, e.g. {id}. Received: \"${s2}\"`)\n }\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${s1}/${s2}`\n }\n return\n }\n\n // No collection: allow any two segments\n if (segments.length !== 2) {\n throw new Error(\n `Resource path must contain exactly two segments when no collection is present. Received: \"${cleaned}\"`\n )\n }\n // Check for collision if this is a root entity (singleton case)\n if (this.isRoot) {\n const collision = this.api.findResourcePathCollision(cleaned, this.key)\n if (collision) {\n throw new Error(`Resource path \"${cleaned}\" is already in use by another root entity.`)\n }\n }\n\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${segments[0]}/${segments[1]}`\n }\n }\n\n /**\n * Computes the absolute path for this exposure's resource endpoint by\n * walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's resource path.\n */\n getAbsoluteResourcePath(): string {\n let absolute = ensureLeadingSlash(this.resourcePath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Computes the absolute path for this exposure's collection endpoint (if any)\n * by walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's collection path.\n * Returns undefined if this exposure has no collection.\n */\n getAbsoluteCollectionPath(): string | undefined {\n if (!this.hasCollection || !this.collectionPath) return undefined\n let absolute = ensureLeadingSlash(this.collectionPath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Returns all access rules for this exposure, including the ones from all the parents up to the API.\n */\n getAllRules(): AccessRule[] {\n const rules: AccessRule[] = []\n this.api.accessRule.forEach((rule) => rules.push(rule))\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.accessRule) {\n rules.push(...current.accessRule)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n\n /**\n * Returns all rate limiters for this exposure, including the ones from all the parents up to the API.\n */\n getAllRateLimiters(): RateLimitingConfiguration[] {\n const rateLimiters: RateLimitingConfiguration[] = []\n if (this.api.rateLimiting) {\n rateLimiters.push(this.api.rateLimiting)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rateLimiters.push(current.rateLimiting)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rateLimiters\n }\n\n /**\n * Returns all rate limiter rules for this exposure, including the ones from all the parents up to the API.\n * Similar to the getAllRules() method, but it flattens the rate limiters into a single list of rules.\n */\n getAllRateLimiterRules(): RateLimitRule[] {\n const rules: RateLimitRule[] = []\n if (this.api.rateLimiting) {\n rules.push(...this.api.rateLimiting.rules)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rules.push(...current.rateLimiting.rules)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ExposedEntity.js","sourceRoot":"","sources":["../../../src/modeling/ExposedEntity.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACpD,OA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,EAAE,CAAC;gBACf,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;oBACzB,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;gBAC3C,CAAC;gBACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YACjF,CAAC;YACD,OAAO,KAAK,CAAA;QACd,CAAC;;;SAzZU,aAAa","sourcesContent":["import { observed } from '../decorators/observed.js'\nimport { ExposedEntityKind } from '../models/kinds.js'\nimport { nanoid } from '../nanoid.js'\nimport { Action } from './actions/Action.js'\nimport { restoreAction } from './actions/index.js'\nimport type { ApiModel } from './ApiModel.js'\nimport { ensureLeadingSlash, joinPaths } from './helpers/endpointHelpers.js'\nimport { AccessRule } from './rules/AccessRule.js'\nimport { type RateLimitRule, restoreAccessRule } from './rules/index.js'\nimport { RateLimitingConfiguration } from './rules/RateLimitingConfiguration.js'\nimport type { AssociationTarget, ExposeOptions, ExposeParentRef, ExposedEntitySchema } from './types.js'\n\n/**\n * A class that specializes in representing an exposed Data Entity within an API Model.\n *\n * ## Design Note\n * This class enforces strict path constraints (e.g., single-segment collection paths like `/users`,\n * two-segment resource paths like `/users/{id}`).\n * This is an intentional design choice to support a UI paradigm for non-technical users, ensuring that\n * path segments are configured individually at each level of the exposure hierarchy.\n *\n * Flexibility is achieved by chaining exposed entities (parent/child relationships), where the final\n * absolute path is composed of all ancestral paths. See `getAbsoluteResourcePath()` and `getAbsoluteCollectionPath()`.\n *\n * @fires change - Emitted when the exposed entity has changed.\n */\nexport class ExposedEntity extends EventTarget {\n /**\n * The exposed entity kind recognizable by the ecosystem.\n */\n kind: typeof ExposedEntityKind\n\n /**\n * The unique key of the exposed entity.\n * This is a stable identifier that does not change across versions.\n */\n key: string\n\n /**\n * A pointer to a Data Entity from the Data Domain.\n */\n @observed() accessor entity: AssociationTarget\n\n /**\n * Indicates whether this exposure has a collection endpoint.\n * A collection endpoint is optional for nested exposures where the association is 1:1\n * and the schema is embedded directly under the parent resource.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n hasCollection: boolean\n\n /**\n * Path to the collection endpoint for this exposure.\n * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.\n */\n @observed() accessor collectionPath: string | undefined\n\n /**\n * Path to the resource endpoint for this exposure.\n * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.\n */\n @observed() accessor resourcePath: string\n\n /**\n * Whether this exposure is a root exposure (top-level collection).\n * If this is set then the `parent` reference must be populated.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n parent?: ExposeParentRef\n\n /**\n * Expose-time config used to create this exposure (persisted for auditing/UI).\n * This is only populated for the root exposure. All children exposures inherit this config.\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n @observed({ deep: true }) accessor actions: Action[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n @observed({ deep: true }) accessor accessRule: AccessRule[] | undefined\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n @observed() accessor rateLimiting: RateLimitingConfiguration | undefined\n\n /**\n * When true, generation for this exposure hit configured limits\n *\n * Note that this property is not observed for changes as it is immutable after creation.\n */\n truncated?: boolean\n\n /**\n * When the notifying flag is set to true,\n * the domain is pending a notification.\n * No other notifications will be sent until\n * the current notification is sent.\n */\n #notifying = false\n /**\n * When the initializing flag is set to true,\n * the domain is not notified of changes.\n */\n #initializing = true\n /**\n * A reference to the parent API Model instance.\n */\n api: ApiModel\n\n static createSchema(input: Partial<ExposedEntitySchema> = {}): ExposedEntitySchema {\n const {\n key = nanoid(),\n entity = { key: '' },\n collectionPath,\n resourcePath = '/',\n hasCollection = true,\n isRoot,\n parent,\n exposeOptions,\n actions = [],\n accessRule,\n rateLimiting,\n truncated,\n } = input\n const result: ExposedEntitySchema = {\n kind: ExposedEntityKind,\n key,\n entity: { ...entity },\n hasCollection,\n resourcePath,\n actions: actions.map((a) => ({ ...a })),\n }\n if (collectionPath !== undefined) {\n result.collectionPath = collectionPath\n }\n if (isRoot !== undefined) {\n result.isRoot = isRoot\n }\n if (parent !== undefined) {\n result.parent = { ...parent }\n }\n if (exposeOptions !== undefined) {\n result.exposeOptions = { ...exposeOptions }\n }\n if (Array.isArray(accessRule)) {\n result.accessRule = accessRule.map((ar) => ({ ...ar }))\n }\n if (rateLimiting !== undefined) {\n result.rateLimiting = { ...rateLimiting }\n }\n if (truncated !== undefined) {\n result.truncated = truncated\n }\n return result\n }\n\n constructor(model: ApiModel, state?: Partial<ExposedEntitySchema>) {\n super()\n this.api = model\n const init = ExposedEntity.createSchema(state)\n this.kind = init.kind\n this.key = init.key\n this.entity = init.entity\n this.hasCollection = init.hasCollection\n this.collectionPath = init.collectionPath\n this.resourcePath = init.resourcePath\n this.isRoot = init.isRoot\n this.parent = init.parent\n this.exposeOptions = init.exposeOptions\n this.actions = init.actions ? init.actions.map((a) => restoreAction(this, a)) : []\n this.accessRule = init.accessRule ? init.accessRule.map((ar) => restoreAccessRule(ar)) : []\n this.rateLimiting = init.rateLimiting ? new RateLimitingConfiguration(init.rateLimiting) : undefined\n this.truncated = init.truncated\n this.#initializing = false\n }\n\n notifyChange() {\n if (this.#notifying || this.#initializing) {\n return\n }\n this.#notifying = true\n queueMicrotask(() => {\n this.#notifying = false\n const event = new Event('change')\n this.dispatchEvent(event)\n })\n }\n\n toJSON(): ExposedEntitySchema {\n const result: ExposedEntitySchema = {\n kind: this.kind,\n key: this.key,\n entity: { ...this.entity },\n resourcePath: this.resourcePath,\n actions: this.actions.map((a) => a.toJSON()),\n hasCollection: this.hasCollection,\n }\n if (this.collectionPath !== undefined) {\n result.collectionPath = this.collectionPath\n }\n if (this.isRoot !== undefined) {\n result.isRoot = this.isRoot\n }\n if (this.parent !== undefined) {\n result.parent = { ...this.parent }\n }\n if (this.exposeOptions !== undefined) {\n result.exposeOptions = { ...this.exposeOptions }\n }\n if (Array.isArray(this.accessRule) && this.accessRule.length > 0) {\n result.accessRule = this.accessRule.map((ar) => ar.toJSON())\n }\n if (this.rateLimiting !== undefined) {\n result.rateLimiting = this.rateLimiting.toJSON()\n }\n if (this.truncated !== undefined) {\n result.truncated = this.truncated\n }\n return result\n }\n\n /**\n * Sets a new collection path for this exposed entity.\n *\n * It:\n * - updates the collectionPath property\n * - updates the absoluteCollectionPath property accordingly\n * - updates the resourcePath accordingly.\n * @param path The new path to set.\n */\n setCollectionPath(path: string) {\n if (!this.hasCollection) {\n throw new Error(`Cannot set collection path on an exposure that does not have a collection`)\n }\n const cleaned = ensureLeadingSlash(path)\n // Ensure exactly one non-empty segment\n const segments = cleaned.split('/').filter(Boolean)\n if (segments.length !== 1) {\n throw new Error(`Collection path must contain exactly one segment. Received: \"${path}\"`)\n }\n const normalizedCollection = `/${segments[0]}`\n\n // Check for collision if this is a root entity\n if (this.isRoot) {\n const collision = this.api.findCollectionPathCollision(normalizedCollection, this.key)\n if (collision) {\n throw new Error(`Collection path \"${normalizedCollection}\" is already in use by another root entity.`)\n }\n }\n\n // Preserve current parameter name if present, otherwise default to {id}\n let param = '{id}'\n if (this.resourcePath) {\n const curSegments = this.resourcePath.split('/').filter(Boolean)\n const maybeParam = curSegments[1]\n if (maybeParam && /^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(maybeParam)) {\n param = maybeParam\n }\n }\n const nextResource = `${normalizedCollection}/${param}`\n this.collectionPath = normalizedCollection\n this.resourcePath = nextResource\n // rely on ApiModel.exposes deep observation to notify on property sets\n }\n\n /**\n * Sets a new resource path for this exposed entity.\n *\n * Rules:\n * - Must start with '/'.\n * - If this exposure has a collection, the path must be exactly the collection path plus a single\n * parameter segment (e.g. `/products/{productId}`) and only the parameter name may vary.\n * - If this exposure does NOT have a collection, the path can be any two segments (e.g. `/profile/{id}` or `/a/b`).\n */\n setResourcePath(path: string) {\n const cleaned = ensureLeadingSlash(path)\n const segments = cleaned.split('/').filter(Boolean)\n\n if (this.hasCollection) {\n if (!this.collectionPath) {\n throw new Error('Cannot set resource path: missing collection path for this exposure')\n }\n const colSegments = this.collectionPath.split('/').filter(Boolean)\n if (colSegments.length !== 1) {\n throw new Error(`Invalid stored collection path \"${this.collectionPath}\"`)\n }\n if (segments.length !== 2) {\n throw new Error(`Resource path must be exactly two segments (collection + parameter). Received: \"${cleaned}\"`)\n }\n const [s1, s2] = segments\n if (s1 !== colSegments[0]) {\n throw new Error(`Resource path must start with the collection segment \"${colSegments[0]}\". Received: \"${s1}\"`)\n }\n // s2 must be a parameter segment {name}\n if (!/^\\{[A-Za-z_][A-Za-z0-9_]*\\}$/.test(s2)) {\n throw new Error(`The second segment must be a parameter in braces, e.g. {id}. Received: \"${s2}\"`)\n }\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${s1}/${s2}`\n }\n return\n }\n\n // No collection: allow exactly one segment\n if (segments.length !== 1) {\n throw new Error(\n `Resource path must contain exactly one segment when no collection is present. Received: \"${cleaned}\"`\n )\n }\n // Check for collision if this is a root entity (singleton case)\n if (this.isRoot) {\n const collision = this.api.findResourcePathCollision(cleaned, this.key)\n if (collision) {\n throw new Error(`Resource path \"${cleaned}\" is already in use by another root entity.`)\n }\n }\n\n if (this.resourcePath !== cleaned) {\n this.resourcePath = `/${segments[0]}`\n }\n }\n\n /**\n * Computes the absolute path for this exposure's resource endpoint by\n * walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's resource path.\n */\n getAbsoluteResourcePath(): string {\n let absolute = ensureLeadingSlash(this.resourcePath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Computes the absolute path for this exposure's collection endpoint (if any)\n * by walking up the exposure tree using `parent.key` until reaching a root exposure.\n * The absolute path is composed by concatenating each ancestor's resource path\n * with this exposure's collection path.\n * Returns undefined if this exposure has no collection.\n */\n getAbsoluteCollectionPath(): string | undefined {\n if (!this.hasCollection || !this.collectionPath) return undefined\n let absolute = ensureLeadingSlash(this.collectionPath)\n // Traverse parents, always joining with the parent's resource path\n let parentKey = this.parent?.key\n while (parentKey) {\n const parent = this.api.exposes.get(parentKey)\n if (!parent) break\n const parentResource = ensureLeadingSlash(parent.resourcePath)\n absolute = joinPaths(parentResource, absolute)\n parentKey = parent.parent?.key\n }\n return absolute\n }\n\n /**\n * Returns all access rules for this exposure, including the ones from all the parents up to the API.\n */\n getAllRules(): AccessRule[] {\n const rules: AccessRule[] = []\n this.api.accessRule.forEach((rule) => rules.push(rule))\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.accessRule) {\n rules.push(...current.accessRule)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n\n /**\n * Returns all rate limiters for this exposure, including the ones from all the parents up to the API.\n */\n getAllRateLimiters(): RateLimitingConfiguration[] {\n const rateLimiters: RateLimitingConfiguration[] = []\n if (this.api.rateLimiting) {\n rateLimiters.push(this.api.rateLimiting)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rateLimiters.push(current.rateLimiting)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rateLimiters\n }\n\n /**\n * Returns all rate limiter rules for this exposure, including the ones from all the parents up to the API.\n * Similar to the getAllRules() method, but it flattens the rate limiters into a single list of rules.\n */\n getAllRateLimiterRules(): RateLimitRule[] {\n const rules: RateLimitRule[] = []\n if (this.api.rateLimiting) {\n rules.push(...this.api.rateLimiting.rules)\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let current: ExposedEntity | undefined = this\n while (current) {\n if (current.rateLimiting) {\n rules.push(...current.rateLimiting.rules)\n }\n current = current.parent ? this.api.exposes.get(current.parent.key) : undefined\n }\n return rules\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ApiModel } from '../ApiModel.js';
|
|
2
2
|
import type { ExposedEntity } from '../ExposedEntity.js';
|
|
3
3
|
import type { Action } from '../actions/Action.js';
|
|
4
|
-
import type { ApiModelValidationItem
|
|
4
|
+
import type { ApiModelValidationItem } from '../types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Validates the core properties and metadata of an ApiModel.
|
|
7
7
|
*/
|
|
@@ -11,5 +11,4 @@ export declare function validateApiModelSecurity(model: ApiModel): ApiModelValid
|
|
|
11
11
|
export declare function validateApiModelMetadata(model: ApiModel): ApiModelValidationItem[];
|
|
12
12
|
export declare function validateAction(action: Action, parent: ExposedEntity, apiModelKey: string): ApiModelValidationItem[];
|
|
13
13
|
export declare function validateExposedEntity(entity: ExposedEntity, apiModel: ApiModel): ApiModelValidationItem[];
|
|
14
|
-
export declare function validateApiModel(model: ApiModel): ApiModelValidationResult;
|
|
15
14
|
//# sourceMappingURL=api_model_rules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_model_rules.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAMlD,OAAO,KAAK,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"api_model_rules.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAMlD,OAAO,KAAK,EAAE,sBAAsB,EAA6B,MAAM,aAAa,CAAA;AAapF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAiD9E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CA+BpF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAuKlF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAuElF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,sBAAsB,EAAE,CA2FnH;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,sBAAsB,EAAE,CAsKzG"}
|
|
@@ -488,11 +488,11 @@ export function validateExposedEntity(entity, apiModel) {
|
|
|
488
488
|
}
|
|
489
489
|
else {
|
|
490
490
|
const parts = entity.resourcePath.split('/').filter(Boolean);
|
|
491
|
-
if (parts.length !==
|
|
491
|
+
if (parts.length !== 1 || !entity.resourcePath.startsWith('/')) {
|
|
492
492
|
issues.push({
|
|
493
493
|
code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),
|
|
494
|
-
message: 'The URL route must only contain
|
|
495
|
-
suggestion: 'Simplify the endpoint URL to
|
|
494
|
+
message: 'The URL route must only contain one exact part or level.',
|
|
495
|
+
suggestion: 'Simplify the endpoint URL to a single segment.',
|
|
496
496
|
severity: 'error',
|
|
497
497
|
context: { ...context, property: 'resourcePath' },
|
|
498
498
|
});
|
|
@@ -570,30 +570,4 @@ export function validateExposedEntity(entity, apiModel) {
|
|
|
570
570
|
}
|
|
571
571
|
return issues;
|
|
572
572
|
}
|
|
573
|
-
export function validateApiModel(model) {
|
|
574
|
-
const issues = [];
|
|
575
|
-
issues.push(...validateApiModelInfo(model));
|
|
576
|
-
issues.push(...validateApiModelDependency(model));
|
|
577
|
-
issues.push(...validateApiModelSecurity(model));
|
|
578
|
-
issues.push(...validateApiModelMetadata(model));
|
|
579
|
-
if (!model.exposes || model.exposes.size === 0) {
|
|
580
|
-
issues.push({
|
|
581
|
-
code: createCode('API', 'NO_EXPOSURES'),
|
|
582
|
-
message: 'Your API currently has no exposed data for external clients to request.',
|
|
583
|
-
suggestion: 'Expose a data model so apps can communicate with it.',
|
|
584
|
-
severity: 'warning',
|
|
585
|
-
context: { apiModelKey: model.key, kind: ApiModelKind, key: model.key, property: 'exposes' },
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
for (const exposure of model.exposes.values()) {
|
|
590
|
-
issues.push(...validateExposedEntity(exposure, model));
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
const hasErrors = issues.some((i) => i.severity === 'error');
|
|
594
|
-
return {
|
|
595
|
-
isValid: !hasErrors,
|
|
596
|
-
issues,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
573
|
//# sourceMappingURL=api_model_rules.js.map
|