@cchistory/lite 0.4.4 → 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 +35 -28
- 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 +155 -81
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +87 -63
- 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 -42
- package/docs/guide/lite.md +64 -24
- 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 -58
- 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 +32 -23
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +65 -45
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +363 -59
- 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 -53
- 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,27 @@
|
|
|
1
|
+
import {compile} from 'moo';
|
|
2
|
+
|
|
3
|
+
// build lexer
|
|
4
|
+
export const lexer = compile({
|
|
5
|
+
valueString: {
|
|
6
|
+
match: /"(?:\\["\\]|[^\n"\\])*"/,
|
|
7
|
+
value: x => JSON.parse(x),
|
|
8
|
+
type: x => 'value',
|
|
9
|
+
},
|
|
10
|
+
valueRaw: {
|
|
11
|
+
match: /[^\s,\{\}"](?:[^,\{\}"]*[^\s,\{\}"])?/,
|
|
12
|
+
type: () => 'value',
|
|
13
|
+
},
|
|
14
|
+
comma: ',',
|
|
15
|
+
space: { match: /[\s\t\n\v\f\r]+/, lineBreaks: true, },
|
|
16
|
+
start_list: '{',
|
|
17
|
+
end_list: '}',
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
lexer.next = (next => () => {
|
|
21
|
+
let tok;
|
|
22
|
+
while ((tok = next.call(lexer)) && (tok.type === 'space')) {
|
|
23
|
+
}
|
|
24
|
+
return tok;
|
|
25
|
+
})(lexer.next);
|
|
26
|
+
|
|
27
|
+
export const lexerAny: any = lexer;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@preprocessor typescript
|
|
2
|
+
|
|
3
|
+
@{%
|
|
4
|
+
import {lexerAny} from './array-lexer';
|
|
5
|
+
%}
|
|
6
|
+
@lexer lexerAny
|
|
7
|
+
@{%
|
|
8
|
+
const get = (i: number) => (x: any[]) => x[i];
|
|
9
|
+
const last = (x: any[]) => x && x[x.length - 1];
|
|
10
|
+
%}
|
|
11
|
+
|
|
12
|
+
main -> %start_list elements:? %end_list {% x => x[1] || [] %}
|
|
13
|
+
|
|
14
|
+
elements -> elt (%comma elt {% last %}):* {% ([head, tail]) => {
|
|
15
|
+
return [head, ...(tail || [])];
|
|
16
|
+
} %}
|
|
17
|
+
|
|
18
|
+
elt -> %value {% x => x[0].value %} | main {% x => x[0] %}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import 'chai';
|
|
3
|
+
import { lexer } from './array-lexer';
|
|
4
|
+
import { expect, assert } from 'chai';
|
|
5
|
+
import { parseArrayLiteral } from '../parser';
|
|
6
|
+
import { Optional } from '../utils';
|
|
7
|
+
import { Token } from 'moo';
|
|
8
|
+
|
|
9
|
+
describe('Array literals', () => {
|
|
10
|
+
|
|
11
|
+
const hasContent = [
|
|
12
|
+
/^value$/,
|
|
13
|
+
]
|
|
14
|
+
function next(expected: any) {
|
|
15
|
+
const result = lexer.next() as Optional<Token>;
|
|
16
|
+
delete result.toString;
|
|
17
|
+
delete result.col;
|
|
18
|
+
delete result.line;
|
|
19
|
+
delete result.lineBreaks;
|
|
20
|
+
delete result.offset;
|
|
21
|
+
delete result.text;
|
|
22
|
+
if (!hasContent.some(x => x.test(result.type!))) {
|
|
23
|
+
delete result.value;
|
|
24
|
+
}
|
|
25
|
+
expect(result).to.deep.equal(expected);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
it('Lexer: tokenizes simple list', () => {
|
|
29
|
+
lexer.reset(`{ a b , " a b " , "a\\" b"}`);
|
|
30
|
+
next({ type: 'start_list' });
|
|
31
|
+
next({ type: 'value', value: 'a b' });
|
|
32
|
+
next({ type: 'comma' });
|
|
33
|
+
next({ type: 'value', value: ' a b ' });
|
|
34
|
+
next({ type: 'comma' });
|
|
35
|
+
next({ type: 'value', value: 'a" b' });
|
|
36
|
+
next({ type: 'end_list' });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it ('parses single array', () => {
|
|
40
|
+
expect(parseArrayLiteral('{a}')).to.deep.equal(['a'])
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it ('parses double array', () => {
|
|
44
|
+
expect(parseArrayLiteral('{a, b}')).to.deep.equal(['a', 'b'])
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
it ('parses empty array', () => {
|
|
49
|
+
expect(parseArrayLiteral('{}')).to.deep.equal([]);
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it ('parses two dimensions', () => {
|
|
53
|
+
expect(parseArrayLiteral('{{a}, {b, c}}')).to.deep.equal([['a'], ['b', 'c']])
|
|
54
|
+
})
|
|
55
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {compile} from 'moo';
|
|
2
|
+
|
|
3
|
+
// build lexer
|
|
4
|
+
export const lexer = compile({
|
|
5
|
+
comma: ',',
|
|
6
|
+
space: { match: /[\s\t\n\v\f\r]+/, lineBreaks: true, },
|
|
7
|
+
int: /\-?\d+(?![\.\d])/,
|
|
8
|
+
float: /\-?(?:(?:\d*\.\d+)|(?:\d+\.\d*))/,
|
|
9
|
+
lcurl: '{',
|
|
10
|
+
rcurl: '}',
|
|
11
|
+
lparen: '(',
|
|
12
|
+
rparen: ')',
|
|
13
|
+
lbracket: '[',
|
|
14
|
+
rbracket: ']',
|
|
15
|
+
lcomp: '<',
|
|
16
|
+
rcomp: '>',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
lexer.next = (next => () => {
|
|
20
|
+
let tok;
|
|
21
|
+
while ((tok = next.call(lexer)) && (tok.type === 'space')) {
|
|
22
|
+
}
|
|
23
|
+
return tok;
|
|
24
|
+
})(lexer.next);
|
|
25
|
+
|
|
26
|
+
export const lexerAny: any = lexer;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
@preprocessor typescript
|
|
2
|
+
|
|
3
|
+
@{%
|
|
4
|
+
import {lexerAny} from './geometric-lexer';
|
|
5
|
+
|
|
6
|
+
const get = (i: number) => (x: any[]) => x[i];
|
|
7
|
+
const last = (x: any[]) => x && x[x.length - 1];
|
|
8
|
+
function unwrap(e: any[]): any {
|
|
9
|
+
if (Array.isArray(e) && e.length === 1) {
|
|
10
|
+
e = unwrap(e[0]);
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(e) && !e.length) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
%}
|
|
18
|
+
@lexer lexerAny
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
number -> (float | int) {%unwrap%}
|
|
23
|
+
float -> %float {% args => parseFloat(unwrap(args)) %}
|
|
24
|
+
int -> %int {% arg => parseInt(unwrap(arg), 10) %}
|
|
25
|
+
comma -> %comma {% id %}
|
|
26
|
+
|
|
27
|
+
opt_paren[X] -> ($X | %lparen $X %rparen {% get(1) %}) {% unwrap %}
|
|
28
|
+
|
|
29
|
+
array_of[EXP] -> $EXP (%comma $EXP {% last %}):* {% ([head, tail]) => {
|
|
30
|
+
return [unwrap(head), ...(tail.map(unwrap) || [])];
|
|
31
|
+
} %}
|
|
32
|
+
|
|
33
|
+
# ========================= POINT
|
|
34
|
+
|
|
35
|
+
point -> opt_paren[point_content] {% unwrap %}
|
|
36
|
+
point_content -> number comma number {% x => ({x:x[0],y:x[2]}) %}
|
|
37
|
+
|
|
38
|
+
# ========================= LINE
|
|
39
|
+
line -> %lcurl number comma number comma number %rcurl {% x => ({
|
|
40
|
+
a: x[1],
|
|
41
|
+
b: x[3],
|
|
42
|
+
c: x[5],
|
|
43
|
+
}) %}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# ========================= BOX
|
|
47
|
+
box -> closed_path {% ([x], rej) => {
|
|
48
|
+
if (x.length !== 2) {
|
|
49
|
+
return rej;
|
|
50
|
+
}
|
|
51
|
+
return x;
|
|
52
|
+
}%}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# ========================= SEGMENT
|
|
56
|
+
lseg -> path {% ([x], rej) => {
|
|
57
|
+
if (x.path.length !== 2) {
|
|
58
|
+
return rej;
|
|
59
|
+
}
|
|
60
|
+
return x.path;
|
|
61
|
+
}%}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ========================= PATHS
|
|
65
|
+
path_tpl[L,R] -> $L array_of[point] $R {% get(1) %}
|
|
66
|
+
|
|
67
|
+
path
|
|
68
|
+
-> open_path {% ([path]) => ({closed: false, path}) %}
|
|
69
|
+
| closed_path {% ([path]) => ({closed: true, path}) %}
|
|
70
|
+
|
|
71
|
+
open_path -> path_tpl[%lbracket, %rbracket] {% last %}
|
|
72
|
+
|
|
73
|
+
closed_path -> (path_tpl[%lparen, %rparen] {%last%}
|
|
74
|
+
| array_of[point] {%last%}
|
|
75
|
+
) {% get(0) %}
|
|
76
|
+
|
|
77
|
+
# ========================= POLYGON
|
|
78
|
+
polygon -> closed_path {% get(0) %}
|
|
79
|
+
|
|
80
|
+
# ========================= CIRCLE
|
|
81
|
+
circle_tpl[L,R] -> $L circle_body $R {% get(1) %}
|
|
82
|
+
|
|
83
|
+
circle_body -> point comma number {% x => ({c: x[0], r: x[2]}) %}
|
|
84
|
+
|
|
85
|
+
circle
|
|
86
|
+
-> (circle_tpl[%lcomp, %rcomp]
|
|
87
|
+
| circle_tpl[%lparen, %rparen]
|
|
88
|
+
| circle_body) {%unwrap%}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import 'chai';
|
|
3
|
+
import { lexer } from './geometric-lexer';
|
|
4
|
+
import { expect, assert } from 'chai';
|
|
5
|
+
import { parseGeometricLiteral } from '../parser';
|
|
6
|
+
import { Optional } from '../utils';
|
|
7
|
+
import { Token } from 'moo';
|
|
8
|
+
import { Segment, Box, Line, Point } from '../syntax/ast';
|
|
9
|
+
|
|
10
|
+
describe('Geometric literals', () => {
|
|
11
|
+
|
|
12
|
+
const hasContent = [
|
|
13
|
+
/^int$/,
|
|
14
|
+
/^float$/,
|
|
15
|
+
]
|
|
16
|
+
function next(expected: any) {
|
|
17
|
+
const result = lexer.next() as Optional<Token>;
|
|
18
|
+
delete result.toString;
|
|
19
|
+
delete result.col;
|
|
20
|
+
delete result.line;
|
|
21
|
+
delete result.lineBreaks;
|
|
22
|
+
delete result.offset;
|
|
23
|
+
delete result.text;
|
|
24
|
+
if (!hasContent.some(x => x.test(result.type!))) {
|
|
25
|
+
delete result.value;
|
|
26
|
+
}
|
|
27
|
+
expect(result).to.deep.equal(expected);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
it('Lexer: various tokens', () => {
|
|
31
|
+
lexer.reset(`(12,)<>{}`);
|
|
32
|
+
next({ type: 'lparen' });
|
|
33
|
+
next({ type: 'int', value: '12' });
|
|
34
|
+
next({ type: 'comma' });
|
|
35
|
+
next({ type: 'rparen' });
|
|
36
|
+
next({ type: 'lcomp' });
|
|
37
|
+
next({ type: 'rcomp' });
|
|
38
|
+
next({ type: 'lcurl' });
|
|
39
|
+
next({ type: 'rcurl' });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('Lexer: tokenizes comma', () => {
|
|
43
|
+
lexer.reset('2,2');
|
|
44
|
+
next({ type: 'int', value: '2' });
|
|
45
|
+
next({ type: 'comma' });
|
|
46
|
+
next({ type: 'int', value: '2' });
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
it('Lexer: tokenizes floats', () => {
|
|
51
|
+
lexer.reset('1.,.1,-.1,-0.1,0.1,10.,-10.');
|
|
52
|
+
next({ type: 'float', value: '1.' });
|
|
53
|
+
next({ type: 'comma' });
|
|
54
|
+
next({ type: 'float', value: '.1' });
|
|
55
|
+
next({ type: 'comma' });
|
|
56
|
+
next({ type: 'float', value: '-.1' });
|
|
57
|
+
next({ type: 'comma' });
|
|
58
|
+
next({ type: 'float', value: '-0.1' });
|
|
59
|
+
next({ type: 'comma' });
|
|
60
|
+
next({ type: 'float', value: '0.1' });
|
|
61
|
+
next({ type: 'comma' });
|
|
62
|
+
next({ type: 'float', value: '10.' });
|
|
63
|
+
next({ type: 'comma' });
|
|
64
|
+
next({ type: 'float', value: '-10.' });
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it('parses point', () => {
|
|
68
|
+
const point: Point = { x: 1, y: 2 };
|
|
69
|
+
expect(parseGeometricLiteral('(1,2)', 'point')).to.deep.equal(point);
|
|
70
|
+
expect(parseGeometricLiteral('.1,2.', 'point')).to.deep.equal({ x: .1, y: 2 });
|
|
71
|
+
expect(parseGeometricLiteral(' 1.1 , .2 ', 'point')).to.deep.equal({ x: 1.1, y: 0.2 });
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
it('parses line', () => {
|
|
76
|
+
const line: Line = { a: 1, b: 2, c: 3 };
|
|
77
|
+
expect(parseGeometricLiteral('{1,2,3}', 'line')).to.deep.equal(line);
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it('parses box', () => {
|
|
81
|
+
const box: Box = [{ x: 1, y: 2 }, { x: 3, y: 4 }];
|
|
82
|
+
expect(parseGeometricLiteral('((1,2),(3,4))', 'box')).to.deep.equal(box);
|
|
83
|
+
expect(parseGeometricLiteral('(1,2),(3,4)', 'box')).to.deep.equal(box);
|
|
84
|
+
expect(parseGeometricLiteral('(1,2,3,4)', 'box')).to.deep.equal(box);
|
|
85
|
+
expect(parseGeometricLiteral('1 , 2 , 3 , 4', 'box')).to.deep.equal(box);
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('parses segment', () => {
|
|
89
|
+
const lseg: Segment = [{ x: 1, y: 2 }, { x: 3, y: 4 }];
|
|
90
|
+
expect(parseGeometricLiteral('[(1,2),(3,4)]', 'lseg')).to.deep.equal(lseg);
|
|
91
|
+
expect(parseGeometricLiteral('((1,2),(3,4))', 'lseg')).to.deep.equal(lseg);
|
|
92
|
+
expect(parseGeometricLiteral('(1,2),(3,4)', 'lseg')).to.deep.equal(lseg);
|
|
93
|
+
expect(parseGeometricLiteral('(1,2,3,4)', 'lseg')).to.deep.equal(lseg);
|
|
94
|
+
expect(parseGeometricLiteral('1 , 2 , 3 , 4', 'lseg')).to.deep.equal(lseg);
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('parses closed paths', () => {
|
|
98
|
+
const path = { closed: true, path: [{ x: 1, y: 2 }, { x: 3, y: 4 }, { x: 5, y: 6 }] };
|
|
99
|
+
expect(parseGeometricLiteral('((1,2),(3,4), (5,6))', 'path')).to.deep.equal(path);
|
|
100
|
+
expect(parseGeometricLiteral('(1,2),(3,4), 5,6', 'path')).to.deep.equal(path);
|
|
101
|
+
expect(parseGeometricLiteral('(1,2,3,4, (5,6))', 'path')).to.deep.equal(path);
|
|
102
|
+
expect(parseGeometricLiteral('1 , 2 , 3 , 4, (5,6)', 'path')).to.deep.equal(path);
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('parses open paths', () => {
|
|
106
|
+
const path = { closed: false, path: [{ x: 1, y: 2 }, { x: 3, y: 4 }, { x: 5, y: 6 }] };
|
|
107
|
+
expect(parseGeometricLiteral('[(1,2),(3,4), (5,6)]', 'path')).to.deep.equal(path);
|
|
108
|
+
expect(parseGeometricLiteral('[(1,2),(3,4), 5,6]', 'path')).to.deep.equal(path);
|
|
109
|
+
expect(parseGeometricLiteral('[1,2,3,4, (5,6)]', 'path')).to.deep.equal(path);
|
|
110
|
+
expect(parseGeometricLiteral('[1 , 2 , 3 , 4, (5,6)]', 'path')).to.deep.equal(path);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
it('parses polygon', () => {
|
|
116
|
+
const polygon = [{ x: 1, y: 2 }, { x: 3, y: 4 }, { x: 5, y: 6 }];
|
|
117
|
+
expect(parseGeometricLiteral('((1,2),(3,4), (5,6))', 'polygon')).to.deep.equal(polygon);
|
|
118
|
+
expect(parseGeometricLiteral('(1,2),(3,4), 5,6', 'polygon')).to.deep.equal(polygon);
|
|
119
|
+
expect(parseGeometricLiteral('(1,2,3,4, (5,6))', 'polygon')).to.deep.equal(polygon);
|
|
120
|
+
expect(parseGeometricLiteral('1 , 2 , 3 , 4, (5,6)', 'polygon')).to.deep.equal(polygon);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
it('parses circle', () => {
|
|
125
|
+
const circle = { c: { x: 1, y: 2 }, r: 3 };
|
|
126
|
+
expect(parseGeometricLiteral('<(1,2),3>', 'circle')).to.deep.equal(circle);
|
|
127
|
+
expect(parseGeometricLiteral('((1,2),3)', 'circle')).to.deep.equal(circle);
|
|
128
|
+
expect(parseGeometricLiteral('(1,2),3', 'circle')).to.deep.equal(circle);
|
|
129
|
+
expect(parseGeometricLiteral('1,2,3', 'circle')).to.deep.equal(circle);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Interval } from '../syntax/ast';
|
|
2
|
+
import { nil } from '../utils';
|
|
3
|
+
|
|
4
|
+
const types: [keyof Interval, number][] = [
|
|
5
|
+
['years', 12],
|
|
6
|
+
['months', 30],
|
|
7
|
+
['days', 24],
|
|
8
|
+
['hours', 60],
|
|
9
|
+
['minutes', 60],
|
|
10
|
+
['seconds', 1000],
|
|
11
|
+
['milliseconds', 0],
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
type E = [keyof Interval, number];
|
|
15
|
+
type K = E | K[];
|
|
16
|
+
function* unwrap(k: K): IterableIterator<E> {
|
|
17
|
+
if (typeof k[1] === 'number') {
|
|
18
|
+
yield k as E;
|
|
19
|
+
} else {
|
|
20
|
+
for (const v of k as K[]) {
|
|
21
|
+
yield* unwrap(v);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function buildInterval(orig: string, vals: 'invalid' | K): Interval {
|
|
27
|
+
const ret: Interval = {};
|
|
28
|
+
if (vals === 'invalid') {
|
|
29
|
+
throw new Error(`invalid input syntax for type interval: "${orig}"`)
|
|
30
|
+
}
|
|
31
|
+
for (const [k, v] of unwrap(vals)) {
|
|
32
|
+
ret[k] = (ret[k] ?? 0) + v;
|
|
33
|
+
}
|
|
34
|
+
return ret;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/** Returns a normalized copy of the given interval */
|
|
39
|
+
export function normalizeInterval(value: Interval): Interval {
|
|
40
|
+
const ret = { ...value };
|
|
41
|
+
|
|
42
|
+
// trim non-integers
|
|
43
|
+
for (let i = 0; i < types.length; i++) {
|
|
44
|
+
const [k, mul] = types[i];
|
|
45
|
+
const v = ret[k] ?? 0;
|
|
46
|
+
const int = v >= 0
|
|
47
|
+
? Math.floor(v)
|
|
48
|
+
: Math.ceil(v);
|
|
49
|
+
if (!v || int === v) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const nk = types[i + 1]?.[0];
|
|
53
|
+
if (nk) {
|
|
54
|
+
ret[nk] = (ret[nk] ?? 0) + mul * (v - int);
|
|
55
|
+
}
|
|
56
|
+
ret[k] = int;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (ret.months || ret.years) {
|
|
60
|
+
const m = (ret.months ?? 0) + (ret.years ?? 0) * 12;
|
|
61
|
+
ret.months = m % 12;
|
|
62
|
+
ret.years = (m - ret.months) / 12;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// normalize time
|
|
66
|
+
let t = (ret.hours ?? 0) * 3600
|
|
67
|
+
+ (ret.minutes ?? 0) * 60
|
|
68
|
+
+ (ret.seconds ?? 0)
|
|
69
|
+
+ (ret.milliseconds ?? 0) / 1000;
|
|
70
|
+
let sign = 1;
|
|
71
|
+
if (t < 0) {
|
|
72
|
+
sign = -1;
|
|
73
|
+
t = -t;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (t >= 3600) {
|
|
77
|
+
ret.hours = sign * Math.floor(t / 3600);
|
|
78
|
+
t -= sign * ret.hours * 3600;
|
|
79
|
+
} else {
|
|
80
|
+
delete ret.hours;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (t >= 60) {
|
|
84
|
+
ret.minutes = sign * Math.floor(t / 60);
|
|
85
|
+
t -= sign * ret.minutes * 60;
|
|
86
|
+
} else {
|
|
87
|
+
delete ret.minutes;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (t > 0) {
|
|
91
|
+
ret.seconds = sign * Math.floor(t);
|
|
92
|
+
t -= sign * ret.seconds;
|
|
93
|
+
} else {
|
|
94
|
+
delete ret.seconds;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (t > 0) {
|
|
98
|
+
ret.milliseconds = sign * Math.round(t * 1000);
|
|
99
|
+
} else {
|
|
100
|
+
delete ret.milliseconds;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
// trim zeros.
|
|
105
|
+
for (const [k] of types) {
|
|
106
|
+
if (!ret[k]) {
|
|
107
|
+
delete ret[k];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return ret;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Interval value to postgres string representation */
|
|
115
|
+
export function intervalToString(value: Interval): String {
|
|
116
|
+
value = normalizeInterval(value);
|
|
117
|
+
const ret: string[] = [];
|
|
118
|
+
if (value.years) {
|
|
119
|
+
ret.push(value.years === 1 ? '1 year' : value.years + ' years');
|
|
120
|
+
}
|
|
121
|
+
if (value.months) {
|
|
122
|
+
ret.push(value.months === 1 ? '1 month' : value.months + ' months');
|
|
123
|
+
}
|
|
124
|
+
if (value.days) {
|
|
125
|
+
ret.push(value.days === 1 ? '1 day' : value.days + ' days');
|
|
126
|
+
}
|
|
127
|
+
if (value.hours || value.minutes || value.seconds || value.milliseconds) {
|
|
128
|
+
|
|
129
|
+
let time = `${num(value.hours ?? 0)}:${num(value.minutes ?? 0)}:${num(value.seconds ?? 0)}`
|
|
130
|
+
if (value.milliseconds) {
|
|
131
|
+
time = time + (value.milliseconds / 1000).toString().substr(1)
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
if (neg(value.hours) || neg(value.minutes) || neg(value.seconds) || neg(value.milliseconds)) {
|
|
135
|
+
time = '-' + time;
|
|
136
|
+
}
|
|
137
|
+
ret.push(time);
|
|
138
|
+
}
|
|
139
|
+
return ret.join(' ');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function num(v: number) {
|
|
143
|
+
v = Math.abs(v);
|
|
144
|
+
return v < 10 ? '0' + v : v.toString();
|
|
145
|
+
}
|
|
146
|
+
function neg(v: number | nil) {
|
|
147
|
+
return v && v < 0;
|
|
148
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {compile} from 'moo';
|
|
2
|
+
|
|
3
|
+
// build lexer
|
|
4
|
+
export const lexer = compile({
|
|
5
|
+
int: /\-?\d+(?![\.\d])/,
|
|
6
|
+
float: /\-?(?:(?:\d*\.\d+)|(?:\d+\.\d*))/,
|
|
7
|
+
P: 'P',
|
|
8
|
+
Y: 'Y',
|
|
9
|
+
M: 'M',
|
|
10
|
+
W: 'W',
|
|
11
|
+
D: 'D',
|
|
12
|
+
H: 'H',
|
|
13
|
+
S: 'S',
|
|
14
|
+
T: 'T',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const lexerAny: any = lexer;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
@preprocessor typescript
|
|
2
|
+
|
|
3
|
+
@{%
|
|
4
|
+
import {lexerAny} from './interval-iso-lexer';
|
|
5
|
+
%}
|
|
6
|
+
@lexer lexerAny
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
num -> %int | %float
|
|
10
|
+
|
|
11
|
+
# ======== ISO-LIKE FORMAT (not really iso) ==========
|
|
12
|
+
|
|
13
|
+
main -> %P long:* (%T short:+):? {% ([_, a, b], rej) => {
|
|
14
|
+
b = !b ? [] : b[1]; {}
|
|
15
|
+
if (!a.length && !b.length) {
|
|
16
|
+
return rej;
|
|
17
|
+
}
|
|
18
|
+
return !a.length ? b
|
|
19
|
+
: !b.length ? a
|
|
20
|
+
: [...a, ...b];
|
|
21
|
+
} %}
|
|
22
|
+
|
|
23
|
+
long -> num (%Y | %M | %W | %D) {% ([n, u]) => {
|
|
24
|
+
n = parseFloat(n[0].value);
|
|
25
|
+
u = u[0].type;
|
|
26
|
+
switch (u) {
|
|
27
|
+
case 'Y':
|
|
28
|
+
return ['years', n];
|
|
29
|
+
case 'M':
|
|
30
|
+
return ['months', n];
|
|
31
|
+
case 'W':
|
|
32
|
+
return ['days', n * 7];
|
|
33
|
+
case 'D':
|
|
34
|
+
return ['days', n];
|
|
35
|
+
default:
|
|
36
|
+
throw new Error('Unexpected unit ' + u);
|
|
37
|
+
}
|
|
38
|
+
}%}
|
|
39
|
+
|
|
40
|
+
short -> %T:? num (%H | %M | %S) {% ([_, n, u]) => {
|
|
41
|
+
n = parseFloat(n[0].value);
|
|
42
|
+
u = u[0].type;
|
|
43
|
+
switch (u) {
|
|
44
|
+
case 'H':
|
|
45
|
+
return ['hours', n];
|
|
46
|
+
case 'M':
|
|
47
|
+
return ['minutes', n];
|
|
48
|
+
case 'S':
|
|
49
|
+
return ['seconds', n];
|
|
50
|
+
default:
|
|
51
|
+
throw new Error('Unexpected unit ' + u);
|
|
52
|
+
}
|
|
53
|
+
}%}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {compile} from 'moo';
|
|
2
|
+
|
|
3
|
+
// build lexer
|
|
4
|
+
export const lexer = compile({
|
|
5
|
+
int: /\d+/,
|
|
6
|
+
neg: '-',
|
|
7
|
+
dot: '.',
|
|
8
|
+
years: /(?:y|yrs?|years?)\b/,
|
|
9
|
+
months: /(?:mon(?:th)?s?)\b/,
|
|
10
|
+
days: /(?:d|days?)\b/,
|
|
11
|
+
hours: /(?:h|hrs?|hours?)\b/,
|
|
12
|
+
minutes: /(?:m|mins?|minutes?)\b/,
|
|
13
|
+
seconds: /(?:s|secs?|seconds?)\b/,
|
|
14
|
+
milliseconds: /(?:ms|milliseconds?)\b/,
|
|
15
|
+
space: { match: /[\s\t\n\v\f\r]+/, lineBreaks: true, },
|
|
16
|
+
colon: ':',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
lexer.next = (next => () => {
|
|
20
|
+
let tok;
|
|
21
|
+
while ((tok = next.call(lexer)) && (tok.type === 'space')) {
|
|
22
|
+
}
|
|
23
|
+
return tok;
|
|
24
|
+
})(lexer.next);
|
|
25
|
+
|
|
26
|
+
export const lexerAny: any = lexer;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@preprocessor typescript
|
|
2
|
+
|
|
3
|
+
@{%
|
|
4
|
+
import {lexerAny} from './interval-lexer';
|
|
5
|
+
%}
|
|
6
|
+
@lexer lexerAny
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# ======== PLAIN TEXT FORMAT ==========
|
|
10
|
+
main -> elt:+ {% ([elts]) => {
|
|
11
|
+
// check unicity
|
|
12
|
+
const s = new Set();
|
|
13
|
+
for (const e of elts) {
|
|
14
|
+
const k = typeof e[1] === 'number'
|
|
15
|
+
? e[0]
|
|
16
|
+
: 'time';
|
|
17
|
+
if (s.has(k)) {
|
|
18
|
+
return 'invalid';
|
|
19
|
+
}
|
|
20
|
+
s.add(k);
|
|
21
|
+
}
|
|
22
|
+
return elts;
|
|
23
|
+
} %}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
elt -> time | num unit {% ([[n], u]) => {
|
|
27
|
+
u = u[0].type;
|
|
28
|
+
return [u, n];
|
|
29
|
+
} %}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
unit -> %years | %months | %days | %hours | %minutes | %seconds | %milliseconds
|
|
33
|
+
|
|
34
|
+
num -> int | float
|
|
35
|
+
uint -> %int {% ([x]) => parseInt(x, 10) %}
|
|
36
|
+
int -> (%neg):? %int {% ([neg, x]) => parseInt(x, 10) * (neg ? -1 : 1) %}
|
|
37
|
+
float -> (%neg):? %int:? %dot %int {% ([neg, ...v]) => parseFloat(v.map(v => v ? v.text : '0').join('')) * (neg ? -1 : 1) %}
|
|
38
|
+
|
|
39
|
+
time -> uint %colon uint (%colon uint):? (%dot %int):? {% ([a, _, b, c, d]) => {
|
|
40
|
+
c = c && c[1];
|
|
41
|
+
d = d && d[1];
|
|
42
|
+
const ret = typeof c === 'number' ? [
|
|
43
|
+
['hours', a],
|
|
44
|
+
['minutes', b],
|
|
45
|
+
['seconds', c],
|
|
46
|
+
] : [
|
|
47
|
+
['minutes', a],
|
|
48
|
+
['seconds', b],
|
|
49
|
+
];
|
|
50
|
+
if (d) {
|
|
51
|
+
ret.push(['milliseconds', parseFloat('0.' + d) * 1000]);
|
|
52
|
+
}
|
|
53
|
+
return ret;
|
|
54
|
+
}%}
|