@lobu/runtime-server 21.1.0 → 21.2.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.
- package/dist/catalogs/connectors.json +2 -35
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +6 -3
- package/dist/connectors/github.ts +0 -6
- package/dist/connectors/google_calendar.ts +0 -4
- package/dist/connectors/google_drive.ts +0 -2
- package/dist/connectors/google_gmail.ts +0 -6
- package/dist/connectors/market_quotes.ts +0 -1
- package/dist/connectors/microsoft_outlook.ts +0 -2
- package/dist/connectors/postgres.ts +68 -3
- package/dist/connectors/whatsapp_web.ts +2 -8
- package/dist/connectors/x.ts +3 -9
- package/dist/connectors/youtube.ts +0 -5
- package/dist/db/migrations/20260930010000_connector_policy_scopes.sql +113 -0
- package/dist/db/migrations/20261002230000_connector_exact_policy_target.sql +36 -0
- package/dist/db/migrations/20261003120000_source_backed_entity_identity.sql +109 -0
- package/dist/db/migrations/20261003200000_drop_source_backed_entity_identity.sql +111 -0
- package/dist/db/migrations/preconditions/20261002230000_connector_exact_policy_target.sql +38 -0
- package/dist/db/migrations/preconditions/20261003200000_drop_source_backed_entity_identity.sql +21 -0
- package/dist/dependencies.bun.lock +52 -54
- package/dist/owletto/dist/assets/_-C1iPVDAS.js +2 -0
- package/dist/owletto/dist/assets/_-TlzPuBqI.js +1 -0
- package/dist/owletto/dist/assets/_agentId-DutmYPK7.js +1 -0
- package/dist/owletto/dist/assets/_agentId-DvhFYLLv.js +1 -0
- package/dist/owletto/dist/assets/_automationId-NuFSEFlw.js +1 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-D_FhMGN1.js +1 -0
- package/dist/owletto/dist/assets/_connectorKey.index-B8AZikVg.js +1 -0
- package/dist/owletto/dist/assets/{_conversationId-CpuEvflw.js → _conversationId-D1Cx42I0.js} +1 -1
- package/dist/owletto/dist/assets/{_deploymentId-BL9tnDFl.js → _deploymentId-BjtZC8Oo.js} +1 -1
- package/dist/owletto/dist/assets/_name-DTlirHDv.js +1 -0
- package/dist/owletto/dist/assets/_owner-c8L8M4FP.js +1 -0
- package/dist/owletto/dist/assets/_shape-DQaUs_O7.js +1 -0
- package/dist/owletto/dist/assets/_skillKey-CJSEeyG0.js +1 -0
- package/dist/owletto/dist/assets/_slug-Nlm2ziLr.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-BK9NZs21.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-D-Og614G.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-DIFCFECi.js +1 -0
- package/dist/owletto/dist/assets/accept-invitation-BfqbITxp.js +1 -0
- package/dist/owletto/dist/assets/activity-route-view-CTQEg3Us.js +1 -0
- package/dist/owletto/dist/assets/{agent-card-controls-bhTMPoVi.js → agent-card-controls-49SIdmyU.js} +1 -1
- package/dist/owletto/dist/assets/{agent-client-setup-list-BBbq_2B1.js → agent-client-setup-list-ChwHMq4Q.js} +1 -1
- package/dist/owletto/dist/assets/agent-connect-pages-CJntJskO.js +1 -0
- package/dist/owletto/dist/assets/agent-editor-form-CEEFNek5.js +1 -0
- package/dist/owletto/dist/assets/agent-guardrails-route-BF_RvzHv.js +1 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-BQLjzMPy.js → agent-loading-shells-Cve_XIMW.js} +1 -1
- package/dist/owletto/dist/assets/agent-permissions-matrix-DEYa123T.js +1 -0
- package/dist/owletto/dist/assets/{agent-skill-context-s42Q4Wjo.js → agent-skill-context-DuS7Ojm_.js} +1 -1
- package/dist/owletto/dist/assets/agent-skills-route-BItudd8s.js +1 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-BkGzpmv5.js +1 -0
- package/dist/owletto/dist/assets/agent-thread-DhCFggHZ.js +8 -0
- package/dist/owletto/dist/assets/agents-BIA5SCAT.js +1 -0
- package/dist/owletto/dist/assets/agents-workbench-BZaoiFNY.js +1 -0
- package/dist/owletto/dist/assets/{app._appId-CqYz3AOO.js → app._appId-0fp8NC9-.js} +1 -1
- package/dist/owletto/dist/assets/automation-detail-content-C08Ef137.js +1 -0
- package/dist/owletto/dist/assets/automations-BIA5SCAT.js +1 -0
- package/dist/owletto/dist/assets/{calendar-CHXehtu0.js → calendar-CvEqJnKS.js} +1 -1
- package/dist/owletto/dist/assets/callback-BfjlxUcL.js +1 -0
- package/dist/owletto/dist/assets/{card-4Ull9W6d.js → card-MXMmjz9G.js} +1 -1
- package/dist/owletto/dist/assets/{claim-BGLCPLXq.js → claim-B5igXpyF.js} +1 -1
- package/dist/owletto/dist/assets/{clients-C7ubnFsS.js → clients-DqMOcwpO.js} +1 -1
- package/dist/owletto/dist/assets/{code-editor-BHiWR94J.js → code-editor-bpbaa7f6.js} +1 -1
- package/dist/owletto/dist/assets/connect-DpQrbviv.js +1 -0
- package/dist/owletto/dist/assets/connect._clientId-A_F-UzTr.js +1 -0
- package/dist/owletto/dist/assets/connected._clientId-BWVr-PMm.js +1 -0
- package/dist/owletto/dist/assets/connection-D-dXA43c.js +1 -0
- package/dist/owletto/dist/assets/connection-feed-detail-XYK-ubKG.js +1 -0
- package/dist/owletto/dist/assets/{connector-provenance-DRdUEmQ1.js → connector-provenance-RL_DcF2q.js} +1 -1
- package/dist/owletto/dist/assets/connectors-B2_PLuXP.js +1 -0
- package/dist/owletto/dist/assets/{consent-fmhPPlpi.js → consent-CMrkyIfi.js} +1 -1
- package/dist/owletto/dist/assets/{core.esm-C-eNiUAl.js → core.esm-BrIR85HL.js} +1 -1
- package/dist/owletto/dist/assets/create-DhxcVjNh.js +1 -0
- package/dist/owletto/dist/assets/create-UTXCruIl.js +1 -0
- package/dist/owletto/dist/assets/create-automation-form-BHir-pIp.js +2 -0
- package/dist/owletto/dist/assets/create-jVkf6V76.js +1 -0
- package/dist/owletto/dist/assets/{create._connectorKey-CHAotlsF.js → create._connectorKey-qjd3B6p5.js} +1 -1
- package/dist/owletto/dist/assets/{cronstrue-C5yTgk5z.js → cronstrue-BwvvZn_Y.js} +1 -1
- package/dist/owletto/dist/assets/deployments-CSJHFlJz.js +1 -0
- package/dist/owletto/dist/assets/{deployments-D1gbQwsy.js → deployments-DHAx8TBs.js} +1 -1
- package/dist/owletto/dist/assets/{deployments-body-DycIGlnL.js → deployments-body-B54mJoZC.js} +1 -1
- package/dist/owletto/dist/assets/{device-DyPnQkhO.js → device-Bi_9KNKQ.js} +1 -1
- package/dist/owletto/dist/assets/device-pin-tombstone-Dkmmka9d.js +1 -0
- package/dist/owletto/dist/assets/device-rows-CkTAaZ3m.js +1 -0
- package/dist/owletto/dist/assets/device._deviceId-B_WqDhY5.js +1 -0
- package/dist/owletto/dist/assets/entity-options-Bm1sbpmt.js +1 -0
- package/dist/owletto/dist/assets/entity-page-DZUGex-P.js +1 -0
- package/dist/owletto/dist/assets/entity-type-page-DSBcVv9e.js +1 -0
- package/dist/owletto/dist/assets/event-page-B837JclA.js +1 -0
- package/dist/owletto/dist/assets/events-feed-BgvLTppV.js +1 -0
- package/dist/owletto/dist/assets/{full-page-spinner-DsU-Cb3L.js → full-page-spinner-ByBsHimW.js} +1 -1
- package/dist/owletto/dist/assets/guardrails-cMGe6IIe.js +1 -0
- package/dist/owletto/dist/assets/identity-BORtpi5L.js +1 -0
- package/dist/owletto/dist/assets/index-B5lGxbbZ.js +1 -0
- package/dist/owletto/dist/assets/index-BGz-9DDG.js +1 -0
- package/dist/owletto/dist/assets/{index-DwtfHCHB.js → index-Be5BLMwZ.js} +1 -1
- package/dist/owletto/dist/assets/index-BmAuAhub.css +1 -0
- package/dist/owletto/dist/assets/{index-nOYvNROJ.js → index-BrT0gBIi.js} +1 -1
- package/dist/owletto/dist/assets/index-BrzsfXR-.js +1 -0
- package/dist/owletto/dist/assets/{index-CpWKAAGX.js → index-C1MV7ajb.js} +1 -1
- package/dist/owletto/dist/assets/index-C31QOVZH.js +1 -0
- package/dist/owletto/dist/assets/index-C6USRbY8.js +1 -0
- package/dist/owletto/dist/assets/{index-D2dcENg2.js → index-Cane2GT3.js} +1 -1
- package/dist/owletto/dist/assets/{index-1YrrvVJ4.js → index-DBs2lhwE.js} +8 -8
- package/dist/owletto/dist/assets/index-Dh8ubWqr.js +1 -0
- package/dist/owletto/dist/assets/index-DjYcFuq9.js +1 -0
- package/dist/owletto/dist/assets/index-Dpf0I2N4.js +1 -0
- package/dist/owletto/dist/assets/index-DpgsgDFc.js +1 -0
- package/dist/owletto/dist/assets/index-DqrjJ9LB.js +1 -0
- package/dist/owletto/dist/assets/{index-DtRfQcRH.js → index-GZkujXG1.js} +1595 -1595
- package/dist/owletto/dist/assets/index-pFFCzVi5.js +1 -0
- package/dist/owletto/dist/assets/{json-diff-DYeX-xLk.js → json-diff-D6sv990W.js} +3 -3
- package/dist/owletto/dist/assets/{list-skeleton-s4GPSJ8J.js → list-skeleton-B39wKVT1.js} +1 -1
- package/dist/owletto/dist/assets/login-DxnhCvKx.js +1 -0
- package/dist/owletto/dist/assets/logout-Lvib6Kk7.js +1 -0
- package/dist/owletto/dist/assets/member-scope-gate-CM-GNviT.js +1 -0
- package/dist/owletto/dist/assets/{memory-browse-page-Bibfs2sK.js → memory-browse-page-DKmyI1FJ.js} +1 -1
- package/dist/owletto/dist/assets/{missing-view-CD4DOaG8.js → missing-view-CAFqvZpi.js} +1 -1
- package/dist/owletto/dist/assets/{model-selector-XC5CI2Et.js → model-selector-BoudNhPZ.js} +1 -1
- package/dist/owletto/dist/assets/models-B8BuBmLu.js +1 -0
- package/dist/owletto/dist/assets/new-CKSjnGM9.js +1 -0
- package/dist/owletto/dist/assets/new-Jp_DtYBt.js +1 -0
- package/dist/owletto/dist/assets/new-e3C5Yokb.js +1 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-D6epOq0R.js → oauth-workspace-access-DuPiMSr2.js} +1 -1
- package/dist/owletto/dist/assets/organization-DUPBruFP.js +1 -0
- package/dist/owletto/dist/assets/{permissions-D8uJHINS.js → permissions-DqkX4mTH.js} +1 -1
- package/dist/owletto/dist/assets/{proposal-review-shell-C3K-JXjb.js → proposal-review-shell-C04RG1qM.js} +1 -1
- package/dist/owletto/dist/assets/{recent-CFcWceBl.js → recent-BmxCZQ8j.js} +1 -1
- package/dist/owletto/dist/assets/{renderer-1nRJFMGx.js → renderer-eFSU65zm.js} +1 -1
- package/dist/owletto/dist/assets/{reset-password-9RTWhBEb.js → reset-password-BinCwene.js} +1 -1
- package/dist/owletto/dist/assets/runs-DwThk2CI.js +1 -0
- package/dist/owletto/dist/assets/{runs-panel-B2852xus.js → runs-panel-DfxWCV7K.js} +1 -1
- package/dist/owletto/dist/assets/runs-table-Dh7FL3Va.js +1 -0
- package/dist/owletto/dist/assets/{schema-value-normalization-BspxVEGy.js → schema-value-normalization-CPLeOm7K.js} +1 -1
- package/dist/owletto/dist/assets/settings-CSrpSUqR.js +1 -0
- package/dist/owletto/dist/assets/{settings-9lDASETT.js → settings-DLg89oqz.js} +1 -1
- package/dist/owletto/dist/assets/skills-PQP0fNxc.js +1 -0
- package/dist/owletto/dist/assets/{switch-CxDXvPGE.js → switch-Dcx3_8kM.js} +1 -1
- package/dist/owletto/dist/assets/{use-applied-views-DvMT3wap.js → use-applied-views-BpvIIgWG.js} +1 -1
- package/dist/owletto/dist/assets/{use-mention-search-CeTEE3oE.js → use-mention-search-Vndny_Gd.js} +1 -1
- package/dist/owletto/dist/assets/{view-frame-HoBawpT2.js → view-frame-DxiuLSGA.js} +1 -1
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +4097 -4383
- package/npm-shrinkwrap.json +198 -207
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +1 -1
- package/vendor/connector-sdk/dist/connector-runtime.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +14 -2
- package/vendor/connector-sdk/dist/define-connector.d.ts +3 -5
- package/vendor/connector-sdk/dist/define-connector.js +1 -1
- package/vendor/connector-sdk/dist/device-manifest.d.ts +0 -1
- package/vendor/connector-sdk/dist/extension-network.js +1 -2
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +0 -1
- package/vendor/core/dist/contracts/agent-settings.js +0 -1
- package/vendor/core/dist/contracts/tools/manage-classifiers.d.ts +6 -6
- package/vendor/core/dist/contracts/tools/manage-classifiers.js +4 -6
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +0 -1
- package/vendor/core/dist/contracts/tools/manage-connections.js +3 -4
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity.js +4 -2
- package/vendor/core/dist/logger.js +13 -2
- package/vendor/core/dist/worker/wire.d.ts +1 -6
- package/vendor/core/dist/worker/wire.js +1 -1
- package/vendor/core/package.json +1 -1
- package/vendor/views/package.json +6 -1
- package/dist/owletto/dist/assets/_-00GgOtdu.js +0 -1
- package/dist/owletto/dist/assets/_-XlUwOWCI.js +0 -2
- package/dist/owletto/dist/assets/_agentId-B2DrawIk.js +0 -1
- package/dist/owletto/dist/assets/_agentId-CS0AcWH2.js +0 -1
- package/dist/owletto/dist/assets/_automationId-BLnqLtUv.js +0 -1
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DcUWoZ-C.js +0 -1
- package/dist/owletto/dist/assets/_connectorKey.index-C_yKycN_.js +0 -1
- package/dist/owletto/dist/assets/_name-DlxjWkKk.js +0 -1
- package/dist/owletto/dist/assets/_owner-Cg50UU6m.js +0 -1
- package/dist/owletto/dist/assets/_shape-BWZW4mj8.js +0 -1
- package/dist/owletto/dist/assets/_skillKey-B25fO0_O.js +0 -1
- package/dist/owletto/dist/assets/_slug-DbD-wv2m.js +0 -1
- package/dist/owletto/dist/assets/_viewKey-BcTEvQ3N.js +0 -1
- package/dist/owletto/dist/assets/_viewKey-W4RjiUWL.js +0 -1
- package/dist/owletto/dist/assets/_viewKey-iGPCKSda.js +0 -1
- package/dist/owletto/dist/assets/accept-invitation-BmQKbQem.js +0 -1
- package/dist/owletto/dist/assets/activity-route-view-BvtAoGVt.js +0 -1
- package/dist/owletto/dist/assets/agent-connect-pages-DkDlFVY5.js +0 -1
- package/dist/owletto/dist/assets/agent-editor-form-DwHD9j1Y.js +0 -1
- package/dist/owletto/dist/assets/agent-guardrails-route-0PsTrqMC.js +0 -1
- package/dist/owletto/dist/assets/agent-permissions-matrix-B-Q5rmuB.js +0 -1
- package/dist/owletto/dist/assets/agent-skills-route-Cwq1QrhW.js +0 -1
- package/dist/owletto/dist/assets/agent-subpage-shell-DtzoRy6N.js +0 -1
- package/dist/owletto/dist/assets/agent-thread-D7AGGjRV.js +0 -8
- package/dist/owletto/dist/assets/agents-BqCKU4CT.js +0 -1
- package/dist/owletto/dist/assets/agents-workbench-Cl7FO7b3.js +0 -1
- package/dist/owletto/dist/assets/automation-detail-content-CKSywvzE.js +0 -1
- package/dist/owletto/dist/assets/automations-BqCKU4CT.js +0 -1
- package/dist/owletto/dist/assets/callback-DZ3YyXeV.js +0 -1
- package/dist/owletto/dist/assets/connect-BNatqg6j.js +0 -1
- package/dist/owletto/dist/assets/connect._clientId-BGG2IqiQ.js +0 -1
- package/dist/owletto/dist/assets/connected._clientId-7RU89sVW.js +0 -1
- package/dist/owletto/dist/assets/connection-CTaUGXl6.js +0 -1
- package/dist/owletto/dist/assets/connection-feed-detail-B1xieiEh.js +0 -1
- package/dist/owletto/dist/assets/connectors-NBwCLuZg.js +0 -1
- package/dist/owletto/dist/assets/create-8bBbQJGY.js +0 -1
- package/dist/owletto/dist/assets/create-Cl6cfNAp.js +0 -1
- package/dist/owletto/dist/assets/create-DrVso8O7.js +0 -1
- package/dist/owletto/dist/assets/create-automation-form-De8J-JD5.js +0 -2
- package/dist/owletto/dist/assets/deployments-C7M3fV5K.js +0 -1
- package/dist/owletto/dist/assets/device-pin-tombstone-CwJitllC.js +0 -1
- package/dist/owletto/dist/assets/device-rows-BBhW1C7Y.js +0 -1
- package/dist/owletto/dist/assets/device._deviceId-XswfXHOc.js +0 -1
- package/dist/owletto/dist/assets/entity-options-utGBmFX0.js +0 -1
- package/dist/owletto/dist/assets/entity-page-BxwuqqWk.js +0 -1
- package/dist/owletto/dist/assets/entity-type-page-BrWqk6so.js +0 -1
- package/dist/owletto/dist/assets/event-page-LIm4EDmJ.js +0 -1
- package/dist/owletto/dist/assets/events-feed-C4L8mQV7.js +0 -1
- package/dist/owletto/dist/assets/guardrails-CGFWCfbQ.js +0 -1
- package/dist/owletto/dist/assets/identity-uPYpPogR.js +0 -1
- package/dist/owletto/dist/assets/index-BKMafTe4.js +0 -1
- package/dist/owletto/dist/assets/index-BsL1-C2-.js +0 -1
- package/dist/owletto/dist/assets/index-C58oW727.js +0 -1
- package/dist/owletto/dist/assets/index-C8CR2-Ck.css +0 -1
- package/dist/owletto/dist/assets/index-CQ4s6nzy.js +0 -1
- package/dist/owletto/dist/assets/index-DCK0KhMM.js +0 -1
- package/dist/owletto/dist/assets/index-DXqiRON3.js +0 -1
- package/dist/owletto/dist/assets/index-DgEc5IvT.js +0 -1
- package/dist/owletto/dist/assets/index-DvhM9tuI.js +0 -1
- package/dist/owletto/dist/assets/index-DyYFZjh-.js +0 -1
- package/dist/owletto/dist/assets/index-oDoJENMF.js +0 -1
- package/dist/owletto/dist/assets/index-rPdUEOa3.js +0 -1
- package/dist/owletto/dist/assets/login-Di5VF2F_.js +0 -1
- package/dist/owletto/dist/assets/logout-BuaQGSnw.js +0 -1
- package/dist/owletto/dist/assets/member-scope-gate-CJqJZk7T.js +0 -1
- package/dist/owletto/dist/assets/models--8mTFOLz.js +0 -1
- package/dist/owletto/dist/assets/new-BzkA1sq2.js +0 -1
- package/dist/owletto/dist/assets/new-C3f0BShb.js +0 -1
- package/dist/owletto/dist/assets/new-DA5LF6iB.js +0 -1
- package/dist/owletto/dist/assets/organization-DOtBRqDQ.js +0 -1
- package/dist/owletto/dist/assets/runs-_yVh6PPB.js +0 -1
- package/dist/owletto/dist/assets/runs-table--dnFQatY.js +0 -1
- package/dist/owletto/dist/assets/settings-DQo_ZS2P.js +0 -1
- package/dist/owletto/dist/assets/skills-a5xQ4RE9.js +0 -1
|
@@ -485,7 +485,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
485
485
|
kind: 'read',
|
|
486
486
|
name: 'Search Videos',
|
|
487
487
|
description: 'Search public YouTube by keyword and return matching videos.',
|
|
488
|
-
requiresApproval: false,
|
|
489
488
|
inputSchema: {
|
|
490
489
|
type: 'object',
|
|
491
490
|
required: ['query'],
|
|
@@ -513,7 +512,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
513
512
|
kind: 'read',
|
|
514
513
|
name: 'Get Video',
|
|
515
514
|
description: 'Fetch metadata for one YouTube video by id or URL.',
|
|
516
|
-
requiresApproval: false,
|
|
517
515
|
inputSchema: {
|
|
518
516
|
type: 'object',
|
|
519
517
|
required: ['video_id'],
|
|
@@ -539,7 +537,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
539
537
|
name: 'Search Liked Videos',
|
|
540
538
|
description:
|
|
541
539
|
"Filter the authenticated user's liked videos by title or channel name (substring match).",
|
|
542
|
-
requiresApproval: false,
|
|
543
540
|
inputSchema: {
|
|
544
541
|
type: 'object',
|
|
545
542
|
required: ['query'],
|
|
@@ -563,7 +560,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
563
560
|
kind: 'read',
|
|
564
561
|
name: 'List Playlists',
|
|
565
562
|
description: "List the authenticated user's YouTube playlists.",
|
|
566
|
-
requiresApproval: false,
|
|
567
563
|
inputSchema: {
|
|
568
564
|
type: 'object',
|
|
569
565
|
properties: {
|
|
@@ -581,7 +577,6 @@ export default class YouTubeConnector extends ConnectorRuntime {
|
|
|
581
577
|
kind: 'read',
|
|
582
578
|
name: 'Get Playlist',
|
|
583
579
|
description: 'List videos in one of your playlists, with an optional title filter.',
|
|
584
|
-
requiresApproval: false,
|
|
585
580
|
inputSchema: {
|
|
586
581
|
type: 'object',
|
|
587
582
|
required: ['playlist_id'],
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
-- Breaking cutover: operators hold rollout and stop old app/workers, then apply
|
|
3
|
+
-- this schema and convert existing connection/default metadata to explicit
|
|
4
|
+
-- policies before releasing the new runtime. Existing connector sources are
|
|
5
|
+
-- updated through the versioned install lifecycle; there is no legacy reader
|
|
6
|
+
-- or automatic data backfill. Only newly created orgs are seeded below.
|
|
7
|
+
-- Connector targets and action filters are independent: a connection can have
|
|
8
|
+
-- one rule for all destructive operations without enumerating today's catalog.
|
|
9
|
+
ALTER TABLE write_approval_policies
|
|
10
|
+
ADD COLUMN IF NOT EXISTS connector_key text,
|
|
11
|
+
ADD COLUMN IF NOT EXISTS connection_id bigint,
|
|
12
|
+
ADD COLUMN IF NOT EXISTS operation_category text;
|
|
13
|
+
|
|
14
|
+
ALTER TABLE write_approval_policies
|
|
15
|
+
DROP CONSTRAINT IF EXISTS write_approval_policies_connector_scope_check;
|
|
16
|
+
ALTER TABLE write_approval_policies
|
|
17
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
18
|
+
ADD CONSTRAINT write_approval_policies_connector_scope_check CHECK (
|
|
19
|
+
(connector_key IS NULL OR (resource_class = 'connector_action' AND btrim(connector_key) <> ''))
|
|
20
|
+
AND (connection_id IS NULL OR resource_class = 'connector_action')
|
|
21
|
+
AND (connector_key IS NULL OR connection_id IS NULL)
|
|
22
|
+
AND (operation_category IS NULL OR (
|
|
23
|
+
resource_class = 'connector_action' AND operation_key IS NULL
|
|
24
|
+
AND operation_category IN ('read', 'write', 'destructive', 'non_destructive', 'unknown')
|
|
25
|
+
))
|
|
26
|
+
) NOT VALID;
|
|
27
|
+
ALTER TABLE write_approval_policies
|
|
28
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
29
|
+
VALIDATE CONSTRAINT write_approval_policies_connector_scope_check;
|
|
30
|
+
|
|
31
|
+
-- squawk-ignore require-concurrent-index-creation -- bounded connection configuration; migration runs while writers are quiesced
|
|
32
|
+
CREATE UNIQUE INDEX IF NOT EXISTS connections_org_id_policy_key
|
|
33
|
+
ON connections (organization_id, id);
|
|
34
|
+
ALTER TABLE write_approval_policies
|
|
35
|
+
DROP CONSTRAINT IF EXISTS write_approval_policies_connection_fkey;
|
|
36
|
+
-- squawk-ignore adding-foreign-key-constraint -- NOT VALID followed by validation; existing rows have null connection_id
|
|
37
|
+
ALTER TABLE write_approval_policies
|
|
38
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
39
|
+
ADD CONSTRAINT write_approval_policies_connection_fkey
|
|
40
|
+
FOREIGN KEY (organization_id, connection_id)
|
|
41
|
+
REFERENCES connections (organization_id, id) ON DELETE CASCADE NOT VALID;
|
|
42
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
43
|
+
ALTER TABLE write_approval_policies VALIDATE CONSTRAINT write_approval_policies_connection_fkey;
|
|
44
|
+
|
|
45
|
+
-- squawk-ignore require-concurrent-index-creation -- bounded policy configuration; replace identity while writers are quiesced
|
|
46
|
+
CREATE UNIQUE INDEX IF NOT EXISTS write_approval_policies_scoped_identity
|
|
47
|
+
ON write_approval_policies (
|
|
48
|
+
organization_id, resource_class, COALESCE(principal_kind, ''), COALESCE(principal_id, ''),
|
|
49
|
+
COALESCE(operation_key, ''), COALESCE(entity_type_slug, ''), COALESCE(field_path, ''),
|
|
50
|
+
COALESCE(entity_id, 0), COALESCE(target_agent_id, ''),
|
|
51
|
+
COALESCE(connector_key, ''), COALESCE(connection_id, 0), COALESCE(operation_category, '')
|
|
52
|
+
);
|
|
53
|
+
-- squawk-ignore require-concurrent-index-deletion -- quiesced migration; expanded identity already exists
|
|
54
|
+
DROP INDEX IF EXISTS write_approval_policies_identity;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
-- Disabled and Block now have the same execution and discovery semantics.
|
|
58
|
+
UPDATE write_policy_action_effects SET effect = 'deny' WHERE effect = 'disabled';
|
|
59
|
+
ALTER TABLE write_policy_action_effects DROP CONSTRAINT IF EXISTS write_policy_action_effects_effect_check;
|
|
60
|
+
ALTER TABLE write_policy_action_effects
|
|
61
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
62
|
+
ADD CONSTRAINT write_policy_action_effects_effect_check
|
|
63
|
+
CHECK (effect IN ('auto', 'approval', 'deny')) NOT VALID;
|
|
64
|
+
ALTER TABLE write_policy_action_effects VALIDATE CONSTRAINT write_policy_action_effects_effect_check;
|
|
65
|
+
|
|
66
|
+
-- Seed an ordinary, editable Reads Auto rule exactly once at org creation.
|
|
67
|
+
-- A DB trigger covers both personal-org provisioning and web-created workspaces.
|
|
68
|
+
-- Deleting this rule is intentional: no runtime fallback recreates it.
|
|
69
|
+
CREATE OR REPLACE FUNCTION seed_connector_read_policy() RETURNS trigger LANGUAGE plpgsql AS $$
|
|
70
|
+
DECLARE policy_id bigint;
|
|
71
|
+
BEGIN
|
|
72
|
+
INSERT INTO write_approval_policies (organization_id, resource_class, operation_category)
|
|
73
|
+
VALUES (NEW.id, 'connector_action', 'read') RETURNING id INTO policy_id;
|
|
74
|
+
INSERT INTO write_policy_action_effects (policy_id, action, effect)
|
|
75
|
+
VALUES (policy_id, 'execute', 'auto');
|
|
76
|
+
RETURN NEW;
|
|
77
|
+
END;
|
|
78
|
+
$$;
|
|
79
|
+
DROP TRIGGER IF EXISTS organization_connector_read_policy ON organization;
|
|
80
|
+
CREATE TRIGGER organization_connector_read_policy AFTER INSERT ON organization
|
|
81
|
+
FOR EACH ROW EXECUTE FUNCTION seed_connector_read_policy();
|
|
82
|
+
|
|
83
|
+
-- migrate:down
|
|
84
|
+
DROP TRIGGER IF EXISTS organization_connector_read_policy ON organization;
|
|
85
|
+
DROP FUNCTION IF EXISTS seed_connector_read_policy();
|
|
86
|
+
ALTER TABLE write_policy_action_effects DROP CONSTRAINT IF EXISTS write_policy_action_effects_effect_check;
|
|
87
|
+
ALTER TABLE write_policy_action_effects
|
|
88
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
89
|
+
ADD CONSTRAINT write_policy_action_effects_effect_check
|
|
90
|
+
CHECK (effect IN ('auto', 'approval', 'deny', 'disabled')) NOT VALID;
|
|
91
|
+
ALTER TABLE write_policy_action_effects VALIDATE CONSTRAINT write_policy_action_effects_effect_check;
|
|
92
|
+
-- Rollback must not silently discard policies the old schema cannot express.
|
|
93
|
+
DO $$ BEGIN
|
|
94
|
+
IF EXISTS (SELECT 1 FROM write_approval_policies
|
|
95
|
+
WHERE connector_key IS NOT NULL OR connection_id IS NOT NULL OR operation_category IS NOT NULL)
|
|
96
|
+
THEN RAISE EXCEPTION 'Remove scoped connector policies explicitly before rolling back';
|
|
97
|
+
END IF;
|
|
98
|
+
END $$;
|
|
99
|
+
-- squawk-ignore require-concurrent-index-creation -- quiesced rollback, policy configuration only
|
|
100
|
+
CREATE UNIQUE INDEX IF NOT EXISTS write_approval_policies_identity
|
|
101
|
+
ON write_approval_policies (
|
|
102
|
+
organization_id, resource_class, COALESCE(principal_kind, ''), COALESCE(principal_id, ''),
|
|
103
|
+
COALESCE(operation_key, ''), COALESCE(entity_type_slug, ''), COALESCE(field_path, ''),
|
|
104
|
+
COALESCE(entity_id, 0), COALESCE(target_agent_id, '')
|
|
105
|
+
);
|
|
106
|
+
-- squawk-ignore require-concurrent-index-deletion -- original identity has been restored
|
|
107
|
+
DROP INDEX IF EXISTS write_approval_policies_scoped_identity;
|
|
108
|
+
ALTER TABLE write_approval_policies DROP CONSTRAINT IF EXISTS write_approval_policies_connection_fkey;
|
|
109
|
+
ALTER TABLE write_approval_policies DROP CONSTRAINT IF EXISTS write_approval_policies_connector_scope_check;
|
|
110
|
+
-- squawk-ignore ban-drop-column -- rollback refuses while any new-scope policy exists
|
|
111
|
+
ALTER TABLE write_approval_policies DROP COLUMN IF EXISTS connector_key, DROP COLUMN IF EXISTS connection_id, DROP COLUMN IF EXISTS operation_category;
|
|
112
|
+
-- squawk-ignore require-concurrent-index-deletion -- quiesced rollback; foreign key was removed
|
|
113
|
+
DROP INDEX IF EXISTS connections_org_id_policy_key;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
-- Exact operation keys already name a connector. Persist that target so a
|
|
3
|
+
-- connector-wide rule cannot outrank its own exact-action exception.
|
|
4
|
+
DO $$ BEGIN
|
|
5
|
+
IF EXISTS (
|
|
6
|
+
SELECT 1 FROM write_approval_policies
|
|
7
|
+
WHERE resource_class = 'connector_action' AND operation_key IS NOT NULL
|
|
8
|
+
AND connector_key IS NULL AND connection_id IS NULL
|
|
9
|
+
AND (strpos(operation_key, '::') <= 1 OR length(operation_key) = strpos(operation_key, '::') + 1)
|
|
10
|
+
) THEN
|
|
11
|
+
RAISE EXCEPTION 'Exact connector policies must use qualified connector::action keys before migration';
|
|
12
|
+
END IF;
|
|
13
|
+
END $$;
|
|
14
|
+
|
|
15
|
+
-- The existing unique scope index deliberately aborts on collisions. Never
|
|
16
|
+
-- choose between two existing decisions or merge their delivery targets here.
|
|
17
|
+
UPDATE write_approval_policies
|
|
18
|
+
SET connector_key = split_part(operation_key, '::', 1)
|
|
19
|
+
WHERE resource_class = 'connector_action' AND operation_key IS NOT NULL
|
|
20
|
+
AND connector_key IS NULL AND connection_id IS NULL;
|
|
21
|
+
|
|
22
|
+
ALTER TABLE write_approval_policies
|
|
23
|
+
DROP CONSTRAINT IF EXISTS write_approval_policies_exact_target_check;
|
|
24
|
+
ALTER TABLE write_approval_policies
|
|
25
|
+
-- squawk-ignore prefer-robust-stmts -- the migration runner owns the transaction
|
|
26
|
+
ADD CONSTRAINT write_approval_policies_exact_target_check CHECK (
|
|
27
|
+
operation_key IS NULL OR connector_key IS NOT NULL OR connection_id IS NOT NULL
|
|
28
|
+
) NOT VALID;
|
|
29
|
+
ALTER TABLE write_approval_policies
|
|
30
|
+
VALIDATE CONSTRAINT write_approval_policies_exact_target_check;
|
|
31
|
+
|
|
32
|
+
-- migrate:down
|
|
33
|
+
-- Canonical targets are valid in the previous schema; keep their identity and
|
|
34
|
+
-- decisions rather than inventing which rows originally omitted the connector.
|
|
35
|
+
ALTER TABLE write_approval_policies
|
|
36
|
+
DROP CONSTRAINT IF EXISTS write_approval_policies_exact_target_check;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
|
|
3
|
+
-- A connection-backed entity type may declare `backing_identity`: the identity
|
|
4
|
+
-- namespace whose identifier IS the source canonical key (the backing SQL's
|
|
5
|
+
-- slug/id column). Such a type keeps stored identity rows in `entities`
|
|
6
|
+
-- (slug = source key, name) so events, relationships, views and ACL can key on
|
|
7
|
+
-- a numeric id; its attributes are still read live from the source. Internal
|
|
8
|
+
-- views (no connection) and connection-backed types without an identity remain
|
|
9
|
+
-- pure views with no stored rows.
|
|
10
|
+
ALTER TABLE public.entity_types ADD COLUMN IF NOT EXISTS backing_identity text;
|
|
11
|
+
|
|
12
|
+
ALTER TABLE public.entity_types
|
|
13
|
+
DROP CONSTRAINT IF EXISTS entity_types_backing_identity_requires_source;
|
|
14
|
+
-- squawk-ignore prefer-robust-stmts,constraint-missing-not-valid -- config-scale table and a column added NULL above; the runner owns the transaction
|
|
15
|
+
ALTER TABLE public.entity_types ADD CONSTRAINT entity_types_backing_identity_requires_source CHECK (
|
|
16
|
+
backing_identity IS NULL
|
|
17
|
+
OR (backing_source IS NOT NULL AND backing_sql IS NOT NULL AND btrim(backing_identity) <> '')
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- (1) Stored rows are allowed only on stored types and identity-backed types.
|
|
21
|
+
CREATE OR REPLACE FUNCTION public.reject_rows_on_derived_entity_type()
|
|
22
|
+
RETURNS trigger AS $$
|
|
23
|
+
BEGIN
|
|
24
|
+
IF EXISTS (
|
|
25
|
+
SELECT 1 FROM public.entity_types et
|
|
26
|
+
WHERE et.id = NEW.entity_type_id
|
|
27
|
+
AND et.backing_sql IS NOT NULL
|
|
28
|
+
AND et.backing_identity IS NULL
|
|
29
|
+
) THEN
|
|
30
|
+
RAISE EXCEPTION
|
|
31
|
+
'entity type % is derived (a SQL view) and cannot have stored rows',
|
|
32
|
+
NEW.entity_type_id
|
|
33
|
+
USING ERRCODE = 'check_violation';
|
|
34
|
+
END IF;
|
|
35
|
+
RETURN NEW;
|
|
36
|
+
END;
|
|
37
|
+
$$ LANGUAGE plpgsql;
|
|
38
|
+
|
|
39
|
+
-- (2) A populated type may not become a pure view, and a stored type may not
|
|
40
|
+
-- become identity-backed while it has rows: their slugs are not source keys.
|
|
41
|
+
-- An identity-backed type may change its SQL while it keeps its identity.
|
|
42
|
+
CREATE OR REPLACE FUNCTION public.reject_derived_conversion_with_rows()
|
|
43
|
+
RETURNS trigger AS $$
|
|
44
|
+
BEGIN
|
|
45
|
+
IF NEW.backing_sql IS NOT NULL
|
|
46
|
+
AND (
|
|
47
|
+
NEW.backing_identity IS NULL
|
|
48
|
+
OR OLD.backing_sql IS NULL
|
|
49
|
+
OR OLD.backing_identity IS DISTINCT FROM NEW.backing_identity
|
|
50
|
+
)
|
|
51
|
+
AND EXISTS (
|
|
52
|
+
SELECT 1 FROM public.entities e
|
|
53
|
+
WHERE e.entity_type_id = NEW.id AND e.deleted_at IS NULL
|
|
54
|
+
) THEN
|
|
55
|
+
RAISE EXCEPTION
|
|
56
|
+
'entity type % cannot change its backing identity while stored rows exist; delete them first',
|
|
57
|
+
NEW.id
|
|
58
|
+
USING ERRCODE = 'check_violation';
|
|
59
|
+
END IF;
|
|
60
|
+
RETURN NEW;
|
|
61
|
+
END;
|
|
62
|
+
$$ LANGUAGE plpgsql;
|
|
63
|
+
|
|
64
|
+
DROP TRIGGER IF EXISTS trg_reject_derived_conversion_with_rows ON public.entity_types;
|
|
65
|
+
CREATE TRIGGER trg_reject_derived_conversion_with_rows
|
|
66
|
+
BEFORE UPDATE OF backing_sql, backing_source, backing_identity ON public.entity_types
|
|
67
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_derived_conversion_with_rows();
|
|
68
|
+
|
|
69
|
+
-- migrate:down
|
|
70
|
+
|
|
71
|
+
DROP TRIGGER IF EXISTS trg_reject_derived_conversion_with_rows ON public.entity_types;
|
|
72
|
+
CREATE OR REPLACE FUNCTION public.reject_derived_conversion_with_rows()
|
|
73
|
+
RETURNS trigger AS $$
|
|
74
|
+
BEGIN
|
|
75
|
+
IF NEW.backing_sql IS NOT NULL AND EXISTS (
|
|
76
|
+
SELECT 1 FROM public.entities e
|
|
77
|
+
WHERE e.entity_type_id = NEW.id AND e.deleted_at IS NULL
|
|
78
|
+
) THEN
|
|
79
|
+
RAISE EXCEPTION
|
|
80
|
+
'entity type % cannot become a derived view while stored rows exist; delete them first',
|
|
81
|
+
NEW.id
|
|
82
|
+
USING ERRCODE = 'check_violation';
|
|
83
|
+
END IF;
|
|
84
|
+
RETURN NEW;
|
|
85
|
+
END;
|
|
86
|
+
$$ LANGUAGE plpgsql;
|
|
87
|
+
CREATE TRIGGER trg_reject_derived_conversion_with_rows
|
|
88
|
+
BEFORE UPDATE OF backing_sql ON public.entity_types
|
|
89
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_derived_conversion_with_rows();
|
|
90
|
+
|
|
91
|
+
CREATE OR REPLACE FUNCTION public.reject_rows_on_derived_entity_type()
|
|
92
|
+
RETURNS trigger AS $$
|
|
93
|
+
BEGIN
|
|
94
|
+
IF EXISTS (
|
|
95
|
+
SELECT 1 FROM public.entity_types et
|
|
96
|
+
WHERE et.id = NEW.entity_type_id AND et.backing_sql IS NOT NULL
|
|
97
|
+
) THEN
|
|
98
|
+
RAISE EXCEPTION
|
|
99
|
+
'entity type % is derived (a SQL view) and cannot have stored rows',
|
|
100
|
+
NEW.entity_type_id
|
|
101
|
+
USING ERRCODE = 'check_violation';
|
|
102
|
+
END IF;
|
|
103
|
+
RETURN NEW;
|
|
104
|
+
END;
|
|
105
|
+
$$ LANGUAGE plpgsql;
|
|
106
|
+
|
|
107
|
+
ALTER TABLE public.entity_types
|
|
108
|
+
DROP CONSTRAINT IF EXISTS entity_types_backing_identity_requires_source;
|
|
109
|
+
ALTER TABLE public.entity_types DROP COLUMN IF EXISTS backing_identity;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
-- migrate:up
|
|
2
|
+
-- Retires source-backed identity rows (20261003120000). A source-backed entity
|
|
3
|
+
-- type creates no stored entities or identities; records resolve live from
|
|
4
|
+
-- the source. Existing live stored rows must be removed before deployment.
|
|
5
|
+
-- Restores the original triggers that reject stored rows on any type with
|
|
6
|
+
-- backing SQL, then drops backing_identity. Quiesced (no lobu:no-quiesce
|
|
7
|
+
-- marker): the code before this deploy selects backing_identity.
|
|
8
|
+
-- Cost: metadata-only DDL on entity_types (389 rows in production on 2026-10-03);
|
|
9
|
+
-- DROP COLUMN does not rewrite the table.
|
|
10
|
+
|
|
11
|
+
DROP TRIGGER IF EXISTS trg_reject_derived_conversion_with_rows ON public.entity_types;
|
|
12
|
+
CREATE OR REPLACE FUNCTION public.reject_derived_conversion_with_rows()
|
|
13
|
+
RETURNS trigger AS $$
|
|
14
|
+
BEGIN
|
|
15
|
+
IF NEW.backing_sql IS NOT NULL AND EXISTS (
|
|
16
|
+
SELECT 1 FROM public.entities e
|
|
17
|
+
WHERE e.entity_type_id = NEW.id AND e.deleted_at IS NULL
|
|
18
|
+
) THEN
|
|
19
|
+
RAISE EXCEPTION
|
|
20
|
+
'entity type % cannot become a derived view while stored rows exist; delete them first',
|
|
21
|
+
NEW.id
|
|
22
|
+
USING ERRCODE = 'check_violation';
|
|
23
|
+
END IF;
|
|
24
|
+
RETURN NEW;
|
|
25
|
+
END;
|
|
26
|
+
$$ LANGUAGE plpgsql;
|
|
27
|
+
CREATE TRIGGER trg_reject_derived_conversion_with_rows
|
|
28
|
+
BEFORE UPDATE OF backing_sql ON public.entity_types
|
|
29
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_derived_conversion_with_rows();
|
|
30
|
+
|
|
31
|
+
CREATE OR REPLACE FUNCTION public.reject_rows_on_derived_entity_type()
|
|
32
|
+
RETURNS trigger AS $$
|
|
33
|
+
BEGIN
|
|
34
|
+
IF EXISTS (
|
|
35
|
+
SELECT 1 FROM public.entity_types et
|
|
36
|
+
WHERE et.id = NEW.entity_type_id AND et.backing_sql IS NOT NULL
|
|
37
|
+
) THEN
|
|
38
|
+
RAISE EXCEPTION
|
|
39
|
+
'entity type % is derived (a SQL view) and cannot have stored rows',
|
|
40
|
+
NEW.entity_type_id
|
|
41
|
+
USING ERRCODE = 'check_violation';
|
|
42
|
+
END IF;
|
|
43
|
+
RETURN NEW;
|
|
44
|
+
END;
|
|
45
|
+
$$ LANGUAGE plpgsql;
|
|
46
|
+
|
|
47
|
+
ALTER TABLE public.entity_types
|
|
48
|
+
DROP CONSTRAINT IF EXISTS entity_types_backing_identity_requires_source;
|
|
49
|
+
ALTER TABLE public.entity_types DROP COLUMN IF EXISTS backing_identity;
|
|
50
|
+
|
|
51
|
+
-- migrate:down
|
|
52
|
+
-- Restores the 20261003120000 state exactly.
|
|
53
|
+
|
|
54
|
+
ALTER TABLE public.entity_types ADD COLUMN IF NOT EXISTS backing_identity text;
|
|
55
|
+
|
|
56
|
+
ALTER TABLE public.entity_types
|
|
57
|
+
DROP CONSTRAINT IF EXISTS entity_types_backing_identity_requires_source;
|
|
58
|
+
-- squawk-ignore prefer-robust-stmts,constraint-missing-not-valid -- config-scale table and a column added NULL above; the runner owns the transaction
|
|
59
|
+
ALTER TABLE public.entity_types ADD CONSTRAINT entity_types_backing_identity_requires_source CHECK (
|
|
60
|
+
backing_identity IS NULL
|
|
61
|
+
OR (backing_source IS NOT NULL AND backing_sql IS NOT NULL AND btrim(backing_identity) <> '')
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
-- (1) Stored rows are allowed only on stored types and identity-backed types.
|
|
65
|
+
CREATE OR REPLACE FUNCTION public.reject_rows_on_derived_entity_type()
|
|
66
|
+
RETURNS trigger AS $$
|
|
67
|
+
BEGIN
|
|
68
|
+
IF EXISTS (
|
|
69
|
+
SELECT 1 FROM public.entity_types et
|
|
70
|
+
WHERE et.id = NEW.entity_type_id
|
|
71
|
+
AND et.backing_sql IS NOT NULL
|
|
72
|
+
AND et.backing_identity IS NULL
|
|
73
|
+
) THEN
|
|
74
|
+
RAISE EXCEPTION
|
|
75
|
+
'entity type % is derived (a SQL view) and cannot have stored rows',
|
|
76
|
+
NEW.entity_type_id
|
|
77
|
+
USING ERRCODE = 'check_violation';
|
|
78
|
+
END IF;
|
|
79
|
+
RETURN NEW;
|
|
80
|
+
END;
|
|
81
|
+
$$ LANGUAGE plpgsql;
|
|
82
|
+
|
|
83
|
+
-- (2) A populated type may not become a pure view, and a stored type may not
|
|
84
|
+
-- become identity-backed while it has rows: their slugs are not source keys.
|
|
85
|
+
-- An identity-backed type may change its SQL while it keeps its identity.
|
|
86
|
+
CREATE OR REPLACE FUNCTION public.reject_derived_conversion_with_rows()
|
|
87
|
+
RETURNS trigger AS $$
|
|
88
|
+
BEGIN
|
|
89
|
+
IF NEW.backing_sql IS NOT NULL
|
|
90
|
+
AND (
|
|
91
|
+
NEW.backing_identity IS NULL
|
|
92
|
+
OR OLD.backing_sql IS NULL
|
|
93
|
+
OR OLD.backing_identity IS DISTINCT FROM NEW.backing_identity
|
|
94
|
+
)
|
|
95
|
+
AND EXISTS (
|
|
96
|
+
SELECT 1 FROM public.entities e
|
|
97
|
+
WHERE e.entity_type_id = NEW.id AND e.deleted_at IS NULL
|
|
98
|
+
) THEN
|
|
99
|
+
RAISE EXCEPTION
|
|
100
|
+
'entity type % cannot change its backing identity while stored rows exist; delete them first',
|
|
101
|
+
NEW.id
|
|
102
|
+
USING ERRCODE = 'check_violation';
|
|
103
|
+
END IF;
|
|
104
|
+
RETURN NEW;
|
|
105
|
+
END;
|
|
106
|
+
$$ LANGUAGE plpgsql;
|
|
107
|
+
|
|
108
|
+
DROP TRIGGER IF EXISTS trg_reject_derived_conversion_with_rows ON public.entity_types;
|
|
109
|
+
CREATE TRIGGER trg_reject_derived_conversion_with_rows
|
|
110
|
+
BEFORE UPDATE OF backing_sql, backing_source, backing_identity ON public.entity_types
|
|
111
|
+
FOR EACH ROW EXECUTE FUNCTION public.reject_derived_conversion_with_rows();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- External prerequisite of binding exact connector policies to their connector.
|
|
2
|
+
-- The migration cannot choose a connector for an unqualified key or decide
|
|
3
|
+
-- between two existing rules for the same canonical scope; an admin must
|
|
4
|
+
-- rewrite or delete those rules first. On a fresh install the scope columns do
|
|
5
|
+
-- not exist yet.
|
|
6
|
+
DO $precondition$
|
|
7
|
+
BEGIN
|
|
8
|
+
IF EXISTS (
|
|
9
|
+
SELECT 1 FROM information_schema.columns
|
|
10
|
+
WHERE table_schema = 'public' AND table_name = 'write_approval_policies'
|
|
11
|
+
AND column_name = 'connector_key'
|
|
12
|
+
) THEN
|
|
13
|
+
IF EXISTS (
|
|
14
|
+
SELECT 1 FROM public.write_approval_policies
|
|
15
|
+
WHERE resource_class = 'connector_action' AND operation_key IS NOT NULL
|
|
16
|
+
AND connector_key IS NULL AND connection_id IS NULL
|
|
17
|
+
AND (strpos(operation_key, '::') <= 1 OR length(operation_key) = strpos(operation_key, '::') + 1)
|
|
18
|
+
) THEN
|
|
19
|
+
RAISE EXCEPTION 'write_approval_policies has exact connector_action rules without a connector::action key; rewrite or delete them before deploying';
|
|
20
|
+
END IF;
|
|
21
|
+
IF EXISTS (
|
|
22
|
+
SELECT 1 FROM public.write_approval_policies legacy
|
|
23
|
+
JOIN public.write_approval_policies canonical
|
|
24
|
+
ON canonical.organization_id = legacy.organization_id
|
|
25
|
+
AND canonical.resource_class = legacy.resource_class
|
|
26
|
+
AND COALESCE(canonical.principal_kind, '') = COALESCE(legacy.principal_kind, '')
|
|
27
|
+
AND COALESCE(canonical.principal_id, '') = COALESCE(legacy.principal_id, '')
|
|
28
|
+
AND canonical.operation_key = legacy.operation_key
|
|
29
|
+
AND canonical.connector_key = split_part(legacy.operation_key, '::', 1)
|
|
30
|
+
AND canonical.connection_id IS NULL
|
|
31
|
+
WHERE legacy.resource_class = 'connector_action' AND legacy.operation_key IS NOT NULL
|
|
32
|
+
AND legacy.connector_key IS NULL AND legacy.connection_id IS NULL
|
|
33
|
+
) THEN
|
|
34
|
+
RAISE EXCEPTION 'write_approval_policies has exact connector_action rules duplicated with and without connector_key; delete one of each pair before deploying';
|
|
35
|
+
END IF;
|
|
36
|
+
END IF;
|
|
37
|
+
END
|
|
38
|
+
$precondition$;
|
package/dist/db/migrations/preconditions/20261003200000_drop_source_backed_entity_identity.sql
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
-- External prerequisite of dropping source-backed identity rows: no live stored
|
|
2
|
+
-- row may remain on a type with backing SQL. Those rows mirror source records;
|
|
3
|
+
-- an admin must delete them (and their identities and edges) before deploying.
|
|
4
|
+
-- Fresh installs run this before the baseline and backing SQL column exist.
|
|
5
|
+
DO $precondition$
|
|
6
|
+
BEGIN
|
|
7
|
+
IF EXISTS (
|
|
8
|
+
SELECT 1 FROM information_schema.columns
|
|
9
|
+
WHERE table_schema = 'public' AND table_name = 'entity_types'
|
|
10
|
+
AND column_name = 'backing_sql'
|
|
11
|
+
) THEN
|
|
12
|
+
IF EXISTS (
|
|
13
|
+
SELECT 1 FROM public.entities e
|
|
14
|
+
JOIN public.entity_types et ON et.id = e.entity_type_id
|
|
15
|
+
WHERE et.backing_sql IS NOT NULL AND e.deleted_at IS NULL
|
|
16
|
+
) THEN
|
|
17
|
+
RAISE EXCEPTION 'stored entities exist on source-backed entity types; delete them before deploying';
|
|
18
|
+
END IF;
|
|
19
|
+
END IF;
|
|
20
|
+
END
|
|
21
|
+
$precondition$;
|