@cdklabs/cdk-ecs-codedeploy 0.0.432 → 0.0.434

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.
Files changed (274) hide show
  1. package/.jsii +3 -3
  2. package/.jsii.tabl.json +1 -1
  3. package/lib/api-canary/index.js +1 -1
  4. package/lib/ecs-appspec/index.js +1 -1
  5. package/lib/ecs-deployment/index.js +1 -1
  6. package/lib/ecs-patterns/application-load-balanced-codedeployed-fargate-service.js +1 -1
  7. package/node_modules/@aws/lambda-invoke-store/dist-cjs/invoke-store.js +2 -2
  8. package/node_modules/@aws/lambda-invoke-store/dist-es/invoke-store.js +2 -2
  9. package/node_modules/@aws/lambda-invoke-store/dist-types/invoke-store.d.ts +1 -1
  10. package/node_modules/@aws/lambda-invoke-store/package.json +1 -1
  11. package/node_modules/@aws-sdk/client-codedeploy/README.md +26 -46
  12. package/node_modules/@aws-sdk/client-codedeploy/package.json +34 -34
  13. package/node_modules/@aws-sdk/core/dist-cjs/index.js +4 -0
  14. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +4 -0
  15. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/index.js +2 -0
  16. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsEc2QueryProtocol.js +3 -0
  17. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/index.d.ts +2 -0
  18. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +4 -0
  19. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/QuerySerializerSettings.d.ts +3 -0
  20. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/index.d.ts +2 -0
  21. package/node_modules/@aws-sdk/core/dist-types/ts3.4/submodules/protocols/query/AwsEc2QueryProtocol.d.ts +1 -0
  22. package/node_modules/@aws-sdk/core/package.json +11 -11
  23. package/node_modules/@aws-sdk/credential-provider-env/package.json +5 -5
  24. package/node_modules/@aws-sdk/credential-provider-http/package.json +10 -10
  25. package/node_modules/@aws-sdk/credential-provider-ini/package.json +14 -14
  26. package/node_modules/@aws-sdk/credential-provider-login/package.json +8 -8
  27. package/node_modules/@aws-sdk/credential-provider-node/package.json +12 -12
  28. package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
  29. package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
  30. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
  31. package/node_modules/@aws-sdk/middleware-host-header/package.json +4 -4
  32. package/node_modules/@aws-sdk/middleware-logger/package.json +3 -3
  33. package/node_modules/@aws-sdk/middleware-recursion-detection/package.json +4 -4
  34. package/node_modules/@aws-sdk/middleware-user-agent/package.json +8 -8
  35. package/node_modules/@aws-sdk/nested-clients/package.json +32 -32
  36. package/node_modules/@aws-sdk/region-config-resolver/package.json +5 -5
  37. package/node_modules/@aws-sdk/token-providers/package.json +7 -7
  38. package/node_modules/@aws-sdk/types/package.json +2 -2
  39. package/node_modules/@aws-sdk/util-endpoints/package.json +5 -5
  40. package/node_modules/@aws-sdk/util-user-agent-browser/package.json +3 -3
  41. package/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js +75 -19
  42. package/node_modules/@aws-sdk/util-user-agent-node/dist-es/getNodeModulesParentDirs.js +15 -0
  43. package/node_modules/@aws-sdk/util-user-agent-node/dist-es/getSanitizedDevTypeScriptVersion.js +14 -0
  44. package/node_modules/@aws-sdk/util-user-agent-node/dist-es/getTypeScriptUserAgentPair.js +53 -7
  45. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/{getTypeScriptPackageJsonPaths.d.ts → getNodeModulesParentDirs.d.ts} +2 -2
  46. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/getSanitizedDevTypeScriptVersion.d.ts +8 -0
  47. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/ts3.4/getNodeModulesParentDirs.d.ts +1 -0
  48. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/ts3.4/getSanitizedDevTypeScriptVersion.d.ts +3 -0
  49. package/node_modules/@aws-sdk/util-user-agent-node/package.json +6 -5
  50. package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +21 -11
  51. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +5 -1
  52. package/node_modules/@aws-sdk/xml-builder/dist-es/escape-attribute.js +8 -1
  53. package/node_modules/@aws-sdk/xml-builder/dist-es/escape-element.js +13 -10
  54. package/node_modules/@aws-sdk/xml-builder/dist-es/xml-parser.js +5 -1
  55. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/CHANGELOG.md +40 -4
  56. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/README.md +8 -7
  57. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js +2 -0
  58. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +1 -0
  59. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.cjs +1 -0
  60. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/lib/fxp.d.cts +82 -20
  61. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js +2 -0
  62. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxp.min.js.map +1 -0
  63. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js +2 -0
  64. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxparser.min.js.map +1 -0
  65. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +1 -0
  66. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/lib/pem.d.cts +148 -0
  67. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/package.json +4 -3
  68. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/fxp.d.ts +75 -19
  69. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/pem.d.ts +135 -0
  70. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/util.js +18 -0
  71. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/xmlparser/DocTypeReader.js +37 -18
  72. package/node_modules/@aws-sdk/xml-builder/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +159 -0
  73. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/xmlparser/OrderedObjParser.js +298 -116
  74. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/xmlparser/XMLParser.js +2 -2
  75. package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/xmlparser/node2json.js +65 -15
  76. package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/CHANGELOG.md +9 -2
  77. package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/package.json +1 -1
  78. package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/strnum.js +12 -6
  79. package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/tests/strnum_test.js +3 -0
  80. package/node_modules/@aws-sdk/xml-builder/node_modules/strnum/tests/temp.js +8 -0
  81. package/node_modules/@aws-sdk/xml-builder/package.json +3 -3
  82. package/node_modules/@smithy/abort-controller/package.json +2 -2
  83. package/node_modules/@smithy/config-resolver/dist-cjs/index.js +12 -0
  84. package/node_modules/@smithy/config-resolver/dist-es/endpointsConfig/NodeUseDualstackEndpointConfigOptions.js +5 -0
  85. package/node_modules/@smithy/config-resolver/dist-es/endpointsConfig/NodeUseFipsEndpointConfigOptions.js +5 -0
  86. package/node_modules/@smithy/config-resolver/dist-types/endpointsConfig/NodeUseDualstackEndpointConfigOptions.d.ts +6 -0
  87. package/node_modules/@smithy/config-resolver/dist-types/endpointsConfig/NodeUseFipsEndpointConfigOptions.d.ts +6 -0
  88. package/node_modules/@smithy/config-resolver/dist-types/ts3.4/endpointsConfig/NodeUseDualstackEndpointConfigOptions.d.ts +6 -0
  89. package/node_modules/@smithy/config-resolver/dist-types/ts3.4/endpointsConfig/NodeUseFipsEndpointConfigOptions.d.ts +6 -0
  90. package/node_modules/@smithy/config-resolver/package.json +5 -5
  91. package/node_modules/@smithy/core/dist-cjs/index.js +1 -2
  92. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +7 -1
  93. package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +22 -0
  94. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +11 -1
  95. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +41 -4
  96. package/node_modules/@smithy/core/dist-es/middleware-http-auth-scheme/getHttpAuthSchemePlugin.js +1 -2
  97. package/node_modules/@smithy/core/dist-es/submodules/cbor/parseCborBody.js +7 -1
  98. package/node_modules/@smithy/core/dist-es/submodules/endpoints/index.js +1 -0
  99. package/node_modules/@smithy/core/dist-es/submodules/endpoints/toEndpointV1.js +17 -0
  100. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +10 -0
  101. package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +1 -1
  102. package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +3 -2
  103. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +30 -1
  104. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js +5 -1
  105. package/node_modules/@smithy/core/dist-types/submodules/endpoints/index.d.ts +1 -0
  106. package/node_modules/@smithy/core/dist-types/submodules/endpoints/toEndpointV1.d.ts +6 -0
  107. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +11 -0
  108. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/translateTraits.d.ts +6 -0
  109. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/index.d.ts +1 -0
  110. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/endpoints/toEndpointV1.d.ts +6 -0
  111. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +11 -0
  112. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +6 -0
  113. package/node_modules/@smithy/core/endpoints.d.ts +7 -0
  114. package/node_modules/@smithy/core/endpoints.js +6 -0
  115. package/node_modules/@smithy/core/package.json +16 -7
  116. package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
  117. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +4 -1
  118. package/node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js +4 -1
  119. package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
  120. package/node_modules/@smithy/hash-node/package.json +2 -2
  121. package/node_modules/@smithy/invalid-dependency/package.json +2 -2
  122. package/node_modules/@smithy/middleware-content-length/package.json +3 -3
  123. package/node_modules/@smithy/middleware-endpoint/dist-cjs/index.js +17 -1
  124. package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/getEndpointFromInstructions.js +9 -0
  125. package/node_modules/@smithy/middleware-endpoint/dist-es/adaptors/toEndpointV1.js +8 -1
  126. package/node_modules/@smithy/middleware-endpoint/dist-types/adaptors/toEndpointV1.d.ts +1 -0
  127. package/node_modules/@smithy/middleware-endpoint/dist-types/resolveEndpointConfig.d.ts +2 -2
  128. package/node_modules/@smithy/middleware-endpoint/dist-types/ts3.4/adaptors/toEndpointV1.d.ts +1 -0
  129. package/node_modules/@smithy/middleware-endpoint/dist-types/ts3.4/resolveEndpointConfig.d.ts +2 -2
  130. package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
  131. package/node_modules/@smithy/middleware-retry/dist-cjs/index.js +9 -12
  132. package/node_modules/@smithy/middleware-retry/dist-es/configurations.js +9 -12
  133. package/node_modules/@smithy/middleware-retry/package.json +8 -8
  134. package/node_modules/@smithy/middleware-serde/dist-cjs/index.js +3 -2
  135. package/node_modules/@smithy/middleware-serde/dist-es/serializerMiddleware.js +3 -2
  136. package/node_modules/@smithy/middleware-serde/package.json +4 -3
  137. package/node_modules/@smithy/middleware-stack/package.json +2 -2
  138. package/node_modules/@smithy/node-config-provider/package.json +4 -4
  139. package/node_modules/@smithy/node-http-handler/dist-cjs/index.js +48 -38
  140. package/node_modules/@smithy/node-http-handler/dist-es/build-abort-error.js +4 -1
  141. package/node_modules/@smithy/node-http-handler/dist-es/node-http-handler.js +38 -31
  142. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-connection-manager.js +1 -1
  143. package/node_modules/@smithy/node-http-handler/dist-es/node-http2-handler.js +1 -1
  144. package/node_modules/@smithy/node-http-handler/dist-es/readable.mock.js +1 -1
  145. package/node_modules/@smithy/node-http-handler/dist-es/server.mock.js +6 -6
  146. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/collector.js +1 -1
  147. package/node_modules/@smithy/node-http-handler/dist-es/stream-collector/readable.mock.js +1 -1
  148. package/node_modules/@smithy/node-http-handler/dist-es/write-request-body.js +1 -1
  149. package/node_modules/@smithy/node-http-handler/dist-types/build-abort-error.d.ts +4 -3
  150. package/node_modules/@smithy/node-http-handler/dist-types/get-transformed-headers.d.ts +1 -1
  151. package/node_modules/@smithy/node-http-handler/dist-types/node-http-handler.d.ts +4 -4
  152. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-manager.d.ts +1 -1
  153. package/node_modules/@smithy/node-http-handler/dist-types/node-http2-connection-pool.d.ts +1 -1
  154. package/node_modules/@smithy/node-http-handler/dist-types/readable.mock.d.ts +2 -2
  155. package/node_modules/@smithy/node-http-handler/dist-types/server.mock.d.ts +3 -3
  156. package/node_modules/@smithy/node-http-handler/dist-types/set-connection-timeout.d.ts +1 -1
  157. package/node_modules/@smithy/node-http-handler/dist-types/set-request-timeout.d.ts +1 -1
  158. package/node_modules/@smithy/node-http-handler/dist-types/set-socket-keep-alive.d.ts +1 -1
  159. package/node_modules/@smithy/node-http-handler/dist-types/set-socket-timeout.d.ts +1 -1
  160. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/collector.d.ts +1 -1
  161. package/node_modules/@smithy/node-http-handler/dist-types/stream-collector/readable.mock.d.ts +2 -2
  162. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/build-abort-error.d.ts +4 -3
  163. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/get-transformed-headers.d.ts +1 -1
  164. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http-handler.d.ts +4 -4
  165. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-connection-manager.d.ts +1 -1
  166. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/node-http2-connection-pool.d.ts +1 -1
  167. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/readable.mock.d.ts +2 -2
  168. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/server.mock.d.ts +3 -3
  169. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-connection-timeout.d.ts +1 -1
  170. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-request-timeout.d.ts +1 -1
  171. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-keep-alive.d.ts +1 -1
  172. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/set-socket-timeout.d.ts +1 -1
  173. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/collector.d.ts +1 -1
  174. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/stream-collector/readable.mock.d.ts +2 -2
  175. package/node_modules/@smithy/node-http-handler/dist-types/ts3.4/write-request-body.d.ts +2 -2
  176. package/node_modules/@smithy/node-http-handler/dist-types/write-request-body.d.ts +2 -2
  177. package/node_modules/@smithy/node-http-handler/package.json +5 -5
  178. package/node_modules/@smithy/property-provider/package.json +2 -2
  179. package/node_modules/@smithy/protocol-http/package.json +2 -2
  180. package/node_modules/@smithy/querystring-builder/package.json +2 -2
  181. package/node_modules/@smithy/querystring-parser/package.json +2 -2
  182. package/node_modules/@smithy/service-error-classification/package.json +2 -2
  183. package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
  184. package/node_modules/@smithy/signature-v4/package.json +4 -4
  185. package/node_modules/@smithy/smithy-client/package.json +7 -7
  186. package/node_modules/@smithy/types/dist-types/http.d.ts +1 -0
  187. package/node_modules/@smithy/types/dist-types/ts3.4/http.d.ts +1 -0
  188. package/node_modules/@smithy/types/package.json +1 -1
  189. package/node_modules/@smithy/url-parser/package.json +3 -3
  190. package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
  191. package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
  192. package/node_modules/@smithy/util-endpoints/package.json +3 -3
  193. package/node_modules/@smithy/util-middleware/package.json +2 -2
  194. package/node_modules/@smithy/util-retry/package.json +3 -3
  195. package/node_modules/@smithy/util-stream/package.json +4 -4
  196. package/node_modules/@smithy/util-waiter/dist-cjs/index.js +1 -1
  197. package/node_modules/@smithy/util-waiter/dist-es/poller.js +1 -1
  198. package/node_modules/@smithy/util-waiter/package.json +3 -3
  199. package/node_modules/fast-xml-builder/CHANGELOG.md +16 -0
  200. package/node_modules/fast-xml-builder/README.md +1 -1
  201. package/node_modules/fast-xml-builder/lib/fxb.cjs +1 -0
  202. package/node_modules/fast-xml-builder/lib/fxb.d.cts +22 -9
  203. package/node_modules/fast-xml-builder/lib/fxb.min.js +2 -0
  204. package/node_modules/fast-xml-builder/lib/fxb.min.js.map +1 -0
  205. package/node_modules/fast-xml-builder/package.json +7 -5
  206. package/node_modules/fast-xml-builder/src/fxb.d.ts +27 -3
  207. package/node_modules/fast-xml-builder/src/fxb.js +265 -21
  208. package/node_modules/fast-xml-builder/src/orderedJs2Xml.js +165 -18
  209. package/node_modules/path-expression-matcher/LICENSE +21 -0
  210. package/node_modules/path-expression-matcher/README.md +720 -0
  211. package/node_modules/path-expression-matcher/lib/pem.cjs +1 -0
  212. package/node_modules/path-expression-matcher/lib/pem.d.cts +523 -0
  213. package/node_modules/path-expression-matcher/lib/pem.min.js +2 -0
  214. package/node_modules/path-expression-matcher/lib/pem.min.js.map +1 -0
  215. package/node_modules/path-expression-matcher/package.json +78 -0
  216. package/node_modules/path-expression-matcher/src/Expression.js +232 -0
  217. package/node_modules/path-expression-matcher/src/Matcher.js +498 -0
  218. package/node_modules/path-expression-matcher/src/index.d.ts +518 -0
  219. package/node_modules/path-expression-matcher/src/index.js +28 -0
  220. package/package.json +4 -4
  221. package/node_modules/@aws-sdk/util-user-agent-node/dist-es/getTypeScriptPackageJsonPaths.js +0 -17
  222. package/node_modules/@aws-sdk/util-user-agent-node/dist-types/ts3.4/getTypeScriptPackageJsonPaths.d.ts +0 -3
  223. package/node_modules/fast-xml-builder/lib/builder.cjs +0 -1
  224. package/node_modules/fast-xml-builder/lib/builder.min.js +0 -2
  225. package/node_modules/fast-xml-builder/lib/builder.min.js.map +0 -1
  226. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js +0 -2
  227. package/node_modules/fast-xml-parser/lib/fxbuilder.min.js.map +0 -1
  228. package/node_modules/fast-xml-parser/lib/fxp.cjs +0 -1
  229. package/node_modules/fast-xml-parser/lib/fxp.min.js +0 -2
  230. package/node_modules/fast-xml-parser/lib/fxp.min.js.map +0 -1
  231. package/node_modules/fast-xml-parser/lib/fxparser.min.js +0 -2
  232. package/node_modules/fast-xml-parser/lib/fxparser.min.js.map +0 -1
  233. package/node_modules/fast-xml-parser/lib/fxvalidator.min.js.map +0 -1
  234. package/node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js +0 -88
  235. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/LICENSE +0 -0
  236. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/lib/fxvalidator.min.js +0 -0
  237. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/cli/cli.js +0 -0
  238. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/cli/man.js +0 -0
  239. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/cli/read.js +0 -0
  240. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/fxp.js +0 -0
  241. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/ignoreAttributes.js +0 -0
  242. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/CharsSymbol.js +0 -0
  243. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/EntitiesParser.js +0 -0
  244. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/OptionsBuilder.js +0 -0
  245. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/OutputBuilders/BaseOutputBuilder.js +0 -0
  246. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/OutputBuilders/JsArrBuilder.js +0 -0
  247. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/OutputBuilders/JsMinArrBuilder.js +0 -0
  248. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/OutputBuilders/JsObjBuilder.js +0 -0
  249. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/OutputBuilders/ParserOptionsBuilder.js +0 -0
  250. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/Report.js +0 -0
  251. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/TagPath.js +0 -0
  252. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/TagPathMatcher.js +0 -0
  253. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/XMLParser.js +0 -0
  254. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/Xml2JsParser.js +0 -0
  255. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/XmlPartReader.js +0 -0
  256. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/XmlSpecialTagsReader.js +0 -0
  257. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/inputSource/BufferSource.js +0 -0
  258. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/inputSource/StringSource.js +0 -0
  259. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/EntitiesParser.js +0 -0
  260. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/booleanParser.js +0 -0
  261. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/booleanParserExt.js +0 -0
  262. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/currency.js +0 -0
  263. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/join.js +0 -0
  264. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/number.js +0 -0
  265. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/v6/valueParsers/trim.js +0 -0
  266. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/validator.js +0 -0
  267. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/xmlbuilder/json2xml.js +0 -0
  268. /package/node_modules/{fast-xml-parser → @aws-sdk/xml-builder/node_modules/fast-xml-parser}/src/xmlparser/xmlNode.js +0 -0
  269. /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/.github/SECURITY.md +0 -0
  270. /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/.vscode/launch.json +0 -0
  271. /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/LICENSE +0 -0
  272. /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/README.md +0 -0
  273. /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/algo.stflow +0 -0
  274. /package/node_modules/{strnum → @aws-sdk/xml-builder/node_modules/strnum}/tests/infinity_test.js +0 -0
