@cchistory/lite 0.4.5 → 0.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.
- package/INSTALL.md +1 -1
- package/apps/lite-cli/dist/agent-contract.d.ts +4 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +32 -25
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +3 -3
- package/apps/lite-cli/dist/bin.js.map +1 -1
- package/apps/lite-cli/dist/index.d.ts.map +1 -1
- package/apps/lite-cli/dist/index.js +147 -66
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +76 -60
- package/apps/lite-cli/dist/index.test.js.map +1 -1
- package/apps/lite-cli/dist/query.d.ts +4 -1
- package/apps/lite-cli/dist/query.d.ts.map +1 -1
- package/apps/lite-cli/dist/query.js +45 -29
- package/apps/lite-cli/dist/query.js.map +1 -1
- package/apps/lite-cli/dist/resource-errors.d.ts +3 -0
- package/apps/lite-cli/dist/resource-errors.d.ts.map +1 -0
- package/apps/lite-cli/dist/resource-errors.js +17 -0
- package/apps/lite-cli/dist/resource-errors.js.map +1 -0
- package/apps/lite-cli/dist/shell.d.ts +12 -2
- package/apps/lite-cli/dist/shell.d.ts.map +1 -1
- package/apps/lite-cli/dist/shell.js +129 -57
- package/apps/lite-cli/dist/shell.js.map +1 -1
- package/apps/lite-cli/dist/sql-query.test.d.ts +2 -0
- package/apps/lite-cli/dist/sql-query.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/sql-query.test.js +290 -0
- package/apps/lite-cli/dist/sql-query.test.js.map +1 -0
- package/apps/lite-cli/dist/version.d.ts +1 -1
- package/apps/lite-cli/dist/version.js +1 -1
- package/apps/lite-tui/dist/bin.js +3 -3
- package/apps/lite-tui/dist/bin.js.map +1 -1
- package/apps/lite-tui/dist/index.d.ts.map +1 -1
- package/apps/lite-tui/dist/index.js +2 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +5 -3
- package/apps/lite-tui/dist/index.test.js.map +1 -1
- package/apps/lite-tui/dist/render.d.ts +1 -1
- package/apps/lite-tui/dist/version.d.ts +1 -1
- package/apps/lite-tui/dist/version.js +1 -1
- package/bin/cchistory-lite-tui.mjs +3 -3
- package/bin/cchistory-lite.mjs +3 -3
- package/docs/guide/for-agents.md +65 -46
- package/docs/guide/lite.md +49 -11
- package/docs/guide/queries/latest-sessions.sql +4 -0
- package/docs/guide/queries/latest-turns.sql +1 -0
- package/docs/guide/queries/list-sessions.sql +2 -0
- package/docs/guide/query.md +153 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +7 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/directory-scope.js +11 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts +5 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.js +5 -1
- package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/query.d.ts +15 -0
- package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/query.js +208 -0
- package/node_modules/@cchistory/canonical/dist/query.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.js +3 -0
- package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.test.js +61 -0
- package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +30 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js +713 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js +56 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/package.json +1 -1
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts +7 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js +36 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts +26 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js +80 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/domain/dist/index.js +5 -0
- package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
- package/node_modules/@cchistory/domain/dist/masks.d.ts +31 -0
- package/node_modules/@cchistory/domain/dist/masks.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/masks.js +342 -0
- package/node_modules/@cchistory/domain/dist/masks.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts +58 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js +2 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts +67 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.js +2 -0
- package/node_modules/@cchistory/domain/dist/query.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts +14 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js +247 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -0
- package/node_modules/@cchistory/domain/package.json +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts +30 -9
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.js +263 -142
- package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.test.js +177 -20
- package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +21 -22
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +53 -41
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +266 -57
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +166 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/package.json +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +80 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +4 -4
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js +54 -36
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +75 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
- package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
- package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +11 -9
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +428 -0
- package/node_modules/commander/index.js +1224 -0
- package/node_modules/commander/package.json +38 -0
- package/node_modules/commander/typings/index.d.ts +310 -0
- package/node_modules/discontinuous-range/.npmignore +28 -0
- package/node_modules/discontinuous-range/.travis.yml +4 -0
- package/node_modules/discontinuous-range/LICENSE +21 -0
- package/node_modules/discontinuous-range/README.md +23 -0
- package/node_modules/discontinuous-range/index.js +144 -0
- package/node_modules/discontinuous-range/package.json +27 -0
- package/node_modules/discontinuous-range/test/main-test.js +96 -0
- package/node_modules/moo/LICENSE +29 -0
- package/node_modules/moo/README.md +385 -0
- package/node_modules/moo/moo.js +645 -0
- package/node_modules/moo/package.json +29 -0
- package/node_modules/nearley/LICENSE.txt +21 -0
- package/node_modules/nearley/README.md +80 -0
- package/node_modules/nearley/bin/nearley-railroad.js +121 -0
- package/node_modules/nearley/bin/nearley-test.js +64 -0
- package/node_modules/nearley/bin/nearley-unparse.js +29 -0
- package/node_modules/nearley/bin/nearleyc.js +38 -0
- package/node_modules/nearley/builtin/cow.ne +2 -0
- package/node_modules/nearley/builtin/number.ne +51 -0
- package/node_modules/nearley/builtin/postprocessors.ne +36 -0
- package/node_modules/nearley/builtin/string.ne +26 -0
- package/node_modules/nearley/builtin/whitespace.ne +5 -0
- package/node_modules/nearley/lib/compile.js +307 -0
- package/node_modules/nearley/lib/generate.js +244 -0
- package/node_modules/nearley/lib/lint.js +28 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
- package/node_modules/nearley/lib/nearley.js +564 -0
- package/node_modules/nearley/lib/stream.js +18 -0
- package/node_modules/nearley/lib/unparse.js +139 -0
- package/node_modules/nearley/package.json +63 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
- package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.js +6484 -0
- package/node_modules/pgsql-ast-parser/index.js.map +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/package.json +69 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/readme.md +255 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
- package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
- package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
- package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
- package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
- package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
- package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
- package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
- package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
- package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
- package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
- package/node_modules/railroad-diagrams/.gitattributes +22 -0
- package/node_modules/railroad-diagrams/.npmignore +163 -0
- package/node_modules/railroad-diagrams/README.md +86 -0
- package/node_modules/railroad-diagrams/css-example.py-js +183 -0
- package/node_modules/railroad-diagrams/example.html +141 -0
- package/node_modules/railroad-diagrams/generator.html +59 -0
- package/node_modules/railroad-diagrams/package.json +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
- package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
- package/node_modules/randexp/LICENSE +19 -0
- package/node_modules/randexp/README.md +134 -0
- package/node_modules/randexp/lib/randexp.js +245 -0
- package/node_modules/randexp/package.json +48 -0
- package/node_modules/ret/LICENSE +19 -0
- package/node_modules/ret/README.md +183 -0
- package/node_modules/ret/lib/index.js +282 -0
- package/node_modules/ret/lib/positions.js +17 -0
- package/node_modules/ret/lib/sets.js +82 -0
- package/node_modules/ret/lib/types.js +10 -0
- package/node_modules/ret/lib/util.js +111 -0
- package/node_modules/ret/package.json +35 -0
- package/package.json +22 -6
- package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
- package/schemas/cchistory-lite-error-v1.schema.json +58 -8
- package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
- package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
- package/schemas/cchistory-lite-query-v3.schema.json +57 -0
- package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
- package/skills/using-cchistory-lite/SKILL.md +125 -55
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
@lexer lexerAny
|
|
2
|
+
@include "base.ne"
|
|
3
|
+
|
|
4
|
+
functions_statements -> create_func | do_stm | drop_func
|
|
5
|
+
|
|
6
|
+
array_of[EXP] -> $EXP (%comma $EXP {% last %}):* {% ([head, tail]) => {
|
|
7
|
+
return [unwrap(head), ...(tail.map(unwrap) || [])];
|
|
8
|
+
} %}
|
|
9
|
+
|
|
10
|
+
# https://www.postgresql.org/docs/13/sql-createfunction.html
|
|
11
|
+
create_func -> %kw_create
|
|
12
|
+
(%kw_or kw_replace):?
|
|
13
|
+
kw_function
|
|
14
|
+
qname
|
|
15
|
+
(lparen array_of[func_argdef]:? rparen {% get(1) %})
|
|
16
|
+
func_spec:+ {% (x, rej) => {
|
|
17
|
+
const specs: any = {};
|
|
18
|
+
for (const s of x[5]) {
|
|
19
|
+
for (const k in s) {
|
|
20
|
+
if (k[0] !== '_' && k in specs) {
|
|
21
|
+
throw new Error('conflicting or redundant options ' + k);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
Object.assign(specs, s);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return track(x, {
|
|
28
|
+
type: 'create function',
|
|
29
|
+
...x[1] && {orReplace: true},
|
|
30
|
+
name: x[3],
|
|
31
|
+
arguments: x[4] ?? [],
|
|
32
|
+
...specs,
|
|
33
|
+
});
|
|
34
|
+
} %}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
func_argdef -> func_argopts:?
|
|
38
|
+
data_type
|
|
39
|
+
func_argdefault:?
|
|
40
|
+
{% x => track(x, {
|
|
41
|
+
default: x[2],
|
|
42
|
+
type: x[1],
|
|
43
|
+
...x[0],
|
|
44
|
+
}) %}
|
|
45
|
+
|
|
46
|
+
func_argdefault -> %kw_default expr {%
|
|
47
|
+
x => x[1]
|
|
48
|
+
%}
|
|
49
|
+
| %op_eq expr {% x => x[1] %}
|
|
50
|
+
|
|
51
|
+
func_argopts -> func_argmod word:? {% x => track(x, {
|
|
52
|
+
mode: toStr(x[0]),
|
|
53
|
+
...x[1] && { name: asName(x[1]) },
|
|
54
|
+
}) %}
|
|
55
|
+
| word {% (x, rej) => {
|
|
56
|
+
const name = asName(x);
|
|
57
|
+
if (name === 'out' || name === 'inout' || name === 'variadic') {
|
|
58
|
+
return rej; // avoid ambiguous syntax
|
|
59
|
+
}
|
|
60
|
+
return track(x, {name});
|
|
61
|
+
} %}
|
|
62
|
+
|
|
63
|
+
func_argmod -> %kw_in | kw_out | kw_inout | kw_variadic
|
|
64
|
+
|
|
65
|
+
func_spec -> kw_language word {% x => track(x, { language: asName(last(x)) }) %}
|
|
66
|
+
| func_purity {% x => track(x, {purity: toStr(x)}) %}
|
|
67
|
+
| %kw_as (%codeblock | string) {% x =>({code: toStr(last(x))}) %}
|
|
68
|
+
| %kw_not:? (word {% kw('leakproof') %}) {% x => track(x, { leakproof: !x[0] })%}
|
|
69
|
+
| func_returns {% x => track(x, { returns: unwrap(x) }) %}
|
|
70
|
+
| (word {%kw('called')%}) oninp {% () => ({ onNullInput: 'call' }) %}
|
|
71
|
+
| (word {%kw('returns')%}) %kw_null oninp {% () => ({ onNullInput: 'null' }) %}
|
|
72
|
+
| (word {%kw('strict')%}) {% () => ({ onNullInput: 'strict' }) %}
|
|
73
|
+
|
|
74
|
+
func_purity -> word {%kw('immutable')%}
|
|
75
|
+
| word {%kw('stable')%}
|
|
76
|
+
| word {%kw('volatile')%}
|
|
77
|
+
|
|
78
|
+
oninp -> %kw_on %kw_null (word {%kw('input')%})
|
|
79
|
+
|
|
80
|
+
func_returns -> kw_returns data_type {% last %}
|
|
81
|
+
| kw_returns %kw_table lparen array_of[func_ret_table_col] rparen {% x => track(x, {
|
|
82
|
+
kind: 'table',
|
|
83
|
+
columns: x[3],
|
|
84
|
+
}) %}
|
|
85
|
+
|
|
86
|
+
func_ret_table_col -> word data_type {% x => track(x, {name: asName(x[0]), type: x[1]}) %}
|
|
87
|
+
|
|
88
|
+
# https://www.postgresql.org/docs/13/sql-do.html
|
|
89
|
+
do_stm -> %kw_do (kw_language word {% last %}):? %codeblock {% x => track(x, {
|
|
90
|
+
type: 'do',
|
|
91
|
+
...x[1] && { language: asName(x[1])},
|
|
92
|
+
code: x[2].value,
|
|
93
|
+
}) %}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
drop_func -> kw_drop
|
|
98
|
+
kw_function
|
|
99
|
+
(kw_if kw_exists):?
|
|
100
|
+
qname
|
|
101
|
+
drop_func_overload:? {% x => track(x, {
|
|
102
|
+
type: 'drop function',
|
|
103
|
+
...x[2] && {ifExists: true},
|
|
104
|
+
name: x[3],
|
|
105
|
+
...x[4] && {arguments: x[4]},
|
|
106
|
+
}) %}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
drop_func_overload -> lparen array_of[drop_func_overload_col] rparen {% get(1) %}
|
|
110
|
+
|
|
111
|
+
drop_func_overload_col -> word:? qname {% x => track(x, {
|
|
112
|
+
type: x[1],
|
|
113
|
+
... x[0] && {name: asName(x[0])},
|
|
114
|
+
}) %}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import 'chai';
|
|
3
|
+
import { checkInvalid, checkStatement } from './spec-utils';
|
|
4
|
+
import { CreateFunctionStatement } from './ast';
|
|
5
|
+
import { parse } from '../parser';
|
|
6
|
+
import { expect } from 'chai';
|
|
7
|
+
|
|
8
|
+
describe('Create function', () => {
|
|
9
|
+
|
|
10
|
+
const integer = { name: 'integer' };
|
|
11
|
+
const int = { name: 'int' };
|
|
12
|
+
const text = { name: 'text' };
|
|
13
|
+
|
|
14
|
+
checkStatement(`CREATE FUNCTION add(integer, integer) RETURNS integer
|
|
15
|
+
AS 'select $1 + $2;'
|
|
16
|
+
LANGUAGE SQL
|
|
17
|
+
IMMUTABLE
|
|
18
|
+
RETURNS NULL ON NULL INPUT`, {
|
|
19
|
+
type: 'create function',
|
|
20
|
+
name: { name: 'add' },
|
|
21
|
+
arguments: [{ type: integer }, { type: integer }],
|
|
22
|
+
code: 'select $1 + $2;',
|
|
23
|
+
language: { name: 'sql' },
|
|
24
|
+
purity: 'immutable',
|
|
25
|
+
onNullInput: 'null',
|
|
26
|
+
returns: integer,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// modifiers BEFORE code block
|
|
30
|
+
checkStatement(`CREATE FUNCTION add(integer, integer) RETURNS integer stable
|
|
31
|
+
LANGUAGE SQL RETURNS NULL ON NULL INPUT
|
|
32
|
+
AS 'select $1 + $2;'
|
|
33
|
+
`, {
|
|
34
|
+
type: 'create function',
|
|
35
|
+
name: { name: 'add' },
|
|
36
|
+
arguments: [{ type: integer }, { type: integer }],
|
|
37
|
+
code: 'select $1 + $2;',
|
|
38
|
+
language: { name: 'sql' },
|
|
39
|
+
purity: 'stable',
|
|
40
|
+
onNullInput: 'null',
|
|
41
|
+
returns: integer,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// duplicate modifiers
|
|
45
|
+
checkInvalid(`CREATE FUNCTION add(integer, integer) RETURNS integer stable
|
|
46
|
+
LANGUAGE SQL STABLE
|
|
47
|
+
AS 'select $1 + $2;'
|
|
48
|
+
`);
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
checkStatement(`CREATE FUNCTION fn(in integer) RETURNS INTeger AS 'code' LANGUAGE SQL`, {
|
|
54
|
+
type: 'create function',
|
|
55
|
+
name: { name: 'fn' },
|
|
56
|
+
arguments: [{ type: integer, mode: 'in' }],
|
|
57
|
+
code: 'code',
|
|
58
|
+
returns: integer,
|
|
59
|
+
language: { name: 'sql' },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
checkStatement(`CREATE FUNCTION fn(i integer = 2) AS 'code' LANGUAGE SQL returns integer`, {
|
|
63
|
+
type: 'create function',
|
|
64
|
+
name: { name: 'fn' },
|
|
65
|
+
arguments: [{ type: integer, name: { name: 'i' }, default: { type: 'integer', value: 2 } }],
|
|
66
|
+
code: 'code',
|
|
67
|
+
returns: integer,
|
|
68
|
+
language: { name: 'sql' },
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
checkStatement(`CREATE FUNCTION fn(in out integer) returns integer AS 'code' LANGUAGE SQL`, {
|
|
72
|
+
type: 'create function',
|
|
73
|
+
name: { name: 'fn' },
|
|
74
|
+
arguments: [{ type: integer, mode: 'in', name: { name: 'out' } }],
|
|
75
|
+
code: 'code',
|
|
76
|
+
returns: integer,
|
|
77
|
+
language: { name: 'sql' },
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
checkStatement(`CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer AS $$BEGIN
|
|
81
|
+
RETURN i + 1;
|
|
82
|
+
END;$$ VOLATILE LANGUAGE plpgsql`, {
|
|
83
|
+
type: 'create function',
|
|
84
|
+
name: { name: 'increment' },
|
|
85
|
+
orReplace: true,
|
|
86
|
+
arguments: [{ type: integer, name: { name: 'i' } }],
|
|
87
|
+
returns: integer,
|
|
88
|
+
language: { name: 'plpgsql' },
|
|
89
|
+
purity: 'volatile',
|
|
90
|
+
code: `BEGIN
|
|
91
|
+
RETURN i + 1;
|
|
92
|
+
END;`,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
checkStatement(`CREATE FUNCTION dup(in int, out f1 int, out f2 text) returns integer
|
|
96
|
+
AS $$SELECT $1, CAST($1 AS text) || ' is text'$$
|
|
97
|
+
LANGUAGE SQL`, {
|
|
98
|
+
type: 'create function',
|
|
99
|
+
name: { name: 'dup' },
|
|
100
|
+
language: { name: 'sql' },
|
|
101
|
+
returns: integer,
|
|
102
|
+
arguments: [{
|
|
103
|
+
type: int,
|
|
104
|
+
mode: 'in',
|
|
105
|
+
}, {
|
|
106
|
+
type: int,
|
|
107
|
+
name: { name: 'f1' },
|
|
108
|
+
mode: 'out',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: text,
|
|
112
|
+
name: { name: 'f2' },
|
|
113
|
+
mode: 'out',
|
|
114
|
+
}],
|
|
115
|
+
code: `SELECT $1, CAST($1 AS text) || ' is text'`,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
checkStatement(`CREATE FUNCTION public.dup(int) RETURNS TABLE(f1 int, f2 text)
|
|
119
|
+
AS $$SELECT $1, CAST($1 AS text) || ' is text'$$
|
|
120
|
+
LANGUAGE SQL`, {
|
|
121
|
+
type: 'create function',
|
|
122
|
+
name: { name: 'dup', schema: 'public', },
|
|
123
|
+
language: { name: 'sql' },
|
|
124
|
+
arguments: [{ type: int }],
|
|
125
|
+
code: `SELECT $1, CAST($1 AS text) || ' is text'`,
|
|
126
|
+
returns: {
|
|
127
|
+
kind: 'table',
|
|
128
|
+
columns: [{
|
|
129
|
+
name: { name: 'f1' },
|
|
130
|
+
type: int
|
|
131
|
+
}, {
|
|
132
|
+
name: { name: 'f2' },
|
|
133
|
+
type: text,
|
|
134
|
+
}],
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const simple: CreateFunctionStatement = {
|
|
140
|
+
type: 'create function',
|
|
141
|
+
name: { name: 'fn' },
|
|
142
|
+
language: { name: 'sql' },
|
|
143
|
+
returns: integer,
|
|
144
|
+
arguments: [],
|
|
145
|
+
code: `body`,
|
|
146
|
+
};
|
|
147
|
+
const simpleSt = (x: string) => [
|
|
148
|
+
`CREATE FUNCTION fn() AS 'body' returns integer LANGUAGE SQL ${x}`,
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
checkStatement(`CREATE FUNCTION fn() AS 'body' returns integer LEAKPROOF LANGUAGE SQL `, {
|
|
153
|
+
...simple,
|
|
154
|
+
leakproof: true,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
checkStatement(simpleSt(`NOT LEAKPROOF`), {
|
|
158
|
+
...simple,
|
|
159
|
+
leakproof: false,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
checkStatement(simpleSt(`CALLED ON NULL INPUT`), {
|
|
163
|
+
...simple,
|
|
164
|
+
onNullInput: 'call',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
checkStatement(simpleSt(`RETURNS NULL ON NULL INPUT`), {
|
|
168
|
+
...simple,
|
|
169
|
+
onNullInput: 'null',
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
checkStatement(simpleSt(`STRICT`), {
|
|
173
|
+
...simple,
|
|
174
|
+
onNullInput: 'strict',
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
checkStatement(`do $$ something $$`, {
|
|
179
|
+
type: 'do',
|
|
180
|
+
code: ' something ',
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
checkStatement(`do language js $$ something $$`, {
|
|
184
|
+
type: 'do',
|
|
185
|
+
language: { name: 'js' },
|
|
186
|
+
code: ' something ',
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
it('is not greedy', () => {
|
|
191
|
+
const parsed = parse(`create function foo() returns text as $$ select 'hi'; $$ language sql;
|
|
192
|
+
create function bar() returns text as $$ select 'there'; $$ language sql;`);
|
|
193
|
+
expect(parsed.length).to.equal(2);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
checkStatement('drop function my_function', {
|
|
197
|
+
type: 'drop function',
|
|
198
|
+
name: { name: 'my_function' },
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
checkStatement('drop function if exists my_function', {
|
|
202
|
+
type: 'drop function',
|
|
203
|
+
ifExists: true,
|
|
204
|
+
name: { name: 'my_function' },
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
checkStatement('drop function my_function(text)', {
|
|
208
|
+
type: 'drop function',
|
|
209
|
+
name: { name: 'my_function' },
|
|
210
|
+
arguments: [{ type: { name: 'text' } }]
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
checkStatement('drop function my_function(text, float)', {
|
|
214
|
+
type: 'drop function',
|
|
215
|
+
name: { name: 'my_function' },
|
|
216
|
+
arguments: [{
|
|
217
|
+
type: { name: 'text' },
|
|
218
|
+
}, {
|
|
219
|
+
type: { name: 'float' },
|
|
220
|
+
}]
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
checkStatement('drop function my_function(txt text, fl float)', {
|
|
225
|
+
type: 'drop function',
|
|
226
|
+
name: { name: 'my_function' },
|
|
227
|
+
arguments: [{
|
|
228
|
+
type: { name: 'text' },
|
|
229
|
+
name: { name: 'txt' },
|
|
230
|
+
}, {
|
|
231
|
+
type: { name: 'float' },
|
|
232
|
+
name: { name: 'fl' },
|
|
233
|
+
}]
|
|
234
|
+
});
|
|
235
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@lexer lexerAny
|
|
2
|
+
@include "base.ne"
|
|
3
|
+
@include "expr.ne"
|
|
4
|
+
@include "select.ne"
|
|
5
|
+
|
|
6
|
+
insert_statement -> (kw_insert %kw_into)
|
|
7
|
+
table_ref_aliased
|
|
8
|
+
collist_paren:?
|
|
9
|
+
(kw_overriding (kw_system | %kw_user) kw_value {% get(1) %}):?
|
|
10
|
+
(selection | selection_paren):?
|
|
11
|
+
(%kw_on kw_conflict insert_on_conflict {% last %}):?
|
|
12
|
+
(%kw_returning select_expr_list_aliased {% last %}):?
|
|
13
|
+
{% x => {
|
|
14
|
+
const columns = x[2] && x[2].map(asName);
|
|
15
|
+
const overriding = toStr(x[3]);
|
|
16
|
+
const insert = unwrap(x[4]);
|
|
17
|
+
const onConflict = x[5];
|
|
18
|
+
const returning = x[6];
|
|
19
|
+
return track(x, {
|
|
20
|
+
type: 'insert',
|
|
21
|
+
into: unwrap(x[1]),
|
|
22
|
+
insert,
|
|
23
|
+
...overriding && { overriding },
|
|
24
|
+
...columns && { columns },
|
|
25
|
+
...returning && { returning },
|
|
26
|
+
...onConflict && { onConflict },
|
|
27
|
+
})
|
|
28
|
+
} %}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
insert_values -> insert_value (comma insert_value {% last %}):* {% ([head, tail]) => {
|
|
32
|
+
return [head, ...(tail || [])];
|
|
33
|
+
} %}
|
|
34
|
+
|
|
35
|
+
insert_value -> lparen insert_expr_list_raw rparen {% get(1) %}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
insert_expr_list_raw -> expr_or_select (comma expr_or_select {% last %}):* {% ([head, tail]) => {
|
|
39
|
+
return [head, ...(tail || [])];
|
|
40
|
+
} %}
|
|
41
|
+
|
|
42
|
+
insert_on_conflict
|
|
43
|
+
-> insert_on_conflict_what:? insert_on_conflict_do {% x => track(x, {
|
|
44
|
+
...x[0] ? { on: unwrap(x[0]) } : {},
|
|
45
|
+
...x[1],
|
|
46
|
+
}) %}
|
|
47
|
+
|
|
48
|
+
insert_on_conflict_what
|
|
49
|
+
-> lparen expr_list_raw rparen {% x => track(x, {
|
|
50
|
+
type: 'on expr',
|
|
51
|
+
exprs: x[1],
|
|
52
|
+
}) %}
|
|
53
|
+
| %kw_on %kw_constraint qname {% x => track(x, {
|
|
54
|
+
type: 'on constraint',
|
|
55
|
+
constraint: last(x),
|
|
56
|
+
}) %}
|
|
57
|
+
|
|
58
|
+
insert_on_conflict_do
|
|
59
|
+
-> %kw_do kw_nothing {% x => ({ do: 'do nothing' }) %}
|
|
60
|
+
| (%kw_do kw_update kw_set) update_set_list (%kw_where expr {% last %}):? {% x => ({
|
|
61
|
+
do: { sets: x[1] },
|
|
62
|
+
...x[2] && { where: x[2] },
|
|
63
|
+
}) %}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import 'chai';
|
|
3
|
+
import { checkInsert, checkInsertLoc, tbl } from './spec-utils';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
describe('Insert', () => {
|
|
7
|
+
|
|
8
|
+
checkInsert([`insert into test(a, b) values (1, 'x')`, `INSERT INTO"test"(a,"b")VALUES(1,'x')`], {
|
|
9
|
+
type: 'insert',
|
|
10
|
+
into: { name: 'test' },
|
|
11
|
+
columns: [{ name: 'a' }, { name: 'b' }],
|
|
12
|
+
insert: {
|
|
13
|
+
type: 'values',
|
|
14
|
+
values: [[{
|
|
15
|
+
type: 'integer',
|
|
16
|
+
value: 1,
|
|
17
|
+
}, {
|
|
18
|
+
type: 'string',
|
|
19
|
+
value: 'x',
|
|
20
|
+
}]]
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
checkInsertLoc([`insert into test(a) values (1)`], {
|
|
25
|
+
_location: { start: 0, end: 29 },
|
|
26
|
+
type: 'insert',
|
|
27
|
+
into: {
|
|
28
|
+
_location: { start: 12, end: 16 },
|
|
29
|
+
name: 'test',
|
|
30
|
+
},
|
|
31
|
+
columns: [{
|
|
32
|
+
_location: { start: 17, end: 18 },
|
|
33
|
+
name: 'a'
|
|
34
|
+
}],
|
|
35
|
+
insert: {
|
|
36
|
+
_location: { start: 20, end: 29 },
|
|
37
|
+
type: 'values',
|
|
38
|
+
values: [[{
|
|
39
|
+
_location: { start: 28, end: 29 },
|
|
40
|
+
type: 'integer',
|
|
41
|
+
value: 1,
|
|
42
|
+
},]]
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
checkInsert([`insert into test(a) values (1) on conflict do nothing`], {
|
|
47
|
+
type: 'insert',
|
|
48
|
+
into: { name: 'test' },
|
|
49
|
+
columns: [{ name: 'a' }],
|
|
50
|
+
insert: {
|
|
51
|
+
type: 'values',
|
|
52
|
+
values: [[{
|
|
53
|
+
type: 'integer',
|
|
54
|
+
value: 1,
|
|
55
|
+
},]]
|
|
56
|
+
},
|
|
57
|
+
onConflict: {
|
|
58
|
+
do: 'do nothing',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
checkInsert([`insert into test(a) values (1) on conflict on constraint cst do nothing`], {
|
|
63
|
+
type: 'insert',
|
|
64
|
+
into: { name: 'test' },
|
|
65
|
+
columns: [{ name: 'a' }],
|
|
66
|
+
insert: {
|
|
67
|
+
type: 'values',
|
|
68
|
+
values: [[{
|
|
69
|
+
type: 'integer',
|
|
70
|
+
value: 1,
|
|
71
|
+
},]]
|
|
72
|
+
},
|
|
73
|
+
onConflict: {
|
|
74
|
+
do: 'do nothing',
|
|
75
|
+
on: {
|
|
76
|
+
type: 'on constraint',
|
|
77
|
+
constraint: { name: 'cst' },
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
checkInsert([`insert into test(a) values (1) on conflict (a, b) do nothing`], {
|
|
83
|
+
type: 'insert',
|
|
84
|
+
into: { name: 'test' },
|
|
85
|
+
columns: [{ name: 'a' }],
|
|
86
|
+
insert: {
|
|
87
|
+
type: 'values',
|
|
88
|
+
values: [[{
|
|
89
|
+
type: 'integer',
|
|
90
|
+
value: 1,
|
|
91
|
+
},]]
|
|
92
|
+
},
|
|
93
|
+
onConflict: {
|
|
94
|
+
do: 'do nothing',
|
|
95
|
+
on: {
|
|
96
|
+
type: 'on expr',
|
|
97
|
+
exprs: [
|
|
98
|
+
{ type: 'ref', name: 'a' }
|
|
99
|
+
, { type: 'ref', name: 'b' }
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
checkInsert([`insert into test(a) values (1) on conflict do update set a=3`], {
|
|
106
|
+
type: 'insert',
|
|
107
|
+
into: { name: 'test' },
|
|
108
|
+
columns: [{ name: 'a' }],
|
|
109
|
+
insert: {
|
|
110
|
+
type: 'values',
|
|
111
|
+
values: [[{
|
|
112
|
+
type: 'integer',
|
|
113
|
+
value: 1,
|
|
114
|
+
},]]
|
|
115
|
+
},
|
|
116
|
+
onConflict: {
|
|
117
|
+
do: {
|
|
118
|
+
sets: [{
|
|
119
|
+
column: { name: 'a' },
|
|
120
|
+
value: { type: 'integer', value: 3 },
|
|
121
|
+
}]
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
checkInsert([`insert into test(a) values (1) on conflict do update set a=3 WHERE v`], {
|
|
128
|
+
type: 'insert',
|
|
129
|
+
into: { name: 'test' },
|
|
130
|
+
columns: [{ name: 'a' }],
|
|
131
|
+
insert: {
|
|
132
|
+
type: 'values',
|
|
133
|
+
values: [[{
|
|
134
|
+
type: 'integer',
|
|
135
|
+
value: 1,
|
|
136
|
+
},]]
|
|
137
|
+
},
|
|
138
|
+
onConflict: {
|
|
139
|
+
do: {
|
|
140
|
+
sets: [{
|
|
141
|
+
column: { name: 'a' },
|
|
142
|
+
value: { type: 'integer', value: 3 },
|
|
143
|
+
}]
|
|
144
|
+
},
|
|
145
|
+
where: { type: 'ref', name: 'v' },
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
checkInsert([`insert into test values (1) returning "id";`], {
|
|
150
|
+
type: 'insert',
|
|
151
|
+
into: { name: 'test' },
|
|
152
|
+
returning: [{ expr: { type: 'ref', name: 'id' } }],
|
|
153
|
+
insert: {
|
|
154
|
+
type: 'values',
|
|
155
|
+
values: [[{
|
|
156
|
+
type: 'integer',
|
|
157
|
+
value: 1,
|
|
158
|
+
},]]
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
checkInsert([`insert into test values (1) returning "id" as x;`], {
|
|
163
|
+
type: 'insert',
|
|
164
|
+
into: { name: 'test' },
|
|
165
|
+
returning: [{ expr: { type: 'ref', name: 'id' }, alias: { name: 'x' } }],
|
|
166
|
+
insert: {
|
|
167
|
+
type: 'values',
|
|
168
|
+
values: [[{
|
|
169
|
+
type: 'integer',
|
|
170
|
+
value: 1,
|
|
171
|
+
},]]
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
checkInsert([`insert into test values (1) returning "id", val;`], {
|
|
175
|
+
type: 'insert',
|
|
176
|
+
into: { name: 'test' },
|
|
177
|
+
returning: [{ expr: { type: 'ref', name: 'id' } }, { expr: { type: 'ref', name: 'val' } }],
|
|
178
|
+
insert: {
|
|
179
|
+
type: 'values',
|
|
180
|
+
values: [[{
|
|
181
|
+
type: 'integer',
|
|
182
|
+
value: 1,
|
|
183
|
+
},]]
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
checkInsert([`insert into db . test(a, b) values (1, 'x')`, `INSERT INTO"db"."test"(a,"b")VALUES(1,'x')`], {
|
|
188
|
+
type: 'insert',
|
|
189
|
+
into: { name: 'test', schema: 'db' },
|
|
190
|
+
columns: [{ name: 'a' }, { name: 'b' }],
|
|
191
|
+
insert: {
|
|
192
|
+
type: 'values',
|
|
193
|
+
values: [[{
|
|
194
|
+
type: 'integer',
|
|
195
|
+
value: 1,
|
|
196
|
+
}, {
|
|
197
|
+
type: 'string',
|
|
198
|
+
value: 'x',
|
|
199
|
+
}]]
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
checkInsert([`insert into db . test(a, b) select a,b FROM x . test`], {
|
|
206
|
+
type: 'insert',
|
|
207
|
+
into: { name: 'test', schema: 'db' },
|
|
208
|
+
columns: [{ name: 'a' }, { name: 'b' }],
|
|
209
|
+
insert: {
|
|
210
|
+
type: 'select',
|
|
211
|
+
from: [{
|
|
212
|
+
type: 'table',
|
|
213
|
+
name: {
|
|
214
|
+
name: 'test',
|
|
215
|
+
schema: 'x',
|
|
216
|
+
},
|
|
217
|
+
}],
|
|
218
|
+
columns: [{
|
|
219
|
+
expr: {
|
|
220
|
+
type: 'ref',
|
|
221
|
+
name: 'a',
|
|
222
|
+
}
|
|
223
|
+
}, {
|
|
224
|
+
expr: {
|
|
225
|
+
type: 'ref',
|
|
226
|
+
name: 'b',
|
|
227
|
+
}
|
|
228
|
+
}],
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
checkInsert([`insert into "test" select * FROM test`, `insert into test(select * FROM test)`], {
|
|
233
|
+
type: 'insert',
|
|
234
|
+
into: { name: 'test' },
|
|
235
|
+
insert: {
|
|
236
|
+
type: 'select',
|
|
237
|
+
from: [tbl('test')],
|
|
238
|
+
columns: [{
|
|
239
|
+
expr: {
|
|
240
|
+
type: 'ref',
|
|
241
|
+
name: '*',
|
|
242
|
+
}
|
|
243
|
+
}],
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
checkInsert([`insert into test(a, b) values (1, default)`], {
|
|
249
|
+
type: 'insert',
|
|
250
|
+
into: { name: 'test' },
|
|
251
|
+
columns: [{ name: 'a' }, { name: 'b' }],
|
|
252
|
+
insert: {
|
|
253
|
+
type: 'values',
|
|
254
|
+
values: [[{
|
|
255
|
+
type: 'integer',
|
|
256
|
+
value: 1,
|
|
257
|
+
}
|
|
258
|
+
, { type: 'default' }]]
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
checkInsert([`insert into test(a, b) overriding system value values (1, default)`], {
|
|
263
|
+
type: 'insert',
|
|
264
|
+
into: { name: 'test' },
|
|
265
|
+
columns: [{ name: 'a' }, { name: 'b' }],
|
|
266
|
+
overriding: 'system',
|
|
267
|
+
insert: {
|
|
268
|
+
type: 'values',
|
|
269
|
+
values: [[{
|
|
270
|
+
type: 'integer',
|
|
271
|
+
value: 1,
|
|
272
|
+
}
|
|
273
|
+
, { type: 'default' }]]
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
checkInsert([`insert into test(a, b) overriding user value values (1, default)`], {
|
|
279
|
+
type: 'insert',
|
|
280
|
+
into: { name: 'test' },
|
|
281
|
+
columns: [{ name: 'a' }, { name: 'b' }],
|
|
282
|
+
overriding: 'user',
|
|
283
|
+
insert: {
|
|
284
|
+
type: 'values',
|
|
285
|
+
values: [[{
|
|
286
|
+
type: 'integer',
|
|
287
|
+
value: 1,
|
|
288
|
+
}
|
|
289
|
+
, { type: 'default' }]]
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
});
|