@memberjunction/codegen-lib 5.4.1 → 5.5.0

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.
Files changed (75) hide show
  1. package/README.md +65 -2
  2. package/dist/Angular/angular-codegen.d.ts.map +1 -1
  3. package/dist/Angular/angular-codegen.js +26 -12
  4. package/dist/Angular/angular-codegen.js.map +1 -1
  5. package/dist/Angular/related-entity-components.js +2 -2
  6. package/dist/Angular/related-entity-components.js.map +1 -1
  7. package/dist/Config/config.d.ts +10 -0
  8. package/dist/Config/config.d.ts.map +1 -1
  9. package/dist/Config/config.js +10 -0
  10. package/dist/Config/config.js.map +1 -1
  11. package/dist/Database/codeGenDatabaseProvider.d.ts +544 -0
  12. package/dist/Database/codeGenDatabaseProvider.d.ts.map +1 -0
  13. package/dist/Database/codeGenDatabaseProvider.js +29 -0
  14. package/dist/Database/codeGenDatabaseProvider.js.map +1 -0
  15. package/dist/Database/manage-metadata.d.ts +165 -60
  16. package/dist/Database/manage-metadata.d.ts.map +1 -1
  17. package/dist/Database/manage-metadata.js +592 -483
  18. package/dist/Database/manage-metadata.js.map +1 -1
  19. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.d.ts +53 -0
  20. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.d.ts.map +1 -0
  21. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.js +112 -0
  22. package/dist/Database/providers/postgresql/PostgreSQLCodeGenConnection.js.map +1 -0
  23. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts +344 -0
  24. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.d.ts.map +1 -0
  25. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js +1567 -0
  26. package/dist/Database/providers/postgresql/PostgreSQLCodeGenProvider.js.map +1 -0
  27. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.d.ts +42 -0
  28. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.d.ts.map +1 -0
  29. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.js +84 -0
  30. package/dist/Database/providers/sqlserver/SQLServerCodeGenConnection.js.map +1 -0
  31. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts +372 -0
  32. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts.map +1 -0
  33. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js +1483 -0
  34. package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js.map +1 -0
  35. package/dist/Database/reorder-columns.d.ts +2 -2
  36. package/dist/Database/reorder-columns.d.ts.map +1 -1
  37. package/dist/Database/reorder-columns.js +9 -9
  38. package/dist/Database/reorder-columns.js.map +1 -1
  39. package/dist/Database/sql.d.ts +10 -5
  40. package/dist/Database/sql.d.ts.map +1 -1
  41. package/dist/Database/sql.js +44 -228
  42. package/dist/Database/sql.js.map +1 -1
  43. package/dist/Database/sql_codegen.d.ts +31 -29
  44. package/dist/Database/sql_codegen.d.ts.map +1 -1
  45. package/dist/Database/sql_codegen.js +209 -842
  46. package/dist/Database/sql_codegen.js.map +1 -1
  47. package/dist/Misc/action_subclasses_codegen.js +3 -2
  48. package/dist/Misc/action_subclasses_codegen.js.map +1 -1
  49. package/dist/Misc/entity_subclasses_codegen.d.ts +4 -4
  50. package/dist/Misc/entity_subclasses_codegen.d.ts.map +1 -1
  51. package/dist/Misc/entity_subclasses_codegen.js.map +1 -1
  52. package/dist/Misc/graphql_server_codegen.d.ts +6 -1
  53. package/dist/Misc/graphql_server_codegen.d.ts.map +1 -1
  54. package/dist/Misc/graphql_server_codegen.js +33 -35
  55. package/dist/Misc/graphql_server_codegen.js.map +1 -1
  56. package/dist/Misc/sql_logging.d.ts +2 -2
  57. package/dist/Misc/sql_logging.d.ts.map +1 -1
  58. package/dist/Misc/sql_logging.js +1 -1
  59. package/dist/Misc/sql_logging.js.map +1 -1
  60. package/dist/Misc/system_integrity.d.ts +6 -6
  61. package/dist/Misc/system_integrity.d.ts.map +1 -1
  62. package/dist/Misc/system_integrity.js +33 -8
  63. package/dist/Misc/system_integrity.js.map +1 -1
  64. package/dist/Misc/temp_batch_file.d.ts.map +1 -1
  65. package/dist/Misc/temp_batch_file.js +4 -1
  66. package/dist/Misc/temp_batch_file.js.map +1 -1
  67. package/dist/index.d.ts +5 -0
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +5 -0
  70. package/dist/index.js.map +1 -1
  71. package/dist/runCodeGen.d.ts +30 -75
  72. package/dist/runCodeGen.d.ts.map +1 -1
  73. package/dist/runCodeGen.js +123 -215
  74. package/dist/runCodeGen.js.map +1 -1
  75. package/package.json +18 -15
