@api-client/core 0.19.11 → 0.19.12
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/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 +0 -26
- 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 +1 -1
- package/src/modeling/ApiValidation.ts +86 -0
- package/src/modeling/DomainValidation.ts +57 -74
- package/src/modeling/validation/api_model_rules.ts +1 -31
- 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/validation/api_model_rules.spec.ts +11 -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,EAAE;YACP,IAAI,EAAE,cAAc;YACpB,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,IAAI;SACjB,CAAA;QACD,MAAM,eAAe,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvD,MAAM,iB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ACjD,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","sourceRoot":"","sources":["../../../src/modeling/DomainValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AACpE,OAAO,EAAE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H,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"]}
|
|
@@ -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"}
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_model_rules.js","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAc,EAAE,KAAa;IAC/C,OAAO,GAAG,MAAM,IAAI,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAe;IAClD,MAAM,MAAM,GAA6B,EAAE,CAAA;IAC3C,MAAM,OAAO,GAA8B;QACzC,WAAW,EAAE,KAAK,CAAC,GAAG;QACtB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAA;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC;YACvC,OAAO,EAAE,kCAAkC;YAC3C,UAAU,EAAE,mCAAmC;YAC/C,QAAQ,EAAE,OAAO;YACjB,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE;SAC1C,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAA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AG,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3C,MAAM,CAAC,IAAI,CAAC,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC,CAAA;IACjD,MAAM,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/C,MAAM,CAAC,IAAI,CAAC,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAA;IAE/C,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC;YACvC,OAAO,EAAE,yEAAyE;YAClF,UAAU,EAAE,sDAAsD;YAClE,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE;SAC7F,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,GAAG,qBAAqB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;IAE5D,OAAO;QACL,OAAO,EAAE,CAAC,SAAS;QACnB,MAAM;KACP,CAAA;AACH,CAAC","sourcesContent":["import type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport type { Action } from '../actions/Action.js'\nimport { ListAction } from '../actions/ListAction.js'\nimport { DeleteAction } from '../actions/DeleteAction.js'\nimport { UpdateAction } from '../actions/UpdateAction.js'\nimport { SearchAction } from '../actions/SearchAction.js'\nimport type { RolesBasedAccessControl, UsernamePasswordConfiguration } from '../types.js'\nimport type { ApiModelValidationItem, ApiModelValidationResult, ApiModelValidationContext } from '../types.js'\nimport { ApiModelKind, ExposedEntityKind } from '../../models/kinds.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Creates a unique validation code.\n * @param entity The entity type (e.g., 'API', 'EXPOSURE', 'ACTION')\n * @param issue The issue identifier (e.g., 'MISSING_NAME')\n */\nfunction createCode(entity: string, issue: string): string {\n return `${entity}_${issue}`\n}\n\n/**\n * Validates the core properties and metadata of an ApiModel.\n */\nexport function validateApiModelInfo(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n if (model.kind !== ApiModelKind) {\n issues.push({\n code: createCode('API', 'INVALID_KIND'),\n message: 'The API model type is incorrect.',\n suggestion: 'Set the model type to \"ApiModel\".',\n severity: 'error',\n context: { ...context, property: 'kind' },\n })\n }\n\n if (!model.key || typeof model.key !== 'string' || model.key.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_KEY'),\n message: 'The API model is missing a unique identifier.',\n suggestion: 'Provide a valid name to use as a unique identifier.',\n severity: 'error',\n context: { ...context, property: 'key' },\n })\n }\n\n if (!model.info || !model.info.name || model.info.name.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_NAME'),\n message: 'The API model has no defined name.',\n suggestion: 'Provide a descriptive name for your API.',\n severity: 'error',\n context: { ...context, property: 'info.name' },\n })\n }\n\n if (!model.info || !model.info.description || model.info.description.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_DESCRIPTION'),\n message: 'Adding a description helps others understand your API.',\n suggestion: 'Add a description to clarify the purpose of this API.',\n severity: 'warning',\n context: { ...context, property: 'info.description' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelDependency(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const domain = model.domain\n if (!domain) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN'),\n message: 'No Data Domain is attached to the API.',\n suggestion: 'Select a Data Domain from the settings to power your API.',\n severity: 'error',\n context,\n })\n return issues // Can't validate version if it doesn't exist\n }\n\n if (!domain.info || !domain.info.version) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN_VERSION'),\n message: 'The selected Data Domain is missing a version number.',\n suggestion: 'Specify a version for the attached Data Domain.',\n severity: 'error',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateApiModelSecurity(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n // Resolve User target\n const userEntity = model.domain && model.user ? model.domain.findEntity(model.user.key, model.user.domain) : undefined\n\n // Authentication\n if (!model.authentication) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHENTICATION'),\n message: 'The API is missing authentication settings.',\n suggestion: 'Go to the security settings and configure how users authenticate.',\n severity: 'error',\n context: { ...context, property: 'authentication' },\n })\n } else if (model.authentication.strategy === 'UsernamePassword') {\n const auth = model.authentication as UsernamePasswordConfiguration\n if (!auth.passwordKey) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_KEY'),\n message: 'Username & Password authentication requires a specific field for the password.',\n suggestion:\n 'Select which field in your user profile should store the password. ' +\n 'The data domain model should have a password data semantic on that property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n } else if (userEntity) {\n const passwordProp = Array.from(userEntity.properties).find((p) => p.key === auth.passwordKey)\n if (passwordProp && !passwordProp.hasSemantic(SemanticType.Password)) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_SEMANTIC'),\n message: 'The selected password field is missing the Password data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Password\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n }\n }\n\n if (userEntity) {\n const hasUsernameSemantic = Array.from(userEntity.properties).some(\n (p) => typeof p.hasSemantic === 'function' && p.hasSemantic(SemanticType.Username)\n )\n if (!hasUsernameSemantic) {\n issues.push({\n code: createCode('API', 'MISSING_USERNAME_SEMANTIC'),\n message: 'Username & Password authentication requires a field with the Username data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Username\" semantic to the property used for login.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n }\n }\n\n // Authorization\n if (!model.authorization) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHORIZATION'),\n message: 'The API is missing authorization settings.',\n suggestion: 'Go to the security settings and configure how to handle user permissions.',\n severity: 'error',\n context: { ...context, property: 'authorization' },\n })\n } else if (model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (!rbac.roleKey) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_KEY'),\n message: 'Role-based access control is selected but no role field has been defined.',\n suggestion: \"Select which field in your user profile determines the user's role.\",\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n } else if (userEntity) {\n const roleProp = Array.from(userEntity.properties).find((p) => p.key === rbac.roleKey)\n if (roleProp && !roleProp.hasSemantic(SemanticType.UserRole)) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_SEMANTIC'),\n message: 'The selected role field is missing the User Role data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"User Role\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n }\n }\n }\n\n // Session\n if (!model.session) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION'),\n message: 'The API is missing session configuration.',\n suggestion: 'Configure how user sessions will be handled.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n } else {\n if (!model.session.secret) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_SECRET'),\n message: 'A secure encryption key is required for sessions.',\n suggestion: 'Provide a strong security key in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.secret' },\n })\n }\n\n if (!model.session.properties || model.session.properties.length === 0) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_PROPERTIES'),\n message: 'The session token needs to include at least one piece of user information, like an ID.',\n suggestion: 'Select fields that should be stored securely inside the session payload.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n } else if (model.authorization && model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (rbac.roleKey && !model.session.properties.includes(rbac.roleKey)) {\n issues.push({\n code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),\n message: 'The user role must be included in the session data for permissions to work.',\n suggestion: 'Make sure your selected role field is checked in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n }\n }\n\n const { cookie, jwt } = model.session\n if ((!cookie || !cookie.enabled) && (!jwt || !jwt.enabled)) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_TRANSPORT'),\n message: 'No delivery method for sessions (like cookies or tokens) is enabled.',\n suggestion: 'Enable at least one session delivery mechanism in the security settings.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n }\n }\n\n // User Target\n if (!model.user) {\n issues.push({\n code: createCode('API', 'MISSING_USER_ENTITY'),\n message: 'You need to specify what kind of object represents your users.',\n suggestion: 'Select a model from your domain that stores your user accounts.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n } else if (model.domain && !model.domain.findEntity(model.user.key, model.user.domain)) {\n issues.push({\n code: createCode('API', 'INVALID_USER_ENTITY'),\n message: 'The selected user model no longer exists in your data domain.',\n suggestion: 'Please navigate to security settings and select a valid user model.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelMetadata(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const urlRegex = /^https?:\\/\\//i\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\n if (model.contact) {\n if (model.contact.email && !emailRegex.test(model.contact.email)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_EMAIL'),\n message: 'The contact email address looks invalid.',\n suggestion: 'Please double check the email address formatting.',\n severity: 'error',\n context: { ...context, property: 'contact.email' },\n })\n }\n if (model.contact.url && !urlRegex.test(model.contact.url)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_URL'),\n message: 'The contact link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'contact.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_CONTACT'),\n message: 'A contact email or link is highly recommended for API consumers.',\n suggestion: 'Add an email or help desk link in the metadata tab.',\n severity: 'info',\n context: { ...context, property: 'contact' },\n })\n }\n\n if (model.license) {\n if (model.license.url && !urlRegex.test(model.license.url)) {\n issues.push({\n code: createCode('API', 'INVALID_LICENSE_URL'),\n message: 'The license link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'license.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_LICENSE'),\n message: 'Adding a license to your API helps users understand its usage rights.',\n suggestion: 'Add the name and a link to your API license terms.',\n severity: 'info',\n context: { ...context, property: 'license' },\n })\n }\n\n if (!model.termsOfService) {\n issues.push({\n code: createCode('API', 'MISSING_TOS'),\n message: 'Terms of Service help legal compliance.',\n suggestion: 'Add a link to the terms of your API service.',\n severity: 'info',\n context: { ...context, property: 'termsOfService' },\n })\n }\n\n return issues\n}\n\nexport function validateAction(action: Action, parent: ExposedEntity, apiModelKey: string): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey,\n kind: 'Action',\n key: action.kind, // Actions lack nanoids, kind represents its type\n parentExposedEntityKey: parent.key,\n }\n\n if (ListAction.isListAction(action)) {\n if (!action.pagination || !action.pagination.kind) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_PAGINATION'),\n message: 'A List action must have a defined pagination strategy.',\n suggestion: 'Configure how results are loaded (e.g. by page or by a continuous cursor).',\n severity: 'error',\n context: { ...context, property: 'pagination' },\n })\n }\n if (\n (!action.filterableFields || action.filterableFields.length === 0) &&\n (!action.sortableFields || action.sortableFields.length === 0)\n ) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_FILTERS'),\n message: 'Listing all elements without filters or sorting could be overwhelming for large tables.',\n suggestion: 'Select a few important fields to allow sorting and searching by.',\n severity: 'warning',\n context,\n })\n }\n }\n\n if (SearchAction.isSearchAction(action)) {\n if (!action.fields || action.fields.length === 0) {\n issues.push({\n code: createCode('ACTION', 'SEARCH_MISSING_FIELDS'),\n message: 'A Search action needs to know which fields to look in.',\n suggestion: 'Select the properties (like names or emails) that the search will run on.',\n severity: 'error',\n context: { ...context, property: 'fields' },\n })\n }\n }\n\n if (DeleteAction.isDeleteAction(action)) {\n if (!action.strategy) {\n issues.push({\n code: createCode('ACTION', 'DELETE_MISSING_STRATEGY'),\n message: 'A Delete action must know if you want to completely erase the record, or just hide it.',\n suggestion: 'Configure the deletion type (permanent or soft).',\n severity: 'error',\n context: { ...context, property: 'strategy' },\n })\n } else if (action.strategy === 'hard') {\n issues.push({\n code: createCode('ACTION', 'DELETE_HARD_WARNING'),\n message: 'Permanent delete is active. There will be no way to restore deleted data.',\n suggestion: 'Consider switching to \"soft delete\" if users might need to undo mistakes.',\n severity: 'info',\n context: { ...context, property: 'strategy' },\n })\n }\n }\n\n if (UpdateAction.isUpdateAction(action)) {\n if (!action.allowedMethods || action.allowedMethods.length === 0) {\n issues.push({\n code: createCode('ACTION', 'UPDATE_MISSING_METHODS'),\n message:\n 'An Update action must define how the data is sent (PUT replaces everything; PATCH applies partial changes).',\n suggestion: 'Select at least one allowed HTTP method.',\n severity: 'error',\n context: { ...context, property: 'allowedMethods' },\n })\n }\n }\n\n const allRateLimiters = action.getAllRateLimiters()\n const oneHasRules = allRateLimiters.some((i) => i.rules.length)\n if (!oneHasRules) {\n issues.push({\n code: createCode('ACTION', 'MISSING_RATE_LIMITS'),\n message: 'It is best practice to configure a rate limit so your API is not overwhelmed.',\n suggestion: 'Set a reasonable maximum request speed for this operation.',\n severity: 'warning',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateExposedEntity(entity: ExposedEntity, apiModel: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: apiModel.key,\n kind: ExposedEntityKind,\n key: entity.key,\n }\n\n // Valid Entity Reference\n if (!entity.entity || !entity.entity.key) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ENTITY_REF'),\n message: 'This exposed endpoint does not point to a specific data model.',\n suggestion: 'Select which database entity this endpoint should serve.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n } else if (apiModel.domain && !apiModel.domain.findEntity(entity.entity.key, entity.entity.domain)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_ENTITY_REF'),\n message: 'This endpoint points to a data model that no longer exists.',\n suggestion: 'Select a new valid database model or delete this endpoint.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n }\n\n // Path Integrity\n if (entity.hasCollection) {\n if (!entity.collectionPath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_COLLECTION_PATH'),\n message: 'When an endpoint exposes a collection, it must define what its base URL path is.',\n suggestion: 'Add a path (e.g., \"/items\").',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n } else {\n const parts = entity.collectionPath.split('/').filter(Boolean)\n if (parts.length !== 1 || !entity.collectionPath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_COLLECTION_PATH'),\n message: 'The collection URL should start with \"/\" and have no extra slashes.',\n suggestion: `Ensure the path looks like exactly \"/${parts[0] || 'subresource'}\".`,\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'You need an identifier to locate single items.',\n suggestion: 'Specify the identification parameter format, like \"{id}\".',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else if (entity.collectionPath) {\n const colRegex = new RegExp(`^${entity.collectionPath}/\\\\{[a-zA-Z0-9_]+\\\\}$`)\n if (!colRegex.test(entity.resourcePath)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The single item route should match exactly your collection path plus one identifier variable.',\n suggestion: `Make sure the item path is formatted exactly like \"${entity.collectionPath}/{id}\".`,\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n } else {\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'Endpoints representing a single item must declare their URL route.',\n suggestion: 'Set the URL path (such as \"/profile\").',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else {\n const parts = entity.resourcePath.split('/').filter(Boolean)\n if (parts.length !== 2 || !entity.resourcePath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The URL route must only contain two exact parts or levels.',\n suggestion: 'Simplify the endpoint URL to prevent deep-nesting.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Path Collisions\n if (entity.isRoot) {\n if (entity.collectionPath) {\n const collectionCollision = apiModel.findCollectionPathCollision(entity.collectionPath, entity.key)\n if (collectionCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_COLLECTION_COLLISION'),\n message: `The route \"${entity.collectionPath}\" is already used by another view.`,\n suggestion: 'Give this resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (entity.resourcePath) {\n const resourceCollision = apiModel.findResourcePathCollision(entity.resourcePath, entity.key)\n if (resourceCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_RESOURCE_COLLISION'),\n message: `The route \"${entity.resourcePath}\" is already used by another view.`,\n suggestion: 'Give this single-item resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Minimum Actions\n if (!entity.actions || entity.actions.length === 0) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ACTIONS'),\n message: 'This exposed view does not let users do anything.',\n suggestion: 'Enable at least one operation like Create, Read, or Update.',\n severity: 'error',\n context: { ...context, property: 'actions' },\n })\n } else {\n for (const action of entity.actions) {\n issues.push(...validateAction(action, entity, apiModel.key))\n\n // Check inheritance of access rules\n // For a rule to exist, it might be on the action, the exposure, any parent, or the apiModel.\n let hasAuth = false\n if (action.accessRule && action.accessRule.length > 0) hasAuth = true\n if (!hasAuth && entity.accessRule && entity.accessRule.length > 0) hasAuth = true\n\n let curr = entity.parent?.key\n while (curr && !hasAuth) {\n const p = apiModel.exposes.get(curr)\n if (p && p.accessRule && p.accessRule.length > 0) {\n hasAuth = true\n break\n }\n curr = p?.parent?.key\n }\n\n if (!hasAuth && apiModel.accessRule && apiModel.accessRule.length > 0) hasAuth = true\n\n if (!hasAuth) {\n issues.push({\n code: createCode('ACTION', 'MISSING_ACCESS_RULES'),\n message: `The ${action.kind} action has no security rules attached, making it entirely inaccessible or open.`,\n suggestion: 'Allow specific user roles to access this operation.',\n severity: 'error',\n context: { ...context, kind: 'Action', key: action.kind }, // using action.kind as the key context equivalent\n })\n }\n }\n }\n\n return issues\n}\n\nexport function validateApiModel(model: ApiModel): ApiModelValidationResult {\n const issues: ApiModelValidationItem[] = []\n\n issues.push(...validateApiModelInfo(model))\n issues.push(...validateApiModelDependency(model))\n issues.push(...validateApiModelSecurity(model))\n issues.push(...validateApiModelMetadata(model))\n\n if (!model.exposes || model.exposes.size === 0) {\n issues.push({\n code: createCode('API', 'NO_EXPOSURES'),\n message: 'Your API currently has no exposed data for external clients to request.',\n suggestion: 'Expose a data model so apps can communicate with it.',\n severity: 'warning',\n context: { apiModelKey: model.key, kind: ApiModelKind, key: model.key, property: 'exposes' },\n })\n } else {\n for (const exposure of model.exposes.values()) {\n issues.push(...validateExposedEntity(exposure, model))\n }\n }\n\n const hasErrors = issues.some((i) => i.severity === 'error')\n\n return {\n isValid: !hasErrors,\n issues,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api_model_rules.js","sourceRoot":"","sources":["../../../../src/modeling/validation/api_model_rules.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAGzD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAc,EAAE,KAAa;IAC/C,OAAO,GAAG,MAAM,IAAI,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAe;IAClD,MAAM,MAAM,GAA6B,EAAE,CAAA;IAC3C,MAAM,OAAO,GAA8B;QACzC,WAAW,EAAE,KAAK,CAAC,GAAG;QACtB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,KAAK,CAAC,GAAG;KACf,CAAA;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,UAAU,CA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AE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,kDAAkD;iBAC9G,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import type { ApiModel } from '../ApiModel.js'\nimport type { ExposedEntity } from '../ExposedEntity.js'\nimport type { Action } from '../actions/Action.js'\nimport { ListAction } from '../actions/ListAction.js'\nimport { DeleteAction } from '../actions/DeleteAction.js'\nimport { UpdateAction } from '../actions/UpdateAction.js'\nimport { SearchAction } from '../actions/SearchAction.js'\nimport type { RolesBasedAccessControl, UsernamePasswordConfiguration } from '../types.js'\nimport type { ApiModelValidationItem, ApiModelValidationContext } from '../types.js'\nimport { ApiModelKind, ExposedEntityKind } from '../../models/kinds.js'\nimport { SemanticType } from '../Semantics.js'\n\n/**\n * Creates a unique validation code.\n * @param entity The entity type (e.g., 'API', 'EXPOSURE', 'ACTION')\n * @param issue The issue identifier (e.g., 'MISSING_NAME')\n */\nfunction createCode(entity: string, issue: string): string {\n return `${entity}_${issue}`\n}\n\n/**\n * Validates the core properties and metadata of an ApiModel.\n */\nexport function validateApiModelInfo(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n if (model.kind !== ApiModelKind) {\n issues.push({\n code: createCode('API', 'INVALID_KIND'),\n message: 'The API model type is incorrect.',\n suggestion: 'Set the model type to \"ApiModel\".',\n severity: 'error',\n context: { ...context, property: 'kind' },\n })\n }\n\n if (!model.key || typeof model.key !== 'string' || model.key.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_KEY'),\n message: 'The API model is missing a unique identifier.',\n suggestion: 'Provide a valid name to use as a unique identifier.',\n severity: 'error',\n context: { ...context, property: 'key' },\n })\n }\n\n if (!model.info || !model.info.name || model.info.name.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_NAME'),\n message: 'The API model has no defined name.',\n suggestion: 'Provide a descriptive name for your API.',\n severity: 'error',\n context: { ...context, property: 'info.name' },\n })\n }\n\n if (!model.info || !model.info.description || model.info.description.trim() === '') {\n issues.push({\n code: createCode('API', 'MISSING_DESCRIPTION'),\n message: 'Adding a description helps others understand your API.',\n suggestion: 'Add a description to clarify the purpose of this API.',\n severity: 'warning',\n context: { ...context, property: 'info.description' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelDependency(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const domain = model.domain\n if (!domain) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN'),\n message: 'No Data Domain is attached to the API.',\n suggestion: 'Select a Data Domain from the settings to power your API.',\n severity: 'error',\n context,\n })\n return issues // Can't validate version if it doesn't exist\n }\n\n if (!domain.info || !domain.info.version) {\n issues.push({\n code: createCode('API', 'MISSING_DOMAIN_VERSION'),\n message: 'The selected Data Domain is missing a version number.',\n suggestion: 'Specify a version for the attached Data Domain.',\n severity: 'error',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateApiModelSecurity(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n // Resolve User target\n const userEntity = model.domain && model.user ? model.domain.findEntity(model.user.key, model.user.domain) : undefined\n\n // Authentication\n if (!model.authentication) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHENTICATION'),\n message: 'The API is missing authentication settings.',\n suggestion: 'Go to the security settings and configure how users authenticate.',\n severity: 'error',\n context: { ...context, property: 'authentication' },\n })\n } else if (model.authentication.strategy === 'UsernamePassword') {\n const auth = model.authentication as UsernamePasswordConfiguration\n if (!auth.passwordKey) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_KEY'),\n message: 'Username & Password authentication requires a specific field for the password.',\n suggestion:\n 'Select which field in your user profile should store the password. ' +\n 'The data domain model should have a password data semantic on that property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n } else if (userEntity) {\n const passwordProp = Array.from(userEntity.properties).find((p) => p.key === auth.passwordKey)\n if (passwordProp && !passwordProp.hasSemantic(SemanticType.Password)) {\n issues.push({\n code: createCode('API', 'MISSING_PASSWORD_SEMANTIC'),\n message: 'The selected password field is missing the Password data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Password\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authentication.passwordKey' },\n })\n }\n }\n\n if (userEntity) {\n const hasUsernameSemantic = Array.from(userEntity.properties).some(\n (p) => typeof p.hasSemantic === 'function' && p.hasSemantic(SemanticType.Username)\n )\n if (!hasUsernameSemantic) {\n issues.push({\n code: createCode('API', 'MISSING_USERNAME_SEMANTIC'),\n message: 'Username & Password authentication requires a field with the Username data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"Username\" semantic to the property used for login.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n }\n }\n\n // Authorization\n if (!model.authorization) {\n issues.push({\n code: createCode('API', 'MISSING_AUTHORIZATION'),\n message: 'The API is missing authorization settings.',\n suggestion: 'Go to the security settings and configure how to handle user permissions.',\n severity: 'error',\n context: { ...context, property: 'authorization' },\n })\n } else if (model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (!rbac.roleKey) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_KEY'),\n message: 'Role-based access control is selected but no role field has been defined.',\n suggestion: \"Select which field in your user profile determines the user's role.\",\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n } else if (userEntity) {\n const roleProp = Array.from(userEntity.properties).find((p) => p.key === rbac.roleKey)\n if (roleProp && !roleProp.hasSemantic(SemanticType.UserRole)) {\n issues.push({\n code: createCode('API', 'MISSING_ROLE_SEMANTIC'),\n message: 'The selected role field is missing the User Role data semantic.',\n suggestion: 'Go to the Data Modeler and add the \"User Role\" semantic to this property.',\n severity: 'error',\n context: { ...context, property: 'authorization.roleKey' },\n })\n }\n }\n }\n\n // Session\n if (!model.session) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION'),\n message: 'The API is missing session configuration.',\n suggestion: 'Configure how user sessions will be handled.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n } else {\n if (!model.session.secret) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_SECRET'),\n message: 'A secure encryption key is required for sessions.',\n suggestion: 'Provide a strong security key in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.secret' },\n })\n }\n\n if (!model.session.properties || model.session.properties.length === 0) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_PROPERTIES'),\n message: 'The session token needs to include at least one piece of user information, like an ID.',\n suggestion: 'Select fields that should be stored securely inside the session payload.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n } else if (model.authorization && model.authorization.strategy === 'RBAC') {\n const rbac = model.authorization as RolesBasedAccessControl\n if (rbac.roleKey && !model.session.properties.includes(rbac.roleKey)) {\n issues.push({\n code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),\n message: 'The user role must be included in the session data for permissions to work.',\n suggestion: 'Make sure your selected role field is checked in the session settings.',\n severity: 'error',\n context: { ...context, property: 'session.properties' },\n })\n }\n }\n\n const { cookie, jwt } = model.session\n if ((!cookie || !cookie.enabled) && (!jwt || !jwt.enabled)) {\n issues.push({\n code: createCode('API', 'MISSING_SESSION_TRANSPORT'),\n message: 'No delivery method for sessions (like cookies or tokens) is enabled.',\n suggestion: 'Enable at least one session delivery mechanism in the security settings.',\n severity: 'error',\n context: { ...context, property: 'session' },\n })\n }\n }\n\n // User Target\n if (!model.user) {\n issues.push({\n code: createCode('API', 'MISSING_USER_ENTITY'),\n message: 'You need to specify what kind of object represents your users.',\n suggestion: 'Select a model from your domain that stores your user accounts.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n } else if (model.domain && !model.domain.findEntity(model.user.key, model.user.domain)) {\n issues.push({\n code: createCode('API', 'INVALID_USER_ENTITY'),\n message: 'The selected user model no longer exists in your data domain.',\n suggestion: 'Please navigate to security settings and select a valid user model.',\n severity: 'error',\n context: { ...context, property: 'user' },\n })\n }\n\n return issues\n}\n\nexport function validateApiModelMetadata(model: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: model.key,\n kind: ApiModelKind,\n key: model.key,\n }\n\n const urlRegex = /^https?:\\/\\//i\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n\n if (model.contact) {\n if (model.contact.email && !emailRegex.test(model.contact.email)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_EMAIL'),\n message: 'The contact email address looks invalid.',\n suggestion: 'Please double check the email address formatting.',\n severity: 'error',\n context: { ...context, property: 'contact.email' },\n })\n }\n if (model.contact.url && !urlRegex.test(model.contact.url)) {\n issues.push({\n code: createCode('API', 'INVALID_CONTACT_URL'),\n message: 'The contact link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'contact.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_CONTACT'),\n message: 'A contact email or link is highly recommended for API consumers.',\n suggestion: 'Add an email or help desk link in the metadata tab.',\n severity: 'info',\n context: { ...context, property: 'contact' },\n })\n }\n\n if (model.license) {\n if (model.license.url && !urlRegex.test(model.license.url)) {\n issues.push({\n code: createCode('API', 'INVALID_LICENSE_URL'),\n message: 'The license link looks invalid.',\n suggestion: 'Provide a working link, starting with http:// or https://.',\n severity: 'error',\n context: { ...context, property: 'license.url' },\n })\n }\n } else {\n issues.push({\n code: createCode('API', 'MISSING_LICENSE'),\n message: 'Adding a license to your API helps users understand its usage rights.',\n suggestion: 'Add the name and a link to your API license terms.',\n severity: 'info',\n context: { ...context, property: 'license' },\n })\n }\n\n if (!model.termsOfService) {\n issues.push({\n code: createCode('API', 'MISSING_TOS'),\n message: 'Terms of Service help legal compliance.',\n suggestion: 'Add a link to the terms of your API service.',\n severity: 'info',\n context: { ...context, property: 'termsOfService' },\n })\n }\n\n return issues\n}\n\nexport function validateAction(action: Action, parent: ExposedEntity, apiModelKey: string): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey,\n kind: 'Action',\n key: action.kind, // Actions lack nanoids, kind represents its type\n parentExposedEntityKey: parent.key,\n }\n\n if (ListAction.isListAction(action)) {\n if (!action.pagination || !action.pagination.kind) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_PAGINATION'),\n message: 'A List action must have a defined pagination strategy.',\n suggestion: 'Configure how results are loaded (e.g. by page or by a continuous cursor).',\n severity: 'error',\n context: { ...context, property: 'pagination' },\n })\n }\n if (\n (!action.filterableFields || action.filterableFields.length === 0) &&\n (!action.sortableFields || action.sortableFields.length === 0)\n ) {\n issues.push({\n code: createCode('ACTION', 'LIST_MISSING_FILTERS'),\n message: 'Listing all elements without filters or sorting could be overwhelming for large tables.',\n suggestion: 'Select a few important fields to allow sorting and searching by.',\n severity: 'warning',\n context,\n })\n }\n }\n\n if (SearchAction.isSearchAction(action)) {\n if (!action.fields || action.fields.length === 0) {\n issues.push({\n code: createCode('ACTION', 'SEARCH_MISSING_FIELDS'),\n message: 'A Search action needs to know which fields to look in.',\n suggestion: 'Select the properties (like names or emails) that the search will run on.',\n severity: 'error',\n context: { ...context, property: 'fields' },\n })\n }\n }\n\n if (DeleteAction.isDeleteAction(action)) {\n if (!action.strategy) {\n issues.push({\n code: createCode('ACTION', 'DELETE_MISSING_STRATEGY'),\n message: 'A Delete action must know if you want to completely erase the record, or just hide it.',\n suggestion: 'Configure the deletion type (permanent or soft).',\n severity: 'error',\n context: { ...context, property: 'strategy' },\n })\n } else if (action.strategy === 'hard') {\n issues.push({\n code: createCode('ACTION', 'DELETE_HARD_WARNING'),\n message: 'Permanent delete is active. There will be no way to restore deleted data.',\n suggestion: 'Consider switching to \"soft delete\" if users might need to undo mistakes.',\n severity: 'info',\n context: { ...context, property: 'strategy' },\n })\n }\n }\n\n if (UpdateAction.isUpdateAction(action)) {\n if (!action.allowedMethods || action.allowedMethods.length === 0) {\n issues.push({\n code: createCode('ACTION', 'UPDATE_MISSING_METHODS'),\n message:\n 'An Update action must define how the data is sent (PUT replaces everything; PATCH applies partial changes).',\n suggestion: 'Select at least one allowed HTTP method.',\n severity: 'error',\n context: { ...context, property: 'allowedMethods' },\n })\n }\n }\n\n const allRateLimiters = action.getAllRateLimiters()\n const oneHasRules = allRateLimiters.some((i) => i.rules.length)\n if (!oneHasRules) {\n issues.push({\n code: createCode('ACTION', 'MISSING_RATE_LIMITS'),\n message: 'It is best practice to configure a rate limit so your API is not overwhelmed.',\n suggestion: 'Set a reasonable maximum request speed for this operation.',\n severity: 'warning',\n context,\n })\n }\n\n return issues\n}\n\nexport function validateExposedEntity(entity: ExposedEntity, apiModel: ApiModel): ApiModelValidationItem[] {\n const issues: ApiModelValidationItem[] = []\n const context: ApiModelValidationContext = {\n apiModelKey: apiModel.key,\n kind: ExposedEntityKind,\n key: entity.key,\n }\n\n // Valid Entity Reference\n if (!entity.entity || !entity.entity.key) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ENTITY_REF'),\n message: 'This exposed endpoint does not point to a specific data model.',\n suggestion: 'Select which database entity this endpoint should serve.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n } else if (apiModel.domain && !apiModel.domain.findEntity(entity.entity.key, entity.entity.domain)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_ENTITY_REF'),\n message: 'This endpoint points to a data model that no longer exists.',\n suggestion: 'Select a new valid database model or delete this endpoint.',\n severity: 'error',\n context: { ...context, property: 'entity' },\n })\n }\n\n // Path Integrity\n if (entity.hasCollection) {\n if (!entity.collectionPath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_COLLECTION_PATH'),\n message: 'When an endpoint exposes a collection, it must define what its base URL path is.',\n suggestion: 'Add a path (e.g., \"/items\").',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n } else {\n const parts = entity.collectionPath.split('/').filter(Boolean)\n if (parts.length !== 1 || !entity.collectionPath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_COLLECTION_PATH'),\n message: 'The collection URL should start with \"/\" and have no extra slashes.',\n suggestion: `Ensure the path looks like exactly \"/${parts[0] || 'subresource'}\".`,\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'You need an identifier to locate single items.',\n suggestion: 'Specify the identification parameter format, like \"{id}\".',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else if (entity.collectionPath) {\n const colRegex = new RegExp(`^${entity.collectionPath}/\\\\{[a-zA-Z0-9_]+\\\\}$`)\n if (!colRegex.test(entity.resourcePath)) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The single item route should match exactly your collection path plus one identifier variable.',\n suggestion: `Make sure the item path is formatted exactly like \"${entity.collectionPath}/{id}\".`,\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n } else {\n if (!entity.resourcePath) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_RESOURCE_PATH'),\n message: 'Endpoints representing a single item must declare their URL route.',\n suggestion: 'Set the URL path (such as \"/profile\").',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n } else {\n const parts = entity.resourcePath.split('/').filter(Boolean)\n if (parts.length !== 2 || !entity.resourcePath.startsWith('/')) {\n issues.push({\n code: createCode('EXPOSURE', 'INVALID_RESOURCE_PATH_FORMAT'),\n message: 'The URL route must only contain two exact parts or levels.',\n suggestion: 'Simplify the endpoint URL to prevent deep-nesting.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Path Collisions\n if (entity.isRoot) {\n if (entity.collectionPath) {\n const collectionCollision = apiModel.findCollectionPathCollision(entity.collectionPath, entity.key)\n if (collectionCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_COLLECTION_COLLISION'),\n message: `The route \"${entity.collectionPath}\" is already used by another view.`,\n suggestion: 'Give this resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'collectionPath' },\n })\n }\n }\n\n if (entity.resourcePath) {\n const resourceCollision = apiModel.findResourcePathCollision(entity.resourcePath, entity.key)\n if (resourceCollision) {\n issues.push({\n code: createCode('EXPOSURE', 'ROOT_RESOURCE_COLLISION'),\n message: `The route \"${entity.resourcePath}\" is already used by another view.`,\n suggestion: 'Give this single-item resource a different path to avoid conflicts.',\n severity: 'error',\n context: { ...context, property: 'resourcePath' },\n })\n }\n }\n }\n\n // Minimum Actions\n if (!entity.actions || entity.actions.length === 0) {\n issues.push({\n code: createCode('EXPOSURE', 'MISSING_ACTIONS'),\n message: 'This exposed view does not let users do anything.',\n suggestion: 'Enable at least one operation like Create, Read, or Update.',\n severity: 'error',\n context: { ...context, property: 'actions' },\n })\n } else {\n for (const action of entity.actions) {\n issues.push(...validateAction(action, entity, apiModel.key))\n\n // Check inheritance of access rules\n // For a rule to exist, it might be on the action, the exposure, any parent, or the apiModel.\n let hasAuth = false\n if (action.accessRule && action.accessRule.length > 0) hasAuth = true\n if (!hasAuth && entity.accessRule && entity.accessRule.length > 0) hasAuth = true\n\n let curr = entity.parent?.key\n while (curr && !hasAuth) {\n const p = apiModel.exposes.get(curr)\n if (p && p.accessRule && p.accessRule.length > 0) {\n hasAuth = true\n break\n }\n curr = p?.parent?.key\n }\n\n if (!hasAuth && apiModel.accessRule && apiModel.accessRule.length > 0) hasAuth = true\n\n if (!hasAuth) {\n issues.push({\n code: createCode('ACTION', 'MISSING_ACCESS_RULES'),\n message: `The ${action.kind} action has no security rules attached, making it entirely inaccessible or open.`,\n suggestion: 'Allow specific user roles to access this operation.',\n severity: 'error',\n context: { ...context, kind: 'Action', key: action.kind }, // using action.kind as the key context equivalent\n })\n }\n }\n }\n\n return issues\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DataDomain } from '../DataDomain.js';
|
|
2
2
|
import type { DomainAssociation } from '../DomainAssociation.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type DomainValidationSchema } from './rules.js';
|
|
4
4
|
/**
|
|
5
5
|
* AssociationValidation is a class that performs validation on associations in a data domain.
|
|
6
6
|
* Note that an association in most cases is a property of an entity.
|
|
@@ -14,7 +14,7 @@ export declare class AssociationValidation {
|
|
|
14
14
|
* @param target The target association to validate. Can be a string with
|
|
15
15
|
* the association key or a DomainAssociation object.
|
|
16
16
|
*/
|
|
17
|
-
validate(target: string | DomainAssociation):
|
|
17
|
+
validate(target: string | DomainAssociation): DomainValidationSchema[];
|
|
18
18
|
/**
|
|
19
19
|
* Validates the association name.
|
|
20
20
|
*
|
|
@@ -28,11 +28,11 @@ export declare class AssociationValidation {
|
|
|
28
28
|
* - (recommendation) Column names should be in lower case.
|
|
29
29
|
* @param association The association to validate
|
|
30
30
|
*/
|
|
31
|
-
validateName(association: DomainAssociation):
|
|
31
|
+
validateName(association: DomainAssociation): DomainValidationSchema[];
|
|
32
32
|
/**
|
|
33
33
|
* Validates the association targets.
|
|
34
34
|
* @param association The association to validate
|
|
35
35
|
*/
|
|
36
|
-
validateTargets(association: DomainAssociation):
|
|
36
|
+
validateTargets(association: DomainAssociation): DomainValidationSchema[];
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=association_validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"association_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,KAAK,sBAAsB,EAAwB,MAAM,YAAY,CAAA;AAE9E;;;GAGG;AACH,qBAAa,qBAAqB;IACpB,SAAS,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IACxC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,GAAG,sBAAsB,EAAE;IA6BtE;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,WAAW,EAAE,iBAAiB,GAAG,sBAAsB,EAAE;IAItE;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,iBAAiB,GAAG,sBAAsB,EAAE;CAsC1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association_validation.js","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAI7D,OAAO,
|
|
1
|
+
{"version":3,"file":"association_validation.js","sourceRoot":"","sources":["../../../../src/modeling/validation/association_validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAI7D,OAAO,EAA+B,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAE9E;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACV;IAAtB,YAAsB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAC5C;;;;;OAKG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pE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,OAAO,GAAG,QAAQ,KAAK,8BAA8B,CAAA;YAC3D,MAAM,IAAI,GAAG,+CAA+C,CAAA;YAC5D,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE,UAAU;gBAChB,OAAO;gBACP,IAAI;gBACJ,QAAQ,EAAE,OAAO;gBACjB,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,IAAI,EAAE,WAAW,CAAC,IAAI;gBACtB,MAAM,EAAE,YAAY,CAAC,GAAG;aACzB,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YAChE,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,OAAO,GAAG,QAAQ,KAAK,wCAAwC,MAAM,CAAC,GAAG,IAAI,CAAA;gBACnF,MAAM,IAAI,GAAG,2CAA2C,CAAA;gBACxD,OAAO,CAAC,IAAI,CAAC;oBACX,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,QAAQ;oBACd,OAAO;oBACP,IAAI;oBACJ,QAAQ,EAAE,OAAO;oBACjB,GAAG,EAAE,WAAW,CAAC,GAAG;oBACpB,IAAI,EAAE,WAAW,CAAC,IAAI;oBACtB,MAAM,EAAE,YAAY,CAAC,GAAG;iBACzB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF","sourcesContent":["import { DomainAssociationKind } from '../../models/kinds.js'\nimport type { DataDomain } from '../DataDomain.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { type DomainValidationSchema, validatePropertyName } from './rules.js'\n\n/**\n * AssociationValidation is a class that performs validation on associations in a data domain.\n * Note that an association in most cases is a property of an entity.\n */\nexport class AssociationValidation {\n constructor(protected domain: DataDomain) {}\n /**\n * Performs all the validation rules on the association.\n * If you are interested in a specific rule, use the specific method.\n * @param target The target association to validate. Can be a string with\n * the association key or a DomainAssociation object.\n */\n validate(target: string | DomainAssociation): DomainValidationSchema[] {\n const results: DomainValidationSchema[] = []\n let association: DomainAssociation | undefined\n if (typeof target === 'string') {\n association = this.domain.findAssociation(target)\n } else {\n association = target\n }\n if (!association) {\n const message = `The \"${target}\" association does not exist.`\n const help = `The association must be defined in the domain.`\n results.push({\n field: '*',\n rule: 'exists',\n message,\n help,\n key: target as string,\n kind: DomainAssociationKind,\n severity: 'error',\n })\n return results\n }\n const name = this.validateName(association)\n results.push(...name)\n const targets = this.validateTargets(association)\n results.push(...targets)\n return results\n }\n\n /**\n * Validates the association name.\n *\n * @remarks\n * - A association must have a name defined.\n * - The name has to follow the same rules as the names in a PostgreSQL database.\n * - Column names can only contain letters (a-z, A-Z), numbers (0-9), and underscores (_).\n * - The name must start with a letter (a-z, A-Z) or an underscore (_).\n * - PostgreSQL limits column names to a maximum of 59 characters.\n * - (our rule) Column names are case insensitive.\n * - (recommendation) Column names should be in lower case.\n * @param association The association to validate\n */\n validateName(association: DomainAssociation): DomainValidationSchema[] {\n return validatePropertyName(association)\n }\n\n /**\n * Validates the association targets.\n * @param association The association to validate\n */\n validateTargets(association: DomainAssociation): DomainValidationSchema[] {\n const results: DomainValidationSchema[] = []\n const label = association.info.getLabel()\n const parentEntity = association.getParentInstance() as DomainEntity\n if (!association.targets.length) {\n const message = `The \"${label}\" association has no target.`\n const help = `An association must have at least one target.`\n results.push({\n field: 'targets',\n rule: 'required',\n message,\n help,\n severity: 'error',\n key: association.key,\n kind: association.kind,\n parent: parentEntity.key,\n })\n return results\n }\n for (const target of association.targets) {\n const entity = this.domain.findEntity(target.key, target.domain)\n if (!entity) {\n const message = `The \"${label}\" association has an invalid target \"${target.key}\".`\n const help = `The target must be defined in the domain.`\n results.push({\n field: 'targets',\n rule: 'exists',\n message,\n help,\n severity: 'error',\n key: association.key,\n kind: association.kind,\n parent: parentEntity.key,\n })\n }\n }\n return results\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DataDomain } from '../DataDomain.js';
|
|
2
2
|
import type { DomainEntity } from '../DomainEntity.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DomainValidationSchema } from './rules.js';
|
|
4
4
|
/**
|
|
5
5
|
* EntityValidation is a class that performs validation on entities in a data domain.
|
|
6
6
|
*
|
|
@@ -17,12 +17,12 @@ export declare class EntityValidation {
|
|
|
17
17
|
* @param target The target entity to validate. Can be a string with
|
|
18
18
|
* the entity key or a DomainEntity object.
|
|
19
19
|
*/
|
|
20
|
-
validate(target: string | DomainEntity):
|
|
20
|
+
validate(target: string | DomainEntity): DomainValidationSchema[];
|
|
21
21
|
/**
|
|
22
22
|
* Validates the entity primary key.
|
|
23
23
|
* @param entity The entity to validate
|
|
24
24
|
*/
|
|
25
|
-
validatePrimaryKey(entity: DomainEntity):
|
|
25
|
+
validatePrimaryKey(entity: DomainEntity): DomainValidationSchema[];
|
|
26
26
|
/**
|
|
27
27
|
* Checks if an entity has properties through its entire inheritance chain.
|
|
28
28
|
* This includes direct properties and properties inherited from any level of parent entities.
|
|
@@ -41,7 +41,7 @@ export declare class EntityValidation {
|
|
|
41
41
|
* Checks if the entity has the minimum required properties.
|
|
42
42
|
* @param entity The entity to validate
|
|
43
43
|
*/
|
|
44
|
-
minimumRequiredProperties(entity: DomainEntity):
|
|
44
|
+
minimumRequiredProperties(entity: DomainEntity): DomainValidationSchema[];
|
|
45
45
|
/**
|
|
46
46
|
* Validates the entity name.
|
|
47
47
|
*
|
|
@@ -56,11 +56,11 @@ export declare class EntityValidation {
|
|
|
56
56
|
* - Should not be a reserved word (for example: "IN", "SELECT", "FROM", etc.).
|
|
57
57
|
* @param entity The entity to validate
|
|
58
58
|
*/
|
|
59
|
-
validateName(entity: DomainEntity):
|
|
59
|
+
validateName(entity: DomainEntity): DomainValidationSchema[];
|
|
60
60
|
/**
|
|
61
61
|
* Checks if the entity name is unique in the data domain.
|
|
62
62
|
* @param entity The entity to validate
|
|
63
63
|
*/
|
|
64
|
-
uniqueName(entity: DomainEntity):
|
|
64
|
+
uniqueName(entity: DomainEntity): DomainValidationSchema[];
|
|
65
65
|
}
|
|
66
66
|
//# sourceMappingURL=entity_validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/entity_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"entity_validation.d.ts","sourceRoot":"","sources":["../../../../src/modeling/validation/entity_validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAExD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IACf,SAAS,CAAC,MAAM,EAAE,UAAU;gBAAlB,MAAM,EAAE,UAAU;IAExC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,sBAAsB,EAAE;IAiCjE;;;OAGG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,sBAAsB,EAAE;IAmBlE;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAgB9B;;;;;OAKG;IACH,OAAO,CAAC,wBAAwB;IAgBhC;;;OAGG;IACH,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,sBAAsB,EAAE;IAuBzE;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,sBAAsB,EAAE;IAuF5D;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,sBAAsB,EAAE;CAwC3D"}
|