@oomol-lab/open-flow 0.1.0-beta.72 → 0.1.0-beta.74
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/LICENSE +36 -0
- package/NOTICE +7 -0
- package/README.md +40 -0
- package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-DI9pL-Yr.js} +2 -2
- package/dist/browser/{dialog-CUy_fwx9.js → dialog-BYJGvItc.js} +54 -19
- package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-RL-H4CjD.js} +306 -48
- package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-BkDsETj0.js} +20745 -20186
- package/dist/browser/preview.css +73 -3
- package/dist/browser/preview.js +21410 -20607
- package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
- package/dist/browser/ui.css +72 -2
- package/dist/browser/workbench.css +73 -3
- package/dist/browser/workbench.js +14 -76
- package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-BcWPWGzw.js} +1 -1
- package/dist/command/index.js +34 -34
- package/dist/common/authoring.d.ts +1 -1
- package/dist/common/authoringFields.d.ts +1 -1
- package/dist/common/authoringSchema.d.ts +28 -4
- package/dist/common/connector-proxy.d.ts +1 -1
- package/dist/common/control-api-conformance.d.ts +1 -1
- package/dist/common/control-api-conformance.js +61 -24
- package/dist/common/control-api.d.ts +4 -3
- package/dist/common/control-api.js +90 -42
- package/dist/common/control-requests.d.ts +2 -1
- package/dist/common/control-requests.js +204 -42
- package/dist/common/cron-trigger.d.ts +1 -1
- package/dist/common/decision.d.ts +1 -1
- package/dist/common/draftOperations.d.ts +1 -1
- package/dist/common/engine-contract.d.ts +3 -2
- package/dist/common/event-source-definition.d.ts +1 -1
- package/dist/common/flow-agent.d.ts +1 -1
- package/dist/{browser → common}/flow-authoring-node.d.ts +3 -3
- package/dist/{browser → common}/flow-authoring.js +75 -23
- package/dist/{browser → common}/flow-change-schema.d.ts +177 -6
- package/dist/{browser → common}/flow-change.d.ts +35 -15
- package/dist/{browser → common}/flow-change.js +77 -25
- package/dist/common/flow-connectionUsage.d.ts +1 -1
- package/dist/common/flow-encoding.d.ts +1 -1
- package/dist/common/flow-encoding.js +34 -16
- package/dist/common/flow-errorHandling.d.ts +1 -1
- package/dist/common/flow-graph.d.ts +1 -1
- package/dist/common/flow-modules.d.ts +1 -1
- package/dist/common/flow-promptTemplate.d.ts +1 -1
- package/dist/common/flow-retry.d.ts +1 -1
- package/dist/common/flow-semantics.d.ts +1 -1
- package/dist/common/flow-semantics.js +151 -32
- package/dist/common/flow-workflowFile.d.ts +1 -1
- package/dist/common/flowInspection.d.ts +3 -3
- package/dist/common/integration-trigger.d.ts +1 -1
- package/dist/common/licenses.md +118 -1
- package/dist/common/liveDetails.d.ts +1 -1
- package/dist/common/mcp.d.ts +2 -1
- package/dist/common/mcp.js +59 -22
- package/dist/common/openapi.d.ts +1 -1
- package/dist/common/poll-trigger.d.ts +1 -1
- package/dist/common/run-results.d.ts +8 -1
- package/dist/common/runtime-contract.d.ts +8 -2
- package/dist/common/runtime-contract.js +22 -5
- package/dist/common/scheduler-checkpoint.d.ts +1 -1
- package/dist/common/scheduler-dependencies.d.ts +1 -1
- package/dist/common/scheduler-node-execution.d.ts +1 -1
- package/dist/common/scheduler.d.ts +2 -2
- package/dist/common/scheduler.js +31 -12
- package/dist/common/trigger-catalog.d.ts +1 -1
- package/dist/common/trigger-config-options.d.ts +1 -1
- package/dist/common/trigger-config.d.ts +1 -1
- package/dist/common/trigger-contract.d.ts +2 -2
- package/dist/common/trigger-localization.d.ts +1 -1
- package/dist/common/webhook-response.d.ts +1 -1
- package/dist/common/webhook-trigger.d.ts +1 -1
- package/dist/common/workflow.d.ts +17 -1
- package/dist/common/workflow.js +68 -22
- package/dist/index.d.ts +6 -3
- package/package.json +7 -6
- package/src/base/common/json.ts +90 -0
- package/src/canvas/common/commands.ts +15 -0
- package/src/connector/common/actionSchema.ts +168 -0
- package/src/connector/common/proxy.ts +44 -0
- package/src/control/common/api.ts +1505 -0
- package/src/control/common/authoring.ts +912 -0
- package/src/control/common/authoringCondition.ts +110 -0
- package/src/control/common/authoringDiagnosticFields.ts +136 -0
- package/src/control/common/authoringExamples.ts +192 -0
- package/src/control/common/authoringFields.ts +53 -0
- package/src/control/common/authoringLlm.ts +70 -0
- package/src/control/common/authoringOpenApi.ts +129 -0
- package/src/control/common/authoringSchema.ts +404 -0
- package/src/control/common/authoringTools.ts +123 -0
- package/src/control/common/authoringTriggers.ts +26 -0
- package/src/control/common/checkDecoders.ts +65 -0
- package/src/control/common/conformance.ts +1989 -0
- package/src/control/common/connectorDecoders.ts +370 -0
- package/src/control/common/connectorQueries.ts +61 -0
- package/src/control/common/decoding.ts +60 -0
- package/src/control/common/draftOperations.ts +61 -0
- package/src/control/common/errors.ts +114 -0
- package/src/control/common/eventSourceSchemas.ts +13 -0
- package/src/control/common/eventSources.ts +186 -0
- package/src/control/common/flowDecoders.ts +153 -0
- package/src/control/common/flowInspection.ts +181 -0
- package/src/control/common/flowNotifications.ts +37 -0
- package/src/control/common/liveDetails.ts +124 -0
- package/src/control/common/mcp.ts +241 -0
- package/src/control/common/mcpConformance.ts +142 -0
- package/src/control/common/providerAccess.ts +28 -0
- package/src/control/common/providerIconSprite.ts +42 -0
- package/src/control/common/publicationDecoders.ts +98 -0
- package/src/control/common/random.ts +16 -0
- package/src/control/common/requests.ts +112 -0
- package/src/control/common/resultQuery.ts +8 -0
- package/src/control/common/results.ts +176 -0
- package/src/control/common/revisionDecoders.ts +52 -0
- package/src/control/common/runDecoders.ts +240 -0
- package/src/control/common/triggerCatalog.ts +89 -0
- package/src/control/common/triggerDecoders.ts +175 -0
- package/src/decision/common/decision.ts +168 -0
- package/src/event-source/common/catalog.generated.json +65 -0
- package/src/event-source/common/definition.ts +66 -0
- package/src/event-source/common/index.ts +99 -0
- package/src/execution/common/checkpoint.ts +311 -0
- package/src/execution/common/dependencies.ts +440 -0
- package/src/execution/common/engineContract.ts +80 -0
- package/src/execution/common/events.ts +328 -0
- package/src/execution/common/node-execution.ts +467 -0
- package/src/execution/common/runLifecycle.ts +250 -0
- package/src/execution/common/runtime.ts +563 -0
- package/src/execution/common/scheduler.ts +696 -0
- package/src/execution/common/wait.ts +36 -0
- package/src/flow/common/agent.ts +305 -0
- package/src/flow/common/authoring.ts +30 -0
- package/src/flow/common/change.ts +1036 -0
- package/src/flow/common/changeSchema.ts +783 -0
- package/src/flow/common/codePermissions.ts +2 -0
- package/src/flow/common/condition.ts +265 -0
- package/src/flow/common/connectionUsage.ts +131 -0
- package/src/flow/common/edgeChanges.ts +35 -0
- package/src/flow/common/encoding.ts +437 -0
- package/src/flow/common/errorHandling.ts +34 -0
- package/src/flow/common/graph.ts +892 -0
- package/src/flow/common/inputValue.ts +16 -0
- package/src/flow/common/json.ts +8 -0
- package/src/flow/common/moduleChanges.ts +31 -0
- package/src/flow/common/modules.ts +292 -0
- package/src/flow/common/nodeChanges.ts +762 -0
- package/src/flow/common/portChanges.ts +36 -0
- package/src/flow/common/promptTemplate.ts +15 -0
- package/src/flow/common/retry.ts +20 -0
- package/src/flow/common/schema.ts +162 -0
- package/src/flow/common/schemaCompare.ts +176 -0
- package/src/flow/common/schemaComparer.ts +178 -0
- package/src/flow/common/schemaKeywords.ts +53 -0
- package/src/flow/common/semantics.ts +474 -0
- package/src/flow/common/sourceField.ts +35 -0
- package/src/flow/common/triggerScheduleSchema.ts +8 -0
- package/src/flow/common/wait.ts +30 -0
- package/src/flow/common/webhookMethod.ts +7 -0
- package/src/flow/common/webhookResponse.ts +75 -0
- package/src/flow/common/workflowFile.ts +97 -0
- package/src/json-schema-subset/checker/array.ts +142 -0
- package/src/json-schema-subset/checker/cache.ts +57 -0
- package/src/json-schema-subset/checker/checker.ts +230 -0
- package/src/json-schema-subset/checker/enumAndConst.ts +113 -0
- package/src/json-schema-subset/checker/equals.ts +93 -0
- package/src/json-schema-subset/checker/numeric/checker.ts +50 -0
- package/src/json-schema-subset/checker/numeric/float.ts +121 -0
- package/src/json-schema-subset/checker/numeric/index.ts +1 -0
- package/src/json-schema-subset/checker/numeric/integer.ts +119 -0
- package/src/json-schema-subset/checker/numeric/integerNormalizer.ts +72 -0
- package/src/json-schema-subset/checker/object.ts +354 -0
- package/src/json-schema-subset/checker/range.ts +91 -0
- package/src/json-schema-subset/checker/string.ts +60 -0
- package/src/json-schema-subset/checker/tools/index.ts +3 -0
- package/src/json-schema-subset/checker/tools/mark.ts +82 -0
- package/src/json-schema-subset/checker/tools/quantum.ts +106 -0
- package/src/json-schema-subset/checker/tools/range.ts +210 -0
- package/src/json-schema-subset/checker/validator.ts +23 -0
- package/src/json-schema-subset/compiler/array.ts +163 -0
- package/src/json-schema-subset/compiler/combination.ts +109 -0
- package/src/json-schema-subset/compiler/common.ts +99 -0
- package/src/json-schema-subset/compiler/compiler.ts +188 -0
- package/src/json-schema-subset/compiler/enumAndConst.ts +75 -0
- package/src/json-schema-subset/compiler/index.ts +11 -0
- package/src/json-schema-subset/compiler/object.ts +411 -0
- package/src/json-schema-subset/compiler/primitive.ts +144 -0
- package/src/json-schema-subset/compiler/utils.ts +24 -0
- package/src/json-schema-subset/compiler/wrapper.ts +192 -0
- package/src/json-schema-subset/error.ts +55 -0
- package/src/json-schema-subset/expression/calculator.ts +442 -0
- package/src/json-schema-subset/expression/combination.ts +49 -0
- package/src/json-schema-subset/expression/expression.ts +191 -0
- package/src/json-schema-subset/expression/index.ts +25 -0
- package/src/json-schema-subset/expression/result.ts +88 -0
- package/src/json-schema-subset/expression/types.ts +36 -0
- package/src/json-schema-subset/extends/extendsContext.ts +89 -0
- package/src/json-schema-subset/extends/index.ts +2 -0
- package/src/json-schema-subset/extends/types.ts +12 -0
- package/src/json-schema-subset/global.ts +60 -0
- package/src/json-schema-subset/index.ts +8 -0
- package/src/json-schema-subset/preprocessing.ts +74 -0
- package/src/json-schema-subset/types.ts +8 -0
- package/src/json-schema-subset/utils.ts +95 -0
- package/src/localization/common/languages.ts +118 -0
- package/src/localization/common/timeZone.ts +25 -0
- package/src/openapi/common/authBindings.ts +12 -0
- package/src/openapi/common/openapi.ts +459 -0
- package/src/trigger/common/config.ts +56 -0
- package/src/trigger/common/configOptions.ts +15 -0
- package/src/trigger/common/configSchema.ts +8 -0
- package/src/trigger/common/contract.ts +132 -0
- package/src/trigger/common/cron.ts +151 -0
- package/src/trigger/common/integration.ts +498 -0
- package/src/trigger/common/poll.ts +187 -0
- package/src/trigger/common/webhook.ts +412 -0
- package/src/trigger/providers/airtable/locales/fr.json +18 -0
- package/src/trigger/providers/airtable/locales/ja.json +18 -0
- package/src/trigger/providers/airtable/locales/ko.json +18 -0
- package/src/trigger/providers/airtable/locales/ru.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-CN.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-TW.json +18 -0
- package/src/trigger/providers/asana/locales/fr.json +15 -0
- package/src/trigger/providers/asana/locales/ja.json +15 -0
- package/src/trigger/providers/asana/locales/ko.json +15 -0
- package/src/trigger/providers/asana/locales/ru.json +15 -0
- package/src/trigger/providers/asana/locales/zh-CN.json +15 -0
- package/src/trigger/providers/asana/locales/zh-TW.json +15 -0
- package/src/trigger/providers/calendly/locales/fr.json +16 -0
- package/src/trigger/providers/calendly/locales/ja.json +16 -0
- package/src/trigger/providers/calendly/locales/ko.json +16 -0
- package/src/trigger/providers/calendly/locales/ru.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-CN.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-TW.json +16 -0
- package/src/trigger/providers/catalog.generated.json +4996 -0
- package/src/trigger/providers/clickup/locales/fr.json +16 -0
- package/src/trigger/providers/clickup/locales/ja.json +16 -0
- package/src/trigger/providers/clickup/locales/ko.json +16 -0
- package/src/trigger/providers/clickup/locales/ru.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-CN.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-TW.json +16 -0
- package/src/trigger/providers/definitions.ts +19 -0
- package/src/trigger/providers/feishu/locales/fr.json +20 -0
- package/src/trigger/providers/feishu/locales/ja.json +20 -0
- package/src/trigger/providers/feishu/locales/ko.json +20 -0
- package/src/trigger/providers/feishu/locales/ru.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-CN.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-TW.json +20 -0
- package/src/trigger/providers/fieldDescriptions.ts +392 -0
- package/src/trigger/providers/fieldLabels.ts +256 -0
- package/src/trigger/providers/fireflies/locales/fr.json +17 -0
- package/src/trigger/providers/fireflies/locales/ja.json +17 -0
- package/src/trigger/providers/fireflies/locales/ko.json +17 -0
- package/src/trigger/providers/fireflies/locales/ru.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-CN.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-TW.json +17 -0
- package/src/trigger/providers/github/locales/fr.json +30 -0
- package/src/trigger/providers/github/locales/ja.json +30 -0
- package/src/trigger/providers/github/locales/ko.json +30 -0
- package/src/trigger/providers/github/locales/ru.json +30 -0
- package/src/trigger/providers/github/locales/zh-CN.json +30 -0
- package/src/trigger/providers/github/locales/zh-TW.json +30 -0
- package/src/trigger/providers/gitlab/locales/fr.json +18 -0
- package/src/trigger/providers/gitlab/locales/ja.json +18 -0
- package/src/trigger/providers/gitlab/locales/ko.json +18 -0
- package/src/trigger/providers/gitlab/locales/ru.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-TW.json +18 -0
- package/src/trigger/providers/gmail/locales/fr.json +18 -0
- package/src/trigger/providers/gmail/locales/ja.json +18 -0
- package/src/trigger/providers/gmail/locales/ko.json +18 -0
- package/src/trigger/providers/gmail/locales/ru.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-TW.json +18 -0
- package/src/trigger/providers/google-calendar/locales/fr.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ja.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ko.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ru.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-CN.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-TW.json +15 -0
- package/src/trigger/providers/google-drive/locales/fr.json +48 -0
- package/src/trigger/providers/google-drive/locales/ja.json +48 -0
- package/src/trigger/providers/google-drive/locales/ko.json +48 -0
- package/src/trigger/providers/google-drive/locales/ru.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-CN.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-TW.json +48 -0
- package/src/trigger/providers/google-sheets/locales/fr.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ja.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ko.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ru.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-CN.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-TW.json +19 -0
- package/src/trigger/providers/intercom/locales/fr.json +17 -0
- package/src/trigger/providers/intercom/locales/ja.json +17 -0
- package/src/trigger/providers/intercom/locales/ko.json +17 -0
- package/src/trigger/providers/intercom/locales/ru.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-TW.json +17 -0
- package/src/trigger/providers/jira/locales/fr.json +17 -0
- package/src/trigger/providers/jira/locales/ja.json +17 -0
- package/src/trigger/providers/jira/locales/ko.json +17 -0
- package/src/trigger/providers/jira/locales/ru.json +17 -0
- package/src/trigger/providers/jira/locales/zh-CN.json +17 -0
- package/src/trigger/providers/jira/locales/zh-TW.json +17 -0
- package/src/trigger/providers/linear/locales/fr.json +13 -0
- package/src/trigger/providers/linear/locales/ja.json +13 -0
- package/src/trigger/providers/linear/locales/ko.json +13 -0
- package/src/trigger/providers/linear/locales/ru.json +13 -0
- package/src/trigger/providers/linear/locales/zh-CN.json +13 -0
- package/src/trigger/providers/linear/locales/zh-TW.json +13 -0
- package/src/trigger/providers/locales/fr.ts +71 -0
- package/src/trigger/providers/locales/ja.ts +71 -0
- package/src/trigger/providers/locales/ko.ts +71 -0
- package/src/trigger/providers/locales/ru.ts +71 -0
- package/src/trigger/providers/locales/zh-CN.ts +71 -0
- package/src/trigger/providers/locales/zh-TW.ts +71 -0
- package/src/trigger/providers/localization.ts +59 -0
- package/src/trigger/providers/notion/locales/fr.json +16 -0
- package/src/trigger/providers/notion/locales/ja.json +16 -0
- package/src/trigger/providers/notion/locales/ko.json +16 -0
- package/src/trigger/providers/notion/locales/ru.json +16 -0
- package/src/trigger/providers/notion/locales/zh-CN.json +16 -0
- package/src/trigger/providers/notion/locales/zh-TW.json +16 -0
- package/src/trigger/providers/one-drive/locales/fr.json +16 -0
- package/src/trigger/providers/one-drive/locales/ja.json +16 -0
- package/src/trigger/providers/one-drive/locales/ko.json +16 -0
- package/src/trigger/providers/one-drive/locales/ru.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-CN.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-TW.json +16 -0
- package/src/trigger/providers/outlook/locales/fr.json +18 -0
- package/src/trigger/providers/outlook/locales/ja.json +18 -0
- package/src/trigger/providers/outlook/locales/ko.json +18 -0
- package/src/trigger/providers/outlook/locales/ru.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-CN.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-TW.json +18 -0
- package/src/trigger/providers/pandadoc/locales/fr.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ja.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ko.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ru.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-CN.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-TW.json +12 -0
- package/src/trigger/providers/pipedrive/locales/fr.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ja.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ko.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ru.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-CN.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-TW.json +15 -0
- package/src/trigger/providers/remote.ts +163 -0
- package/src/trigger/providers/resend/locales/fr.json +16 -0
- package/src/trigger/providers/resend/locales/ja.json +16 -0
- package/src/trigger/providers/resend/locales/ko.json +16 -0
- package/src/trigger/providers/resend/locales/ru.json +16 -0
- package/src/trigger/providers/resend/locales/zh-CN.json +16 -0
- package/src/trigger/providers/resend/locales/zh-TW.json +16 -0
- package/src/trigger/providers/sentry/locales/fr.json +19 -0
- package/src/trigger/providers/sentry/locales/ja.json +19 -0
- package/src/trigger/providers/sentry/locales/ko.json +19 -0
- package/src/trigger/providers/sentry/locales/ru.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-CN.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-TW.json +19 -0
- package/src/trigger/providers/shopify/locales/fr.json +18 -0
- package/src/trigger/providers/shopify/locales/ja.json +18 -0
- package/src/trigger/providers/shopify/locales/ko.json +18 -0
- package/src/trigger/providers/shopify/locales/ru.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-CN.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slack/locales/fr.json +18 -0
- package/src/trigger/providers/slack/locales/ja.json +18 -0
- package/src/trigger/providers/slack/locales/ko.json +18 -0
- package/src/trigger/providers/slack/locales/ru.json +18 -0
- package/src/trigger/providers/slack/locales/zh-CN.json +18 -0
- package/src/trigger/providers/slack/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slackbot/locales/fr.json +23 -0
- package/src/trigger/providers/slackbot/locales/ja.json +23 -0
- package/src/trigger/providers/slackbot/locales/ko.json +23 -0
- package/src/trigger/providers/slackbot/locales/ru.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-CN.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-TW.json +23 -0
- package/src/trigger/providers/source-events.ts +25 -0
- package/src/trigger/providers/stripe/locales/fr.json +17 -0
- package/src/trigger/providers/stripe/locales/ja.json +17 -0
- package/src/trigger/providers/stripe/locales/ko.json +17 -0
- package/src/trigger/providers/stripe/locales/ru.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-CN.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-TW.json +17 -0
- package/src/trigger/providers/tally/locales/fr.json +12 -0
- package/src/trigger/providers/tally/locales/ja.json +12 -0
- package/src/trigger/providers/tally/locales/ko.json +12 -0
- package/src/trigger/providers/tally/locales/ru.json +12 -0
- package/src/trigger/providers/tally/locales/zh-CN.json +12 -0
- package/src/trigger/providers/tally/locales/zh-TW.json +12 -0
- package/src/trigger/providers/telegram/locales/fr.json +17 -0
- package/src/trigger/providers/telegram/locales/ja.json +17 -0
- package/src/trigger/providers/telegram/locales/ko.json +17 -0
- package/src/trigger/providers/telegram/locales/ru.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-CN.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-TW.json +17 -0
- package/src/trigger/providers/typeform/locales/fr.json +12 -0
- package/src/trigger/providers/typeform/locales/ja.json +12 -0
- package/src/trigger/providers/typeform/locales/ko.json +12 -0
- package/src/trigger/providers/typeform/locales/ru.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-CN.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-TW.json +12 -0
- package/src/trigger/providers/vercel/locales/fr.json +18 -0
- package/src/trigger/providers/vercel/locales/ja.json +18 -0
- package/src/trigger/providers/vercel/locales/ko.json +18 -0
- package/src/trigger/providers/vercel/locales/ru.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-CN.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-TW.json +18 -0
- package/src/trigger/providers/woocommerce/locales/fr.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ja.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ko.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ru.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-CN.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-TW.json +19 -0
- package/src/trigger/providers/zendesk/locales/fr.json +15 -0
- package/src/trigger/providers/zendesk/locales/ja.json +15 -0
- package/src/trigger/providers/zendesk/locales/ko.json +15 -0
- package/src/trigger/providers/zendesk/locales/ru.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-CN.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-TW.json +15 -0
- package/src/trigger/providers/zoom/locales/fr.json +17 -0
- package/src/trigger/providers/zoom/locales/ja.json +17 -0
- package/src/trigger/providers/zoom/locales/ko.json +17 -0
- package/src/trigger/providers/zoom/locales/ru.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-TW.json +17 -0
- package/src/types/index.ts +112 -0
- package/src/workflow/common/workflow.ts +273 -0
- package/dist/browser/lib-DrKav3HG.js +0 -11403
- /package/dist/{browser → common}/flow-authoring-edge.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring-module.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring.d.ts +0 -0
- /package/dist/{browser → common}/flow-input-value.d.ts +0 -0
- /package/dist/{browser → common}/webhook-method.d.ts +0 -0
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import type { CompiledSchema } from '../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../expression/index.ts'
|
|
3
|
+
import type { Schema } from '../types.ts'
|
|
4
|
+
import type { Context } from './cache.ts'
|
|
5
|
+
import type { QuantumVariableType } from './tools/index.ts'
|
|
6
|
+
|
|
7
|
+
import { getKind, ANY, NEVER, CompiledKind } from '../compiler/index.ts'
|
|
8
|
+
import {
|
|
9
|
+
ExpressionNone,
|
|
10
|
+
ExpressionEquals,
|
|
11
|
+
ExpressionContaining,
|
|
12
|
+
ExpressionContainedBy,
|
|
13
|
+
ExpressionIntersection,
|
|
14
|
+
ExpressionRejection,
|
|
15
|
+
ExpressionSingleResult,
|
|
16
|
+
} from '../expression/index.ts'
|
|
17
|
+
import { createRangeSplitter, toExpressionSingleResult } from './range.ts'
|
|
18
|
+
import { makeQuantum } from './tools/index.ts'
|
|
19
|
+
import { ValidResult, valid } from './validator.ts'
|
|
20
|
+
|
|
21
|
+
const splitRange = createRangeSplitter(0)
|
|
22
|
+
const quantum = makeQuantum(['hasCommonInRequired', 'hasCommonOutRequired', 'hasExtra1', 'hasExtra2', 'hasRejection'])
|
|
23
|
+
|
|
24
|
+
// TODO: Handle object schemas introduced by the unsupported dependencies keyword.
|
|
25
|
+
export function calculateObject<E>(context: Context<E>, schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
26
|
+
if (isPropertiesCountCannotMatch(schema1, schema2)) {
|
|
27
|
+
return ExpressionRejection
|
|
28
|
+
}
|
|
29
|
+
const splitRequiredResult = splitRequired(schema1, schema2)
|
|
30
|
+
|
|
31
|
+
if (!splitRequiredResult) {
|
|
32
|
+
return ExpressionRejection
|
|
33
|
+
}
|
|
34
|
+
const getProperty1 = createPropertySchemaGetter(schema1)
|
|
35
|
+
const getProperty2 = createPropertySchemaGetter(schema2)
|
|
36
|
+
const calculateKey = (key: string): ExpressionResult => {
|
|
37
|
+
const propertySchema1 = getProperty1(key)
|
|
38
|
+
const propertySchema2 = getProperty2(key)
|
|
39
|
+
|
|
40
|
+
if (areNotBothNever(propertySchema1, propertySchema2)) {
|
|
41
|
+
return context.calculate(propertySchema1, propertySchema2)
|
|
42
|
+
} else {
|
|
43
|
+
return ExpressionNone
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult
|
|
47
|
+
const quantumVariable = quantum.variable({})
|
|
48
|
+
|
|
49
|
+
for (const requiredKey of [...commonRequired].toSorted()) {
|
|
50
|
+
quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression)
|
|
51
|
+
}
|
|
52
|
+
for (const requiredKey of [...extraRequired1].toSorted()) {
|
|
53
|
+
quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1)
|
|
54
|
+
}
|
|
55
|
+
for (const requiredKey of [...extraRequired2].toSorted()) {
|
|
56
|
+
quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2)
|
|
57
|
+
}
|
|
58
|
+
const { hasOptional1, hasOptional2 } = splitRequiredResult
|
|
59
|
+
|
|
60
|
+
if (hasOptional1 || hasOptional2) {
|
|
61
|
+
const calculator = calculateOptionalExpression(hasOptional1, hasOptional2)
|
|
62
|
+
|
|
63
|
+
for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
|
|
64
|
+
const expression = calculateKey(optionalKey)
|
|
65
|
+
if (expression !== ExpressionNone) {
|
|
66
|
+
quantumVariable.push(expression, calculator)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const additionalProperties1 = (schema1.additionalProperties as Schema<E>) ?? ANY
|
|
70
|
+
const additionalProperties2 = (schema2.additionalProperties as Schema<E>) ?? ANY
|
|
71
|
+
|
|
72
|
+
if (areNotBothNever(additionalProperties1, additionalProperties2)) {
|
|
73
|
+
const expression = context.calculate(additionalProperties1, additionalProperties2)
|
|
74
|
+
quantumVariable.push(expression, calculator)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
quantumVariable.update((variable) => {
|
|
78
|
+
if (!variable.hasRejection) {
|
|
79
|
+
// Fewer required properties leave more possibilities outside the common set.
|
|
80
|
+
if (extraRequired1.size > 0) {
|
|
81
|
+
variable.hasExtra2 = true
|
|
82
|
+
}
|
|
83
|
+
if (extraRequired2.size > 0) {
|
|
84
|
+
variable.hasExtra1 = true
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
const { requiredKeysCount } = splitRequiredResult
|
|
89
|
+
let expression = ExpressionNone
|
|
90
|
+
|
|
91
|
+
for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) {
|
|
92
|
+
if (!hasCommonInRequired && requiredKeysCount > 0) {
|
|
93
|
+
expression |= ExpressionRejection
|
|
94
|
+
} else if (!hasCommonOutRequired && requiredKeysCount === 0) {
|
|
95
|
+
expression |= ExpressionRejection
|
|
96
|
+
} else if (hasRejection) {
|
|
97
|
+
expression |= ExpressionRejection
|
|
98
|
+
} else if (hasExtra1 && hasExtra2) {
|
|
99
|
+
expression |= ExpressionIntersection
|
|
100
|
+
} else if (hasExtra1) {
|
|
101
|
+
expression |= ExpressionContaining
|
|
102
|
+
} else if (hasExtra2) {
|
|
103
|
+
expression |= ExpressionContainedBy
|
|
104
|
+
} else {
|
|
105
|
+
expression |= ExpressionEquals
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return expression
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isPropertiesCountCannotMatch<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): boolean {
|
|
112
|
+
const splitResult = splitRange(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)
|
|
113
|
+
const splitExpression = toExpressionSingleResult(splitResult)
|
|
114
|
+
|
|
115
|
+
return splitExpression === ExpressionSingleResult.Rejection
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type SplitRequiredResult = {
|
|
119
|
+
readonly requiredKeysCount: number
|
|
120
|
+
readonly commonRequired: Set<string>
|
|
121
|
+
readonly extraRequired1: Set<string>
|
|
122
|
+
readonly extraRequired2: Set<string>
|
|
123
|
+
readonly hasOptional1: boolean
|
|
124
|
+
readonly hasOptional2: boolean
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function splitRequired<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): SplitRequiredResult | null {
|
|
128
|
+
const extraRequired1 = new Set<string>(schema1.required)
|
|
129
|
+
const extraRequired2 = new Set<string>(schema2.required)
|
|
130
|
+
const commonRequired = new Set<string>()
|
|
131
|
+
const wholeRequired = new Set<string>()
|
|
132
|
+
|
|
133
|
+
const requiredCount1 = extraRequired1.size
|
|
134
|
+
const requiredCount2 = extraRequired2.size
|
|
135
|
+
|
|
136
|
+
for (const key of extraRequired1) {
|
|
137
|
+
if (extraRequired2.has(key)) {
|
|
138
|
+
commonRequired.add(key)
|
|
139
|
+
}
|
|
140
|
+
wholeRequired.add(key)
|
|
141
|
+
}
|
|
142
|
+
for (const key of extraRequired2) {
|
|
143
|
+
if (extraRequired1.has(key)) {
|
|
144
|
+
commonRequired.add(key)
|
|
145
|
+
}
|
|
146
|
+
wholeRequired.add(key)
|
|
147
|
+
}
|
|
148
|
+
const requiredKeysCount = wholeRequired.size
|
|
149
|
+
|
|
150
|
+
for (const key of commonRequired) {
|
|
151
|
+
extraRequired1.delete(key)
|
|
152
|
+
extraRequired2.delete(key)
|
|
153
|
+
}
|
|
154
|
+
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER
|
|
155
|
+
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER
|
|
156
|
+
|
|
157
|
+
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) {
|
|
158
|
+
return null
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
requiredKeysCount,
|
|
162
|
+
extraRequired1,
|
|
163
|
+
extraRequired2,
|
|
164
|
+
commonRequired,
|
|
165
|
+
hasOptional1: maxProperties1 > requiredCount1,
|
|
166
|
+
hasOptional2: maxProperties2 > requiredCount2,
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getOptionalKeys<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): Set<string> {
|
|
171
|
+
const optionalKeys = new Set<string>(schema1.required)
|
|
172
|
+
const properties1 = schema1.properties
|
|
173
|
+
const properties2 = schema2.properties
|
|
174
|
+
const required1 = schema1.required
|
|
175
|
+
const required2 = schema2.required
|
|
176
|
+
|
|
177
|
+
if (properties1) {
|
|
178
|
+
for (const key in properties1) {
|
|
179
|
+
optionalKeys.add(key)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (properties2) {
|
|
183
|
+
for (const key in properties2) {
|
|
184
|
+
optionalKeys.add(key)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (required1) {
|
|
188
|
+
for (const key of required1) {
|
|
189
|
+
optionalKeys.delete(key)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (required2) {
|
|
193
|
+
for (const key of required2) {
|
|
194
|
+
optionalKeys.delete(key)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return optionalKeys
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const calculateCommonRequiredExpression = (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
|
|
201
|
+
switch (singleExpression) {
|
|
202
|
+
case ExpressionSingleResult.Equals: {
|
|
203
|
+
variable.hasCommonInRequired = true
|
|
204
|
+
break
|
|
205
|
+
}
|
|
206
|
+
case ExpressionSingleResult.Containing: {
|
|
207
|
+
variable.hasExtra1 = true
|
|
208
|
+
variable.hasCommonInRequired = true
|
|
209
|
+
break
|
|
210
|
+
}
|
|
211
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
212
|
+
variable.hasExtra2 = true
|
|
213
|
+
variable.hasCommonInRequired = true
|
|
214
|
+
break
|
|
215
|
+
}
|
|
216
|
+
case ExpressionSingleResult.Intersection: {
|
|
217
|
+
variable.hasExtra1 = true
|
|
218
|
+
variable.hasExtra2 = true
|
|
219
|
+
variable.hasCommonInRequired = true
|
|
220
|
+
break
|
|
221
|
+
}
|
|
222
|
+
case ExpressionSingleResult.Rejection: {
|
|
223
|
+
variable.hasRejection = true
|
|
224
|
+
break
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const calculateExtraRequiredExpression1 = (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
|
|
230
|
+
switch (singleExpression) {
|
|
231
|
+
case ExpressionSingleResult.Equals:
|
|
232
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
233
|
+
variable.hasCommonInRequired = true
|
|
234
|
+
break
|
|
235
|
+
}
|
|
236
|
+
case ExpressionSingleResult.Intersection:
|
|
237
|
+
case ExpressionSingleResult.Containing: {
|
|
238
|
+
variable.hasExtra1 = true
|
|
239
|
+
variable.hasCommonInRequired = true
|
|
240
|
+
break
|
|
241
|
+
}
|
|
242
|
+
case ExpressionSingleResult.Rejection: {
|
|
243
|
+
variable.hasRejection = true
|
|
244
|
+
break
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const calculateExtraRequiredExpression2 = (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
|
|
250
|
+
switch (singleExpression) {
|
|
251
|
+
case ExpressionSingleResult.Equals:
|
|
252
|
+
case ExpressionSingleResult.Containing: {
|
|
253
|
+
variable.hasCommonInRequired = true
|
|
254
|
+
break
|
|
255
|
+
}
|
|
256
|
+
case ExpressionSingleResult.Intersection:
|
|
257
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
258
|
+
variable.hasExtra2 = true
|
|
259
|
+
variable.hasCommonInRequired = true
|
|
260
|
+
break
|
|
261
|
+
}
|
|
262
|
+
case ExpressionSingleResult.Rejection: {
|
|
263
|
+
variable.hasRejection = true
|
|
264
|
+
break
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const calculateOptionalExpression =
|
|
270
|
+
(hasOptional1: boolean, hasOptional2: boolean) =>
|
|
271
|
+
(singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
|
|
272
|
+
if (variable.hasRejection) {
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
let foundExtraPossibility1 = false
|
|
276
|
+
let foundExtraPossibility2 = false
|
|
277
|
+
let foundCommonPossibility = false
|
|
278
|
+
|
|
279
|
+
switch (singleExpression) {
|
|
280
|
+
case ExpressionSingleResult.Equals: {
|
|
281
|
+
foundCommonPossibility = true
|
|
282
|
+
break
|
|
283
|
+
}
|
|
284
|
+
case ExpressionSingleResult.Containing: {
|
|
285
|
+
foundExtraPossibility1 = true
|
|
286
|
+
foundCommonPossibility = true
|
|
287
|
+
break
|
|
288
|
+
}
|
|
289
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
290
|
+
foundExtraPossibility2 = true
|
|
291
|
+
foundCommonPossibility = true
|
|
292
|
+
break
|
|
293
|
+
}
|
|
294
|
+
case ExpressionSingleResult.Intersection: {
|
|
295
|
+
foundExtraPossibility1 = true
|
|
296
|
+
foundExtraPossibility2 = true
|
|
297
|
+
foundCommonPossibility = true
|
|
298
|
+
break
|
|
299
|
+
}
|
|
300
|
+
case ExpressionSingleResult.Rejection: {
|
|
301
|
+
foundExtraPossibility1 = true
|
|
302
|
+
foundExtraPossibility2 = true
|
|
303
|
+
break
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (hasOptional1 && foundExtraPossibility1) {
|
|
307
|
+
variable.hasExtra1 = true
|
|
308
|
+
}
|
|
309
|
+
if (hasOptional2 && foundExtraPossibility2) {
|
|
310
|
+
variable.hasExtra2 = true
|
|
311
|
+
}
|
|
312
|
+
if (hasOptional1 && hasOptional2 && foundCommonPossibility) {
|
|
313
|
+
variable.hasCommonOutRequired = true
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
type PropertySchemaGetter<E> = (key: string) => Schema<E>
|
|
318
|
+
|
|
319
|
+
function createPropertySchemaGetter<E>(schema: CompiledSchema<E>): PropertySchemaGetter<E> {
|
|
320
|
+
const properties = schema.properties as Readonly<{ [key: string]: CompiledSchema<E> }> | undefined
|
|
321
|
+
const propertyNames = schema.propertyNames as CompiledSchema<E> | undefined
|
|
322
|
+
const additionalProperties = schema.additionalProperties as Schema<E> | undefined
|
|
323
|
+
const patternProperties: { pattern: RegExp; schema: Schema<E> }[] = []
|
|
324
|
+
|
|
325
|
+
if (schema.patternProperties) {
|
|
326
|
+
for (const pattern in schema.patternProperties) {
|
|
327
|
+
const valueSchema = schema.patternProperties[pattern] as Schema<E>
|
|
328
|
+
const regExp = new RegExp(pattern, 'i')
|
|
329
|
+
patternProperties.push({ pattern: regExp, schema: valueSchema })
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return (key) => {
|
|
333
|
+
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) {
|
|
334
|
+
return NEVER
|
|
335
|
+
}
|
|
336
|
+
for (const { pattern, schema: patternSchema } of patternProperties) {
|
|
337
|
+
if (pattern.test(key)) {
|
|
338
|
+
return patternSchema
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const propertySchema = (properties && properties[key]) ?? additionalProperties
|
|
342
|
+
|
|
343
|
+
if (!propertySchema) {
|
|
344
|
+
return ANY
|
|
345
|
+
}
|
|
346
|
+
return propertySchema
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function areNotBothNever<E>(schema1: Schema<E>, schema2: Schema<E>): boolean {
|
|
351
|
+
const kind1 = getKind(schema1)
|
|
352
|
+
const kind2 = getKind(schema2)
|
|
353
|
+
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never
|
|
354
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ExpressionSingleResult } from '../expression/index.ts'
|
|
2
|
+
import { splitRange } from './tools/index.ts'
|
|
3
|
+
|
|
4
|
+
export type RangeSplitter = (min1?: number, max1?: number, min2?: number, max2?: number) => RangeSplitResult
|
|
5
|
+
export type RangeSplitResult = {
|
|
6
|
+
readonly left?: RangeItem & { readonly isFrom1: boolean }
|
|
7
|
+
readonly right?: RangeItem & { readonly isFrom1: boolean }
|
|
8
|
+
readonly intersection?: RangeItem
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type RangeItem = {
|
|
12
|
+
readonly min: number
|
|
13
|
+
readonly max: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const createRangeSplitter =
|
|
17
|
+
(undefinedMin: number): RangeSplitter =>
|
|
18
|
+
(min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
|
|
19
|
+
const { left, center, right } = splitRange(
|
|
20
|
+
[
|
|
21
|
+
{ num: min1, exclusive: false },
|
|
22
|
+
{ num: max1, exclusive: false },
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
{ num: min2, exclusive: false },
|
|
26
|
+
{ num: max2, exclusive: false },
|
|
27
|
+
],
|
|
28
|
+
)
|
|
29
|
+
let leftItem: RangeSplitResult['left']
|
|
30
|
+
let rightItem: RangeSplitResult['right']
|
|
31
|
+
let intersectionItem: RangeSplitResult['intersection']
|
|
32
|
+
|
|
33
|
+
if (left) {
|
|
34
|
+
leftItem = {
|
|
35
|
+
min: left.range[0].num,
|
|
36
|
+
max: left.range[1].num,
|
|
37
|
+
isFrom1: left.fromLeft,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (right) {
|
|
41
|
+
rightItem = {
|
|
42
|
+
min: right.range[0].num,
|
|
43
|
+
max: right.range[1].num,
|
|
44
|
+
isFrom1: right.fromLeft,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (center) {
|
|
48
|
+
intersectionItem = {
|
|
49
|
+
min: center[0].num,
|
|
50
|
+
max: center[1].num,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
left: leftItem,
|
|
55
|
+
right: rightItem,
|
|
56
|
+
intersection: intersectionItem,
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function toExpressionSingleResult({ left, right, intersection }: RangeSplitResult): ExpressionSingleResult {
|
|
61
|
+
if (!intersection) {
|
|
62
|
+
return ExpressionSingleResult.Rejection
|
|
63
|
+
}
|
|
64
|
+
let extra1 = false
|
|
65
|
+
let extra2 = false
|
|
66
|
+
|
|
67
|
+
if (left) {
|
|
68
|
+
if (left.isFrom1) {
|
|
69
|
+
extra1 = true
|
|
70
|
+
} else {
|
|
71
|
+
extra2 = true
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (right) {
|
|
75
|
+
if (right.isFrom1) {
|
|
76
|
+
extra1 = true
|
|
77
|
+
} else {
|
|
78
|
+
extra2 = true
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (extra1 && extra2) {
|
|
82
|
+
return ExpressionSingleResult.Intersection
|
|
83
|
+
}
|
|
84
|
+
if (extra1) {
|
|
85
|
+
return ExpressionSingleResult.Containing
|
|
86
|
+
}
|
|
87
|
+
if (extra2) {
|
|
88
|
+
return ExpressionSingleResult.ContainedBy
|
|
89
|
+
}
|
|
90
|
+
return ExpressionSingleResult.Equals
|
|
91
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CompiledSchema } from '../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../expression/index.ts'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ExpressionAny,
|
|
6
|
+
ExpressionEquals,
|
|
7
|
+
ExpressionContaining,
|
|
8
|
+
ExpressionContainedBy,
|
|
9
|
+
ExpressionIntersection,
|
|
10
|
+
ExpressionRejection,
|
|
11
|
+
ExpressionSingleResult,
|
|
12
|
+
} from '../expression/index.ts'
|
|
13
|
+
import { createRangeSplitter, toExpressionSingleResult } from './range.ts'
|
|
14
|
+
|
|
15
|
+
const splitRange = createRangeSplitter(0)
|
|
16
|
+
|
|
17
|
+
export function calculateString<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
18
|
+
if (schema2.format && !schema1.format) return ExpressionContaining
|
|
19
|
+
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny
|
|
20
|
+
const splitResult = splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength)
|
|
21
|
+
const expression = toExpressionSingleResult(splitResult)
|
|
22
|
+
const hasPattern1 = !!schema1.pattern
|
|
23
|
+
const hasPattern2 = !!schema2.pattern
|
|
24
|
+
|
|
25
|
+
switch (expression) {
|
|
26
|
+
case ExpressionSingleResult.Rejection: {
|
|
27
|
+
return ExpressionRejection
|
|
28
|
+
}
|
|
29
|
+
case ExpressionSingleResult.Containing: {
|
|
30
|
+
return hasPattern1 ? ExpressionAny : ExpressionContaining
|
|
31
|
+
}
|
|
32
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
33
|
+
return hasPattern2 ? ExpressionAny : ExpressionContainedBy
|
|
34
|
+
}
|
|
35
|
+
case ExpressionSingleResult.Equals: {
|
|
36
|
+
if (hasPattern1 && hasPattern2) {
|
|
37
|
+
return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny
|
|
38
|
+
}
|
|
39
|
+
if (hasPattern1) {
|
|
40
|
+
return ExpressionEquals | ExpressionContainedBy
|
|
41
|
+
}
|
|
42
|
+
if (hasPattern2) {
|
|
43
|
+
return ExpressionEquals | ExpressionContaining
|
|
44
|
+
}
|
|
45
|
+
return ExpressionEquals
|
|
46
|
+
}
|
|
47
|
+
case ExpressionSingleResult.Intersection: {
|
|
48
|
+
if (hasPattern1 && hasPattern2) {
|
|
49
|
+
return ExpressionAny
|
|
50
|
+
}
|
|
51
|
+
if (hasPattern1) {
|
|
52
|
+
return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy
|
|
53
|
+
}
|
|
54
|
+
if (hasPattern2) {
|
|
55
|
+
return ExpressionIntersection | ExpressionRejection | ExpressionContaining
|
|
56
|
+
}
|
|
57
|
+
return ExpressionIntersection
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export type VariableBundle<K extends string> = {
|
|
2
|
+
[P in K]: boolean
|
|
3
|
+
} & {
|
|
4
|
+
toInt32(): number
|
|
5
|
+
toString(): string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class VariableBundleDescription<K extends string> {
|
|
9
|
+
public readonly keys: readonly K[]
|
|
10
|
+
private readonly clazz: { new (int32: number): VariableBundleImpls<K> }
|
|
11
|
+
|
|
12
|
+
public constructor(_keys: readonly K[]) {
|
|
13
|
+
const keys = Object.freeze(_keys.toSorted())
|
|
14
|
+
if (keys.length > 32) {
|
|
15
|
+
throw new Error(`cannot define ${keys.length} keys which is greater than 32`)
|
|
16
|
+
}
|
|
17
|
+
this.keys = keys
|
|
18
|
+
this.clazz = class extends VariableBundleImpls<K> {
|
|
19
|
+
public constructor(int32: number) {
|
|
20
|
+
super(keys, int32)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const [i, key] of this.keys.entries()) {
|
|
24
|
+
const mask = 1 << i
|
|
25
|
+
|
|
26
|
+
Object.defineProperty(this.clazz.prototype, key, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get(this: VariableBundleImpls<K>): boolean {
|
|
29
|
+
return !!(this.int32 & mask)
|
|
30
|
+
},
|
|
31
|
+
set: function set(this: VariableBundleImpls<K>, value: boolean): void {
|
|
32
|
+
if (value) {
|
|
33
|
+
this.int32 |= mask
|
|
34
|
+
} else {
|
|
35
|
+
this.int32 &= ~mask
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public toBundle(): VariableBundle<K>
|
|
43
|
+
public toBundle(int32: number): VariableBundle<K>
|
|
44
|
+
public toBundle(variable: Partial<Record<K, boolean>>): VariableBundle<K>
|
|
45
|
+
|
|
46
|
+
public toBundle(variable?: number | Partial<Record<K, boolean>>): VariableBundle<K> {
|
|
47
|
+
let int32 = 0
|
|
48
|
+
|
|
49
|
+
if (typeof variable === 'number') {
|
|
50
|
+
int32 = variable
|
|
51
|
+
} else if (variable) {
|
|
52
|
+
for (const [i, key] of this.keys.entries()) {
|
|
53
|
+
if (variable[key]) {
|
|
54
|
+
int32 |= 1 << i
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return new this.clazz(int32) as VariableBundle<K>
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
class VariableBundleImpls<K extends string> {
|
|
63
|
+
private readonly keys: readonly K[]
|
|
64
|
+
protected int32: number
|
|
65
|
+
|
|
66
|
+
public constructor(keys: readonly K[], int32: number) {
|
|
67
|
+
this.keys = keys
|
|
68
|
+
this.int32 = int32
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public toInt32(): number {
|
|
72
|
+
return this.int32
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public toString(): string {
|
|
76
|
+
const object: Record<string, boolean> = {}
|
|
77
|
+
for (const key of this.keys) {
|
|
78
|
+
object[key] = (this as unknown as Record<string, boolean>)[key]
|
|
79
|
+
}
|
|
80
|
+
return JSON.stringify(object)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ExpressionResult, ExpressionSingleResult } from '../../expression/index.ts'
|
|
2
|
+
import type { VariableBundle } from './mark.ts'
|
|
3
|
+
|
|
4
|
+
import { ExpressionMaskList } from '../../expression/index.ts'
|
|
5
|
+
import { VariableBundleDescription } from './mark.ts'
|
|
6
|
+
|
|
7
|
+
export interface Quantum<K extends string> {
|
|
8
|
+
readonly keys: readonly K[]
|
|
9
|
+
variable(variable?: Partial<Record<K, boolean>>): QuantumVariable<K>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
export type QuantumVariableType<Q extends Quantum<any>> = VariableBundle<Q['keys'][0]>
|
|
14
|
+
|
|
15
|
+
export interface QuantumVariable<K extends string> extends Iterable<VariableBundle<K>> {
|
|
16
|
+
assign(other: QuantumVariable<K>): this
|
|
17
|
+
push(expression: ExpressionResult, calculate: QuantumCalculator<K>): void
|
|
18
|
+
update(invoker: (variable: VariableBundle<K>) => void): void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type QuantumCalculator<K extends string> = (singleExpression: ExpressionSingleResult, variable: VariableBundle<K>) => void
|
|
22
|
+
|
|
23
|
+
export function makeQuantum<K extends string>(keys: readonly K[]): Quantum<K> {
|
|
24
|
+
return new QuantumImpls(keys)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class QuantumImpls<K extends string> {
|
|
28
|
+
private readonly description: VariableBundleDescription<K>
|
|
29
|
+
|
|
30
|
+
public constructor(keys: readonly K[]) {
|
|
31
|
+
this.description = new VariableBundleDescription(keys)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public get keys(): readonly K[] {
|
|
35
|
+
return this.description.keys
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public variable(variable?: Partial<Record<K, boolean>>): QuantumVariable<K> {
|
|
39
|
+
let int32: number | undefined
|
|
40
|
+
if (variable) {
|
|
41
|
+
int32 = this.description.toBundle(variable).toInt32()
|
|
42
|
+
}
|
|
43
|
+
return new QuantumVariableImpls(this.description, int32)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class QuantumVariableImpls<K extends string> implements QuantumVariable<K> {
|
|
48
|
+
private readonly description: VariableBundleDescription<K>
|
|
49
|
+
private values: Set<number> = new Set()
|
|
50
|
+
|
|
51
|
+
public constructor(description: VariableBundleDescription<K>, int32?: number) {
|
|
52
|
+
this.description = description
|
|
53
|
+
if (int32 !== undefined) {
|
|
54
|
+
this.values.add(int32)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public [Symbol.iterator](): Iterator<VariableBundle<K>> {
|
|
59
|
+
const iterator = this.values[Symbol.iterator]()
|
|
60
|
+
return {
|
|
61
|
+
next: (): IteratorResult<VariableBundle<K>> => {
|
|
62
|
+
const result = iterator.next()
|
|
63
|
+
if (result.done) {
|
|
64
|
+
return result
|
|
65
|
+
} else {
|
|
66
|
+
return {
|
|
67
|
+
done: false,
|
|
68
|
+
value: this.description.toBundle(result.value),
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public assign(other: QuantumVariable<K>): this {
|
|
76
|
+
const { values } = other as QuantumVariableImpls<K>
|
|
77
|
+
for (const int32 of values) {
|
|
78
|
+
this.values.add(int32)
|
|
79
|
+
}
|
|
80
|
+
return this
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
public push(expression: ExpressionResult, calculate: QuantumCalculator<K>): void {
|
|
84
|
+
const nextValues = new Set<number>()
|
|
85
|
+
for (const int32 of this.values) {
|
|
86
|
+
for (const [singleExpression, mask] of ExpressionMaskList) {
|
|
87
|
+
if (expression & mask) {
|
|
88
|
+
const variable = this.description.toBundle(int32)
|
|
89
|
+
calculate(singleExpression, variable)
|
|
90
|
+
nextValues.add(variable.toInt32())
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
this.values = nextValues
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public update(invoker: (variable: VariableBundle<K>) => void): void {
|
|
98
|
+
const nextValues = new Set<number>()
|
|
99
|
+
for (const int32 of this.values) {
|
|
100
|
+
const variable = this.description.toBundle(int32)
|
|
101
|
+
invoker(variable)
|
|
102
|
+
nextValues.add(variable.toInt32())
|
|
103
|
+
}
|
|
104
|
+
this.values = nextValues
|
|
105
|
+
}
|
|
106
|
+
}
|