@beehexa/hexasync-ai-toolkit 0.0.0-stage → 2610.12.2
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/.claude-plugin/marketplace.json +31 -0
- package/.claude-plugin/plugin.json +19 -0
- package/.codex-plugin/plugin.json +37 -0
- package/.cursor-plugin/mcp.json +12 -0
- package/.cursor-plugin/plugin.json +20 -0
- package/.mcp.json +11 -0
- package/README.md +46 -2
- package/dist/cli.js +2922 -0
- package/gemini-extension.json +14 -0
- package/openclaw.extension.mjs +9 -0
- package/openclaw.plugin.json +14 -0
- package/package.json +69 -3
- package/plugin.json +21 -0
- package/skills/hexasync-connections/SKILL.md +36 -0
- package/skills/hexasync-connections/references/INDEX.md +33 -0
- package/skills/hexasync-connections/references/INSTALL.md +35 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.api-recovery.md +17 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.authentication-and-setup-steps.md +64 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.captured-call-and-authenticated-composition.md +96 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.compiled-connector-hooks.md +23 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.connection-authentication.md +36 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.connection-rate-limiting.md +17 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.fields.md +225 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.framework-understood-connection-option-catalogue.md +225 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.how-a-step-finds-its-connection.md +54 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.md +84 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.never-invent-a-systemcode.md +6 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.one-connection-one-credential-scope.md +16 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.related.md +9 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.resolution-and-transport-scope.md +8 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.the-self-connector.md +22 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.two-spellings-of-the-collection-both-accepted.md +6 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.two-spellings-of-the-provider-with-defined-precedence.md +6 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.unsupported-authentication.md +26 -0
- package/skills/hexasync-connections/references/connections.CONNECTIONS.untyped-options-generic-validity-is-not-provider-completeness.md +192 -0
- package/skills/hexasync-error-handling/SKILL.md +47 -0
- package/skills/hexasync-error-handling/references/INDEX.md +22 -0
- package/skills/hexasync-error-handling/references/INSTALL.md +35 -0
- package/skills/hexasync-error-handling/references/routing.NEXT.md +246 -0
- package/skills/hexasync-error-handling/references/steps.EXCEPTION.md +139 -0
- package/skills/hexasync-error-handling/references/steps.Error.md +296 -0
- package/skills/hexasync-expressions/SKILL.md +53 -0
- package/skills/hexasync-expressions/references/INDEX.md +45 -0
- package/skills/hexasync-expressions/references/INSTALL.md +35 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.arguments--computed-before-the-step-runs.md +6 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.dialect-classification-and-silent-scriban-fallback.md +32 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.exact-mutation-timeline.md +41 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.executor-results-are-not-downstream-values.md +10 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.graceful-failures-and-run-errors.md +6 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.jsonata-call-site-scope-and-bindings.md +89 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.jsonata-engine-pinned-version-and-restrictions.md +28 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.jsonpath-expressions.md +47 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.md +21 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.quick-reference-the-three-expression-dialects.md +44 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.related.md +5 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.runtime-scope.md +110 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.custom-array-enum-item-and-numeric-functions.md +17 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.custom-date-functions.md +19 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.custom-object-functions.md +13 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.custom-string-functions.md +45 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.host-qualified-authoring-examples.md +27 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.md +15 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.standard-engine-versus-host-custom-functions.md +32 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.scriban-default-and-host-custom-builtins.visibility-and-call-site-constraints.md +8 -0
- package/skills/hexasync-expressions/references/expressions.CONTEXT-AND-IO.shared-stepiterator-roots.md +23 -0
- package/skills/hexasync-expressions/references/steps.JSONata.md +200 -0
- package/skills/hexasync-expressions/references/steps.Liquid.md +95 -0
- package/skills/hexasync-expressions/references/steps.Scriban.md +156 -0
- package/skills/hexasync-field-mapping/SKILL.md +60 -0
- package/skills/hexasync-field-mapping/references/INDEX.md +54 -0
- package/skills/hexasync-field-mapping/references/INSTALL.md +35 -0
- package/skills/hexasync-field-mapping/references/steps.SAVE_TASK_DATA.md +318 -0
- package/skills/hexasync-field-mapping/references/tables.TABLES.best-practices.md +11 -0
- package/skills/hexasync-field-mapping/references/tables.TABLES.fields.md +518 -0
- package/skills/hexasync-field-mapping/references/tables.TABLES.md +62 -0
- package/skills/hexasync-field-mapping/references/tables.TABLES.minimal-declaration-and-composed-usage.md +49 -0
- package/skills/hexasync-field-mapping/references/tables.TABLES.related.md +10 -0
- package/skills/hexasync-field-mapping/references/tables.TABLES.the-system-columns-are-not-declared-here.md +6 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.best-practices.md +21 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.contract.md +12 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.envelope-fields.md +115 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.example-enrich-an-item-with-a-structured-lookup.md +36 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.explicit-mapping-for-push.md +37 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.md +20 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.none--disabled-versus-absent-discriminator.md +17 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.puller-mapping-transformations.md +37 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.related.md +10 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.renamedependency--declared-but-unimplemented.md +18 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.sensible-configuration.md +23 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.syntax.md +30 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-chain-contract.md +43 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.bulkclone--clone-many.md +24 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.bulkrename--rename-many.md +27 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.clone--copy-one-field-to-several-names.md +47 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.jsonata--compute-a-field-from-a-jsonata-expression.md +120 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.md +18 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.nested_sql--legacy-raw-sql-producing-a-nested-list.md +64 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.query-argument-binding.md +88 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.query_many--the-dsl-replacement-for-nested_sql.md +172 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.query_single--the-dsl-replacement-for-sql.md +220 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.rename--rename-one-field.md +45 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.resolve_raw_data--lift-a-value-out-of-the-raw-payload.md +86 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.scriban--compute-a-field-from-a-scriban-expression.md +49 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.transformation-types.sql--legacy-raw-sql.md +73 -0
- package/skills/hexasync-field-mapping/references/transformations.TRANSFORMATIONS.when-to-use.md +9 -0
- package/skills/hexasync-metrics-reports/SKILL.md +55 -0
- package/skills/hexasync-metrics-reports/references/INDEX.md +41 -0
- package/skills/hexasync-metrics-reports/references/INSTALL.md +35 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.best-practices.md +13 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.choosing-a-scoremode.md +44 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.common-metadata-properties.md +35 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.contract.md +6 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.digest-message-templates.md +31 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.facet-properties.md +6 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.fields.md +551 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.health-scores.md +69 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.md +20 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.metric-configuration.md +57 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.metric-kinds-reference.md +574 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.related.md +9 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.sensible-configuration.md +30 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.severity-scoring.md +89 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.syntax.md +18 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.when-to-use.md +6 -0
- package/skills/hexasync-metrics-reports/references/metrics.METRICS_REFERENCE.worked-example-from-rows-to-health-score.md +108 -0
- package/skills/hexasync-metrics-reports/references/reports.REPORTS.md +460 -0
- package/skills/hexasync-metrics-reports/references/steps.METRIC_QUERY.md +171 -0
- package/skills/hexasync-metrics-reports/references/steps.QUERY_METRICS.md +400 -0
- package/skills/hexasync-pullers/SKILL.md +44 -0
- package/skills/hexasync-pullers/references/INDEX.md +50 -0
- package/skills/hexasync-pullers/references/INSTALL.md +35 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.api-error-classification.md +26 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.entity-classification.md +52 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.entry-context-and-transitions.md +12 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.error-and-final-handling.md +10 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.generalisation.md +17 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.md +36 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.overview.md +77 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.page-termination-and-the-four-platform-guards.md +49 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.paging-is-the-authors-job.md +8 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.persistence-and-safe-full-pull-removal.md +23 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-afterpullsteps.md +56 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-beforepullsteps.md +43 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-contracts.md +6 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-finalsteps.md +48 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-onerrorsteps.md +38 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-pullsteps.md +66 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.placement-steps.md +46 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.probe-discipline.md +13 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.property-reference.md +561 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.puller-completeness-contract.md +88 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.related.md +11 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.stamp--sweep.md +21 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.symptom--cause--rule.md +24 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.the-resume-computation.md +19 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.the-six-slot-specificity-checklist--once-per-endpoint.md +28 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.the-webhook-vs-puller-division.md +8 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.two-puller-host-modes-not-two-workflow-constructs.md +24 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.watermark-trustworthiness.md +15 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.worked-example-legacy-paged-pull.md +38 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.worked-example-new-kind-snapshot-pull.md +74 -0
- package/skills/hexasync-pullers/references/pullers.PULLERS.worked-example-opaque-token-api.md +14 -0
- package/skills/hexasync-pullers/references/steps.PULLER.md +187 -0
- package/skills/hexasync-pushers/SKILL.md +60 -0
- package/skills/hexasync-pushers/references/INDEX.md +47 -0
- package/skills/hexasync-pushers/references/INSTALL.md +35 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.association-transform-routing.md +38 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.best-practices.md +38 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.expression-roots-differ-from-a-puller.md +27 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.fields.md +332 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.four-step-phases.md +17 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.indirect-pushers.md +36 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.md +85 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.minimal-configuration.md +45 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.ordinary-result-contract.md +136 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-afterpushsteps.md +34 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-beforepushsteps.md +33 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-bulkpushers-afterpushsteps.md +8 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-bulkpushers-beforepushsteps.md +46 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-bulkpushers-pushsteps.md +8 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-contracts.md +10 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-finalsteps.md +99 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.placement-pushsteps.md +50 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.related.md +10 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.resolution-ordering-locks-and-retries.md +56 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.the-two-identities-a-push-step-reads-off-the-item.md +18 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.troubleshooting.md +16 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.worked-example-direct-push-with-dependency.md +66 -0
- package/skills/hexasync-pushers/references/pushers.PUSHERS.worked-example-indirect-push.md +35 -0
- package/skills/hexasync-pushers/references/steps.PUSHER.md +238 -0
- package/skills/hexasync-pushers/references/steps.UPDATE_ITEM_STATUS.md +201 -0
- package/skills/hexasync-pushers/references/steps.UPDATE_ITEM_SYNC_PROCESS.md +359 -0
- package/skills/hexasync-query-dsl/SKILL.md +67 -0
- package/skills/hexasync-query-dsl/references/INDEX.md +60 -0
- package/skills/hexasync-query-dsl/references/INSTALL.md +35 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.best-practice.md +6 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.filter-dsl-language-contract.filter-composition.md +48 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.filter-dsl-language-contract.filter-fields.md +51 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.filter-dsl-language-contract.filter-predicates.md +51 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.filter-dsl-language-contract.filter-quick-reference.md +67 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.filter-dsl-language-contract.filter-request-envelope.md +123 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.filter-dsl-language-contract.md +61 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.md +25 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operands.md +61 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operands.query-arguments.md +80 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operands.value-binding-and-casts.md +54 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.between-takes-a-range-not-an-operand.md +52 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.bitwise-predicates.md +60 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.last_int_unit-needs-format-on-the-left.md +92 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.md +16 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.membership-predicates.md +44 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.null-predicates-are-unary.md +67 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.regex-predicates-complete-scalar-postgresql-patterns.md +87 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.text-matching-six-predicates-scalar-patterns-and-value-lists.md +85 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.operators.verbatim-scalar-comparisons.md +92 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.property-reference.md +428 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.quick-reference-syntax-variants-and-how-to-choose.md +363 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.runtime-rules-and-authoring-shape.md +104 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.sensible-configuration.md +24 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.the-shape.builder-condition-tree.md +57 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.the-shape.grouping-precedence-and-exact-parentheses.md +102 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.the-shape.join-types.md +91 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.the-shape.md +10 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.the-shape.query-envelope.md +95 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.troubleshooting-and-canonical-references.md +39 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.when-to-use.md +9 -0
- package/skills/hexasync-query-dsl/references/query-dsl.QUERY-DSL.where-it-is-used.md +141 -0
- package/skills/hexasync-query-dsl/references/steps.QUERY_MANY.md +510 -0
- package/skills/hexasync-query-dsl/references/steps.QUERY_SINGLE.md +491 -0
- package/skills/hexasync-query-dsl/references/steps.SQL.md +362 -0
- package/skills/hexasync-query-dsl/references/steps.SQL_PROXY.md +315 -0
- package/skills/hexasync-startup-tasks-scheduling/SKILL.md +44 -0
- package/skills/hexasync-startup-tasks-scheduling/references/INDEX.md +28 -0
- package/skills/hexasync-startup-tasks-scheduling/references/INSTALL.md +35 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.contract.md +6 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.legacy-target-tasks.md +124 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.md +15 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.metric-defaults.md +73 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.related.md +9 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.scheduler-metadata.md +324 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.sensible-configuration.md +28 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.shape.md +108 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.syntax.md +33 -0
- package/skills/hexasync-startup-tasks-scheduling/references/startupTasks.STARTUP-TASKS.when-to-use.md +10 -0
- package/skills/hexasync-startup-tasks-scheduling/references/steps.ENQUEUER.md +234 -0
- package/skills/hexasync-steps-api-http/SKILL.md +61 -0
- package/skills/hexasync-steps-api-http/references/INDEX.md +73 -0
- package/skills/hexasync-steps-api-http/references/INSTALL.md +35 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.best-practices.md +11 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.exact-authored-shape.md +37 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.execution-order-and-shared-values.md +13 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.field-contract.md +60 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.md +49 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.members-encoded-inside-yaml-expression-strings.md +18 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.parsejson-boundary.md +14 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.parser-examples.md +77 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.parser-groups.md +203 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.related.md +5 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.same-name-different-placement-grammars.md +80 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.status-narrowing.md +29 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.the-eight-parser-ids.md +17 -0
- package/skills/hexasync-steps-api-http/references/responseFilters.RESPONSE-FILTERS.troubleshooting.md +13 -0
- package/skills/hexasync-steps-api-http/references/routing.NEXT.md +246 -0
- package/skills/hexasync-steps-api-http/references/steps.API.api-pagination.md +44 -0
- package/skills/hexasync-steps-api-http/references/steps.API.api-response-parsing-and-outputs.md +43 -0
- package/skills/hexasync-steps-api-http/references/steps.API.api-response-status.md +37 -0
- package/skills/hexasync-steps-api-http/references/steps.API.best-practices.md +14 -0
- package/skills/hexasync-steps-api-http/references/steps.API.contract.md +64 -0
- package/skills/hexasync-steps-api-http/references/steps.API.curl-request-intake.md +31 -0
- package/skills/hexasync-steps-api-http/references/steps.API.failure-handling.md +18 -0
- package/skills/hexasync-steps-api-http/references/steps.API.fields.md +457 -0
- package/skills/hexasync-steps-api-http/references/steps.API.md +21 -0
- package/skills/hexasync-steps-api-http/references/steps.API.public-webhook-binding.md +17 -0
- package/skills/hexasync-steps-api-http/references/steps.API.related.md +12 -0
- package/skills/hexasync-steps-api-http/references/steps.API.request-builders.md +206 -0
- package/skills/hexasync-steps-api-http/references/steps.API.request-pipeline-and-precedence.md +13 -0
- package/skills/hexasync-steps-api-http/references/steps.API.sensitive-headers-and-diagnostic-trail.md +25 -0
- package/skills/hexasync-steps-api-http/references/steps.INDEX.md +137 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE._history--the-per-step-occurrence-ring.md +6 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.arguments-and-routing.md +103 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.best-practices.md +11 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.connection-binding.md +6 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.cross-cutting-step-flags.md +76 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.execution-budgets.md +6 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.executor-results-graceful-returns-and-run-error-data.md +18 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.executor-selection-is-exact.md +21 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.flow-entry.md +8 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.md +22 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.one-canonical-workflow-component.md +79 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.payload-selection-and-thrown-error-routing.md +19 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.recovery-bypasses-and-connector-restart.md +11 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.related.md +5 -0
- package/skills/hexasync-steps-api-http/references/steps.STEP-ENVELOPE.shape.md +300 -0
- package/skills/hexasync-steps-control-data/SKILL.md +59 -0
- package/skills/hexasync-steps-control-data/references/INDEX.md +133 -0
- package/skills/hexasync-steps-control-data/references/INSTALL.md +35 -0
- package/skills/hexasync-steps-control-data/references/steps.BASE64_TO_MIME_TYPE.md +101 -0
- package/skills/hexasync-steps-control-data/references/steps.Begin.md +80 -0
- package/skills/hexasync-steps-control-data/references/steps.CACHE.md +221 -0
- package/skills/hexasync-steps-control-data/references/steps.Composite.md +87 -0
- package/skills/hexasync-steps-control-data/references/steps.DIRECT_INDEX.md +303 -0
- package/skills/hexasync-steps-control-data/references/steps.DOWNLOAD_CSV.md +475 -0
- package/skills/hexasync-steps-control-data/references/steps.EXCEL_READER.md +323 -0
- package/skills/hexasync-steps-control-data/references/steps.End.md +100 -0
- package/skills/hexasync-steps-control-data/references/steps.GET_KEY_VALUE.md +167 -0
- package/skills/hexasync-steps-control-data/references/steps.GraphQL.md +88 -0
- package/skills/hexasync-steps-control-data/references/steps.IF.md +284 -0
- package/skills/hexasync-steps-control-data/references/steps.IGNORE_ITEM.md +170 -0
- package/skills/hexasync-steps-control-data/references/steps.INDEX.md +137 -0
- package/skills/hexasync-steps-control-data/references/steps.INVALIDATE_CACHE.md +175 -0
- package/skills/hexasync-steps-control-data/references/steps.LOOKUP_STEP.md +146 -0
- package/skills/hexasync-steps-control-data/references/steps.OData.md +133 -0
- package/skills/hexasync-steps-control-data/references/steps.PUBLISH_EVENT.md +274 -0
- package/skills/hexasync-steps-control-data/references/steps.QueryDSL.md +126 -0
- package/skills/hexasync-steps-control-data/references/steps.REMOVE_DATA.md +264 -0
- package/skills/hexasync-steps-control-data/references/steps.RESET_ITEM.md +164 -0
- package/skills/hexasync-steps-control-data/references/steps.RESOLVE_RAW_DATA.md +180 -0
- package/skills/hexasync-steps-control-data/references/steps.Restful.md +124 -0
- package/skills/hexasync-steps-control-data/references/steps.SEED_DATA.md +255 -0
- package/skills/hexasync-steps-control-data/references/steps.SET_KEY_VALUE.md +168 -0
- package/skills/hexasync-steps-control-data/references/steps.SLEEP.md +207 -0
- package/skills/hexasync-steps-control-data/references/steps.SWITCH.md +194 -0
- package/skills/hexasync-steps-control-data/references/steps.TRACK_FOR_REMOVAL.md +253 -0
- package/skills/hexasync-steps-control-data/references/steps.UPDATE_TASK_DATA_STATUS.md +247 -0
- package/skills/hexasync-steps-control-data/references/steps.VALUES.md +149 -0
- package/skills/hexasync-steps-control-data/references/steps.VERIFY_CACHED.md +172 -0
- package/skills/hexasync-steps-control-data/references/steps.cURL.md +78 -0
- package/skills/hexasync-tables-tasks-objects/SKILL.md +57 -0
- package/skills/hexasync-tables-tasks-objects/references/INDEX.md +78 -0
- package/skills/hexasync-tables-tasks-objects/references/INSTALL.md +35 -0
- package/skills/hexasync-tables-tasks-objects/references/dependencies.DEPENDENCIES.authoring-dependencies.md +80 -0
- package/skills/hexasync-tables-tasks-objects/references/dependencies.DEPENDENCIES.best-practices-and-pitfalls.md +22 -0
- package/skills/hexasync-tables-tasks-objects/references/dependencies.DEPENDENCIES.fields.md +430 -0
- package/skills/hexasync-tables-tasks-objects/references/dependencies.DEPENDENCIES.md +57 -0
- package/skills/hexasync-tables-tasks-objects/references/dependencies.DEPENDENCIES.related.md +6 -0
- package/skills/hexasync-tables-tasks-objects/references/dependencies.DEPENDENCIES.using-resolved-prerequisite-data.md +12 -0
- package/skills/hexasync-tables-tasks-objects/references/objectAssociations.OBJECT-ASSOCIATIONS.md +340 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.best-practices-and-pitfalls.md +20 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.dataprocessing.md +88 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.dependencies.md +27 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.description.md +37 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.enqueue.md +179 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.fromconnectionid.md +21 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.id.md +20 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.ignorechange.md +31 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.ignoreremoval.md +25 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.integrationtype.md +26 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.isdirtyremovable.md +21 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.md +52 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.metricgroups.md +28 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.metrics.md +25 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.name.md +20 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.newtablename.md +23 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.oldtablename.md +23 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.priority.md +20 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.puller.md +55 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.pusher.md +24 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.queuer.md +23 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.toconnectionid.md +21 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.type.md +35 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.valuetablename.md +25 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.viewname.md +23 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.fields.visible.md +21 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.md +64 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.minimal-declaration.md +32 -0
- package/skills/hexasync-tables-tasks-objects/references/objects.object.related.md +8 -0
- package/skills/hexasync-tables-tasks-objects/references/steps.SAVE_TASK_DATA.md +318 -0
- package/skills/hexasync-tables-tasks-objects/references/tables.TABLES.best-practices.md +11 -0
- package/skills/hexasync-tables-tasks-objects/references/tables.TABLES.fields.md +518 -0
- package/skills/hexasync-tables-tasks-objects/references/tables.TABLES.md +62 -0
- package/skills/hexasync-tables-tasks-objects/references/tables.TABLES.minimal-declaration-and-composed-usage.md +49 -0
- package/skills/hexasync-tables-tasks-objects/references/tables.TABLES.related.md +10 -0
- package/skills/hexasync-tables-tasks-objects/references/tables.TABLES.the-system-columns-are-not-declared-here.md +6 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.best-practices.md +11 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.fields.md +357 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.md +14 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.related.md +12 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.status-and-row-clocks.md +28 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.system-column-contract.md +44 -0
- package/skills/hexasync-tables-tasks-objects/references/tasks.TASKS-AND-TABLES.systemcolumns-presentation.md +99 -0
- package/skills/hexasync-templates/SKILL.md +67 -0
- package/skills/hexasync-templates/references/AI-INDEX.md +125 -0
- package/skills/hexasync-templates/references/INDEX.md +73 -0
- package/skills/hexasync-templates/references/INSTALL.md +35 -0
- package/skills/hexasync-templates/references/KB-INDEX.md +128 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.composed-and-render-only-metadata.md +30 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.composition-fields.md +44 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.deployment-descriptor-retirement-and-current-composition.md +13 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.md +32 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.minimal-worker-facing-profile.md +34 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-references.md +54 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.author.md +15 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.connector-definition-document.md +356 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.connectors.md +15 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.contributors.md +15 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.creationsteps.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.databasename.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.dependencies.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.description.md +15 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.externals.md +14 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.api--gateway_api.md +33 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.browser.md +101 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.form-field-fields.md +238 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.form.md +65 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.get_local_storage--set_local_storage.md +114 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.health_check_worker.md +33 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.if--switch.md +148 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.integration_app_management.md +115 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.jsonata--liquid.md +47 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.md +109 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.nextbranch-fields.md +93 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.output-fields.md +82 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.read_queries.md +30 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.redirect.md +80 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.select_google_drive.md +47 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.show_info.md +65 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.single_choice_form--multiple_choice_form.md +47 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.step-envelope-fields.md +233 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.frontend-steps-creationsteps-setupsteps-authorizationsteps.wait.md +79 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.id.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.legacy-roots--do-not-author.md +30 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.md +36 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.metricgroups.md +14 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.name.md +13 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.noschedules.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.objectassociations.md +15 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.objects.md +23 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.pullers.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.pushers.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.recommendations.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.reports.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.startuptasks.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.tables.md +15 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.thumbnail.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.transformations.md +13 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.validations.md +13 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.variables.md +16 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.profile-root-fields-1.webhooks.md +12 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.recommendation-selection.md +36 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.reference-composition-across-run-and-render-scope.md +29 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.rejected-reference-forms-and-safe-correction.md +21 -0
- package/skills/hexasync-templates/references/PROFILE-ROOT.related.md +5 -0
- package/skills/hexasync-transformations/SKILL.md +51 -0
- package/skills/hexasync-transformations/references/INDEX.md +40 -0
- package/skills/hexasync-transformations/references/INSTALL.md +35 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.best-practices.md +21 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.contract.md +12 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.envelope-fields.md +115 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.example-enrich-an-item-with-a-structured-lookup.md +36 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.explicit-mapping-for-push.md +37 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.md +20 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.none--disabled-versus-absent-discriminator.md +17 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.puller-mapping-transformations.md +37 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.related.md +10 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.renamedependency--declared-but-unimplemented.md +18 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.sensible-configuration.md +23 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.syntax.md +30 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-chain-contract.md +43 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.bulkclone--clone-many.md +24 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.bulkrename--rename-many.md +27 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.clone--copy-one-field-to-several-names.md +47 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.jsonata--compute-a-field-from-a-jsonata-expression.md +120 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.md +18 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.nested_sql--legacy-raw-sql-producing-a-nested-list.md +64 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.query-argument-binding.md +88 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.query_many--the-dsl-replacement-for-nested_sql.md +172 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.query_single--the-dsl-replacement-for-sql.md +220 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.rename--rename-one-field.md +45 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.resolve_raw_data--lift-a-value-out-of-the-raw-payload.md +86 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.scriban--compute-a-field-from-a-scriban-expression.md +49 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.transformation-types.sql--legacy-raw-sql.md +73 -0
- package/skills/hexasync-transformations/references/transformations.TRANSFORMATIONS.when-to-use.md +9 -0
- package/skills/hexasync-validations/SKILL.md +52 -0
- package/skills/hexasync-validations/references/INDEX.md +27 -0
- package/skills/hexasync-validations/references/INSTALL.md +35 -0
- package/skills/hexasync-validations/references/steps.CHECK_FORMAT.md +196 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.authoring-validations.md +5 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.best-practices.md +15 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.composing-rules.md +37 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.example-required-text-plus-a-numeric-range.md +33 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.fields.md +118 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.how-validations-behave.md +27 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.md +57 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.metadata-members.md +134 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.not-the-query-dsl.md +15 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.operators.md +406 -0
- package/skills/hexasync-validations/references/validations.VALIDATIONS.troubleshooting.md +13 -0
- package/skills/hexasync-webhooks/SKILL.md +62 -0
- package/skills/hexasync-webhooks/references/INDEX.md +46 -0
- package/skills/hexasync-webhooks/references/INSTALL.md +35 -0
- package/skills/hexasync-webhooks/references/steps.FORWARD.md +130 -0
- package/skills/hexasync-webhooks/references/steps.WEBHOOK_FORWARD.md +259 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.best-practices.md +31 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.gateway-mcp-webhook-workflow.md +206 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.md +62 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.message-shape.md +29 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.placement-finalsteps.md +59 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.placement-pullsteps.md +72 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.related.md +10 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.routing-and-boundary-ownership.md +30 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.shape.md +37 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.autoenqueue.md +66 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.datafilter.md +68 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.dataparser.md +268 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.id-target.md +21 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.matchfilter-and-matchpattern.md +77 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.matchremovefilter-and-matchremovepattern.md +41 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.md +20 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.objectid-deprecated.md +25 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.objectids.md +66 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.options.md +67 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.pullsteps.md +31 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.target-properties.rejected-target-fields-finalsteps-and-responsefilters.md +8 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.troubleshooting.md +17 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.webhook-properties.md +117 -0
- package/skills/hexasync-webhooks/references/webhooks.WEBHOOKS.worked-example-webhook-direct-index-plus-steps.md +71 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2922 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __hexasyncCreateRequire } from 'node:module'; const require = __hexasyncCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/cli/bin.ts
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
// src/features/install/apply.ts
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
import { constants } from "node:fs";
|
|
10
|
+
import { access, cp, mkdir, readdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { delimiter, dirname, extname, join } from "node:path";
|
|
13
|
+
function nodeInstallPorts() {
|
|
14
|
+
return {
|
|
15
|
+
host: { platform: process.platform, home: homedir(), cwd: process.cwd(), env: process.env },
|
|
16
|
+
readText: async (path) => {
|
|
17
|
+
try {
|
|
18
|
+
return await readFile(path, "utf8");
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
listDir: async (path) => {
|
|
24
|
+
try {
|
|
25
|
+
return await readdir(path);
|
|
26
|
+
} catch {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
which: async (executable) => {
|
|
31
|
+
const extensions = process.platform === "win32" ? (process.env["PATHEXT"] ?? ".EXE;.CMD;.BAT").split(";") : [""];
|
|
32
|
+
for (const directory of (process.env["PATH"] ?? "").split(delimiter).filter(Boolean)) {
|
|
33
|
+
for (const extension of extensions) {
|
|
34
|
+
const candidate = join(directory, executable + extension.toLowerCase());
|
|
35
|
+
try {
|
|
36
|
+
await access(candidate, process.platform === "win32" ? constants.F_OK : constants.X_OK);
|
|
37
|
+
return candidate;
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var timestamp = () => (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
47
|
+
function runCommand(executable, argv) {
|
|
48
|
+
const shim = process.platform === "win32" && [".cmd", ".bat"].includes(extname(executable).toLowerCase());
|
|
49
|
+
const quote = (value) => `"${value.replace(/"/g, '""')}"`;
|
|
50
|
+
const child = shim ? spawn(`${quote(executable)} ${argv.map(quote).join(" ")}`, { shell: true, windowsHide: true }) : spawn(executable, [...argv], { windowsHide: true });
|
|
51
|
+
const deferred = Promise.withResolvers();
|
|
52
|
+
let output = "";
|
|
53
|
+
child.stdout?.on("data", (chunk) => {
|
|
54
|
+
output += chunk;
|
|
55
|
+
});
|
|
56
|
+
child.stderr?.on("data", (chunk) => {
|
|
57
|
+
output += chunk;
|
|
58
|
+
});
|
|
59
|
+
child.once("error", (error) => deferred.resolve({ code: null, output: error.message }));
|
|
60
|
+
child.once("close", (code) => deferred.resolve({ code, output: output.trim() }));
|
|
61
|
+
return deferred.promise;
|
|
62
|
+
}
|
|
63
|
+
async function applyInstallPlan(plan) {
|
|
64
|
+
const results = [];
|
|
65
|
+
for (const client of plan.clients) {
|
|
66
|
+
for (const action of client.actions) {
|
|
67
|
+
try {
|
|
68
|
+
switch (action.kind) {
|
|
69
|
+
case "copy-skills":
|
|
70
|
+
await mkdir(action.target, { recursive: true });
|
|
71
|
+
for (const skill of action.skills) {
|
|
72
|
+
await rm(join(action.target, skill), { recursive: true, force: true });
|
|
73
|
+
await cp(join(plan.options.skillsSource, skill), join(action.target, skill), { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
results.push({ action, ok: true });
|
|
76
|
+
break;
|
|
77
|
+
case "remove-skills":
|
|
78
|
+
for (const skill of action.skills) await rm(join(action.target, skill), { recursive: true, force: true });
|
|
79
|
+
results.push({ action, ok: true });
|
|
80
|
+
break;
|
|
81
|
+
case "write-config": {
|
|
82
|
+
let current = null;
|
|
83
|
+
try {
|
|
84
|
+
current = await readFile(action.path, "utf8");
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
if (current !== action.before) {
|
|
88
|
+
results.push({ action, ok: false, detail: "the file changed after planning; nothing was written \u2014 run the command again" });
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
await mkdir(dirname(action.path), { recursive: true });
|
|
92
|
+
let backup;
|
|
93
|
+
if (action.before !== null) {
|
|
94
|
+
backup = `${action.path}.hexasync-backup-${timestamp()}`;
|
|
95
|
+
await writeFile(backup, action.before, { flag: "wx" });
|
|
96
|
+
}
|
|
97
|
+
const temporary = `${action.path}.${process.pid}.tmp`;
|
|
98
|
+
await writeFile(temporary, action.after);
|
|
99
|
+
await rename(temporary, action.path);
|
|
100
|
+
results.push({ action, ok: true, ...backup ? { detail: `backup ${backup}` } : {} });
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case "run": {
|
|
104
|
+
const { code, output } = await runCommand(action.executable, action.argv);
|
|
105
|
+
results.push({ action, ok: code === 0 || action.allowFailure, ...code === 0 ? {} : { detail: output || `exit ${code}` } });
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "error":
|
|
109
|
+
results.push({ action, ok: false });
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
results.push({ action, ok: true });
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
results.push({ action, ok: false, detail: error instanceof Error ? error.message : String(error) });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/cli/main.ts
|
|
123
|
+
import { readdir as readdir2, readFile as readFile2, stat } from "node:fs/promises";
|
|
124
|
+
import { join as join2 } from "node:path";
|
|
125
|
+
|
|
126
|
+
// ../hexasync-template-client-setup/src/node/standalone.ts
|
|
127
|
+
import { posix, win32 } from "node:path";
|
|
128
|
+
|
|
129
|
+
// ../hexasync-template-client-setup/src/dialects.ts
|
|
130
|
+
var RELOAD = "Reload the Client so it reads the new MCP configuration.";
|
|
131
|
+
var APPROVE = "Approve the hexasync-template-ide server in the Client when prompted.";
|
|
132
|
+
var CLIENT_ACTIONS = [RELOAD, APPROVE];
|
|
133
|
+
var CLIENT_DIALECT_POLICIES = Object.freeze(Object.fromEntries(Object.entries({
|
|
134
|
+
vscode: { project: [], user: [], format: "jsonc", executableNames: [], identitySources: ["host-api"], nextActions: [] },
|
|
135
|
+
"claude-code": { project: [".mcp.json"], user: [".claude.json"], format: "json", executableNames: ["claude"], identitySources: ["executable"], nextActions: CLIENT_ACTIONS },
|
|
136
|
+
codex: { project: [".codex/config.toml"], user: [".codex/config.toml"], format: "toml", executableNames: ["codex"], identitySources: ["executable"], nextActions: CLIENT_ACTIONS },
|
|
137
|
+
"copilot-cli": { project: [".mcp.json", ".github/mcp.json"], user: [".copilot/mcp-config.json"], format: "json", executableNames: ["copilot"], identitySources: ["executable"], nextActions: CLIENT_ACTIONS },
|
|
138
|
+
cursor: { project: [".cursor/mcp.json"], user: [".cursor/mcp.json"], format: "json", executableNames: ["cursor"], identitySources: ["host-api", "executable"], nextActions: CLIENT_ACTIONS },
|
|
139
|
+
antigravity: { project: [".agents/mcp_config.json"], user: [".gemini/config/mcp_config.json"], format: "json", executableNames: ["antigravity"], identitySources: ["host-api", "executable"], nextActions: CLIENT_ACTIONS },
|
|
140
|
+
"qwen-code": { project: [".qwen/settings.json"], user: [".qwen/settings.json"], format: "json", executableNames: ["qwen"], identitySources: ["executable"], nextActions: CLIENT_ACTIONS },
|
|
141
|
+
"grok-cli": { project: [".grok/config.toml"], user: [".grok/config.toml"], format: "toml", executableNames: ["grok"], identitySources: ["executable"], nextActions: CLIENT_ACTIONS },
|
|
142
|
+
"windsurf-devin": { project: [], user: [".config/devin/mcp_config.json", ".codeium/windsurf/mcp_config.json"], format: "json", executableNames: ["devin", "windsurf"], identitySources: ["host-api", "executable"], nextActions: CLIENT_ACTIONS }
|
|
143
|
+
}).map(([id, policy]) => [id, Object.freeze({
|
|
144
|
+
...policy,
|
|
145
|
+
project: Object.freeze(policy.project),
|
|
146
|
+
user: Object.freeze(policy.user),
|
|
147
|
+
executableNames: Object.freeze(policy.executableNames),
|
|
148
|
+
identitySources: Object.freeze(policy.identitySources),
|
|
149
|
+
nextActions: Object.freeze([...policy.nextActions])
|
|
150
|
+
})])));
|
|
151
|
+
|
|
152
|
+
// ../hexasync-template-client-setup/src/config/json.ts
|
|
153
|
+
var InvalidJson = class extends Error {
|
|
154
|
+
};
|
|
155
|
+
var Parser = class {
|
|
156
|
+
constructor(text, comments) {
|
|
157
|
+
this.text = text;
|
|
158
|
+
this.comments = comments;
|
|
159
|
+
}
|
|
160
|
+
text;
|
|
161
|
+
comments;
|
|
162
|
+
position = 0;
|
|
163
|
+
depth = 0;
|
|
164
|
+
literal = /(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)/y;
|
|
165
|
+
parse() {
|
|
166
|
+
for (let index = 0; index < this.text.length; index++) {
|
|
167
|
+
const unit = this.text.charCodeAt(index);
|
|
168
|
+
if (unit >= 55296 && unit <= 56319) {
|
|
169
|
+
const next = this.text.charCodeAt(++index);
|
|
170
|
+
if (!(next >= 56320 && next <= 57343)) throw new InvalidJson();
|
|
171
|
+
} else if (unit >= 56320 && unit <= 57343) throw new InvalidJson();
|
|
172
|
+
}
|
|
173
|
+
const value = this.value();
|
|
174
|
+
this.trivia();
|
|
175
|
+
if (this.position !== this.text.length) throw new InvalidJson();
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
trivia() {
|
|
179
|
+
for (; ; ) {
|
|
180
|
+
while (/[\t\r\n ]/.test(this.text[this.position] ?? "") && this.position < this.text.length) this.position++;
|
|
181
|
+
if (!this.comments || this.text[this.position] !== "/") return;
|
|
182
|
+
if (this.text[this.position + 1] === "/") {
|
|
183
|
+
this.position += 2;
|
|
184
|
+
while (this.position < this.text.length && !/[\r\n]/.test(this.text[this.position])) this.position++;
|
|
185
|
+
} else if (this.text[this.position + 1] === "*") {
|
|
186
|
+
const end = this.text.indexOf("*/", this.position + 2);
|
|
187
|
+
if (end === -1) throw new InvalidJson();
|
|
188
|
+
this.position = end + 2;
|
|
189
|
+
} else return;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
string() {
|
|
193
|
+
const start = this.position++;
|
|
194
|
+
let escaped = false;
|
|
195
|
+
while (this.position < this.text.length) {
|
|
196
|
+
const character = this.text[this.position++];
|
|
197
|
+
if (character === '"' && !escaped) {
|
|
198
|
+
let value;
|
|
199
|
+
try {
|
|
200
|
+
value = JSON.parse(this.text.slice(start, this.position));
|
|
201
|
+
} catch {
|
|
202
|
+
throw new InvalidJson();
|
|
203
|
+
}
|
|
204
|
+
return { start, end: this.position, value };
|
|
205
|
+
}
|
|
206
|
+
if (character.charCodeAt(0) < 32) throw new InvalidJson();
|
|
207
|
+
escaped = character === "\\" && !escaped;
|
|
208
|
+
}
|
|
209
|
+
throw new InvalidJson();
|
|
210
|
+
}
|
|
211
|
+
value() {
|
|
212
|
+
if (++this.depth > 256) throw new InvalidJson();
|
|
213
|
+
try {
|
|
214
|
+
this.trivia();
|
|
215
|
+
const start = this.position;
|
|
216
|
+
const character = this.text[this.position];
|
|
217
|
+
if (character === '"') return this.string();
|
|
218
|
+
if (character === "{") return this.object();
|
|
219
|
+
if (character === "[") return this.array();
|
|
220
|
+
this.literal.lastIndex = start;
|
|
221
|
+
const literal = this.literal.exec(this.text);
|
|
222
|
+
if (!literal) throw new InvalidJson();
|
|
223
|
+
this.position += literal[0].length;
|
|
224
|
+
const value = JSON.parse(literal[0]);
|
|
225
|
+
if (typeof value === "number" && !Number.isFinite(value)) throw new InvalidJson();
|
|
226
|
+
return { start, end: this.position, value };
|
|
227
|
+
} finally {
|
|
228
|
+
this.depth--;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
object() {
|
|
232
|
+
const start = this.position++;
|
|
233
|
+
const properties = [];
|
|
234
|
+
const value = /* @__PURE__ */ Object.create(null);
|
|
235
|
+
this.trivia();
|
|
236
|
+
while (this.text[this.position] !== "}") {
|
|
237
|
+
if (this.text[this.position] !== '"') throw new InvalidJson();
|
|
238
|
+
const key = this.string();
|
|
239
|
+
const name = key.value;
|
|
240
|
+
if (Object.hasOwn(value, name)) throw new InvalidJson();
|
|
241
|
+
this.trivia();
|
|
242
|
+
if (this.text[this.position++] !== ":") throw new InvalidJson();
|
|
243
|
+
const child = this.value();
|
|
244
|
+
value[name] = child.value;
|
|
245
|
+
this.trivia();
|
|
246
|
+
const comma = this.text[this.position] === "," ? this.position++ : null;
|
|
247
|
+
properties.push({ key: name, keyStart: key.start, value: child, comma });
|
|
248
|
+
this.trivia();
|
|
249
|
+
if (comma === null && this.text[this.position] !== "}") throw new InvalidJson();
|
|
250
|
+
if (comma !== null && this.text[this.position] === "}" && !this.comments) throw new InvalidJson();
|
|
251
|
+
}
|
|
252
|
+
return { start, end: ++this.position, value, properties };
|
|
253
|
+
}
|
|
254
|
+
array() {
|
|
255
|
+
const start = this.position++;
|
|
256
|
+
const value = [];
|
|
257
|
+
this.trivia();
|
|
258
|
+
while (this.text[this.position] !== "]") {
|
|
259
|
+
value.push(this.value().value);
|
|
260
|
+
this.trivia();
|
|
261
|
+
const comma = this.text[this.position] === ",";
|
|
262
|
+
if (comma) this.position++;
|
|
263
|
+
this.trivia();
|
|
264
|
+
if (!comma && this.text[this.position] !== "]") throw new InvalidJson();
|
|
265
|
+
if (comma && this.text[this.position] === "]" && !this.comments) throw new InvalidJson();
|
|
266
|
+
}
|
|
267
|
+
return { start, end: ++this.position, value };
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
function semantic(value) {
|
|
271
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
272
|
+
if (Array.isArray(value)) return `[${value.map(semantic).join(",")}]`;
|
|
273
|
+
const record = value;
|
|
274
|
+
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${semantic(record[key])}`).join(",")}}`;
|
|
275
|
+
}
|
|
276
|
+
function applyEdits(text, edits) {
|
|
277
|
+
let result = text;
|
|
278
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
function indentation(text, position) {
|
|
282
|
+
const start = Math.max(text.lastIndexOf("\n", position - 1), text.lastIndexOf("\r", position - 1)) + 1;
|
|
283
|
+
return /^[\t ]*/.exec(text.slice(start, position))[0];
|
|
284
|
+
}
|
|
285
|
+
function render(value, indent, unit, newline) {
|
|
286
|
+
return JSON.stringify(value, null, unit).replace(/\n/g, `${newline}${indent}`);
|
|
287
|
+
}
|
|
288
|
+
function insertProperties(text, object, entries, newline) {
|
|
289
|
+
const properties = object.properties;
|
|
290
|
+
const last2 = properties.at(-1);
|
|
291
|
+
const multiline = /[\r\n]/.test(text.slice(object.start, object.end));
|
|
292
|
+
const parentIndent = indentation(text, object.start);
|
|
293
|
+
const childIndent = properties.length && multiline ? indentation(text, properties[0].keyStart) : `${parentIndent} `;
|
|
294
|
+
const unit = childIndent.slice(parentIndent.length) || " ";
|
|
295
|
+
const entry = entries.map(
|
|
296
|
+
([key, value]) => `${JSON.stringify(key)}: ${render(value, multiline ? childIndent : "", multiline ? unit : "", newline)}`
|
|
297
|
+
).join(multiline ? `,${newline}${childIndent}` : ", ");
|
|
298
|
+
const edits = [];
|
|
299
|
+
const close = object.end - 1;
|
|
300
|
+
const needsComma = last2 !== void 0 && last2.comma === null;
|
|
301
|
+
const commaAtClose = needsComma && last2.value.end === close;
|
|
302
|
+
if (needsComma && !commaAtClose) edits.push({ start: last2.value.end, end: last2.value.end, text: "," });
|
|
303
|
+
const prefix = multiline ? (text[close - 1] === "\n" ? "" : newline) + childIndent : last2 || close > object.start + 1 ? " " : "";
|
|
304
|
+
edits.push({ start: close, end: close, text: `${commaAtClose ? "," : ""}${prefix}${entry}${multiline ? newline + parentIndent : ""}` });
|
|
305
|
+
return applyEdits(text, edits);
|
|
306
|
+
}
|
|
307
|
+
function planJsonServerEntry(beforeImage, request) {
|
|
308
|
+
const removing = request.entry === null;
|
|
309
|
+
const comments = request.format === "jsonc";
|
|
310
|
+
const malformed = (reason) => Object.freeze({ status: "Malformed", afterImage: beforeImage, operation: removing ? "remove" : "add", reason });
|
|
311
|
+
const done = (afterImage, operation) => {
|
|
312
|
+
if (afterImage !== beforeImage && afterImage !== null) {
|
|
313
|
+
try {
|
|
314
|
+
new Parser(afterImage, comments).parse();
|
|
315
|
+
} catch {
|
|
316
|
+
return malformed("The preserving edit cannot guarantee valid JSON; the original file was kept.");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return Object.freeze({ status: afterImage === beforeImage ? "NoOp" : "Planned", afterImage, operation });
|
|
320
|
+
};
|
|
321
|
+
const nest = (path, value2) => path.reduceRight((inner, key2) => ({ [key2]: inner }), value2);
|
|
322
|
+
const fresh = (newline2) => `${JSON.stringify(nest([...request.mapPath, request.entryKey], request.entry), null, 2)}${newline2}`;
|
|
323
|
+
const text = beforeImage ?? "";
|
|
324
|
+
if (!text.trim()) return removing ? done(beforeImage, "remove") : done(fresh("\n"), "add");
|
|
325
|
+
let root;
|
|
326
|
+
try {
|
|
327
|
+
root = new Parser(text, comments).parse();
|
|
328
|
+
} catch {
|
|
329
|
+
return malformed("The configuration is not valid JSON (or has duplicate keys); repair it before installing.");
|
|
330
|
+
}
|
|
331
|
+
if (!root.properties) return malformed("The configuration root must be an object.");
|
|
332
|
+
const newline = /\r\n|\n|\r/.exec(text)?.[0] ?? "\n";
|
|
333
|
+
let parent = root;
|
|
334
|
+
let depth = 0;
|
|
335
|
+
for (; depth < request.mapPath.length; depth++) {
|
|
336
|
+
const property = parent.properties.find((candidate) => candidate.key === request.mapPath[depth]);
|
|
337
|
+
if (!property) break;
|
|
338
|
+
if (!property.value.properties) return malformed(`\`${request.mapPath.slice(0, depth + 1).join(".")}\` must be an object.`);
|
|
339
|
+
parent = property.value;
|
|
340
|
+
}
|
|
341
|
+
const existing = depth === request.mapPath.length ? parent.properties.find((property) => property.key === request.entryKey) : void 0;
|
|
342
|
+
if (removing) {
|
|
343
|
+
if (!existing) return done(beforeImage, "remove");
|
|
344
|
+
const properties = parent.properties;
|
|
345
|
+
const index = properties.indexOf(existing);
|
|
346
|
+
const comma = existing.comma ?? (index > 0 ? properties[index - 1].comma : null);
|
|
347
|
+
const edits = [{ start: existing.keyStart, end: existing.value.end, text: "" }];
|
|
348
|
+
if (comma !== null) edits.push({ start: comma, end: comma + 1, text: "" });
|
|
349
|
+
return done(applyEdits(text, edits), "remove");
|
|
350
|
+
}
|
|
351
|
+
const desired = request.entry;
|
|
352
|
+
if (existing) {
|
|
353
|
+
if (semantic(existing.value.value) === semantic(desired)) return done(beforeImage, "update");
|
|
354
|
+
const indent = indentation(text, existing.keyStart);
|
|
355
|
+
return done(applyEdits(text, [{
|
|
356
|
+
start: existing.value.start,
|
|
357
|
+
end: existing.value.end,
|
|
358
|
+
text: render(desired, indent, indent.includes(" ") ? " " : " ", newline)
|
|
359
|
+
}]), "update");
|
|
360
|
+
}
|
|
361
|
+
if (root.properties.length === 0 && text.trim() === "{}") return done(fresh(newline), "add");
|
|
362
|
+
const remaining = request.mapPath.slice(depth);
|
|
363
|
+
const [key, value] = remaining.length === 0 ? [request.entryKey, desired] : [remaining[0], nest([...remaining.slice(1), request.entryKey], desired)];
|
|
364
|
+
return done(insertProperties(text, parent, [[key, value]], newline), "add");
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// ../../node_modules/eslint-visitor-keys/lib/visitor-keys.js
|
|
368
|
+
var KEYS = {
|
|
369
|
+
ArrayExpression: ["elements"],
|
|
370
|
+
ArrayPattern: ["elements"],
|
|
371
|
+
ArrowFunctionExpression: ["params", "body"],
|
|
372
|
+
AssignmentExpression: ["left", "right"],
|
|
373
|
+
AssignmentPattern: ["left", "right"],
|
|
374
|
+
AwaitExpression: ["argument"],
|
|
375
|
+
BinaryExpression: ["left", "right"],
|
|
376
|
+
BlockStatement: ["body"],
|
|
377
|
+
BreakStatement: ["label"],
|
|
378
|
+
CallExpression: ["callee", "arguments"],
|
|
379
|
+
CatchClause: ["param", "body"],
|
|
380
|
+
ChainExpression: ["expression"],
|
|
381
|
+
ClassBody: ["body"],
|
|
382
|
+
ClassDeclaration: ["id", "superClass", "body"],
|
|
383
|
+
ClassExpression: ["id", "superClass", "body"],
|
|
384
|
+
ConditionalExpression: ["test", "consequent", "alternate"],
|
|
385
|
+
ContinueStatement: ["label"],
|
|
386
|
+
DebuggerStatement: [],
|
|
387
|
+
DoWhileStatement: ["body", "test"],
|
|
388
|
+
EmptyStatement: [],
|
|
389
|
+
ExperimentalRestProperty: ["argument"],
|
|
390
|
+
ExperimentalSpreadProperty: ["argument"],
|
|
391
|
+
ExportAllDeclaration: ["exported", "source", "attributes"],
|
|
392
|
+
ExportDefaultDeclaration: ["declaration"],
|
|
393
|
+
ExportNamedDeclaration: [
|
|
394
|
+
"declaration",
|
|
395
|
+
"specifiers",
|
|
396
|
+
"source",
|
|
397
|
+
"attributes"
|
|
398
|
+
],
|
|
399
|
+
ExportSpecifier: ["local", "exported"],
|
|
400
|
+
ExpressionStatement: ["expression"],
|
|
401
|
+
ForInStatement: ["left", "right", "body"],
|
|
402
|
+
ForOfStatement: ["left", "right", "body"],
|
|
403
|
+
ForStatement: ["init", "test", "update", "body"],
|
|
404
|
+
FunctionDeclaration: ["id", "params", "body"],
|
|
405
|
+
FunctionExpression: ["id", "params", "body"],
|
|
406
|
+
Identifier: [],
|
|
407
|
+
IfStatement: ["test", "consequent", "alternate"],
|
|
408
|
+
ImportAttribute: ["key", "value"],
|
|
409
|
+
ImportDeclaration: ["specifiers", "source", "attributes"],
|
|
410
|
+
ImportDefaultSpecifier: ["local"],
|
|
411
|
+
ImportExpression: ["source", "options"],
|
|
412
|
+
ImportNamespaceSpecifier: ["local"],
|
|
413
|
+
ImportSpecifier: ["imported", "local"],
|
|
414
|
+
JSXAttribute: ["name", "value"],
|
|
415
|
+
JSXClosingElement: ["name"],
|
|
416
|
+
JSXClosingFragment: [],
|
|
417
|
+
JSXElement: ["openingElement", "children", "closingElement"],
|
|
418
|
+
JSXEmptyExpression: [],
|
|
419
|
+
JSXExpressionContainer: ["expression"],
|
|
420
|
+
JSXFragment: ["openingFragment", "children", "closingFragment"],
|
|
421
|
+
JSXIdentifier: [],
|
|
422
|
+
JSXMemberExpression: ["object", "property"],
|
|
423
|
+
JSXNamespacedName: ["namespace", "name"],
|
|
424
|
+
JSXOpeningElement: ["name", "attributes"],
|
|
425
|
+
JSXOpeningFragment: [],
|
|
426
|
+
JSXSpreadAttribute: ["argument"],
|
|
427
|
+
JSXSpreadChild: ["expression"],
|
|
428
|
+
JSXText: [],
|
|
429
|
+
LabeledStatement: ["label", "body"],
|
|
430
|
+
Literal: [],
|
|
431
|
+
LogicalExpression: ["left", "right"],
|
|
432
|
+
MemberExpression: ["object", "property"],
|
|
433
|
+
MetaProperty: ["meta", "property"],
|
|
434
|
+
MethodDefinition: ["key", "value"],
|
|
435
|
+
NewExpression: ["callee", "arguments"],
|
|
436
|
+
ObjectExpression: ["properties"],
|
|
437
|
+
ObjectPattern: ["properties"],
|
|
438
|
+
PrivateIdentifier: [],
|
|
439
|
+
Program: ["body"],
|
|
440
|
+
Property: ["key", "value"],
|
|
441
|
+
PropertyDefinition: ["key", "value"],
|
|
442
|
+
RestElement: ["argument"],
|
|
443
|
+
ReturnStatement: ["argument"],
|
|
444
|
+
SequenceExpression: ["expressions"],
|
|
445
|
+
SpreadElement: ["argument"],
|
|
446
|
+
StaticBlock: ["body"],
|
|
447
|
+
Super: [],
|
|
448
|
+
SwitchCase: ["test", "consequent"],
|
|
449
|
+
SwitchStatement: ["discriminant", "cases"],
|
|
450
|
+
TaggedTemplateExpression: ["tag", "quasi"],
|
|
451
|
+
TemplateElement: [],
|
|
452
|
+
TemplateLiteral: ["quasis", "expressions"],
|
|
453
|
+
ThisExpression: [],
|
|
454
|
+
ThrowStatement: ["argument"],
|
|
455
|
+
TryStatement: ["block", "handler", "finalizer"],
|
|
456
|
+
UnaryExpression: ["argument"],
|
|
457
|
+
UpdateExpression: ["argument"],
|
|
458
|
+
VariableDeclaration: ["declarations"],
|
|
459
|
+
VariableDeclarator: ["id", "init"],
|
|
460
|
+
WhileStatement: ["test", "body"],
|
|
461
|
+
WithStatement: ["object", "body"],
|
|
462
|
+
YieldExpression: ["argument"]
|
|
463
|
+
};
|
|
464
|
+
var NODE_TYPES = Object.keys(KEYS);
|
|
465
|
+
for (const type of NODE_TYPES) {
|
|
466
|
+
Object.freeze(KEYS[type]);
|
|
467
|
+
}
|
|
468
|
+
Object.freeze(KEYS);
|
|
469
|
+
var visitor_keys_default = KEYS;
|
|
470
|
+
|
|
471
|
+
// ../../node_modules/eslint-visitor-keys/lib/index.js
|
|
472
|
+
function unionWith(additionalKeys) {
|
|
473
|
+
const retv = (
|
|
474
|
+
/** @type {{ [type: string]: ReadonlyArray<string> }} */
|
|
475
|
+
Object.assign({}, visitor_keys_default)
|
|
476
|
+
);
|
|
477
|
+
for (const type of Object.keys(additionalKeys)) {
|
|
478
|
+
if (Object.hasOwn(retv, type)) {
|
|
479
|
+
const keys = new Set(additionalKeys[type]);
|
|
480
|
+
for (const key of retv[type]) {
|
|
481
|
+
keys.add(key);
|
|
482
|
+
}
|
|
483
|
+
retv[type] = Object.freeze(Array.from(keys));
|
|
484
|
+
} else {
|
|
485
|
+
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return Object.freeze(retv);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// ../../node_modules/toml-eslint-parser/lib/index.mjs
|
|
492
|
+
function last(arr) {
|
|
493
|
+
return arr[arr.length - 1] ?? null;
|
|
494
|
+
}
|
|
495
|
+
function toKeyName(node) {
|
|
496
|
+
return node.type === "TOMLBare" ? node.name : node.value;
|
|
497
|
+
}
|
|
498
|
+
var TOMLVerImpl = class {
|
|
499
|
+
constructor(major, minor) {
|
|
500
|
+
this.major = major;
|
|
501
|
+
this.minor = minor;
|
|
502
|
+
}
|
|
503
|
+
lt(major, minor) {
|
|
504
|
+
return this.major < major || this.major === major && this.minor < minor;
|
|
505
|
+
}
|
|
506
|
+
gte(major, minor) {
|
|
507
|
+
return this.major > major || this.major === major && this.minor >= minor;
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
var TOML_VERSION_1_0 = new TOMLVerImpl(1, 0);
|
|
511
|
+
var TOML_VERSION_1_1 = new TOMLVerImpl(1, 1);
|
|
512
|
+
var DEFAULT_TOML_VERSION = TOML_VERSION_1_1;
|
|
513
|
+
var SUPPORTED_TOML_VERSIONS = {
|
|
514
|
+
"1.0": TOML_VERSION_1_0,
|
|
515
|
+
"1.0.0": TOML_VERSION_1_0,
|
|
516
|
+
"1.1": TOML_VERSION_1_1,
|
|
517
|
+
"1.1.0": TOML_VERSION_1_1,
|
|
518
|
+
latest: TOML_VERSION_1_1,
|
|
519
|
+
next: TOML_VERSION_1_1
|
|
520
|
+
};
|
|
521
|
+
function getTOMLVer(v) {
|
|
522
|
+
return v && SUPPORTED_TOML_VERSIONS[v] || DEFAULT_TOML_VERSION;
|
|
523
|
+
}
|
|
524
|
+
var MESSAGES = {
|
|
525
|
+
"unterminated-string": "Unterminated string constant",
|
|
526
|
+
"unterminated-table-key": "Unterminated table-key",
|
|
527
|
+
"unterminated-array": "Unterminated array",
|
|
528
|
+
"unterminated-inline-table": "Unterminated inline table",
|
|
529
|
+
"missing-key": "Empty bare keys are not allowed",
|
|
530
|
+
"missing-newline": "Must be a newline",
|
|
531
|
+
"missing-equals-sign": "Expected equal (=) token",
|
|
532
|
+
"missing-value": "Unspecified values are invalid",
|
|
533
|
+
"missing-comma": "Expected comma (,) token",
|
|
534
|
+
"dupe-keys": "Defining a key multiple times is invalid",
|
|
535
|
+
"unexpected-char": "Unexpected character",
|
|
536
|
+
"unexpected-token": "Unexpected token",
|
|
537
|
+
"invalid-control-character": "Control characters (codes < 0x1f and 0x7f) are not allowed",
|
|
538
|
+
"invalid-comment-character": "Invalid code point {{cp}} within comments",
|
|
539
|
+
"invalid-key-value-newline": "The key, equals sign, and value must be on the same line",
|
|
540
|
+
"invalid-inline-table-newline": "No newlines are allowed between the curly braces unless they are valid within a value",
|
|
541
|
+
"invalid-underscore": "Underscores are allowed between digits",
|
|
542
|
+
"invalid-space": "Unexpected spaces",
|
|
543
|
+
"invalid-three-quotes": "Three or more quotes are not permitted",
|
|
544
|
+
"invalid-date": "Unexpected invalid date",
|
|
545
|
+
"invalid-time": "Unexpected invalid time",
|
|
546
|
+
"invalid-leading-zero": "Leading zeros are not allowed",
|
|
547
|
+
"invalid-trailing-comma-in-inline-table": "Trailing comma is not permitted in an inline table",
|
|
548
|
+
"invalid-char-in-escape-sequence": "Invalid character in escape sequence",
|
|
549
|
+
"invalid-consecutive-dots-in-key": "Consecutive dots are not permitted in keys",
|
|
550
|
+
"invalid-code-point": "Invalid code point {{cp}}",
|
|
551
|
+
"invalid-trailing-dot-in-key": "Keys cannot end with a dot",
|
|
552
|
+
"invalid-leading-dot-in-key": "Keys cannot start with a dot"
|
|
553
|
+
};
|
|
554
|
+
function getMessage(code, data) {
|
|
555
|
+
if (data) return MESSAGES[code].replace(/\{\{(.*?)\}\}/gu, (_, name$2) => {
|
|
556
|
+
if (name$2 in data) return data[name$2];
|
|
557
|
+
return `{{${name$2}}}`;
|
|
558
|
+
});
|
|
559
|
+
return MESSAGES[code];
|
|
560
|
+
}
|
|
561
|
+
var ParseError = class extends SyntaxError {
|
|
562
|
+
/**
|
|
563
|
+
* Initialize this ParseError instance.
|
|
564
|
+
*
|
|
565
|
+
*/
|
|
566
|
+
constructor(code, offset, line, column, data) {
|
|
567
|
+
super(getMessage(code, data));
|
|
568
|
+
this.index = offset;
|
|
569
|
+
this.lineNumber = line;
|
|
570
|
+
this.column = column;
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
var CodePoint = {
|
|
574
|
+
EOF: -1,
|
|
575
|
+
NULL: 0,
|
|
576
|
+
SOH: 1,
|
|
577
|
+
BACKSPACE: 8,
|
|
578
|
+
TABULATION: 9,
|
|
579
|
+
LINE_FEED: 10,
|
|
580
|
+
FORM_FEED: 12,
|
|
581
|
+
CARRIAGE_RETURN: 13,
|
|
582
|
+
ESCAPE: 27,
|
|
583
|
+
SO: 14,
|
|
584
|
+
US: 31,
|
|
585
|
+
SPACE: 32,
|
|
586
|
+
QUOTATION_MARK: 34,
|
|
587
|
+
HASH: 35,
|
|
588
|
+
SINGLE_QUOTE: 39,
|
|
589
|
+
PLUS_SIGN: 43,
|
|
590
|
+
COMMA: 44,
|
|
591
|
+
DASH: 45,
|
|
592
|
+
DOT: 46,
|
|
593
|
+
DIGIT_0: 48,
|
|
594
|
+
DIGIT_1: 49,
|
|
595
|
+
DIGIT_2: 50,
|
|
596
|
+
DIGIT_3: 51,
|
|
597
|
+
DIGIT_7: 55,
|
|
598
|
+
DIGIT_9: 57,
|
|
599
|
+
COLON: 58,
|
|
600
|
+
EQUALS_SIGN: 61,
|
|
601
|
+
LATIN_CAPITAL_A: 65,
|
|
602
|
+
LATIN_CAPITAL_E: 69,
|
|
603
|
+
LATIN_CAPITAL_F: 70,
|
|
604
|
+
LATIN_CAPITAL_T: 84,
|
|
605
|
+
LATIN_CAPITAL_U: 85,
|
|
606
|
+
LATIN_CAPITAL_Z: 90,
|
|
607
|
+
LEFT_BRACKET: 91,
|
|
608
|
+
BACKSLASH: 92,
|
|
609
|
+
RIGHT_BRACKET: 93,
|
|
610
|
+
UNDERSCORE: 95,
|
|
611
|
+
LATIN_SMALL_A: 97,
|
|
612
|
+
LATIN_SMALL_B: 98,
|
|
613
|
+
LATIN_SMALL_E: 101,
|
|
614
|
+
LATIN_SMALL_F: 102,
|
|
615
|
+
LATIN_SMALL_I: 105,
|
|
616
|
+
LATIN_SMALL_L: 108,
|
|
617
|
+
LATIN_SMALL_N: 110,
|
|
618
|
+
LATIN_SMALL_O: 111,
|
|
619
|
+
LATIN_SMALL_R: 114,
|
|
620
|
+
LATIN_SMALL_S: 115,
|
|
621
|
+
LATIN_SMALL_T: 116,
|
|
622
|
+
LATIN_SMALL_U: 117,
|
|
623
|
+
LATIN_SMALL_X: 120,
|
|
624
|
+
LATIN_SMALL_Z: 122,
|
|
625
|
+
LEFT_BRACE: 123,
|
|
626
|
+
RIGHT_BRACE: 125,
|
|
627
|
+
TILDE: 126,
|
|
628
|
+
DELETE: 127,
|
|
629
|
+
PAD: 128,
|
|
630
|
+
SUPERSCRIPT_TWO: 178,
|
|
631
|
+
SUPERSCRIPT_THREE: 179,
|
|
632
|
+
SUPERSCRIPT_ONE: 185,
|
|
633
|
+
VULGAR_FRACTION_ONE_QUARTER: 188,
|
|
634
|
+
VULGAR_FRACTION_THREE_QUARTERS: 190,
|
|
635
|
+
LATIN_CAPITAL_LETTER_A_WITH_GRAVE: 192,
|
|
636
|
+
LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS: 214,
|
|
637
|
+
LATIN_CAPITAL_LETTER_O_WITH_STROKE: 216,
|
|
638
|
+
LATIN_SMALL_LETTER_O_WITH_DIAERESIS: 246,
|
|
639
|
+
LATIN_SMALL_LETTER_O_WITH_STROKE: 248,
|
|
640
|
+
GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL: 891,
|
|
641
|
+
GREEK_CAPITAL_LETTER_YOT: 895,
|
|
642
|
+
CP_1FFF: 8191,
|
|
643
|
+
ZERO_WIDTH_NON_JOINER: 8204,
|
|
644
|
+
ZERO_WIDTH_JOINER: 8205,
|
|
645
|
+
UNDERTIE: 8255,
|
|
646
|
+
CHARACTER_TIE: 8256,
|
|
647
|
+
SUPERSCRIPT_ZERO: 8304,
|
|
648
|
+
CP_218F: 8591,
|
|
649
|
+
CIRCLED_DIGIT_ONE: 9312,
|
|
650
|
+
NEGATIVE_CIRCLED_DIGIT_ZERO: 9471,
|
|
651
|
+
GLAGOLITIC_CAPITAL_LETTER_AZU: 11264,
|
|
652
|
+
CP_2FEF: 12271,
|
|
653
|
+
IDEOGRAPHIC_COMMA: 12289,
|
|
654
|
+
CP_D7FF: 55295,
|
|
655
|
+
CP_E000: 57344,
|
|
656
|
+
CJK_COMPATIBILITY_IDEOGRAPH_F900: 63744,
|
|
657
|
+
ARABIC_LIGATURE_SALAAMUHU_ALAYNAA: 64975,
|
|
658
|
+
ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM: 65008,
|
|
659
|
+
REPLACEMENT_CHARACTER: 65533,
|
|
660
|
+
LINEAR_B_SYLLABLE_B008_A: 65536,
|
|
661
|
+
CP_EFFFF: 983039,
|
|
662
|
+
CP_10FFFF: 1114111
|
|
663
|
+
};
|
|
664
|
+
function isControl(cp2) {
|
|
665
|
+
return cp2 >= CodePoint.NULL && cp2 <= CodePoint.US;
|
|
666
|
+
}
|
|
667
|
+
function isWhitespace(cp2) {
|
|
668
|
+
return cp2 === CodePoint.TABULATION || cp2 === CodePoint.SPACE;
|
|
669
|
+
}
|
|
670
|
+
function isEOL(cp2) {
|
|
671
|
+
return cp2 === CodePoint.LINE_FEED || cp2 === CodePoint.CARRIAGE_RETURN;
|
|
672
|
+
}
|
|
673
|
+
function isUpperLetter(cp2) {
|
|
674
|
+
return cp2 >= CodePoint.LATIN_CAPITAL_A && cp2 <= CodePoint.LATIN_CAPITAL_Z;
|
|
675
|
+
}
|
|
676
|
+
function isLowerLetter(cp2) {
|
|
677
|
+
return cp2 >= CodePoint.LATIN_SMALL_A && cp2 <= CodePoint.LATIN_SMALL_Z;
|
|
678
|
+
}
|
|
679
|
+
function isLetter(cp2) {
|
|
680
|
+
return isLowerLetter(cp2) || isUpperLetter(cp2);
|
|
681
|
+
}
|
|
682
|
+
function isDigit(cp2) {
|
|
683
|
+
return cp2 >= CodePoint.DIGIT_0 && cp2 <= CodePoint.DIGIT_9;
|
|
684
|
+
}
|
|
685
|
+
function isHexDig(cp2) {
|
|
686
|
+
return isDigit(cp2) || cp2 >= CodePoint.LATIN_SMALL_A && cp2 <= CodePoint.LATIN_SMALL_F || cp2 >= CodePoint.LATIN_CAPITAL_A && cp2 <= CodePoint.LATIN_CAPITAL_F;
|
|
687
|
+
}
|
|
688
|
+
function isOctalDig(cp2) {
|
|
689
|
+
return cp2 >= CodePoint.DIGIT_0 && cp2 <= CodePoint.DIGIT_7;
|
|
690
|
+
}
|
|
691
|
+
function isUnicodeScalarValue(cp2) {
|
|
692
|
+
return cp2 >= 0 && cp2 <= 55295 || cp2 >= 57344 && cp2 <= 1114111;
|
|
693
|
+
}
|
|
694
|
+
function sortedLastIndex(array, value) {
|
|
695
|
+
let low = 0;
|
|
696
|
+
let high = array.length;
|
|
697
|
+
while (low < high) {
|
|
698
|
+
const mid = low + high >>> 1;
|
|
699
|
+
const val = array[mid];
|
|
700
|
+
if (val === value) return mid + 1;
|
|
701
|
+
if (val < value) low = mid + 1;
|
|
702
|
+
else high = mid;
|
|
703
|
+
}
|
|
704
|
+
return low;
|
|
705
|
+
}
|
|
706
|
+
var Locations = class {
|
|
707
|
+
constructor() {
|
|
708
|
+
this.offsets = [];
|
|
709
|
+
}
|
|
710
|
+
addOffset(offset) {
|
|
711
|
+
for (let i = this.offsets.length - 1; i >= 0; i--) {
|
|
712
|
+
const element = this.offsets[i];
|
|
713
|
+
if (element === offset) return;
|
|
714
|
+
if (element < offset) break;
|
|
715
|
+
}
|
|
716
|
+
this.offsets.push(offset);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Calculate the location of the given index.
|
|
720
|
+
* @param index The index to calculate their location.
|
|
721
|
+
* @returns The location of the index.
|
|
722
|
+
*/
|
|
723
|
+
getLocFromIndex(offset) {
|
|
724
|
+
const line = sortedLastIndex(this.offsets, offset) + 1;
|
|
725
|
+
return {
|
|
726
|
+
line,
|
|
727
|
+
column: offset - (line === 1 ? 0 : this.offsets[line - 2])
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
var CodePointIterator = class {
|
|
732
|
+
/**
|
|
733
|
+
* Initialize this char iterator.
|
|
734
|
+
*/
|
|
735
|
+
constructor(text) {
|
|
736
|
+
this.locs = new Locations();
|
|
737
|
+
this.lastCodePoint = CodePoint.NULL;
|
|
738
|
+
this.start = -1;
|
|
739
|
+
this.end = 0;
|
|
740
|
+
this.text = text;
|
|
741
|
+
}
|
|
742
|
+
next() {
|
|
743
|
+
if (this.lastCodePoint === CodePoint.EOF) return CodePoint.EOF;
|
|
744
|
+
return this.lastCodePoint = this.moveAt(this.end);
|
|
745
|
+
}
|
|
746
|
+
getLocFromIndex(index) {
|
|
747
|
+
return this.locs.getLocFromIndex(index);
|
|
748
|
+
}
|
|
749
|
+
eat(cp2) {
|
|
750
|
+
if (this.text.codePointAt(this.end) === cp2) {
|
|
751
|
+
this.next();
|
|
752
|
+
return true;
|
|
753
|
+
}
|
|
754
|
+
return false;
|
|
755
|
+
}
|
|
756
|
+
moveAt(offset) {
|
|
757
|
+
this.start = this.end = offset;
|
|
758
|
+
const cp2 = this.text.codePointAt(this.start) ?? CodePoint.EOF;
|
|
759
|
+
if (cp2 === CodePoint.EOF) {
|
|
760
|
+
this.end = this.start;
|
|
761
|
+
return cp2;
|
|
762
|
+
}
|
|
763
|
+
this.end += cp2 >= 65536 ? 2 : 1;
|
|
764
|
+
if (cp2 === CodePoint.LINE_FEED) this.locs.addOffset(this.end);
|
|
765
|
+
else if (cp2 === CodePoint.CARRIAGE_RETURN) {
|
|
766
|
+
if (this.text.codePointAt(this.end) === CodePoint.LINE_FEED) {
|
|
767
|
+
this.end++;
|
|
768
|
+
this.locs.addOffset(this.end);
|
|
769
|
+
}
|
|
770
|
+
return CodePoint.LINE_FEED;
|
|
771
|
+
}
|
|
772
|
+
return cp2;
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
var HAS_BIGINT = typeof BigInt !== "undefined";
|
|
776
|
+
var RADIX_PREFIXES = {
|
|
777
|
+
16: "0x",
|
|
778
|
+
10: "",
|
|
779
|
+
8: "0o",
|
|
780
|
+
2: "0b"
|
|
781
|
+
};
|
|
782
|
+
var ESCAPES_1_0 = {
|
|
783
|
+
[CodePoint.QUOTATION_MARK]: CodePoint.QUOTATION_MARK,
|
|
784
|
+
[CodePoint.BACKSLASH]: CodePoint.BACKSLASH,
|
|
785
|
+
[CodePoint.LATIN_SMALL_B]: CodePoint.BACKSPACE,
|
|
786
|
+
[CodePoint.LATIN_SMALL_F]: CodePoint.FORM_FEED,
|
|
787
|
+
[CodePoint.LATIN_SMALL_N]: CodePoint.LINE_FEED,
|
|
788
|
+
[CodePoint.LATIN_SMALL_R]: CodePoint.CARRIAGE_RETURN,
|
|
789
|
+
[CodePoint.LATIN_SMALL_T]: CodePoint.TABULATION
|
|
790
|
+
};
|
|
791
|
+
var ESCAPES_LATEST = {
|
|
792
|
+
...ESCAPES_1_0,
|
|
793
|
+
[CodePoint.LATIN_SMALL_E]: CodePoint.ESCAPE
|
|
794
|
+
};
|
|
795
|
+
var Tokenizer = class {
|
|
796
|
+
/**
|
|
797
|
+
* Initialize this tokenizer.
|
|
798
|
+
*/
|
|
799
|
+
constructor(text, parserOptions) {
|
|
800
|
+
this.backCode = false;
|
|
801
|
+
this.lastCodePoint = CodePoint.NULL;
|
|
802
|
+
this.state = "DATA";
|
|
803
|
+
this.token = null;
|
|
804
|
+
this.tokenStart = -1;
|
|
805
|
+
this.valuesEnabled = false;
|
|
806
|
+
this.text = text;
|
|
807
|
+
this.parserOptions = parserOptions || {};
|
|
808
|
+
this.codePointIterator = new CodePointIterator(text);
|
|
809
|
+
this.tomlVersion = getTOMLVer(this.parserOptions.tomlVersion);
|
|
810
|
+
this.ESCAPES = this.tomlVersion.gte(1, 1) ? ESCAPES_LATEST : ESCAPES_1_0;
|
|
811
|
+
}
|
|
812
|
+
get start() {
|
|
813
|
+
return this.codePointIterator.start;
|
|
814
|
+
}
|
|
815
|
+
get end() {
|
|
816
|
+
return this.codePointIterator.end;
|
|
817
|
+
}
|
|
818
|
+
getLocFromIndex(index) {
|
|
819
|
+
return this.codePointIterator.getLocFromIndex(index);
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Report an invalid character error.
|
|
823
|
+
*/
|
|
824
|
+
reportParseError(code, data) {
|
|
825
|
+
const offset = this.codePointIterator.start;
|
|
826
|
+
const loc = this.codePointIterator.getLocFromIndex(offset);
|
|
827
|
+
throw new ParseError(code, offset, loc.line, loc.column, data);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Get the next token.
|
|
831
|
+
*/
|
|
832
|
+
nextToken() {
|
|
833
|
+
let token = this.token;
|
|
834
|
+
if (token != null) {
|
|
835
|
+
this.token = null;
|
|
836
|
+
return token;
|
|
837
|
+
}
|
|
838
|
+
let cp2 = this.lastCodePoint;
|
|
839
|
+
while (cp2 !== CodePoint.EOF && !this.token) {
|
|
840
|
+
cp2 = this.nextCode();
|
|
841
|
+
const nextState = this[this.state](cp2);
|
|
842
|
+
if (!nextState) throw new Error(`Unknown error: pre state=${this.state}`);
|
|
843
|
+
this.state = nextState;
|
|
844
|
+
}
|
|
845
|
+
token = this.token;
|
|
846
|
+
this.token = null;
|
|
847
|
+
return token;
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Get the next code point.
|
|
851
|
+
*/
|
|
852
|
+
nextCode() {
|
|
853
|
+
if (this.lastCodePoint === CodePoint.EOF) return CodePoint.EOF;
|
|
854
|
+
if (this.backCode) {
|
|
855
|
+
this.backCode = false;
|
|
856
|
+
return this.lastCodePoint;
|
|
857
|
+
}
|
|
858
|
+
return this.lastCodePoint = this.codePointIterator.next();
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Eat the next code point.
|
|
862
|
+
*/
|
|
863
|
+
eatCode(cp2) {
|
|
864
|
+
if (this.lastCodePoint === CodePoint.EOF) return false;
|
|
865
|
+
if (this.backCode) {
|
|
866
|
+
if (this.lastCodePoint === cp2) {
|
|
867
|
+
this.backCode = false;
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
return this.codePointIterator.eat(cp2);
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Moves the character position to the given position.
|
|
876
|
+
*/
|
|
877
|
+
moveAt(loc) {
|
|
878
|
+
if (this.backCode) this.backCode = false;
|
|
879
|
+
this.lastCodePoint = this.codePointIterator.moveAt(loc);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Back the current code point as the given state.
|
|
883
|
+
*/
|
|
884
|
+
back(state) {
|
|
885
|
+
this.backCode = true;
|
|
886
|
+
return state;
|
|
887
|
+
}
|
|
888
|
+
punctuatorToken() {
|
|
889
|
+
this.startToken();
|
|
890
|
+
this.endToken("Punctuator", "end");
|
|
891
|
+
}
|
|
892
|
+
startToken() {
|
|
893
|
+
this.tokenStart = this.codePointIterator.start;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Commit the current token.
|
|
897
|
+
*/
|
|
898
|
+
endToken(type, pos, option1, option2) {
|
|
899
|
+
const { tokenStart } = this;
|
|
900
|
+
const end = this.codePointIterator[pos];
|
|
901
|
+
const range = [tokenStart, end];
|
|
902
|
+
const loc = {
|
|
903
|
+
start: this.codePointIterator.getLocFromIndex(tokenStart),
|
|
904
|
+
end: this.codePointIterator.getLocFromIndex(end)
|
|
905
|
+
};
|
|
906
|
+
if (type === "Block") this.token = {
|
|
907
|
+
type,
|
|
908
|
+
value: this.text.slice(tokenStart + 1, end),
|
|
909
|
+
range,
|
|
910
|
+
loc
|
|
911
|
+
};
|
|
912
|
+
else {
|
|
913
|
+
let token;
|
|
914
|
+
const value = this.text.slice(tokenStart, end);
|
|
915
|
+
if (type === "BasicString" || type === "LiteralString" || type === "MultiLineBasicString" || type === "MultiLineLiteralString") token = {
|
|
916
|
+
type,
|
|
917
|
+
value,
|
|
918
|
+
string: option1,
|
|
919
|
+
range,
|
|
920
|
+
loc
|
|
921
|
+
};
|
|
922
|
+
else if (type === "Integer") {
|
|
923
|
+
const text = option1;
|
|
924
|
+
token = {
|
|
925
|
+
type,
|
|
926
|
+
value,
|
|
927
|
+
number: parseInt(text, option2),
|
|
928
|
+
bigint: HAS_BIGINT ? BigInt(RADIX_PREFIXES[option2] + text) : null,
|
|
929
|
+
range,
|
|
930
|
+
loc
|
|
931
|
+
};
|
|
932
|
+
} else if (type === "Float") token = {
|
|
933
|
+
type,
|
|
934
|
+
value,
|
|
935
|
+
number: option1,
|
|
936
|
+
range,
|
|
937
|
+
loc
|
|
938
|
+
};
|
|
939
|
+
else if (type === "Boolean") token = {
|
|
940
|
+
type,
|
|
941
|
+
value,
|
|
942
|
+
boolean: option1,
|
|
943
|
+
range,
|
|
944
|
+
loc
|
|
945
|
+
};
|
|
946
|
+
else if (type === "LocalDate" || type === "LocalTime" || type === "LocalDateTime" || type === "OffsetDateTime") token = {
|
|
947
|
+
type,
|
|
948
|
+
value,
|
|
949
|
+
date: option1,
|
|
950
|
+
range,
|
|
951
|
+
loc
|
|
952
|
+
};
|
|
953
|
+
else token = {
|
|
954
|
+
type,
|
|
955
|
+
value,
|
|
956
|
+
range,
|
|
957
|
+
loc
|
|
958
|
+
};
|
|
959
|
+
this.token = token;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
DATA(cp2) {
|
|
963
|
+
while (isWhitespace(cp2) || isEOL(cp2)) cp2 = this.nextCode();
|
|
964
|
+
if (cp2 === CodePoint.HASH) {
|
|
965
|
+
this.startToken();
|
|
966
|
+
return "COMMENT";
|
|
967
|
+
}
|
|
968
|
+
if (cp2 === CodePoint.QUOTATION_MARK) {
|
|
969
|
+
this.startToken();
|
|
970
|
+
return "BASIC_STRING";
|
|
971
|
+
}
|
|
972
|
+
if (cp2 === CodePoint.SINGLE_QUOTE) {
|
|
973
|
+
this.startToken();
|
|
974
|
+
return "LITERAL_STRING";
|
|
975
|
+
}
|
|
976
|
+
if (cp2 === CodePoint.DOT || cp2 === CodePoint.EQUALS_SIGN || cp2 === CodePoint.LEFT_BRACKET || cp2 === CodePoint.RIGHT_BRACKET || cp2 === CodePoint.LEFT_BRACE || cp2 === CodePoint.RIGHT_BRACE || cp2 === CodePoint.COMMA) {
|
|
977
|
+
this.punctuatorToken();
|
|
978
|
+
return "DATA";
|
|
979
|
+
}
|
|
980
|
+
if (this.valuesEnabled) {
|
|
981
|
+
if (cp2 === CodePoint.DASH || cp2 === CodePoint.PLUS_SIGN) {
|
|
982
|
+
this.startToken();
|
|
983
|
+
return "SIGN";
|
|
984
|
+
}
|
|
985
|
+
if (cp2 === CodePoint.LATIN_SMALL_N || cp2 === CodePoint.LATIN_SMALL_I) {
|
|
986
|
+
this.startToken();
|
|
987
|
+
return this.back("NAN_OR_INF");
|
|
988
|
+
}
|
|
989
|
+
if (isDigit(cp2)) {
|
|
990
|
+
this.startToken();
|
|
991
|
+
return this.back("NUMBER");
|
|
992
|
+
}
|
|
993
|
+
if (cp2 === CodePoint.LATIN_SMALL_T || cp2 === CodePoint.LATIN_SMALL_F) {
|
|
994
|
+
this.startToken();
|
|
995
|
+
return this.back("BOOLEAN");
|
|
996
|
+
}
|
|
997
|
+
} else if (isUnquotedKeyChar(cp2, this.tomlVersion)) {
|
|
998
|
+
this.startToken();
|
|
999
|
+
return "BARE";
|
|
1000
|
+
}
|
|
1001
|
+
if (cp2 === CodePoint.EOF) return "DATA";
|
|
1002
|
+
return this.reportParseError("unexpected-char");
|
|
1003
|
+
}
|
|
1004
|
+
COMMENT(cp2) {
|
|
1005
|
+
const processCommentChar = this.tomlVersion.gte(1, 1) ? (c) => {
|
|
1006
|
+
if (!isNonEOL(c)) this.reportParseError("invalid-comment-character", { cp: JSON.stringify(String.fromCodePoint(c)).slice(1, -1) });
|
|
1007
|
+
} : (c) => {
|
|
1008
|
+
if (isControlOtherThanTab(c)) this.reportParseErrorControlChar();
|
|
1009
|
+
};
|
|
1010
|
+
while (!isEOL(cp2) && cp2 !== CodePoint.EOF) {
|
|
1011
|
+
processCommentChar(cp2);
|
|
1012
|
+
cp2 = this.nextCode();
|
|
1013
|
+
}
|
|
1014
|
+
this.endToken("Block", "start");
|
|
1015
|
+
return "DATA";
|
|
1016
|
+
}
|
|
1017
|
+
BARE(cp2) {
|
|
1018
|
+
while (isUnquotedKeyChar(cp2, this.tomlVersion)) cp2 = this.nextCode();
|
|
1019
|
+
this.endToken("Bare", "start");
|
|
1020
|
+
return this.back("DATA");
|
|
1021
|
+
}
|
|
1022
|
+
BASIC_STRING(cp2) {
|
|
1023
|
+
if (cp2 === CodePoint.QUOTATION_MARK) {
|
|
1024
|
+
cp2 = this.nextCode();
|
|
1025
|
+
if (cp2 === CodePoint.QUOTATION_MARK) return "MULTI_LINE_BASIC_STRING";
|
|
1026
|
+
this.endToken("BasicString", "start", "");
|
|
1027
|
+
return this.back("DATA");
|
|
1028
|
+
}
|
|
1029
|
+
const out = [];
|
|
1030
|
+
while (cp2 !== CodePoint.QUOTATION_MARK && cp2 !== CodePoint.EOF && cp2 !== CodePoint.LINE_FEED) {
|
|
1031
|
+
if (isControlOtherThanTab(cp2)) return this.reportParseErrorControlChar();
|
|
1032
|
+
if (cp2 === CodePoint.BACKSLASH) {
|
|
1033
|
+
cp2 = this.nextCode();
|
|
1034
|
+
const ecp = this.ESCAPES[cp2];
|
|
1035
|
+
if (ecp) {
|
|
1036
|
+
out.push(ecp);
|
|
1037
|
+
cp2 = this.nextCode();
|
|
1038
|
+
continue;
|
|
1039
|
+
} else if (cp2 === CodePoint.LATIN_SMALL_U) {
|
|
1040
|
+
const code = this.parseUnicode(4);
|
|
1041
|
+
out.push(code);
|
|
1042
|
+
cp2 = this.nextCode();
|
|
1043
|
+
continue;
|
|
1044
|
+
} else if (cp2 === CodePoint.LATIN_CAPITAL_U) {
|
|
1045
|
+
const code = this.parseUnicode(8);
|
|
1046
|
+
out.push(code);
|
|
1047
|
+
cp2 = this.nextCode();
|
|
1048
|
+
continue;
|
|
1049
|
+
} else if (cp2 === CodePoint.LATIN_SMALL_X && this.tomlVersion.gte(1, 1)) {
|
|
1050
|
+
const code = this.parseUnicode(2);
|
|
1051
|
+
out.push(code);
|
|
1052
|
+
cp2 = this.nextCode();
|
|
1053
|
+
continue;
|
|
1054
|
+
}
|
|
1055
|
+
return this.reportParseError("invalid-char-in-escape-sequence");
|
|
1056
|
+
}
|
|
1057
|
+
out.push(cp2);
|
|
1058
|
+
cp2 = this.nextCode();
|
|
1059
|
+
}
|
|
1060
|
+
if (cp2 !== CodePoint.QUOTATION_MARK) return this.reportParseError("unterminated-string");
|
|
1061
|
+
this.endToken("BasicString", "end", String.fromCodePoint(...out));
|
|
1062
|
+
return "DATA";
|
|
1063
|
+
}
|
|
1064
|
+
MULTI_LINE_BASIC_STRING(cp2) {
|
|
1065
|
+
const out = [];
|
|
1066
|
+
if (cp2 === CodePoint.LINE_FEED) cp2 = this.nextCode();
|
|
1067
|
+
while (cp2 !== CodePoint.EOF) {
|
|
1068
|
+
if (cp2 !== CodePoint.LINE_FEED && isControlOtherThanTab(cp2)) return this.reportParseErrorControlChar();
|
|
1069
|
+
if (cp2 === CodePoint.QUOTATION_MARK) {
|
|
1070
|
+
const startPos = this.codePointIterator.start;
|
|
1071
|
+
if (this.eatCode(CodePoint.QUOTATION_MARK) && this.eatCode(CodePoint.QUOTATION_MARK)) {
|
|
1072
|
+
if (this.eatCode(CodePoint.QUOTATION_MARK)) {
|
|
1073
|
+
out.push(CodePoint.QUOTATION_MARK);
|
|
1074
|
+
if (this.eatCode(CodePoint.QUOTATION_MARK)) {
|
|
1075
|
+
out.push(CodePoint.QUOTATION_MARK);
|
|
1076
|
+
if (this.eatCode(CodePoint.QUOTATION_MARK)) {
|
|
1077
|
+
this.moveAt(startPos);
|
|
1078
|
+
return this.reportParseError("invalid-three-quotes");
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
this.endToken("MultiLineBasicString", "end", String.fromCodePoint(...out));
|
|
1083
|
+
return "DATA";
|
|
1084
|
+
}
|
|
1085
|
+
this.moveAt(startPos);
|
|
1086
|
+
}
|
|
1087
|
+
if (cp2 === CodePoint.BACKSLASH) {
|
|
1088
|
+
cp2 = this.nextCode();
|
|
1089
|
+
const ecp = this.ESCAPES[cp2];
|
|
1090
|
+
if (ecp) {
|
|
1091
|
+
out.push(ecp);
|
|
1092
|
+
cp2 = this.nextCode();
|
|
1093
|
+
continue;
|
|
1094
|
+
} else if (cp2 === CodePoint.LATIN_SMALL_U) {
|
|
1095
|
+
const code = this.parseUnicode(4);
|
|
1096
|
+
out.push(code);
|
|
1097
|
+
cp2 = this.nextCode();
|
|
1098
|
+
continue;
|
|
1099
|
+
} else if (cp2 === CodePoint.LATIN_CAPITAL_U) {
|
|
1100
|
+
const code = this.parseUnicode(8);
|
|
1101
|
+
out.push(code);
|
|
1102
|
+
cp2 = this.nextCode();
|
|
1103
|
+
continue;
|
|
1104
|
+
} else if (cp2 === CodePoint.LATIN_SMALL_X && this.tomlVersion.gte(1, 1)) {
|
|
1105
|
+
const code = this.parseUnicode(2);
|
|
1106
|
+
out.push(code);
|
|
1107
|
+
cp2 = this.nextCode();
|
|
1108
|
+
continue;
|
|
1109
|
+
} else if (cp2 === CodePoint.LINE_FEED) {
|
|
1110
|
+
cp2 = this.nextCode();
|
|
1111
|
+
while (isWhitespace(cp2) || cp2 === CodePoint.LINE_FEED) cp2 = this.nextCode();
|
|
1112
|
+
continue;
|
|
1113
|
+
} else if (isWhitespace(cp2)) {
|
|
1114
|
+
let valid = true;
|
|
1115
|
+
const startPos = this.codePointIterator.start;
|
|
1116
|
+
let nextCp;
|
|
1117
|
+
while ((nextCp = this.nextCode()) !== CodePoint.EOF) {
|
|
1118
|
+
if (nextCp === CodePoint.LINE_FEED) break;
|
|
1119
|
+
if (!isWhitespace(nextCp)) {
|
|
1120
|
+
this.moveAt(startPos);
|
|
1121
|
+
valid = false;
|
|
1122
|
+
break;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
if (valid) {
|
|
1126
|
+
cp2 = this.nextCode();
|
|
1127
|
+
while (isWhitespace(cp2) || cp2 === CodePoint.LINE_FEED) cp2 = this.nextCode();
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return this.reportParseError("invalid-char-in-escape-sequence");
|
|
1132
|
+
}
|
|
1133
|
+
out.push(cp2);
|
|
1134
|
+
cp2 = this.nextCode();
|
|
1135
|
+
}
|
|
1136
|
+
return this.reportParseError("unterminated-string");
|
|
1137
|
+
}
|
|
1138
|
+
LITERAL_STRING(cp2) {
|
|
1139
|
+
if (cp2 === CodePoint.SINGLE_QUOTE) {
|
|
1140
|
+
cp2 = this.nextCode();
|
|
1141
|
+
if (cp2 === CodePoint.SINGLE_QUOTE) return "MULTI_LINE_LITERAL_STRING";
|
|
1142
|
+
this.endToken("LiteralString", "start", "");
|
|
1143
|
+
return this.back("DATA");
|
|
1144
|
+
}
|
|
1145
|
+
const out = [];
|
|
1146
|
+
while (cp2 !== CodePoint.SINGLE_QUOTE && cp2 !== CodePoint.EOF && cp2 !== CodePoint.LINE_FEED) {
|
|
1147
|
+
if (isControlOtherThanTab(cp2)) return this.reportParseErrorControlChar();
|
|
1148
|
+
out.push(cp2);
|
|
1149
|
+
cp2 = this.nextCode();
|
|
1150
|
+
}
|
|
1151
|
+
if (cp2 !== CodePoint.SINGLE_QUOTE) return this.reportParseError("unterminated-string");
|
|
1152
|
+
this.endToken("LiteralString", "end", String.fromCodePoint(...out));
|
|
1153
|
+
return "DATA";
|
|
1154
|
+
}
|
|
1155
|
+
MULTI_LINE_LITERAL_STRING(cp2) {
|
|
1156
|
+
const out = [];
|
|
1157
|
+
if (cp2 === CodePoint.LINE_FEED) cp2 = this.nextCode();
|
|
1158
|
+
while (cp2 !== CodePoint.EOF) {
|
|
1159
|
+
if (cp2 !== CodePoint.LINE_FEED && isControlOtherThanTab(cp2)) return this.reportParseErrorControlChar();
|
|
1160
|
+
if (cp2 === CodePoint.SINGLE_QUOTE) {
|
|
1161
|
+
const startPos = this.codePointIterator.start;
|
|
1162
|
+
if (this.eatCode(CodePoint.SINGLE_QUOTE) && this.eatCode(CodePoint.SINGLE_QUOTE)) {
|
|
1163
|
+
if (this.eatCode(CodePoint.SINGLE_QUOTE)) {
|
|
1164
|
+
out.push(CodePoint.SINGLE_QUOTE);
|
|
1165
|
+
if (this.eatCode(CodePoint.SINGLE_QUOTE)) {
|
|
1166
|
+
out.push(CodePoint.SINGLE_QUOTE);
|
|
1167
|
+
if (this.eatCode(CodePoint.SINGLE_QUOTE)) {
|
|
1168
|
+
this.moveAt(startPos);
|
|
1169
|
+
return this.reportParseError("invalid-three-quotes");
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
this.endToken("MultiLineLiteralString", "end", String.fromCodePoint(...out));
|
|
1174
|
+
return "DATA";
|
|
1175
|
+
}
|
|
1176
|
+
this.moveAt(startPos);
|
|
1177
|
+
}
|
|
1178
|
+
out.push(cp2);
|
|
1179
|
+
cp2 = this.nextCode();
|
|
1180
|
+
}
|
|
1181
|
+
return this.reportParseError("unterminated-string");
|
|
1182
|
+
}
|
|
1183
|
+
SIGN(cp2) {
|
|
1184
|
+
if (cp2 === CodePoint.LATIN_SMALL_N || cp2 === CodePoint.LATIN_SMALL_I) return this.back("NAN_OR_INF");
|
|
1185
|
+
if (isDigit(cp2)) return this.back("NUMBER");
|
|
1186
|
+
return this.reportParseError("unexpected-char");
|
|
1187
|
+
}
|
|
1188
|
+
NAN_OR_INF(cp2) {
|
|
1189
|
+
if (cp2 === CodePoint.LATIN_SMALL_N) {
|
|
1190
|
+
const startPos = this.codePointIterator.start;
|
|
1191
|
+
if (this.eatCode(CodePoint.LATIN_SMALL_A) && this.eatCode(CodePoint.LATIN_SMALL_N)) {
|
|
1192
|
+
this.endToken("Float", "end", NaN);
|
|
1193
|
+
return "DATA";
|
|
1194
|
+
}
|
|
1195
|
+
this.moveAt(startPos);
|
|
1196
|
+
} else if (cp2 === CodePoint.LATIN_SMALL_I) {
|
|
1197
|
+
const startPos = this.codePointIterator.start;
|
|
1198
|
+
if (this.eatCode(CodePoint.LATIN_SMALL_N) && this.eatCode(CodePoint.LATIN_SMALL_F)) {
|
|
1199
|
+
this.endToken("Float", "end", this.text[this.tokenStart] === "-" ? -Infinity : Infinity);
|
|
1200
|
+
return "DATA";
|
|
1201
|
+
}
|
|
1202
|
+
this.moveAt(startPos);
|
|
1203
|
+
}
|
|
1204
|
+
return this.reportParseError("unexpected-char");
|
|
1205
|
+
}
|
|
1206
|
+
NUMBER(cp2) {
|
|
1207
|
+
const start = this.text[this.tokenStart];
|
|
1208
|
+
const sign = start === "+" ? CodePoint.PLUS_SIGN : start === "-" ? CodePoint.DASH : CodePoint.NULL;
|
|
1209
|
+
if (cp2 === CodePoint.DIGIT_0) {
|
|
1210
|
+
if (sign === CodePoint.NULL) {
|
|
1211
|
+
const startPos = this.codePointIterator.start;
|
|
1212
|
+
const nextCp$1 = this.nextCode();
|
|
1213
|
+
if (isDigit(nextCp$1)) {
|
|
1214
|
+
const nextNextCp = this.nextCode();
|
|
1215
|
+
if (nextNextCp === CodePoint.COLON) {
|
|
1216
|
+
this.data = {
|
|
1217
|
+
hasDate: false,
|
|
1218
|
+
year: 0,
|
|
1219
|
+
month: 0,
|
|
1220
|
+
day: 0,
|
|
1221
|
+
hour: Number(String.fromCodePoint(CodePoint.DIGIT_0, nextCp$1)),
|
|
1222
|
+
minute: 0,
|
|
1223
|
+
second: 0
|
|
1224
|
+
};
|
|
1225
|
+
return "TIME_MINUTE";
|
|
1226
|
+
}
|
|
1227
|
+
if (isDigit(nextNextCp)) {
|
|
1228
|
+
const nextNextNextCp = this.nextCode();
|
|
1229
|
+
if (isDigit(nextNextNextCp) && this.eatCode(CodePoint.DASH)) {
|
|
1230
|
+
this.data = {
|
|
1231
|
+
hasDate: true,
|
|
1232
|
+
year: Number(String.fromCodePoint(CodePoint.DIGIT_0, nextCp$1, nextNextCp, nextNextNextCp)),
|
|
1233
|
+
month: 0,
|
|
1234
|
+
day: 0,
|
|
1235
|
+
hour: 0,
|
|
1236
|
+
minute: 0,
|
|
1237
|
+
second: 0
|
|
1238
|
+
};
|
|
1239
|
+
return "DATE_MONTH";
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
this.moveAt(startPos);
|
|
1243
|
+
return this.reportParseError("invalid-leading-zero");
|
|
1244
|
+
}
|
|
1245
|
+
this.moveAt(startPos);
|
|
1246
|
+
}
|
|
1247
|
+
cp2 = this.nextCode();
|
|
1248
|
+
if (cp2 === CodePoint.LATIN_SMALL_X || cp2 === CodePoint.LATIN_SMALL_O || cp2 === CodePoint.LATIN_SMALL_B) {
|
|
1249
|
+
if (sign !== CodePoint.NULL) return this.reportParseError("unexpected-char");
|
|
1250
|
+
return cp2 === CodePoint.LATIN_SMALL_X ? "HEX" : cp2 === CodePoint.LATIN_SMALL_O ? "OCTAL" : "BINARY";
|
|
1251
|
+
}
|
|
1252
|
+
if (cp2 === CodePoint.LATIN_SMALL_E || cp2 === CodePoint.LATIN_CAPITAL_E) {
|
|
1253
|
+
this.data = {
|
|
1254
|
+
minus: sign === CodePoint.DASH,
|
|
1255
|
+
left: [CodePoint.DIGIT_0]
|
|
1256
|
+
};
|
|
1257
|
+
return "EXPONENT_RIGHT";
|
|
1258
|
+
}
|
|
1259
|
+
if (cp2 === CodePoint.DOT) {
|
|
1260
|
+
this.data = {
|
|
1261
|
+
minus: sign === CodePoint.DASH,
|
|
1262
|
+
absInt: [CodePoint.DIGIT_0]
|
|
1263
|
+
};
|
|
1264
|
+
return "FRACTIONAL_RIGHT";
|
|
1265
|
+
}
|
|
1266
|
+
this.endToken("Integer", "start", "0", 10);
|
|
1267
|
+
return this.back("DATA");
|
|
1268
|
+
}
|
|
1269
|
+
const { out, nextCp, hasUnderscore } = this.parseDigits(cp2, isDigit);
|
|
1270
|
+
if (nextCp === CodePoint.DASH && sign === CodePoint.NULL && !hasUnderscore && out.length === 4) {
|
|
1271
|
+
this.data = {
|
|
1272
|
+
hasDate: true,
|
|
1273
|
+
year: Number(String.fromCodePoint(...out)),
|
|
1274
|
+
month: 0,
|
|
1275
|
+
day: 0,
|
|
1276
|
+
hour: 0,
|
|
1277
|
+
minute: 0,
|
|
1278
|
+
second: 0
|
|
1279
|
+
};
|
|
1280
|
+
return "DATE_MONTH";
|
|
1281
|
+
}
|
|
1282
|
+
if (nextCp === CodePoint.COLON && sign === CodePoint.NULL && !hasUnderscore && out.length === 2) {
|
|
1283
|
+
this.data = {
|
|
1284
|
+
hasDate: false,
|
|
1285
|
+
year: 0,
|
|
1286
|
+
month: 0,
|
|
1287
|
+
day: 0,
|
|
1288
|
+
hour: Number(String.fromCodePoint(...out)),
|
|
1289
|
+
minute: 0,
|
|
1290
|
+
second: 0
|
|
1291
|
+
};
|
|
1292
|
+
return "TIME_MINUTE";
|
|
1293
|
+
}
|
|
1294
|
+
if (nextCp === CodePoint.LATIN_SMALL_E || nextCp === CodePoint.LATIN_CAPITAL_E) {
|
|
1295
|
+
this.data = {
|
|
1296
|
+
minus: sign === CodePoint.DASH,
|
|
1297
|
+
left: out
|
|
1298
|
+
};
|
|
1299
|
+
return "EXPONENT_RIGHT";
|
|
1300
|
+
}
|
|
1301
|
+
if (nextCp === CodePoint.DOT) {
|
|
1302
|
+
this.data = {
|
|
1303
|
+
minus: sign === CodePoint.DASH,
|
|
1304
|
+
absInt: out
|
|
1305
|
+
};
|
|
1306
|
+
return "FRACTIONAL_RIGHT";
|
|
1307
|
+
}
|
|
1308
|
+
this.endToken("Integer", "start", sign === CodePoint.DASH ? String.fromCodePoint(CodePoint.DASH, ...out) : String.fromCodePoint(...out), 10);
|
|
1309
|
+
return this.back("DATA");
|
|
1310
|
+
}
|
|
1311
|
+
HEX(cp2) {
|
|
1312
|
+
const { out } = this.parseDigits(cp2, isHexDig);
|
|
1313
|
+
this.endToken("Integer", "start", String.fromCodePoint(...out), 16);
|
|
1314
|
+
return this.back("DATA");
|
|
1315
|
+
}
|
|
1316
|
+
OCTAL(cp2) {
|
|
1317
|
+
const { out } = this.parseDigits(cp2, isOctalDig);
|
|
1318
|
+
this.endToken("Integer", "start", String.fromCodePoint(...out), 8);
|
|
1319
|
+
return this.back("DATA");
|
|
1320
|
+
}
|
|
1321
|
+
BINARY(cp2) {
|
|
1322
|
+
const { out } = this.parseDigits(cp2, (c) => c === CodePoint.DIGIT_0 || c === CodePoint.DIGIT_1);
|
|
1323
|
+
this.endToken("Integer", "start", String.fromCodePoint(...out), 2);
|
|
1324
|
+
return this.back("DATA");
|
|
1325
|
+
}
|
|
1326
|
+
FRACTIONAL_RIGHT(cp2) {
|
|
1327
|
+
const { minus, absInt } = this.data;
|
|
1328
|
+
const { out, nextCp } = this.parseDigits(cp2, isDigit);
|
|
1329
|
+
const absNum = [
|
|
1330
|
+
...absInt,
|
|
1331
|
+
CodePoint.DOT,
|
|
1332
|
+
...out
|
|
1333
|
+
];
|
|
1334
|
+
if (nextCp === CodePoint.LATIN_SMALL_E || nextCp === CodePoint.LATIN_CAPITAL_E) {
|
|
1335
|
+
this.data = {
|
|
1336
|
+
minus,
|
|
1337
|
+
left: absNum
|
|
1338
|
+
};
|
|
1339
|
+
return "EXPONENT_RIGHT";
|
|
1340
|
+
}
|
|
1341
|
+
const value = Number(minus ? String.fromCodePoint(CodePoint.DASH, ...absNum) : String.fromCodePoint(...absNum));
|
|
1342
|
+
this.endToken("Float", "start", value);
|
|
1343
|
+
return this.back("DATA");
|
|
1344
|
+
}
|
|
1345
|
+
EXPONENT_RIGHT(cp2) {
|
|
1346
|
+
const { left, minus: leftMinus } = this.data;
|
|
1347
|
+
let minus = false;
|
|
1348
|
+
if (cp2 === CodePoint.DASH || cp2 === CodePoint.PLUS_SIGN) {
|
|
1349
|
+
minus = cp2 === CodePoint.DASH;
|
|
1350
|
+
cp2 = this.nextCode();
|
|
1351
|
+
}
|
|
1352
|
+
const { out } = this.parseDigits(cp2, isDigit);
|
|
1353
|
+
const right = out;
|
|
1354
|
+
if (minus) right.unshift(CodePoint.DASH);
|
|
1355
|
+
const value = Number(leftMinus ? String.fromCodePoint(CodePoint.DASH, ...left, CodePoint.LATIN_SMALL_E, ...right) : String.fromCodePoint(...left, CodePoint.LATIN_SMALL_E, ...right));
|
|
1356
|
+
this.endToken("Float", "start", value);
|
|
1357
|
+
return this.back("DATA");
|
|
1358
|
+
}
|
|
1359
|
+
BOOLEAN(cp2) {
|
|
1360
|
+
if (cp2 === CodePoint.LATIN_SMALL_T) {
|
|
1361
|
+
const startPos = this.codePointIterator.start;
|
|
1362
|
+
if (this.eatCode(CodePoint.LATIN_SMALL_R) && this.eatCode(CodePoint.LATIN_SMALL_U) && this.eatCode(CodePoint.LATIN_SMALL_E)) {
|
|
1363
|
+
this.endToken("Boolean", "end", true);
|
|
1364
|
+
return "DATA";
|
|
1365
|
+
}
|
|
1366
|
+
this.moveAt(startPos);
|
|
1367
|
+
} else if (cp2 === CodePoint.LATIN_SMALL_F) {
|
|
1368
|
+
const startPos = this.codePointIterator.start;
|
|
1369
|
+
if (this.eatCode(CodePoint.LATIN_SMALL_A) && this.eatCode(CodePoint.LATIN_SMALL_L) && this.eatCode(CodePoint.LATIN_SMALL_S) && this.eatCode(CodePoint.LATIN_SMALL_E)) {
|
|
1370
|
+
this.endToken("Boolean", "end", false);
|
|
1371
|
+
return "DATA";
|
|
1372
|
+
}
|
|
1373
|
+
this.moveAt(startPos);
|
|
1374
|
+
}
|
|
1375
|
+
return this.reportParseError("unexpected-char");
|
|
1376
|
+
}
|
|
1377
|
+
DATE_MONTH(cp2) {
|
|
1378
|
+
const start = this.codePointIterator.start;
|
|
1379
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1380
|
+
cp2 = this.nextCode();
|
|
1381
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1382
|
+
cp2 = this.nextCode();
|
|
1383
|
+
if (cp2 !== CodePoint.DASH) return this.reportParseError("unexpected-char");
|
|
1384
|
+
const end = this.codePointIterator.start;
|
|
1385
|
+
const data = this.data;
|
|
1386
|
+
data.month = Number(this.text.slice(start, end));
|
|
1387
|
+
return "DATE_DAY";
|
|
1388
|
+
}
|
|
1389
|
+
DATE_DAY(cp2) {
|
|
1390
|
+
const start = this.codePointIterator.start;
|
|
1391
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1392
|
+
cp2 = this.nextCode();
|
|
1393
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1394
|
+
const end = this.codePointIterator.end;
|
|
1395
|
+
const data = this.data;
|
|
1396
|
+
data.day = Number(this.text.slice(start, end));
|
|
1397
|
+
if (!isValidDate(data.year, data.month, data.day)) return this.reportParseError("invalid-date");
|
|
1398
|
+
cp2 = this.nextCode();
|
|
1399
|
+
if (cp2 === CodePoint.LATIN_CAPITAL_T || cp2 === CodePoint.LATIN_SMALL_T) return "TIME_HOUR";
|
|
1400
|
+
if (cp2 === CodePoint.SPACE) {
|
|
1401
|
+
const startPos = this.codePointIterator.start;
|
|
1402
|
+
if (isDigit(this.nextCode()) && isDigit(this.nextCode())) {
|
|
1403
|
+
this.moveAt(startPos);
|
|
1404
|
+
return "TIME_HOUR";
|
|
1405
|
+
}
|
|
1406
|
+
this.moveAt(startPos);
|
|
1407
|
+
}
|
|
1408
|
+
const dateValue = getDateFromDateTimeData(data, "");
|
|
1409
|
+
this.endToken("LocalDate", "start", dateValue);
|
|
1410
|
+
return this.back("DATA");
|
|
1411
|
+
}
|
|
1412
|
+
TIME_HOUR(cp2) {
|
|
1413
|
+
const start = this.codePointIterator.start;
|
|
1414
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1415
|
+
cp2 = this.nextCode();
|
|
1416
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1417
|
+
cp2 = this.nextCode();
|
|
1418
|
+
if (cp2 !== CodePoint.COLON) return this.reportParseError("unexpected-char");
|
|
1419
|
+
const end = this.codePointIterator.start;
|
|
1420
|
+
const data = this.data;
|
|
1421
|
+
data.hour = Number(this.text.slice(start, end));
|
|
1422
|
+
return "TIME_MINUTE";
|
|
1423
|
+
}
|
|
1424
|
+
TIME_MINUTE(cp2) {
|
|
1425
|
+
const start = this.codePointIterator.start;
|
|
1426
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1427
|
+
cp2 = this.nextCode();
|
|
1428
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1429
|
+
const end = this.codePointIterator.end;
|
|
1430
|
+
const data = this.data;
|
|
1431
|
+
data.minute = Number(this.text.slice(start, end));
|
|
1432
|
+
cp2 = this.nextCode();
|
|
1433
|
+
if (cp2 === CodePoint.COLON) return "TIME_SECOND";
|
|
1434
|
+
if (this.tomlVersion.lt(1, 1)) return this.reportParseError("unexpected-char");
|
|
1435
|
+
if (!isValidTime(data.hour, data.minute, data.second)) return this.reportParseError("invalid-time");
|
|
1436
|
+
return this.processTimeEnd(cp2, data);
|
|
1437
|
+
}
|
|
1438
|
+
TIME_SECOND(cp2) {
|
|
1439
|
+
const start = this.codePointIterator.start;
|
|
1440
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1441
|
+
cp2 = this.nextCode();
|
|
1442
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1443
|
+
const end = this.codePointIterator.end;
|
|
1444
|
+
const data = this.data;
|
|
1445
|
+
data.second = Number(this.text.slice(start, end));
|
|
1446
|
+
if (!isValidTime(data.hour, data.minute, data.second)) return this.reportParseError("invalid-time");
|
|
1447
|
+
cp2 = this.nextCode();
|
|
1448
|
+
if (cp2 === CodePoint.DOT) return "TIME_SEC_FRAC";
|
|
1449
|
+
return this.processTimeEnd(cp2, data);
|
|
1450
|
+
}
|
|
1451
|
+
TIME_SEC_FRAC(cp2) {
|
|
1452
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1453
|
+
const start = this.codePointIterator.start;
|
|
1454
|
+
while (isDigit(cp2)) cp2 = this.nextCode();
|
|
1455
|
+
const end = this.codePointIterator.start;
|
|
1456
|
+
const data = this.data;
|
|
1457
|
+
data.frac = this.text.slice(start, end);
|
|
1458
|
+
return this.processTimeEnd(cp2, data);
|
|
1459
|
+
}
|
|
1460
|
+
processTimeEnd(cp2, data) {
|
|
1461
|
+
if (data.hasDate) {
|
|
1462
|
+
if (cp2 === CodePoint.DASH || cp2 === CodePoint.PLUS_SIGN) {
|
|
1463
|
+
data.offsetSign = cp2;
|
|
1464
|
+
return "TIME_OFFSET";
|
|
1465
|
+
}
|
|
1466
|
+
if (cp2 === CodePoint.LATIN_CAPITAL_Z || cp2 === CodePoint.LATIN_SMALL_Z) {
|
|
1467
|
+
const dateValue$2 = getDateFromDateTimeData(data, "Z");
|
|
1468
|
+
this.endToken("OffsetDateTime", "end", dateValue$2);
|
|
1469
|
+
return "DATA";
|
|
1470
|
+
}
|
|
1471
|
+
const dateValue$1 = getDateFromDateTimeData(data, "");
|
|
1472
|
+
this.endToken("LocalDateTime", "start", dateValue$1);
|
|
1473
|
+
return this.back("DATA");
|
|
1474
|
+
}
|
|
1475
|
+
const dateValue = getDateFromDateTimeData(data, "");
|
|
1476
|
+
this.endToken("LocalTime", "start", dateValue);
|
|
1477
|
+
return this.back("DATA");
|
|
1478
|
+
}
|
|
1479
|
+
TIME_OFFSET(cp2) {
|
|
1480
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1481
|
+
const hourStart = this.codePointIterator.start;
|
|
1482
|
+
cp2 = this.nextCode();
|
|
1483
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1484
|
+
cp2 = this.nextCode();
|
|
1485
|
+
if (cp2 !== CodePoint.COLON) return this.reportParseError("unexpected-char");
|
|
1486
|
+
const hourEnd = this.codePointIterator.start;
|
|
1487
|
+
cp2 = this.nextCode();
|
|
1488
|
+
const minuteStart = this.codePointIterator.start;
|
|
1489
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1490
|
+
cp2 = this.nextCode();
|
|
1491
|
+
if (!isDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1492
|
+
const minuteEnd = this.codePointIterator.end;
|
|
1493
|
+
const hour = Number(this.text.slice(hourStart, hourEnd));
|
|
1494
|
+
const minute = Number(this.text.slice(minuteStart, minuteEnd));
|
|
1495
|
+
if (!isValidTime(hour, minute, 0)) return this.reportParseError("invalid-time");
|
|
1496
|
+
const data = this.data;
|
|
1497
|
+
const dateValue = getDateFromDateTimeData(data, `${String.fromCodePoint(data.offsetSign)}${padStart(hour, 2)}:${padStart(minute, 2)}`);
|
|
1498
|
+
this.endToken("OffsetDateTime", "end", dateValue);
|
|
1499
|
+
return "DATA";
|
|
1500
|
+
}
|
|
1501
|
+
parseDigits(cp2, checkDigit) {
|
|
1502
|
+
if (cp2 === CodePoint.UNDERSCORE) return this.reportParseError("invalid-underscore");
|
|
1503
|
+
if (!checkDigit(cp2)) return this.reportParseError("unexpected-char");
|
|
1504
|
+
const out = [];
|
|
1505
|
+
let before = CodePoint.NULL;
|
|
1506
|
+
let hasUnderscore = false;
|
|
1507
|
+
while (checkDigit(cp2) || cp2 === CodePoint.UNDERSCORE) {
|
|
1508
|
+
if (cp2 === CodePoint.UNDERSCORE) {
|
|
1509
|
+
hasUnderscore = true;
|
|
1510
|
+
if (before === CodePoint.UNDERSCORE) return this.reportParseError("invalid-underscore");
|
|
1511
|
+
} else out.push(cp2);
|
|
1512
|
+
before = cp2;
|
|
1513
|
+
cp2 = this.nextCode();
|
|
1514
|
+
}
|
|
1515
|
+
if (before === CodePoint.UNDERSCORE) return this.reportParseError("invalid-underscore");
|
|
1516
|
+
return {
|
|
1517
|
+
out,
|
|
1518
|
+
nextCp: cp2,
|
|
1519
|
+
hasUnderscore
|
|
1520
|
+
};
|
|
1521
|
+
}
|
|
1522
|
+
parseUnicode(count) {
|
|
1523
|
+
const startLoc = this.codePointIterator.start;
|
|
1524
|
+
const start = this.codePointIterator.end;
|
|
1525
|
+
let charCount = 0;
|
|
1526
|
+
let cp2;
|
|
1527
|
+
while ((cp2 = this.nextCode()) !== CodePoint.EOF) {
|
|
1528
|
+
if (!isHexDig(cp2)) {
|
|
1529
|
+
this.moveAt(startLoc);
|
|
1530
|
+
return this.reportParseError("invalid-char-in-escape-sequence");
|
|
1531
|
+
}
|
|
1532
|
+
charCount++;
|
|
1533
|
+
if (charCount >= count) break;
|
|
1534
|
+
}
|
|
1535
|
+
const end = this.codePointIterator.end;
|
|
1536
|
+
const code = this.text.slice(start, end);
|
|
1537
|
+
const codePoint = parseInt(code, 16);
|
|
1538
|
+
if (!isUnicodeScalarValue(codePoint)) return this.reportParseError("invalid-code-point", { cp: code });
|
|
1539
|
+
return codePoint;
|
|
1540
|
+
}
|
|
1541
|
+
reportParseErrorControlChar() {
|
|
1542
|
+
return this.reportParseError("invalid-control-character");
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
function isUnquotedKeyChar(cp2, tomlVersion) {
|
|
1546
|
+
if (isLetter(cp2) || isDigit(cp2) || cp2 === CodePoint.UNDERSCORE || cp2 === CodePoint.DASH) return true;
|
|
1547
|
+
if (tomlVersion.lt(1, 1)) return false;
|
|
1548
|
+
return false;
|
|
1549
|
+
}
|
|
1550
|
+
function isControlOtherThanTab(cp2) {
|
|
1551
|
+
return isControl(cp2) && cp2 !== CodePoint.TABULATION || cp2 === CodePoint.DELETE;
|
|
1552
|
+
}
|
|
1553
|
+
function isNonEOL(cp2) {
|
|
1554
|
+
return cp2 === CodePoint.TABULATION || CodePoint.SPACE <= cp2 && cp2 <= CodePoint.TILDE || isNonAscii(cp2);
|
|
1555
|
+
}
|
|
1556
|
+
function isNonAscii(cp2) {
|
|
1557
|
+
return CodePoint.PAD <= cp2 && cp2 <= CodePoint.CP_D7FF || CodePoint.CP_E000 <= cp2 && cp2 <= CodePoint.CP_10FFFF;
|
|
1558
|
+
}
|
|
1559
|
+
function isValidDate(y, m, d) {
|
|
1560
|
+
if (y >= 0 && m <= 12 && m >= 1 && d >= 1) return d <= (m === 2 ? y & 3 || !(y % 25) && y & 15 ? 28 : 29 : 30 + (m + (m >> 3) & 1));
|
|
1561
|
+
return false;
|
|
1562
|
+
}
|
|
1563
|
+
function isValidTime(h, m, s) {
|
|
1564
|
+
if (h >= 24 || h < 0 || m > 59 || m < 0 || s > 60 || s < 0) return false;
|
|
1565
|
+
return true;
|
|
1566
|
+
}
|
|
1567
|
+
function getDateFromDateTimeData(data, timeZone) {
|
|
1568
|
+
const year = padStart(data.year, 4);
|
|
1569
|
+
const month = data.month ? padStart(data.month, 2) : "01";
|
|
1570
|
+
const day = data.day ? padStart(data.day, 2) : "01";
|
|
1571
|
+
const hour = padStart(data.hour, 2);
|
|
1572
|
+
const minute = padStart(data.minute, 2);
|
|
1573
|
+
const second = padStart(data.second, 2);
|
|
1574
|
+
const textDate = `${year}-${month}-${day}`;
|
|
1575
|
+
const frac = data.frac ? `.${data.frac}` : "";
|
|
1576
|
+
const dateValue = /* @__PURE__ */ new Date(`${textDate}T${hour}:${minute}:${second}${frac}${timeZone}`);
|
|
1577
|
+
if (!isNaN(dateValue.getTime()) || data.second !== 60) return dateValue;
|
|
1578
|
+
return /* @__PURE__ */ new Date(`${textDate}T${hour}:${minute}:59${frac}${timeZone}`);
|
|
1579
|
+
}
|
|
1580
|
+
function padStart(num, maxLength) {
|
|
1581
|
+
return String(num).padStart(maxLength, "0");
|
|
1582
|
+
}
|
|
1583
|
+
var VALUE_KIND_VALUE = /* @__PURE__ */ Symbol("VALUE_KIND_VALUE");
|
|
1584
|
+
var VALUE_KIND_INTERMEDIATE = /* @__PURE__ */ Symbol("VALUE_KIND_INTERMEDIATE");
|
|
1585
|
+
var KeysResolver = class {
|
|
1586
|
+
constructor(ctx) {
|
|
1587
|
+
this.rootKeys = /* @__PURE__ */ new Map();
|
|
1588
|
+
this.tables = [];
|
|
1589
|
+
this.ctx = ctx;
|
|
1590
|
+
}
|
|
1591
|
+
applyResolveKeyForTable(node) {
|
|
1592
|
+
let keys = this.rootKeys;
|
|
1593
|
+
const peekKeyIndex = node.key.keys.length - 1;
|
|
1594
|
+
for (let index = 0; index < peekKeyIndex; index++) {
|
|
1595
|
+
const keyNode = node.key.keys[index];
|
|
1596
|
+
const keyName = toKeyName(keyNode);
|
|
1597
|
+
node.resolvedKey.push(keyName);
|
|
1598
|
+
let keyStore = keys.get(keyName);
|
|
1599
|
+
if (!keyStore) {
|
|
1600
|
+
keyStore = {
|
|
1601
|
+
node: keyNode,
|
|
1602
|
+
keys: /* @__PURE__ */ new Map()
|
|
1603
|
+
};
|
|
1604
|
+
keys.set(keyName, keyStore);
|
|
1605
|
+
} else if (keyStore.table === "array") {
|
|
1606
|
+
const peekIndex = keyStore.peekIndex;
|
|
1607
|
+
node.resolvedKey.push(peekIndex);
|
|
1608
|
+
keyStore = keyStore.keys.get(peekIndex);
|
|
1609
|
+
}
|
|
1610
|
+
keys = keyStore.keys;
|
|
1611
|
+
}
|
|
1612
|
+
const lastKeyNode = node.key.keys[peekKeyIndex];
|
|
1613
|
+
const lastKeyName = toKeyName(lastKeyNode);
|
|
1614
|
+
node.resolvedKey.push(lastKeyName);
|
|
1615
|
+
const lastKeyStore = keys.get(lastKeyName);
|
|
1616
|
+
if (!lastKeyStore) if (node.kind === "array") {
|
|
1617
|
+
node.resolvedKey.push(0);
|
|
1618
|
+
const newKeyStore = {
|
|
1619
|
+
node: lastKeyNode,
|
|
1620
|
+
keys: /* @__PURE__ */ new Map()
|
|
1621
|
+
};
|
|
1622
|
+
keys.set(lastKeyName, {
|
|
1623
|
+
table: node.kind,
|
|
1624
|
+
node: lastKeyNode,
|
|
1625
|
+
keys: /* @__PURE__ */ new Map([[0, newKeyStore]]),
|
|
1626
|
+
peekIndex: 0
|
|
1627
|
+
});
|
|
1628
|
+
this.tables.push({
|
|
1629
|
+
node,
|
|
1630
|
+
keys: newKeyStore.keys
|
|
1631
|
+
});
|
|
1632
|
+
} else {
|
|
1633
|
+
const newKeyStore = {
|
|
1634
|
+
table: node.kind,
|
|
1635
|
+
node: lastKeyNode,
|
|
1636
|
+
keys: /* @__PURE__ */ new Map()
|
|
1637
|
+
};
|
|
1638
|
+
keys.set(lastKeyName, newKeyStore);
|
|
1639
|
+
this.tables.push({
|
|
1640
|
+
node,
|
|
1641
|
+
keys: newKeyStore.keys
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
else if (!lastKeyStore.table) if (node.kind === "array") this.ctx.reportParseError("dupe-keys", lastKeyNode);
|
|
1645
|
+
else {
|
|
1646
|
+
const transformKey = {
|
|
1647
|
+
table: node.kind,
|
|
1648
|
+
node: lastKeyNode,
|
|
1649
|
+
keys: lastKeyStore.keys
|
|
1650
|
+
};
|
|
1651
|
+
keys.set(lastKeyName, transformKey);
|
|
1652
|
+
this.tables.push({
|
|
1653
|
+
node,
|
|
1654
|
+
keys: transformKey.keys
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
else if (lastKeyStore.table === "array") if (node.kind === "array") {
|
|
1658
|
+
const newKeyStore = {
|
|
1659
|
+
node: lastKeyNode,
|
|
1660
|
+
keys: /* @__PURE__ */ new Map()
|
|
1661
|
+
};
|
|
1662
|
+
const newIndex = lastKeyStore.peekIndex + 1;
|
|
1663
|
+
node.resolvedKey.push(newIndex);
|
|
1664
|
+
lastKeyStore.keys.set(newIndex, newKeyStore);
|
|
1665
|
+
lastKeyStore.peekIndex = newIndex;
|
|
1666
|
+
this.tables.push({
|
|
1667
|
+
node,
|
|
1668
|
+
keys: newKeyStore.keys
|
|
1669
|
+
});
|
|
1670
|
+
} else this.ctx.reportParseError("dupe-keys", lastKeyNode);
|
|
1671
|
+
else this.ctx.reportParseError("dupe-keys", lastKeyNode);
|
|
1672
|
+
}
|
|
1673
|
+
verifyDuplicateKeys(node) {
|
|
1674
|
+
for (const body of node.body) if (body.type === "TOMLKeyValue") verifyDuplicateKeysForKeyValue(this.ctx, this.rootKeys, body);
|
|
1675
|
+
for (const { node: tableNode, keys } of this.tables) for (const body of tableNode.body) verifyDuplicateKeysForKeyValue(this.ctx, keys, body);
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
function verifyDuplicateKeysForKeyValue(ctx, defineKeys, node) {
|
|
1679
|
+
let keys = defineKeys;
|
|
1680
|
+
const lastKey = last(node.key.keys);
|
|
1681
|
+
for (const keyNode of node.key.keys) {
|
|
1682
|
+
const key = toKeyName(keyNode);
|
|
1683
|
+
let defineKey = keys.get(key);
|
|
1684
|
+
if (defineKey) {
|
|
1685
|
+
if (defineKey.value === VALUE_KIND_VALUE) ctx.reportParseError("dupe-keys", getAfterNode(keyNode, defineKey.node));
|
|
1686
|
+
else if (lastKey === keyNode) ctx.reportParseError("dupe-keys", getAfterNode(keyNode, defineKey.node));
|
|
1687
|
+
else if (defineKey.table) ctx.reportParseError("dupe-keys", getAfterNode(keyNode, defineKey.node));
|
|
1688
|
+
defineKey.value = VALUE_KIND_INTERMEDIATE;
|
|
1689
|
+
} else {
|
|
1690
|
+
if (lastKey === keyNode) defineKey = {
|
|
1691
|
+
value: VALUE_KIND_VALUE,
|
|
1692
|
+
node: keyNode,
|
|
1693
|
+
keys: /* @__PURE__ */ new Map()
|
|
1694
|
+
};
|
|
1695
|
+
else defineKey = {
|
|
1696
|
+
value: VALUE_KIND_INTERMEDIATE,
|
|
1697
|
+
node: keyNode,
|
|
1698
|
+
keys: /* @__PURE__ */ new Map()
|
|
1699
|
+
};
|
|
1700
|
+
keys.set(key, defineKey);
|
|
1701
|
+
}
|
|
1702
|
+
keys = defineKey.keys;
|
|
1703
|
+
}
|
|
1704
|
+
if (node.value.type === "TOMLInlineTable") verifyDuplicateKeysForInlineTable(ctx, keys, node.value);
|
|
1705
|
+
else if (node.value.type === "TOMLArray") verifyDuplicateKeysForArray(ctx, keys, node.value);
|
|
1706
|
+
}
|
|
1707
|
+
function verifyDuplicateKeysForInlineTable(ctx, defineKeys, node) {
|
|
1708
|
+
for (const body of node.body) verifyDuplicateKeysForKeyValue(ctx, defineKeys, body);
|
|
1709
|
+
}
|
|
1710
|
+
function verifyDuplicateKeysForArray(ctx, defineKeys, node) {
|
|
1711
|
+
const keys = defineKeys;
|
|
1712
|
+
for (let index = 0; index < node.elements.length; index++) {
|
|
1713
|
+
const element = node.elements[index];
|
|
1714
|
+
let defineKey = keys.get(index);
|
|
1715
|
+
if (defineKey) ctx.reportParseError("dupe-keys", getAfterNode(element, defineKey.node));
|
|
1716
|
+
else {
|
|
1717
|
+
defineKey = {
|
|
1718
|
+
value: VALUE_KIND_VALUE,
|
|
1719
|
+
node: element,
|
|
1720
|
+
keys: /* @__PURE__ */ new Map()
|
|
1721
|
+
};
|
|
1722
|
+
defineKeys.set(index, defineKey);
|
|
1723
|
+
if (element.type === "TOMLInlineTable") verifyDuplicateKeysForInlineTable(ctx, defineKey.keys, element);
|
|
1724
|
+
else if (element.type === "TOMLArray") verifyDuplicateKeysForArray(ctx, defineKey.keys, element);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
function getAfterNode(a, b) {
|
|
1729
|
+
return a.range[0] <= b.range[0] ? b : a;
|
|
1730
|
+
}
|
|
1731
|
+
var Context = class {
|
|
1732
|
+
constructor(data) {
|
|
1733
|
+
this.tokens = [];
|
|
1734
|
+
this.comments = [];
|
|
1735
|
+
this.back = null;
|
|
1736
|
+
this.stateStack = [];
|
|
1737
|
+
this.needNewLine = false;
|
|
1738
|
+
this.needSameLine = false;
|
|
1739
|
+
this.currToken = null;
|
|
1740
|
+
this.prevToken = null;
|
|
1741
|
+
this.valueContainerStack = [];
|
|
1742
|
+
this.tokenizer = new Tokenizer(data.text, data.parserOptions);
|
|
1743
|
+
this.topLevelTable = data.topLevelTable;
|
|
1744
|
+
this.table = data.topLevelTable;
|
|
1745
|
+
this.keysResolver = new KeysResolver(this);
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Get the next token.
|
|
1749
|
+
*/
|
|
1750
|
+
nextToken(option) {
|
|
1751
|
+
this.prevToken = this.currToken;
|
|
1752
|
+
if (this.back) {
|
|
1753
|
+
this.currToken = this.back;
|
|
1754
|
+
this.back = null;
|
|
1755
|
+
} else this.currToken = this._nextTokenFromTokenizer(option);
|
|
1756
|
+
if ((this.needNewLine || this.needSameLine || option?.needSameLine) && this.prevToken && this.currToken) if (this.prevToken.loc.end.line === this.currToken.loc.start.line) {
|
|
1757
|
+
if (this.needNewLine) return this.reportParseError("missing-newline", this.currToken);
|
|
1758
|
+
} else {
|
|
1759
|
+
const needSameLine = this.needSameLine || option?.needSameLine;
|
|
1760
|
+
if (needSameLine) return this.reportParseError(needSameLine, this.currToken);
|
|
1761
|
+
}
|
|
1762
|
+
this.needNewLine = false;
|
|
1763
|
+
this.needSameLine = false;
|
|
1764
|
+
return this.currToken;
|
|
1765
|
+
}
|
|
1766
|
+
_nextTokenFromTokenizer(option) {
|
|
1767
|
+
const valuesEnabled = this.tokenizer.valuesEnabled;
|
|
1768
|
+
if (option?.valuesEnabled) this.tokenizer.valuesEnabled = option.valuesEnabled;
|
|
1769
|
+
let token = this.tokenizer.nextToken();
|
|
1770
|
+
while (token && token.type === "Block") {
|
|
1771
|
+
this.comments.push(token);
|
|
1772
|
+
token = this.tokenizer.nextToken();
|
|
1773
|
+
}
|
|
1774
|
+
if (token) this.tokens.push(token);
|
|
1775
|
+
this.tokenizer.valuesEnabled = valuesEnabled;
|
|
1776
|
+
return token;
|
|
1777
|
+
}
|
|
1778
|
+
backToken() {
|
|
1779
|
+
if (this.back) throw new Error("Illegal state");
|
|
1780
|
+
this.back = this.currToken;
|
|
1781
|
+
this.currToken = this.prevToken;
|
|
1782
|
+
}
|
|
1783
|
+
addValueContainer(valueContainer) {
|
|
1784
|
+
this.valueContainerStack.push(valueContainer);
|
|
1785
|
+
this.tokenizer.valuesEnabled = true;
|
|
1786
|
+
}
|
|
1787
|
+
consumeValueContainer() {
|
|
1788
|
+
const valueContainer = this.valueContainerStack.pop();
|
|
1789
|
+
this.tokenizer.valuesEnabled = this.valueContainerStack.length > 0;
|
|
1790
|
+
return valueContainer;
|
|
1791
|
+
}
|
|
1792
|
+
applyResolveKeyForTable(node) {
|
|
1793
|
+
this.keysResolver.applyResolveKeyForTable(node);
|
|
1794
|
+
}
|
|
1795
|
+
verifyDuplicateKeys() {
|
|
1796
|
+
this.keysResolver.verifyDuplicateKeys(this.topLevelTable);
|
|
1797
|
+
}
|
|
1798
|
+
/**
|
|
1799
|
+
* Report an invalid token error.
|
|
1800
|
+
*/
|
|
1801
|
+
reportParseError(code, token) {
|
|
1802
|
+
let offset, line, column;
|
|
1803
|
+
if (token) {
|
|
1804
|
+
offset = token.range[0];
|
|
1805
|
+
line = token.loc.start.line;
|
|
1806
|
+
column = token.loc.start.column;
|
|
1807
|
+
} else {
|
|
1808
|
+
offset = this.tokenizer.start;
|
|
1809
|
+
const startPos = this.tokenizer.getLocFromIndex(offset);
|
|
1810
|
+
line = startPos.line;
|
|
1811
|
+
column = startPos.column;
|
|
1812
|
+
}
|
|
1813
|
+
throw new ParseError(code, offset, line, column);
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
var STATE_FOR_ERROR = { VALUE: "missing-value" };
|
|
1817
|
+
var STRING_VALUE_STYLE_MAP = {
|
|
1818
|
+
BasicString: "basic",
|
|
1819
|
+
MultiLineBasicString: "basic",
|
|
1820
|
+
LiteralString: "literal",
|
|
1821
|
+
MultiLineLiteralString: "literal"
|
|
1822
|
+
};
|
|
1823
|
+
var STRING_KEY_STYLE_MAP = {
|
|
1824
|
+
BasicString: "basic",
|
|
1825
|
+
LiteralString: "literal"
|
|
1826
|
+
};
|
|
1827
|
+
var DATETIME_VALUE_KIND_MAP = {
|
|
1828
|
+
OffsetDateTime: "offset-date-time",
|
|
1829
|
+
LocalDateTime: "local-date-time",
|
|
1830
|
+
LocalDate: "local-date",
|
|
1831
|
+
LocalTime: "local-time"
|
|
1832
|
+
};
|
|
1833
|
+
var TOMLParser = class {
|
|
1834
|
+
/**
|
|
1835
|
+
* Initialize this parser.
|
|
1836
|
+
*/
|
|
1837
|
+
constructor(text, parserOptions) {
|
|
1838
|
+
this.text = text;
|
|
1839
|
+
this.parserOptions = parserOptions || {};
|
|
1840
|
+
this.tomlVersion = getTOMLVer(this.parserOptions.tomlVersion);
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Parse TOML
|
|
1844
|
+
*/
|
|
1845
|
+
parse() {
|
|
1846
|
+
const ast = {
|
|
1847
|
+
type: "Program",
|
|
1848
|
+
body: [],
|
|
1849
|
+
sourceType: "module",
|
|
1850
|
+
tokens: [],
|
|
1851
|
+
comments: [],
|
|
1852
|
+
parent: null,
|
|
1853
|
+
range: [0, 0],
|
|
1854
|
+
loc: {
|
|
1855
|
+
start: {
|
|
1856
|
+
line: 1,
|
|
1857
|
+
column: 0
|
|
1858
|
+
},
|
|
1859
|
+
end: {
|
|
1860
|
+
line: 1,
|
|
1861
|
+
column: 0
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
const node = {
|
|
1866
|
+
type: "TOMLTopLevelTable",
|
|
1867
|
+
body: [],
|
|
1868
|
+
parent: ast,
|
|
1869
|
+
range: cloneRange(ast.range),
|
|
1870
|
+
loc: cloneLoc(ast.loc)
|
|
1871
|
+
};
|
|
1872
|
+
ast.body = [node];
|
|
1873
|
+
const ctx = new Context({
|
|
1874
|
+
text: this.text,
|
|
1875
|
+
parserOptions: this.parserOptions,
|
|
1876
|
+
topLevelTable: node
|
|
1877
|
+
});
|
|
1878
|
+
let token = ctx.nextToken();
|
|
1879
|
+
if (token) {
|
|
1880
|
+
node.range[0] = token.range[0];
|
|
1881
|
+
node.loc.start = clonePos(token.loc.start);
|
|
1882
|
+
while (token) {
|
|
1883
|
+
const state$1 = ctx.stateStack.pop() || "TABLE";
|
|
1884
|
+
ctx.stateStack.push(...this[state$1](token, ctx));
|
|
1885
|
+
token = ctx.nextToken();
|
|
1886
|
+
}
|
|
1887
|
+
const state = ctx.stateStack.pop() || "TABLE";
|
|
1888
|
+
if (state in STATE_FOR_ERROR) return ctx.reportParseError(STATE_FOR_ERROR[state], null);
|
|
1889
|
+
if (ctx.table.type === "TOMLTable") applyEndLoc(ctx.table, last(ctx.table.body));
|
|
1890
|
+
applyEndLoc(node, last(node.body));
|
|
1891
|
+
}
|
|
1892
|
+
ctx.verifyDuplicateKeys();
|
|
1893
|
+
ast.tokens = ctx.tokens;
|
|
1894
|
+
ast.comments = ctx.comments;
|
|
1895
|
+
const endOffset = ctx.tokenizer.end;
|
|
1896
|
+
const endPos = ctx.tokenizer.getLocFromIndex(endOffset);
|
|
1897
|
+
ast.range[1] = endOffset;
|
|
1898
|
+
ast.loc.end = {
|
|
1899
|
+
line: endPos.line,
|
|
1900
|
+
column: endPos.column
|
|
1901
|
+
};
|
|
1902
|
+
return ast;
|
|
1903
|
+
}
|
|
1904
|
+
TABLE(token, ctx) {
|
|
1905
|
+
if (isBare(token) || isString(token)) return this.processKeyValue(token, ctx.table, ctx);
|
|
1906
|
+
if (isLeftBracket(token)) return this.processTable(token, ctx.topLevelTable, ctx);
|
|
1907
|
+
return ctx.reportParseError("unexpected-token", token);
|
|
1908
|
+
}
|
|
1909
|
+
VALUE(token, ctx) {
|
|
1910
|
+
if (isString(token) || isMultiLineString(token)) return this.processStringValue(token, ctx);
|
|
1911
|
+
if (isNumber(token)) return this.processNumberValue(token, ctx);
|
|
1912
|
+
if (isBoolean(token)) return this.processBooleanValue(token, ctx);
|
|
1913
|
+
if (isDateTime(token)) return this.processDateTimeValue(token, ctx);
|
|
1914
|
+
if (isLeftBracket(token)) return this.processArray(token, ctx);
|
|
1915
|
+
if (isLeftBrace(token)) return this.processInlineTable(token, ctx);
|
|
1916
|
+
return ctx.reportParseError("unexpected-token", token);
|
|
1917
|
+
}
|
|
1918
|
+
processTable(token, topLevelTableNode, ctx) {
|
|
1919
|
+
const tableNode = {
|
|
1920
|
+
type: "TOMLTable",
|
|
1921
|
+
kind: "standard",
|
|
1922
|
+
key: null,
|
|
1923
|
+
resolvedKey: [],
|
|
1924
|
+
body: [],
|
|
1925
|
+
parent: topLevelTableNode,
|
|
1926
|
+
range: cloneRange(token.range),
|
|
1927
|
+
loc: cloneLoc(token.loc)
|
|
1928
|
+
};
|
|
1929
|
+
if (ctx.table.type === "TOMLTable") applyEndLoc(ctx.table, last(ctx.table.body));
|
|
1930
|
+
topLevelTableNode.body.push(tableNode);
|
|
1931
|
+
ctx.table = tableNode;
|
|
1932
|
+
let targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
|
|
1933
|
+
if (isLeftBracket(targetToken)) {
|
|
1934
|
+
if (token.range[1] < targetToken.range[0]) return ctx.reportParseError("invalid-space", targetToken);
|
|
1935
|
+
tableNode.kind = "array";
|
|
1936
|
+
targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
|
|
1937
|
+
}
|
|
1938
|
+
if (isRightBracket(targetToken)) return ctx.reportParseError("missing-key", targetToken);
|
|
1939
|
+
if (!targetToken) return ctx.reportParseError("unterminated-table-key", null);
|
|
1940
|
+
targetToken = this.processKeyNode(targetToken, tableNode, ctx).nextToken;
|
|
1941
|
+
if (!isRightBracket(targetToken)) return ctx.reportParseError("unterminated-table-key", targetToken);
|
|
1942
|
+
if (tableNode.kind === "array") {
|
|
1943
|
+
const rightBracket = targetToken;
|
|
1944
|
+
targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
|
|
1945
|
+
if (!isRightBracket(targetToken)) return ctx.reportParseError("unterminated-table-key", targetToken);
|
|
1946
|
+
if (rightBracket.range[1] < targetToken.range[0]) return ctx.reportParseError("invalid-space", targetToken);
|
|
1947
|
+
}
|
|
1948
|
+
applyEndLoc(tableNode, targetToken);
|
|
1949
|
+
ctx.applyResolveKeyForTable(tableNode);
|
|
1950
|
+
ctx.needNewLine = true;
|
|
1951
|
+
return [];
|
|
1952
|
+
}
|
|
1953
|
+
processKeyValue(token, tableNode, ctx) {
|
|
1954
|
+
const keyValueNode = {
|
|
1955
|
+
type: "TOMLKeyValue",
|
|
1956
|
+
key: null,
|
|
1957
|
+
value: null,
|
|
1958
|
+
parent: tableNode,
|
|
1959
|
+
range: cloneRange(token.range),
|
|
1960
|
+
loc: cloneLoc(token.loc)
|
|
1961
|
+
};
|
|
1962
|
+
tableNode.body.push(keyValueNode);
|
|
1963
|
+
const { nextToken: targetToken } = this.processKeyNode(token, keyValueNode, ctx);
|
|
1964
|
+
if (!isEq(targetToken)) return ctx.reportParseError("missing-equals-sign", targetToken);
|
|
1965
|
+
ctx.addValueContainer({
|
|
1966
|
+
parent: keyValueNode,
|
|
1967
|
+
set: (valNode) => {
|
|
1968
|
+
keyValueNode.value = valNode;
|
|
1969
|
+
applyEndLoc(keyValueNode, valNode);
|
|
1970
|
+
ctx.needNewLine = true;
|
|
1971
|
+
return [];
|
|
1972
|
+
}
|
|
1973
|
+
});
|
|
1974
|
+
ctx.needSameLine = "invalid-key-value-newline";
|
|
1975
|
+
return ["VALUE"];
|
|
1976
|
+
}
|
|
1977
|
+
processKeyNode(token, parent, ctx) {
|
|
1978
|
+
if (isDot(token)) ctx.reportParseError("invalid-leading-dot-in-key", token);
|
|
1979
|
+
const keyNode = {
|
|
1980
|
+
type: "TOMLKey",
|
|
1981
|
+
keys: [],
|
|
1982
|
+
parent,
|
|
1983
|
+
range: cloneRange(token.range),
|
|
1984
|
+
loc: cloneLoc(token.loc)
|
|
1985
|
+
};
|
|
1986
|
+
parent.key = keyNode;
|
|
1987
|
+
let targetToken = token;
|
|
1988
|
+
let dotToken = null;
|
|
1989
|
+
do {
|
|
1990
|
+
if (isBare(targetToken)) this.processBareKey(targetToken, keyNode);
|
|
1991
|
+
else if (isString(targetToken)) this.processStringKey(targetToken, keyNode);
|
|
1992
|
+
else break;
|
|
1993
|
+
dotToken = null;
|
|
1994
|
+
targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
|
|
1995
|
+
if (!isDot(targetToken)) break;
|
|
1996
|
+
dotToken = targetToken;
|
|
1997
|
+
targetToken = ctx.nextToken({ needSameLine: "invalid-key-value-newline" });
|
|
1998
|
+
} while (targetToken);
|
|
1999
|
+
if (dotToken) ctx.reportParseError(isDot(targetToken) ? "invalid-consecutive-dots-in-key" : "invalid-trailing-dot-in-key", dotToken);
|
|
2000
|
+
applyEndLoc(keyNode, last(keyNode.keys));
|
|
2001
|
+
return {
|
|
2002
|
+
keyNode,
|
|
2003
|
+
nextToken: targetToken
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
processBareKey(token, keyNode) {
|
|
2007
|
+
const node = {
|
|
2008
|
+
type: "TOMLBare",
|
|
2009
|
+
name: token.value,
|
|
2010
|
+
parent: keyNode,
|
|
2011
|
+
range: cloneRange(token.range),
|
|
2012
|
+
loc: cloneLoc(token.loc)
|
|
2013
|
+
};
|
|
2014
|
+
keyNode.keys.push(node);
|
|
2015
|
+
}
|
|
2016
|
+
processStringKey(token, keyNode) {
|
|
2017
|
+
const node = {
|
|
2018
|
+
type: "TOMLQuoted",
|
|
2019
|
+
kind: "string",
|
|
2020
|
+
value: token.string,
|
|
2021
|
+
style: STRING_KEY_STYLE_MAP[token.type],
|
|
2022
|
+
multiline: false,
|
|
2023
|
+
parent: keyNode,
|
|
2024
|
+
range: cloneRange(token.range),
|
|
2025
|
+
loc: cloneLoc(token.loc)
|
|
2026
|
+
};
|
|
2027
|
+
keyNode.keys.push(node);
|
|
2028
|
+
}
|
|
2029
|
+
processStringValue(token, ctx) {
|
|
2030
|
+
const valueContainer = ctx.consumeValueContainer();
|
|
2031
|
+
const node = {
|
|
2032
|
+
type: "TOMLValue",
|
|
2033
|
+
kind: "string",
|
|
2034
|
+
value: token.string,
|
|
2035
|
+
style: STRING_VALUE_STYLE_MAP[token.type],
|
|
2036
|
+
multiline: isMultiLineString(token),
|
|
2037
|
+
parent: valueContainer.parent,
|
|
2038
|
+
range: cloneRange(token.range),
|
|
2039
|
+
loc: cloneLoc(token.loc)
|
|
2040
|
+
};
|
|
2041
|
+
return valueContainer.set(node);
|
|
2042
|
+
}
|
|
2043
|
+
processNumberValue(token, ctx) {
|
|
2044
|
+
const valueContainer = ctx.consumeValueContainer();
|
|
2045
|
+
const text = this.text;
|
|
2046
|
+
const [startRange, endRange] = token.range;
|
|
2047
|
+
let numberString = null;
|
|
2048
|
+
const getNumberText = () => {
|
|
2049
|
+
return numberString ?? (numberString = text.slice(startRange, endRange).replace(/_/g, ""));
|
|
2050
|
+
};
|
|
2051
|
+
let node;
|
|
2052
|
+
if (token.type === "Integer") node = {
|
|
2053
|
+
type: "TOMLValue",
|
|
2054
|
+
kind: "integer",
|
|
2055
|
+
value: token.number,
|
|
2056
|
+
bigint: token.bigint,
|
|
2057
|
+
get number() {
|
|
2058
|
+
return getNumberText();
|
|
2059
|
+
},
|
|
2060
|
+
parent: valueContainer.parent,
|
|
2061
|
+
range: cloneRange(token.range),
|
|
2062
|
+
loc: cloneLoc(token.loc)
|
|
2063
|
+
};
|
|
2064
|
+
else node = {
|
|
2065
|
+
type: "TOMLValue",
|
|
2066
|
+
kind: "float",
|
|
2067
|
+
value: token.number,
|
|
2068
|
+
get number() {
|
|
2069
|
+
return getNumberText();
|
|
2070
|
+
},
|
|
2071
|
+
parent: valueContainer.parent,
|
|
2072
|
+
range: cloneRange(token.range),
|
|
2073
|
+
loc: cloneLoc(token.loc)
|
|
2074
|
+
};
|
|
2075
|
+
return valueContainer.set(node);
|
|
2076
|
+
}
|
|
2077
|
+
processBooleanValue(token, ctx) {
|
|
2078
|
+
const valueContainer = ctx.consumeValueContainer();
|
|
2079
|
+
const node = {
|
|
2080
|
+
type: "TOMLValue",
|
|
2081
|
+
kind: "boolean",
|
|
2082
|
+
value: token.boolean,
|
|
2083
|
+
parent: valueContainer.parent,
|
|
2084
|
+
range: cloneRange(token.range),
|
|
2085
|
+
loc: cloneLoc(token.loc)
|
|
2086
|
+
};
|
|
2087
|
+
return valueContainer.set(node);
|
|
2088
|
+
}
|
|
2089
|
+
processDateTimeValue(token, ctx) {
|
|
2090
|
+
const valueContainer = ctx.consumeValueContainer();
|
|
2091
|
+
const node = {
|
|
2092
|
+
type: "TOMLValue",
|
|
2093
|
+
kind: DATETIME_VALUE_KIND_MAP[token.type],
|
|
2094
|
+
value: token.date,
|
|
2095
|
+
datetime: token.value,
|
|
2096
|
+
parent: valueContainer.parent,
|
|
2097
|
+
range: cloneRange(token.range),
|
|
2098
|
+
loc: cloneLoc(token.loc)
|
|
2099
|
+
};
|
|
2100
|
+
return valueContainer.set(node);
|
|
2101
|
+
}
|
|
2102
|
+
processArray(token, ctx) {
|
|
2103
|
+
const valueContainer = ctx.consumeValueContainer();
|
|
2104
|
+
const node = {
|
|
2105
|
+
type: "TOMLArray",
|
|
2106
|
+
elements: [],
|
|
2107
|
+
parent: valueContainer.parent,
|
|
2108
|
+
range: cloneRange(token.range),
|
|
2109
|
+
loc: cloneLoc(token.loc)
|
|
2110
|
+
};
|
|
2111
|
+
const nextToken = ctx.nextToken({ valuesEnabled: true });
|
|
2112
|
+
if (isRightBracket(nextToken)) {
|
|
2113
|
+
applyEndLoc(node, nextToken);
|
|
2114
|
+
return valueContainer.set(node);
|
|
2115
|
+
}
|
|
2116
|
+
ctx.backToken();
|
|
2117
|
+
return this.processArrayValue(node, valueContainer, ctx);
|
|
2118
|
+
}
|
|
2119
|
+
processArrayValue(node, valueContainer, ctx) {
|
|
2120
|
+
ctx.addValueContainer({
|
|
2121
|
+
parent: node,
|
|
2122
|
+
set: (valNode) => {
|
|
2123
|
+
node.elements.push(valNode);
|
|
2124
|
+
let nextToken = ctx.nextToken({ valuesEnabled: true });
|
|
2125
|
+
const hasComma = isComma(nextToken);
|
|
2126
|
+
if (hasComma) nextToken = ctx.nextToken({ valuesEnabled: true });
|
|
2127
|
+
if (isRightBracket(nextToken)) {
|
|
2128
|
+
applyEndLoc(node, nextToken);
|
|
2129
|
+
return valueContainer.set(node);
|
|
2130
|
+
}
|
|
2131
|
+
if (hasComma) {
|
|
2132
|
+
ctx.backToken();
|
|
2133
|
+
return this.processArrayValue(node, valueContainer, ctx);
|
|
2134
|
+
}
|
|
2135
|
+
return ctx.reportParseError(nextToken ? "missing-comma" : "unterminated-array", nextToken);
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
return ["VALUE"];
|
|
2139
|
+
}
|
|
2140
|
+
processInlineTable(token, ctx) {
|
|
2141
|
+
const valueContainer = ctx.consumeValueContainer();
|
|
2142
|
+
const node = {
|
|
2143
|
+
type: "TOMLInlineTable",
|
|
2144
|
+
body: [],
|
|
2145
|
+
parent: valueContainer.parent,
|
|
2146
|
+
range: cloneRange(token.range),
|
|
2147
|
+
loc: cloneLoc(token.loc)
|
|
2148
|
+
};
|
|
2149
|
+
const needSameLine = this.tomlVersion.gte(1, 1) ? void 0 : "invalid-inline-table-newline";
|
|
2150
|
+
const nextToken = ctx.nextToken({ needSameLine });
|
|
2151
|
+
if (nextToken) {
|
|
2152
|
+
if (isBare(nextToken) || isString(nextToken)) return this.processInlineTableKeyValue(nextToken, node, valueContainer, ctx);
|
|
2153
|
+
if (isRightBrace(nextToken)) {
|
|
2154
|
+
applyEndLoc(node, nextToken);
|
|
2155
|
+
return valueContainer.set(node);
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
return ctx.reportParseError("unexpected-token", nextToken);
|
|
2159
|
+
}
|
|
2160
|
+
processInlineTableKeyValue(token, inlineTableNode, valueContainer, ctx) {
|
|
2161
|
+
const keyValueNode = {
|
|
2162
|
+
type: "TOMLKeyValue",
|
|
2163
|
+
key: null,
|
|
2164
|
+
value: null,
|
|
2165
|
+
parent: inlineTableNode,
|
|
2166
|
+
range: cloneRange(token.range),
|
|
2167
|
+
loc: cloneLoc(token.loc)
|
|
2168
|
+
};
|
|
2169
|
+
inlineTableNode.body.push(keyValueNode);
|
|
2170
|
+
const { nextToken: targetToken } = this.processKeyNode(token, keyValueNode, ctx);
|
|
2171
|
+
if (!isEq(targetToken)) return ctx.reportParseError("missing-equals-sign", targetToken);
|
|
2172
|
+
const needSameLine = this.tomlVersion.gte(1, 1) ? void 0 : "invalid-inline-table-newline";
|
|
2173
|
+
ctx.addValueContainer({
|
|
2174
|
+
parent: keyValueNode,
|
|
2175
|
+
set: (valNode) => {
|
|
2176
|
+
keyValueNode.value = valNode;
|
|
2177
|
+
applyEndLoc(keyValueNode, valNode);
|
|
2178
|
+
let nextToken = ctx.nextToken({ needSameLine });
|
|
2179
|
+
if (isComma(nextToken)) {
|
|
2180
|
+
nextToken = ctx.nextToken({ needSameLine });
|
|
2181
|
+
if (nextToken && (isBare(nextToken) || isString(nextToken))) return this.processInlineTableKeyValue(nextToken, inlineTableNode, valueContainer, ctx);
|
|
2182
|
+
if (isRightBrace(nextToken)) {
|
|
2183
|
+
if (this.tomlVersion.lt(1, 1)) return ctx.reportParseError("invalid-trailing-comma-in-inline-table", nextToken);
|
|
2184
|
+
} else return ctx.reportParseError(nextToken ? "unexpected-token" : "unterminated-inline-table", nextToken);
|
|
2185
|
+
}
|
|
2186
|
+
if (isRightBrace(nextToken)) {
|
|
2187
|
+
applyEndLoc(inlineTableNode, nextToken);
|
|
2188
|
+
return valueContainer.set(inlineTableNode);
|
|
2189
|
+
}
|
|
2190
|
+
return ctx.reportParseError(nextToken ? "missing-comma" : "unterminated-inline-table", nextToken);
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
ctx.needSameLine = "invalid-key-value-newline";
|
|
2194
|
+
return ["VALUE"];
|
|
2195
|
+
}
|
|
2196
|
+
};
|
|
2197
|
+
function isDot(token) {
|
|
2198
|
+
return isPunctuator(token) && token.value === ".";
|
|
2199
|
+
}
|
|
2200
|
+
function isEq(token) {
|
|
2201
|
+
return isPunctuator(token) && token.value === "=";
|
|
2202
|
+
}
|
|
2203
|
+
function isLeftBracket(token) {
|
|
2204
|
+
return isPunctuator(token) && token.value === "[";
|
|
2205
|
+
}
|
|
2206
|
+
function isRightBracket(token) {
|
|
2207
|
+
return isPunctuator(token) && token.value === "]";
|
|
2208
|
+
}
|
|
2209
|
+
function isLeftBrace(token) {
|
|
2210
|
+
return isPunctuator(token) && token.value === "{";
|
|
2211
|
+
}
|
|
2212
|
+
function isRightBrace(token) {
|
|
2213
|
+
return isPunctuator(token) && token.value === "}";
|
|
2214
|
+
}
|
|
2215
|
+
function isComma(token) {
|
|
2216
|
+
return isPunctuator(token) && token.value === ",";
|
|
2217
|
+
}
|
|
2218
|
+
function isPunctuator(token) {
|
|
2219
|
+
return Boolean(token && token.type === "Punctuator");
|
|
2220
|
+
}
|
|
2221
|
+
function isBare(token) {
|
|
2222
|
+
return token.type === "Bare";
|
|
2223
|
+
}
|
|
2224
|
+
function isString(token) {
|
|
2225
|
+
return token.type === "BasicString" || token.type === "LiteralString";
|
|
2226
|
+
}
|
|
2227
|
+
function isMultiLineString(token) {
|
|
2228
|
+
return token.type === "MultiLineBasicString" || token.type === "MultiLineLiteralString";
|
|
2229
|
+
}
|
|
2230
|
+
function isNumber(token) {
|
|
2231
|
+
return token.type === "Integer" || token.type === "Float";
|
|
2232
|
+
}
|
|
2233
|
+
function isBoolean(token) {
|
|
2234
|
+
return token.type === "Boolean";
|
|
2235
|
+
}
|
|
2236
|
+
function isDateTime(token) {
|
|
2237
|
+
return token.type === "OffsetDateTime" || token.type === "LocalDateTime" || token.type === "LocalDate" || token.type === "LocalTime";
|
|
2238
|
+
}
|
|
2239
|
+
function applyEndLoc(node, child) {
|
|
2240
|
+
if (child) {
|
|
2241
|
+
node.range[1] = child.range[1];
|
|
2242
|
+
node.loc.end = clonePos(child.loc.end);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
function cloneRange(range) {
|
|
2246
|
+
return [range[0], range[1]];
|
|
2247
|
+
}
|
|
2248
|
+
function cloneLoc(loc) {
|
|
2249
|
+
return {
|
|
2250
|
+
start: clonePos(loc.start),
|
|
2251
|
+
end: clonePos(loc.end)
|
|
2252
|
+
};
|
|
2253
|
+
}
|
|
2254
|
+
function clonePos(pos) {
|
|
2255
|
+
return {
|
|
2256
|
+
line: pos.line,
|
|
2257
|
+
column: pos.column
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
var tomlKeys = {
|
|
2261
|
+
Program: ["body"],
|
|
2262
|
+
TOMLTopLevelTable: ["body"],
|
|
2263
|
+
TOMLTable: ["key", "body"],
|
|
2264
|
+
TOMLKeyValue: ["key", "value"],
|
|
2265
|
+
TOMLKey: ["keys"],
|
|
2266
|
+
TOMLArray: ["elements"],
|
|
2267
|
+
TOMLInlineTable: ["body"],
|
|
2268
|
+
TOMLBare: [],
|
|
2269
|
+
TOMLQuoted: [],
|
|
2270
|
+
TOMLValue: []
|
|
2271
|
+
};
|
|
2272
|
+
var KEYS2 = unionWith(tomlKeys);
|
|
2273
|
+
function parseForESLint(code, options) {
|
|
2274
|
+
return {
|
|
2275
|
+
ast: new TOMLParser(code, options).parse(),
|
|
2276
|
+
visitorKeys: KEYS2,
|
|
2277
|
+
services: { isTOML: true }
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
var getStaticTOMLValue = generateConvertTOMLValue((node) => node.value);
|
|
2281
|
+
function generateConvertTOMLValue(convertValue) {
|
|
2282
|
+
function resolveValue(node, baseTable) {
|
|
2283
|
+
return resolver[node.type](node, baseTable);
|
|
2284
|
+
}
|
|
2285
|
+
const resolver = {
|
|
2286
|
+
Program(node, baseTable = {}) {
|
|
2287
|
+
return resolveValue(node.body[0], baseTable);
|
|
2288
|
+
},
|
|
2289
|
+
TOMLTopLevelTable(node, baseTable = {}) {
|
|
2290
|
+
for (const body of node.body) resolveValue(body, baseTable);
|
|
2291
|
+
return baseTable;
|
|
2292
|
+
},
|
|
2293
|
+
TOMLKeyValue(node, baseTable = {}) {
|
|
2294
|
+
const value = resolveValue(node.value);
|
|
2295
|
+
set(baseTable, resolveValue(node.key), value);
|
|
2296
|
+
return baseTable;
|
|
2297
|
+
},
|
|
2298
|
+
TOMLTable(node, baseTable = {}) {
|
|
2299
|
+
const table = getTable(baseTable, resolveValue(node.key), node.kind === "array");
|
|
2300
|
+
for (const body of node.body) resolveValue(body, table);
|
|
2301
|
+
return baseTable;
|
|
2302
|
+
},
|
|
2303
|
+
TOMLArray(node) {
|
|
2304
|
+
return node.elements.map((e) => resolveValue(e));
|
|
2305
|
+
},
|
|
2306
|
+
TOMLInlineTable(node) {
|
|
2307
|
+
const table = {};
|
|
2308
|
+
for (const body of node.body) resolveValue(body, table);
|
|
2309
|
+
return table;
|
|
2310
|
+
},
|
|
2311
|
+
TOMLKey(node) {
|
|
2312
|
+
return node.keys.map((key) => resolveValue(key));
|
|
2313
|
+
},
|
|
2314
|
+
TOMLBare(node) {
|
|
2315
|
+
return node.name;
|
|
2316
|
+
},
|
|
2317
|
+
TOMLQuoted(node) {
|
|
2318
|
+
return node.value;
|
|
2319
|
+
},
|
|
2320
|
+
TOMLValue(node) {
|
|
2321
|
+
return convertValue(node);
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
return (node) => resolveValue(node);
|
|
2325
|
+
}
|
|
2326
|
+
function getTable(baseTable, keys, array) {
|
|
2327
|
+
let target = baseTable;
|
|
2328
|
+
for (let index = 0; index < keys.length - 1; index++) {
|
|
2329
|
+
const key = keys[index];
|
|
2330
|
+
target = getNextTargetFromKey(target, key);
|
|
2331
|
+
}
|
|
2332
|
+
const lastKey = last(keys);
|
|
2333
|
+
const lastTarget = target[lastKey];
|
|
2334
|
+
if (lastTarget == null) {
|
|
2335
|
+
const tableValue$1 = {};
|
|
2336
|
+
target[lastKey] = array ? [tableValue$1] : tableValue$1;
|
|
2337
|
+
return tableValue$1;
|
|
2338
|
+
}
|
|
2339
|
+
if (isValue(lastTarget)) {
|
|
2340
|
+
const tableValue$1 = {};
|
|
2341
|
+
target[lastKey] = array ? [tableValue$1] : tableValue$1;
|
|
2342
|
+
return tableValue$1;
|
|
2343
|
+
}
|
|
2344
|
+
if (!array) {
|
|
2345
|
+
if (Array.isArray(lastTarget)) {
|
|
2346
|
+
const tableValue$1 = {};
|
|
2347
|
+
target[lastKey] = tableValue$1;
|
|
2348
|
+
return tableValue$1;
|
|
2349
|
+
}
|
|
2350
|
+
return lastTarget;
|
|
2351
|
+
}
|
|
2352
|
+
if (Array.isArray(lastTarget)) {
|
|
2353
|
+
const tableValue$1 = {};
|
|
2354
|
+
lastTarget.push(tableValue$1);
|
|
2355
|
+
return tableValue$1;
|
|
2356
|
+
}
|
|
2357
|
+
const tableValue = {};
|
|
2358
|
+
target[lastKey] = [tableValue];
|
|
2359
|
+
return tableValue;
|
|
2360
|
+
function getNextTargetFromKey(currTarget, key) {
|
|
2361
|
+
const nextTarget = currTarget[key];
|
|
2362
|
+
if (nextTarget == null) {
|
|
2363
|
+
const val = {};
|
|
2364
|
+
currTarget[key] = val;
|
|
2365
|
+
return val;
|
|
2366
|
+
}
|
|
2367
|
+
if (isValue(nextTarget)) {
|
|
2368
|
+
const val = {};
|
|
2369
|
+
currTarget[key] = val;
|
|
2370
|
+
return val;
|
|
2371
|
+
}
|
|
2372
|
+
let resultTarget = nextTarget;
|
|
2373
|
+
while (Array.isArray(resultTarget)) {
|
|
2374
|
+
const lastIndex = resultTarget.length - 1;
|
|
2375
|
+
const nextElement = resultTarget[lastIndex];
|
|
2376
|
+
if (isValue(nextElement)) {
|
|
2377
|
+
const val = {};
|
|
2378
|
+
resultTarget[lastIndex] = val;
|
|
2379
|
+
return val;
|
|
2380
|
+
}
|
|
2381
|
+
resultTarget = nextElement;
|
|
2382
|
+
}
|
|
2383
|
+
return resultTarget;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
function set(baseTable, keys, value) {
|
|
2387
|
+
let target = baseTable;
|
|
2388
|
+
for (let index = 0; index < keys.length - 1; index++) {
|
|
2389
|
+
const key = keys[index];
|
|
2390
|
+
const nextTarget = target[key];
|
|
2391
|
+
if (nextTarget == null) {
|
|
2392
|
+
const val = {};
|
|
2393
|
+
target[key] = val;
|
|
2394
|
+
target = val;
|
|
2395
|
+
} else if (isValue(nextTarget) || Array.isArray(nextTarget)) {
|
|
2396
|
+
const val = {};
|
|
2397
|
+
target[key] = val;
|
|
2398
|
+
target = val;
|
|
2399
|
+
} else target = nextTarget;
|
|
2400
|
+
}
|
|
2401
|
+
target[last(keys)] = value;
|
|
2402
|
+
}
|
|
2403
|
+
function isValue(value) {
|
|
2404
|
+
return typeof value !== "object" || value instanceof Date;
|
|
2405
|
+
}
|
|
2406
|
+
function parseTOML(code, options) {
|
|
2407
|
+
return parseForESLint(code, options).ast;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
// ../hexasync-template-client-setup/src/config/toml.ts
|
|
2411
|
+
function keyPath(key) {
|
|
2412
|
+
return key.keys.map((component) => component.type === "TOMLBare" ? component.name : component.value);
|
|
2413
|
+
}
|
|
2414
|
+
function renderTomlValue(value) {
|
|
2415
|
+
if (Array.isArray(value)) return `[${value.map((item) => JSON.stringify(item)).join(", ")}]`;
|
|
2416
|
+
return typeof value === "string" ? JSON.stringify(value) : String(value);
|
|
2417
|
+
}
|
|
2418
|
+
function planTomlServerTable(beforeImage, request) {
|
|
2419
|
+
const [mapKey, name] = request.tablePath;
|
|
2420
|
+
const removing = request.fields === null;
|
|
2421
|
+
const refused = (status, reason) => Object.freeze({ status, afterImage: beforeImage, operation: removing ? "remove" : "add", reason });
|
|
2422
|
+
const text = beforeImage ?? "";
|
|
2423
|
+
let parsed;
|
|
2424
|
+
try {
|
|
2425
|
+
parsed = parseTOML(text, { tomlVersion: "1.0" });
|
|
2426
|
+
} catch {
|
|
2427
|
+
return refused("Malformed", "The configuration is not valid TOML; repair it before installing.");
|
|
2428
|
+
}
|
|
2429
|
+
let owned = null;
|
|
2430
|
+
const descendants = [];
|
|
2431
|
+
for (const statement of parsed.body[0].body) {
|
|
2432
|
+
const path = keyPath(statement.key);
|
|
2433
|
+
if (path[0] !== mapKey) continue;
|
|
2434
|
+
if (statement.type === "TOMLKeyValue") {
|
|
2435
|
+
if (path.length === 1 || path[1] === name) return refused("Unsupported", `\`${mapKey}\` is defined with dotted or inline keys; edit \`${name}\` manually.`);
|
|
2436
|
+
continue;
|
|
2437
|
+
}
|
|
2438
|
+
if (path.length === 1) {
|
|
2439
|
+
if (statement.kind === "array" || statement.body.some((field) => keyPath(field.key)[0] === name)) {
|
|
2440
|
+
return refused("Unsupported", `\`${name}\` is defined inline under \`[${mapKey}]\`; edit it manually.`);
|
|
2441
|
+
}
|
|
2442
|
+
continue;
|
|
2443
|
+
}
|
|
2444
|
+
if (path[1] !== name) continue;
|
|
2445
|
+
if (path.length > 2) {
|
|
2446
|
+
descendants.push(statement);
|
|
2447
|
+
continue;
|
|
2448
|
+
}
|
|
2449
|
+
if (statement.kind !== "standard" || owned !== null) return refused("Unsupported", `\`${name}\` is declared more than once or as an array table.`);
|
|
2450
|
+
owned = statement;
|
|
2451
|
+
}
|
|
2452
|
+
const outcome = (afterImage, operation) => {
|
|
2453
|
+
if (afterImage !== beforeImage) {
|
|
2454
|
+
try {
|
|
2455
|
+
parseTOML(afterImage ?? "", { tomlVersion: "1.0" });
|
|
2456
|
+
} catch {
|
|
2457
|
+
return refused("Unsupported", "The preserving edit cannot guarantee valid TOML; the original file was kept.");
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
return Object.freeze({ status: afterImage === beforeImage ? "NoOp" : "Planned", afterImage, operation });
|
|
2461
|
+
};
|
|
2462
|
+
const apply = (edits2) => {
|
|
2463
|
+
let result = text;
|
|
2464
|
+
for (const edit of [...edits2].sort((a, b) => b.start - a.start)) result = result.slice(0, edit.start) + edit.text + result.slice(edit.end);
|
|
2465
|
+
return result;
|
|
2466
|
+
};
|
|
2467
|
+
const newline = /\r\n|\n|\r/.exec(text)?.[0] ?? "\n";
|
|
2468
|
+
const header = `[${mapKey}.${JSON.stringify(name)}]`;
|
|
2469
|
+
if (owned === null) {
|
|
2470
|
+
if (removing) return outcome(beforeImage, "remove");
|
|
2471
|
+
const table = header + newline + Object.entries(request.fields).map(([key, value]) => `${key} = ${renderTomlValue(value)}`).join(newline) + newline;
|
|
2472
|
+
return outcome(text + (text.length && !/[\r\n]$/.test(text) ? newline : "") + (text.length ? newline : "") + table, "add");
|
|
2473
|
+
}
|
|
2474
|
+
const closing = parsed.tokens.find((token) => token.type === "Punctuator" && token.value === "]" && token.range[0] >= owned.key.range[1] && token.loc.start.line === owned.loc.start.line);
|
|
2475
|
+
if (!closing) return refused("Unsupported", "The server table header could not be located safely.");
|
|
2476
|
+
if (removing) {
|
|
2477
|
+
const edits2 = [owned, ...descendants].map((table) => {
|
|
2478
|
+
let start = table.range[0];
|
|
2479
|
+
let end = table === owned ? Math.max(table.range[1], closing.range[1]) : table.range[1];
|
|
2480
|
+
const trailing = /^[\t ]*(?:\r\n|\n|\r)/.exec(text.slice(end));
|
|
2481
|
+
if (trailing) end += trailing[0].length;
|
|
2482
|
+
const blankBefore = /(?:\r\n|\n|\r)((?:\r\n|\n|\r))$/.exec(text.slice(0, start));
|
|
2483
|
+
if (blankBefore) start -= blankBefore[1].length;
|
|
2484
|
+
return { start, end, text: "" };
|
|
2485
|
+
});
|
|
2486
|
+
return outcome(apply(edits2), "remove");
|
|
2487
|
+
}
|
|
2488
|
+
const fields = /* @__PURE__ */ new Map();
|
|
2489
|
+
for (const field of owned.body) {
|
|
2490
|
+
const path = keyPath(field.key);
|
|
2491
|
+
if (path.length === 1) fields.set(path[0], field);
|
|
2492
|
+
}
|
|
2493
|
+
const edits = [];
|
|
2494
|
+
const missing = [];
|
|
2495
|
+
for (const [key, value] of Object.entries(request.fields)) {
|
|
2496
|
+
const field = fields.get(key);
|
|
2497
|
+
if (!field) missing.push(`${key} = ${renderTomlValue(value)}`);
|
|
2498
|
+
else {
|
|
2499
|
+
const current = field.value.type === "TOMLArray" ? field.value.elements.map((element) => element.type === "TOMLValue" ? element.value : void 0) : field.value.type === "TOMLValue" ? field.value.value : void 0;
|
|
2500
|
+
if (JSON.stringify(typeof current === "bigint" ? Number(current) : current) !== JSON.stringify(value)) {
|
|
2501
|
+
edits.push({ start: field.value.range[0], end: field.value.range[1], text: renderTomlValue(value) });
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
if (missing.length) {
|
|
2506
|
+
const lineFeed = text.indexOf("\n", closing.range[1]);
|
|
2507
|
+
const insertion = lineFeed < 0 ? text.length : text[lineFeed - 1] === "\r" ? lineFeed - 1 : lineFeed;
|
|
2508
|
+
edits.push({ start: insertion, end: insertion, text: newline + missing.join(newline) + (lineFeed < 0 ? newline : "") });
|
|
2509
|
+
}
|
|
2510
|
+
return outcome(edits.length ? apply(edits) : beforeImage, "update");
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
// ../hexasync-template-client-setup/src/node/standalone.ts
|
|
2514
|
+
var STANDALONE_SERVER_NAME = "hexasync-template-ide";
|
|
2515
|
+
var STANDALONE_MCP_PACKAGE = "@beehexa/hexasync-template-ide-mcp";
|
|
2516
|
+
var STANDALONE_CLIENT_IDS = ["claude", "codex", "cursor", "antigravity", "pi", "openclaw", "vscode"];
|
|
2517
|
+
function standaloneLaunch(platform, packageSpec = `${STANDALONE_MCP_PACKAGE}@latest`) {
|
|
2518
|
+
return platform === "win32" ? { command: "cmd", args: ["/c", "npx", "-y", packageSpec] } : { command: "npx", args: ["-y", packageSpec] };
|
|
2519
|
+
}
|
|
2520
|
+
var pathFor = (host) => host.platform === "win32" ? win32 : posix;
|
|
2521
|
+
var envPath = (host, name) => host.env[name]?.trim() || void 0;
|
|
2522
|
+
function vscodeUserDir(host) {
|
|
2523
|
+
const path = pathFor(host);
|
|
2524
|
+
if (host.platform === "win32") return path.join(envPath(host, "APPDATA") ?? path.join(host.home, "AppData", "Roaming"), "Code", "User");
|
|
2525
|
+
if (host.platform === "darwin") return path.join(host.home, "Library", "Application Support", "Code", "User");
|
|
2526
|
+
return path.join(envPath(host, "XDG_CONFIG_HOME") ?? path.join(host.home, ".config"), "Code", "User");
|
|
2527
|
+
}
|
|
2528
|
+
var STANDALONE_DIALECTS = Object.freeze({
|
|
2529
|
+
claude: {
|
|
2530
|
+
id: "claude",
|
|
2531
|
+
displayName: "Claude Code",
|
|
2532
|
+
format: "json",
|
|
2533
|
+
mapPath: ["mcpServers"],
|
|
2534
|
+
configPath: (scope, host) => scope === "project" ? pathFor(host).join(host.cwd, ".mcp.json") : pathFor(host).join(envPath(host, "CLAUDE_CONFIG_DIR") ?? host.home, ".claude.json"),
|
|
2535
|
+
entry: (launch) => ({ type: "stdio", command: launch.command, args: [...launch.args], env: {} }),
|
|
2536
|
+
cli: {
|
|
2537
|
+
executable: "claude",
|
|
2538
|
+
beforeAdd: (scope) => ["mcp", "remove", "--scope", scope, STANDALONE_SERVER_NAME],
|
|
2539
|
+
add: (scope, launch) => ["mcp", "add", "--scope", scope, "--transport", "stdio", STANDALONE_SERVER_NAME, "--", launch.command, ...launch.args],
|
|
2540
|
+
remove: (scope) => ["mcp", "remove", "--scope", scope, STANDALONE_SERVER_NAME]
|
|
2541
|
+
}
|
|
2542
|
+
},
|
|
2543
|
+
codex: {
|
|
2544
|
+
id: "codex",
|
|
2545
|
+
displayName: "Codex",
|
|
2546
|
+
format: "toml",
|
|
2547
|
+
mapPath: ["mcp_servers"],
|
|
2548
|
+
configPath: (scope, host) => scope === "project" ? pathFor(host).join(host.cwd, ".codex", "config.toml") : pathFor(host).join(envPath(host, "CODEX_HOME") ?? pathFor(host).join(host.home, ".codex"), "config.toml"),
|
|
2549
|
+
// The first npx run downloads the package; Codex's 10 s default start-up budget is too short for that.
|
|
2550
|
+
entry: (launch) => ({ command: launch.command, args: [...launch.args], startup_timeout_sec: 30 })
|
|
2551
|
+
},
|
|
2552
|
+
cursor: {
|
|
2553
|
+
id: "cursor",
|
|
2554
|
+
displayName: "Cursor",
|
|
2555
|
+
format: "json",
|
|
2556
|
+
mapPath: ["mcpServers"],
|
|
2557
|
+
configPath: (scope, host) => pathFor(host).join(scope === "project" ? host.cwd : host.home, ".cursor", "mcp.json"),
|
|
2558
|
+
entry: (launch) => ({ type: "stdio", command: launch.command, args: [...launch.args] })
|
|
2559
|
+
},
|
|
2560
|
+
antigravity: {
|
|
2561
|
+
id: "antigravity",
|
|
2562
|
+
displayName: "Antigravity",
|
|
2563
|
+
format: "json",
|
|
2564
|
+
mapPath: ["mcpServers"],
|
|
2565
|
+
configPath: (scope, host) => scope === "project" ? pathFor(host).join(host.cwd, ".agents", "mcp_config.json") : pathFor(host).join(host.home, ".gemini", "config", "mcp_config.json"),
|
|
2566
|
+
entry: (launch) => ({ command: launch.command, args: [...launch.args] })
|
|
2567
|
+
},
|
|
2568
|
+
pi: {
|
|
2569
|
+
id: "pi",
|
|
2570
|
+
displayName: "pi",
|
|
2571
|
+
format: "json",
|
|
2572
|
+
mapPath: ["mcpServers"],
|
|
2573
|
+
configPath: (scope, host) => scope === "project" ? pathFor(host).join(host.cwd, ".pi", "mcp.json") : pathFor(host).join(envPath(host, "PI_CODING_AGENT_DIR") ?? pathFor(host).join(host.home, ".pi", "agent"), "mcp.json"),
|
|
2574
|
+
// Direct exposure registers the seven tools as first-class tools instead of behind the MCP proxy tool.
|
|
2575
|
+
entry: (launch) => ({ command: launch.command, args: [...launch.args], exposure: "direct" })
|
|
2576
|
+
},
|
|
2577
|
+
openclaw: {
|
|
2578
|
+
id: "openclaw",
|
|
2579
|
+
displayName: "OpenClaw",
|
|
2580
|
+
format: "jsonc",
|
|
2581
|
+
mapPath: ["mcp", "servers"],
|
|
2582
|
+
configPath: (scope, host) => scope === "project" ? null : envPath(host, "OPENCLAW_CONFIG_PATH") ?? pathFor(host).join(envPath(host, "OPENCLAW_STATE_DIR") ?? pathFor(host).join(host.home, ".openclaw"), "openclaw.json"),
|
|
2583
|
+
entry: (launch) => ({ command: launch.command, args: [...launch.args] }),
|
|
2584
|
+
cli: {
|
|
2585
|
+
executable: "openclaw",
|
|
2586
|
+
add: (_scope, launch) => ["mcp", "set", STANDALONE_SERVER_NAME, JSON.stringify({ command: launch.command, args: launch.args })],
|
|
2587
|
+
remove: () => ["mcp", "unset", STANDALONE_SERVER_NAME]
|
|
2588
|
+
}
|
|
2589
|
+
},
|
|
2590
|
+
vscode: {
|
|
2591
|
+
id: "vscode",
|
|
2592
|
+
displayName: "VS Code",
|
|
2593
|
+
format: "jsonc",
|
|
2594
|
+
mapPath: ["servers"],
|
|
2595
|
+
configPath: (scope, host) => scope === "project" ? pathFor(host).join(host.cwd, ".vscode", "mcp.json") : pathFor(host).join(vscodeUserDir(host), "mcp.json"),
|
|
2596
|
+
entry: (launch) => ({ type: "stdio", command: launch.command, args: [...launch.args] })
|
|
2597
|
+
}
|
|
2598
|
+
});
|
|
2599
|
+
function planStandaloneRegistration(clientId, beforeImage, request) {
|
|
2600
|
+
const dialect = STANDALONE_DIALECTS[clientId];
|
|
2601
|
+
const entry = request.operation === "remove" ? null : dialect.entry(request.launch);
|
|
2602
|
+
if (dialect.format === "toml") {
|
|
2603
|
+
return planTomlServerTable(beforeImage, {
|
|
2604
|
+
tablePath: [dialect.mapPath[0], STANDALONE_SERVER_NAME],
|
|
2605
|
+
fields: entry
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
return planJsonServerEntry(beforeImage, { format: dialect.format, mapPath: dialect.mapPath, entryKey: STANDALONE_SERVER_NAME, entry });
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
// src/features/install/clients.ts
|
|
2612
|
+
import { posix as posix2, win32 as win322 } from "node:path";
|
|
2613
|
+
function skillsDir(clientId, scope, host) {
|
|
2614
|
+
const path = host.platform === "win32" ? win322 : posix2;
|
|
2615
|
+
const env = (name) => host.env[name]?.trim() || void 0;
|
|
2616
|
+
const project = path.join(host.cwd, ".agents", "skills");
|
|
2617
|
+
switch (clientId) {
|
|
2618
|
+
case "claude":
|
|
2619
|
+
return scope === "project" ? path.join(host.cwd, ".claude", "skills") : path.join(env("CLAUDE_CONFIG_DIR") ?? path.join(host.home, ".claude"), "skills");
|
|
2620
|
+
case "codex":
|
|
2621
|
+
return scope === "project" ? project : path.join(host.home, ".agents", "skills");
|
|
2622
|
+
case "cursor":
|
|
2623
|
+
return scope === "project" ? project : path.join(host.home, ".cursor", "skills");
|
|
2624
|
+
case "antigravity":
|
|
2625
|
+
return scope === "project" ? project : path.join(host.home, ".gemini", "antigravity", "skills");
|
|
2626
|
+
case "pi":
|
|
2627
|
+
return scope === "project" ? project : path.join(host.home, ".agents", "skills");
|
|
2628
|
+
case "openclaw":
|
|
2629
|
+
return scope === "project" ? path.join(host.cwd, "skills") : path.join(env("OPENCLAW_STATE_DIR") ?? path.join(host.home, ".openclaw"), "skills");
|
|
2630
|
+
case "vscode":
|
|
2631
|
+
return scope === "project" ? project : path.join(host.home, ".copilot", "skills");
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
function vscodeExtensionRoots(host) {
|
|
2635
|
+
const path = host.platform === "win32" ? win322 : posix2;
|
|
2636
|
+
return [".vscode", ".vscode-insiders", ".vscode-server", ".vscode-server-insiders", ".vscode-oss"].map((folder) => path.join(host.home, folder, "extensions"));
|
|
2637
|
+
}
|
|
2638
|
+
var HEXASYNC_EXTENSION_PREFIX = "beehexa-corp.hexasync-templates-";
|
|
2639
|
+
|
|
2640
|
+
// src/features/install/plan.ts
|
|
2641
|
+
async function extensionInstalled(ports) {
|
|
2642
|
+
for (const root of vscodeExtensionRoots(ports.host)) {
|
|
2643
|
+
const match = (await ports.listDir(root)).find((name) => name.toLowerCase().startsWith(HEXASYNC_EXTENSION_PREFIX));
|
|
2644
|
+
if (match) return `${root}/${match}`;
|
|
2645
|
+
}
|
|
2646
|
+
return null;
|
|
2647
|
+
}
|
|
2648
|
+
async function planInstall(options, ports) {
|
|
2649
|
+
const launch = standaloneLaunch(ports.host.platform);
|
|
2650
|
+
const copiedTo = /* @__PURE__ */ new Map();
|
|
2651
|
+
const clients = [];
|
|
2652
|
+
for (const clientId of options.clients) {
|
|
2653
|
+
const dialect = STANDALONE_DIALECTS[clientId];
|
|
2654
|
+
const actions = [];
|
|
2655
|
+
const configPath = dialect.configPath(options.scope, ports.host);
|
|
2656
|
+
const before = configPath === null ? null : await ports.readText(configPath);
|
|
2657
|
+
const registered = before !== null && planStandaloneRegistration(clientId, before, { operation: "remove", launch }).status === "Planned";
|
|
2658
|
+
const target = skillsDir(clientId, options.scope, ports.host);
|
|
2659
|
+
const present = target === null ? [] : (await ports.listDir(target)).filter((name) => options.skillNames.includes(name));
|
|
2660
|
+
if (options.command === "update" && !registered && present.length === 0) {
|
|
2661
|
+
clients.push({ clientId, displayName: dialect.displayName, actions: [{ kind: "note", message: `nothing installed at ${options.scope} scope; run \`install\` to add it` }] });
|
|
2662
|
+
continue;
|
|
2663
|
+
}
|
|
2664
|
+
const removing = options.command === "uninstall";
|
|
2665
|
+
if (options.skills && target !== null) {
|
|
2666
|
+
const shared = copiedTo.get(target);
|
|
2667
|
+
if (shared) actions.push({ kind: "note", message: `skills: shared directory ${target} (handled with ${shared})` });
|
|
2668
|
+
else if (removing) {
|
|
2669
|
+
copiedTo.set(target, dialect.displayName);
|
|
2670
|
+
actions.push(present.length ? { kind: "remove-skills", target, skills: present } : { kind: "note", message: `skills: none installed in ${target}` });
|
|
2671
|
+
} else {
|
|
2672
|
+
copiedTo.set(target, dialect.displayName);
|
|
2673
|
+
actions.push({ kind: "copy-skills", target, skills: options.skillNames });
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
if (options.mcp) {
|
|
2677
|
+
const extension = !removing && clientId === "vscode" ? await extensionInstalled(ports) : null;
|
|
2678
|
+
const cli = options.useCli && dialect.cli ? await ports.which(dialect.cli.executable) : null;
|
|
2679
|
+
if (extension) {
|
|
2680
|
+
actions.push({ kind: "warn", message: `mcp: skipped \u2014 the HexaSync Template IDE extension (${extension}) already provides this server in VS Code; a second registration would duplicate every tool` });
|
|
2681
|
+
} else if (configPath === null) {
|
|
2682
|
+
actions.push({ kind: "warn", message: `mcp: ${dialect.displayName} has no ${options.scope}-scope MCP configuration; use --scope user` });
|
|
2683
|
+
} else if (cli && dialect.cli) {
|
|
2684
|
+
if (removing) actions.push({ kind: "run", executable: cli, argv: dialect.cli.remove(options.scope), allowFailure: !registered });
|
|
2685
|
+
else {
|
|
2686
|
+
const prepare = dialect.cli.beforeAdd?.(options.scope);
|
|
2687
|
+
if (prepare) actions.push({ kind: "run", executable: cli, argv: prepare, allowFailure: true });
|
|
2688
|
+
actions.push({ kind: "run", executable: cli, argv: dialect.cli.add(options.scope, launch), allowFailure: false });
|
|
2689
|
+
}
|
|
2690
|
+
} else {
|
|
2691
|
+
const planned = planStandaloneRegistration(clientId, before, { operation: removing ? "remove" : "add", launch });
|
|
2692
|
+
const mapLabel = `${dialect.mapPath.join(".")}.${STANDALONE_SERVER_NAME}`;
|
|
2693
|
+
if (planned.status === "Planned" && planned.afterImage !== null) {
|
|
2694
|
+
actions.push({
|
|
2695
|
+
kind: "write-config",
|
|
2696
|
+
path: configPath,
|
|
2697
|
+
before,
|
|
2698
|
+
after: planned.afterImage,
|
|
2699
|
+
operation: planned.operation,
|
|
2700
|
+
summary: `${planned.operation} ${mapLabel}`
|
|
2701
|
+
});
|
|
2702
|
+
} else if (planned.status === "NoOp") {
|
|
2703
|
+
actions.push({ kind: "note", message: `mcp: ${configPath} already ${removing ? "has no" : "has the current"} ${mapLabel}` });
|
|
2704
|
+
} else {
|
|
2705
|
+
actions.push({ kind: "error", message: `mcp: ${configPath} left unchanged \u2014 ${planned.reason ?? planned.status}` });
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
clients.push({ clientId, displayName: dialect.displayName, actions });
|
|
2710
|
+
}
|
|
2711
|
+
return { options, launch, clients };
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
// src/cli/main.ts
|
|
2715
|
+
var USAGE = `Usage: hexasync-ai-toolkit <command> [options]
|
|
2716
|
+
|
|
2717
|
+
Commands:
|
|
2718
|
+
install Copy the HexaSync skills and register the HexaSync Template IDE MCP server
|
|
2719
|
+
update Refresh skills and the MCP registration wherever they are already installed
|
|
2720
|
+
uninstall Remove the HexaSync skills and the MCP registration
|
|
2721
|
+
list Show the packaged skills and what is installed for each client
|
|
2722
|
+
|
|
2723
|
+
Options:
|
|
2724
|
+
--client <id> ${STANDALONE_CLIENT_IDS.join("|")}|all (repeatable or comma-separated; default all)
|
|
2725
|
+
--scope <scope> user|project (default user; project uses the current directory)
|
|
2726
|
+
--skills-only Only copy/remove skills
|
|
2727
|
+
--mcp-only Only register/remove the MCP server
|
|
2728
|
+
--dry-run Print the planned changes without writing anything
|
|
2729
|
+
--no-cli Edit config files even when the client's own CLI (claude, openclaw) is on PATH
|
|
2730
|
+
-h, --help Show this help
|
|
2731
|
+
-v, --version Print the toolkit version`;
|
|
2732
|
+
function parseArgs(argv) {
|
|
2733
|
+
let command;
|
|
2734
|
+
const clients = /* @__PURE__ */ new Set();
|
|
2735
|
+
let scope = "user";
|
|
2736
|
+
let skillsOnly = false, mcpOnly = false, dryRun = false, useCli = true;
|
|
2737
|
+
for (let index = 0; index < argv.length; index++) {
|
|
2738
|
+
const argument = argv[index];
|
|
2739
|
+
const [flag, inline] = argument.startsWith("--") && argument.includes("=") ? [argument.slice(0, argument.indexOf("=")), argument.slice(argument.indexOf("=") + 1)] : [argument, void 0];
|
|
2740
|
+
const value = () => {
|
|
2741
|
+
const next = inline ?? argv[++index];
|
|
2742
|
+
if (next === void 0 || next.startsWith("-")) throw new Error(`${flag} needs a value.`);
|
|
2743
|
+
return next;
|
|
2744
|
+
};
|
|
2745
|
+
switch (flag) {
|
|
2746
|
+
case "-h":
|
|
2747
|
+
case "--help":
|
|
2748
|
+
command = "help";
|
|
2749
|
+
break;
|
|
2750
|
+
case "-v":
|
|
2751
|
+
case "--version":
|
|
2752
|
+
command = "version";
|
|
2753
|
+
break;
|
|
2754
|
+
case "--client":
|
|
2755
|
+
for (const id of value().split(",").map((part) => part.trim().toLowerCase()).filter(Boolean)) {
|
|
2756
|
+
if (id === "all") STANDALONE_CLIENT_IDS.forEach((client) => clients.add(client));
|
|
2757
|
+
else if (STANDALONE_CLIENT_IDS.includes(id)) clients.add(id);
|
|
2758
|
+
else throw new Error(`Unknown client "${id}". Use one of: ${STANDALONE_CLIENT_IDS.join(", ")}, all.`);
|
|
2759
|
+
}
|
|
2760
|
+
break;
|
|
2761
|
+
case "--scope": {
|
|
2762
|
+
const selected = value();
|
|
2763
|
+
if (selected !== "user" && selected !== "project") throw new Error("--scope must be user or project.");
|
|
2764
|
+
scope = selected;
|
|
2765
|
+
break;
|
|
2766
|
+
}
|
|
2767
|
+
case "--skills-only":
|
|
2768
|
+
skillsOnly = true;
|
|
2769
|
+
break;
|
|
2770
|
+
case "--mcp-only":
|
|
2771
|
+
mcpOnly = true;
|
|
2772
|
+
break;
|
|
2773
|
+
case "--dry-run":
|
|
2774
|
+
dryRun = true;
|
|
2775
|
+
break;
|
|
2776
|
+
case "--no-cli":
|
|
2777
|
+
useCli = false;
|
|
2778
|
+
break;
|
|
2779
|
+
default:
|
|
2780
|
+
if (command === void 0 && ["install", "uninstall", "update", "list", "help"].includes(argument)) command = argument;
|
|
2781
|
+
else throw new Error(`Unknown argument "${argument}".`);
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
if (skillsOnly && mcpOnly) throw new Error("--skills-only and --mcp-only exclude each other.");
|
|
2785
|
+
return {
|
|
2786
|
+
command: command ?? "help",
|
|
2787
|
+
clients: clients.size ? [...clients] : [...STANDALONE_CLIENT_IDS],
|
|
2788
|
+
scope,
|
|
2789
|
+
skills: !mcpOnly,
|
|
2790
|
+
mcp: !skillsOnly,
|
|
2791
|
+
dryRun,
|
|
2792
|
+
useCli
|
|
2793
|
+
};
|
|
2794
|
+
}
|
|
2795
|
+
function describe(action, plan, clientId) {
|
|
2796
|
+
switch (action.kind) {
|
|
2797
|
+
case "copy-skills":
|
|
2798
|
+
return [`+ skills copy ${action.skills.length} skills \u2192 ${action.target}`];
|
|
2799
|
+
case "remove-skills":
|
|
2800
|
+
return [`- skills remove ${action.skills.length} skills from ${action.target}`];
|
|
2801
|
+
case "write-config": {
|
|
2802
|
+
const dialect = STANDALONE_DIALECTS[clientId];
|
|
2803
|
+
const lines = [`${action.operation === "remove" ? "-" : "+"} mcp ${action.path}: ${action.summary}${action.before === null ? " (new file)" : " (backup kept)"}`];
|
|
2804
|
+
if (action.operation !== "remove") lines.push(` entry ${JSON.stringify(dialect.entry(plan.launch))}`);
|
|
2805
|
+
return lines;
|
|
2806
|
+
}
|
|
2807
|
+
case "run":
|
|
2808
|
+
return [`${action.allowFailure ? "\xB7" : "+"} mcp $ ${[action.executable, ...action.argv].map((part) => /[\s{"]/.test(part) ? `'${part}'` : part).join(" ")}`];
|
|
2809
|
+
case "note":
|
|
2810
|
+
return [`\xB7 ${action.message}`];
|
|
2811
|
+
case "warn":
|
|
2812
|
+
return [`! ${action.message}`];
|
|
2813
|
+
case "error":
|
|
2814
|
+
return [`\u2717 ${action.message}`];
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2817
|
+
async function directoryBytes(path) {
|
|
2818
|
+
let total = 0;
|
|
2819
|
+
for (const entry of await readdir2(path, { withFileTypes: true })) {
|
|
2820
|
+
total += entry.isDirectory() ? await directoryBytes(join2(path, entry.name)) : (await stat(join2(path, entry.name))).size;
|
|
2821
|
+
}
|
|
2822
|
+
return total;
|
|
2823
|
+
}
|
|
2824
|
+
async function packagedSkills(packageRoot2) {
|
|
2825
|
+
const root = join2(packageRoot2, "skills");
|
|
2826
|
+
try {
|
|
2827
|
+
return (await readdir2(root, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort();
|
|
2828
|
+
} catch {
|
|
2829
|
+
throw new Error(`No skills found in ${root}. Build the package first (yarn ai-toolkit:build).`);
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
async function runCli(argv, environment) {
|
|
2833
|
+
const { write, ports, packageRoot: packageRoot2 } = environment;
|
|
2834
|
+
let args;
|
|
2835
|
+
try {
|
|
2836
|
+
args = parseArgs(argv);
|
|
2837
|
+
} catch (error) {
|
|
2838
|
+
write(`${error instanceof Error ? error.message : String(error)}
|
|
2839
|
+
|
|
2840
|
+
${USAGE}
|
|
2841
|
+
`);
|
|
2842
|
+
return 2;
|
|
2843
|
+
}
|
|
2844
|
+
const manifest = JSON.parse(await readFile2(join2(packageRoot2, "package.json"), "utf8"));
|
|
2845
|
+
const version = manifest && typeof manifest === "object" && "version" in manifest && typeof manifest.version === "string" ? manifest.version : "unknown";
|
|
2846
|
+
if (args.command === "help") {
|
|
2847
|
+
write(`${USAGE}
|
|
2848
|
+
`);
|
|
2849
|
+
return 0;
|
|
2850
|
+
}
|
|
2851
|
+
if (args.command === "version") {
|
|
2852
|
+
write(`${version}
|
|
2853
|
+
`);
|
|
2854
|
+
return 0;
|
|
2855
|
+
}
|
|
2856
|
+
const skillNames = await packagedSkills(packageRoot2);
|
|
2857
|
+
const skillsSource = join2(packageRoot2, "skills");
|
|
2858
|
+
if (args.command === "list") {
|
|
2859
|
+
write(`HexaSync AI toolkit ${version} \u2014 ${skillNames.length} skills (${args.scope} scope, ${ports.host.platform})
|
|
2860
|
+
|
|
2861
|
+
`);
|
|
2862
|
+
for (const name of skillNames) write(` ${name.padEnd(36)} ${(await directoryBytes(join2(skillsSource, name)) / 1024).toFixed(1).padStart(7)} KiB
|
|
2863
|
+
`);
|
|
2864
|
+
write("\n");
|
|
2865
|
+
for (const clientId of args.clients) {
|
|
2866
|
+
const dialect = STANDALONE_DIALECTS[clientId];
|
|
2867
|
+
const target = skillsDir(clientId, args.scope, ports.host);
|
|
2868
|
+
const installed = target === null ? [] : (await ports.listDir(target)).filter((name) => skillNames.includes(name));
|
|
2869
|
+
const configPath = dialect.configPath(args.scope, ports.host);
|
|
2870
|
+
const before = configPath === null ? null : await ports.readText(configPath);
|
|
2871
|
+
const registered = before !== null && planStandaloneRegistration(clientId, before, { operation: "remove", launch: { command: "npx", args: [] } }).status === "Planned";
|
|
2872
|
+
write(`${dialect.displayName}
|
|
2873
|
+
skills ${installed.length}/${skillNames.length} in ${target ?? "(none)"}
|
|
2874
|
+
mcp ${configPath === null ? `(no ${args.scope}-scope config)` : `${registered ? "registered" : "not registered"} in ${configPath}`}
|
|
2875
|
+
`);
|
|
2876
|
+
}
|
|
2877
|
+
return 0;
|
|
2878
|
+
}
|
|
2879
|
+
const plan = await planInstall({
|
|
2880
|
+
command: args.command,
|
|
2881
|
+
clients: args.clients,
|
|
2882
|
+
scope: args.scope,
|
|
2883
|
+
skills: args.skills,
|
|
2884
|
+
mcp: args.mcp,
|
|
2885
|
+
useCli: args.useCli,
|
|
2886
|
+
skillsSource,
|
|
2887
|
+
skillNames
|
|
2888
|
+
}, ports);
|
|
2889
|
+
write(`HexaSync AI toolkit ${version} \u2014 ${args.command}, ${args.scope} scope, ${ports.host.platform}${args.dryRun ? " (dry run: nothing is written)" : ""}
|
|
2890
|
+
`);
|
|
2891
|
+
write(`MCP launch: ${[plan.launch.command, ...plan.launch.args].join(" ")}
|
|
2892
|
+
`);
|
|
2893
|
+
let failed = plan.clients.some((client) => client.actions.some((action) => action.kind === "error"));
|
|
2894
|
+
const results = args.dryRun ? null : await applyInstallPlan(plan);
|
|
2895
|
+
for (const client of plan.clients) {
|
|
2896
|
+
write(`
|
|
2897
|
+
${client.displayName}
|
|
2898
|
+
`);
|
|
2899
|
+
for (const action of client.actions) {
|
|
2900
|
+
for (const line of describe(action, plan, client.clientId)) write(` ${line}
|
|
2901
|
+
`);
|
|
2902
|
+
const result = results?.find((candidate) => candidate.action === action);
|
|
2903
|
+
if (result && (!result.ok || result.detail)) write(` ${result.ok ? "" : "FAILED: "}${result.detail ?? ""}
|
|
2904
|
+
`);
|
|
2905
|
+
if (result && !result.ok) failed = true;
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
if (!args.dryRun && plan.clients.some((client) => client.actions.some((action) => action.kind === "write-config" || action.kind === "run"))) {
|
|
2909
|
+
write("\nRestart (or reload) each client so it starts the MCP server and loads the skills.\n");
|
|
2910
|
+
}
|
|
2911
|
+
return failed ? 1 : 0;
|
|
2912
|
+
}
|
|
2913
|
+
|
|
2914
|
+
// src/cli/bin.ts
|
|
2915
|
+
var packageRoot = fileURLToPath(new URL("..", import.meta.url));
|
|
2916
|
+
try {
|
|
2917
|
+
process.exitCode = await runCli(process.argv.slice(2), { ports: nodeInstallPorts(), packageRoot, write: (text) => process.stdout.write(text) });
|
|
2918
|
+
} catch (error) {
|
|
2919
|
+
process.stderr.write(`hexasync-ai-toolkit: ${error instanceof Error ? error.message : String(error)}
|
|
2920
|
+
`);
|
|
2921
|
+
process.exitCode = 1;
|
|
2922
|
+
}
|