wicked-crew 0.16.13 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -9
- package/dist/api/audit-view.d.ts +24 -0
- package/dist/api/audit-view.d.ts.map +1 -0
- package/dist/api/audit-view.js +70 -0
- package/dist/api/audit-view.js.map +1 -0
- package/dist/api/auth.d.ts +42 -2
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +157 -18
- package/dist/api/auth.js.map +1 -1
- package/dist/api/capture.d.ts +12 -59
- package/dist/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +9 -17
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-context.d.ts +6 -62
- package/dist/api/chat-context.d.ts.map +1 -1
- package/dist/api/chat-context.js +6 -12
- package/dist/api/chat-context.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +163 -0
- package/dist/api/chat-jobs.d.ts.map +1 -0
- package/dist/api/chat-jobs.js +767 -0
- package/dist/api/chat-jobs.js.map +1 -0
- package/dist/api/chat-mcp.d.ts +37 -0
- package/dist/api/chat-mcp.d.ts.map +1 -1
- package/dist/api/chat-mcp.js +118 -2
- package/dist/api/chat-mcp.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +170 -152
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +833 -15
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/delivery-assurance.d.ts +3 -1
- package/dist/api/delivery-assurance.d.ts.map +1 -1
- package/dist/api/delivery-assurance.js +20 -0
- package/dist/api/delivery-assurance.js.map +1 -1
- package/dist/api/delivery-freeze.d.ts +2 -8
- package/dist/api/delivery-freeze.d.ts.map +1 -1
- package/dist/api/delivery-freeze.js +2 -4
- package/dist/api/delivery-freeze.js.map +1 -1
- package/dist/api/eval-sample.d.ts +18 -114
- package/dist/api/eval-sample.d.ts.map +1 -1
- package/dist/api/eval-sample.js +7 -13
- package/dist/api/eval-sample.js.map +1 -1
- package/dist/api/governance-steering.d.ts +27 -71
- package/dist/api/governance-steering.d.ts.map +1 -1
- package/dist/api/governance-steering.js +11 -19
- package/dist/api/governance-steering.js.map +1 -1
- package/dist/api/mcp.d.ts +159 -199
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +433 -68
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.d.ts +10 -0
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +77 -0
- package/dist/api/needs.js.map +1 -1
- package/dist/api/open-path.d.ts +10 -0
- package/dist/api/open-path.d.ts.map +1 -1
- package/dist/api/open-path.js +58 -1
- package/dist/api/open-path.js.map +1 -1
- package/dist/api/plan-schema.d.ts +8 -51
- package/dist/api/plan-schema.d.ts.map +1 -1
- package/dist/api/plan-schema.js +6 -6
- package/dist/api/plan-schema.js.map +1 -1
- package/dist/api/product.d.ts +81 -23
- package/dist/api/product.d.ts.map +1 -1
- package/dist/api/product.js +149 -72
- package/dist/api/product.js.map +1 -1
- package/dist/api/project-aggregates.d.ts +12 -20
- package/dist/api/project-aggregates.d.ts.map +1 -1
- package/dist/api/project-aggregates.js +3 -3
- package/dist/api/project-aggregates.js.map +1 -1
- package/dist/api/recording.d.ts +69 -39
- package/dist/api/recording.d.ts.map +1 -1
- package/dist/api/recording.js +60 -49
- package/dist/api/recording.js.map +1 -1
- package/dist/api/routes.d.ts +229 -1506
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +1226 -169
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +12 -1
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +35 -0
- package/dist/api/run-timing-index.js.map +1 -1
- package/dist/api/seat-images.d.ts +10 -0
- package/dist/api/seat-images.d.ts.map +1 -1
- package/dist/api/seat-images.js +16 -3
- package/dist/api/seat-images.js.map +1 -1
- package/dist/api/server-error-body.d.ts +44 -0
- package/dist/api/server-error-body.d.ts.map +1 -0
- package/dist/api/server-error-body.js +206 -0
- package/dist/api/server-error-body.js.map +1 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +179 -4
- package/dist/api/server.js.map +1 -1
- package/dist/api/skills.d.ts +12 -36
- package/dist/api/skills.d.ts.map +1 -1
- package/dist/api/skills.js +12 -15
- package/dist/api/skills.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +1 -5
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +7 -15
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts +29 -50
- package/dist/api/testing.d.ts.map +1 -1
- package/dist/api/testing.js +7 -13
- package/dist/api/testing.js.map +1 -1
- package/dist/apps/actions/api-action.d.ts +47 -0
- package/dist/apps/actions/api-action.d.ts.map +1 -0
- package/dist/apps/actions/api-action.js +135 -0
- package/dist/apps/actions/api-action.js.map +1 -0
- package/dist/apps/actions/pg-fit.d.ts +27 -0
- package/dist/apps/actions/pg-fit.d.ts.map +1 -0
- package/dist/apps/actions/pg-fit.js +35 -0
- package/dist/apps/actions/pg-fit.js.map +1 -0
- package/dist/apps/actions/pg-write.d.ts +84 -0
- package/dist/apps/actions/pg-write.d.ts.map +1 -0
- package/dist/apps/actions/pg-write.js +161 -0
- package/dist/apps/actions/pg-write.js.map +1 -0
- package/dist/apps/actions/store.d.ts +109 -0
- package/dist/apps/actions/store.d.ts.map +1 -0
- package/dist/apps/actions/store.js +182 -0
- package/dist/apps/actions/store.js.map +1 -0
- package/dist/apps/actions/values.d.ts +59 -0
- package/dist/apps/actions/values.d.ts.map +1 -0
- package/dist/apps/actions/values.js +315 -0
- package/dist/apps/actions/values.js.map +1 -0
- package/dist/apps/actions/write-path.d.ts +103 -0
- package/dist/apps/actions/write-path.d.ts.map +1 -0
- package/dist/apps/actions/write-path.js +576 -0
- package/dist/apps/actions/write-path.js.map +1 -0
- package/dist/apps/check.d.ts +112 -0
- package/dist/apps/check.d.ts.map +1 -0
- package/dist/apps/check.js +358 -0
- package/dist/apps/check.js.map +1 -0
- package/dist/apps/exec/arg-types.d.ts +56 -0
- package/dist/apps/exec/arg-types.d.ts.map +1 -0
- package/dist/apps/exec/arg-types.js +234 -0
- package/dist/apps/exec/arg-types.js.map +1 -0
- package/dist/apps/exec/cache.d.ts +46 -0
- package/dist/apps/exec/cache.d.ts.map +1 -0
- package/dist/apps/exec/cache.js +93 -0
- package/dist/apps/exec/cache.js.map +1 -0
- package/dist/apps/exec/contract.d.ts +83 -0
- package/dist/apps/exec/contract.d.ts.map +1 -0
- package/dist/apps/exec/contract.js +220 -0
- package/dist/apps/exec/contract.js.map +1 -0
- package/dist/apps/exec/executor.d.ts +122 -0
- package/dist/apps/exec/executor.d.ts.map +1 -0
- package/dist/apps/exec/executor.js +455 -0
- package/dist/apps/exec/executor.js.map +1 -0
- package/dist/apps/exec/limits.d.ts +25 -0
- package/dist/apps/exec/limits.d.ts.map +1 -0
- package/dist/apps/exec/limits.js +71 -0
- package/dist/apps/exec/limits.js.map +1 -0
- package/dist/apps/exec/params.d.ts +34 -0
- package/dist/apps/exec/params.d.ts.map +1 -0
- package/dist/apps/exec/params.js +97 -0
- package/dist/apps/exec/params.js.map +1 -0
- package/dist/apps/exec/project.d.ts +67 -0
- package/dist/apps/exec/project.d.ts.map +1 -0
- package/dist/apps/exec/project.js +299 -0
- package/dist/apps/exec/project.js.map +1 -0
- package/dist/apps/exec/recall.d.ts +88 -0
- package/dist/apps/exec/recall.d.ts.map +1 -0
- package/dist/apps/exec/recall.js +301 -0
- package/dist/apps/exec/recall.js.map +1 -0
- package/dist/apps/exec/source-stage.d.ts +61 -0
- package/dist/apps/exec/source-stage.d.ts.map +1 -0
- package/dist/apps/exec/source-stage.js +540 -0
- package/dist/apps/exec/source-stage.js.map +1 -0
- package/dist/apps/exec/sources.d.ts +65 -0
- package/dist/apps/exec/sources.d.ts.map +1 -0
- package/dist/apps/exec/sources.js +77 -0
- package/dist/apps/exec/sources.js.map +1 -0
- package/dist/apps/exec/texts.d.ts +140 -0
- package/dist/apps/exec/texts.d.ts.map +1 -0
- package/dist/apps/exec/texts.js +76 -0
- package/dist/apps/exec/texts.js.map +1 -0
- package/dist/apps/exec/viewer.d.ts +11 -0
- package/dist/apps/exec/viewer.d.ts.map +1 -0
- package/dist/apps/exec/viewer.js +26 -0
- package/dist/apps/exec/viewer.js.map +1 -0
- package/dist/apps/git.d.ts +109 -0
- package/dist/apps/git.d.ts.map +1 -0
- package/dist/apps/git.js +361 -0
- package/dist/apps/git.js.map +1 -0
- package/dist/apps/publish/image.d.ts +25 -0
- package/dist/apps/publish/image.d.ts.map +1 -0
- package/dist/apps/publish/image.js +86 -0
- package/dist/apps/publish/image.js.map +1 -0
- package/dist/apps/publish/layout.d.ts +41 -0
- package/dist/apps/publish/layout.d.ts.map +1 -0
- package/dist/apps/publish/layout.js +31 -0
- package/dist/apps/publish/layout.js.map +1 -0
- package/dist/apps/publish/manifest.d.ts +64 -0
- package/dist/apps/publish/manifest.d.ts.map +1 -0
- package/dist/apps/publish/manifest.js +282 -0
- package/dist/apps/publish/manifest.js.map +1 -0
- package/dist/apps/publish/pack.d.ts +40 -0
- package/dist/apps/publish/pack.d.ts.map +1 -0
- package/dist/apps/publish/pack.js +78 -0
- package/dist/apps/publish/pack.js.map +1 -0
- package/dist/apps/routes.d.ts +103 -0
- package/dist/apps/routes.d.ts.map +1 -0
- package/dist/apps/routes.js +440 -0
- package/dist/apps/routes.js.map +1 -0
- package/dist/apps/spec.d.ts +322 -2640
- package/dist/apps/spec.d.ts.map +1 -1
- package/dist/apps/spec.js +89 -120
- package/dist/apps/spec.js.map +1 -1
- package/dist/apps/store.d.ts +341 -0
- package/dist/apps/store.d.ts.map +1 -0
- package/dist/apps/store.js +905 -0
- package/dist/apps/store.js.map +1 -0
- package/dist/apps/turns.d.ts +169 -0
- package/dist/apps/turns.d.ts.map +1 -0
- package/dist/apps/turns.js +556 -0
- package/dist/apps/turns.js.map +1 -0
- package/dist/apps/views.d.ts +44 -0
- package/dist/apps/views.d.ts.map +1 -0
- package/dist/apps/views.js +53 -0
- package/dist/apps/views.js.map +1 -0
- package/dist/campaigns/routes.d.ts +22 -94
- package/dist/campaigns/routes.d.ts.map +1 -1
- package/dist/campaigns/routes.js +8 -14
- package/dist/campaigns/routes.js.map +1 -1
- package/dist/cli/apps-check.d.ts +43 -0
- package/dist/cli/apps-check.d.ts.map +1 -0
- package/dist/cli/apps-check.js +166 -0
- package/dist/cli/apps-check.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.js +2 -2
- package/dist/cli/mcp.js.map +1 -1
- package/dist/core/adapter.d.ts +34 -1
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +78 -2
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/builtin-catalog.d.ts.map +1 -1
- package/dist/core/builtin-catalog.js +2 -0
- package/dist/core/builtin-catalog.js.map +1 -1
- package/dist/core/deliver-text.d.ts +62 -1
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +244 -22
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +30 -3
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/estate-mcp-client.d.ts +9 -0
- package/dist/core/estate-mcp-client.d.ts.map +1 -1
- package/dist/core/estate-mcp-client.js +31 -3
- package/dist/core/estate-mcp-client.js.map +1 -1
- package/dist/core/linked-issues.d.ts +51 -3
- package/dist/core/linked-issues.d.ts.map +1 -1
- package/dist/core/linked-issues.js +59 -14
- package/dist/core/linked-issues.js.map +1 -1
- package/dist/core/qe-acceptance-setting.d.ts.map +1 -1
- package/dist/core/qe-acceptance-setting.js +6 -0
- package/dist/core/qe-acceptance-setting.js.map +1 -1
- package/dist/decisions/chat-recorder.js +1 -1
- package/dist/decisions/chat-recorder.js.map +1 -1
- package/dist/decisions/routes.d.ts.map +1 -1
- package/dist/decisions/routes.js +5 -9
- package/dist/decisions/routes.js.map +1 -1
- package/dist/decisions/rules-brief.d.ts +76 -0
- package/dist/decisions/rules-brief.d.ts.map +1 -0
- package/dist/decisions/rules-brief.js +179 -0
- package/dist/decisions/rules-brief.js.map +1 -0
- package/dist/editors/registry.d.ts +97 -258
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +11 -11
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.js +3 -3
- package/dist/editors/routes.js.map +1 -1
- package/dist/evals/routes.d.ts.map +1 -1
- package/dist/evals/routes.js +3 -5
- package/dist/evals/routes.js.map +1 -1
- package/dist/insights/routes.js +2 -2
- package/dist/insights/routes.js.map +1 -1
- package/dist/interactive/proxy-routes.d.ts.map +1 -1
- package/dist/interactive/proxy-routes.js +76 -7
- package/dist/interactive/proxy-routes.js.map +1 -1
- package/dist/interactive/ws-relay.d.ts +3 -9
- package/dist/interactive/ws-relay.d.ts.map +1 -1
- package/dist/interactive/ws-relay.js +4 -6
- package/dist/interactive/ws-relay.js.map +1 -1
- package/dist/knowledge/adapters/native.d.ts +44 -0
- package/dist/knowledge/adapters/native.d.ts.map +1 -0
- package/dist/knowledge/adapters/native.js +60 -0
- package/dist/knowledge/adapters/native.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/binary.d.ts +48 -0
- package/dist/knowledge/adapters/toolbox/binary.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/binary.js +145 -0
- package/dist/knowledge/adapters/toolbox/binary.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/catalog.d.ts +22 -0
- package/dist/knowledge/adapters/toolbox/catalog.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/catalog.js +87 -0
- package/dist/knowledge/adapters/toolbox/catalog.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/document.d.ts +71 -0
- package/dist/knowledge/adapters/toolbox/document.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/document.js +165 -0
- package/dist/knowledge/adapters/toolbox/document.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts +142 -0
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/supervisor.js +438 -0
- package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -0
- package/dist/knowledge/gate/access.d.ts +36 -0
- package/dist/knowledge/gate/access.d.ts.map +1 -0
- package/dist/knowledge/gate/access.js +46 -0
- package/dist/knowledge/gate/access.js.map +1 -0
- package/dist/knowledge/gate/envelope.d.ts +67 -0
- package/dist/knowledge/gate/envelope.d.ts.map +1 -0
- package/dist/knowledge/gate/envelope.js +96 -0
- package/dist/knowledge/gate/envelope.js.map +1 -0
- package/dist/knowledge/gate/gate.d.ts +238 -0
- package/dist/knowledge/gate/gate.d.ts.map +1 -0
- package/dist/knowledge/gate/gate.js +782 -0
- package/dist/knowledge/gate/gate.js.map +1 -0
- package/dist/knowledge/gate/pg.d.ts +57 -0
- package/dist/knowledge/gate/pg.d.ts.map +1 -0
- package/dist/knowledge/gate/pg.js +94 -0
- package/dist/knowledge/gate/pg.js.map +1 -0
- package/dist/knowledge/gate/record.d.ts +77 -0
- package/dist/knowledge/gate/record.d.ts.map +1 -0
- package/dist/knowledge/gate/record.js +205 -0
- package/dist/knowledge/gate/record.js.map +1 -0
- package/dist/knowledge/gate/routes.d.ts +38 -0
- package/dist/knowledge/gate/routes.d.ts.map +1 -0
- package/dist/knowledge/gate/routes.js +102 -0
- package/dist/knowledge/gate/routes.js.map +1 -0
- package/dist/knowledge/gate/scheduler.d.ts +90 -0
- package/dist/knowledge/gate/scheduler.d.ts.map +1 -0
- package/dist/knowledge/gate/scheduler.js +224 -0
- package/dist/knowledge/gate/scheduler.js.map +1 -0
- package/dist/knowledge/gate/sources.d.ts +69 -0
- package/dist/knowledge/gate/sources.d.ts.map +1 -0
- package/dist/knowledge/gate/sources.js +135 -0
- package/dist/knowledge/gate/sources.js.map +1 -0
- package/dist/knowledge/package.d.ts +136 -0
- package/dist/knowledge/package.d.ts.map +1 -0
- package/dist/knowledge/package.js +148 -0
- package/dist/knowledge/package.js.map +1 -0
- package/dist/knowledge/projector.d.ts +144 -0
- package/dist/knowledge/projector.d.ts.map +1 -0
- package/dist/knowledge/projector.js +287 -0
- package/dist/knowledge/projector.js.map +1 -0
- package/dist/knowledge/registry/entry.d.ts +177 -0
- package/dist/knowledge/registry/entry.d.ts.map +1 -0
- package/dist/knowledge/registry/entry.js +126 -0
- package/dist/knowledge/registry/entry.js.map +1 -0
- package/dist/knowledge/registry/policy.d.ts +79 -0
- package/dist/knowledge/registry/policy.d.ts.map +1 -0
- package/dist/knowledge/registry/policy.js +139 -0
- package/dist/knowledge/registry/policy.js.map +1 -0
- package/dist/knowledge/shapes/code-search.d.ts +55 -0
- package/dist/knowledge/shapes/code-search.d.ts.map +1 -0
- package/dist/knowledge/shapes/code-search.js +88 -0
- package/dist/knowledge/shapes/code-search.js.map +1 -0
- package/dist/knowledge/shapes/map.d.ts +25 -0
- package/dist/knowledge/shapes/map.d.ts.map +1 -0
- package/dist/knowledge/shapes/map.js +187 -0
- package/dist/knowledge/shapes/map.js.map +1 -0
- package/dist/knowledge/shapes/profile.d.ts +117 -0
- package/dist/knowledge/shapes/profile.d.ts.map +1 -0
- package/dist/knowledge/shapes/profile.js +264 -0
- package/dist/knowledge/shapes/profile.js.map +1 -0
- package/dist/knowledge/shapes/routes.d.ts +69 -0
- package/dist/knowledge/shapes/routes.d.ts.map +1 -0
- package/dist/knowledge/shapes/routes.js +270 -0
- package/dist/knowledge/shapes/routes.js.map +1 -0
- package/dist/knowledge/shapes/shapes.d.ts +144 -0
- package/dist/knowledge/shapes/shapes.d.ts.map +1 -0
- package/dist/knowledge/shapes/shapes.js +280 -0
- package/dist/knowledge/shapes/shapes.js.map +1 -0
- package/dist/knowledge/shapes/verified.d.ts +36 -0
- package/dist/knowledge/shapes/verified.d.ts.map +1 -0
- package/dist/knowledge/shapes/verified.js +73 -0
- package/dist/knowledge/shapes/verified.js.map +1 -0
- package/dist/knowledge/summary.d.ts +45 -0
- package/dist/knowledge/summary.d.ts.map +1 -0
- package/dist/knowledge/summary.js +119 -0
- package/dist/knowledge/summary.js.map +1 -0
- package/dist/knowledge/trackers/actions.d.ts +55 -0
- package/dist/knowledge/trackers/actions.d.ts.map +1 -0
- package/dist/knowledge/trackers/actions.js +327 -0
- package/dist/knowledge/trackers/actions.js.map +1 -0
- package/dist/knowledge/trackers/addresses.d.ts +45 -0
- package/dist/knowledge/trackers/addresses.d.ts.map +1 -0
- package/dist/knowledge/trackers/addresses.js +59 -0
- package/dist/knowledge/trackers/addresses.js.map +1 -0
- package/dist/knowledge/trackers/bindings.d.ts +190 -0
- package/dist/knowledge/trackers/bindings.d.ts.map +1 -0
- package/dist/knowledge/trackers/bindings.js +970 -0
- package/dist/knowledge/trackers/bindings.js.map +1 -0
- package/dist/knowledge/trackers/gate-pm.d.ts +160 -0
- package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -0
- package/dist/knowledge/trackers/gate-pm.js +427 -0
- package/dist/knowledge/trackers/gate-pm.js.map +1 -0
- package/dist/knowledge/trackers/issues.d.ts +69 -0
- package/dist/knowledge/trackers/issues.d.ts.map +1 -0
- package/dist/knowledge/trackers/issues.js +193 -0
- package/dist/knowledge/trackers/issues.js.map +1 -0
- package/dist/knowledge/trackers/map.d.ts +23 -0
- package/dist/knowledge/trackers/map.d.ts.map +1 -0
- package/dist/knowledge/trackers/map.js +130 -0
- package/dist/knowledge/trackers/map.js.map +1 -0
- package/dist/knowledge/trackers/projector.d.ts +113 -0
- package/dist/knowledge/trackers/projector.d.ts.map +1 -0
- package/dist/knowledge/trackers/projector.js +274 -0
- package/dist/knowledge/trackers/projector.js.map +1 -0
- package/dist/knowledge/trackers/routes.d.ts +107 -0
- package/dist/knowledge/trackers/routes.d.ts.map +1 -0
- package/dist/knowledge/trackers/routes.js +563 -0
- package/dist/knowledge/trackers/routes.js.map +1 -0
- package/dist/knowledge/trackers/set.d.ts +61 -0
- package/dist/knowledge/trackers/set.d.ts.map +1 -0
- package/dist/knowledge/trackers/set.js +77 -0
- package/dist/knowledge/trackers/set.js.map +1 -0
- package/dist/knowledge/trackers/view.d.ts +22 -0
- package/dist/knowledge/trackers/view.d.ts.map +1 -0
- package/dist/knowledge/trackers/view.js +31 -0
- package/dist/knowledge/trackers/view.js.map +1 -0
- package/dist/knowledge/trackers/visible.d.ts +9 -0
- package/dist/knowledge/trackers/visible.d.ts.map +1 -0
- package/dist/knowledge/trackers/visible.js +10 -0
- package/dist/knowledge/trackers/visible.js.map +1 -0
- package/dist/learn/routes.d.ts +3 -17
- package/dist/learn/routes.d.ts.map +1 -1
- package/dist/learn/routes.js +4 -6
- package/dist/learn/routes.js.map +1 -1
- package/dist/mcp/ask-server.d.ts +6 -0
- package/dist/mcp/ask-server.d.ts.map +1 -1
- package/dist/mcp/ask-server.js +15 -9
- package/dist/mcp/ask-server.js.map +1 -1
- package/dist/mcp/broker.d.ts +16 -0
- package/dist/mcp/broker.d.ts.map +1 -1
- package/dist/mcp/broker.js +137 -3
- package/dist/mcp/broker.js.map +1 -1
- package/dist/mcp/estate-relay.d.ts +50 -2
- package/dist/mcp/estate-relay.d.ts.map +1 -1
- package/dist/mcp/estate-relay.js +126 -4
- package/dist/mcp/estate-relay.js.map +1 -1
- package/dist/mcp/invoke.d.ts +12 -1
- package/dist/mcp/invoke.d.ts.map +1 -1
- package/dist/mcp/invoke.js +5 -2
- package/dist/mcp/invoke.js.map +1 -1
- package/dist/mcp/probe.d.ts +34 -2
- package/dist/mcp/probe.d.ts.map +1 -1
- package/dist/mcp/probe.js +51 -9
- package/dist/mcp/probe.js.map +1 -1
- package/dist/mcp/registry-store.d.ts +91 -0
- package/dist/mcp/registry-store.d.ts.map +1 -1
- package/dist/mcp/registry-store.js +116 -9
- package/dist/mcp/registry-store.js.map +1 -1
- package/dist/mcp/registry.d.ts +249 -6
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +735 -35
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/rest.d.ts +36 -10
- package/dist/mcp/rest.d.ts.map +1 -1
- package/dist/mcp/rest.js +71 -73
- package/dist/mcp/rest.js.map +1 -1
- package/dist/mcp/tool-list.d.ts +7 -0
- package/dist/mcp/tool-list.d.ts.map +1 -1
- package/dist/mcp/tool-list.js +32 -4
- package/dist/mcp/tool-list.js.map +1 -1
- package/dist/mcp-inspect/routes.d.ts +3 -0
- package/dist/mcp-inspect/routes.d.ts.map +1 -1
- package/dist/mcp-inspect/routes.js +31 -18
- package/dist/mcp-inspect/routes.js.map +1 -1
- package/dist/persona/routes.d.ts +14 -69
- package/dist/persona/routes.d.ts.map +1 -1
- package/dist/persona/routes.js +2 -2
- package/dist/persona/routes.js.map +1 -1
- package/dist/persona/store.d.ts +13 -40
- package/dist/persona/store.d.ts.map +1 -1
- package/dist/persona/store.js +9 -11
- package/dist/persona/store.js.map +1 -1
- package/dist/presets/routes.d.ts +3 -21
- package/dist/presets/routes.d.ts.map +1 -1
- package/dist/presets/routes.js +5 -7
- package/dist/presets/routes.js.map +1 -1
- package/dist/projects/repo-guard.d.ts +32 -0
- package/dist/projects/repo-guard.d.ts.map +1 -0
- package/dist/projects/repo-guard.js +46 -0
- package/dist/projects/repo-guard.js.map +1 -0
- package/dist/projects/routes.d.ts +16 -44
- package/dist/projects/routes.d.ts.map +1 -1
- package/dist/projects/routes.js +15 -18
- package/dist/projects/routes.js.map +1 -1
- package/dist/schedules/routes.d.ts +4 -18
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +4 -6
- package/dist/schedules/routes.js.map +1 -1
- package/dist/skills/plugin-source.d.ts +6 -5
- package/dist/skills/plugin-source.d.ts.map +1 -1
- package/dist/skills/plugin-source.js +6 -5
- package/dist/skills/plugin-source.js.map +1 -1
- package/dist/sources/ask.d.ts +108 -0
- package/dist/sources/ask.d.ts.map +1 -0
- package/dist/sources/ask.js +251 -0
- package/dist/sources/ask.js.map +1 -0
- package/dist/sources/catalog/mysql.d.ts +9 -0
- package/dist/sources/catalog/mysql.d.ts.map +1 -0
- package/dist/sources/catalog/mysql.js +77 -0
- package/dist/sources/catalog/mysql.js.map +1 -0
- package/dist/sources/catalog/postgres.d.ts +68 -0
- package/dist/sources/catalog/postgres.d.ts.map +1 -0
- package/dist/sources/catalog/postgres.js +164 -0
- package/dist/sources/catalog/postgres.js.map +1 -0
- package/dist/sources/catalog/types.d.ts +53 -0
- package/dist/sources/catalog/types.d.ts.map +1 -0
- package/dist/sources/catalog/types.js +30 -0
- package/dist/sources/catalog/types.js.map +1 -0
- package/dist/sources/connection-test.d.ts +37 -0
- package/dist/sources/connection-test.d.ts.map +1 -0
- package/dist/sources/connection-test.js +101 -0
- package/dist/sources/connection-test.js.map +1 -0
- package/dist/sources/crew-source.d.ts +31 -0
- package/dist/sources/crew-source.d.ts.map +1 -0
- package/dist/sources/crew-source.js +48 -0
- package/dist/sources/crew-source.js.map +1 -0
- package/dist/sources/dialer.d.ts +169 -0
- package/dist/sources/dialer.d.ts.map +1 -0
- package/dist/sources/dialer.js +761 -0
- package/dist/sources/dialer.js.map +1 -0
- package/dist/sources/drivers/mysql.d.ts +52 -0
- package/dist/sources/drivers/mysql.d.ts.map +1 -0
- package/dist/sources/drivers/mysql.js +348 -0
- package/dist/sources/drivers/mysql.js.map +1 -0
- package/dist/sources/drivers/postgres.d.ts +84 -0
- package/dist/sources/drivers/postgres.d.ts.map +1 -0
- package/dist/sources/drivers/postgres.js +381 -0
- package/dist/sources/drivers/postgres.js.map +1 -0
- package/dist/sources/drivers/sqlite.d.ts +47 -0
- package/dist/sources/drivers/sqlite.d.ts.map +1 -0
- package/dist/sources/drivers/sqlite.js +156 -0
- package/dist/sources/drivers/sqlite.js.map +1 -0
- package/dist/sources/drivers/types.d.ts +79 -0
- package/dist/sources/drivers/types.d.ts.map +1 -0
- package/dist/sources/drivers/types.js +31 -0
- package/dist/sources/drivers/types.js.map +1 -0
- package/dist/sources/graphql.d.ts +85 -0
- package/dist/sources/graphql.d.ts.map +1 -0
- package/dist/sources/graphql.js +155 -0
- package/dist/sources/graphql.js.map +1 -0
- package/dist/sources/kinds.d.ts +79 -0
- package/dist/sources/kinds.d.ts.map +1 -0
- package/dist/sources/kinds.js +145 -0
- package/dist/sources/kinds.js.map +1 -0
- package/dist/sources/policy/allowlists.d.ts +30 -0
- package/dist/sources/policy/allowlists.d.ts.map +1 -0
- package/dist/sources/policy/allowlists.js +104 -0
- package/dist/sources/policy/allowlists.js.map +1 -0
- package/dist/sources/policy/index.d.ts +20 -0
- package/dist/sources/policy/index.d.ts.map +1 -0
- package/dist/sources/policy/index.js +34 -0
- package/dist/sources/policy/index.js.map +1 -0
- package/dist/sources/policy/mysql.d.ts +21 -0
- package/dist/sources/policy/mysql.d.ts.map +1 -0
- package/dist/sources/policy/mysql.js +834 -0
- package/dist/sources/policy/mysql.js.map +1 -0
- package/dist/sources/policy/pg.d.ts +37 -0
- package/dist/sources/policy/pg.d.ts.map +1 -0
- package/dist/sources/policy/pg.js +572 -0
- package/dist/sources/policy/pg.js.map +1 -0
- package/dist/sources/policy/sqlite.d.ts +37 -0
- package/dist/sources/policy/sqlite.d.ts.map +1 -0
- package/dist/sources/policy/sqlite.js +94 -0
- package/dist/sources/policy/sqlite.js.map +1 -0
- package/dist/sources/policy/types.d.ts +46 -0
- package/dist/sources/policy/types.d.ts.map +1 -0
- package/dist/sources/policy/types.js +13 -0
- package/dist/sources/policy/types.js.map +1 -0
- package/dist/sources/routes.d.ts +154 -0
- package/dist/sources/routes.d.ts.map +1 -0
- package/dist/sources/routes.js +745 -0
- package/dist/sources/routes.js.map +1 -0
- package/dist/sources/safety/postgres.d.ts +87 -0
- package/dist/sources/safety/postgres.d.ts.map +1 -0
- package/dist/sources/safety/postgres.js +349 -0
- package/dist/sources/safety/postgres.js.map +1 -0
- package/dist/sources/sql.d.ts +51 -0
- package/dist/sources/sql.d.ts.map +1 -0
- package/dist/sources/sql.js +89 -0
- package/dist/sources/sql.js.map +1 -0
- package/dist/sources/store.d.ts +25 -0
- package/dist/sources/store.d.ts.map +1 -0
- package/dist/sources/store.js +59 -0
- package/dist/sources/store.js.map +1 -0
- package/dist/sources/uploads.d.ts +70 -0
- package/dist/sources/uploads.d.ts.map +1 -0
- package/dist/sources/uploads.js +636 -0
- package/dist/sources/uploads.js.map +1 -0
- package/dist/standing-orders/parse.d.ts +38 -0
- package/dist/standing-orders/parse.d.ts.map +1 -1
- package/dist/standing-orders/parse.js +104 -43
- package/dist/standing-orders/parse.js.map +1 -1
- package/dist/standing-orders/routes.d.ts +25 -126
- package/dist/standing-orders/routes.d.ts.map +1 -1
- package/dist/standing-orders/routes.js +4 -6
- package/dist/standing-orders/routes.js.map +1 -1
- package/dist/standing-orders/store.d.ts +22 -73
- package/dist/standing-orders/store.d.ts.map +1 -1
- package/dist/standing-orders/store.js +8 -12
- package/dist/standing-orders/store.js.map +1 -1
- package/dist/studio/assets/KnowledgeGraph-Cpm46tEp.js +1 -0
- package/dist/studio/assets/WickedSansA-Regular-CGPJLyb8.woff2 +0 -0
- package/dist/studio/assets/WickedSansA-SemiBold-Bk9KXUaV.woff2 +0 -0
- package/dist/studio/assets/favicon-BJA6hF2f.svg +1 -0
- package/dist/studio/assets/index-BRBwWQMH.css +32 -0
- package/dist/studio/assets/index-CVrWDGRP.js +1097 -0
- package/dist/studio/assets/wicked-studio-lettering-small-CBwSGqop.svg +2 -0
- package/dist/studio/assets/wicked-studio-wordmark-small-gF5xn6IC.svg +2 -0
- package/dist/studio/editors/wicked-apps/editor.json +45 -0
- package/dist/studio/editors/wicked-apps/icon.svg +1 -0
- package/dist/studio/editors/wicked-apps/index.html +151 -0
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +12 -8
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +12 -8
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +12 -8
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/fonts/LICENSE-WickedSans.txt +97 -0
- package/dist/studio/index.html +3 -2
- package/dist/studio/testid-inventory.json +10850 -6700
- package/dist/team/routes.d.ts +31 -172
- package/dist/team/routes.d.ts.map +1 -1
- package/dist/team/routes.js +31 -8
- package/dist/team/routes.js.map +1 -1
- package/dist/voice/dashboard.d.ts +35 -313
- package/dist/voice/dashboard.d.ts.map +1 -1
- package/dist/voice/dashboard.js +10 -10
- package/dist/voice/dashboard.js.map +1 -1
- package/dist/voice/routes.d.ts +2 -6
- package/dist/voice/routes.d.ts.map +1 -1
- package/dist/voice/routes.js +2 -2
- package/dist/voice/routes.js.map +1 -1
- package/dist/watch/checks/check-failed.d.ts +4 -10
- package/dist/watch/checks/check-failed.d.ts.map +1 -1
- package/dist/watch/checks/check-failed.js +6 -8
- package/dist/watch/checks/check-failed.js.map +1 -1
- package/dist/watch/checks/claim-vs-evidence.js +3 -3
- package/dist/watch/checks/claim-vs-evidence.js.map +1 -1
- package/dist/watch/checks/deliver-audit.js +3 -3
- package/dist/watch/checks/deliver-audit.js.map +1 -1
- package/dist/watch/checks/discovery.d.ts.map +1 -1
- package/dist/watch/checks/discovery.js +5 -7
- package/dist/watch/checks/discovery.js.map +1 -1
- package/dist/watch/checks/lag.d.ts +4 -10
- package/dist/watch/checks/lag.d.ts.map +1 -1
- package/dist/watch/checks/lag.js +6 -8
- package/dist/watch/checks/lag.js.map +1 -1
- package/dist/watch/checks/quiet-after-claim.js +3 -3
- package/dist/watch/checks/quiet-after-claim.js.map +1 -1
- package/dist/watch/checks/scope-drift.js +3 -3
- package/dist/watch/checks/scope-drift.js.map +1 -1
- package/dist/watch/checks/team-path.js +2 -2
- package/dist/watch/checks/team-path.js.map +1 -1
- package/dist/watch/checks/ungated.js +3 -3
- package/dist/watch/checks/ungated.js.map +1 -1
- package/dist/watch/checks/warned-rule.js +3 -3
- package/dist/watch/checks/warned-rule.js.map +1 -1
- package/dist/watch/loader.d.ts.map +1 -1
- package/dist/watch/loader.js +12 -16
- package/dist/watch/loader.js.map +1 -1
- package/dist/workflow-catalog/build-v2.d.ts +90 -0
- package/dist/workflow-catalog/build-v2.d.ts.map +1 -0
- package/dist/workflow-catalog/build-v2.js +527 -0
- package/dist/workflow-catalog/build-v2.js.map +1 -0
- package/dist/workflow-catalog/build.d.ts +2 -0
- package/dist/workflow-catalog/build.d.ts.map +1 -1
- package/dist/workflow-catalog/build.js +8 -4
- package/dist/workflow-catalog/build.js.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.d.ts +12 -0
- package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -0
- package/dist/workflow-catalog/catalog-data-v2.js +2582 -0
- package/dist/workflow-catalog/catalog-data-v2.js.map +1 -0
- package/dist/workflow-catalog/catalog-data.d.ts +7 -1
- package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data.js +36 -7
- package/dist/workflow-catalog/catalog-data.js.map +1 -1
- package/dist/workflow-catalog/seeds-v2.d.ts +91 -0
- package/dist/workflow-catalog/seeds-v2.d.ts.map +1 -0
- package/dist/workflow-catalog/seeds-v2.js +2 -0
- package/dist/workflow-catalog/seeds-v2.js.map +1 -0
- package/dist/workflow-catalog/shape.d.ts +97 -0
- package/dist/workflow-catalog/shape.d.ts.map +1 -0
- package/dist/workflow-catalog/shape.js +97 -0
- package/dist/workflow-catalog/shape.js.map +1 -0
- package/dist/working-doc/service.d.ts.map +1 -1
- package/dist/working-doc/service.js +2 -1
- package/dist/working-doc/service.js.map +1 -1
- package/dist/zod.d.ts +39 -0
- package/dist/zod.d.ts.map +1 -0
- package/dist/zod.js +197 -0
- package/dist/zod.js.map +1 -0
- package/endpoint-manifest.json +651 -11
- package/package.json +31 -7
- package/runners/sqlite-runner.mjs +110 -0
- package/dist/studio/assets/WickedSans-Regular-fb698rcD.woff2 +0 -0
- package/dist/studio/assets/WickedSans-SemiBold-CD53n1AC.woff2 +0 -0
- package/dist/studio/assets/index-BUZ_-Syk.css +0 -32
- package/dist/studio/assets/index-u4O_7N-b.js +0 -986
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The MySQL half of the read policy (DES-APPS-001 §5.3): a hand-written grammar of the CLOSED read
|
|
3
|
+
* subset. Anything this grammar does not name is a parse error, which is a refusal, so the subset is
|
|
4
|
+
* closed by construction rather than by walking a permissive parser's tree.
|
|
5
|
+
*
|
|
6
|
+
* The lexer refuses everything where MySQL and this grammar could read the same text differently:
|
|
7
|
+
* backslashes (MySQL escapes in strings unless NO_BACKSLASH_ESCAPES), executable and optimizer-hint
|
|
8
|
+
* comments (`/*!`, `/*+`, which MySQL RUNS), `#` comments, a `--` not followed by whitespace,
|
|
9
|
+
* double-quoted strings (ANSI_QUOTES changes their meaning), `||`/`&&`, user and system variables
|
|
10
|
+
* (`@`), hex/bit/national literals and charset introducers. The session also pins `sql_mode`
|
|
11
|
+
* (drivers/mysql.ts), so the server reads the text the way this file did.
|
|
12
|
+
*
|
|
13
|
+
* Rules (§5.3): one statement, a SELECT (UNION allowed) or a non-recursive WITH … SELECT; no INTO,
|
|
14
|
+
* locking, index hints, partitions or modifiers; functions from the allowlist only, never qualified;
|
|
15
|
+
* casts to scalar types; tables of the described catalog (`db.table`, or a bare name meaning the
|
|
16
|
+
* source's database), views only by name, never another database's tables. Parameters are `?`.
|
|
17
|
+
*/
|
|
18
|
+
import { deniedFunction, MYSQL_CAST_TYPES, MYSQL_FUNCTIONS } from './allowlists.js';
|
|
19
|
+
import { relKey, relLabel } from './types.js';
|
|
20
|
+
class Refusal extends Error {
|
|
21
|
+
code;
|
|
22
|
+
constructor(code, message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.code = code;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const refuse = (code, message) => {
|
|
28
|
+
throw new Refusal(code, message);
|
|
29
|
+
};
|
|
30
|
+
const OPS = ['<=>', '<>', '!=', '<=', '>=', '(', ')', ',', '.', '*', '+', '-', '/', '%', '=', '<', '>', ';'];
|
|
31
|
+
/** MySQL's own whitespace in a single-byte view: ASCII space and control characters only. */
|
|
32
|
+
const ASCII_SPACE = /[\t\n\v\f\r ]/;
|
|
33
|
+
function lex(text) {
|
|
34
|
+
if (text.includes('\\'))
|
|
35
|
+
refuse('lexical', 'a backslash is refused in MySQL query text (MySQL and the checker could read it differently); pass the value as a parameter');
|
|
36
|
+
const out = [];
|
|
37
|
+
let i = 0;
|
|
38
|
+
const n = text.length;
|
|
39
|
+
const push = (kind, v, raw, start, end) => {
|
|
40
|
+
out.push({ kind, v, raw, start, end });
|
|
41
|
+
};
|
|
42
|
+
while (i < n) {
|
|
43
|
+
const c = text[i];
|
|
44
|
+
if (ASCII_SPACE.test(c)) {
|
|
45
|
+
i++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
// Outside a quoted literal or name, only ASCII is read: MySQL decides spaces and identifier
|
|
49
|
+
// characters by the connection character set, so a non-ASCII byte could mean something else there.
|
|
50
|
+
if (c.charCodeAt(0) > 0x7e || (c.charCodeAt(0) < 0x20 && !ASCII_SPACE.test(c))) {
|
|
51
|
+
refuse('lexical', 'a non-ASCII or control character outside a quoted string or `name` is refused');
|
|
52
|
+
}
|
|
53
|
+
if (c === '/' && text[i + 1] === '*') {
|
|
54
|
+
if (text[i + 2] === '!' || text[i + 2] === '+')
|
|
55
|
+
refuse('lexical', 'executable (/*! … */) and optimizer-hint (/*+ … */) comments are refused: MySQL runs them');
|
|
56
|
+
const end = text.indexOf('*/', i + 2);
|
|
57
|
+
if (end < 0)
|
|
58
|
+
refuse('lexical', 'an unterminated comment');
|
|
59
|
+
i = end + 2;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (c === '-' && text[i + 1] === '-') {
|
|
63
|
+
const after = text[i + 2];
|
|
64
|
+
if (after !== undefined && !ASCII_SPACE.test(after))
|
|
65
|
+
refuse('lexical', 'a "--" not followed by an ASCII space is refused (MySQL reads it as two minus signs, not a comment)');
|
|
66
|
+
const end = text.indexOf('\n', i);
|
|
67
|
+
i = end < 0 ? n : end + 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (c === '#')
|
|
71
|
+
refuse('lexical', '# comments are refused; use /* … */ or "-- "');
|
|
72
|
+
if (c === '"')
|
|
73
|
+
refuse('lexical', 'double-quoted strings are refused (their meaning depends on ANSI_QUOTES); use single quotes for strings and backticks for names');
|
|
74
|
+
if (c === '@')
|
|
75
|
+
refuse('lexical', 'user and system variables (@…) are refused');
|
|
76
|
+
if (c === "'") {
|
|
77
|
+
let j = i + 1;
|
|
78
|
+
let v = '';
|
|
79
|
+
for (;;) {
|
|
80
|
+
if (j >= n)
|
|
81
|
+
refuse('lexical', 'an unterminated string');
|
|
82
|
+
if (text[j] === "'") {
|
|
83
|
+
if (text[j + 1] === "'") {
|
|
84
|
+
v += "'";
|
|
85
|
+
j += 2;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
v += text[j];
|
|
91
|
+
j++;
|
|
92
|
+
}
|
|
93
|
+
push('str', v, v, i, j + 1);
|
|
94
|
+
i = j + 1;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (c === '`') {
|
|
98
|
+
let j = i + 1;
|
|
99
|
+
let v = '';
|
|
100
|
+
for (;;) {
|
|
101
|
+
if (j >= n)
|
|
102
|
+
refuse('lexical', 'an unterminated `name`');
|
|
103
|
+
if (text[j] === '`') {
|
|
104
|
+
if (text[j + 1] === '`') {
|
|
105
|
+
v += '`';
|
|
106
|
+
j += 2;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
v += text[j];
|
|
112
|
+
j++;
|
|
113
|
+
}
|
|
114
|
+
if (v === '')
|
|
115
|
+
refuse('lexical', 'an empty `name`');
|
|
116
|
+
push('qident', v, v, i, j + 1);
|
|
117
|
+
i = j + 1;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (/[0-9]/.test(c) || (c === '.' && /[0-9]/.test(text[i + 1] ?? ''))) {
|
|
121
|
+
const m = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(text.slice(i));
|
|
122
|
+
const after = text[i + m[0].length] ?? '';
|
|
123
|
+
if (/[A-Za-z_$]/.test(after) || (c === '0' && /^0[xXbB]/.test(text.slice(i, i + 2))))
|
|
124
|
+
refuse('lexical', 'hex, bit and digit-led names are refused');
|
|
125
|
+
push('num', m[0], m[0], i, i + m[0].length);
|
|
126
|
+
i += m[0].length;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (/[A-Za-z_]/.test(c)) {
|
|
130
|
+
const m = /^[A-Za-z_][A-Za-z0-9_$]*/.exec(text.slice(i));
|
|
131
|
+
const word = m[0];
|
|
132
|
+
if (text[i + word.length] === "'")
|
|
133
|
+
refuse('lexical', `${word}'…' literals and charset introducers are refused`);
|
|
134
|
+
push('ident', word.toUpperCase(), word, i, i + word.length);
|
|
135
|
+
i += word.length;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (c === '?') {
|
|
139
|
+
push('param', '?', '?', i, i + 1);
|
|
140
|
+
i++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const op = OPS.find((o) => text.startsWith(o, i));
|
|
144
|
+
if (op === undefined)
|
|
145
|
+
refuse('lexical', `the character ${JSON.stringify(c)} (or the operator it starts) is outside the read subset`);
|
|
146
|
+
push('op', op, op, i, i + op.length);
|
|
147
|
+
i += op.length;
|
|
148
|
+
}
|
|
149
|
+
push('eof', '', '', n, n);
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
/** Words that are never a bare name here (MySQL reserves them, or they change what a statement does). */
|
|
153
|
+
const RESERVED = new Set([
|
|
154
|
+
'SELECT', 'FROM', 'WHERE', 'GROUP', 'HAVING', 'ORDER', 'LIMIT', 'OFFSET', 'UNION', 'EXCEPT', 'INTERSECT', 'INTO', 'FOR', 'LOCK',
|
|
155
|
+
'PROCEDURE', 'WINDOW', 'JOIN', 'ON', 'USING', 'AS', 'AND', 'OR', 'XOR', 'NOT', 'IN', 'IS', 'NULL', 'LIKE', 'RLIKE', 'REGEXP',
|
|
156
|
+
'BETWEEN', 'EXISTS', 'CASE', 'WHEN', 'THEN', 'ELSE', 'END', 'DISTINCT', 'DISTINCTROW', 'ALL', 'ANY', 'SOME', 'WITH',
|
|
157
|
+
'RECURSIVE', 'INNER', 'LEFT', 'RIGHT', 'CROSS', 'OUTER', 'NATURAL', 'STRAIGHT_JOIN', 'HIGH_PRIORITY', 'SQL_SMALL_RESULT',
|
|
158
|
+
'SQL_BIG_RESULT', 'SQL_BUFFER_RESULT', 'SQL_NO_CACHE', 'SQL_CACHE', 'SQL_CALC_FOUND_ROWS', 'BY', 'ASC', 'DESC', 'DIV',
|
|
159
|
+
'MOD', 'INTERVAL', 'CAST', 'CONVERT', 'BINARY', 'COLLATE', 'ESCAPE', 'ROLLUP', 'TRUE', 'FALSE', 'UNKNOWN', 'USE',
|
|
160
|
+
'FORCE', 'IGNORE', 'PARTITION', 'LATERAL', 'OVER', 'ROWS', 'RANGE', 'DUAL', 'MATCH', 'AGAINST', 'SEPARATOR', 'TABLE',
|
|
161
|
+
'VALUES', 'DEFAULT', 'OUTFILE', 'DUMPFILE', 'SHARE', 'UPDATE', 'DELETE', 'INSERT', 'REPLACE', 'CALL', 'SET', 'DO',
|
|
162
|
+
]);
|
|
163
|
+
const UNITS = new Set(['MICROSECOND', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'QUARTER', 'YEAR']);
|
|
164
|
+
const BARE_TIME = new Set(['CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'LOCALTIME', 'LOCALTIMESTAMP', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP']);
|
|
165
|
+
/** Functions MySQL calls with no parentheses that are not in the read subset (they read the login, not data). */
|
|
166
|
+
const BARE_FUNCTIONS = new Set(['CURRENT_USER', 'CURRENT_ROLE']);
|
|
167
|
+
class Parser {
|
|
168
|
+
toks;
|
|
169
|
+
catalog;
|
|
170
|
+
i = 0;
|
|
171
|
+
relations = new Set();
|
|
172
|
+
functions = new Set();
|
|
173
|
+
params = 0;
|
|
174
|
+
constructor(toks, catalog) {
|
|
175
|
+
this.toks = toks;
|
|
176
|
+
this.catalog = catalog;
|
|
177
|
+
}
|
|
178
|
+
get t() {
|
|
179
|
+
return this.toks[this.i];
|
|
180
|
+
}
|
|
181
|
+
peek(k = 1) {
|
|
182
|
+
return this.toks[Math.min(this.i + k, this.toks.length - 1)];
|
|
183
|
+
}
|
|
184
|
+
isWord(w, tok = this.t) {
|
|
185
|
+
return tok.kind === 'ident' && tok.v === w;
|
|
186
|
+
}
|
|
187
|
+
isOp(o, tok = this.t) {
|
|
188
|
+
return tok.kind === 'op' && tok.v === o;
|
|
189
|
+
}
|
|
190
|
+
eatWord(w) {
|
|
191
|
+
if (this.isWord(w)) {
|
|
192
|
+
this.i++;
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
eatOp(o) {
|
|
198
|
+
if (this.isOp(o)) {
|
|
199
|
+
this.i++;
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
expectWord(w) {
|
|
205
|
+
if (!this.eatWord(w))
|
|
206
|
+
this.unexpected(w);
|
|
207
|
+
}
|
|
208
|
+
expectOp(o) {
|
|
209
|
+
if (!this.eatOp(o))
|
|
210
|
+
this.unexpected(o);
|
|
211
|
+
}
|
|
212
|
+
unexpected(wanted) {
|
|
213
|
+
const got = this.t.kind === 'eof' ? 'the end of the query' : JSON.stringify(this.t.raw);
|
|
214
|
+
return refuse('syntax', `${got} is outside the read subset${wanted === undefined ? '' : ` (expected ${wanted})`}`);
|
|
215
|
+
}
|
|
216
|
+
/** A name: a backtick-quoted one, or a bare word that is not reserved. */
|
|
217
|
+
name() {
|
|
218
|
+
const tok = this.t;
|
|
219
|
+
if (tok.kind === 'qident') {
|
|
220
|
+
this.i++;
|
|
221
|
+
return tok.raw;
|
|
222
|
+
}
|
|
223
|
+
if (tok.kind === 'ident' && !RESERVED.has(tok.v)) {
|
|
224
|
+
this.i++;
|
|
225
|
+
return tok.raw;
|
|
226
|
+
}
|
|
227
|
+
return this.unexpected('a name');
|
|
228
|
+
}
|
|
229
|
+
isName(tok = this.t) {
|
|
230
|
+
return tok.kind === 'qident' || (tok.kind === 'ident' && !RESERVED.has(tok.v));
|
|
231
|
+
}
|
|
232
|
+
statement() {
|
|
233
|
+
this.query(null);
|
|
234
|
+
this.eatOp(';');
|
|
235
|
+
if (this.t.kind !== 'eof')
|
|
236
|
+
refuse('statements', 'a query is exactly one statement');
|
|
237
|
+
}
|
|
238
|
+
query(scope) {
|
|
239
|
+
let inner = { ctes: new Set(), parent: scope };
|
|
240
|
+
if (this.eatWord('WITH')) {
|
|
241
|
+
if (this.isWord('RECURSIVE'))
|
|
242
|
+
refuse('recursive', 'WITH RECURSIVE is outside the read subset');
|
|
243
|
+
const seen = { ctes: new Set(), parent: scope };
|
|
244
|
+
do {
|
|
245
|
+
const cte = this.name();
|
|
246
|
+
if (this.eatOp('(')) {
|
|
247
|
+
do
|
|
248
|
+
this.name();
|
|
249
|
+
while (this.eatOp(','));
|
|
250
|
+
this.expectOp(')');
|
|
251
|
+
}
|
|
252
|
+
this.expectWord('AS');
|
|
253
|
+
this.expectOp('(');
|
|
254
|
+
this.query({ ctes: new Set(seen.ctes), parent: scope });
|
|
255
|
+
this.expectOp(')');
|
|
256
|
+
seen.ctes.add(cte);
|
|
257
|
+
} while (this.eatOp(','));
|
|
258
|
+
inner = seen;
|
|
259
|
+
}
|
|
260
|
+
this.selectPrimary(inner);
|
|
261
|
+
while (this.isWord('UNION')) {
|
|
262
|
+
this.i++;
|
|
263
|
+
if (!this.eatWord('ALL'))
|
|
264
|
+
this.eatWord('DISTINCT');
|
|
265
|
+
this.selectPrimary(inner);
|
|
266
|
+
}
|
|
267
|
+
if (this.isWord('EXCEPT') || this.isWord('INTERSECT'))
|
|
268
|
+
refuse('syntax', 'EXCEPT and INTERSECT are outside the read subset; use UNION');
|
|
269
|
+
if (this.eatWord('ORDER')) {
|
|
270
|
+
this.expectWord('BY');
|
|
271
|
+
this.orderList(inner);
|
|
272
|
+
}
|
|
273
|
+
if (this.eatWord('LIMIT')) {
|
|
274
|
+
this.limitValue();
|
|
275
|
+
if (this.eatOp(',') || this.eatWord('OFFSET'))
|
|
276
|
+
this.limitValue();
|
|
277
|
+
}
|
|
278
|
+
for (const w of ['INTO', 'FOR', 'LOCK', 'PROCEDURE'])
|
|
279
|
+
if (this.isWord(w))
|
|
280
|
+
refuse(w === 'INTO' ? 'into' : 'locking', `${w} … is not a read`);
|
|
281
|
+
}
|
|
282
|
+
limitValue() {
|
|
283
|
+
if (this.t.kind === 'num' && /^\d+$/.test(this.t.v))
|
|
284
|
+
this.i++;
|
|
285
|
+
else if (this.t.kind === 'param') {
|
|
286
|
+
this.i++;
|
|
287
|
+
this.params++;
|
|
288
|
+
}
|
|
289
|
+
else
|
|
290
|
+
this.unexpected('a row count');
|
|
291
|
+
}
|
|
292
|
+
selectPrimary(scope) {
|
|
293
|
+
if (this.eatOp('(')) {
|
|
294
|
+
this.query(scope);
|
|
295
|
+
this.expectOp(')');
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (!this.isWord('SELECT')) {
|
|
299
|
+
if (this.t.kind === 'ident' && ['DELETE', 'UPDATE', 'INSERT', 'REPLACE', 'CALL', 'SET', 'DO', 'TABLE', 'VALUES', 'HANDLER', 'LOAD', 'CREATE', 'DROP', 'ALTER', 'TRUNCATE', 'GRANT', 'SHOW', 'EXPLAIN'].includes(this.t.v)) {
|
|
300
|
+
refuse('not_select', `${this.t.v} is not a read; only SELECT (or WITH … SELECT) is`);
|
|
301
|
+
}
|
|
302
|
+
this.unexpected('SELECT');
|
|
303
|
+
}
|
|
304
|
+
this.i++;
|
|
305
|
+
if (!this.eatWord('ALL'))
|
|
306
|
+
this.eatWord('DISTINCT');
|
|
307
|
+
do
|
|
308
|
+
this.selectItem(scope);
|
|
309
|
+
while (this.eatOp(','));
|
|
310
|
+
if (this.eatWord('FROM')) {
|
|
311
|
+
if (this.isWord('DUAL'))
|
|
312
|
+
this.i++;
|
|
313
|
+
else
|
|
314
|
+
this.tableRefs(scope);
|
|
315
|
+
}
|
|
316
|
+
if (this.eatWord('WHERE'))
|
|
317
|
+
this.expr(scope);
|
|
318
|
+
if (this.eatWord('GROUP')) {
|
|
319
|
+
this.expectWord('BY');
|
|
320
|
+
do
|
|
321
|
+
this.expr(scope);
|
|
322
|
+
while (this.eatOp(','));
|
|
323
|
+
if (this.eatWord('WITH'))
|
|
324
|
+
this.expectWord('ROLLUP');
|
|
325
|
+
}
|
|
326
|
+
if (this.eatWord('HAVING'))
|
|
327
|
+
this.expr(scope);
|
|
328
|
+
if (this.isWord('WINDOW'))
|
|
329
|
+
refuse('syntax', 'named windows are outside the read subset; write OVER (…) in place');
|
|
330
|
+
}
|
|
331
|
+
selectItem(scope) {
|
|
332
|
+
if (this.eatOp('*'))
|
|
333
|
+
return;
|
|
334
|
+
// qualifier.* or qualifier.qualifier.*
|
|
335
|
+
if (this.isName() && this.isOp('.', this.peek()) && (this.isOp('*', this.peek(2)) || (this.isName(this.peek(2)) && this.isOp('.', this.peek(3)) && this.isOp('*', this.peek(4))))) {
|
|
336
|
+
this.name();
|
|
337
|
+
this.expectOp('.');
|
|
338
|
+
if (this.eatOp('*'))
|
|
339
|
+
return;
|
|
340
|
+
this.name();
|
|
341
|
+
this.expectOp('.');
|
|
342
|
+
this.expectOp('*');
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
this.expr(scope);
|
|
346
|
+
if (this.eatWord('AS'))
|
|
347
|
+
this.name();
|
|
348
|
+
else if (this.isName())
|
|
349
|
+
this.name();
|
|
350
|
+
}
|
|
351
|
+
tableRefs(scope) {
|
|
352
|
+
do {
|
|
353
|
+
this.tablePrimary(scope);
|
|
354
|
+
this.joins(scope);
|
|
355
|
+
} while (this.eatOp(','));
|
|
356
|
+
}
|
|
357
|
+
joins(scope) {
|
|
358
|
+
for (;;) {
|
|
359
|
+
if (this.isWord('NATURAL') || this.isWord('STRAIGHT_JOIN'))
|
|
360
|
+
refuse('syntax', `${this.t.v} joins are outside the read subset`);
|
|
361
|
+
let outer = false;
|
|
362
|
+
if (this.eatWord('INNER') || this.eatWord('CROSS')) {
|
|
363
|
+
this.expectWord('JOIN');
|
|
364
|
+
}
|
|
365
|
+
else if (this.eatWord('LEFT') || this.eatWord('RIGHT')) {
|
|
366
|
+
outer = true;
|
|
367
|
+
this.eatWord('OUTER');
|
|
368
|
+
this.expectWord('JOIN');
|
|
369
|
+
}
|
|
370
|
+
else if (!this.eatWord('JOIN'))
|
|
371
|
+
return;
|
|
372
|
+
this.tablePrimary(scope);
|
|
373
|
+
if (this.eatWord('ON'))
|
|
374
|
+
this.expr(scope);
|
|
375
|
+
else if (this.eatWord('USING')) {
|
|
376
|
+
this.expectOp('(');
|
|
377
|
+
do
|
|
378
|
+
this.name();
|
|
379
|
+
while (this.eatOp(','));
|
|
380
|
+
this.expectOp(')');
|
|
381
|
+
}
|
|
382
|
+
else if (outer)
|
|
383
|
+
this.unexpected('ON or USING');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
tablePrimary(scope) {
|
|
387
|
+
if (this.isWord('LATERAL'))
|
|
388
|
+
refuse('syntax', 'LATERAL is outside the read subset');
|
|
389
|
+
if (this.eatOp('(')) {
|
|
390
|
+
if (this.isWord('SELECT') || this.isWord('WITH') || this.isOp('(')) {
|
|
391
|
+
this.query(scope);
|
|
392
|
+
this.expectOp(')');
|
|
393
|
+
this.eatWord('AS');
|
|
394
|
+
this.name();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
this.tableRefs(scope);
|
|
398
|
+
this.expectOp(')');
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
const first = this.name();
|
|
402
|
+
let schema = null;
|
|
403
|
+
let table = first;
|
|
404
|
+
if (this.eatOp('.')) {
|
|
405
|
+
schema = first;
|
|
406
|
+
table = this.name();
|
|
407
|
+
}
|
|
408
|
+
this.relation(schema, table, scope);
|
|
409
|
+
if (this.isWord('PARTITION'))
|
|
410
|
+
refuse('syntax', 'PARTITION selection is outside the read subset');
|
|
411
|
+
if (this.eatWord('AS'))
|
|
412
|
+
this.name();
|
|
413
|
+
else if (this.isName())
|
|
414
|
+
this.name();
|
|
415
|
+
if (this.isWord('USE') || this.isWord('FORCE') || this.isWord('IGNORE'))
|
|
416
|
+
refuse('syntax', 'index hints are outside the read subset');
|
|
417
|
+
}
|
|
418
|
+
relation(schema, table, scope) {
|
|
419
|
+
if (schema === null) {
|
|
420
|
+
for (let s = scope; s !== null; s = s.parent)
|
|
421
|
+
if (s.ctes.has(table))
|
|
422
|
+
return;
|
|
423
|
+
const db = this.catalog.defaultSchema ?? null;
|
|
424
|
+
if (db === null)
|
|
425
|
+
refuse('unqualified', `the table ${table} must be qualified with its database`);
|
|
426
|
+
schema = db;
|
|
427
|
+
}
|
|
428
|
+
const key = relKey(schema, table);
|
|
429
|
+
const label = relLabel(key);
|
|
430
|
+
const kind = this.catalog.relations.get(key);
|
|
431
|
+
if (kind === undefined)
|
|
432
|
+
refuse('relation', `${label} is not a table of this source's catalog (describe the source again if it is new)`);
|
|
433
|
+
else if (kind === 'foreign')
|
|
434
|
+
refuse('relation', `${label} is a foreign table`);
|
|
435
|
+
else if ((kind === 'view' || kind === 'matview') && !this.catalog.viewsAllowed.has(key))
|
|
436
|
+
refuse('view', `${label} is a view the person has not allowed by name on the source sheet`);
|
|
437
|
+
this.relations.add(key);
|
|
438
|
+
}
|
|
439
|
+
orderList(scope) {
|
|
440
|
+
do {
|
|
441
|
+
this.expr(scope);
|
|
442
|
+
if (!this.eatWord('ASC'))
|
|
443
|
+
this.eatWord('DESC');
|
|
444
|
+
} while (this.eatOp(','));
|
|
445
|
+
}
|
|
446
|
+
// ── expressions ──
|
|
447
|
+
expr(scope) {
|
|
448
|
+
this.andExpr(scope);
|
|
449
|
+
while (this.eatWord('OR'))
|
|
450
|
+
this.andExpr(scope);
|
|
451
|
+
if (this.isWord('XOR'))
|
|
452
|
+
refuse('syntax', 'XOR is outside the read subset');
|
|
453
|
+
}
|
|
454
|
+
andExpr(scope) {
|
|
455
|
+
this.notExpr(scope);
|
|
456
|
+
while (this.eatWord('AND'))
|
|
457
|
+
this.notExpr(scope);
|
|
458
|
+
}
|
|
459
|
+
notExpr(scope) {
|
|
460
|
+
if (this.eatWord('NOT')) {
|
|
461
|
+
this.notExpr(scope);
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
this.predicate(scope);
|
|
465
|
+
}
|
|
466
|
+
predicate(scope) {
|
|
467
|
+
this.addExpr(scope);
|
|
468
|
+
for (;;) {
|
|
469
|
+
if (this.t.kind === 'op' && ['=', '<>', '!=', '<', '>', '<=', '>=', '<=>'].includes(this.t.v)) {
|
|
470
|
+
this.i++;
|
|
471
|
+
if (this.isWord('ANY') || this.isWord('SOME') || this.isWord('ALL')) {
|
|
472
|
+
this.i++;
|
|
473
|
+
this.expectOp('(');
|
|
474
|
+
this.query(scope);
|
|
475
|
+
this.expectOp(')');
|
|
476
|
+
}
|
|
477
|
+
else
|
|
478
|
+
this.addExpr(scope);
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
if (this.eatWord('IS')) {
|
|
482
|
+
this.eatWord('NOT');
|
|
483
|
+
if (!(this.eatWord('NULL') || this.eatWord('TRUE') || this.eatWord('FALSE') || this.eatWord('UNKNOWN')))
|
|
484
|
+
this.unexpected('NULL, TRUE, FALSE or UNKNOWN');
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
const negated = this.isWord('NOT') && (this.isWord('IN', this.peek()) || this.isWord('BETWEEN', this.peek()) || this.isWord('LIKE', this.peek()));
|
|
488
|
+
if (negated)
|
|
489
|
+
this.i++;
|
|
490
|
+
if (this.eatWord('IN')) {
|
|
491
|
+
this.expectOp('(');
|
|
492
|
+
if (this.isWord('SELECT') || this.isWord('WITH'))
|
|
493
|
+
this.query(scope);
|
|
494
|
+
else {
|
|
495
|
+
do
|
|
496
|
+
this.expr(scope);
|
|
497
|
+
while (this.eatOp(','));
|
|
498
|
+
}
|
|
499
|
+
this.expectOp(')');
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (this.eatWord('BETWEEN')) {
|
|
503
|
+
this.addExpr(scope);
|
|
504
|
+
this.expectWord('AND');
|
|
505
|
+
this.addExpr(scope);
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (this.eatWord('LIKE')) {
|
|
509
|
+
this.addExpr(scope);
|
|
510
|
+
if (this.eatWord('ESCAPE')) {
|
|
511
|
+
if (this.t.kind !== 'str')
|
|
512
|
+
this.unexpected('an escape string');
|
|
513
|
+
this.i++;
|
|
514
|
+
}
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
if (negated)
|
|
518
|
+
this.unexpected('IN, BETWEEN or LIKE');
|
|
519
|
+
if (this.isWord('REGEXP') || this.isWord('RLIKE') || this.isWord('SOUNDS') || this.isWord('MEMBER'))
|
|
520
|
+
refuse('operator', `${this.t.v} is outside the read subset`);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
addExpr(scope) {
|
|
525
|
+
this.mulExpr(scope);
|
|
526
|
+
while (this.isOp('+') || this.isOp('-')) {
|
|
527
|
+
this.i++;
|
|
528
|
+
this.mulExpr(scope);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
mulExpr(scope) {
|
|
532
|
+
this.unary(scope);
|
|
533
|
+
while (this.isOp('*') || this.isOp('/') || this.isOp('%') || this.isWord('DIV') || this.isWord('MOD')) {
|
|
534
|
+
this.i++;
|
|
535
|
+
this.unary(scope);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
unary(scope) {
|
|
539
|
+
if (this.isOp('-') || this.isOp('+')) {
|
|
540
|
+
this.i++;
|
|
541
|
+
this.unary(scope);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
this.primary(scope);
|
|
545
|
+
}
|
|
546
|
+
primary(scope) {
|
|
547
|
+
const tok = this.t;
|
|
548
|
+
if (tok.kind === 'num' || tok.kind === 'str') {
|
|
549
|
+
this.i++;
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (tok.kind === 'param') {
|
|
553
|
+
this.i++;
|
|
554
|
+
this.params++;
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (this.eatOp('(')) {
|
|
558
|
+
if (this.isWord('SELECT') || this.isWord('WITH'))
|
|
559
|
+
this.query(scope);
|
|
560
|
+
else {
|
|
561
|
+
this.expr(scope);
|
|
562
|
+
if (this.isOp(','))
|
|
563
|
+
refuse('syntax', 'row constructors are outside the read subset');
|
|
564
|
+
}
|
|
565
|
+
this.expectOp(')');
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (tok.kind === 'ident') {
|
|
569
|
+
switch (tok.v) {
|
|
570
|
+
case 'NULL':
|
|
571
|
+
case 'TRUE':
|
|
572
|
+
case 'FALSE':
|
|
573
|
+
this.i++;
|
|
574
|
+
return;
|
|
575
|
+
case 'EXISTS':
|
|
576
|
+
this.i++;
|
|
577
|
+
this.expectOp('(');
|
|
578
|
+
this.query(scope);
|
|
579
|
+
this.expectOp(')');
|
|
580
|
+
return;
|
|
581
|
+
case 'CASE':
|
|
582
|
+
this.i++;
|
|
583
|
+
this.caseExpr(scope);
|
|
584
|
+
return;
|
|
585
|
+
case 'CAST':
|
|
586
|
+
this.i++;
|
|
587
|
+
this.expectOp('(');
|
|
588
|
+
this.expr(scope);
|
|
589
|
+
this.expectWord('AS');
|
|
590
|
+
this.castType();
|
|
591
|
+
this.expectOp(')');
|
|
592
|
+
return;
|
|
593
|
+
case 'INTERVAL':
|
|
594
|
+
this.i++;
|
|
595
|
+
this.expr(scope);
|
|
596
|
+
this.unit();
|
|
597
|
+
return;
|
|
598
|
+
case 'DATE':
|
|
599
|
+
case 'TIMESTAMP':
|
|
600
|
+
case 'TIME':
|
|
601
|
+
if (this.peek().kind === 'str') {
|
|
602
|
+
this.i += 2; // DATE '2024-01-01' and friends
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
break;
|
|
606
|
+
case 'CONVERT':
|
|
607
|
+
case 'BINARY':
|
|
608
|
+
case 'MATCH':
|
|
609
|
+
refuse('syntax', `${tok.v} is outside the read subset`);
|
|
610
|
+
}
|
|
611
|
+
if (BARE_TIME.has(tok.v) && !this.isOp('(', this.peek())) {
|
|
612
|
+
this.i++;
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
if (BARE_FUNCTIONS.has(tok.v) && !this.isOp('(', this.peek()))
|
|
616
|
+
refuse('function', `${tok.v} is a function MySQL calls without parentheses, outside the read subset`);
|
|
617
|
+
}
|
|
618
|
+
if (this.isName() || (tok.kind === 'ident' && this.isOp('(', this.peek()))) {
|
|
619
|
+
if (this.isOp('(', this.peek())) {
|
|
620
|
+
this.funcCall(scope);
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
this.name();
|
|
624
|
+
if (this.eatOp('.')) {
|
|
625
|
+
this.name();
|
|
626
|
+
if (this.isOp('('))
|
|
627
|
+
refuse('qualified_name', 'qualified routine names are refused: no stored functions');
|
|
628
|
+
if (this.eatOp('.'))
|
|
629
|
+
this.name();
|
|
630
|
+
}
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
this.unexpected('an expression');
|
|
634
|
+
}
|
|
635
|
+
caseExpr(scope) {
|
|
636
|
+
if (!this.isWord('WHEN'))
|
|
637
|
+
this.expr(scope);
|
|
638
|
+
if (!this.isWord('WHEN'))
|
|
639
|
+
this.unexpected('WHEN');
|
|
640
|
+
while (this.eatWord('WHEN')) {
|
|
641
|
+
this.expr(scope);
|
|
642
|
+
this.expectWord('THEN');
|
|
643
|
+
this.expr(scope);
|
|
644
|
+
}
|
|
645
|
+
if (this.eatWord('ELSE'))
|
|
646
|
+
this.expr(scope);
|
|
647
|
+
this.expectWord('END');
|
|
648
|
+
}
|
|
649
|
+
castType() {
|
|
650
|
+
const tok = this.t;
|
|
651
|
+
if (tok.kind !== 'ident' || !MYSQL_CAST_TYPES.has(tok.v))
|
|
652
|
+
refuse('cast', `a cast to ${tok.raw} is refused; casts go only to SIGNED, UNSIGNED, DECIMAL, CHAR, DATE, DATETIME, TIME, DOUBLE, FLOAT or JSON`);
|
|
653
|
+
this.i++;
|
|
654
|
+
if (tok.v === 'SIGNED' || tok.v === 'UNSIGNED') {
|
|
655
|
+
if (!this.eatWord('INTEGER'))
|
|
656
|
+
this.eatWord('INT');
|
|
657
|
+
return;
|
|
658
|
+
}
|
|
659
|
+
if (['DECIMAL', 'CHAR', 'DATETIME', 'TIME'].includes(tok.v) && this.eatOp('(')) {
|
|
660
|
+
if (this.t.kind !== 'num')
|
|
661
|
+
this.unexpected('a length');
|
|
662
|
+
this.i++;
|
|
663
|
+
if (tok.v === 'DECIMAL' && this.eatOp(',')) {
|
|
664
|
+
if (this.t.kind !== 'num')
|
|
665
|
+
this.unexpected('a scale');
|
|
666
|
+
this.i++;
|
|
667
|
+
}
|
|
668
|
+
this.expectOp(')');
|
|
669
|
+
}
|
|
670
|
+
if (this.isWord('CHARACTER') || this.isWord('CHARSET'))
|
|
671
|
+
refuse('cast', 'a character set in a cast is refused');
|
|
672
|
+
}
|
|
673
|
+
unit() {
|
|
674
|
+
if (this.t.kind !== 'ident' || !UNITS.has(this.t.v))
|
|
675
|
+
this.unexpected('an interval unit (SECOND … YEAR)');
|
|
676
|
+
this.i++;
|
|
677
|
+
}
|
|
678
|
+
funcCall(scope) {
|
|
679
|
+
const tok = this.t;
|
|
680
|
+
if (tok.kind !== 'ident')
|
|
681
|
+
this.unexpected('a function');
|
|
682
|
+
const fn = tok.v;
|
|
683
|
+
if (deniedFunction(fn) || !MYSQL_FUNCTIONS.has(fn))
|
|
684
|
+
refuse('function', `${tok.raw}() is not a function a read may call`);
|
|
685
|
+
// With IGNORE_SPACE off (the pinned sql_mode), `NAME (` is a stored routine call to MySQL, not the
|
|
686
|
+
// built-in this allowlist names: the parenthesis must follow the name directly.
|
|
687
|
+
if (this.peek().start !== tok.end)
|
|
688
|
+
refuse('function', `${tok.raw} must be followed directly by "(" (with a space, MySQL looks for a stored function of that name)`);
|
|
689
|
+
this.functions.add(fn);
|
|
690
|
+
this.i++;
|
|
691
|
+
this.expectOp('(');
|
|
692
|
+
switch (fn) {
|
|
693
|
+
case 'COUNT':
|
|
694
|
+
if (this.eatOp('*'))
|
|
695
|
+
break;
|
|
696
|
+
this.eatWord('DISTINCT');
|
|
697
|
+
do
|
|
698
|
+
this.expr(scope);
|
|
699
|
+
while (this.eatOp(','));
|
|
700
|
+
break;
|
|
701
|
+
case 'EXTRACT':
|
|
702
|
+
this.unit();
|
|
703
|
+
this.expectWord('FROM');
|
|
704
|
+
this.expr(scope);
|
|
705
|
+
break;
|
|
706
|
+
case 'SUBSTRING':
|
|
707
|
+
case 'SUBSTR':
|
|
708
|
+
this.expr(scope);
|
|
709
|
+
if (this.eatWord('FROM')) {
|
|
710
|
+
this.expr(scope);
|
|
711
|
+
if (this.eatWord('FOR'))
|
|
712
|
+
this.expr(scope);
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
this.expectOp(',');
|
|
716
|
+
this.expr(scope);
|
|
717
|
+
if (this.eatOp(','))
|
|
718
|
+
this.expr(scope);
|
|
719
|
+
}
|
|
720
|
+
break;
|
|
721
|
+
case 'TRIM':
|
|
722
|
+
if (this.eatWord('BOTH') || this.eatWord('LEADING') || this.eatWord('TRAILING')) {
|
|
723
|
+
if (!this.isWord('FROM'))
|
|
724
|
+
this.expr(scope);
|
|
725
|
+
this.expectWord('FROM');
|
|
726
|
+
this.expr(scope);
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
this.expr(scope);
|
|
730
|
+
if (this.eatWord('FROM'))
|
|
731
|
+
this.expr(scope);
|
|
732
|
+
}
|
|
733
|
+
break;
|
|
734
|
+
case 'POSITION':
|
|
735
|
+
this.addExpr(scope);
|
|
736
|
+
this.expectWord('IN');
|
|
737
|
+
this.expr(scope);
|
|
738
|
+
break;
|
|
739
|
+
case 'GROUP_CONCAT':
|
|
740
|
+
this.eatWord('DISTINCT');
|
|
741
|
+
do
|
|
742
|
+
this.expr(scope);
|
|
743
|
+
while (this.eatOp(','));
|
|
744
|
+
if (this.eatWord('ORDER')) {
|
|
745
|
+
this.expectWord('BY');
|
|
746
|
+
this.orderList(scope);
|
|
747
|
+
}
|
|
748
|
+
if (this.eatWord('SEPARATOR')) {
|
|
749
|
+
if (this.t.kind !== 'str')
|
|
750
|
+
this.unexpected('a separator string');
|
|
751
|
+
this.i++;
|
|
752
|
+
}
|
|
753
|
+
break;
|
|
754
|
+
case 'TIMESTAMPDIFF':
|
|
755
|
+
case 'TIMESTAMPADD':
|
|
756
|
+
this.unit();
|
|
757
|
+
this.expectOp(',');
|
|
758
|
+
this.expr(scope);
|
|
759
|
+
this.expectOp(',');
|
|
760
|
+
this.expr(scope);
|
|
761
|
+
break;
|
|
762
|
+
default:
|
|
763
|
+
if (this.isOp(')'))
|
|
764
|
+
break;
|
|
765
|
+
if (['SUM', 'AVG', 'MIN', 'MAX', 'JSON_ARRAYAGG'].includes(fn))
|
|
766
|
+
this.eatWord('DISTINCT');
|
|
767
|
+
do
|
|
768
|
+
this.expr(scope);
|
|
769
|
+
while (this.eatOp(','));
|
|
770
|
+
}
|
|
771
|
+
this.expectOp(')');
|
|
772
|
+
if (this.eatWord('OVER'))
|
|
773
|
+
this.windowSpec(scope);
|
|
774
|
+
}
|
|
775
|
+
windowSpec(scope) {
|
|
776
|
+
if (!this.isOp('('))
|
|
777
|
+
refuse('syntax', 'named windows are outside the read subset; write OVER (…) in place');
|
|
778
|
+
this.i++;
|
|
779
|
+
if (this.eatWord('PARTITION')) {
|
|
780
|
+
this.expectWord('BY');
|
|
781
|
+
do
|
|
782
|
+
this.expr(scope);
|
|
783
|
+
while (this.eatOp(','));
|
|
784
|
+
}
|
|
785
|
+
if (this.eatWord('ORDER')) {
|
|
786
|
+
this.expectWord('BY');
|
|
787
|
+
this.orderList(scope);
|
|
788
|
+
}
|
|
789
|
+
if (this.eatWord('ROWS') || this.eatWord('RANGE')) {
|
|
790
|
+
if (this.eatWord('BETWEEN')) {
|
|
791
|
+
this.frameBound(scope);
|
|
792
|
+
this.expectWord('AND');
|
|
793
|
+
this.frameBound(scope);
|
|
794
|
+
}
|
|
795
|
+
else
|
|
796
|
+
this.frameBound(scope);
|
|
797
|
+
}
|
|
798
|
+
this.expectOp(')');
|
|
799
|
+
}
|
|
800
|
+
frameBound(scope) {
|
|
801
|
+
if (this.eatWord('UNBOUNDED')) {
|
|
802
|
+
if (!this.eatWord('PRECEDING'))
|
|
803
|
+
this.expectWord('FOLLOWING');
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
if (this.eatWord('CURRENT')) {
|
|
807
|
+
this.expectWord('ROW');
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
if (this.t.kind === 'num' || this.t.kind === 'param') {
|
|
811
|
+
if (this.t.kind === 'param')
|
|
812
|
+
this.params++;
|
|
813
|
+
this.i++;
|
|
814
|
+
}
|
|
815
|
+
else
|
|
816
|
+
this.primary(scope);
|
|
817
|
+
if (!this.eatWord('PRECEDING'))
|
|
818
|
+
this.expectWord('FOLLOWING');
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
/** Check one query text against the MySQL read subset. Never connects. */
|
|
822
|
+
export function checkMysqlRead(text, catalog) {
|
|
823
|
+
try {
|
|
824
|
+
const p = new Parser(lex(text), catalog);
|
|
825
|
+
p.statement();
|
|
826
|
+
return { ok: true, relations: [...p.relations].map(relLabel).sort(), keys: [...p.relations].sort(), functions: [...p.functions].sort(), params: p.params };
|
|
827
|
+
}
|
|
828
|
+
catch (err) {
|
|
829
|
+
if (err instanceof Refusal)
|
|
830
|
+
return { ok: false, code: err.code, detail: err.message };
|
|
831
|
+
throw err;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
//# sourceMappingURL=mysql.js.map
|