@memberjunction/codegen-lib 6.2.0-edge.5 → 6.2.0-edge.6
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/dist/Config/config.d.ts +126 -0
- package/dist/Config/config.d.ts.map +1 -1
- package/dist/Config/config.js +48 -2
- package/dist/Config/config.js.map +1 -1
- package/dist/Database/codeGenDatabaseProvider.d.ts +87 -4
- package/dist/Database/codeGenDatabaseProvider.d.ts.map +1 -1
- package/dist/Database/codeGenDatabaseProvider.js +133 -1
- package/dist/Database/codeGenDatabaseProvider.js.map +1 -1
- package/dist/Database/manage-metadata.d.ts +121 -6
- package/dist/Database/manage-metadata.d.ts.map +1 -1
- package/dist/Database/manage-metadata.js +338 -58
- package/dist/Database/manage-metadata.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/metadataSupportObjects.js +45 -6
- package/dist/Database/providers/postgresql/metadataSupportObjects.js.map +1 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts +40 -12
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.d.ts.map +1 -1
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.js +127 -53
- package/dist/Database/providers/sqlserver/SQLServerCodeGenProvider.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/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 +138 -4
- package/dist/Database/sql_codegen.d.ts.map +1 -1
- package/dist/Database/sql_codegen.js +585 -44
- package/dist/Database/sql_codegen.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/runCodeGen.d.ts +21 -3
- package/dist/runCodeGen.d.ts.map +1 -1
- package/dist/runCodeGen.js +114 -44
- package/dist/runCodeGen.js.map +1 -1
- package/package.json +29 -29
|
@@ -365,6 +365,10 @@ export declare class PostgreSQLCodeGenProvider extends CodeGenDatabaseProvider {
|
|
|
365
365
|
*/
|
|
366
366
|
generateRootFieldJoin(entity: EntityInfo, field: EntityFieldInfo, alias: string): string;
|
|
367
367
|
/** @inheritdoc */
|
|
368
|
+
GenerateViewPermissionsForTarget(entity: EntityInfo, targetSchemaName: string, targetViewName: string): string;
|
|
369
|
+
/** @inheritdoc */
|
|
370
|
+
GenerateDisabledViewRevokePermissionsForTarget(entity: EntityInfo, targetSchemaName: string, targetViewName: string): string;
|
|
371
|
+
/** @inheritdoc */
|
|
368
372
|
generateViewPermissions(entity: EntityInfo): string;
|
|
369
373
|
/**
|
|
370
374
|
* Generates `GRANT EXECUTE ON FUNCTION` statements for the given CRUD function,
|
|
@@ -498,12 +502,25 @@ export declare class PostgreSQLCodeGenProvider extends CodeGenDatabaseProvider {
|
|
|
498
502
|
* is not installed yet (bootstrap before that migration).
|
|
499
503
|
*/
|
|
500
504
|
generateLayeredOuterRebindSQL(entity: EntityInfo): string;
|
|
505
|
+
/** @inheritdoc */
|
|
506
|
+
GenerateAlternateBaseViewRebindSQL(_entity: EntityInfo, altViewSchema: string, altViewName: string, innerViewName: string): string;
|
|
507
|
+
/** @inheritdoc */
|
|
508
|
+
getViewDependenciesSQL(schema: string, viewName: string): string;
|
|
501
509
|
/**
|
|
502
510
|
* After the inner generated view is current, restar the application-owned
|
|
503
511
|
* outer wrapper so `g.*` re-expands. No-op when the entity is not layered
|
|
504
512
|
* or the outer view does not exist yet (bootstrap pass).
|
|
505
513
|
*/
|
|
506
514
|
private rebindLayeredOuterIfPresent;
|
|
515
|
+
/**
|
|
516
|
+
* Rebinds each registered alternate base view on `entity` in topological
|
|
517
|
+
* `ParentID` order so `SELECT *` / `alias.*` re-expands after the entity's
|
|
518
|
+
* `BaseView` (or parent alternate view) is regenerated. Wrapped per-view in
|
|
519
|
+
* `try/catch` so a single broken alternate view logs a warning without
|
|
520
|
+
* failing the owning entity's view phase.
|
|
521
|
+
*/
|
|
522
|
+
private rebindAlternateBaseViewsIfPresent;
|
|
523
|
+
private rebindOuterViewAgainstInnerIfPresent;
|
|
507
524
|
/** @inheritdoc */
|
|
508
525
|
generateIfViewExistsSQL(schema: string, viewName: string, innerSQL: string): string;
|
|
509
526
|
/** @inheritdoc */
|
|
@@ -567,17 +584,19 @@ export declare class PostgreSQLCodeGenProvider extends CodeGenDatabaseProvider {
|
|
|
567
584
|
*/
|
|
568
585
|
regenerateBaseView(entity: EntityInfo, viewSQL: string, willRegenerate?: Set<string>): Promise<void>;
|
|
569
586
|
/**
|
|
570
|
-
* Phased per-entity execution for PG. Runs view → CRUD functions →
|
|
571
|
-
* permissions against the target DB, guaranteeing
|
|
572
|
-
* phase 1 failed (so we never leave `fn_create_*`
|
|
573
|
-
* a missing or stale view's rowtype).
|
|
587
|
+
* Phased per-entity execution for PG. Runs view → CRUD functions →
|
|
588
|
+
* full-text search → view permissions against the target DB, guaranteeing
|
|
589
|
+
* phase 2 is skipped if phase 1 failed (so we never leave `fn_create_*`
|
|
590
|
+
* functions pointing at a missing or stale view's rowtype).
|
|
574
591
|
*
|
|
575
592
|
* Phase 1 routes through `executeWithFallback` so a 42P16 triggers the
|
|
576
593
|
* capture/drop/recreate/restore flow rather than blowing up. Phase 2 runs
|
|
577
594
|
* each CRUD function's CREATE individually — we do NOT concatenate them
|
|
578
595
|
* because node-pg's simple query protocol would then abort the whole
|
|
579
596
|
* batch on the first failure; running them separately gives a per-routine
|
|
580
|
-
* error signal. Phase 3
|
|
597
|
+
* error signal. Phase 3 installs the full-text objects, whose search
|
|
598
|
+
* function returns the base view's rowtype and so depends on phase 1.
|
|
599
|
+
* Phase 4 applies view-level GRANTs.
|
|
581
600
|
*/
|
|
582
601
|
executeEntityPhased(opts: {
|
|
583
602
|
entity: EntityInfo;
|
|
@@ -586,6 +605,7 @@ export declare class PostgreSQLCodeGenProvider extends CodeGenDatabaseProvider {
|
|
|
586
605
|
crudCreateSQL: string;
|
|
587
606
|
crudUpdateSQL: string;
|
|
588
607
|
crudDeleteSQL: string;
|
|
608
|
+
ftsSQL: string;
|
|
589
609
|
viewPermSQL: string;
|
|
590
610
|
willRegenerate?: Set<string>;
|
|
591
611
|
}): Promise<PhasedExecutionResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSQLCodeGenProvider.d.ts","sourceRoot":"","sources":["../../../../src/Database/providers/postgresql/PostgreSQLCodeGenProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"PostgreSQLCodeGenProvider.d.ts","sourceRoot":"","sources":["../../../../src/Database/providers/postgresql/PostgreSQLCodeGenProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAA+F,MAAM,sBAAsB,CAAC;AAEhK,OAAO,EACH,uBAAuB,EACvB,QAAQ,EACR,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EAC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KG;IACH,oCAAoC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAoBnG;;;OAGG;IACa,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAkBjH,kBAAkB;IAClB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAUzF;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IA8FrC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;OAGG;IACH,OAAO,CAAC,wCAAwC;CA2BnD"}
|
|
@@ -4,9 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { EntityInfo, ResolveStartupMode, SetProvider, StartupManager } from '@memberjunction/core';
|
|
7
|
+
import { EntityInfo, IsValidSQLIdentifier, ResolveStartupMode, SetProvider, StartupManager } from '@memberjunction/core';
|
|
8
8
|
import { EscapeSQLString, RegisterClass, UUIDsEqual } from '@memberjunction/global';
|
|
9
|
-
import { CodeGenDatabaseProvider, CRUDType, ExcludedBaseViewFieldNames, } from '../../codeGenDatabaseProvider.js';
|
|
9
|
+
import { CodeGenDatabaseProvider, CRUDType, ExcludedBaseViewFieldNames, OrderAlternateBaseViewsTopologically, } from '../../codeGenDatabaseProvider.js';
|
|
10
10
|
import { configInfo, MjCoreSchema } from '../../../Config/config.js';
|
|
11
11
|
import { logError, logStatus, LogWarning, StartSpinner, SucceedSpinner } from '../../../Misc/status_logging.js';
|
|
12
12
|
import { BuildMetadataSupportObjectsSQL } from './metadataSupportObjects.js';
|
|
@@ -1488,12 +1488,23 @@ $$ LANGUAGE sql STABLE;
|
|
|
1488
1488
|
}
|
|
1489
1489
|
// ─── PERMISSIONS ─────────────────────────────────────────────────────
|
|
1490
1490
|
/** @inheritdoc */
|
|
1491
|
-
|
|
1492
|
-
const
|
|
1491
|
+
GenerateViewPermissionsForTarget(entity, targetSchemaName, targetViewName) {
|
|
1492
|
+
const roles = this.collectPermissionRoles(entity.Permissions);
|
|
1493
|
+
if (roles.length === 0)
|
|
1494
|
+
return '';
|
|
1495
|
+
return roles.map((role) => `GRANT SELECT ON ${pgDialect.QuoteSchema(targetSchemaName, targetViewName)} TO ${pgDialect.QuoteIdentifier(role)};`).join('\n');
|
|
1496
|
+
}
|
|
1497
|
+
/** @inheritdoc */
|
|
1498
|
+
GenerateDisabledViewRevokePermissionsForTarget(entity, targetSchemaName, targetViewName) {
|
|
1493
1499
|
const roles = this.collectPermissionRoles(entity.Permissions);
|
|
1494
1500
|
if (roles.length === 0)
|
|
1495
1501
|
return '';
|
|
1496
|
-
return roles.map((role) => `
|
|
1502
|
+
return roles.map((role) => `REVOKE SELECT ON ${pgDialect.QuoteSchema(targetSchemaName, targetViewName)} FROM ${pgDialect.QuoteIdentifier(role)};`).join('\n');
|
|
1503
|
+
}
|
|
1504
|
+
/** @inheritdoc */
|
|
1505
|
+
generateViewPermissions(entity) {
|
|
1506
|
+
const viewName = this.getBaseViewName(entity);
|
|
1507
|
+
return this.GenerateViewPermissionsForTarget(entity, entity.SchemaName, viewName);
|
|
1497
1508
|
}
|
|
1498
1509
|
/**
|
|
1499
1510
|
* Generates `GRANT EXECUTE ON FUNCTION` statements for the given CRUD function,
|
|
@@ -1522,7 +1533,27 @@ $$ LANGUAGE sql STABLE;
|
|
|
1522
1533
|
const roles = this.collectPermissionRoles(entity.Permissions);
|
|
1523
1534
|
if (roles.length === 0)
|
|
1524
1535
|
return '';
|
|
1525
|
-
|
|
1536
|
+
// Each GRANT is guarded by an existence check rather than issued bare.
|
|
1537
|
+
// The permissions file is replayed for EVERY full-text-enabled entity,
|
|
1538
|
+
// including entities whose DDL phase did not run in this pass, and the
|
|
1539
|
+
// 42P16 view-recovery fallback's `DROP ... CASCADE` can take the search
|
|
1540
|
+
// function with it. A GRANT on a function that is not there raises 42883,
|
|
1541
|
+
// which aborts the ENTIRE CodeGen run — an absent function now logs a
|
|
1542
|
+
// NOTICE and the run carries on.
|
|
1543
|
+
const schemaLiteral = entity.SchemaName.replace(/'/g, "''");
|
|
1544
|
+
const functionLiteral = functionName.replace(/'/g, "''");
|
|
1545
|
+
return roles.map((role) => `DO $mjfts$
|
|
1546
|
+
BEGIN
|
|
1547
|
+
IF EXISTS (
|
|
1548
|
+
SELECT 1 FROM pg_proc p
|
|
1549
|
+
JOIN pg_namespace n ON n.oid = p.pronamespace
|
|
1550
|
+
WHERE n.nspname = '${schemaLiteral}' AND p.proname = '${functionLiteral}'
|
|
1551
|
+
) THEN
|
|
1552
|
+
GRANT EXECUTE ON FUNCTION ${pgDialect.QuoteSchema(entity.SchemaName, functionName)} TO ${pgDialect.QuoteIdentifier(role)};
|
|
1553
|
+
ELSE
|
|
1554
|
+
RAISE NOTICE 'Skipping GRANT on missing full-text search function %.%', '${schemaLiteral}', '${functionLiteral}';
|
|
1555
|
+
END IF;
|
|
1556
|
+
END $mjfts$;`).join('\n');
|
|
1526
1557
|
}
|
|
1527
1558
|
// ─── CASCADE DELETES ─────────────────────────────────────────────────
|
|
1528
1559
|
/** @inheritdoc */
|
|
@@ -1930,6 +1961,10 @@ ORDER BY ordinal_position`;
|
|
|
1930
1961
|
if (!entity.HasLayeredBaseView) {
|
|
1931
1962
|
return '';
|
|
1932
1963
|
}
|
|
1964
|
+
return this.GenerateAlternateBaseViewRebindSQL(entity, entity.SchemaName, entity.BaseView, entity.GeneratedViewName);
|
|
1965
|
+
}
|
|
1966
|
+
/** @inheritdoc */
|
|
1967
|
+
GenerateAlternateBaseViewRebindSQL(_entity, altViewSchema, altViewName, innerViewName) {
|
|
1933
1968
|
let core = '__mj';
|
|
1934
1969
|
try {
|
|
1935
1970
|
core = (MjCoreSchema() || '__mj').replace(/"/g, '""');
|
|
@@ -1937,11 +1972,30 @@ ORDER BY ordinal_position`;
|
|
|
1937
1972
|
catch {
|
|
1938
1973
|
core = '__mj';
|
|
1939
1974
|
}
|
|
1940
|
-
const schema =
|
|
1941
|
-
const outer =
|
|
1942
|
-
const inner =
|
|
1975
|
+
const schema = altViewSchema.replace(/'/g, "''");
|
|
1976
|
+
const outer = altViewName.replace(/'/g, "''");
|
|
1977
|
+
const inner = innerViewName.replace(/'/g, "''");
|
|
1943
1978
|
return `SELECT "${core}"."spRebindLayeredOuterView"('${schema}', '${outer}', '${inner}');`;
|
|
1944
1979
|
}
|
|
1980
|
+
/** @inheritdoc */
|
|
1981
|
+
getViewDependenciesSQL(schema, viewName) {
|
|
1982
|
+
const escapedSchema = EscapeSQLString(schema);
|
|
1983
|
+
const escapedView = EscapeSQLString(viewName);
|
|
1984
|
+
return `SELECT DISTINCT
|
|
1985
|
+
ns.nspname AS "ReferencedSchema",
|
|
1986
|
+
cl.relname AS "ReferencedObject",
|
|
1987
|
+
cl.relkind AS "ReferencedType"
|
|
1988
|
+
FROM pg_depend d
|
|
1989
|
+
JOIN pg_rewrite r ON r.oid = d.objid
|
|
1990
|
+
JOIN pg_class v ON v.oid = r.ev_class
|
|
1991
|
+
JOIN pg_namespace vns ON vns.oid = v.relnamespace
|
|
1992
|
+
JOIN pg_class cl ON cl.oid = d.refobjid
|
|
1993
|
+
JOIN pg_namespace ns ON ns.oid = cl.relnamespace
|
|
1994
|
+
WHERE vns.nspname = '${escapedSchema}'
|
|
1995
|
+
AND v.relname = '${escapedView}'
|
|
1996
|
+
AND cl.oid <> v.oid
|
|
1997
|
+
AND cl.relkind IN ('r', 'v', 'm', 'f', 'p')`;
|
|
1998
|
+
}
|
|
1945
1999
|
/**
|
|
1946
2000
|
* After the inner generated view is current, restar the application-owned
|
|
1947
2001
|
* outer wrapper so `g.*` re-expands. No-op when the entity is not layered
|
|
@@ -1951,23 +2005,56 @@ ORDER BY ordinal_position`;
|
|
|
1951
2005
|
if (!entity.HasLayeredBaseView) {
|
|
1952
2006
|
return;
|
|
1953
2007
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
2008
|
+
await this.rebindOuterViewAgainstInnerIfPresent(client, entity.SchemaName, entity.BaseView, entity.SchemaName, entity.GeneratedViewName, willRegenerate);
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Rebinds each registered alternate base view on `entity` in topological
|
|
2012
|
+
* `ParentID` order so `SELECT *` / `alias.*` re-expands after the entity's
|
|
2013
|
+
* `BaseView` (or parent alternate view) is regenerated. Wrapped per-view in
|
|
2014
|
+
* `try/catch` so a single broken alternate view logs a warning without
|
|
2015
|
+
* failing the owning entity's view phase.
|
|
2016
|
+
*/
|
|
2017
|
+
async rebindAlternateBaseViewsIfPresent(client, entity, willRegenerate) {
|
|
2018
|
+
const orderedAltViews = OrderAlternateBaseViewsTopologically(entity.AlternateBaseViews ?? []);
|
|
2019
|
+
if (orderedAltViews.length === 0) {
|
|
2020
|
+
return;
|
|
2021
|
+
}
|
|
2022
|
+
const defaultInnerName = this.getBaseViewName(entity);
|
|
2023
|
+
for (const altView of orderedAltViews) {
|
|
2024
|
+
if (!IsValidSQLIdentifier(altView.EffectiveSchemaName) || !IsValidSQLIdentifier(altView.ViewName)) {
|
|
2025
|
+
logError(`[AlternateBaseView] Skipping rebind for alternate view '${altView.Name}' on '${entity.Name}': invalid SQL identifier '${altView.EffectiveSchemaName}.${altView.ViewName}'.`);
|
|
2026
|
+
continue;
|
|
2027
|
+
}
|
|
2028
|
+
const parentView = altView.ParentView;
|
|
2029
|
+
const innerSchema = parentView ? parentView.EffectiveSchemaName : entity.SchemaName;
|
|
2030
|
+
const innerName = parentView ? parentView.ViewName : defaultInnerName;
|
|
2031
|
+
try {
|
|
2032
|
+
await this.rebindOuterViewAgainstInnerIfPresent(client, altView.EffectiveSchemaName, altView.ViewName, innerSchema, innerName, willRegenerate);
|
|
2033
|
+
}
|
|
2034
|
+
catch (e) {
|
|
2035
|
+
LogWarning(` ⚠️ [AlternateBaseView] Failed to rebind alternate view '${altView.Name}' (${altView.EffectiveSchemaName}.${altView.ViewName}) on '${entity.Name}': ${e instanceof Error ? e.message : String(e)}`);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
async rebindOuterViewAgainstInnerIfPresent(client, outerSchema, outerViewName, innerSchema, innerViewName, willRegenerate) {
|
|
2040
|
+
const outerSchemaLit = outerSchema.replace(/'/g, "''").replace(/"/g, '""');
|
|
2041
|
+
const outerLit = outerViewName.replace(/'/g, "''").replace(/"/g, '""');
|
|
2042
|
+
const innerSchemaLit = innerSchema.replace(/'/g, "''").replace(/"/g, '""');
|
|
2043
|
+
const innerLit = innerViewName.replace(/'/g, "''").replace(/"/g, '""');
|
|
2044
|
+
const existsResult = await client.query(`SELECT to_regclass('"${outerSchemaLit}"."${outerLit}"') IS NOT NULL AS present`);
|
|
1958
2045
|
if (!existsResult.rows?.[0]?.['present']) {
|
|
1959
2046
|
return;
|
|
1960
2047
|
}
|
|
1961
|
-
const defResult = await client.query(this.getViewDefinitionSQL(
|
|
2048
|
+
const defResult = await client.query(this.getViewDefinitionSQL(outerSchema, outerViewName));
|
|
1962
2049
|
const viewDefinition = String(defResult.rows?.[0]?.['ViewDefinition'] ?? defResult.rows?.[0]?.['viewdefinition'] ?? '');
|
|
1963
2050
|
if (!viewDefinition) {
|
|
1964
|
-
throw new LayeredOuterRestarError(`Could not read pg_get_viewdef for layered outer view ${
|
|
2051
|
+
throw new LayeredOuterRestarError(`Could not read pg_get_viewdef for layered outer view ${outerSchema}.${outerViewName}`);
|
|
1965
2052
|
}
|
|
1966
2053
|
const colResult = await client.query(`SELECT a.attname AS "Name"
|
|
1967
2054
|
FROM pg_attribute a
|
|
1968
2055
|
JOIN pg_class c ON c.oid = a.attrelid
|
|
1969
2056
|
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
1970
|
-
WHERE n.nspname = '${
|
|
2057
|
+
WHERE n.nspname = '${innerSchemaLit}'
|
|
1971
2058
|
AND c.relname = '${innerLit}'
|
|
1972
2059
|
AND a.attnum > 0
|
|
1973
2060
|
AND NOT a.attisdropped
|
|
@@ -1975,14 +2062,14 @@ ORDER BY ordinal_position`;
|
|
|
1975
2062
|
const innerColumns = (colResult.rows ?? []).map((r) => String(r['Name'] ?? r['name'] ?? ''));
|
|
1976
2063
|
const restarred = restarLayeredOuterView({
|
|
1977
2064
|
viewDefinition,
|
|
1978
|
-
innerViewName
|
|
2065
|
+
innerViewName,
|
|
1979
2066
|
innerColumns,
|
|
1980
2067
|
});
|
|
1981
|
-
const createSQL = buildCreateOrReplaceLayeredOuterViewSQL(
|
|
2068
|
+
const createSQL = buildCreateOrReplaceLayeredOuterViewSQL(outerSchema, outerViewName, restarred);
|
|
1982
2069
|
await ExecuteWithFallback({
|
|
1983
2070
|
Client: client,
|
|
1984
|
-
schema:
|
|
1985
|
-
ViewName:
|
|
2071
|
+
schema: outerSchema,
|
|
2072
|
+
ViewName: outerViewName,
|
|
1986
2073
|
CreateOrReplaceSQL: createSQL,
|
|
1987
2074
|
WillRegenerate: willRegenerate,
|
|
1988
2075
|
});
|
|
@@ -2215,23 +2302,26 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2215
2302
|
BaseTableQualified: pgDialect.QuoteSchema(entity.SchemaName, entity.BaseTable),
|
|
2216
2303
|
});
|
|
2217
2304
|
await this.rebindLayeredOuterIfPresent(client, entity, willRegenerate);
|
|
2305
|
+
await this.rebindAlternateBaseViewsIfPresent(client, entity, willRegenerate);
|
|
2218
2306
|
}
|
|
2219
2307
|
finally {
|
|
2220
2308
|
client.release();
|
|
2221
2309
|
}
|
|
2222
2310
|
}
|
|
2223
2311
|
/**
|
|
2224
|
-
* Phased per-entity execution for PG. Runs view → CRUD functions →
|
|
2225
|
-
* permissions against the target DB, guaranteeing
|
|
2226
|
-
* phase 1 failed (so we never leave `fn_create_*`
|
|
2227
|
-
* a missing or stale view's rowtype).
|
|
2312
|
+
* Phased per-entity execution for PG. Runs view → CRUD functions →
|
|
2313
|
+
* full-text search → view permissions against the target DB, guaranteeing
|
|
2314
|
+
* phase 2 is skipped if phase 1 failed (so we never leave `fn_create_*`
|
|
2315
|
+
* functions pointing at a missing or stale view's rowtype).
|
|
2228
2316
|
*
|
|
2229
2317
|
* Phase 1 routes through `executeWithFallback` so a 42P16 triggers the
|
|
2230
2318
|
* capture/drop/recreate/restore flow rather than blowing up. Phase 2 runs
|
|
2231
2319
|
* each CRUD function's CREATE individually — we do NOT concatenate them
|
|
2232
2320
|
* because node-pg's simple query protocol would then abort the whole
|
|
2233
2321
|
* batch on the first failure; running them separately gives a per-routine
|
|
2234
|
-
* error signal. Phase 3
|
|
2322
|
+
* error signal. Phase 3 installs the full-text objects, whose search
|
|
2323
|
+
* function returns the base view's rowtype and so depends on phase 1.
|
|
2324
|
+
* Phase 4 applies view-level GRANTs.
|
|
2235
2325
|
*/
|
|
2236
2326
|
async executeEntityPhased(opts) {
|
|
2237
2327
|
// [Large Schema Series] pooled client (was `new pg.Client()` per entity —
|
|
@@ -2267,6 +2357,7 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2267
2357
|
BaseTableQualified: pgDialect.QuoteSchema(opts.entity.SchemaName, opts.entity.BaseTable),
|
|
2268
2358
|
});
|
|
2269
2359
|
await this.rebindLayeredOuterIfPresent(client, opts.entity, opts.willRegenerate);
|
|
2360
|
+
await this.rebindAlternateBaseViewsIfPresent(client, opts.entity, opts.willRegenerate);
|
|
2270
2361
|
}
|
|
2271
2362
|
catch (e) {
|
|
2272
2363
|
return {
|
|
@@ -2293,7 +2384,25 @@ WHERE p.prokind IN ('f', 'p')
|
|
|
2293
2384
|
};
|
|
2294
2385
|
}
|
|
2295
2386
|
}
|
|
2296
|
-
// ── Phase 3:
|
|
2387
|
+
// ── Phase 3: full-text search DDL ────────────────────────────
|
|
2388
|
+
// The search function is declared `RETURNS SETOF <baseview>`, so it
|
|
2389
|
+
// can only be created once phase 1 has put the view in place — and it
|
|
2390
|
+
// must be created before the permissions replay, which GRANTs EXECUTE
|
|
2391
|
+
// on it. Before this phase existed the generated full-text SQL was
|
|
2392
|
+
// written to a file and never executed on PostgreSQL at all.
|
|
2393
|
+
if (opts.ftsSQL && opts.ftsSQL.trim()) {
|
|
2394
|
+
try {
|
|
2395
|
+
await client.query(opts.ftsSQL);
|
|
2396
|
+
}
|
|
2397
|
+
catch (e) {
|
|
2398
|
+
return {
|
|
2399
|
+
success: false,
|
|
2400
|
+
phase: 'fulltext',
|
|
2401
|
+
error: e instanceof Error ? e : new Error(String(e)),
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
// ── Phase 4: view permissions ────────────────────────────────
|
|
2297
2406
|
if (opts.viewPermSQL && opts.viewPermSQL.trim()) {
|
|
2298
2407
|
try {
|
|
2299
2408
|
await client.query(opts.viewPermSQL);
|