@@ -0,0 +1,544 @@
1
+ import { EntityInfo, EntityFieldInfo } from '@memberjunction/core';
2
+ import { DatabasePlatform, SQLDialect } from '@memberjunction/sql-dialect';
3
+ /**
4
+ * Represents a single row from a query result.
5
+ *
6
+ * NOTE: This is typed as `any` for backward compatibility with the existing codebase,
7
+ * which extensively accesses recordset rows with inline type annotations and untyped
8
+ * property access inherited from the mssql driver's `IRecordSet<any>`. As individual
9
+ * call sites are migrated to proper typing, this can be narrowed to
10
+ * `Record<string, unknown>` or a generic parameter.
11
+ */
12
+ export type CodeGenQueryRow = any;
13
+ /**
14
+ * Result from executing a SQL query through a CodeGenConnection.
15
+ * Normalizes the result shapes from different database drivers (mssql, pg, etc.)
16
+ * into a single interface that the orchestrator code can rely on.
17
+ */
18
+ export interface CodeGenQueryResult {
19
+ /** The array of rows returned by the query. Empty array if no rows. */
20
+ recordset: CodeGenQueryRow[];
21
+ }
22
+ /**
23
+ * A database transaction handle that supports query execution, commit, and rollback.
24
+ * Obtained from CodeGenConnection.beginTransaction().
25
+ */
26
+ export interface CodeGenTransaction {
27
+ /**
28
+ * Executes a SQL query within this transaction.
29
+ * @param sql The SQL statement to execute.
30
+ * @returns The query result.
31
+ */
32
+ query(sql: string): Promise<CodeGenQueryResult>;
33
+ /**
34
+ * Commits the transaction. After commit, this transaction handle must not be reused.
35
+ */
36
+ commit(): Promise<void>;
37
+ /**
38
+ * Rolls back the transaction. After rollback, this transaction handle must not be reused.
39
+ */
40
+ rollback(): Promise<void>;
41
+ }
42
+ /**
43
+ * Database-agnostic connection interface for CodeGen operations.
44
+ *
45
+ * This interface abstracts the underlying database driver (mssql.ConnectionPool,
46
+ * pg.Pool, etc.) so that the orchestration code in SQLCodeGenBase, ManageMetadataBase,
47
+ * and related classes can work with any supported database platform.
48
+ *
49
+ * ## Usage Patterns
50
+ *
51
+ * **Simple query (no parameters):**
52
+ * ```typescript
53
+ * const result = await conn.query("SELECT ID, Name FROM MyTable WHERE Status = Active");
54
+ * const rows = result.recordset;
55
+ * ```
56
+ *
57
+ * **Parameterized query (safe from SQL injection):**
58
+ * ```typescript
59
+ * const result = await conn.queryWithParams(
60
+ * "SELECT ID FROM MyTable WHERE Name = @Name AND SchemaName = @Schema",
61
+ * { Name: Users, Schema: dbo }
62
+ * );
63
+ * ```
64
+ *
65
+ * **Stored procedure / function call:**
66
+ * ```typescript
67
+ * const result = await conn.executeStoredProcedure(
68
+ * "[dbo].[spCreateEntity]",
69
+ * { Name: NewEntity, SchemaName: dbo }
70
+ * );
71
+ * ```
72
+ *
73
+ * **Transaction:**
74
+ * ```typescript
75
+ * const tx = await conn.beginTransaction();
76
+ * try {
77
+ * await tx.query("INSERT INTO ...");
78
+ * await tx.query("UPDATE ...");
79
+ * await tx.commit();
80
+ * } catch (e) {
81
+ * await tx.rollback();
82
+ * throw e;
83
+ * }
84
+ * ```
85
+ *
86
+ * ## Implementations
87
+ * - `SQLServerCodeGenConnection` wraps `mssql.ConnectionPool` (in CodeGenLib)
88
+ * - `PostgreSQLCodeGenConnection` wraps `pg.Pool` (in PostgreSQLDataProvider)
89
+ */
90
+ export interface CodeGenConnection {
91
+ /**
92
+ * Executes a SQL query without parameters.
93
+ * @param sql The SQL statement to execute.
94
+ * @returns The query result with a `recordset` array.
95
+ */
96
+ query(sql: string): Promise<CodeGenQueryResult>;
97
+ /**
98
+ * Executes a SQL query with named parameters.
99
+ * Parameters are passed as key-value pairs and the implementation is responsible
100
+ * for binding them safely (e.g., @Name for SQL Server, $1/$2 for PostgreSQL).
101
+ *
102
+ * For SQL Server, the parameter names in the SQL should use @-prefix notation
103
+ * matching the keys in the params object.
104
+ * For PostgreSQL, the implementation translates @-prefixed names to $N notation.
105
+ *
106
+ * @param sql The SQL statement with parameter placeholders.
107
+ * @param params Named parameters as key-value pairs.
108
+ * @returns The query result with a `recordset` array.
109
+ */
110
+ queryWithParams(sql: string, params: Record<string, unknown>): Promise<CodeGenQueryResult>;
111
+ /**
112
+ * Executes a stored procedure (SQL Server) or function call (PostgreSQL).
113
+ * @param name The fully qualified routine name (e.g., "[dbo].[spCreateEntity]").
114
+ * @param params Named parameters for the routine.
115
+ * @returns The query result with a `recordset` array.
116
+ */
117
+ executeStoredProcedure(name: string, params: Record<string, unknown>): Promise<CodeGenQueryResult>;
118
+ /**
119
+ * Begins a new database transaction.
120
+ * @returns A CodeGenTransaction handle for executing queries within the transaction.
121
+ */
122
+ beginTransaction(): Promise<CodeGenTransaction>;
123
+ }
124
+ /**
125
+ * Union type for stored procedure / function types (Create, Update, Delete).
126
+ */
127
+ export declare const CRUDType: {
128
+ readonly Create: "Create";
129
+ readonly Update: "Update";
130
+ readonly Delete: "Delete";
131
+ };
132
+ export type CRUDType = (typeof CRUDType)[keyof typeof CRUDType];
133
+ /**
134
+ * Result from full-text search SQL generation.
135
+ */
136
+ export interface FullTextSearchResult {
137
+ /** The complete SQL string for creating the FTS objects */
138
+ sql: string;
139
+ /** The name of the generated search function */
140
+ functionName: string;
141
+ }
142
+ /**
143
+ * Options for generating a base view.
144
+ */
145
+ export interface BaseViewGenerationContext {
146
+ /** Entity to generate the view for */
147
+ entity: EntityInfo;
148
+ /** Related field SELECT expressions (e.g., joined name fields) */
149
+ relatedFieldsSelect: string;
150
+ /** JOIN clauses for related entities */
151
+ relatedFieldsJoins: string;
152
+ /** IS-A parent entity field SELECTs */
153
+ parentFieldsSelect: string;
154
+ /** IS-A parent entity JOIN clauses */
155
+ parentJoins: string;
156
+ /** Root ID field SELECTs (for recursive FKs) */
157
+ rootFieldsSelect: string;
158
+ /** Root ID JOIN clauses (for recursive FKs) */
159
+ rootJoins: string;
160
+ }
161
+ /**
162
+ * Options for cascade delete generation.
163
+ */
164
+ export interface CascadeDeleteContext {
165
+ /** The parent entity being deleted */
166
+ parentEntity: EntityInfo;
167
+ /** The related entity whose records must be cascaded */
168
+ relatedEntity: EntityInfo;
169
+ /** The FK field on the related entity pointing to the parent */
170
+ fkField: EntityFieldInfo;
171
+ /** The operation to perform: 'delete' cascades by deleting records, 'update' sets the FK to NULL */
172
+ operation: 'delete' | 'update';
173
+ }
174
+ /**
175
+ * Abstract base class for database-specific code generation providers.
176
+ *
177
+ * Each database platform (SQL Server, PostgreSQL, etc.) implements this class
178
+ * to generate the appropriate DDL for views, CRUD routines, triggers, indexes,
179
+ * full-text search, permissions, and other database objects.
180
+ *
181
+ * The orchestrator (SQLCodeGenBase) calls these methods to produce platform-specific
182
+ * SQL while keeping the high-level generation logic database-agnostic.
183
+ */
184
+ export declare abstract class CodeGenDatabaseProvider {
185
+ /**
186
+ * The SQL dialect instance for this provider.
187
+ */
188
+ abstract get Dialect(): SQLDialect;
189
+ /**
190
+ * The database platform key (e.g., 'sqlserver', 'postgresql').
191
+ */
192
+ abstract get PlatformKey(): DatabasePlatform;
193
+ /**
194
+ * Generates a conditional DROP + CREATE guard for a database object.
195
+ * For SQL Server: `IF OBJECT_ID(...) IS NOT NULL DROP ...`
196
+ * For PostgreSQL: `DROP ... IF EXISTS ...` or `CREATE OR REPLACE ...`
197
+ */
198
+ abstract generateDropGuard(objectType: 'VIEW' | 'PROCEDURE' | 'FUNCTION' | 'TRIGGER', schema: string, name: string): string;
199
+ /**
200
+ * Generates the complete base view DDL for an entity, including the DROP guard.
201
+ * The orchestrator provides pre-computed context (related fields, joins, parent joins, etc.)
202
+ * so the provider only needs to assemble the platform-specific SQL.
203
+ */
204
+ abstract generateBaseView(context: BaseViewGenerationContext): string;
205
+ /**
206
+ * Generates the CREATE stored procedure or function for an entity.
207
+ * SQL Server: `CREATE PROCEDURE [schema].[spCreate...]`
208
+ * PostgreSQL: `CREATE OR REPLACE FUNCTION schema.fn_create_...()`
209
+ */
210
+ abstract generateCRUDCreate(entity: EntityInfo): string;
211
+ /**
212
+ * Generates the UPDATE stored procedure or function for an entity.
213
+ * Includes the updated-at trigger generation.
214
+ */
215
+ abstract generateCRUDUpdate(entity: EntityInfo): string;
216
+ /**
217
+ * Generates the DELETE stored procedure or function for an entity.
218
+ * Handles both hard and soft delete types, and includes cascade delete logic.
219
+ */
220
+ abstract generateCRUDDelete(entity: EntityInfo, cascadeSQL: string): string;
221
+ /**
222
+ * Generates the __mj_UpdatedAt timestamp trigger for an entity.
223
+ * SQL Server: single AFTER UPDATE trigger.
224
+ * PostgreSQL: companion function + BEFORE UPDATE trigger.
225
+ */
226
+ abstract generateTimestampTrigger(entity: EntityInfo): string;
227
+ /**
228
+ * Generates CREATE INDEX statements for all foreign key columns on an entity.
229
+ * Returns an array of individual index DDL strings.
230
+ */
231
+ abstract generateForeignKeyIndexes(entity: EntityInfo): string[];
232
+ /**
233
+ * Generates full-text search infrastructure for an entity:
234
+ * SQL Server: FULLTEXT CATALOG + INDEX + inline TVF
235
+ * PostgreSQL: tsvector column + GIN index + trigger + search function
236
+ */
237
+ abstract generateFullTextSearch(entity: EntityInfo, searchFields: EntityFieldInfo[], primaryKeyIndexName: string): FullTextSearchResult;
238
+ /**
239
+ * Generates a recursive root-ID function for a self-referencing FK field.
240
+ * SQL Server: inline TVF with recursive CTE + OUTER APPLY in view.
241
+ * PostgreSQL: scalar function with recursive CTE + LEFT JOIN LATERAL in view.
242
+ */
243
+ abstract generateRootIDFunction(entity: EntityInfo, field: EntityFieldInfo): string;
244
+ /**
245
+ * Generates the SELECT expression for a root ID field in a base view.
246
+ * SQL Server: `rootFn.RootID AS [FieldRoot...]`
247
+ * PostgreSQL: `root_fn.root_id AS "FieldRoot..."`
248
+ */
249
+ abstract generateRootFieldSelect(entity: EntityInfo, field: EntityFieldInfo, alias: string): string;
250
+ /**
251
+ * Generates the JOIN clause for a root ID function in a base view.
252
+ * SQL Server: `OUTER APPLY [schema].[fnTable_GetRootID](t.ID) AS rootFn`
253
+ * PostgreSQL: `LEFT JOIN LATERAL schema.fn_table_get_root_id(t."ID") AS root_fn ON true`
254
+ */
255
+ abstract generateRootFieldJoin(entity: EntityInfo, field: EntityFieldInfo, alias: string): string;
256
+ /**
257
+ * Generates GRANT SELECT permission for a base view.
258
+ */
259
+ abstract generateViewPermissions(entity: EntityInfo): string;
260
+ /**
261
+ * Generates GRANT EXECUTE permission for a CRUD routine.
262
+ */
263
+ abstract generateCRUDPermissions(entity: EntityInfo, routineName: string, type: CRUDType): string;
264
+ /**
265
+ * Generates GRANT EXECUTE permission for a full-text search function.
266
+ */
267
+ abstract generateFullTextSearchPermissions(entity: EntityInfo, functionName: string): string;
268
+ /**
269
+ * Generates the cascade delete/update SQL for a single related entity.
270
+ * Called by the orchestrator for each FK relationship when CascadeDeletes is true.
271
+ */
272
+ abstract generateSingleCascadeOperation(context: CascadeDeleteContext): string;
273
+ /**
274
+ * Generates ALTER TABLE statements to add __mj_CreatedAt and __mj_UpdatedAt columns.
275
+ */
276
+ abstract generateTimestampColumns(schema: string, tableName: string): string;
277
+ /**
278
+ * Generates the parameter list string for a CRUD routine.
279
+ * SQL Server: `@Name NVARCHAR(255), @Email NVARCHAR(255)`
280
+ * PostgreSQL: `p_name VARCHAR(255), p_email VARCHAR(255)`
281
+ */
282
+ abstract generateCRUDParamString(entityFields: EntityFieldInfo[], isUpdate: boolean): string;
283
+ /**
284
+ * Generates the column-list or value-list portion of an INSERT statement.
285
+ * When `prefix` is empty, generates column names.
286
+ * When `prefix` is '@' (SQL Server) or 'p_' (PostgreSQL), generates parameter references.
287
+ */
288
+ abstract generateInsertFieldString(entity: EntityInfo, entityFields: EntityFieldInfo[], prefix: string, excludePrimaryKey?: boolean): string;
289
+ /**
290
+ * Generates the SET clause for an UPDATE statement.
291
+ * SQL Server: `[Name] = @Name, [Email] = @Email`
292
+ * PostgreSQL: `"Name" = p_name, "Email" = p_email`
293
+ */
294
+ abstract generateUpdateFieldString(entityFields: EntityFieldInfo[]): string;
295
+ /**
296
+ * Returns the name of the CRUD routine for an entity.
297
+ * SQL Server: `spCreateEntityName`
298
+ * PostgreSQL: `fn_create_entity_name`
299
+ */
300
+ abstract getCRUDRoutineName(entity: EntityInfo, type: CRUDType): string;
301
+ /**
302
+ * Generates a comment header for a generated SQL file.
303
+ */
304
+ abstract generateSQLFileHeader(entity: EntityInfo, itemName: string): string;
305
+ /**
306
+ * Generates a comment header for the combined all-entities SQL file.
307
+ */
308
+ abstract generateAllEntitiesSQLFileHeader(): string;
309
+ /**
310
+ * Formats a default value for use in generated SQL.
311
+ * Handles SQL functions (GETUTCDATE, gen_random_uuid, etc.) and literal values.
312
+ */
313
+ abstract formatDefaultValue(defaultValue: string, needsQuotes: boolean): string;
314
+ /**
315
+ * Builds primary key variable declarations, select fields, fetch-into, and SP param strings
316
+ * for use in cursor-based cascade operations.
317
+ */
318
+ abstract buildPrimaryKeyComponents(entity: EntityInfo, prefix?: string): {
319
+ varDeclarations: string;
320
+ selectFields: string;
321
+ fetchInto: string;
322
+ routineParams: string;
323
+ };
324
+ /**
325
+ * Returns a SQL query string to retrieve the current view definition from the database.
326
+ * SQL Server: `SELECT OBJECT_DEFINITION(OBJECT_ID('[schema].[viewName]')) AS ViewDefinition`
327
+ * PostgreSQL: `SELECT pg_get_viewdef('"schema"."viewName"'::regclass, true) AS "ViewDefinition"`
328
+ *
329
+ * The result set must include a column named `ViewDefinition`.
330
+ */
331
+ abstract getViewDefinitionSQL(schema: string, viewName: string): string;
332
+ /**
333
+ * Returns a SQL query string to retrieve the primary key index name for a table.
334
+ * SQL Server: queries `sys.indexes` + `sys.key_constraints`
335
+ * PostgreSQL: queries `pg_index` + `pg_class`
336
+ *
337
+ * The result set must include a column named `IndexName`.
338
+ */
339
+ abstract getPrimaryKeyIndexNameSQL(schema: string, tableName: string): string;
340
+ /**
341
+ * Returns a SQL query string to check if a given column is part of a composite unique constraint.
342
+ * The query should accept the schema, table, and column name as parameters (platform-specific).
343
+ *
344
+ * The orchestrator checks `result.recordset.length > 0` to determine if the column
345
+ * participates in a multi-column unique index.
346
+ *
347
+ * Note: Implementations should return the SQL query string. The orchestrator is responsible
348
+ * for executing the query with proper parameterization for the target database platform.
349
+ */
350
+ abstract getCompositeUniqueConstraintCheckSQL(schema: string, tableName: string, columnName: string): string;
351
+ /**
352
+ * Returns a SQL query string to check if a foreign key index already exists.
353
+ * Used by the orchestrator to conditionally create FK indexes.
354
+ * SQL Server: queries `sys.indexes` with OBJECT_ID
355
+ * PostgreSQL: queries `pg_indexes`
356
+ *
357
+ * The result set should return rows if the index exists (length > 0 means exists).
358
+ */
359
+ abstract getForeignKeyIndexExistsSQL(schema: string, tableName: string, indexName: string): string;
360
+ /**
361
+ * Returns the batch separator for the database platform.
362
+ * SQL Server: 'GO'
363
+ * PostgreSQL: '' (empty string, uses semicolons)
364
+ */
365
+ get BatchSeparator(): string;
366
+ /**
367
+ * Generates SQL to invoke a stored procedure or function.
368
+ * SQL Server: `EXEC [schema].[spName] @Param1='val1', @Param2='val2'`
369
+ * PostgreSQL: `SELECT * FROM schema."spName"('val1', 'val2')`
370
+ *
371
+ * @param schema The schema containing the routine.
372
+ * @param routineName The routine name (e.g., `spUpdateExistingEntitiesFromSchema`).
373
+ * @param params Ordered array of parameter values as pre-formatted SQL strings.
374
+ * For SQL Server these become `@ParamName='value'` pairs;
375
+ * for PostgreSQL they become positional arguments.
376
+ * @param paramNames Optional parameter names for SQL Server's `@Name=value` syntax.
377
+ * Ignored on PostgreSQL.
378
+ */
379
+ abstract callRoutineSQL(schema: string, routineName: string, params: string[], paramNames?: string[]): string;
380
+ /**
381
+ * Generates a conditional INSERT statement (insert only if not exists).
382
+ * SQL Server: `IF NOT EXISTS (checkQuery) BEGIN insertSQL END`
383
+ * PostgreSQL: `DO $$ BEGIN IF NOT EXISTS (checkQuery) THEN insertSQL; END IF; END $$`
384
+ *
385
+ * @param checkQuery The SELECT query to check for existence.
386
+ * @param insertSQL The INSERT statement to execute if the check returns no rows.
387
+ */
388
+ abstract conditionalInsertSQL(checkQuery: string, insertSQL: string): string;
389
+ /**
390
+ * Wraps an INSERT statement with a conditional existence check at the statement level.
391
+ * SQL Server: Adds `IF NOT EXISTS (...) BEGIN` prefix and `END` suffix.
392
+ * PostgreSQL: Adds `ON CONFLICT DO NOTHING` suffix (no prefix needed).
393
+ *
394
+ * @param conflictCheckSQL The SQL Server existence check query. Ignored on PostgreSQL.
395
+ * @returns An object with `prefix` and `suffix` strings to wrap around the INSERT.
396
+ */
397
+ abstract wrapInsertWithConflictGuard(conflictCheckSQL: string): {
398
+ prefix: string;
399
+ suffix: string;
400
+ };
401
+ /**
402
+ * Generates ALTER TABLE ... ADD COLUMN SQL.
403
+ * SQL Server: `ALTER TABLE [schema].[table] ADD colName TYPE [NOT] NULL [DEFAULT expr]`
404
+ * PostgreSQL: `ALTER TABLE schema."table" ADD COLUMN "colName" TYPE [NOT] NULL [DEFAULT expr]`
405
+ */
406
+ abstract addColumnSQL(schema: string, tableName: string, columnName: string, dataType: string, nullable: boolean, defaultExpression?: string): string;
407
+ /**
408
+ * Generates ALTER TABLE ... ALTER COLUMN to change type and nullability.
409
+ * SQL Server: `ALTER TABLE ... ALTER COLUMN col TYPE NULL|NOT NULL`
410
+ * PostgreSQL: `ALTER TABLE ... ALTER COLUMN "col" TYPE type, ALTER COLUMN "col" SET|DROP NOT NULL`
411
+ */
412
+ abstract alterColumnTypeAndNullabilitySQL(schema: string, tableName: string, columnName: string, dataType: string, nullable: boolean): string;
413
+ /**
414
+ * Generates SQL to add a default constraint/value to a column.
415
+ * SQL Server: `ALTER TABLE ... ADD CONSTRAINT DF_name DEFAULT expr FOR [col]`
416
+ * PostgreSQL: `ALTER TABLE ... ALTER COLUMN "col" SET DEFAULT expr`
417
+ */
418
+ abstract addDefaultConstraintSQL(schema: string, tableName: string, columnName: string, defaultExpression: string): string;
419
+ /**
420
+ * Generates SQL to drop an existing default constraint from a column.
421
+ * SQL Server: Dynamic lookup of constraint name from sys catalog + DROP.
422
+ * PostgreSQL: Dynamic lookup from pg_catalog + ALTER COLUMN DROP DEFAULT.
423
+ */
424
+ abstract dropDefaultConstraintSQL(schema: string, tableName: string, columnName: string): string;
425
+ /**
426
+ * Generates a DROP statement for a database object (view/procedure/function).
427
+ * SQL Server: `IF OBJECT_ID('...', 'P') IS NOT NULL DROP PROCEDURE ...`
428
+ * PostgreSQL: `DROP FUNCTION IF EXISTS ... CASCADE`
429
+ *
430
+ * Note: This differs from `generateDropGuard()` which is used for CREATE OR REPLACE
431
+ * patterns. This method is used for cleanup operations.
432
+ */
433
+ abstract dropObjectSQL(objectType: 'VIEW' | 'PROCEDURE' | 'FUNCTION', schema: string, name: string): string;
434
+ /**
435
+ * Returns SQL to check if a view exists.
436
+ * The query uses `@ViewName` and `@SchemaName` as named parameters.
437
+ * Returns 1 row if the view exists.
438
+ */
439
+ abstract getViewExistsSQL(): string;
440
+ /**
441
+ * Returns SQL to get column metadata for a view or table.
442
+ * Result columns: FieldName, Type, Length, Precision, Scale, AllowsNull.
443
+ */
444
+ abstract getViewColumnsSQL(schema: string, viewName: string): string;
445
+ /**
446
+ * Returns the native timestamp-with-timezone type name for this platform.
447
+ * SQL Server: `DATETIMEOFFSET`
448
+ * PostgreSQL: `TIMESTAMPTZ`
449
+ */
450
+ abstract get TimestampType(): string;
451
+ /**
452
+ * Compares two data type names, accounting for platform-specific aliases.
453
+ * For example, PostgreSQL reports `timestamp with time zone` in information_schema
454
+ * but DDL uses `timestamptz`.
455
+ *
456
+ * @param reported The type name as reported by the database catalog.
457
+ * @param expected The expected type name (from DDL or configuration).
458
+ * @returns True if the types are equivalent.
459
+ */
460
+ abstract compareDataTypes(reported: string, expected: string): boolean;
461
+ /**
462
+ * Returns an array of system schema names that should be excluded from
463
+ * metadata synchronization. Empty array if the platform has no system
464
+ * schemas that need excluding.
465
+ * SQL Server: `[]` (no system schemas need excluding)
466
+ * PostgreSQL: `['information_schema', 'pg_catalog', 'pg_toast', ...]`
467
+ */
468
+ abstract getSystemSchemasToExclude(): string[];
469
+ /**
470
+ * Whether this platform needs explicit view refresh after schema changes.
471
+ * SQL Server: `true` (uses `sp_refreshview`)
472
+ * PostgreSQL: `false` (views resolve at query time)
473
+ */
474
+ abstract get NeedsViewRefresh(): boolean;
475
+ /**
476
+ * Generates SQL to refresh/recompile a view.
477
+ * SQL Server: `EXEC sp_refreshview 'schema.viewName';`
478
+ * PostgreSQL: returns empty string (no-op).
479
+ */
480
+ abstract generateViewRefreshSQL(schema: string, viewName: string): string;
481
+ /**
482
+ * Generates a simple test query to validate a view is functional.
483
+ * SQL Server: `SELECT TOP 1 * FROM [schema].[viewName]`
484
+ * PostgreSQL: `SELECT * FROM "schema"."viewName" LIMIT 1`
485
+ */
486
+ abstract generateViewTestQuerySQL(schema: string, viewName: string): string;
487
+ /**
488
+ * Whether this platform needs a post-sync fix for virtual field nullability.
489
+ * SQL Server: `false`
490
+ * PostgreSQL: `true` (PG view columns always report attnotnull=false)
491
+ */
492
+ abstract get NeedsVirtualFieldNullabilityFix(): boolean;
493
+ /**
494
+ * Quotes mixed-case identifiers in a raw SQL string for execution.
495
+ * SQL Server: returns the SQL unchanged (case-insensitive identifiers).
496
+ * PostgreSQL: double-quotes PascalCase identifiers to preserve case.
497
+ */
498
+ abstract quoteSQLForExecution(sql: string): string;
499
+ /**
500
+ * Parses a raw default-value string from the database catalog into a clean value.
501
+ * SQL Server: strips wrapping parens and N'' prefix, e.g. `(getdate())` → `getdate()`
502
+ * PostgreSQL: strips `::type` casts, recognizes `nextval()` as auto-increment (returns null).
503
+ *
504
+ * @returns The cleaned default value, or `null` if the column has no meaningful default.
505
+ */
506
+ abstract parseColumnDefaultValue(sqlDefaultValue: string): string | null;
507
+ /**
508
+ * Generates the SQL to retrieve pending entity fields that exist in the database
509
+ * but not yet in the MJ metadata. This is a large, platform-specific query.
510
+ *
511
+ * @param mjCoreSchema The MJ core schema name (e.g., `__mj`).
512
+ */
513
+ abstract getPendingEntityFieldsSQL(mjCoreSchema: string): string;
514
+ /**
515
+ * Returns an additional WHERE clause fragment for the check-constraints query.
516
+ * SQL Server: ` WHERE SchemaName NOT IN (...)` when excludeSchemas is provided.
517
+ * PostgreSQL: empty string (the PG view already handles schema filtering).
518
+ */
519
+ abstract getCheckConstraintsSchemaFilter(excludeSchemas: string[]): string;
520
+ /**
521
+ * Returns an additional WHERE clause fragment for the missing-base-tables query.
522
+ * SQL Server: ` WHERE VirtualEntity=0`
523
+ * PostgreSQL: empty string (PG query doesn't need this filter).
524
+ */
525
+ abstract getEntitiesWithMissingBaseTablesFilter(): string;
526
+ /**
527
+ * Generates SQL to fix virtual field nullability after metadata sync.
528
+ * PostgreSQL: Updates AllowsNull for virtual fields based on the FK column's nullability.
529
+ * SQL Server: returns empty string (no fix needed).
530
+ *
531
+ * @param mjCoreSchema The MJ core schema name.
532
+ */
533
+ abstract getFixVirtualFieldNullabilitySQL(mjCoreSchema: string): string;
534
+ /**
535
+ * Executes a SQL file using the platform's native CLI tool (sqlcmd/psql).
536
+ * The implementation is responsible for reading connection configuration
537
+ * from the environment or config objects.
538
+ *
539
+ * @param filePath Path to the SQL file to execute.
540
+ * @returns True if execution succeeded, false otherwise.
541
+ */
542
+ abstract executeSQLFileViaShell(filePath: string): Promise<boolean>;
543
+ }
544
+ //# sourceMappingURL=codeGenDatabaseProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeGenDatabaseProvider.d.ts","sourceRoot":"","sources":["../../src/Database/codeGenDatabaseProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAwB,MAAM,sBAAsB,CAAC;AACzF,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AAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAEhE;;;;OAIG;IACH,QAAQ,CAAC,+BAA+B,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM;IAE1E;;;;OAIG;IACH,QAAQ,CAAC,sCAAsC,IAAI,MAAM;IAEzD;;;;;;OAMG;IACH,QAAQ,CAAC,gCAAgC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAIvE;;;;;;;OAOG;IACH,QAAQ,CAAC,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CACtE"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Union type for stored procedure / function types (Create, Update, Delete).
3
+ */
4
+ export const CRUDType = {
5
+ Create: 'Create',
6
+ Update: 'Update',
7
+ Delete: 'Delete',
8
+ };
9
+ /**
10
+ * Abstract base class for database-specific code generation providers.
11
+ *
12
+ * Each database platform (SQL Server, PostgreSQL, etc.) implements this class
13
+ * to generate the appropriate DDL for views, CRUD routines, triggers, indexes,
14
+ * full-text search, permissions, and other database objects.
15
+ *
16
+ * The orchestrator (SQLCodeGenBase) calls these methods to produce platform-specific
17
+ * SQL while keeping the high-level generation logic database-agnostic.
18
+ */
19
+ export class CodeGenDatabaseProvider {
20
+ /**
21
+ * Returns the batch separator for the database platform.
22
+ * SQL Server: 'GO'
23
+ * PostgreSQL: '' (empty string, uses semicolons)
24
+ */
25
+ get BatchSeparator() {
26
+ return this.Dialect.BatchSeparator();
27
+ }
28
+ }
29
+ //# sourceMappingURL=codeGenDatabaseProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeGenDatabaseProvider.js","sourceRoot":"","sources":["../../src/Database/codeGenDatabaseProvider.ts"],"names":[],"mappings":"AAyIA;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACV,CAAC;AA+CX;;;;;;;;;GASG;AACH,MAAM,OAAgB,uBAAuB;IA4OzC;;;;OAIG;IACH,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;IACzC,CAAC;CA2NJ"}