@memberjunction/codegen-lib 6.2.0-edge.5 → 6.2.0-edge.7
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/README.md +1 -0
- package/dist/Angular/angular-codegen.d.ts +12 -1
- package/dist/Angular/angular-codegen.d.ts.map +1 -1
- package/dist/Angular/angular-codegen.js +36 -1
- package/dist/Angular/angular-codegen.js.map +1 -1
- package/dist/Config/config.d.ts +301 -0
- package/dist/Config/config.d.ts.map +1 -1
- package/dist/Config/config.js +188 -84
- package/dist/Config/config.js.map +1 -1
- package/dist/Database/codeGenDatabaseProvider.d.ts +101 -4
- package/dist/Database/codeGenDatabaseProvider.d.ts.map +1 -1
- package/dist/Database/codeGenDatabaseProvider.js +170 -4
- package/dist/Database/codeGenDatabaseProvider.js.map +1 -1
- package/dist/Database/manage-metadata.d.ts +379 -24
- package/dist/Database/manage-metadata.d.ts.map +1 -1
- package/dist/Database/manage-metadata.js +1021 -237
- package/dist/Database/manage-metadata.js.map +1 -1
- package/dist/Database/materializationAnalysis.d.ts +18 -4
- package/dist/Database/materializationAnalysis.d.ts.map +1 -1
- package/dist/Database/materializationAnalysis.js +113 -99
- package/dist/Database/materializationAnalysis.js.map +1 -1
- package/dist/Database/materializationBroadRender.d.ts +7 -3
- package/dist/Database/materializationBroadRender.d.ts.map +1 -1
- package/dist/Database/materializationBroadRender.js +89 -56
- package/dist/Database/materializationBroadRender.js.map +1 -1
- package/dist/Database/materializationParamClassifier.d.ts +1 -1
- package/dist/Database/materializationParamClassifier.js +2 -2
- package/dist/Database/materializationParamVerifier.d.ts +1 -1
- package/dist/Database/materializationParamVerifier.d.ts.map +1 -1
- package/dist/Database/materializationParamVerifier.js +127 -221
- package/dist/Database/materializationParamVerifier.js.map +1 -1
- package/dist/Database/materializationSqlAst.d.ts +107 -79
- package/dist/Database/materializationSqlAst.d.ts.map +1 -1
- package/dist/Database/materializationSqlAst.js +307 -134
- package/dist/Database/materializationSqlAst.js.map +1 -1
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts +25 -5
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts.map +1 -1
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js +135 -26
- package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js.map +1 -1
- package/dist/Database/providers/postgresql/__tests__/MetadataSupportObjectsDDL.test.js +9 -5
- package/dist/Database/providers/postgresql/__tests__/MetadataSupportObjectsDDL.test.js.map +1 -1
- package/dist/Database/providers/postgresql/metadataSupportObjects.js +289 -90
- package/dist/Database/providers/postgresql/metadataSupportObjects.js.map +1 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts +48 -12
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts.map +1 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js +146 -54
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js.map +1 -1
- package/dist/Database/providers/sqlserver/__tests__/VerifiedJoinIndexes.test.js +66 -0
- package/dist/Database/providers/sqlserver/__tests__/VerifiedJoinIndexes.test.js.map +1 -1
- package/dist/Database/providers/sqlserver/sqlServerDefaultValues.d.ts +47 -0
- package/dist/Database/providers/sqlserver/sqlServerDefaultValues.d.ts.map +1 -0
- package/dist/Database/providers/sqlserver/sqlServerDefaultValues.js +167 -0
- package/dist/Database/providers/sqlserver/sqlServerDefaultValues.js.map +1 -0
- package/dist/Database/providers/sqlserver/sqlServerScriptText.d.ts +31 -0
- package/dist/Database/providers/sqlserver/sqlServerScriptText.d.ts.map +1 -0
- package/dist/Database/providers/sqlserver/sqlServerScriptText.js +116 -0
- package/dist/Database/providers/sqlserver/sqlServerScriptText.js.map +1 -0
- package/dist/Database/queryRebindPass.d.ts +37 -0
- package/dist/Database/queryRebindPass.d.ts.map +1 -0
- package/dist/Database/queryRebindPass.js +110 -0
- package/dist/Database/queryRebindPass.js.map +1 -0
- package/dist/Database/schema-scope.d.ts +12 -0
- package/dist/Database/schema-scope.d.ts.map +1 -1
- package/dist/Database/schema-scope.js +15 -0
- package/dist/Database/schema-scope.js.map +1 -1
- package/dist/Database/sql.d.ts +13 -0
- package/dist/Database/sql.d.ts.map +1 -1
- package/dist/Database/sql.js +39 -8
- package/dist/Database/sql.js.map +1 -1
- package/dist/Database/sql_codegen.d.ts +212 -6
- package/dist/Database/sql_codegen.d.ts.map +1 -1
- package/dist/Database/sql_codegen.js +765 -63
- package/dist/Database/sql_codegen.js.map +1 -1
- package/dist/Misc/advanced_generation.d.ts +129 -5
- package/dist/Misc/advanced_generation.d.ts.map +1 -1
- package/dist/Misc/advanced_generation.js +212 -8
- package/dist/Misc/advanced_generation.js.map +1 -1
- package/dist/Misc/display-name-heuristics.d.ts +57 -0
- package/dist/Misc/display-name-heuristics.d.ts.map +1 -0
- package/dist/Misc/display-name-heuristics.js +97 -0
- package/dist/Misc/display-name-heuristics.js.map +1 -0
- package/dist/Misc/entity_subclasses_codegen.d.ts +31 -3
- package/dist/Misc/entity_subclasses_codegen.d.ts.map +1 -1
- package/dist/Misc/entity_subclasses_codegen.js +79 -17
- package/dist/Misc/entity_subclasses_codegen.js.map +1 -1
- package/dist/Misc/remote_operations_codegen.d.ts.map +1 -1
- package/dist/Misc/remote_operations_codegen.js +21 -4
- package/dist/Misc/remote_operations_codegen.js.map +1 -1
- package/dist/Misc/sql_logging.d.ts +12 -0
- package/dist/Misc/sql_logging.d.ts.map +1 -1
- package/dist/Misc/sql_logging.js +21 -8
- package/dist/Misc/sql_logging.js.map +1 -1
- package/dist/Misc/system_integrity.d.ts +48 -0
- package/dist/Misc/system_integrity.d.ts.map +1 -1
- package/dist/Misc/system_integrity.js +151 -75
- package/dist/Misc/system_integrity.js.map +1 -1
- package/dist/Misc/validator-text.d.ts +17 -0
- package/dist/Misc/validator-text.d.ts.map +1 -1
- package/dist/Misc/validator-text.js +59 -0
- package/dist/Misc/validator-text.js.map +1 -1
- package/dist/runCodeGen.d.ts +37 -3
- package/dist/runCodeGen.d.ts.map +1 -1
- package/dist/runCodeGen.js +161 -51
- package/dist/runCodeGen.js.map +1 -1
- package/package.json +29 -29
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseViewExclusionsPermitted } from '../Database/codeGenDatabaseProvider.js';
|
|
1
2
|
import { logError, logStatus } from "./status_logging.js";
|
|
2
3
|
import { configInfo, DbPlatform, MjCoreSchema } from "../Config/config.js";
|
|
3
4
|
/**
|
|
@@ -10,16 +11,11 @@ function qi(name) {
|
|
|
10
11
|
}
|
|
11
12
|
return '[' + name + ']';
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function selectOne(schema, viewName) {
|
|
19
|
-
if (DbPlatform() === 'postgresql') {
|
|
20
|
-
return `SELECT * FROM ${qi(schema)}.${qi(viewName)} LIMIT 1`;
|
|
21
|
-
}
|
|
22
|
-
return `SELECT TOP 1 * FROM ${qi(schema)}.${qi(viewName)}`;
|
|
14
|
+
function catalogKey(schema, objectName) {
|
|
15
|
+
return `${schema.trim().toLowerCase()}.${objectName.trim().toLowerCase()}`;
|
|
16
|
+
}
|
|
17
|
+
function escapeLiteral(value) {
|
|
18
|
+
return value.replace(/'/g, "''");
|
|
23
19
|
}
|
|
24
20
|
/**
|
|
25
21
|
* This class has methods that can check various aspects of a MemberJunction installation's integrity. Code Gen will
|
|
@@ -90,80 +86,46 @@ export class SystemIntegrityBase {
|
|
|
90
86
|
static async CheckSinleEntityFieldSequences(pool, entityName) {
|
|
91
87
|
return SystemIntegrityBase.CheckEntityFieldSequencesInternal(pool, `WHERE ${qi('Entity')}='${entityName}'`);
|
|
92
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks every in-scope entity on its own, so one failing entity does not hide the next one
|
|
91
|
+
* (#4737). For each entity the EntityField sequences must run 1..N with no duplicates, and the
|
|
92
|
+
* fields must line up with the base view's columns as the database catalog reports them. The
|
|
93
|
+
* catalog is read instead of a sample row so a view with no rows is still checked.
|
|
94
|
+
*
|
|
95
|
+
* Scope follows the run's schema configuration: `excludeSchemas` is skipped, and when
|
|
96
|
+
* `includeSchemas` is set only those schemas are checked.
|
|
97
|
+
*/
|
|
93
98
|
static async CheckEntityFieldSequencesInternal(pool, filter) {
|
|
94
99
|
try {
|
|
95
100
|
const schema = MjCoreSchema();
|
|
96
101
|
const sSQL = `SELECT ${qi('ID')}, ${qi('Entity')}, ${qi('SchemaName')}, ${qi('BaseView')}, ${qi('EntityID')}, ${qi('Name')}, ${qi('Sequence')} FROM ${qi(schema)}.${qi('vwEntityFields')} ${filter} ORDER BY ${qi('Entity')}, ${qi('Sequence')}`;
|
|
97
102
|
const resultResult = await pool.query(sSQL);
|
|
98
|
-
const result = resultResult.recordset;
|
|
99
|
-
if (
|
|
103
|
+
const result = (resultResult.recordset ?? []);
|
|
104
|
+
if (result.length === 0) {
|
|
100
105
|
throw new Error("No entity fields found");
|
|
101
106
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
for (const row of result) {
|
|
111
|
-
if (excludedSchemas.has(String(row.SchemaName ?? '').toLowerCase())) {
|
|
112
|
-
lastEntity = row.Entity;
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (lastEntity !== row.Entity) {
|
|
116
|
-
// we have a new entity, check all the fields in this entity
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
-
const fields = result.filter((f) => f.Entity === row.Entity);
|
|
119
|
-
// check for duplicate sequences, and build a list of duplicate sequences to include the field name in the message along with the sequence
|
|
120
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
-
const duplicates = fields.filter((f) => fields.filter((f2) => f2.Sequence === f.Sequence).length > 1);
|
|
122
|
-
if (duplicates.length > 0) {
|
|
123
|
-
success = false;
|
|
124
|
-
message += `Entity ${row.Entity} has duplicate Entity Field sequences:\n`;
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
-
message += duplicates.map((d) => ` * ${d.Name} (${d.Sequence})`).join("\n");
|
|
127
|
-
message += "\n";
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
// no duplicates, so now check to see if all of the sequences are in order, starting with 1
|
|
131
|
-
let sequence = 1;
|
|
132
|
-
for (const field of fields) {
|
|
133
|
-
if (field.Sequence !== sequence) {
|
|
134
|
-
success = false;
|
|
135
|
-
message += `Entity ${row.Entity} has a missing sequence number. Expected ${sequence}, but found ${field.Sequence} for field ${field.Name}\n`;
|
|
136
|
-
}
|
|
137
|
-
sequence++;
|
|
138
|
-
}
|
|
139
|
-
if (success) {
|
|
140
|
-
// finally, check to see if the metadata sequence numbers match the physical order of the columns in the
|
|
141
|
-
// underlying base view. This is critical for calling the spUpdate/spCreate procs correctly.
|
|
142
|
-
// we will do this by selecting one row from the base view
|
|
143
|
-
const entity = row.Entity;
|
|
144
|
-
const sampleSQL = selectOne(row.SchemaName, row.BaseView);
|
|
145
|
-
const sampleResultResult = await pool.query(sampleSQL);
|
|
146
|
-
const sampleResult = sampleResultResult.recordset;
|
|
147
|
-
// now check the order of the columns in the result set relative to the
|
|
148
|
-
// fields array
|
|
149
|
-
if (sampleResult && sampleResult.length > 0) {
|
|
150
|
-
const columns = Object.keys(sampleResult[0]);
|
|
151
|
-
let i = 0;
|
|
152
|
-
for (const field of fields) {
|
|
153
|
-
if (columns[i] !== field.Name) {
|
|
154
|
-
success = false;
|
|
155
|
-
message += `Entity ${entity} has a mismatch between the metadata sequence and the physical column order in the base view ${qi(row.SchemaName)}.${qi(row.BaseView)} for position ${i + 1}. Expected ${field.Name} but found ${columns[i]}\n`;
|
|
156
|
-
}
|
|
157
|
-
i++;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
lastEntity = row.Entity;
|
|
163
|
-
}
|
|
107
|
+
const inScope = result.filter(r => SystemIntegrityBase.IsSchemaInScope(r.SchemaName));
|
|
108
|
+
const byEntity = new Map();
|
|
109
|
+
for (const row of inScope) {
|
|
110
|
+
const key = String(row.EntityID);
|
|
111
|
+
let fields = byEntity.get(key);
|
|
112
|
+
if (!fields) {
|
|
113
|
+
fields = [];
|
|
114
|
+
byEntity.set(key, fields);
|
|
164
115
|
}
|
|
165
|
-
|
|
116
|
+
fields.push(row);
|
|
166
117
|
}
|
|
118
|
+
const viewSchemas = [...new Set(inScope.map(r => r.SchemaName).filter(s => !!s))];
|
|
119
|
+
const catalog = await SystemIntegrityBase.LoadCatalogColumns(pool, viewSchemas);
|
|
120
|
+
const excludedViewFields = SystemIntegrityBase.ExcludedBaseViewFields();
|
|
121
|
+
const messages = [];
|
|
122
|
+
for (const fields of byEntity.values()) {
|
|
123
|
+
const entityMessage = SystemIntegrityBase.CheckSingleEntity(fields, catalog, excludedViewFields);
|
|
124
|
+
if (entityMessage) {
|
|
125
|
+
messages.push(entityMessage);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return { Success: messages.length === 0, Message: messages.join(''), Name: 'entityFieldsSequenceCheck' };
|
|
167
129
|
}
|
|
168
130
|
catch (e) {
|
|
169
131
|
const message = `Error checking entity field sequences: ${e}`;
|
|
@@ -171,6 +133,120 @@ export class SystemIntegrityBase {
|
|
|
171
133
|
return { Success: false, Message: message, Name: 'entityFieldsSequenceCheck' };
|
|
172
134
|
}
|
|
173
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* True when the schema is checked: not in `excludeSchemas`, and in `includeSchemas` when that
|
|
138
|
+
* list is set. Compared case-insensitively.
|
|
139
|
+
*/
|
|
140
|
+
static IsSchemaInScope(schemaName) {
|
|
141
|
+
const target = String(schemaName ?? '').trim().toLowerCase();
|
|
142
|
+
const excluded = (configInfo.excludeSchemas ?? []).map(s => s.trim().toLowerCase());
|
|
143
|
+
if (excluded.includes(target)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const included = (configInfo.includeSchemas ?? []).map(s => s.trim().toLowerCase());
|
|
147
|
+
if (included.length > 0 && !included.includes(target)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Reads the column order of every view and table in the given schemas from
|
|
154
|
+
* INFORMATION_SCHEMA.COLUMNS, which both SQL Server and PostgreSQL provide.
|
|
155
|
+
* @returns `schema.object` (lower case) → column names in ordinal order
|
|
156
|
+
*/
|
|
157
|
+
static async LoadCatalogColumns(pool, schemas) {
|
|
158
|
+
const columns = new Map();
|
|
159
|
+
if (schemas.length === 0) {
|
|
160
|
+
return columns;
|
|
161
|
+
}
|
|
162
|
+
const schemaList = schemas.map(s => `'${escapeLiteral(s)}'`).join(', ');
|
|
163
|
+
const sql = `SELECT TABLE_SCHEMA AS "TableSchema", TABLE_NAME AS "TableName", COLUMN_NAME AS "ColumnName", ORDINAL_POSITION AS "Ordinal"
|
|
164
|
+
FROM INFORMATION_SCHEMA.COLUMNS
|
|
165
|
+
WHERE TABLE_SCHEMA IN (${schemaList})
|
|
166
|
+
ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION`;
|
|
167
|
+
const rows = ((await pool.query(sql)).recordset ?? []);
|
|
168
|
+
const ordered = [...rows].sort((a, b) => Number(a.Ordinal) - Number(b.Ordinal));
|
|
169
|
+
for (const row of ordered) {
|
|
170
|
+
const key = catalogKey(row.TableSchema, row.TableName);
|
|
171
|
+
let list = columns.get(key);
|
|
172
|
+
if (!list) {
|
|
173
|
+
list = [];
|
|
174
|
+
columns.set(key, list);
|
|
175
|
+
}
|
|
176
|
+
list.push(row.ColumnName);
|
|
177
|
+
}
|
|
178
|
+
return columns;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Base-view column exclusions (`baseViewExcludedFields`) keep an EntityField whose column the
|
|
182
|
+
* view leaves out on purpose, so those fields are skipped in the column comparison. Entries are
|
|
183
|
+
* `Entity.Field` or a bare `Field` (any entity). Empty unless exclusions are permitted.
|
|
184
|
+
*/
|
|
185
|
+
static ExcludedBaseViewFields() {
|
|
186
|
+
const qualified = new Set();
|
|
187
|
+
const bare = new Set();
|
|
188
|
+
if (!BaseViewExclusionsPermitted()) {
|
|
189
|
+
return { qualified, bare };
|
|
190
|
+
}
|
|
191
|
+
for (const raw of configInfo.baseViewExcludedFields ?? []) {
|
|
192
|
+
const entry = raw.trim();
|
|
193
|
+
const lastDot = entry.lastIndexOf('.');
|
|
194
|
+
if (lastDot > 0 && lastDot < entry.length - 1) {
|
|
195
|
+
qualified.add(`${entry.slice(0, lastDot).trim().toLowerCase()}.${entry.slice(lastDot + 1).trim().toLowerCase()}`);
|
|
196
|
+
}
|
|
197
|
+
else if (entry.length > 0) {
|
|
198
|
+
bare.add(entry.toLowerCase());
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return { qualified, bare };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Checks one entity's fields (already ordered by Sequence).
|
|
205
|
+
* @returns an empty string when the entity passes, otherwise the failure text
|
|
206
|
+
*/
|
|
207
|
+
static CheckSingleEntity(fields, catalog, excludedViewFields) {
|
|
208
|
+
const entity = fields[0].Entity;
|
|
209
|
+
const seen = new Map();
|
|
210
|
+
for (const f of fields) {
|
|
211
|
+
seen.set(f.Sequence, (seen.get(f.Sequence) ?? 0) + 1);
|
|
212
|
+
}
|
|
213
|
+
const duplicates = fields.filter(f => (seen.get(f.Sequence) ?? 0) > 1);
|
|
214
|
+
if (duplicates.length > 0) {
|
|
215
|
+
return `Entity ${entity} has duplicate Entity Field sequences:\n` +
|
|
216
|
+
duplicates.map(d => ` * ${d.Name} (${d.Sequence})`).join("\n") + "\n";
|
|
217
|
+
}
|
|
218
|
+
let message = '';
|
|
219
|
+
fields.forEach((field, index) => {
|
|
220
|
+
if (field.Sequence !== index + 1) {
|
|
221
|
+
message += `Entity ${entity} has a missing sequence number. Expected ${index + 1}, but found ${field.Sequence} for field ${field.Name}\n`;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
if (message) {
|
|
225
|
+
return message;
|
|
226
|
+
}
|
|
227
|
+
// The metadata sequence must match the physical column order of the base view; the
|
|
228
|
+
// spCreate/spUpdate result capture depends on it.
|
|
229
|
+
const schemaName = fields[0].SchemaName;
|
|
230
|
+
const baseView = fields[0].BaseView;
|
|
231
|
+
if (!schemaName || !baseView) {
|
|
232
|
+
return '';
|
|
233
|
+
}
|
|
234
|
+
const columns = catalog.get(catalogKey(schemaName, baseView));
|
|
235
|
+
if (!columns || columns.length === 0) {
|
|
236
|
+
return `Entity ${entity} has no base view ${qi(schemaName)}.${qi(baseView)} in the database catalog\n`;
|
|
237
|
+
}
|
|
238
|
+
const entityKey = entity.trim().toLowerCase();
|
|
239
|
+
const comparable = fields.filter(f => {
|
|
240
|
+
const name = f.Name.toLowerCase();
|
|
241
|
+
return !excludedViewFields.bare.has(name) && !excludedViewFields.qualified.has(`${entityKey}.${name}`);
|
|
242
|
+
});
|
|
243
|
+
for (let i = 0; i < comparable.length; i++) {
|
|
244
|
+
if (columns[i] !== comparable[i].Name) {
|
|
245
|
+
return `Entity ${entity} has a mismatch between the metadata sequence and the physical column order in the base view ${qi(schemaName)}.${qi(baseView)} for position ${i + 1}. Expected ${comparable[i].Name} but found ${columns[i]}\n`;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return '';
|
|
249
|
+
}
|
|
174
250
|
/**
|
|
175
251
|
* Classifies the output of {@link RunIntegrityChecks}. Pure: it decides, it does not report.
|
|
176
252
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system_integrity.js","sourceRoot":"","sources":["../../src/Misc/system_integrity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"system_integrity.js","sourceRoot":"","sources":["../../src/Misc/system_integrity.ts"],"names":[],"mappings":"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AC;IACpD,CAAC"}
|
|
@@ -8,4 +8,21 @@
|
|
|
8
8
|
* turning them into characters breaks the code.
|
|
9
9
|
*/
|
|
10
10
|
export declare function NormalizeGeneratedValidatorText(functionText: string): string;
|
|
11
|
+
/** Name of the case-insensitive UUID comparison helper from `@memberjunction/global`. */
|
|
12
|
+
export declare const UUIDS_EQUAL_FUNCTION_NAME = "UUIDsEqual";
|
|
13
|
+
/**
|
|
14
|
+
* Rewrites `===` / `!==` / `==` / `!=` comparisons between UUID fields in a generated validator into
|
|
15
|
+
* `UUIDsEqual(a, b)` / `!UUIDsEqual(a, b)` (#3984). A UUID can arrive in either casing depending on
|
|
16
|
+
* how the row was loaded, so `===` lets a self-reference that differs only in case pass the
|
|
17
|
+
* validator and fail on the database CHECK instead.
|
|
18
|
+
*
|
|
19
|
+
* A comparison is rewritten when one operand is `this.<field>` for a field in `uuidFieldNames` and
|
|
20
|
+
* the other is another such field or a string literal. Anything else (a `null` guard, a non-UUID
|
|
21
|
+
* field, a call) is left as written. Text that does not parse is returned unchanged.
|
|
22
|
+
*
|
|
23
|
+
* @param functionText - The validator method's source (a class member, signature included).
|
|
24
|
+
* @param uuidFieldNames - Property names of the entity's UUID fields as the generated class exposes them.
|
|
25
|
+
* @returns The rewritten source, or the input unchanged when nothing matched.
|
|
26
|
+
*/
|
|
27
|
+
export declare function RewriteUUIDComparisons(functionText: string, uuidFieldNames: ReadonlySet<string>): string;
|
|
11
28
|
//# sourceMappingURL=validator-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator-text.d.ts","sourceRoot":"","sources":["../../src/Misc/validator-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validator-text.d.ts","sourceRoot":"","sources":["../../src/Misc/validator-text.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAG5E;AAUD,yFAAyF;AACzF,eAAO,MAAM,yBAAyB,eAAe,CAAC;AAEtD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAmCxG"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
1
2
|
/**
|
|
2
3
|
* Turns a generated validator's text into source that can be written into a class.
|
|
3
4
|
*
|
|
@@ -12,4 +13,62 @@ export function NormalizeGeneratedValidatorText(functionText) {
|
|
|
12
13
|
return functionText;
|
|
13
14
|
return functionText.replace(/\\n/g, '\n').replace(/\\t/g, '\t').replace(/\\"/g, '"');
|
|
14
15
|
}
|
|
16
|
+
/** The equality operators a UUID comparison is rewritten from, mapped to whether the result is negated. */
|
|
17
|
+
const UUID_EQUALITY_OPERATORS = new Map([
|
|
18
|
+
[ts.SyntaxKind.EqualsEqualsEqualsToken, false],
|
|
19
|
+
[ts.SyntaxKind.EqualsEqualsToken, false],
|
|
20
|
+
[ts.SyntaxKind.ExclamationEqualsEqualsToken, true],
|
|
21
|
+
[ts.SyntaxKind.ExclamationEqualsToken, true],
|
|
22
|
+
]);
|
|
23
|
+
/** Name of the case-insensitive UUID comparison helper from `@memberjunction/global`. */
|
|
24
|
+
export const UUIDS_EQUAL_FUNCTION_NAME = 'UUIDsEqual';
|
|
25
|
+
/**
|
|
26
|
+
* Rewrites `===` / `!==` / `==` / `!=` comparisons between UUID fields in a generated validator into
|
|
27
|
+
* `UUIDsEqual(a, b)` / `!UUIDsEqual(a, b)` (#3984). A UUID can arrive in either casing depending on
|
|
28
|
+
* how the row was loaded, so `===` lets a self-reference that differs only in case pass the
|
|
29
|
+
* validator and fail on the database CHECK instead.
|
|
30
|
+
*
|
|
31
|
+
* A comparison is rewritten when one operand is `this.<field>` for a field in `uuidFieldNames` and
|
|
32
|
+
* the other is another such field or a string literal. Anything else (a `null` guard, a non-UUID
|
|
33
|
+
* field, a call) is left as written. Text that does not parse is returned unchanged.
|
|
34
|
+
*
|
|
35
|
+
* @param functionText - The validator method's source (a class member, signature included).
|
|
36
|
+
* @param uuidFieldNames - Property names of the entity's UUID fields as the generated class exposes them.
|
|
37
|
+
* @returns The rewritten source, or the input unchanged when nothing matched.
|
|
38
|
+
*/
|
|
39
|
+
export function RewriteUUIDComparisons(functionText, uuidFieldNames) {
|
|
40
|
+
if (uuidFieldNames.size === 0 || !/[=!]=/.test(functionText))
|
|
41
|
+
return functionText;
|
|
42
|
+
const prefix = 'class __Validator {\n';
|
|
43
|
+
const wrapped = `${prefix}${functionText}\n}`;
|
|
44
|
+
const sourceFile = ts.createSourceFile('validator.ts', wrapped, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
45
|
+
const parseDiagnostics = sourceFile.parseDiagnostics ?? [];
|
|
46
|
+
if (parseDiagnostics.length > 0)
|
|
47
|
+
return functionText;
|
|
48
|
+
const isUUIDField = (node) => ts.isPropertyAccessExpression(node) && node.expression.kind === ts.SyntaxKind.ThisKeyword && uuidFieldNames.has(node.name.text);
|
|
49
|
+
const isStringLiteral = (node) => ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node);
|
|
50
|
+
const edits = [];
|
|
51
|
+
const visit = (node) => {
|
|
52
|
+
if (ts.isBinaryExpression(node)) {
|
|
53
|
+
const negate = UUID_EQUALITY_OPERATORS.get(node.operatorToken.kind);
|
|
54
|
+
const left = node.left;
|
|
55
|
+
const right = node.right;
|
|
56
|
+
const matches = (isUUIDField(left) && (isUUIDField(right) || isStringLiteral(right))) || (isStringLiteral(left) && isUUIDField(right));
|
|
57
|
+
if (negate !== undefined && matches) {
|
|
58
|
+
const call = `${UUIDS_EQUAL_FUNCTION_NAME}(${left.getText(sourceFile)}, ${right.getText(sourceFile)})`;
|
|
59
|
+
edits.push({ Start: node.getStart(sourceFile), End: node.getEnd(), Text: negate ? `!${call}` : call });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
ts.forEachChild(node, visit);
|
|
64
|
+
};
|
|
65
|
+
visit(sourceFile);
|
|
66
|
+
if (edits.length === 0)
|
|
67
|
+
return functionText;
|
|
68
|
+
let result = wrapped;
|
|
69
|
+
for (const edit of edits.sort((a, b) => b.Start - a.Start)) {
|
|
70
|
+
result = result.slice(0, edit.Start) + edit.Text + result.slice(edit.End);
|
|
71
|
+
}
|
|
72
|
+
return result.slice(prefix.length, result.length - 2);
|
|
73
|
+
}
|
|
15
74
|
//# sourceMappingURL=validator-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator-text.js","sourceRoot":"","sources":["../../src/Misc/validator-text.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,YAAoB;IAClE,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,YAAY,CAAC;IAC5D,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACvF,CAAC"}
|
|
1
|
+
{"version":3,"file":"validator-text.js","sourceRoot":"","sources":["../../src/Misc/validator-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,YAAoB;IAClE,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,YAAY,CAAC;IAC5D,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACvF,CAAC;AAED,2GAA2G;AAC3G,MAAM,uBAAuB,GAAwC,IAAI,G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,MAAM,KAAK,CAAC;QAAE,OAAO,YAAY,CAAC;IAE5C,IAAI,MAAM,GAAG,OAAO,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/runCodeGen.d.ts
CHANGED
|
@@ -18,16 +18,50 @@ type DataSourceResult = ProviderDataSourceResult;
|
|
|
18
18
|
/**
|
|
19
19
|
* Main orchestrator class for the MemberJunction code generation process.
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* Counts validators by identity (`entityName|functionName`, entity compared case-insensitively),
|
|
23
|
+
* so a validator regenerated or loaded twice is reported once.
|
|
24
|
+
*/
|
|
25
|
+
export declare function CountDistinctValidators(validators: ReadonlyArray<{
|
|
26
|
+
entityName: string;
|
|
27
|
+
functionName: string;
|
|
28
|
+
}>): number;
|
|
21
29
|
export declare class RunCodeGenBase {
|
|
22
30
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
31
|
+
* The entities the post-run CRUD validator expects routines for: IncludeInAPI and in scope. An
|
|
32
|
+
* out-of-scope schema's routines belong to another run (#3384).
|
|
33
|
+
*/
|
|
34
|
+
static CRUDValidationBaseline<T extends {
|
|
35
|
+
IncludeInAPI: boolean;
|
|
36
|
+
SchemaName: string;
|
|
37
|
+
}>(entities: T[], excludeSchemas: string[] | undefined): T[];
|
|
38
|
+
/**
|
|
39
|
+
* Every step failure captured during a pipeline run: BEFORE/AFTER commands, SQL scripts,
|
|
40
|
+
* metadata management, the SQL pass, validators, file generation and integrity checks.
|
|
41
|
+
* The pipeline runs every step to the end, then fails (success=false, non-zero exit) with
|
|
42
|
+
* this full list, instead of stopping at the first failure or logging and reporting success.
|
|
26
43
|
*/
|
|
27
44
|
protected commandFailures: Array<{
|
|
28
45
|
context: string;
|
|
29
46
|
message: string;
|
|
30
47
|
}>;
|
|
48
|
+
/** Records a step failure for the end-of-run list, and logs it now. */
|
|
49
|
+
protected RecordStepFailure(context: string, message: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* True when a CORE file-generation pass has no in-scope entities, so it must not run (#3384). Those
|
|
52
|
+
* passes rewrite whole files from the entity list, so running one on an empty list (the core schema
|
|
53
|
+
* left out of `includeSchemas`, or excluded) would empty its output. The skip is logged as a warning.
|
|
54
|
+
* @param passLabel name of the pass, for the log
|
|
55
|
+
* @param entities the pass's scope-narrowed entity list
|
|
56
|
+
*/
|
|
57
|
+
static SkipEmptyCorePass(passLabel: string, entities: ReadonlyArray<MJ.EntityInfo>): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Formats the end-of-run failure list. Returns an empty string when there are none.
|
|
60
|
+
*/
|
|
61
|
+
static FormatStepFailures(failures: ReadonlyArray<{
|
|
62
|
+
context: string;
|
|
63
|
+
message: string;
|
|
64
|
+
}>): string;
|
|
31
65
|
/**
|
|
32
66
|
* Record any failed entries from a BEFORE/AFTER command batch, paired by index.
|
|
33
67
|
*
|
package/dist/runCodeGen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCodeGen.d.ts","sourceRoot":"","sources":["../src/runCodeGen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,EAA4G,WAAW,
|
|
1
|
+
{"version":3,"file":"runCodeGen.d.ts","sourceRoot":"","sources":["../src/runCodeGen.ts"],"names":[],"mappings":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