@@ -0,0 +1,720 @@
1
+ # path-expression-matcher
2
+
3
+ Efficient path tracking and pattern matching for XML, JSON, YAML or any other parsers.
4
+
5
+ ## 🎯 Purpose
6
+
7
+ `path-expression-matcher` provides two core classes for tracking and matching paths:
8
+
9
+ - **`Expression`**: Parses and stores pattern expressions (e.g., `"root.users.user[id]"`)
10
+ - **`Matcher`**: Tracks current path during parsing and matches against expressions
11
+
12
+ Compatible with [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) and similar tools.
13
+
14
+ ## 📦 Installation
15
+
16
+ ```bash
17
+ npm install path-expression-matcher
18
+ ```
19
+
20
+ ## 🚀 Quick Start
21
+
22
+ ```javascript
23
+ import { Expression, Matcher } from 'path-expression-matcher';
24
+
25
+ // Create expression (parse once, reuse many times)
26
+ const expr = new Expression("root.users.user");
27
+
28
+ // Create matcher (tracks current path)
29
+ const matcher = new Matcher();
30
+
31
+ matcher.push("root");
32
+ matcher.push("users");
33
+ matcher.push("user", { id: "123" });
34
+
35
+ // Match current path against expression
36
+ if (matcher.matches(expr)) {
37
+ console.log("Match found!");
38
+ console.log("Current path:", matcher.toString()); // "root.users.user"
39
+ }
40
+
41
+ // Namespace support
42
+ const nsExpr = new Expression("soap::Envelope.soap::Body..ns::UserId");
43
+ matcher.push("Envelope", null, "soap");
44
+ matcher.push("Body", null, "soap");
45
+ matcher.push("UserId", null, "ns");
46
+ console.log(matcher.toString()); // "soap:Envelope.soap:Body.ns:UserId"
47
+ ```
48
+
49
+ ## 📖 Pattern Syntax
50
+
51
+ ### Basic Paths
52
+
53
+ ```javascript
54
+ "root.users.user" // Exact path match
55
+ "*.users.user" // Wildcard: any parent
56
+ "root.*.user" // Wildcard: any middle
57
+ "root.users.*" // Wildcard: any child
58
+ ```
59
+
60
+ ### Deep Wildcard
61
+
62
+ ```javascript
63
+ "..user" // user anywhere in tree
64
+ "root..user" // user anywhere under root
65
+ "..users..user" // users somewhere, then user below it
66
+ ```
67
+
68
+ ### Attribute Matching
69
+
70
+ ```javascript
71
+ "user[id]" // user with "id" attribute
72
+ "user[type=admin]" // user with type="admin" (current node only)
73
+ "root[lang]..user" // user under root that has "lang" attribute
74
+ ```
75
+
76
+ ### Position Selectors
77
+
78
+ ```javascript
79
+ "user:first" // First user (counter=0)
80
+ "user:nth(2)" // Third user (counter=2, zero-based)
81
+ "user:odd" // Odd-numbered users (counter=1,3,5...)
82
+ "user:even" // Even-numbered users (counter=0,2,4...)
83
+ "root.users.user:first" // First user under users
84
+ ```
85
+
86
+ **Note:** Position selectors use the **counter** (occurrence count of the tag name), not the position (child index). For example, in `<root><a/><b/><a/></root>`, the second `<a/>` has position=2 but counter=1.
87
+
88
+ ### Namespaces
89
+
90
+ ```javascript
91
+ "ns::user" // user with namespace "ns"
92
+ "soap::Envelope" // Envelope with namespace "soap"
93
+ "ns::user[id]" // user with namespace "ns" and "id" attribute
94
+ "ns::user:first" // First user with namespace "ns"
95
+ "*::user" // user with any namespace
96
+ "..ns::item" // item with namespace "ns" anywhere in tree
97
+ "soap::Envelope.soap::Body" // Nested namespaced elements
98
+ "ns::first" // Tag named "first" with namespace "ns" (NO ambiguity!)
99
+ ```
100
+
101
+ **Namespace syntax:**
102
+ - Use **double colon (::)** for namespace: `ns::tag`
103
+ - Use **single colon (:)** for position: `tag:first`
104
+ - Combined: `ns::tag:first` (namespace + tag + position)
105
+
106
+ **Namespace matching rules:**
107
+ - Pattern `ns::user` matches only nodes with namespace "ns" and tag "user"
108
+ - Pattern `user` (no namespace) matches nodes with tag "user" regardless of namespace
109
+ - Pattern `*::user` matches tag "user" with any namespace (wildcard namespace)
110
+ - Namespaces are tracked separately for counter/position (e.g., `ns1::item` and `ns2::item` have independent counters)
111
+
112
+ ### Wildcard Differences
113
+
114
+ **Single wildcard (`*`)** - Matches exactly ONE level:
115
+ - `"*.fix1"` matches `root.fix1` (2 levels) ✅
116
+ - `"*.fix1"` does NOT match `root.another.fix1` (3 levels) ❌
117
+ - Path depth MUST equal pattern depth
118
+
119
+ **Deep wildcard (`..`)** - Matches ZERO or MORE levels:
120
+ - `"..fix1"` matches `root.fix1` ✅
121
+ - `"..fix1"` matches `root.another.fix1` ✅
122
+ - `"..fix1"` matches `a.b.c.d.fix1` ✅
123
+ - Works at any depth
124
+
125
+ ### Combined Patterns
126
+
127
+ ```javascript
128
+ "..user[id]:first" // First user with id, anywhere
129
+ "root..user[type=admin]" // Admin user under root
130
+ "ns::user[id]:first" // First namespaced user with id
131
+ "soap::Envelope..ns::UserId" // UserId with namespace ns under SOAP envelope
132
+ ```
133
+
134
+ ## 🔧 API Reference
135
+
136
+ ### Expression
137
+
138
+ #### Constructor
139
+
140
+ ```javascript
141
+ new Expression(pattern, options)
142
+ ```
143
+
144
+ **Parameters:**
145
+ - `pattern` (string): Pattern to parse
146
+ - `options.separator` (string): Path separator (default: `'.'`)
147
+
148
+ **Example:**
149
+ ```javascript
150
+ const expr1 = new Expression("root.users.user");
151
+ const expr2 = new Expression("root/users/user", { separator: '/' });
152
+ ```
153
+
154
+ #### Methods
155
+
156
+ - `hasDeepWildcard()` → boolean
157
+ - `hasAttributeCondition()` → boolean
158
+ - `hasPositionSelector()` → boolean
159
+ - `toString()` → string
160
+
161
+ ### Matcher
162
+
163
+ #### Constructor
164
+
165
+ ```javascript
166
+ new Matcher(options)
167
+ ```
168
+
169
+ **Parameters:**
170
+ - `options.separator` (string): Default path separator (default: `'.'`)
171
+
172
+ #### Path Tracking Methods
173
+
174
+ ##### `push(tagName, attrValues, namespace)`
175
+
176
+ Add a tag to the current path. Position and counter are automatically calculated.
177
+
178
+ **Parameters:**
179
+ - `tagName` (string): Tag name
180
+ - `attrValues` (object, optional): Attribute key-value pairs (current node only)
181
+ - `namespace` (string, optional): Namespace for the tag
182
+
183
+ **Example:**
184
+ ```javascript
185
+ matcher.push("user", { id: "123", type: "admin" });
186
+ matcher.push("item"); // No attributes
187
+ matcher.push("Envelope", null, "soap"); // With namespace
188
+ matcher.push("Body", { version: "1.1" }, "soap"); // With both
189
+ ```
190
+
191
+ **Position vs Counter:**
192
+ - **Position**: The child index in the parent (0, 1, 2, 3...)
193
+ - **Counter**: How many times this tag name appeared at this level (0, 1, 2...)
194
+
195
+ Example:
196
+ ```xml
197
+ <root>
198
+ <a/> <!-- position=0, counter=0 -->
199
+ <b/> <!-- position=1, counter=0 -->
200
+ <a/> <!-- position=2, counter=1 -->
201
+ </root>
202
+ ```
203
+
204
+ ##### `pop()`
205
+
206
+ Remove the last tag from the path.
207
+
208
+ ```javascript
209
+ matcher.pop();
210
+ ```
211
+
212
+ ##### `updateCurrent(attrValues)`
213
+
214
+ Update current node's attributes (useful when attributes are parsed after push).
215
+
216
+ ```javascript
217
+ matcher.push("user"); // Don't know values yet
218
+ // ... parse attributes ...
219
+ matcher.updateCurrent({ id: "123" });
220
+ ```
221
+
222
+ ##### `reset()`
223
+
224
+ Clear the entire path.
225
+
226
+ ```javascript
227
+ matcher.reset();
228
+ ```
229
+
230
+ #### Query Methods
231
+
232
+ ##### `matches(expression)`
233
+
234
+ Check if current path matches an Expression.
235
+
236
+ ```javascript
237
+ const expr = new Expression("root.users.user");
238
+ if (matcher.matches(expr)) {
239
+ // Current path matches
240
+ }
241
+ ```
242
+
243
+ ##### `getCurrentTag()`
244
+
245
+ Get current tag name.
246
+
247
+ ```javascript
248
+ const tag = matcher.getCurrentTag(); // "user"
249
+ ```
250
+
251
+ ##### `getCurrentNamespace()`
252
+
253
+ Get current namespace.
254
+
255
+ ```javascript
256
+ const ns = matcher.getCurrentNamespace(); // "soap" or undefined
257
+ ```
258
+
259
+ ##### `getAttrValue(attrName)`
260
+
261
+ Get attribute value of current node.
262
+
263
+ ```javascript
264
+ const id = matcher.getAttrValue("id"); // "123"
265
+ ```
266
+
267
+ ##### `hasAttr(attrName)`
268
+
269
+ Check if current node has an attribute.
270
+
271
+ ```javascript
272
+ if (matcher.hasAttr("id")) {
273
+ // Current node has "id" attribute
274
+ }
275
+ ```
276
+
277
+ ##### `getPosition()`
278
+
279
+ Get sibling position of current node (child index in parent).
280
+
281
+ ```javascript
282
+ const position = matcher.getPosition(); // 0, 1, 2, ...
283
+ ```
284
+
285
+ ##### `getCounter()`
286
+
287
+ Get repeat counter of current node (occurrence count of this tag name).
288
+
289
+ ```javascript
290
+ const counter = matcher.getCounter(); // 0, 1, 2, ...
291
+ ```
292
+
293
+ ##### `getIndex()` (deprecated)
294
+
295
+ Alias for `getPosition()`. Use `getPosition()` or `getCounter()` instead for clarity.
296
+
297
+ ```javascript
298
+ const index = matcher.getIndex(); // Same as getPosition()
299
+ ```
300
+
301
+ ##### `getDepth()`
302
+
303
+ Get current path depth.
304
+
305
+ ```javascript
306
+ const depth = matcher.getDepth(); // 3 for "root.users.user"
307
+ ```
308
+
309
+ ##### `toString(separator?, includeNamespace?)`
310
+
311
+ Get path as string.
312
+
313
+ **Parameters:**
314
+ - `separator` (string, optional): Path separator (uses default if not provided)
315
+ - `includeNamespace` (boolean, optional): Whether to include namespaces (default: true)
316
+
317
+ ```javascript
318
+ const path = matcher.toString(); // "root.ns:user.item"
319
+ const path2 = matcher.toString('/'); // "root/ns:user/item"
320
+ const path3 = matcher.toString('.', false); // "root.user.item" (no namespaces)
321
+ ```
322
+
323
+ ##### `toArray()`
324
+
325
+ Get path as array.
326
+
327
+ ```javascript
328
+ const arr = matcher.toArray(); // ["root", "users", "user"]
329
+ ```
330
+
331
+ #### State Management
332
+
333
+ ##### `snapshot()`
334
+
335
+ Create a snapshot of current state.
336
+
337
+ ```javascript
338
+ const snapshot = matcher.snapshot();
339
+ ```
340
+
341
+ ##### `restore(snapshot)`
342
+
343
+ Restore from a snapshot.
344
+
345
+ ```javascript
346
+ matcher.restore(snapshot);
347
+ ```
348
+
349
+ #### Read-Only Access
350
+
351
+ ##### `readOnly()`
352
+
353
+ Returns a **live, read-only proxy** of the matcher. All query and inspection methods work normally, but any attempt to call a state-mutating method (`push`, `pop`, `reset`, `updateCurrent`, `restore`) or to write/delete a property throws a `TypeError`.
354
+
355
+ This is the recommended way to share the matcher with external consumers — plugins, callbacks, event handlers — that only need to inspect the current path without being able to corrupt parser state.
356
+
357
+ ```javascript
358
+ const ro = matcher.readOnly();
359
+ ```
360
+
361
+ **What works on the read-only view:**
362
+
363
+ ```javascript
364
+ ro.matches(expr) // ✓ pattern matching
365
+ ro.getCurrentTag() // ✓ current tag name
366
+ ro.getCurrentNamespace() // ✓ current namespace
367
+ ro.getAttrValue("id") // ✓ attribute value
368
+ ro.hasAttr("id") // ✓ attribute presence check
369
+ ro.getPosition() // ✓ sibling position
370
+ ro.getCounter() // ✓ occurrence counter
371
+ ro.getDepth() // ✓ path depth
372
+ ro.toString() // ✓ path as string
373
+ ro.toArray() // ✓ path as array
374
+ ro.snapshot() // ✓ snapshot (can be used to restore the real matcher)
375
+ ```
376
+
377
+ **What throws a `TypeError`:**
378
+
379
+ ```javascript
380
+ ro.push("child", {}) // ✗ TypeError: Cannot call 'push' on a read-only Matcher
381
+ ro.pop() // ✗ TypeError: Cannot call 'pop' on a read-only Matcher
382
+ ro.reset() // ✗ TypeError: Cannot call 'reset' on a read-only Matcher
383
+ ro.updateCurrent({}) // ✗ TypeError: Cannot call 'updateCurrent' on a read-only Matcher
384
+ ro.restore(snapshot) // ✗ TypeError: Cannot call 'restore' on a read-only Matcher
385
+ ro.separator = '/' // ✗ TypeError: Cannot set property on a read-only Matcher
386
+ ```
387
+
388
+ **Important:** The read-only view is **live** — it always reflects the current state of the underlying matcher. If you need a frozen-in-time copy instead, use `snapshot()`.
389
+
390
+ ```javascript
391
+ const matcher = new Matcher();
392
+ const ro = matcher.readOnly();
393
+
394
+ matcher.push("root");
395
+ ro.getDepth(); // 1 — immediately reflects the push
396
+ matcher.push("users");
397
+ ro.getDepth(); // 2 — still live
398
+ ```
399
+
400
+ ## 💡 Usage Examples
401
+
402
+ ### Example 1: XML Parser with stopNodes
403
+
404
+ ```javascript
405
+ import { XMLParser } from 'fast-xml-parser';
406
+ import { Expression, Matcher } from 'path-expression-matcher';
407
+
408
+ class MyParser {
409
+ constructor() {
410
+ this.matcher = new Matcher();
411
+
412
+ // Pre-compile stop node patterns
413
+ this.stopNodeExpressions = [
414
+ new Expression("html.body.script"),
415
+ new Expression("html.body.style"),
416
+ new Expression("..svg"),
417
+ ];
418
+ }
419
+
420
+ parseTag(tagName, attrs) {
421
+ this.matcher.push(tagName, attrs);
422
+
423
+ // Check if this is a stop node
424
+ for (const expr of this.stopNodeExpressions) {
425
+ if (this.matcher.matches(expr)) {
426
+ // Don't parse children, read as raw text
427
+ return this.readRawContent();
428
+ }
429
+ }
430
+
431
+ // Continue normal parsing
432
+ this.parseChildren();
433
+
434
+ this.matcher.pop();
435
+ }
436
+ }
437
+ ```
438
+
439
+ ### Example 2: Conditional Processing
440
+
441
+ ```javascript
442
+ const matcher = new Matcher();
443
+ const userExpr = new Expression("..user[type=admin]");
444
+ const firstItemExpr = new Expression("..item:first");
445
+
446
+ function processTag(tagName, value, attrs) {
447
+ matcher.push(tagName, attrs);
448
+
449
+ if (matcher.matches(userExpr)) {
450
+ value = enhanceAdminUser(value);
451
+ }
452
+
453
+ if (matcher.matches(firstItemExpr)) {
454
+ value = markAsFirst(value);
455
+ }
456
+
457
+ matcher.pop();
458
+ return value;
459
+ }
460
+ ```
461
+
462
+ ### Example 3: Path-based Filtering
463
+
464
+ ```javascript
465
+ const patterns = [
466
+ new Expression("data.users.user"),
467
+ new Expression("data.posts.post"),
468
+ new Expression("..comment[approved=true]"),
469
+ ];
470
+
471
+ function shouldInclude(matcher) {
472
+ return patterns.some(expr => matcher.matches(expr));
473
+ }
474
+ ```
475
+
476
+ ### Example 4: Custom Separator
477
+
478
+ ```javascript
479
+ const matcher = new Matcher({ separator: '/' });
480
+ const expr = new Expression("root/config/database", { separator: '/' });
481
+
482
+ matcher.push("root");
483
+ matcher.push("config");
484
+ matcher.push("database");
485
+
486
+ console.log(matcher.toString()); // "root/config/database"
487
+ console.log(matcher.matches(expr)); // true
488
+ ```
489
+
490
+ ### Example 5: Attribute Checking
491
+
492
+ ```javascript
493
+ const matcher = new Matcher();
494
+ matcher.push("root");
495
+ matcher.push("user", { id: "123", type: "admin", status: "active" });
496
+
497
+ // Check attribute existence (current node only)
498
+ console.log(matcher.hasAttr("id")); // true
499
+ console.log(matcher.hasAttr("email")); // false
500
+
501
+ // Get attribute value (current node only)
502
+ console.log(matcher.getAttrValue("type")); // "admin"
503
+
504
+ // Match by attribute
505
+ const expr1 = new Expression("user[id]");
506
+ console.log(matcher.matches(expr1)); // true
507
+
508
+ const expr2 = new Expression("user[type=admin]");
509
+ console.log(matcher.matches(expr2)); // true
510
+ ```
511
+
512
+ ### Example 6: Position vs Counter
513
+
514
+ ```javascript
515
+ const matcher = new Matcher();
516
+ matcher.push("root");
517
+
518
+ // Mixed tags at same level
519
+ matcher.push("item"); // position=0, counter=0 (first item)
520
+ matcher.pop();
521
+
522
+ matcher.push("div"); // position=1, counter=0 (first div)
523
+ matcher.pop();
524
+
525
+ matcher.push("item"); // position=2, counter=1 (second item)
526
+
527
+ console.log(matcher.getPosition()); // 2 (third child overall)
528
+ console.log(matcher.getCounter()); // 1 (second "item" specifically)
529
+
530
+ // :first uses counter, not position
531
+ const expr = new Expression("root.item:first");
532
+ console.log(matcher.matches(expr)); // false (counter=1, not 0)
533
+ ```
534
+
535
+ ### Example 8: Passing a Read-Only Matcher to External Consumers
536
+
537
+ When passing the matcher into callbacks, plugins, or other code you don't control, use `readOnly()` to prevent accidental state corruption.
538
+
539
+ ```javascript
540
+ import { Expression, Matcher } from 'path-expression-matcher';
541
+
542
+ const matcher = new Matcher();
543
+
544
+ const adminExpr = new Expression("..user[type=admin]");
545
+
546
+ function parseTag(tagName, attrs, onTag) {
547
+ matcher.push(tagName, attrs);
548
+
549
+ // Pass a read-only view — consumer can inspect but not mutate
550
+ onTag(matcher.readOnly());
551
+
552
+ matcher.pop();
553
+ }
554
+
555
+ // Safe consumer — can only read
556
+ function myPlugin(ro) {
557
+ if (ro.matches(adminExpr)) {
558
+ console.log("Admin at path:", ro.toString());
559
+ console.log("Depth:", ro.getDepth());
560
+ console.log("ID:", ro.getAttrValue("id"));
561
+ }
562
+ }
563
+
564
+ // ro.push(...) or ro.reset() here would throw TypeError,
565
+ // so the parser's state is always safe.
566
+ parseTag("user", { id: "1", type: "admin" }, myPlugin);
567
+ ```
568
+
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
+ ```javascript
584
+ const matcher = new Matcher();
585
+ const soapExpr = new Expression("soap::Envelope.soap::Body..ns::UserId");
586
+
587
+ // Parse SOAP document
588
+ matcher.push("Envelope", { xmlns: "..." }, "soap");
589
+ matcher.push("Body", null, "soap");
590
+ matcher.push("GetUserRequest", null, "ns");
591
+ matcher.push("UserId", null, "ns");
592
+
593
+ // Match namespaced pattern
594
+ if (matcher.matches(soapExpr)) {
595
+ console.log("Found UserId in SOAP body");
596
+ console.log(matcher.toString()); // "soap:Envelope.soap:Body.ns:GetUserRequest.ns:UserId"
597
+ }
598
+
599
+ // Namespace-specific counters
600
+ matcher.reset();
601
+ matcher.push("root");
602
+ matcher.push("item", null, "ns1"); // ns1::item counter=0
603
+ matcher.pop();
604
+ matcher.push("item", null, "ns2"); // ns2::item counter=0 (different namespace)
605
+ matcher.pop();
606
+ matcher.push("item", null, "ns1"); // ns1::item counter=1
607
+
608
+ const firstNs1Item = new Expression("root.ns1::item:first");
609
+ console.log(matcher.matches(firstNs1Item)); // false (counter=1)
610
+
611
+ const secondNs1Item = new Expression("root.ns1::item:nth(1)");
612
+ console.log(matcher.matches(secondNs1Item)); // true
613
+
614
+ // NO AMBIGUITY: Tags named after position keywords
615
+ matcher.reset();
616
+ matcher.push("root");
617
+ matcher.push("first", null, "ns"); // Tag named "first" with namespace
618
+
619
+ const expr = new Expression("root.ns::first");
620
+ console.log(matcher.matches(expr)); // true - matches namespace "ns", tag "first"
621
+ ```
622
+
623
+ ## 🏗️ Architecture
624
+
625
+ ### Data Storage Strategy
626
+
627
+ **Ancestor nodes:** Store only tag name, position, and counter (minimal memory)
628
+ **Current node:** Store tag name, position, counter, and attribute values
629
+
630
+ This design minimizes memory usage:
631
+ - No attribute names stored (derived from values object when needed)
632
+ - Attribute values only for current node, not ancestors
633
+ - Attribute checking for ancestors is not supported (acceptable trade-off)
634
+ - For 1M nodes with 3 attributes each, saves ~50MB vs storing attribute names
635
+
636
+ ### Matching Strategy
637
+
638
+ Matching is performed **bottom-to-top** (from current node toward root):
639
+ 1. Start at current node
640
+ 2. Match segments from pattern end to start
641
+ 3. Attribute checking only works for current node (ancestors have no attribute data)
642
+ 4. Position selectors use **counter** (occurrence count), not position (child index)
643
+
644
+ ### Performance
645
+
646
+ - **Expression parsing:** One-time cost when Expression is created
647
+ - **Expression analysis:** Cached (hasDeepWildcard, hasAttributeCondition, hasPositionSelector)
648
+ - **Path tracking:** O(1) for push/pop operations
649
+ - **Pattern matching:** O(n*m) where n = path depth, m = pattern segments
650
+ - **Memory per ancestor node:** ~40-60 bytes (tag, position, counter only)
651
+ - **Memory per current node:** ~80-120 bytes (adds attribute values)
652
+
653
+ ## 🎓 Design Patterns
654
+
655
+ ### Pre-compile Patterns (Recommended)
656
+
657
+ ```javascript
658
+ // ✅ GOOD: Parse once, reuse many times
659
+ const expr = new Expression("..user[id]");
660
+
661
+ for (let i = 0; i < 1000; i++) {
662
+ if (matcher.matches(expr)) {
663
+ // ...
664
+ }
665
+ }
666
+ ```
667
+
668
+ ```javascript
669
+ // ❌ BAD: Parse on every iteration
670
+ for (let i = 0; i < 1000; i++) {
671
+ if (matcher.matches(new Expression("..user[id]"))) {
672
+ // ...
673
+ }
674
+ }
675
+ ```
676
+
677
+ ### Batch Pattern Checking
678
+
679
+ ```javascript
680
+ // For multiple patterns, check all at once
681
+ const patterns = [
682
+ new Expression("..user"),
683
+ new Expression("..post"),
684
+ new Expression("..comment"),
685
+ ];
686
+
687
+ function matchesAny(matcher, patterns) {
688
+ return patterns.some(expr => matcher.matches(expr));
689
+ }
690
+ ```
691
+
692
+ ## 🔗 Integration with fast-xml-parser
693
+
694
+ **Basic integration:**
695
+
696
+ ```javascript
697
+ import { XMLParser } from 'fast-xml-parser';
698
+ import { Expression, Matcher } from 'path-expression-matcher';
699
+
700
+ const parser = new XMLParser({
701
+ // Custom options using path-expression-matcher
702
+ stopNodes: ["script", "style"].map(tag => new Expression(`..${tag}`)),
703
+
704
+ tagValueProcessor: (tagName, value, jPath, hasAttrs, isLeaf, matcher) => {
705
+ // matcher is available in callbacks
706
+ if (matcher.matches(new Expression("..user[type=admin]"))) {
707
+ return enhanceValue(value);
708
+ }
709
+ return value;
710
+ }
711
+ });
712
+ ```
713
+
714
+ ## 📄 License
715
+
716
+ MIT
717
+
718
+ ## 🤝 Contributing
719
+
720
+ Issues and PRs welcome! This package is designed to be used by XML/JSON parsers like fast-xml-parser.