n8n-workflow 2.31.2 → 2.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/augment-object.js +136 -146
- package/dist/cjs/augment-object.js.map +1 -1
- package/dist/cjs/build.tsbuildinfo +1 -1
- package/dist/cjs/common/find-ai-root-node-names.js +36 -46
- package/dist/cjs/common/find-ai-root-node-names.js.map +1 -1
- package/dist/cjs/common/get-child-nodes.js +8 -18
- package/dist/cjs/common/get-child-nodes.js.map +1 -1
- package/dist/cjs/common/get-connected-nodes.js +84 -94
- package/dist/cjs/common/get-connected-nodes.js.map +1 -1
- package/dist/cjs/common/get-node-by-name.js +16 -26
- package/dist/cjs/common/get-node-by-name.js.map +1 -1
- package/dist/cjs/common/get-parent-nodes.js +14 -24
- package/dist/cjs/common/get-parent-nodes.js.map +1 -1
- package/dist/cjs/common/index.js +9 -19
- package/dist/cjs/common/index.js.map +1 -1
- package/dist/cjs/common/map-connections-by-destination.js +31 -41
- package/dist/cjs/common/map-connections-by-destination.js.map +1 -1
- package/dist/cjs/common/resolve-variables.d.ts +8 -0
- package/dist/cjs/common/resolve-variables.d.ts.map +1 -1
- package/dist/cjs/common/resolve-variables.js +46 -33
- package/dist/cjs/common/resolve-variables.js.map +1 -1
- package/dist/cjs/connections-diff.js +58 -68
- package/dist/cjs/connections-diff.js.map +1 -1
- package/dist/cjs/constants.d.ts +3 -3
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +157 -166
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/credential-domain-restrictions.js +153 -163
- package/dist/cjs/credential-domain-restrictions.js.map +1 -1
- package/dist/cjs/cron.d.ts.map +1 -1
- package/dist/cjs/cron.js +25 -35
- package/dist/cjs/cron.js.map +1 -1
- package/dist/cjs/data-table.types.js +10 -20
- package/dist/cjs/data-table.types.js.map +1 -1
- package/dist/cjs/dynamic-credentials-helpers.js +93 -103
- package/dist/cjs/dynamic-credentials-helpers.js.map +1 -1
- package/dist/cjs/errors/abstract/execution-base.error.d.ts.map +1 -1
- package/dist/cjs/errors/abstract/execution-base.error.js +41 -51
- package/dist/cjs/errors/abstract/execution-base.error.js.map +1 -1
- package/dist/cjs/errors/abstract/node.error.d.ts.map +1 -1
- package/dist/cjs/errors/abstract/node.error.js +142 -152
- package/dist/cjs/errors/abstract/node.error.js.map +1 -1
- package/dist/cjs/errors/base/base.error.d.ts.map +1 -1
- package/dist/cjs/errors/base/base.error.js +35 -45
- package/dist/cjs/errors/base/base.error.js.map +1 -1
- package/dist/cjs/errors/base/operational.error.d.ts.map +1 -1
- package/dist/cjs/errors/base/operational.error.js +17 -27
- package/dist/cjs/errors/base/operational.error.js.map +1 -1
- package/dist/cjs/errors/base/unexpected.error.d.ts.map +1 -1
- package/dist/cjs/errors/base/unexpected.error.js +17 -27
- package/dist/cjs/errors/base/unexpected.error.js.map +1 -1
- package/dist/cjs/errors/base/user.error.d.ts.map +1 -1
- package/dist/cjs/errors/base/user.error.js +17 -27
- package/dist/cjs/errors/base/user.error.js.map +1 -1
- package/dist/cjs/errors/cli-subworkflow-operation.error.js +7 -17
- package/dist/cjs/errors/cli-subworkflow-operation.error.js.map +1 -1
- package/dist/cjs/errors/db-connection-timeout-error.d.ts.map +1 -1
- package/dist/cjs/errors/db-connection-timeout-error.js +11 -21
- package/dist/cjs/errors/db-connection-timeout-error.js.map +1 -1
- package/dist/cjs/errors/execution-cancelled.error.d.ts.map +1 -1
- package/dist/cjs/errors/execution-cancelled.error.js +33 -43
- package/dist/cjs/errors/execution-cancelled.error.js.map +1 -1
- package/dist/cjs/errors/expression-class-extension.error.d.ts.map +1 -1
- package/dist/cjs/errors/expression-class-extension.error.js +9 -19
- package/dist/cjs/errors/expression-class-extension.error.js.map +1 -1
- package/dist/cjs/errors/expression-computed-destructuring.error.d.ts.map +1 -1
- package/dist/cjs/errors/expression-computed-destructuring.error.js +9 -19
- package/dist/cjs/errors/expression-computed-destructuring.error.js.map +1 -1
- package/dist/cjs/errors/expression-destructuring.error.d.ts.map +1 -1
- package/dist/cjs/errors/expression-destructuring.error.js +9 -19
- package/dist/cjs/errors/expression-destructuring.error.js.map +1 -1
- package/dist/cjs/errors/expression-extension.error.js +7 -17
- package/dist/cjs/errors/expression-extension.error.js.map +1 -1
- package/dist/cjs/errors/expression-reserved-variable.error.d.ts.map +1 -1
- package/dist/cjs/errors/expression-reserved-variable.error.js +9 -19
- package/dist/cjs/errors/expression-reserved-variable.error.js.map +1 -1
- package/dist/cjs/errors/expression-with-statement.error.d.ts.map +1 -1
- package/dist/cjs/errors/expression-with-statement.error.js +9 -19
- package/dist/cjs/errors/expression-with-statement.error.js.map +1 -1
- package/dist/cjs/errors/expression.error.d.ts.map +1 -1
- package/dist/cjs/errors/expression.error.js +33 -43
- package/dist/cjs/errors/expression.error.js.map +1 -1
- package/dist/cjs/errors/index.js +62 -72
- package/dist/cjs/errors/index.js.map +1 -1
- package/dist/cjs/errors/node-api.error.d.ts.map +1 -1
- package/dist/cjs/errors/node-api.error.js +227 -237
- package/dist/cjs/errors/node-api.error.js.map +1 -1
- package/dist/cjs/errors/node-operation.error.d.ts.map +1 -1
- package/dist/cjs/errors/node-operation.error.js +43 -53
- package/dist/cjs/errors/node-operation.error.js.map +1 -1
- package/dist/cjs/errors/node-ssl.error.d.ts.map +1 -1
- package/dist/cjs/errors/node-ssl.error.js +9 -19
- package/dist/cjs/errors/node-ssl.error.js.map +1 -1
- package/dist/cjs/errors/subworkflow-operation.error.d.ts.map +1 -1
- package/dist/cjs/errors/subworkflow-operation.error.js +18 -28
- package/dist/cjs/errors/subworkflow-operation.error.js.map +1 -1
- package/dist/cjs/errors/trigger-close.error.d.ts.map +1 -1
- package/dist/cjs/errors/trigger-close.error.js +11 -21
- package/dist/cjs/errors/trigger-close.error.js.map +1 -1
- package/dist/cjs/errors/webhook-taken.error.d.ts.map +1 -1
- package/dist/cjs/errors/webhook-taken.error.js +9 -19
- package/dist/cjs/errors/webhook-taken.error.js.map +1 -1
- package/dist/cjs/errors/workflow-activation.error.d.ts.map +1 -1
- package/dist/cjs/errors/workflow-activation.error.js +54 -64
- package/dist/cjs/errors/workflow-activation.error.js.map +1 -1
- package/dist/cjs/errors/workflow-configuration.error.js +10 -20
- package/dist/cjs/errors/workflow-configuration.error.js.map +1 -1
- package/dist/cjs/errors/workflow-deactivation.error.js +7 -17
- package/dist/cjs/errors/workflow-deactivation.error.js.map +1 -1
- package/dist/cjs/errors/workflow-operation.error.d.ts.map +1 -1
- package/dist/cjs/errors/workflow-operation.error.js +20 -30
- package/dist/cjs/errors/workflow-operation.error.js.map +1 -1
- package/dist/cjs/evaluation-helpers.js +16 -26
- package/dist/cjs/evaluation-helpers.js.map +1 -1
- package/dist/cjs/execution-context-establishment-hooks.d.ts.map +1 -1
- package/dist/cjs/execution-context-establishment-hooks.js +43 -53
- package/dist/cjs/execution-context-establishment-hooks.js.map +1 -1
- package/dist/cjs/execution-context.d.ts +14 -14
- package/dist/cjs/execution-context.d.ts.map +1 -1
- package/dist/cjs/execution-context.js +203 -213
- package/dist/cjs/execution-context.js.map +1 -1
- package/dist/cjs/execution-status.d.ts +2 -2
- package/dist/cjs/execution-status.d.ts.map +1 -1
- package/dist/cjs/execution-status.js +27 -37
- package/dist/cjs/execution-status.js.map +1 -1
- package/dist/cjs/expression-evaluator-proxy.d.ts.map +1 -1
- package/dist/cjs/expression-evaluator-proxy.js +18 -28
- package/dist/cjs/expression-evaluator-proxy.js.map +1 -1
- package/dist/cjs/expression-sandboxing.d.ts.map +1 -1
- package/dist/cjs/expression-sandboxing.js +447 -457
- package/dist/cjs/expression-sandboxing.js.map +1 -1
- package/dist/cjs/expression.d.ts.map +1 -1
- package/dist/cjs/expression.js +535 -546
- package/dist/cjs/expression.js.map +1 -1
- package/dist/cjs/expressions/expression-helpers.d.ts.map +1 -1
- package/dist/cjs/expressions/expression-helpers.js +13 -23
- package/dist/cjs/expressions/expression-helpers.js.map +1 -1
- package/dist/cjs/extensions/array-extensions.js +591 -601
- package/dist/cjs/extensions/array-extensions.js.map +1 -1
- package/dist/cjs/extensions/boolean-extensions.d.ts +1 -1
- package/dist/cjs/extensions/boolean-extensions.js +38 -48
- package/dist/cjs/extensions/boolean-extensions.js.map +1 -1
- package/dist/cjs/extensions/date-extensions.js +507 -517
- package/dist/cjs/extensions/date-extensions.js.map +1 -1
- package/dist/cjs/extensions/expression-extension.d.ts.map +1 -1
- package/dist/cjs/extensions/expression-extension.js +455 -465
- package/dist/cjs/extensions/expression-extension.js.map +1 -1
- package/dist/cjs/extensions/expression-parser.d.ts.map +1 -1
- package/dist/cjs/extensions/expression-parser.js +82 -92
- package/dist/cjs/extensions/expression-parser.js.map +1 -1
- package/dist/cjs/extensions/extended-functions.d.ts +10 -18
- package/dist/cjs/extensions/extended-functions.d.ts.map +1 -1
- package/dist/cjs/extensions/extended-functions.js +80 -90
- package/dist/cjs/extensions/extended-functions.js.map +1 -1
- package/dist/cjs/extensions/extensions.js +2 -12
- package/dist/cjs/extensions/index.js +10 -20
- package/dist/cjs/extensions/index.js.map +1 -1
- package/dist/cjs/extensions/number-extensions.js +226 -236
- package/dist/cjs/extensions/number-extensions.js.map +1 -1
- package/dist/cjs/extensions/object-extensions.js +274 -284
- package/dist/cjs/extensions/object-extensions.js.map +1 -1
- package/dist/cjs/extensions/string-extensions.d.ts +1 -1
- package/dist/cjs/extensions/string-extensions.d.ts.map +1 -1
- package/dist/cjs/extensions/string-extensions.js +769 -779
- package/dist/cjs/extensions/string-extensions.js.map +1 -1
- package/dist/cjs/extensions/utils.d.ts.map +1 -1
- package/dist/cjs/extensions/utils.js +35 -45
- package/dist/cjs/extensions/utils.js.map +1 -1
- package/dist/cjs/from-ai-parse-utils.js +393 -403
- package/dist/cjs/from-ai-parse-utils.js.map +1 -1
- package/dist/cjs/global-state.js +12 -22
- package/dist/cjs/global-state.js.map +1 -1
- package/dist/cjs/graph/graph-utils.js +166 -176
- package/dist/cjs/graph/graph-utils.js.map +1 -1
- package/dist/cjs/highlighted-data.js +13 -23
- package/dist/cjs/highlighted-data.js.map +1 -1
- package/dist/cjs/index.js +105 -115
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces.d.ts +112 -22
- package/dist/cjs/interfaces.d.ts.map +1 -1
- package/dist/cjs/interfaces.js +62 -72
- package/dist/cjs/interfaces.js.map +1 -1
- package/dist/cjs/jmespath-query.js +26 -36
- package/dist/cjs/jmespath-query.js.map +1 -1
- package/dist/cjs/logger-proxy.d.ts.map +1 -1
- package/dist/cjs/logger-proxy.js +15 -25
- package/dist/cjs/logger-proxy.js.map +1 -1
- package/dist/cjs/mcp-helpers.js +10 -20
- package/dist/cjs/mcp-helpers.js.map +1 -1
- package/dist/cjs/message-event-bus.d.ts +184 -165
- package/dist/cjs/message-event-bus.d.ts.map +1 -1
- package/dist/cjs/message-event-bus.js +207 -217
- package/dist/cjs/message-event-bus.js.map +1 -1
- package/dist/cjs/metadata-utils.js +35 -45
- package/dist/cjs/metadata-utils.js.map +1 -1
- package/dist/cjs/native-methods/array.methods.js +527 -537
- package/dist/cjs/native-methods/array.methods.js.map +1 -1
- package/dist/cjs/native-methods/boolean.methods.js +18 -28
- package/dist/cjs/native-methods/boolean.methods.js.map +1 -1
- package/dist/cjs/native-methods/index.js +16 -26
- package/dist/cjs/native-methods/index.js.map +1 -1
- package/dist/cjs/native-methods/number.methods.js +79 -89
- package/dist/cjs/native-methods/number.methods.js.map +1 -1
- package/dist/cjs/native-methods/object.methods.js +7 -17
- package/dist/cjs/native-methods/object.methods.js.map +1 -1
- package/dist/cjs/native-methods/string.methods.js +474 -484
- package/dist/cjs/native-methods/string.methods.js.map +1 -1
- package/dist/cjs/node-grouping-validation.d.ts +6 -0
- package/dist/cjs/node-grouping-validation.d.ts.map +1 -1
- package/dist/cjs/node-grouping-validation.js +165 -144
- package/dist/cjs/node-grouping-validation.js.map +1 -1
- package/dist/cjs/node-helpers.d.ts.map +1 -1
- package/dist/cjs/node-helpers.js +1486 -1493
- package/dist/cjs/node-helpers.js.map +1 -1
- package/dist/cjs/node-parameters/filter-parameter.d.ts.map +1 -1
- package/dist/cjs/node-parameters/filter-parameter.js +315 -325
- package/dist/cjs/node-parameters/filter-parameter.js.map +1 -1
- package/dist/cjs/node-parameters/node-parameter-value-type-guard.js +105 -115
- package/dist/cjs/node-parameters/node-parameter-value-type-guard.js.map +1 -1
- package/dist/cjs/node-parameters/parameter-type-validation.js +120 -130
- package/dist/cjs/node-parameters/parameter-type-validation.js.map +1 -1
- package/dist/cjs/node-parameters/path-utils.js +21 -31
- package/dist/cjs/node-parameters/path-utils.js.map +1 -1
- package/dist/cjs/node-parameters/rename-node-utils.js +22 -32
- package/dist/cjs/node-parameters/rename-node-utils.js.map +1 -1
- package/dist/cjs/node-reference-parser-utils.js +472 -482
- package/dist/cjs/node-reference-parser-utils.js.map +1 -1
- package/dist/cjs/node-validation.js +59 -69
- package/dist/cjs/node-validation.js.map +1 -1
- package/dist/cjs/observable-object.js +56 -66
- package/dist/cjs/observable-object.js.map +1 -1
- package/dist/cjs/redaction-channels.js +36 -46
- package/dist/cjs/redaction-channels.js.map +1 -1
- package/dist/cjs/run-execution-data/run-execution-data.js +15 -25
- package/dist/cjs/run-execution-data/run-execution-data.js.map +1 -1
- package/dist/cjs/run-execution-data/run-execution-data.v0.js +2 -12
- package/dist/cjs/run-execution-data/run-execution-data.v1.js +26 -36
- package/dist/cjs/run-execution-data/run-execution-data.v1.js.map +1 -1
- package/dist/cjs/run-execution-data-factory.js +113 -123
- package/dist/cjs/run-execution-data-factory.js.map +1 -1
- package/dist/cjs/schemas.d.ts +13 -13
- package/dist/cjs/schemas.d.ts.map +1 -1
- package/dist/cjs/schemas.js +351 -360
- package/dist/cjs/schemas.js.map +1 -1
- package/dist/cjs/sub-workflow-output.js +10 -20
- package/dist/cjs/sub-workflow-output.js.map +1 -1
- package/dist/cjs/telemetry-helpers.d.ts.map +1 -1
- package/dist/cjs/telemetry-helpers.js +716 -726
- package/dist/cjs/telemetry-helpers.js.map +1 -1
- package/dist/cjs/tool-helpers.js +18 -28
- package/dist/cjs/tool-helpers.js.map +1 -1
- package/dist/cjs/trigger-identity.js +41 -51
- package/dist/cjs/trigger-identity.js.map +1 -1
- package/dist/cjs/trimmed-task-data.js +21 -31
- package/dist/cjs/trimmed-task-data.js.map +1 -1
- package/dist/cjs/type-guards.d.ts +3 -3
- package/dist/cjs/type-guards.d.ts.map +1 -1
- package/dist/cjs/type-guards.js +74 -84
- package/dist/cjs/type-guards.js.map +1 -1
- package/dist/cjs/type-validation.d.ts.map +1 -1
- package/dist/cjs/type-validation.js +383 -393
- package/dist/cjs/type-validation.js.map +1 -1
- package/dist/cjs/utils.d.ts +2 -2
- package/dist/cjs/utils.d.ts.map +1 -1
- package/dist/cjs/utils.js +430 -440
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/versioned-node-type.d.ts.map +1 -1
- package/dist/cjs/versioned-node-type.js +20 -30
- package/dist/cjs/versioned-node-type.js.map +1 -1
- package/dist/cjs/workflow-checksum.js +67 -77
- package/dist/cjs/workflow-checksum.js.map +1 -1
- package/dist/cjs/workflow-data-proxy-env-provider.js +58 -68
- package/dist/cjs/workflow-data-proxy-env-provider.js.map +1 -1
- package/dist/cjs/workflow-data-proxy-helpers.js +8 -18
- package/dist/cjs/workflow-data-proxy-helpers.js.map +1 -1
- package/dist/cjs/workflow-data-proxy.d.ts.map +1 -1
- package/dist/cjs/workflow-data-proxy.js +1162 -1172
- package/dist/cjs/workflow-data-proxy.js.map +1 -1
- package/dist/cjs/workflow-diff.d.ts +2 -1
- package/dist/cjs/workflow-diff.d.ts.map +1 -1
- package/dist/cjs/workflow-diff.js +292 -300
- package/dist/cjs/workflow-diff.js.map +1 -1
- package/dist/cjs/workflow-environments-helper.js +23 -33
- package/dist/cjs/workflow-environments-helper.js.map +1 -1
- package/dist/cjs/workflow-expression.d.ts.map +1 -1
- package/dist/cjs/workflow-expression.js +97 -107
- package/dist/cjs/workflow-expression.js.map +1 -1
- package/dist/cjs/workflow-structure-validation.d.ts.map +1 -1
- package/dist/cjs/workflow-structure-validation.js +140 -150
- package/dist/cjs/workflow-structure-validation.js.map +1 -1
- package/dist/cjs/workflow-validation.js +40 -50
- package/dist/cjs/workflow-validation.js.map +1 -1
- package/dist/cjs/workflow.d.ts.map +1 -1
- package/dist/cjs/workflow.js +612 -622
- package/dist/cjs/workflow.js.map +1 -1
- package/dist/esm/common/get-child-nodes.js.map +1 -1
- package/dist/esm/common/get-connected-nodes.js.map +1 -1
- package/dist/esm/common/get-parent-nodes.js.map +1 -1
- package/dist/esm/common/resolve-variables.d.ts +8 -0
- package/dist/esm/common/resolve-variables.d.ts.map +1 -1
- package/dist/esm/common/resolve-variables.js +22 -0
- package/dist/esm/common/resolve-variables.js.map +1 -1
- package/dist/esm/constants.d.ts +3 -3
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/cron.d.ts.map +1 -1
- package/dist/esm/errors/abstract/execution-base.error.d.ts.map +1 -1
- package/dist/esm/errors/abstract/execution-base.error.js.map +1 -1
- package/dist/esm/errors/abstract/node.error.d.ts.map +1 -1
- package/dist/esm/errors/abstract/node.error.js.map +1 -1
- package/dist/esm/errors/base/base.error.d.ts.map +1 -1
- package/dist/esm/errors/base/base.error.js.map +1 -1
- package/dist/esm/errors/base/operational.error.d.ts.map +1 -1
- package/dist/esm/errors/base/operational.error.js.map +1 -1
- package/dist/esm/errors/base/unexpected.error.d.ts.map +1 -1
- package/dist/esm/errors/base/unexpected.error.js.map +1 -1
- package/dist/esm/errors/base/user.error.d.ts.map +1 -1
- package/dist/esm/errors/base/user.error.js.map +1 -1
- package/dist/esm/errors/db-connection-timeout-error.d.ts.map +1 -1
- package/dist/esm/errors/execution-cancelled.error.d.ts.map +1 -1
- package/dist/esm/errors/expression-class-extension.error.d.ts.map +1 -1
- package/dist/esm/errors/expression-computed-destructuring.error.d.ts.map +1 -1
- package/dist/esm/errors/expression-destructuring.error.d.ts.map +1 -1
- package/dist/esm/errors/expression-reserved-variable.error.d.ts.map +1 -1
- package/dist/esm/errors/expression-with-statement.error.d.ts.map +1 -1
- package/dist/esm/errors/expression.error.d.ts.map +1 -1
- package/dist/esm/errors/node-api.error.d.ts.map +1 -1
- package/dist/esm/errors/node-api.error.js.map +1 -1
- package/dist/esm/errors/node-operation.error.d.ts.map +1 -1
- package/dist/esm/errors/node-operation.error.js.map +1 -1
- package/dist/esm/errors/node-ssl.error.d.ts.map +1 -1
- package/dist/esm/errors/subworkflow-operation.error.d.ts.map +1 -1
- package/dist/esm/errors/trigger-close.error.d.ts.map +1 -1
- package/dist/esm/errors/trigger-close.error.js.map +1 -1
- package/dist/esm/errors/webhook-taken.error.d.ts.map +1 -1
- package/dist/esm/errors/workflow-activation.error.d.ts.map +1 -1
- package/dist/esm/errors/workflow-activation.error.js.map +1 -1
- package/dist/esm/errors/workflow-operation.error.d.ts.map +1 -1
- package/dist/esm/execution-context-establishment-hooks.d.ts.map +1 -1
- package/dist/esm/execution-context.d.ts +14 -14
- package/dist/esm/execution-context.d.ts.map +1 -1
- package/dist/esm/execution-status.d.ts +2 -2
- package/dist/esm/execution-status.d.ts.map +1 -1
- package/dist/esm/expression-evaluator-proxy.d.ts.map +1 -1
- package/dist/esm/expression-sandboxing.d.ts.map +1 -1
- package/dist/esm/expression-sandboxing.js.map +1 -1
- package/dist/esm/expression.d.ts.map +1 -1
- package/dist/esm/expression.js.map +1 -1
- package/dist/esm/expressions/expression-helpers.d.ts.map +1 -1
- package/dist/esm/extensions/boolean-extensions.d.ts +1 -1
- package/dist/esm/extensions/expression-extension.d.ts.map +1 -1
- package/dist/esm/extensions/expression-parser.d.ts.map +1 -1
- package/dist/esm/extensions/extended-functions.d.ts +10 -18
- package/dist/esm/extensions/extended-functions.d.ts.map +1 -1
- package/dist/esm/extensions/number-extensions.js.map +1 -1
- package/dist/esm/extensions/string-extensions.d.ts +1 -1
- package/dist/esm/extensions/string-extensions.d.ts.map +1 -1
- package/dist/esm/extensions/string-extensions.js.map +1 -1
- package/dist/esm/extensions/utils.d.ts.map +1 -1
- package/dist/esm/from-ai-parse-utils.js.map +1 -1
- package/dist/esm/interfaces.d.ts +112 -22
- package/dist/esm/interfaces.d.ts.map +1 -1
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/logger-proxy.d.ts.map +1 -1
- package/dist/esm/message-event-bus.d.ts +184 -165
- package/dist/esm/message-event-bus.d.ts.map +1 -1
- package/dist/esm/message-event-bus.js +2 -2
- package/dist/esm/message-event-bus.js.map +1 -1
- package/dist/esm/node-grouping-validation.d.ts +6 -0
- package/dist/esm/node-grouping-validation.d.ts.map +1 -1
- package/dist/esm/node-grouping-validation.js +34 -5
- package/dist/esm/node-grouping-validation.js.map +1 -1
- package/dist/esm/node-helpers.d.ts.map +1 -1
- package/dist/esm/node-helpers.js +3 -0
- package/dist/esm/node-helpers.js.map +1 -1
- package/dist/esm/node-parameters/filter-parameter.d.ts.map +1 -1
- package/dist/esm/node-parameters/filter-parameter.js.map +1 -1
- package/dist/esm/node-reference-parser-utils.js.map +1 -1
- package/dist/esm/run-execution-data-factory.js.map +1 -1
- package/dist/esm/schemas.d.ts +13 -13
- package/dist/esm/schemas.d.ts.map +1 -1
- package/dist/esm/schemas.js +1 -0
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/telemetry-helpers.d.ts.map +1 -1
- package/dist/esm/telemetry-helpers.js.map +1 -1
- package/dist/esm/type-guards.d.ts +3 -3
- package/dist/esm/type-guards.d.ts.map +1 -1
- package/dist/esm/type-validation.d.ts.map +1 -1
- package/dist/esm/type-validation.js.map +1 -1
- package/dist/esm/typecheck.tsbuildinfo +1 -1
- package/dist/esm/utils.d.ts +2 -2
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/versioned-node-type.d.ts.map +1 -1
- package/dist/esm/workflow-data-proxy.d.ts.map +1 -1
- package/dist/esm/workflow-data-proxy.js.map +1 -1
- package/dist/esm/workflow-diff.d.ts +2 -1
- package/dist/esm/workflow-diff.d.ts.map +1 -1
- package/dist/esm/workflow-diff.js +3 -1
- package/dist/esm/workflow-diff.js.map +1 -1
- package/dist/esm/workflow-expression.d.ts.map +1 -1
- package/dist/esm/workflow-expression.js.map +1 -1
- package/dist/esm/workflow-structure-validation.d.ts.map +1 -1
- package/dist/esm/workflow-structure-validation.js.map +1 -1
- package/dist/esm/workflow.d.ts.map +1 -1
- package/dist/esm/workflow.js.map +1 -1
- package/package.json +10 -9
|
@@ -1,498 +1,488 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extendTransform = exports.hasNativeMethod = exports.hasExpressionExtension = exports.EXTENSION_OBJECTS = void 0;
|
|
4
|
+
exports.extend = extend;
|
|
5
|
+
exports.extendOptional = extendOptional;
|
|
6
|
+
exports.extendSyntax = extendSyntax;
|
|
7
|
+
const esprima_next_1 = require("esprima-next");
|
|
8
|
+
const luxon_1 = require("luxon");
|
|
9
|
+
const recast_1 = require("recast");
|
|
10
|
+
const util_1 = require("recast/lib/util");
|
|
11
|
+
const array_extensions_1 = require("./array-extensions");
|
|
12
|
+
const boolean_extensions_1 = require("./boolean-extensions");
|
|
13
|
+
const date_extensions_1 = require("./date-extensions");
|
|
14
|
+
const expression_parser_1 = require("./expression-parser");
|
|
15
|
+
const number_extensions_1 = require("./number-extensions");
|
|
16
|
+
const object_extensions_1 = require("./object-extensions");
|
|
17
|
+
const string_extensions_1 = require("./string-extensions");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
const expression_extension_error_1 = require("../errors/expression-extension.error");
|
|
20
|
+
const utils_2 = require("../utils");
|
|
21
|
+
const EXPRESSION_EXTENDER = 'extend';
|
|
22
|
+
const EXPRESSION_EXTENDER_OPTIONAL = 'extendOptional';
|
|
23
|
+
function isEmpty(value) {
|
|
24
|
+
return value === null || value === undefined || !value;
|
|
25
|
+
}
|
|
26
|
+
function isNotEmpty(value) {
|
|
27
|
+
return !isEmpty(value);
|
|
28
|
+
}
|
|
29
|
+
exports.EXTENSION_OBJECTS = [
|
|
30
|
+
array_extensions_1.arrayExtensions,
|
|
31
|
+
date_extensions_1.dateExtensions,
|
|
32
|
+
number_extensions_1.numberExtensions,
|
|
33
|
+
object_extensions_1.objectExtensions,
|
|
34
|
+
string_extensions_1.stringExtensions,
|
|
35
|
+
boolean_extensions_1.booleanExtensions,
|
|
36
|
+
];
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
|
38
|
+
const genericExtensions = {
|
|
39
|
+
isEmpty,
|
|
40
|
+
isNotEmpty,
|
|
41
|
+
};
|
|
42
|
+
const EXPRESSION_EXTENSION_METHODS = Array.from(new Set([
|
|
43
|
+
...Object.keys(string_extensions_1.stringExtensions.functions),
|
|
44
|
+
...Object.keys(number_extensions_1.numberExtensions.functions),
|
|
45
|
+
...Object.keys(date_extensions_1.dateExtensions.functions),
|
|
46
|
+
...Object.keys(array_extensions_1.arrayExtensions.functions),
|
|
47
|
+
...Object.keys(object_extensions_1.objectExtensions.functions),
|
|
48
|
+
...Object.keys(boolean_extensions_1.booleanExtensions.functions),
|
|
49
|
+
...Object.keys(genericExtensions),
|
|
50
|
+
]));
|
|
51
|
+
const EXPRESSION_EXTENSION_REGEX = new RegExp(`(\\$if|\\.(${EXPRESSION_EXTENSION_METHODS.join('|')})\\s*(\\?\\.)?)\\s*\\(`);
|
|
52
|
+
const isExpressionExtension = (str) => EXPRESSION_EXTENSION_METHODS.some((m) => m === str);
|
|
53
|
+
const hasExpressionExtension = (str) => EXPRESSION_EXTENSION_REGEX.test(str);
|
|
54
|
+
exports.hasExpressionExtension = hasExpressionExtension;
|
|
55
|
+
const hasNativeMethod = (method) => {
|
|
56
|
+
if ((0, exports.hasExpressionExtension)(method)) {
|
|
57
|
+
return false;
|
|
5
58
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.extendSyntax = extendSyntax;
|
|
16
|
-
const esprima_next_1 = require("esprima-next");
|
|
17
|
-
const luxon_1 = require("luxon");
|
|
18
|
-
const recast_1 = require("recast");
|
|
19
|
-
const util_1 = require("recast/lib/util");
|
|
20
|
-
const array_extensions_1 = require("./array-extensions");
|
|
21
|
-
const boolean_extensions_1 = require("./boolean-extensions");
|
|
22
|
-
const date_extensions_1 = require("./date-extensions");
|
|
23
|
-
const expression_parser_1 = require("./expression-parser");
|
|
24
|
-
const number_extensions_1 = require("./number-extensions");
|
|
25
|
-
const object_extensions_1 = require("./object-extensions");
|
|
26
|
-
const string_extensions_1 = require("./string-extensions");
|
|
27
|
-
const utils_1 = require("./utils");
|
|
28
|
-
const expression_extension_error_1 = require("../errors/expression-extension.error");
|
|
29
|
-
const utils_2 = require("../utils");
|
|
30
|
-
const EXPRESSION_EXTENDER = 'extend';
|
|
31
|
-
const EXPRESSION_EXTENDER_OPTIONAL = 'extendOptional';
|
|
32
|
-
function isEmpty(value) {
|
|
33
|
-
return value === null || value === undefined || !value;
|
|
34
|
-
}
|
|
35
|
-
function isNotEmpty(value) {
|
|
36
|
-
return !isEmpty(value);
|
|
37
|
-
}
|
|
38
|
-
exports.EXTENSION_OBJECTS = [
|
|
39
|
-
array_extensions_1.arrayExtensions,
|
|
40
|
-
date_extensions_1.dateExtensions,
|
|
41
|
-
number_extensions_1.numberExtensions,
|
|
42
|
-
object_extensions_1.objectExtensions,
|
|
43
|
-
string_extensions_1.stringExtensions,
|
|
44
|
-
boolean_extensions_1.booleanExtensions,
|
|
45
|
-
];
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
|
47
|
-
const genericExtensions = {
|
|
48
|
-
isEmpty,
|
|
49
|
-
isNotEmpty,
|
|
50
|
-
};
|
|
51
|
-
const EXPRESSION_EXTENSION_METHODS = Array.from(new Set([
|
|
52
|
-
...Object.keys(string_extensions_1.stringExtensions.functions),
|
|
53
|
-
...Object.keys(number_extensions_1.numberExtensions.functions),
|
|
54
|
-
...Object.keys(date_extensions_1.dateExtensions.functions),
|
|
55
|
-
...Object.keys(array_extensions_1.arrayExtensions.functions),
|
|
56
|
-
...Object.keys(object_extensions_1.objectExtensions.functions),
|
|
57
|
-
...Object.keys(boolean_extensions_1.booleanExtensions.functions),
|
|
58
|
-
...Object.keys(genericExtensions),
|
|
59
|
-
]));
|
|
60
|
-
const EXPRESSION_EXTENSION_REGEX = new RegExp(`(\\$if|\\.(${EXPRESSION_EXTENSION_METHODS.join('|')})\\s*(\\?\\.)?)\\s*\\(`);
|
|
61
|
-
const isExpressionExtension = (str) => EXPRESSION_EXTENSION_METHODS.some((m) => m === str);
|
|
62
|
-
const hasExpressionExtension = (str) => EXPRESSION_EXTENSION_REGEX.test(str);
|
|
63
|
-
exports.hasExpressionExtension = hasExpressionExtension;
|
|
64
|
-
const hasNativeMethod = (method) => {
|
|
65
|
-
if ((0, exports.hasExpressionExtension)(method)) {
|
|
59
|
+
const methods = method
|
|
60
|
+
.replace(/[^\w\s]/gi, ' ')
|
|
61
|
+
.split(' ')
|
|
62
|
+
.filter(Boolean); // DateTime.now().toLocaleString().format() => [DateTime,now,toLocaleString,format]
|
|
63
|
+
return methods.every((methodName) => {
|
|
64
|
+
return [String.prototype, Array.prototype, Number.prototype, Date.prototype].some((nativeType) => {
|
|
65
|
+
if (methodName in nativeType) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
66
68
|
return false;
|
|
67
|
-
}
|
|
68
|
-
const methods = method
|
|
69
|
-
.replace(/[^\w\s]/gi, ' ')
|
|
70
|
-
.split(' ')
|
|
71
|
-
.filter(Boolean); // DateTime.now().toLocaleString().format() => [DateTime,now,toLocaleString,format]
|
|
72
|
-
return methods.every((methodName) => {
|
|
73
|
-
return [String.prototype, Array.prototype, Number.prototype, Date.prototype].some((nativeType) => {
|
|
74
|
-
if (methodName in nativeType) {
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
exports.hasNativeMethod = hasNativeMethod;
|
|
82
|
-
// /**
|
|
83
|
-
// * recast's types aren't great and we need to use a lot of anys
|
|
84
|
-
// */
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
function parseWithEsprimaNext(source, options) {
|
|
87
|
-
const ast = (0, esprima_next_1.parse)(source, {
|
|
88
|
-
loc: true,
|
|
89
|
-
locations: true,
|
|
90
|
-
comment: true,
|
|
91
|
-
range: (0, util_1.getOption)(options, 'range', false),
|
|
92
|
-
tolerant: (0, util_1.getOption)(options, 'tolerant', true),
|
|
93
|
-
tokens: true,
|
|
94
|
-
jsx: (0, util_1.getOption)(options, 'jsx', false),
|
|
95
|
-
sourceType: (0, util_1.getOption)(options, 'sourceType', 'module'),
|
|
96
69
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
exports.hasNativeMethod = hasNativeMethod;
|
|
73
|
+
// /**
|
|
74
|
+
// * recast's types aren't great and we need to use a lot of anys
|
|
75
|
+
// */
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
function parseWithEsprimaNext(source, options) {
|
|
78
|
+
const ast = (0, esprima_next_1.parse)(source, {
|
|
79
|
+
loc: true,
|
|
80
|
+
locations: true,
|
|
81
|
+
comment: true,
|
|
82
|
+
range: (0, util_1.getOption)(options, 'range', false),
|
|
83
|
+
tolerant: (0, util_1.getOption)(options, 'tolerant', true),
|
|
84
|
+
tokens: true,
|
|
85
|
+
jsx: (0, util_1.getOption)(options, 'jsx', false),
|
|
86
|
+
sourceType: (0, util_1.getOption)(options, 'sourceType', 'module'),
|
|
87
|
+
});
|
|
88
|
+
return ast;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A function to inject an extender function call into the AST of an expression.
|
|
92
|
+
* This uses recast to do the transform.
|
|
93
|
+
*
|
|
94
|
+
* This function also polyfills optional chaining if using extended functions.
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* 'a'.method('x') // becomes
|
|
98
|
+
* extend('a', 'method', ['x']);
|
|
99
|
+
*
|
|
100
|
+
* 'a'.first('x').second('y') // becomes
|
|
101
|
+
* extend(extend('a', 'first', ['x']), 'second', ['y']));
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
const extendTransform = (expression) => {
|
|
105
|
+
try {
|
|
106
|
+
const ast = (0, recast_1.parse)(expression, { parser: { parse: parseWithEsprimaNext } });
|
|
107
|
+
let currentChain = 1;
|
|
108
|
+
// Polyfill optional chaining
|
|
109
|
+
(0, recast_1.visit)(ast, {
|
|
110
|
+
// eslint-disable-next-line complexity
|
|
111
|
+
visitChainExpression(path) {
|
|
112
|
+
this.traverse(path);
|
|
113
|
+
const chainNumber = currentChain;
|
|
114
|
+
currentChain += 1;
|
|
115
|
+
// This is to match behavior in our original expression evaluator (tmpl)
|
|
116
|
+
const globalIdentifier = recast_1.types.builders.identifier(typeof window !== 'object' ? 'global' : 'window');
|
|
117
|
+
// We want to define all of our commonly used identifiers and member
|
|
118
|
+
// expressions now so we don't have to create multiple instances
|
|
119
|
+
const undefinedIdentifier = recast_1.types.builders.identifier('undefined');
|
|
120
|
+
const cancelIdentifier = recast_1.types.builders.identifier(`chainCancelToken${chainNumber}`);
|
|
121
|
+
const valueIdentifier = recast_1.types.builders.identifier(`chainValue${chainNumber}`);
|
|
122
|
+
const cancelMemberExpression = recast_1.types.builders.memberExpression(globalIdentifier, cancelIdentifier);
|
|
123
|
+
const valueMemberExpression = recast_1.types.builders.memberExpression(globalIdentifier, valueIdentifier);
|
|
124
|
+
const patchedStack = [];
|
|
125
|
+
// This builds the cancel check. This lets us slide to the end of the expression
|
|
126
|
+
// if it's undefined/null at any of the optional points of the chain.
|
|
127
|
+
const buildCancelCheckWrapper = (node) => {
|
|
128
|
+
return recast_1.types.builders.conditionalExpression(recast_1.types.builders.binaryExpression('===', cancelMemberExpression, recast_1.types.builders.booleanLiteral(true)), undefinedIdentifier, node);
|
|
129
|
+
};
|
|
130
|
+
// This is just a quick small wrapper to create the assignment expression
|
|
131
|
+
// for the running value.
|
|
132
|
+
const buildValueAssignWrapper = (node) => {
|
|
133
|
+
return recast_1.types.builders.assignmentExpression('=', valueMemberExpression, node);
|
|
134
|
+
};
|
|
135
|
+
// This builds what actually does the comparison. It wraps the current
|
|
136
|
+
// chunk of the expression with a nullish coalescing operator that returns
|
|
137
|
+
// undefined if it's null or undefined. We do this because optional chains
|
|
138
|
+
// always return undefined if they fail part way, even if the value they
|
|
139
|
+
// fail on is null.
|
|
140
|
+
const buildOptionalWrapper = (node) => {
|
|
141
|
+
return recast_1.types.builders.binaryExpression('===', recast_1.types.builders.logicalExpression('??', buildValueAssignWrapper(node), undefinedIdentifier), undefinedIdentifier);
|
|
142
|
+
};
|
|
143
|
+
// Another small wrapper, but for assigning to the cancel token this time.
|
|
144
|
+
const buildCancelAssignWrapper = (node) => {
|
|
145
|
+
return recast_1.types.builders.assignmentExpression('=', cancelMemberExpression, node);
|
|
146
|
+
};
|
|
147
|
+
let currentNode = path.node.expression;
|
|
148
|
+
let currentPatch = null;
|
|
149
|
+
let patchTop = null;
|
|
150
|
+
let wrapNextTopInOptionalExtend = false;
|
|
151
|
+
// This patches the previous node to use our current one as it's left hand value.
|
|
152
|
+
// It takes `window.chainValue1.test1` and `window.chainValue1.test2` and turns it
|
|
153
|
+
// into `window.chainValue1.test2.test1`.
|
|
154
|
+
const updatePatch = (toPatch, node) => {
|
|
155
|
+
if (toPatch.type === 'MemberExpression' || toPatch.type === 'OptionalMemberExpression') {
|
|
156
|
+
toPatch.object = node;
|
|
157
|
+
}
|
|
158
|
+
else if (toPatch.type === 'CallExpression' ||
|
|
159
|
+
toPatch.type === 'OptionalCallExpression') {
|
|
160
|
+
toPatch.callee = node;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
// This loop walks down an optional chain from the top. This will walk
|
|
164
|
+
// from right to left through an optional chain. We keep track of our current
|
|
165
|
+
// top of the chain (furthest right) and create a chain below it. This chain
|
|
166
|
+
// contains all of the (member and call) expressions that we need. These are
|
|
167
|
+
// patched versions that reference our current chain value. We then push this
|
|
168
|
+
// chain onto a stack when we hit an optional point in our chain.
|
|
169
|
+
while (true) {
|
|
170
|
+
// This should only ever be these types but you can optional chain on
|
|
171
|
+
// JSX nodes, which we don't support.
|
|
172
|
+
if (currentNode.type === 'MemberExpression' ||
|
|
173
|
+
currentNode.type === 'OptionalMemberExpression' ||
|
|
174
|
+
currentNode.type === 'CallExpression' ||
|
|
175
|
+
currentNode.type === 'OptionalCallExpression') {
|
|
176
|
+
let patchNode;
|
|
177
|
+
// Here we take the current node and extract the parts we actually care
|
|
178
|
+
// about.
|
|
179
|
+
// In the case of a member expression we take the property it's trying to
|
|
180
|
+
// access and make the object it's accessing be our chain value.
|
|
181
181
|
if (currentNode.type === 'MemberExpression' ||
|
|
182
|
-
currentNode.type === 'OptionalMemberExpression'
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
// Here we take the current node and extract the parts we actually care
|
|
187
|
-
// about.
|
|
188
|
-
// In the case of a member expression we take the property it's trying to
|
|
189
|
-
// access and make the object it's accessing be our chain value.
|
|
190
|
-
if (currentNode.type === 'MemberExpression' ||
|
|
191
|
-
currentNode.type === 'OptionalMemberExpression') {
|
|
192
|
-
patchNode = recast_1.types.builders.memberExpression(valueMemberExpression, currentNode.property);
|
|
193
|
-
// In the case of a call expression we take the arguments and make the
|
|
194
|
-
// callee our chain value.
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
patchNode = recast_1.types.builders.callExpression(valueMemberExpression, currentNode.arguments);
|
|
198
|
-
}
|
|
199
|
-
// If we have a previous node we patch it here.
|
|
200
|
-
if (currentPatch) {
|
|
201
|
-
updatePatch(currentPatch, patchNode);
|
|
202
|
-
}
|
|
203
|
-
// If we have no top patch (first run, or just pushed onto the stack) we
|
|
204
|
-
// note it here.
|
|
205
|
-
if (!patchTop) {
|
|
206
|
-
patchTop = patchNode;
|
|
207
|
-
}
|
|
208
|
-
currentPatch = patchNode;
|
|
209
|
-
// This is an optional in our chain. In here we'll push the node onto the
|
|
210
|
-
// stack. We also do a polyfill if the top of the stack is function call
|
|
211
|
-
// that might be a extended function.
|
|
212
|
-
if (currentNode.optional) {
|
|
213
|
-
// Implement polyfill described below
|
|
214
|
-
if (wrapNextTopInOptionalExtend) {
|
|
215
|
-
wrapNextTopInOptionalExtend = false;
|
|
216
|
-
// This shouldn't ever happen
|
|
217
|
-
if (patchTop.type === 'MemberExpression' &&
|
|
218
|
-
patchTop.property.type === 'Identifier') {
|
|
219
|
-
patchTop = recast_1.types.builders.callExpression(recast_1.types.builders.identifier(EXPRESSION_EXTENDER_OPTIONAL), [patchTop.object, recast_1.types.builders.stringLiteral(patchTop.property.name)]);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
patchedStack.push(patchTop);
|
|
223
|
-
patchTop = null;
|
|
224
|
-
currentPatch = null;
|
|
225
|
-
// Attempting to optional chain on an extended function. If we don't
|
|
226
|
-
// polyfill this most calls will always be undefined. Marking that the
|
|
227
|
-
// next part of the chain should be wrapped in our polyfill.
|
|
228
|
-
if ((currentNode.type === 'CallExpression' ||
|
|
229
|
-
currentNode.type === 'OptionalCallExpression') &&
|
|
230
|
-
(currentNode.callee.type === 'MemberExpression' ||
|
|
231
|
-
currentNode.callee.type === 'OptionalMemberExpression') &&
|
|
232
|
-
currentNode.callee.property.type === 'Identifier' &&
|
|
233
|
-
isExpressionExtension(currentNode.callee.property.name)) {
|
|
234
|
-
wrapNextTopInOptionalExtend = true;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
// Finally we get the next point AST to walk down.
|
|
238
|
-
if (currentNode.type === 'MemberExpression' ||
|
|
239
|
-
currentNode.type === 'OptionalMemberExpression') {
|
|
240
|
-
currentNode = currentNode.object;
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
currentNode = currentNode.callee;
|
|
244
|
-
}
|
|
182
|
+
currentNode.type === 'OptionalMemberExpression') {
|
|
183
|
+
patchNode = recast_1.types.builders.memberExpression(valueMemberExpression, currentNode.property);
|
|
184
|
+
// In the case of a call expression we take the arguments and make the
|
|
185
|
+
// callee our chain value.
|
|
245
186
|
}
|
|
246
187
|
else {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
188
|
+
patchNode = recast_1.types.builders.callExpression(valueMemberExpression, currentNode.arguments);
|
|
189
|
+
}
|
|
190
|
+
// If we have a previous node we patch it here.
|
|
191
|
+
if (currentPatch) {
|
|
192
|
+
updatePatch(currentPatch, patchNode);
|
|
193
|
+
}
|
|
194
|
+
// If we have no top patch (first run, or just pushed onto the stack) we
|
|
195
|
+
// note it here.
|
|
196
|
+
if (!patchTop) {
|
|
197
|
+
patchTop = patchNode;
|
|
198
|
+
}
|
|
199
|
+
currentPatch = patchNode;
|
|
200
|
+
// This is an optional in our chain. In here we'll push the node onto the
|
|
201
|
+
// stack. We also do a polyfill if the top of the stack is function call
|
|
202
|
+
// that might be a extended function.
|
|
203
|
+
if (currentNode.optional) {
|
|
204
|
+
// Implement polyfill described below
|
|
255
205
|
if (wrapNextTopInOptionalExtend) {
|
|
256
206
|
wrapNextTopInOptionalExtend = false;
|
|
257
207
|
// This shouldn't ever happen
|
|
258
|
-
if (patchTop
|
|
208
|
+
if (patchTop.type === 'MemberExpression' &&
|
|
259
209
|
patchTop.property.type === 'Identifier') {
|
|
260
210
|
patchTop = recast_1.types.builders.callExpression(recast_1.types.builders.identifier(EXPRESSION_EXTENDER_OPTIONAL), [patchTop.object, recast_1.types.builders.stringLiteral(patchTop.property.name)]);
|
|
261
211
|
}
|
|
262
212
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
213
|
+
patchedStack.push(patchTop);
|
|
214
|
+
patchTop = null;
|
|
215
|
+
currentPatch = null;
|
|
216
|
+
// Attempting to optional chain on an extended function. If we don't
|
|
217
|
+
// polyfill this most calls will always be undefined. Marking that the
|
|
218
|
+
// next part of the chain should be wrapped in our polyfill.
|
|
219
|
+
if ((currentNode.type === 'CallExpression' ||
|
|
220
|
+
currentNode.type === 'OptionalCallExpression') &&
|
|
221
|
+
(currentNode.callee.type === 'MemberExpression' ||
|
|
222
|
+
currentNode.callee.type === 'OptionalMemberExpression') &&
|
|
223
|
+
currentNode.callee.property.type === 'Identifier' &&
|
|
224
|
+
isExpressionExtension(currentNode.callee.property.name)) {
|
|
225
|
+
wrapNextTopInOptionalExtend = true;
|
|
269
226
|
}
|
|
270
|
-
|
|
227
|
+
}
|
|
228
|
+
// Finally we get the next point AST to walk down.
|
|
229
|
+
if (currentNode.type === 'MemberExpression' ||
|
|
230
|
+
currentNode.type === 'OptionalMemberExpression') {
|
|
231
|
+
currentNode = currentNode.object;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
currentNode = currentNode.callee;
|
|
271
235
|
}
|
|
272
236
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
237
|
+
else {
|
|
238
|
+
// We update the final patch to point to the first part of the optional chain
|
|
239
|
+
// which is probably an identifier for an object.
|
|
240
|
+
if (currentPatch) {
|
|
241
|
+
updatePatch(currentPatch, currentNode);
|
|
242
|
+
if (!patchTop) {
|
|
243
|
+
patchTop = currentPatch;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (wrapNextTopInOptionalExtend) {
|
|
247
|
+
wrapNextTopInOptionalExtend = false;
|
|
248
|
+
// This shouldn't ever happen
|
|
249
|
+
if (patchTop?.type === 'MemberExpression' &&
|
|
250
|
+
patchTop.property.type === 'Identifier') {
|
|
251
|
+
patchTop = recast_1.types.builders.callExpression(recast_1.types.builders.identifier(EXPRESSION_EXTENDER_OPTIONAL), [patchTop.object, recast_1.types.builders.stringLiteral(patchTop.property.name)]);
|
|
252
|
+
}
|
|
285
253
|
}
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
node = buildCancelCheckWrapper(node);
|
|
254
|
+
// Push the first part of our chain to stack.
|
|
255
|
+
if (patchTop) {
|
|
256
|
+
patchedStack.push(patchTop);
|
|
290
257
|
}
|
|
291
|
-
|
|
292
|
-
|
|
258
|
+
else {
|
|
259
|
+
patchedStack.push(currentNode);
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
293
262
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
if (
|
|
306
|
-
|
|
307
|
-
isExpressionExtension(path.node.callee.property.name)) {
|
|
308
|
-
path.replace(recast_1.types.builders.callExpression(recast_1.types.builders.identifier(EXPRESSION_EXTENDER), [
|
|
309
|
-
path.node.callee.object,
|
|
310
|
-
recast_1.types.builders.stringLiteral(path.node.callee.property.name),
|
|
311
|
-
recast_1.types.builders.arrayExpression(path.node.arguments),
|
|
312
|
-
]));
|
|
263
|
+
}
|
|
264
|
+
// Since we're working from right to left we need to flip the stack
|
|
265
|
+
// for the correct order of operations
|
|
266
|
+
patchedStack.reverse();
|
|
267
|
+
// Walk the node stack and wrap all our expressions in cancel/assignment
|
|
268
|
+
// wrappers.
|
|
269
|
+
for (let i = 0; i < patchedStack.length; i++) {
|
|
270
|
+
let node = patchedStack[i];
|
|
271
|
+
// We don't wrap the last expression in an assignment wrapper because
|
|
272
|
+
// it's going to be returned anyway. We just wrap it in a cancel check
|
|
273
|
+
// wrapper.
|
|
274
|
+
if (i !== patchedStack.length - 1) {
|
|
275
|
+
node = buildCancelAssignWrapper(buildOptionalWrapper(node));
|
|
313
276
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
throw new expression_extension_error_1.ExpressionExtensionError('$if requires at least 2 parameters: test, value_if_true[, and value_if_false]');
|
|
319
|
-
}
|
|
320
|
-
const test = path.node.arguments[0];
|
|
321
|
-
const consequent = path.node.arguments[1];
|
|
322
|
-
const alternative = path.node.arguments[2] === undefined
|
|
323
|
-
? recast_1.types.builders.booleanLiteral(false)
|
|
324
|
-
: path.node.arguments[2];
|
|
325
|
-
path.replace(recast_1.types.builders.conditionalExpression(
|
|
326
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
327
|
-
test,
|
|
328
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
329
|
-
consequent,
|
|
330
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
331
|
-
alternative));
|
|
277
|
+
// Don't wrap the first part in a cancel wrapper because the cancel
|
|
278
|
+
// token will always be undefined.
|
|
279
|
+
if (i !== 0) {
|
|
280
|
+
node = buildCancelCheckWrapper(node);
|
|
332
281
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
282
|
+
// Replace the node in the stack with our wrapped one
|
|
283
|
+
patchedStack[i] = node;
|
|
284
|
+
}
|
|
285
|
+
// Put all our expressions in a sequence expression (also called a
|
|
286
|
+
// group operator). These will all be executed in order and the value
|
|
287
|
+
// of the final expression will be returned.
|
|
288
|
+
const sequenceNode = recast_1.types.builders.sequenceExpression(patchedStack);
|
|
289
|
+
path.replace(sequenceNode);
|
|
290
|
+
},
|
|
291
|
+
});
|
|
292
|
+
// Extended functions
|
|
293
|
+
(0, recast_1.visit)(ast, {
|
|
294
|
+
visitCallExpression(path) {
|
|
295
|
+
this.traverse(path);
|
|
296
|
+
if (path.node.callee.type === 'MemberExpression' &&
|
|
297
|
+
path.node.callee.property.type === 'Identifier' &&
|
|
298
|
+
isExpressionExtension(path.node.callee.property.name)) {
|
|
299
|
+
path.replace(recast_1.types.builders.callExpression(recast_1.types.builders.identifier(EXPRESSION_EXTENDER), [
|
|
300
|
+
path.node.callee.object,
|
|
301
|
+
recast_1.types.builders.stringLiteral(path.node.callee.property.name),
|
|
302
|
+
recast_1.types.builders.arrayExpression(path.node.arguments),
|
|
303
|
+
]));
|
|
304
|
+
}
|
|
305
|
+
else if (path.node.callee.type === 'Identifier' &&
|
|
306
|
+
path.node.callee.name === '$if' &&
|
|
307
|
+
path.node.arguments.every((v) => v.type !== 'SpreadElement')) {
|
|
308
|
+
if (path.node.arguments.length < 2) {
|
|
309
|
+
throw new expression_extension_error_1.ExpressionExtensionError('$if requires at least 2 parameters: test, value_if_true[, and value_if_false]');
|
|
310
|
+
}
|
|
311
|
+
const test = path.node.arguments[0];
|
|
312
|
+
const consequent = path.node.arguments[1];
|
|
313
|
+
const alternative = path.node.arguments[2] === undefined
|
|
314
|
+
? recast_1.types.builders.booleanLiteral(false)
|
|
315
|
+
: path.node.arguments[2];
|
|
316
|
+
path.replace(recast_1.types.builders.conditionalExpression(
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
318
|
+
test,
|
|
319
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
320
|
+
consequent,
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
322
|
+
alternative));
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
return (0, recast_1.print)(ast);
|
|
351
327
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
328
|
+
catch (e) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
exports.extendTransform = extendTransform;
|
|
333
|
+
function isDate(input) {
|
|
334
|
+
if (typeof input !== 'string' || !input.length) {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
if (!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(input)) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
const d = new Date(input);
|
|
341
|
+
return d instanceof Date && !isNaN(d.valueOf()) && d.toISOString() === input;
|
|
342
|
+
}
|
|
343
|
+
function findExtendedFunction(input, functionName) {
|
|
344
|
+
// Coerce to string early so the name is stable for the property check below
|
|
345
|
+
const name = typeof functionName === 'string' ? functionName : String(functionName);
|
|
346
|
+
// Ensure the property name is in the allowed set before looking it up
|
|
347
|
+
if (!(0, utils_2.isSafeObjectProperty)(name)) {
|
|
348
|
+
throw new expression_extension_error_1.ExpressionExtensionError(`Cannot access "${name}" via expression extension due to security concerns`);
|
|
349
|
+
}
|
|
350
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
|
351
|
+
let foundFunction;
|
|
352
|
+
if (Array.isArray(input)) {
|
|
353
|
+
foundFunction = array_extensions_1.arrayExtensions.functions[name];
|
|
354
|
+
}
|
|
355
|
+
else if (isDate(input) && name !== 'toDate' && name !== 'toDateTime') {
|
|
356
|
+
// If it's a string date (from $json), convert it to a Date object,
|
|
357
|
+
// unless that function is `toDate`, since `toDate` does something
|
|
358
|
+
// very different on date objects
|
|
359
|
+
input = new Date(input);
|
|
360
|
+
foundFunction = date_extensions_1.dateExtensions.functions[name];
|
|
361
|
+
}
|
|
362
|
+
else if (typeof input === 'string') {
|
|
363
|
+
foundFunction = string_extensions_1.stringExtensions.functions[name];
|
|
364
|
+
}
|
|
365
|
+
else if (typeof input === 'number') {
|
|
366
|
+
foundFunction = number_extensions_1.numberExtensions.functions[name];
|
|
367
|
+
}
|
|
368
|
+
else if (input && (luxon_1.DateTime.isDateTime(input) || input instanceof Date)) {
|
|
369
|
+
foundFunction = date_extensions_1.dateExtensions.functions[name];
|
|
370
|
+
}
|
|
371
|
+
else if (input !== null && typeof input === 'object') {
|
|
372
|
+
foundFunction = object_extensions_1.objectExtensions.functions[name];
|
|
373
|
+
}
|
|
374
|
+
else if (typeof input === 'boolean') {
|
|
375
|
+
foundFunction = boolean_extensions_1.booleanExtensions.functions[name];
|
|
376
|
+
}
|
|
377
|
+
// Look for generic or builtin
|
|
378
|
+
if (!foundFunction) {
|
|
379
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
380
|
+
const inputAny = input;
|
|
381
|
+
// This is likely a builtin we're implementing for another type
|
|
382
|
+
// (e.g. toLocaleString). We'll return that instead
|
|
383
|
+
if (inputAny && name && typeof inputAny[name] === 'function') {
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
385
|
+
return { type: 'native', function: inputAny[name] };
|
|
382
386
|
}
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
// Use a generic version if available
|
|
388
|
+
foundFunction = genericExtensions[name];
|
|
389
|
+
}
|
|
390
|
+
if (!foundFunction) {
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
return { type: 'extended', function: foundFunction };
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Extender function injected by expression extension plugin to allow calls to extensions.
|
|
397
|
+
*
|
|
398
|
+
* ```ts
|
|
399
|
+
* extend(input, "functionName", [...args]);
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
function extend(input, functionName, args) {
|
|
403
|
+
const foundFunction = findExtendedFunction(input, functionName);
|
|
404
|
+
// No type specific or generic function found. Check to see if
|
|
405
|
+
// any types have a function with that name. Then throw an error
|
|
406
|
+
// letting the user know the available types.
|
|
407
|
+
if (!foundFunction) {
|
|
408
|
+
(0, utils_1.checkIfValueDefinedOrThrow)(input, functionName);
|
|
409
|
+
const haveFunction = exports.EXTENSION_OBJECTS.filter((v) => functionName in v.functions);
|
|
410
|
+
if (!haveFunction.length) {
|
|
411
|
+
// This shouldn't really be possible but we should cover it anyway
|
|
412
|
+
throw new expression_extension_error_1.ExpressionExtensionError(`Unknown expression function: ${functionName}`);
|
|
385
413
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
// This is likely a builtin we're implementing for another type
|
|
391
|
-
// (e.g. toLocaleString). We'll return that instead
|
|
392
|
-
if (inputAny && name && typeof inputAny[name] === 'function') {
|
|
393
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
394
|
-
return { type: 'native', function: inputAny[name] };
|
|
395
|
-
}
|
|
396
|
-
// Use a generic version if available
|
|
397
|
-
foundFunction = genericExtensions[name];
|
|
414
|
+
if (haveFunction.length > 1) {
|
|
415
|
+
const lastType = `"${haveFunction.pop().typeName}"`;
|
|
416
|
+
const typeNames = `${haveFunction.map((v) => `"${v.typeName}"`).join(', ')}, and ${lastType}`;
|
|
417
|
+
throw new expression_extension_error_1.ExpressionExtensionError(`${functionName}() is only callable on types ${typeNames}`);
|
|
398
418
|
}
|
|
399
|
-
|
|
400
|
-
|
|
419
|
+
else {
|
|
420
|
+
throw new expression_extension_error_1.ExpressionExtensionError(`${functionName}() is only callable on type "${haveFunction[0].typeName}"`);
|
|
401
421
|
}
|
|
402
|
-
return { type: 'extended', function: foundFunction };
|
|
403
422
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
throw new expression_extension_error_1.ExpressionExtensionError(`Unknown expression function: ${functionName}`);
|
|
422
|
-
}
|
|
423
|
-
if (haveFunction.length > 1) {
|
|
424
|
-
const lastType = `"${haveFunction.pop().typeName}"`;
|
|
425
|
-
const typeNames = `${haveFunction.map((v) => `"${v.typeName}"`).join(', ')}, and ${lastType}`;
|
|
426
|
-
throw new expression_extension_error_1.ExpressionExtensionError(`${functionName}() is only callable on types ${typeNames}`);
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
throw new expression_extension_error_1.ExpressionExtensionError(`${functionName}() is only callable on type "${haveFunction[0].typeName}"`);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
if (foundFunction.type === 'native') {
|
|
433
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
434
|
-
return foundFunction.function.apply(input, args);
|
|
435
|
-
}
|
|
423
|
+
if (foundFunction.type === 'native') {
|
|
424
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
425
|
+
return foundFunction.function.apply(input, args);
|
|
426
|
+
}
|
|
427
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
428
|
+
return foundFunction.function(input, args);
|
|
429
|
+
}
|
|
430
|
+
function extendOptional(input, functionName) {
|
|
431
|
+
const foundFunction = findExtendedFunction(input, functionName);
|
|
432
|
+
if (!foundFunction) {
|
|
433
|
+
return undefined;
|
|
434
|
+
}
|
|
435
|
+
if (foundFunction.type === 'native') {
|
|
436
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
437
|
+
return foundFunction.function.bind(input);
|
|
438
|
+
}
|
|
439
|
+
return (...args) => {
|
|
436
440
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
437
441
|
return foundFunction.function(input, args);
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
const EXTENDED_SYNTAX_CACHE = {};
|
|
445
|
+
function extendSyntax(bracketedExpression, forceExtend = false) {
|
|
446
|
+
const chunks = (0, expression_parser_1.splitExpression)(bracketedExpression);
|
|
447
|
+
const codeChunks = chunks
|
|
448
|
+
.filter((c) => c.type === 'code')
|
|
449
|
+
.map((c) => c.text.replace(/("|').*?("|')/, '').trim());
|
|
450
|
+
if ((!codeChunks.some(exports.hasExpressionExtension) || (0, exports.hasNativeMethod)(bracketedExpression)) &&
|
|
451
|
+
!forceExtend) {
|
|
452
|
+
return bracketedExpression;
|
|
438
453
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
return undefined;
|
|
443
|
-
}
|
|
444
|
-
if (foundFunction.type === 'native') {
|
|
445
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
446
|
-
return foundFunction.function.bind(input);
|
|
447
|
-
}
|
|
448
|
-
return (...args) => {
|
|
449
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
450
|
-
return foundFunction.function(input, args);
|
|
451
|
-
};
|
|
454
|
+
// If we've seen this expression before grab it from the cache
|
|
455
|
+
if (bracketedExpression in EXTENDED_SYNTAX_CACHE) {
|
|
456
|
+
return EXTENDED_SYNTAX_CACHE[bracketedExpression];
|
|
452
457
|
}
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
!forceExtend) {
|
|
461
|
-
return bracketedExpression;
|
|
462
|
-
}
|
|
463
|
-
// If we've seen this expression before grab it from the cache
|
|
464
|
-
if (bracketedExpression in EXTENDED_SYNTAX_CACHE) {
|
|
465
|
-
return EXTENDED_SYNTAX_CACHE[bracketedExpression];
|
|
466
|
-
}
|
|
467
|
-
const extendedChunks = chunks.map((chunk) => {
|
|
468
|
-
if (chunk.type === 'code') {
|
|
469
|
-
let output = (0, exports.extendTransform)(chunk.text);
|
|
470
|
-
// esprima fails to parse bare objects (e.g. `{ data: something }`), we can
|
|
471
|
-
// work around this by wrapping it in an parentheses
|
|
472
|
-
if (!output?.code && chunk.text.trim()[0] === '{') {
|
|
473
|
-
output = (0, exports.extendTransform)(`(${chunk.text})`);
|
|
474
|
-
}
|
|
475
|
-
if (!output?.code) {
|
|
476
|
-
throw new expression_extension_error_1.ExpressionExtensionError('invalid syntax');
|
|
477
|
-
}
|
|
478
|
-
let text = output.code;
|
|
479
|
-
// We need to cut off any trailing semicolons. These cause issues
|
|
480
|
-
// with certain types of expression and cause the whole expression
|
|
481
|
-
// to fail.
|
|
482
|
-
if (text.trim().endsWith(';')) {
|
|
483
|
-
text = text.trim().slice(0, -1);
|
|
484
|
-
}
|
|
485
|
-
return {
|
|
486
|
-
...chunk,
|
|
487
|
-
text,
|
|
488
|
-
};
|
|
458
|
+
const extendedChunks = chunks.map((chunk) => {
|
|
459
|
+
if (chunk.type === 'code') {
|
|
460
|
+
let output = (0, exports.extendTransform)(chunk.text);
|
|
461
|
+
// esprima fails to parse bare objects (e.g. `{ data: something }`), we can
|
|
462
|
+
// work around this by wrapping it in an parentheses
|
|
463
|
+
if (!output?.code && chunk.text.trim()[0] === '{') {
|
|
464
|
+
output = (0, exports.extendTransform)(`(${chunk.text})`);
|
|
489
465
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
466
|
+
if (!output?.code) {
|
|
467
|
+
throw new expression_extension_error_1.ExpressionExtensionError('invalid syntax');
|
|
468
|
+
}
|
|
469
|
+
let text = output.code;
|
|
470
|
+
// We need to cut off any trailing semicolons. These cause issues
|
|
471
|
+
// with certain types of expression and cause the whole expression
|
|
472
|
+
// to fail.
|
|
473
|
+
if (text.trim().endsWith(';')) {
|
|
474
|
+
text = text.trim().slice(0, -1);
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
...chunk,
|
|
478
|
+
text,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
return chunk;
|
|
482
|
+
});
|
|
483
|
+
const expression = (0, expression_parser_1.joinExpression)(extendedChunks);
|
|
484
|
+
// Cache the expression so we don't have to do this transform again
|
|
485
|
+
EXTENDED_SYNTAX_CACHE[bracketedExpression] = expression;
|
|
486
|
+
return expression;
|
|
487
|
+
}
|
|
498
488
|
//# sourceMappingURL=expression-extension.js.map
|