@cdklabs/cdk-ssm-documents 0.0.55 → 0.0.56
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/.jsii +12 -12
- package/lib/construct/synth-utils.js +1 -1
- package/lib/document/automation-document.js +1 -1
- package/lib/document/command-document.js +1 -1
- package/lib/document/document-builder.js +2 -2
- package/lib/document/ssm-document.js +1 -1
- package/lib/domain/aws-service.js +1 -1
- package/lib/domain/choice.js +1 -1
- package/lib/domain/data-type.js +1 -1
- package/lib/domain/enum/install-action.js +2 -2
- package/lib/domain/enum/install-uninstall-repair.js +2 -2
- package/lib/domain/enum/installation-type.js +2 -2
- package/lib/domain/enum/package-name.js +2 -2
- package/lib/domain/input.js +1 -1
- package/lib/domain/operation.js +1 -1
- package/lib/domain/platform.js +1 -1
- package/lib/domain/precondition.js +1 -1
- package/lib/incident-response/incident-response.js +3 -3
- package/lib/interface/approve-hook.js +2 -2
- package/lib/interface/auth-method.js +3 -3
- package/lib/interface/aws-invoker.js +2 -2
- package/lib/interface/downloadable-content.js +8 -8
- package/lib/interface/environment.js +3 -3
- package/lib/interface/execute-automation-hook/api-execute-automation-hook.js +1 -1
- package/lib/interface/observer.js +1 -1
- package/lib/interface/on-failure.js +6 -6
- package/lib/interface/pause-hook.js +2 -2
- package/lib/interface/run-command-hook/api-run-command-hook.js +1 -1
- package/lib/interface/run-document-location.js +2 -2
- package/lib/interface/sleep-hook.js +2 -2
- package/lib/interface/step-ref.js +1 -1
- package/lib/interface/variables/boolean-variable.js +2 -2
- package/lib/interface/variables/map-list-variable.js +2 -2
- package/lib/interface/variables/number-variable.js +2 -2
- package/lib/interface/variables/secure-string-variable.js +4 -4
- package/lib/interface/variables/string-list-variable.js +2 -2
- package/lib/interface/variables/string-map-variable.js +2 -2
- package/lib/interface/variables/string-variable.js +4 -4
- package/lib/interface/variables/variable.js +2 -2
- package/lib/interface/webhook.js +1 -1
- package/lib/parent-steps/automation/approve-step.js +1 -1
- package/lib/parent-steps/automation/assert-aws-resource-step.js +1 -1
- package/lib/parent-steps/automation/aws-api-step.js +1 -1
- package/lib/parent-steps/automation/branch-step.js +1 -1
- package/lib/parent-steps/automation/change-instance-state-step.js +3 -3
- package/lib/parent-steps/automation/copy-image-step.js +1 -1
- package/lib/parent-steps/automation/create-image-step.js +1 -1
- package/lib/parent-steps/automation/create-stack-step.js +3 -3
- package/lib/parent-steps/automation/create-tags-step.js +3 -3
- package/lib/parent-steps/automation/delete-image-step.js +1 -1
- package/lib/parent-steps/automation/delete-stack-step.js +1 -1
- package/lib/parent-steps/automation/execute-automation-step.js +1 -1
- package/lib/parent-steps/automation/execute-script-step.js +5 -5
- package/lib/parent-steps/automation/execute-state-machine-step.js +1 -1
- package/lib/parent-steps/automation/invoke-lambda-function-step.js +1 -1
- package/lib/parent-steps/automation/invoke-webhook-step.js +1 -1
- package/lib/parent-steps/automation/pause-step.js +1 -1
- package/lib/parent-steps/automation/run-command-step.js +3 -3
- package/lib/parent-steps/automation/run-instance-step.js +1 -1
- package/lib/parent-steps/automation/sleep-step.js +1 -1
- package/lib/parent-steps/automation/update-variable.js +1 -1
- package/lib/parent-steps/automation/wait-for-resource-step.js +1 -1
- package/lib/parent-steps/automation-step.js +1 -1
- package/lib/parent-steps/command/applications-step.js +1 -1
- package/lib/parent-steps/command/configure-docker-step.js +1 -1
- package/lib/parent-steps/command/configure-package-step.js +1 -1
- package/lib/parent-steps/command/domain-join-step.js +1 -1
- package/lib/parent-steps/command/download-content-step.js +1 -1
- package/lib/parent-steps/command/ps-module-step.js +1 -1
- package/lib/parent-steps/command/run-docker-action-step.js +1 -1
- package/lib/parent-steps/command/run-document-step.js +1 -1
- package/lib/parent-steps/command/run-powershell-script-step.js +1 -1
- package/lib/parent-steps/command/run-shell-script-step.js +1 -1
- package/lib/parent-steps/command/software-inventory-step.js +1 -1
- package/lib/parent-steps/command/update-agent-step.js +1 -1
- package/lib/parent-steps/command/update-ssm-agent-step.js +1 -1
- package/lib/parent-steps/command-step.js +1 -1
- package/lib/parent-steps/step.js +1 -1
- package/lib/patterns/automation/composite-step.js +2 -2
- package/lib/patterns/automation/reboot-instance-and-wait.js +1 -1
- package/lib/patterns/automation/string-step.js +1 -1
- package/lib/patterns/document/string-document.js +1 -1
- package/lib/patterns/document/timed-document.js +1 -1
- package/lib/samples/hello-world.js +1 -1
- package/lib/simulation/automation/approve-simulation.js +1 -1
- package/lib/simulation/automation/assert-aws-resource-simulation.js +1 -1
- package/lib/simulation/automation/automation-simulation-base.js +1 -1
- package/lib/simulation/automation/aws-api-simulation.js +1 -1
- package/lib/simulation/automation/branch-simulation.js +1 -1
- package/lib/simulation/automation/change-instance-state-simulation.js +1 -1
- package/lib/simulation/automation/copy-image-simulation.js +1 -1
- package/lib/simulation/automation/create-image-simulation.js +1 -1
- package/lib/simulation/automation/create-stack-simulation.js +1 -1
- package/lib/simulation/automation/create-tags-simulation.js +1 -1
- package/lib/simulation/automation/delete-image-simulation.js +1 -1
- package/lib/simulation/automation/delete-stack-simulation.js +1 -1
- package/lib/simulation/automation/execute-script-simulation.js +1 -1
- package/lib/simulation/automation/execute-state-machine-simulation.js +1 -1
- package/lib/simulation/automation/invoke-lambda-function-simulation.js +1 -1
- package/lib/simulation/automation/invoke-webhook-simulation.js +1 -1
- package/lib/simulation/automation/pause-simulation.js +1 -1
- package/lib/simulation/automation/run-command-simulation.js +1 -1
- package/lib/simulation/automation/run-instance-simulation.js +1 -1
- package/lib/simulation/automation/sleep-simulation.js +1 -1
- package/lib/simulation/automation/update-variable-simulation.js +1 -1
- package/lib/simulation/automation/wait-for-resource-simulation.js +1 -1
- package/lib/simulation/automation-step-simulation.js +1 -1
- package/lib/simulation/command/command-simulation-base.js +1 -1
- package/lib/simulation/command/ps-module-simulation.js +1 -1
- package/lib/simulation/command/run-powershell-script-simulation.js +1 -1
- package/lib/simulation/command/run-shell-script-simulation.js +1 -1
- package/lib/simulation/command-step-simulation.js +1 -1
- package/lib/simulation/document/automation-simulation.js +1 -1
- package/lib/simulation/document/command-simulation.js +1 -1
- package/lib/simulation/simulation.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +34 -34
- package/node_modules/@aws-sdk/client-cloudwatch/package.json +36 -36
- package/node_modules/@aws-sdk/client-ec2/README.md +14 -0
- package/node_modules/@aws-sdk/client-ec2/dist-cjs/index.js +41 -0
- package/node_modules/@aws-sdk/client-ec2/dist-cjs/schemas/schemas_0.js +156 -78
- package/node_modules/@aws-sdk/client-ec2/dist-es/EC2.js +6 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/commands/GetCapacityManagerMonitoredTagKeysCommand.js +16 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/commands/UpdateCapacityManagerMonitoredTagKeysCommand.js +16 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/commands/index.js +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/models/enums.js +8 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/pagination/GetCapacityManagerMonitoredTagKeysPaginator.js +4 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/pagination/index.js +1 -0
- package/node_modules/@aws-sdk/client-ec2/dist-es/schemas/schemas_0.js +96 -18
- package/node_modules/@aws-sdk/client-ec2/dist-types/EC2.d.ts +23 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/EC2Client.d.ts +4 -2
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/GetCapacityManagerMetricDataCommand.d.ts +9 -2
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/GetCapacityManagerMetricDimensionsCommand.d.ts +9 -2
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/GetCapacityManagerMonitoredTagKeysCommand.d.ts +87 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/GetConsoleScreenshotCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/GetDeclarativePoliciesReportSummaryCommand.d.ts +1 -2
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/ModifyTrafficMirrorFilterNetworkServicesCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/ModifyTrafficMirrorFilterRuleCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/UpdateCapacityManagerMonitoredTagKeysCommand.d.ts +91 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/commands/index.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/models/enums.d.ts +16 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/models/models_5.d.ts +126 -79
- package/node_modules/@aws-sdk/client-ec2/dist-types/models/models_6.d.ts +81 -122
- package/node_modules/@aws-sdk/client-ec2/dist-types/models/models_7.d.ts +168 -3
- package/node_modules/@aws-sdk/client-ec2/dist-types/pagination/GetCapacityManagerMonitoredTagKeysPaginator.d.ts +7 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/pagination/index.d.ts +1 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/schemas/schemas_0.d.ts +8 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/EC2.d.ts +55 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/EC2Client.d.ts +12 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/GetCapacityManagerMonitoredTagKeysCommand.d.ts +51 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/GetConsoleScreenshotCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/GetDeclarativePoliciesReportSummaryCommand.d.ts +4 -2
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/ModifyTrafficMirrorFilterNetworkServicesCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/ModifyTrafficMirrorFilterRuleCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/UpdateCapacityManagerMonitoredTagKeysCommand.d.ts +51 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/commands/index.d.ts +2 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/models/enums.d.ts +10 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/models/models_5.d.ts +23 -18
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/models/models_6.d.ts +19 -34
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/models/models_7.d.ts +43 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/pagination/GetCapacityManagerMonitoredTagKeysPaginator.d.ts +11 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/pagination/index.d.ts +1 -0
- package/node_modules/@aws-sdk/client-ec2/dist-types/ts3.4/schemas/schemas_0.d.ts +8 -0
- package/node_modules/@aws-sdk/client-ec2/package.json +36 -36
- package/node_modules/@aws-sdk/client-iam/package.json +35 -35
- package/node_modules/@aws-sdk/client-lambda/dist-cjs/models/errors.js +52 -1
- package/node_modules/@aws-sdk/client-lambda/dist-cjs/schemas/schemas_0.js +29 -8
- package/node_modules/@aws-sdk/client-lambda/dist-es/models/errors.js +48 -0
- package/node_modules/@aws-sdk/client-lambda/dist-es/schemas/schemas_0.js +22 -1
- package/node_modules/@aws-sdk/client-lambda/dist-types/commands/InvokeCommand.d.ts +9 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/commands/InvokeWithResponseStreamCommand.d.ts +9 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/models/errors.d.ts +66 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/models/models_0.d.ts +6 -6
- package/node_modules/@aws-sdk/client-lambda/dist-types/schemas/schemas_0.d.ts +3 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/ts3.4/models/errors.d.ts +30 -0
- package/node_modules/@aws-sdk/client-lambda/dist-types/ts3.4/schemas/schemas_0.d.ts +3 -0
- package/node_modules/@aws-sdk/client-lambda/package.json +38 -38
- package/node_modules/@aws-sdk/client-s3/dist-cjs/index.js +5 -0
- package/node_modules/@aws-sdk/client-s3/dist-es/models/enums.js +5 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/CreateBucketCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/commands/GetBucketLocationCommand.d.ts +1 -1
- package/node_modules/@aws-sdk/client-s3/dist-types/models/enums.d.ts +5 -0
- package/node_modules/@aws-sdk/client-s3/dist-types/ts3.4/models/enums.d.ts +5 -0
- package/node_modules/@aws-sdk/client-s3/package.json +50 -50
- package/node_modules/@aws-sdk/client-sns/package.json +33 -33
- package/node_modules/@aws-sdk/client-sqs/dist-cjs/index.js +2 -0
- package/node_modules/@aws-sdk/client-sqs/dist-es/commands/ReceiveMessageCommand.js +2 -0
- package/node_modules/@aws-sdk/client-sqs/package.json +36 -36
- package/node_modules/@aws-sdk/client-ssm/package.json +34 -34
- package/node_modules/@aws-sdk/core/dist-cjs/index.js +17 -0
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +17 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/index.js +1 -0
- package/node_modules/@aws-sdk/core/dist-es/submodules/client/longPollMiddleware.js +15 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/client/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/submodules/client/longPollMiddleware.d.ts +14 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/index.d.ts +1 -0
- package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/client/longPollMiddleware.d.ts +15 -0
- package/node_modules/@aws-sdk/core/package.json +11 -11
- package/node_modules/@aws-sdk/crc64-nvme/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
- package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +14 -14
- package/node_modules/@aws-sdk/credential-provider-login/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
- package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
- package/node_modules/@aws-sdk/middleware-bucket-endpoint/package.json +5 -5
- package/node_modules/@aws-sdk/middleware-expect-continue/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-flexible-checksums/package.json +10 -10
- package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-location-constraint/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-sdk-ec2/package.json +8 -8
- package/node_modules/@aws-sdk/middleware-sdk-s3/package.json +11 -11
- package/node_modules/@aws-sdk/middleware-sdk-sqs/package.json +4 -4
- package/node_modules/@aws-sdk/middleware-ssec/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +8 -8
- package/node_modules/@aws-sdk/nested-clients/package.json +32 -32
- package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +6 -6
- package/node_modules/@aws-sdk/token-providers/package.json +7 -7
- package/node_modules/@aws-sdk/types/package.json +2 -2
- package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
- package/node_modules/@aws-sdk/util-format-url/package.json +4 -4
- package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +5 -5
- package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/package.json +1 -1
- package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
- package/node_modules/@smithy/config-resolver/package.json +2 -2
- package/node_modules/@smithy/middleware-retry/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +154 -61
- package/node_modules/@smithy/util-endpoints/dist-es/bdd/BinaryDecisionDiagram.js +15 -0
- package/node_modules/@smithy/util-endpoints/dist-es/decideEndpoint.js +41 -0
- package/node_modules/@smithy/util-endpoints/dist-es/index.js +2 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/coalesce.js +8 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/index.js +3 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/ite.js +3 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/split.js +13 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/substring.js +1 -1
- package/node_modules/@smithy/util-endpoints/dist-es/utils/endpointFunctions.js +4 -1
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +20 -5
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateTemplate.js +3 -6
- package/node_modules/@smithy/util-endpoints/dist-es/utils/getReferenceValue.js +1 -5
- package/node_modules/@smithy/util-endpoints/dist-types/bdd/BinaryDecisionDiagram.d.ts +22 -0
- package/node_modules/@smithy/util-endpoints/dist-types/decideEndpoint.d.ts +7 -0
- package/node_modules/@smithy/util-endpoints/dist-types/index.d.ts +2 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/coalesce.d.ts +7 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/index.d.ts +3 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/ite.d.ts +6 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/split.d.ts +11 -0
- package/node_modules/@smithy/util-endpoints/dist-types/utils/endpointFunctions.d.ts +4 -0
- package/node_modules/@smithy/util-endpoints/dist-types/utils/getReferenceValue.d.ts +3 -1
- package/node_modules/@smithy/util-endpoints/package.json +1 -1
- package/node_modules/@smithy/util-retry/dist-cjs/index.js +6 -0
- package/node_modules/@smithy/util-retry/dist-es/AdaptiveRetryStrategy.js +3 -0
- package/node_modules/@smithy/util-retry/dist-es/StandardRetryStrategy.js +3 -0
- package/node_modules/@smithy/util-retry/dist-types/AdaptiveRetryStrategy.d.ts +5 -0
- package/node_modules/@smithy/util-retry/dist-types/StandardRetryStrategy.d.ts +5 -0
- package/node_modules/@smithy/util-retry/package.json +1 -1
- package/node_modules/path-expression-matcher/README.md +214 -62
- package/node_modules/path-expression-matcher/lib/pem.cjs +1 -1
- package/node_modules/path-expression-matcher/lib/pem.d.cts +111 -0
- package/node_modules/path-expression-matcher/lib/pem.min.js +1 -1
- package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -1
- package/node_modules/path-expression-matcher/package.json +1 -1
- package/node_modules/path-expression-matcher/src/Expression.js +2 -2
- package/node_modules/path-expression-matcher/src/ExpressionSet.js +209 -0
- package/node_modules/path-expression-matcher/src/Matcher.js +235 -177
- package/node_modules/path-expression-matcher/src/index.d.ts +199 -194
- package/node_modules/path-expression-matcher/src/index.js +3 -2
- package/package.json +10 -10
- package/node_modules/strnum/.github/SECURITY.md +0 -5
- package/node_modules/strnum/.vscode/launch.json +0 -25
- package/node_modules/strnum/algo.stflow +0 -84
- package/node_modules/strnum/tests/infinity_test.js +0 -18
- package/node_modules/strnum/tests/strnum_test.js +0 -175
- package/node_modules/strnum/tests/temp.js +0 -8
- /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/CHANGELOG.md +0 -0
- /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/LICENSE +0 -0
- /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/README.md +0 -0
- /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/strnum.js +0 -0
|
@@ -4,10 +4,11 @@ Efficient path tracking and pattern matching for XML, JSON, YAML or any other pa
|
|
|
4
4
|
|
|
5
5
|
## 🎯 Purpose
|
|
6
6
|
|
|
7
|
-
`path-expression-matcher` provides
|
|
7
|
+
`path-expression-matcher` provides three core classes for tracking and matching paths:
|
|
8
8
|
|
|
9
9
|
- **`Expression`**: Parses and stores pattern expressions (e.g., `"root.users.user[id]"`)
|
|
10
10
|
- **`Matcher`**: Tracks current path during parsing and matches against expressions
|
|
11
|
+
- **`MatcherView`**: A lightweight read-only view of a `Matcher`, safe to pass to callbacks
|
|
11
12
|
|
|
12
13
|
Compatible with [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and similar tools.
|
|
13
14
|
|
|
@@ -138,7 +139,7 @@ console.log(matcher.toString()); // "soap:Envelope.soap:Body.ns:UserId"
|
|
|
138
139
|
#### Constructor
|
|
139
140
|
|
|
140
141
|
```javascript
|
|
141
|
-
new Expression(pattern, options)
|
|
142
|
+
new Expression(pattern, options = {}, data)
|
|
142
143
|
```
|
|
143
144
|
|
|
144
145
|
**Parameters:**
|
|
@@ -149,6 +150,8 @@ new Expression(pattern, options)
|
|
|
149
150
|
```javascript
|
|
150
151
|
const expr1 = new Expression("root.users.user");
|
|
151
152
|
const expr2 = new Expression("root/users/user", { separator: '/' });
|
|
153
|
+
const expr3 = new Expression("root/users/user", { separator: '/' }, { extra: "data"});
|
|
154
|
+
console.log(expr3.data) // { extra: "data" }
|
|
152
155
|
```
|
|
153
156
|
|
|
154
157
|
#### Methods
|
|
@@ -240,6 +243,22 @@ if (matcher.matches(expr)) {
|
|
|
240
243
|
}
|
|
241
244
|
```
|
|
242
245
|
|
|
246
|
+
#### `matchesAny(exprSet)` → `boolean`
|
|
247
|
+
|
|
248
|
+
Please check `ExpressionSet` class for more details.
|
|
249
|
+
|
|
250
|
+
```javascript
|
|
251
|
+
const matcher = new Matcher();
|
|
252
|
+
const exprSet = new ExpressionSet();
|
|
253
|
+
exprSet.add(new Expression("root.users.user"));
|
|
254
|
+
exprSet.add(new Expression("root.config.*"));
|
|
255
|
+
exprSet.seal();
|
|
256
|
+
|
|
257
|
+
if (matcher.matchesAny(exprSet)) {
|
|
258
|
+
// Current path matches any expression in the set
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
243
262
|
##### `getCurrentTag()`
|
|
244
263
|
|
|
245
264
|
Get current tag name.
|
|
@@ -350,51 +369,51 @@ matcher.restore(snapshot);
|
|
|
350
369
|
|
|
351
370
|
##### `readOnly()`
|
|
352
371
|
|
|
353
|
-
Returns a
|
|
372
|
+
Returns a **`MatcherView`** — a lightweight, live read-only view of the matcher. All query and inspection methods work normally and always reflect the current state of the underlying matcher. Mutation methods (`push`, `pop`, `reset`, `updateCurrent`, `restore`) simply don't exist on `MatcherView`, so misuse is caught at **compile time** by TypeScript rather than at runtime.
|
|
354
373
|
|
|
355
|
-
This is the recommended way to share the matcher with
|
|
374
|
+
The **same instance** is returned on every call — no allocation occurs per invocation. This is the recommended way to share the matcher with callbacks, plugins, or any external code that only needs to inspect the current path.
|
|
356
375
|
|
|
357
376
|
```javascript
|
|
358
|
-
const
|
|
377
|
+
const view = matcher.readOnly();
|
|
378
|
+
// Same reference every time — safe to cache
|
|
379
|
+
view === matcher.readOnly(); // true
|
|
359
380
|
```
|
|
360
381
|
|
|
361
|
-
**What works on the
|
|
382
|
+
**What works on the view:**
|
|
362
383
|
|
|
363
384
|
```javascript
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
ro.snapshot() // ✓ snapshot (can be used to restore the real matcher)
|
|
385
|
+
view.matches(expr) // ✓ pattern matching
|
|
386
|
+
view.getCurrentTag() // ✓ current tag name
|
|
387
|
+
view.getCurrentNamespace() // ✓ current namespace
|
|
388
|
+
view.getAttrValue("id") // ✓ attribute value
|
|
389
|
+
view.hasAttr("id") // ✓ attribute presence check
|
|
390
|
+
view.getPosition() // ✓ sibling position
|
|
391
|
+
view.getCounter() // ✓ occurrence counter
|
|
392
|
+
view.getDepth() // ✓ path depth
|
|
393
|
+
view.toString() // ✓ path as string
|
|
394
|
+
view.toArray() // ✓ path as array
|
|
375
395
|
```
|
|
376
396
|
|
|
377
|
-
**What
|
|
397
|
+
**What doesn't exist (compile-time error in TypeScript):**
|
|
378
398
|
|
|
379
399
|
```javascript
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
ro.separator = '/' // ✗ TypeError: Cannot set property on a read-only Matcher
|
|
400
|
+
view.push("child", {}) // ✗ Property 'push' does not exist on type 'MatcherView'
|
|
401
|
+
view.pop() // ✗ Property 'pop' does not exist on type 'MatcherView'
|
|
402
|
+
view.reset() // ✗ Property 'reset' does not exist on type 'MatcherView'
|
|
403
|
+
view.updateCurrent({}) // ✗ Property 'updateCurrent' does not exist on type 'MatcherView'
|
|
404
|
+
view.restore(snapshot) // ✗ Property 'restore' does not exist on type 'MatcherView'
|
|
386
405
|
```
|
|
387
406
|
|
|
388
|
-
**
|
|
407
|
+
**The view is live** — it always reflects the current state of the underlying matcher.
|
|
389
408
|
|
|
390
409
|
```javascript
|
|
391
410
|
const matcher = new Matcher();
|
|
392
|
-
const
|
|
411
|
+
const view = matcher.readOnly();
|
|
393
412
|
|
|
394
413
|
matcher.push("root");
|
|
395
|
-
|
|
414
|
+
view.getDepth(); // 1 — immediately reflects the push
|
|
396
415
|
matcher.push("users");
|
|
397
|
-
|
|
416
|
+
view.getDepth(); // 2 — still live
|
|
398
417
|
```
|
|
399
418
|
|
|
400
419
|
## 💡 Usage Examples
|
|
@@ -532,9 +551,9 @@ const expr = new Expression("root.item:first");
|
|
|
532
551
|
console.log(matcher.matches(expr)); // false (counter=1, not 0)
|
|
533
552
|
```
|
|
534
553
|
|
|
535
|
-
### Example 8: Passing a Read-Only
|
|
554
|
+
### Example 8: Passing a Read-Only View to External Consumers
|
|
536
555
|
|
|
537
|
-
When passing the matcher into callbacks, plugins, or other code you don't control, use `readOnly()` to
|
|
556
|
+
When passing the matcher into callbacks, plugins, or other code you don't control, use `readOnly()` to get a `MatcherView` — it can inspect but never mutate parser state.
|
|
538
557
|
|
|
539
558
|
```javascript
|
|
540
559
|
import { Expression, Matcher } from 'path-expression-matcher';
|
|
@@ -546,40 +565,26 @@ const adminExpr = new Expression("..user[type=admin]");
|
|
|
546
565
|
function parseTag(tagName, attrs, onTag) {
|
|
547
566
|
matcher.push(tagName, attrs);
|
|
548
567
|
|
|
549
|
-
// Pass
|
|
568
|
+
// Pass MatcherView — consumer can inspect but not mutate
|
|
550
569
|
onTag(matcher.readOnly());
|
|
551
570
|
|
|
552
571
|
matcher.pop();
|
|
553
572
|
}
|
|
554
573
|
|
|
555
574
|
// Safe consumer — can only read
|
|
556
|
-
function myPlugin(
|
|
557
|
-
if (
|
|
558
|
-
console.log("Admin at path:",
|
|
559
|
-
console.log("Depth:",
|
|
560
|
-
console.log("ID:",
|
|
575
|
+
function myPlugin(view) {
|
|
576
|
+
if (view.matches(adminExpr)) {
|
|
577
|
+
console.log("Admin at path:", view.toString());
|
|
578
|
+
console.log("Depth:", view.getDepth());
|
|
579
|
+
console.log("ID:", view.getAttrValue("id"));
|
|
561
580
|
}
|
|
562
581
|
}
|
|
563
582
|
|
|
564
|
-
//
|
|
565
|
-
//
|
|
583
|
+
// view.push(...) or view.reset() don't exist on MatcherView —
|
|
584
|
+
// TypeScript catches misuse at compile time.
|
|
566
585
|
parseTag("user", { id: "1", type: "admin" }, myPlugin);
|
|
567
586
|
```
|
|
568
587
|
|
|
569
|
-
**Combining with `snapshot()`:** A snapshot taken via the read-only view can still be used to restore the real matcher.
|
|
570
|
-
|
|
571
|
-
```javascript
|
|
572
|
-
const matcher = new Matcher();
|
|
573
|
-
matcher.push("root");
|
|
574
|
-
matcher.push("users");
|
|
575
|
-
|
|
576
|
-
const ro = matcher.readOnly();
|
|
577
|
-
const snap = ro.snapshot(); // ✓ snapshot works on read-only view
|
|
578
|
-
|
|
579
|
-
matcher.push("user"); // continue parsing...
|
|
580
|
-
matcher.restore(snap); // restore to "root.users" using the snapshot
|
|
581
|
-
```
|
|
582
|
-
|
|
583
588
|
```javascript
|
|
584
589
|
const matcher = new Matcher();
|
|
585
590
|
const soapExpr = new Expression("soap::Envelope.soap::Body..ns::UserId");
|
|
@@ -674,21 +679,168 @@ for (let i = 0; i < 1000; i++) {
|
|
|
674
679
|
}
|
|
675
680
|
```
|
|
676
681
|
|
|
677
|
-
### Batch Pattern Checking
|
|
682
|
+
### Batch Pattern Checking with ExpressionSet (Recommended)
|
|
683
|
+
|
|
684
|
+
For checking multiple patterns on every tag, use `ExpressionSet` instead of a manual loop.
|
|
685
|
+
It pre-indexes expressions at build time so each call to `matchesAny()` does an O(1) bucket
|
|
686
|
+
lookup rather than a full O(N) scan:
|
|
678
687
|
|
|
679
688
|
```javascript
|
|
680
|
-
|
|
681
|
-
const patterns = [
|
|
682
|
-
new Expression("..user"),
|
|
683
|
-
new Expression("..post"),
|
|
684
|
-
new Expression("..comment"),
|
|
685
|
-
];
|
|
689
|
+
import { Expression, ExpressionSet, Matcher } from 'path-expression-matcher';
|
|
686
690
|
|
|
687
|
-
|
|
688
|
-
|
|
691
|
+
// Build once at config/startup time
|
|
692
|
+
const stopNodes = new ExpressionSet();
|
|
693
|
+
stopNodes
|
|
694
|
+
.add(new Expression('root.users.user'))
|
|
695
|
+
.add(new Expression('root.config.*'))
|
|
696
|
+
.add(new Expression('..script'))
|
|
697
|
+
.seal(); // prevent accidental mutation during parsing
|
|
698
|
+
|
|
699
|
+
// Per-tag — hot path
|
|
700
|
+
if (stopNodes.matchesAny(matcher)) {
|
|
701
|
+
// handle stop node
|
|
702
|
+
}
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
This replaces the manual loop pattern:
|
|
706
|
+
|
|
707
|
+
```javascript
|
|
708
|
+
// ❌ Before — O(N) per tag
|
|
709
|
+
function isStopNode(expressions, matcher) {
|
|
710
|
+
for (let i = 0; i < expressions.length; i++) {
|
|
711
|
+
if (matcher.matches(expressions[i])) return true;
|
|
712
|
+
}
|
|
713
|
+
return false;
|
|
689
714
|
}
|
|
715
|
+
|
|
716
|
+
// ✅ After — O(1) lookup per tag
|
|
717
|
+
const stopNodes = new ExpressionSet();
|
|
718
|
+
stopNodes.addAll(expressions);
|
|
719
|
+
stopNodes.matchesAny(matcher);
|
|
720
|
+
//or matcher.matchesAny(stopNodes)
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
---
|
|
724
|
+
|
|
725
|
+
## 📦 ExpressionSet API
|
|
726
|
+
|
|
727
|
+
`ExpressionSet` is an indexed collection of `Expression` objects designed for efficient
|
|
728
|
+
bulk matching. Build it once from your config, then call `matchesAny()` on every tag.
|
|
729
|
+
|
|
730
|
+
### Constructor
|
|
731
|
+
|
|
732
|
+
```javascript
|
|
733
|
+
const set = new ExpressionSet();
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
### `add(expression)` → `this`
|
|
737
|
+
|
|
738
|
+
Add a single `Expression`. Duplicate patterns (same pattern string) are silently ignored.
|
|
739
|
+
Returns `this` for chaining. Throws `TypeError` if the set is sealed.
|
|
740
|
+
|
|
741
|
+
```javascript
|
|
742
|
+
set.add(new Expression('root.users.user'));
|
|
743
|
+
set.add(new Expression('..script'));
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
### `addAll(expressions)` → `this`
|
|
747
|
+
|
|
748
|
+
Add an array of `Expression` objects at once. Returns `this` for chaining.
|
|
749
|
+
|
|
750
|
+
```javascript
|
|
751
|
+
set.addAll(config.stopNodes.map(p => new Expression(p)));
|
|
690
752
|
```
|
|
691
753
|
|
|
754
|
+
### `has(expression)` → `boolean`
|
|
755
|
+
|
|
756
|
+
Check whether an expression with the same pattern is already present.
|
|
757
|
+
|
|
758
|
+
```javascript
|
|
759
|
+
set.has(new Expression('root.users.user')); // true / false
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### `seal()` → `this`
|
|
763
|
+
|
|
764
|
+
Prevent further additions. Any subsequent call to `add()` or `addAll()` throws a `TypeError`.
|
|
765
|
+
Useful to guard against accidental mutation once parsing has started.
|
|
766
|
+
|
|
767
|
+
```javascript
|
|
768
|
+
const stopNodes = new ExpressionSet();
|
|
769
|
+
stopNodes.addAll(patterns).seal();
|
|
770
|
+
|
|
771
|
+
stopNodes.add(new Expression('root.extra')); // ❌ TypeError: ExpressionSet is sealed
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
### `size` → `number`
|
|
775
|
+
|
|
776
|
+
Number of distinct expressions in the set.
|
|
777
|
+
|
|
778
|
+
```javascript
|
|
779
|
+
set.size; // 3
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
### `isSealed` → `boolean`
|
|
783
|
+
|
|
784
|
+
Whether `seal()` has been called.
|
|
785
|
+
|
|
786
|
+
### `matchesAny(matcher)` → `boolean`
|
|
787
|
+
|
|
788
|
+
Returns `true` if the matcher's current path matches **any** expression in the set.
|
|
789
|
+
Accepts both a `Matcher` instance and a `MatcherView`.
|
|
790
|
+
|
|
791
|
+
```javascript
|
|
792
|
+
if (stopNodes.matchesAny(matcher)) { /* ... */ }
|
|
793
|
+
if (stopNodes.matchesAny(matcher.readOnly())) { /* ... */ } // also works
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
**How indexing works:** expressions are bucketed at `add()` time, not at match time.
|
|
797
|
+
|
|
798
|
+
| Expression type | Bucket | Lookup cost |
|
|
799
|
+
|---|---|---|
|
|
800
|
+
| Fixed path, concrete tag (`root.users.user`) | `depth:tag` map | O(1) |
|
|
801
|
+
| Fixed path, wildcard tag (`root.config.*`) | `depth` map | O(1) |
|
|
802
|
+
| Deep wildcard (`..script`) | flat list | O(D) — always scanned |
|
|
803
|
+
|
|
804
|
+
In practice, deep-wildcard expressions are rare in configs, so the list stays small.
|
|
805
|
+
|
|
806
|
+
### `findMatch(matcher)` → `Expression`
|
|
807
|
+
|
|
808
|
+
Returns the Expression instance that matched the current path. Accepts both a `Matcher` instance and a `MatcherView`.
|
|
809
|
+
|
|
810
|
+
```javascript
|
|
811
|
+
const node = stopNodes.findMatch(matcher);
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
### Example 7: ExpressionSet in a real parser loop
|
|
816
|
+
|
|
817
|
+
```javascript
|
|
818
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
819
|
+
import { Expression, ExpressionSet, Matcher } from 'path-expression-matcher';
|
|
820
|
+
|
|
821
|
+
// Config-time setup
|
|
822
|
+
const stopNodes = new ExpressionSet();
|
|
823
|
+
stopNodes
|
|
824
|
+
.addAll(['script', 'style'].map(t => new Expression(`..${t}`)))
|
|
825
|
+
.seal();
|
|
826
|
+
|
|
827
|
+
const matcher = new Matcher();
|
|
828
|
+
|
|
829
|
+
const parser = new XMLParser({
|
|
830
|
+
onOpenTag(tagName, attrs) {
|
|
831
|
+
matcher.push(tagName, attrs);
|
|
832
|
+
if (stopNodes.matchesAny(matcher)) {
|
|
833
|
+
// treat as stop node
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
onCloseTag() {
|
|
837
|
+
matcher.pop();
|
|
838
|
+
},
|
|
839
|
+
});
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
|
|
843
|
+
|
|
692
844
|
## 🔗 Integration with fast-xml-parser
|
|
693
845
|
|
|
694
846
|
**Basic integration:**
|
|
@@ -717,4 +869,4 @@ MIT
|
|
|
717
869
|
|
|
718
870
|
## 🤝 Contributing
|
|
719
871
|
|
|
720
|
-
Issues and PRs welcome! This package is designed to be used by XML/JSON parsers like fast-xml-parser.
|
|
872
|
+
Issues and PRs welcome! This package is designed to be used by XML/JSON parsers like fast-xml-parser. But can be used with any formar parser.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,
|
|
1
|
+
(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,ExpressionSet:()=>n,Matcher:()=>h,default:()=>r});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const h=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(h&&(i=h[1]+h[3],h[2])){const t=h[2].slice(1,-1);t&&(s=t)}let n,r,a=i;if(i.includes("::")){const e=i.indexOf("::");if(n=i.substring(0,e).trim(),a=i.substring(e+2).trim(),!n)throw new Error(`Invalid namespace in pattern: ${t}`)}let p=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),s=a.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(r=e,p=s):r=a}else r=a;if(!r)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=r,n&&(e.namespace=n),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(p){const t=p.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=p}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const s=e[e.length-1];return void 0!==s.values&&t in s.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class h{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new i(this)}push(t,e=null,s=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const h=this.siblingStacks[i],n=s?`${s}:${t}`:t,r=h.get(n)||0;let a=0;for(const t of h.values())a+=t;h.set(n,r+1);const p={tag:t,position:a,counter:r};null!=s&&(p.namespace=s),null!=e&&(p.values=e),this.path.push(p)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let h=!1;for(let t=e;t>=0;t--)if(this._matchSegment(i,this.path[t],t===this.path.length-1)){e=t-1,s--,h=!0;break}if(!h)return!1}else{if(!this._matchSegment(i,this.path[e],e===this.path.length-1))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}class n{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,s=t.segments[t.segments.length-1],i=s?.tag;if(i&&"*"!==i){const s=`${e}:${i}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),s=`${e}:${t.getCurrentTag()}`,i=this._byDepthAndTag.get(s);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];const h=this._wildcardByDepth.get(e);if(h)for(let e=0;e<h.length;e++)if(t.matches(h[e]))return h[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const r={Expression:s,Matcher:h,ExpressionSet:n};module.exports=e})();
|
|
@@ -299,6 +299,13 @@ declare interface ReadOnlyMatcher {
|
|
|
299
299
|
*/
|
|
300
300
|
matches(expression: Expression): boolean;
|
|
301
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Test whether the matcher's current path matches **any** expression in the set.
|
|
304
|
+
*
|
|
305
|
+
* @param exprSet - A `ExpressionSet` instance
|
|
306
|
+
* @returns `true` if at least one expression matches the current path
|
|
307
|
+
*/
|
|
308
|
+
matchesAny(exprSet: ExpressionSet): boolean;
|
|
302
309
|
/**
|
|
303
310
|
* Create a snapshot of current state
|
|
304
311
|
* @returns State snapshot that can be restored later
|
|
@@ -490,6 +497,31 @@ declare class Matcher {
|
|
|
490
497
|
*/
|
|
491
498
|
matches(expression: Expression): boolean;
|
|
492
499
|
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Test whether the matcher's current path matches **any** expression in the set.
|
|
503
|
+
*
|
|
504
|
+
* Uses the pre-built index to evaluate only the relevant bucket(s):
|
|
505
|
+
* 1. Exact depth + tag — O(1) lookup
|
|
506
|
+
* 2. Depth-matched wildcard tag — O(1) lookup
|
|
507
|
+
* 3. Deep-wildcard expressions — always scanned (typically a small list)
|
|
508
|
+
*
|
|
509
|
+
* @param exprSet - A `ExpressionSet` instance
|
|
510
|
+
* @returns `true` if at least one expression matches the current path
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* // Replaces:
|
|
515
|
+
* // for (const expr of stopNodeExpressions) {
|
|
516
|
+
* // if (matcher.matches(expr)) return true;
|
|
517
|
+
* // }
|
|
518
|
+
*
|
|
519
|
+
* if (matcher.matchesAny(stopNodes)) {
|
|
520
|
+
* // current tag is a stop node
|
|
521
|
+
* }
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
matchesAny(exprSet: ExpressionSet): boolean;
|
|
493
525
|
/**
|
|
494
526
|
* Create a snapshot of current state
|
|
495
527
|
* @returns State snapshot that can be restored later
|
|
@@ -508,10 +540,89 @@ declare class Matcher {
|
|
|
508
540
|
readOnly(): ReadOnlyMatcher;
|
|
509
541
|
}
|
|
510
542
|
|
|
543
|
+
/**
|
|
544
|
+
* ExpressionSet - An indexed collection of Expressions for efficient bulk matching
|
|
545
|
+
*
|
|
546
|
+
* Pre-indexes expressions at insertion time by depth and terminal tag name so
|
|
547
|
+
* that `matchesAny()` performs an O(1) bucket lookup rather than a full O(E)
|
|
548
|
+
* linear scan on every tag.
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```javascript
|
|
552
|
+
* const { Expression, ExpressionSet, Matcher } = require('path-expression-matcher');
|
|
553
|
+
*
|
|
554
|
+
* // Build once at config time
|
|
555
|
+
* const stopNodes = new ExpressionSet();
|
|
556
|
+
* stopNodes
|
|
557
|
+
* .add(new Expression('root.users.user'))
|
|
558
|
+
* .add(new Expression('root.config.*'))
|
|
559
|
+
* .add(new Expression('..script'))
|
|
560
|
+
* .seal();
|
|
561
|
+
*
|
|
562
|
+
* // Per-tag — hot path
|
|
563
|
+
* if (stopNodes.matchesAny(matcher)) { ... }
|
|
564
|
+
* ```
|
|
565
|
+
*/
|
|
566
|
+
declare class ExpressionSet {
|
|
567
|
+
constructor();
|
|
568
|
+
|
|
569
|
+
/** Number of expressions currently in the set. */
|
|
570
|
+
readonly size: number;
|
|
571
|
+
|
|
572
|
+
/** Whether the set has been sealed against further modifications. */
|
|
573
|
+
readonly isSealed: boolean;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Add a single Expression. Duplicate patterns are silently ignored.
|
|
577
|
+
* @throws {TypeError} if the set has been sealed
|
|
578
|
+
*/
|
|
579
|
+
add(expression: Expression): this;
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Add multiple expressions at once.
|
|
583
|
+
* @throws {TypeError} if the set has been sealed
|
|
584
|
+
*/
|
|
585
|
+
addAll(expressions: Expression[]): this;
|
|
586
|
+
|
|
587
|
+
/** Check whether an expression with the same pattern is already present. */
|
|
588
|
+
has(expression: Expression): boolean;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Seal the set against further modifications.
|
|
592
|
+
* Any subsequent call to add() or addAll() will throw a TypeError.
|
|
593
|
+
*/
|
|
594
|
+
seal(): this;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Test whether the matcher's current path matches any expression in the set.
|
|
598
|
+
* Accepts both a Matcher instance and a ReadOnlyMatcher view.
|
|
599
|
+
*
|
|
600
|
+
*
|
|
601
|
+
* @param matcher - A `Matcher` instance or a `ReadOnlyMatcher` view
|
|
602
|
+
* @returns Expression if at least one expression matches the current path
|
|
603
|
+
*/
|
|
604
|
+
matchesAny(matcher: Matcher | ReadOnlyMatcher): boolean;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Find the first expression in the set that matches the matcher's current path.
|
|
608
|
+
|
|
609
|
+
*
|
|
610
|
+
* @param matcher - A `Matcher` instance or a `ReadOnlyMatcher` view
|
|
611
|
+
* @returns Expression if at least one expression matches the current path
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```typescript
|
|
615
|
+
* const node = stopNodes.findMatch(matcher);
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
findMatch(matcher: Matcher | ReadOnlyMatcher): Expression;
|
|
619
|
+
}
|
|
620
|
+
|
|
511
621
|
declare namespace pathExpressionMatcher {
|
|
512
622
|
export {
|
|
513
623
|
Expression,
|
|
514
624
|
Matcher,
|
|
625
|
+
ExpressionSet,
|
|
515
626
|
ExpressionOptions,
|
|
516
627
|
MatcherOptions,
|
|
517
628
|
Segment,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pem=e():t.pem=e()}(this,()=>(()=>{"use strict";var t={d:(e,s)=>{for(var
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.pem=e():t.pem=e()}(this,()=>(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Expression:()=>s,ExpressionSet:()=>r,Matcher:()=>n,default:()=>h});class s{constructor(t,e={},s){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=s,this._hasDeepWildcard=this.segments.some(t=>"deep-wildcard"===t.type),this._hasAttributeCondition=this.segments.some(t=>void 0!==t.attrName),this._hasPositionSelector=this.segments.some(t=>void 0!==t.position)}_parse(t){const e=[];let s=0,i="";for(;s<t.length;)t[s]===this.separator?s+1<t.length&&t[s+1]===this.separator?(i.trim()&&(e.push(this._parseSegment(i.trim())),i=""),e.push({type:"deep-wildcard"}),s+=2):(i.trim()&&e.push(this._parseSegment(i.trim())),i="",s++):(i+=t[s],s++);return i.trim()&&e.push(this._parseSegment(i.trim())),e}_parseSegment(t){const e={type:"tag"};let s=null,i=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(i=n[1]+n[3],n[2])){const t=n[2].slice(1,-1);t&&(s=t)}let r,h,a=i;if(i.includes("::")){const e=i.indexOf("::");if(r=i.substring(0,e).trim(),a=i.substring(e+2).trim(),!r)throw new Error(`Invalid namespace in pattern: ${t}`)}let p=null;if(a.includes(":")){const t=a.lastIndexOf(":"),e=a.substring(0,t).trim(),s=a.substring(t+1).trim();["first","last","odd","even"].includes(s)||/^nth\(\d+\)$/.test(s)?(h=e,p=s):h=a}else h=a;if(!h)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=h,r&&(e.namespace=r),s)if(s.includes("=")){const t=s.indexOf("=");e.attrName=s.substring(0,t).trim(),e.attrValue=s.substring(t+1).trim()}else e.attrName=s.trim();if(p){const t=p.match(/^nth\((\d+)\)$/);t?(e.position="nth",e.positionValue=parseInt(t[1],10)):e.position=p}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class i{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){const e=this._matcher.path;if(0!==e.length)return e[e.length-1].values?.[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const s=e[e.length-1];return void 0!==s.values&&t in s.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class n{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new i(this)}push(t,e=null,s=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const i=this.path.length;this.siblingStacks[i]||(this.siblingStacks[i]=new Map);const n=this.siblingStacks[i],r=s?`${s}:${t}`:t,h=n.get(r)||0;let a=0;for(const t of n.values())a+=t;n.set(r,h+1);const p={tag:t,position:a,counter:h};null!=s&&(p.namespace=s),null!=e&&(p.values=e),this.path.push(p)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){if(this.path.length>0){const e=this.path[this.path.length-1];null!=t&&(e.values=t)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){if(0!==this.path.length)return this.path[this.path.length-1].values?.[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const s=t||this.separator;if(s===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const t=this.path.map(t=>t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s);return this._pathStringCache=t,t}return this.path.map(t=>e&&t.namespace?`${t.namespace}:${t.tag}`:t.tag).join(s)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,s=t.length-1;for(;s>=0&&e>=0;){const i=t[s];if("deep-wildcard"===i.type){if(s--,s<0)return!0;const i=t[s];let n=!1;for(let t=e;t>=0;t--)if(this._matchSegment(i,this.path[t],t===this.path.length-1)){e=t-1,s--,n=!0;break}if(!n)return!1}else{if(!this._matchSegment(i,this.path[e],e===this.path.length-1))return!1;e--,s--}}return s<0}_matchSegment(t,e,s){if("*"!==t.tag&&t.tag!==e.tag)return!1;if(void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace)return!1;if(void 0!==t.attrName){if(!s)return!1;if(!e.values||!(t.attrName in e.values))return!1;if(void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue))return!1}if(void 0!==t.position){if(!s)return!1;const i=e.counter??0;if("first"===t.position&&0!==i)return!1;if("odd"===t.position&&i%2!=1)return!1;if("even"===t.position&&i%2!=0)return!1;if("nth"===t.position&&i!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(t=>({...t})),this.siblingStacks=t.siblingStacks.map(t=>new Map(t))}readOnly(){return this._view}}class r{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,s=t.segments[t.segments.length-1],i=s?.tag;if(i&&"*"!==i){const s=`${e}:${i}`;this._byDepthAndTag.has(s)||this._byDepthAndTag.set(s,[]),this._byDepthAndTag.get(s).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),s=`${e}:${t.getCurrentTag()}`,i=this._byDepthAndTag.get(s);if(i)for(let e=0;e<i.length;e++)if(t.matches(i[e]))return i[e];const n=this._wildcardByDepth.get(e);if(n)for(let e=0;e<n.length;e++)if(t.matches(n[e]))return n[e];for(let e=0;e<this._deepWildcards.length;e++)if(t.matches(this._deepWildcards[e]))return this._deepWildcards[e];return null}}const h={Expression:s,Matcher:n,ExpressionSet:r};return e})());
|
|
2
2
|
//# sourceMappingURL=pem.min.js.map
|