@oomol-lab/open-flow 0.1.0-beta.73 → 0.1.0-beta.75
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 +41 -0
- package/dist/browser/{ContentIcon-CUQHjQIw.js → ContentIcon-FCpKiwjp.js} +2 -1
- package/dist/browser/{FlowCanvas-Dtf8_cQp.js → FlowCanvas-dzRBnlUT.js} +1 -1
- package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-BeYDdUl-.js} +2 -2
- package/dist/browser/{dialog-CUy_fwx9.js → dialog-ZtpsFbl4.js} +337 -31
- package/dist/browser/{exportSvg-BOoy7-Db.js → exportSvg-DqXw1yf-.js} +2 -2
- package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-b_5UobFj.js} +586 -87
- package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-ItojZbO4.js} +21162 -20242
- package/dist/browser/preview.css +254 -179
- package/dist/browser/preview.js +22201 -20625
- package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
- package/dist/browser/ui.css +72 -2
- package/dist/browser/workbench.css +254 -179
- package/dist/browser/workbench.js +22 -78
- package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-M441Lz0d.js} +1 -1
- package/dist/command/index.js +42 -42
- package/dist/common/authoring.d.ts +5 -5
- package/dist/common/authoringExamples.d.ts +3 -2
- package/dist/common/authoringFields.d.ts +1 -1
- package/dist/common/authoringSchema.d.ts +95 -8
- 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 +119 -31
- package/dist/common/control-api.d.ts +4 -3
- package/dist/common/control-api.js +117 -29
- package/dist/common/control-requests.d.ts +5 -4
- package/dist/common/control-requests.js +437 -103
- 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 +4 -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 +131 -30
- 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 +133 -32
- package/dist/common/flow-connectionUsage.d.ts +1 -1
- package/dist/common/flow-encoding.d.ts +1 -1
- package/dist/common/flow-encoding.js +89 -23
- package/dist/common/flow-errorHandling.d.ts +1 -1
- package/dist/common/flow-graph.d.ts +3 -2
- 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 +2 -2
- package/dist/common/flow-semantics.d.ts +1 -1
- package/dist/common/flow-semantics.js +966 -614
- package/dist/common/flow-workflowFile.d.ts +1 -1
- package/dist/common/flowInspection.d.ts +3 -3
- package/dist/common/http-request.d.ts +156 -0
- package/dist/common/http-request.js +5254 -0
- 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 +5 -4
- package/dist/common/mcp.js +117 -29
- package/dist/common/openapi.d.ts +1 -1
- package/dist/common/poll-trigger.d.ts +1 -1
- package/dist/common/run-events.js +11 -9
- package/dist/common/run-results.d.ts +8 -1
- package/dist/common/runtime-contract.d.ts +8 -2
- package/dist/common/runtime-contract.js +25 -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 +3 -3
- package/dist/common/scheduler.js +101 -33
- 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 -3
- package/dist/common/webhook-trigger.d.ts +1 -1
- package/dist/common/webhook-trigger.js +12 -11
- 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 +11 -6
- package/skills/open-flow/references/flow-authoring.md +1 -0
- package/skills/open-flow/references/flow-n8n-conversion.md +19 -15
- 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 +1506 -0
- package/src/control/common/authoring.ts +923 -0
- package/src/control/common/authoringCondition.ts +110 -0
- package/src/control/common/authoringDiagnosticFields.ts +136 -0
- package/src/control/common/authoringExamples.ts +200 -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 +410 -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 +84 -0
- package/src/execution/common/events.ts +331 -0
- package/src/execution/common/node-execution.ts +469 -0
- package/src/execution/common/runLifecycle.ts +250 -0
- package/src/execution/common/runtime.ts +563 -0
- package/src/execution/common/scheduler.ts +697 -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 +1037 -0
- package/src/flow/common/changeSchema.ts +792 -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 +898 -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 +531 -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 +71 -0
- package/src/flow/common/workflowFile.ts +97 -0
- package/src/http/common/authBindings.ts +12 -0
- package/src/http/common/headers.ts +5 -0
- package/src/http/common/httpRequest.ts +251 -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/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 +413 -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,49 @@
|
|
|
1
|
+
import type { ExpressionResult, ExpressionSingleResult } from './result.ts'
|
|
2
|
+
|
|
3
|
+
import { ExpressionAny, ExpressionMaskList, ExpressionNone } from './result.ts'
|
|
4
|
+
|
|
5
|
+
export type SingleCalculator = (e1: ExpressionSingleResult, e2: ExpressionSingleResult) => ExpressionResult
|
|
6
|
+
export interface Combination {
|
|
7
|
+
readonly result: ExpressionResult
|
|
8
|
+
readonly count: number
|
|
9
|
+
push(expression: ExpressionResult): ExpressionResult
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function makeCombination(calculator: SingleCalculator): Combination {
|
|
13
|
+
let expression: ExpressionResult = ExpressionNone
|
|
14
|
+
let count = 0
|
|
15
|
+
|
|
16
|
+
const quantum = {
|
|
17
|
+
push: (newExpression: ExpressionResult): ExpressionResult => {
|
|
18
|
+
if (count === 0) {
|
|
19
|
+
expression = newExpression
|
|
20
|
+
} else {
|
|
21
|
+
expression = forEach(expression, newExpression, calculator)
|
|
22
|
+
}
|
|
23
|
+
count += 1
|
|
24
|
+
return expression
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
Object.defineProperties(quantum, {
|
|
28
|
+
result: { get: () => expression },
|
|
29
|
+
count: { get: () => count },
|
|
30
|
+
})
|
|
31
|
+
return quantum as Combination
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function forEach(e1: ExpressionResult, e2: ExpressionResult, calculator: SingleCalculator): ExpressionResult {
|
|
35
|
+
let expression: ExpressionResult = ExpressionNone
|
|
36
|
+
for (const [singleResult1, mask1] of ExpressionMaskList) {
|
|
37
|
+
if (mask1 & e1) {
|
|
38
|
+
for (const [singleResult2, mask2] of ExpressionMaskList) {
|
|
39
|
+
if (mask2 & e2) {
|
|
40
|
+
expression |= calculator(singleResult1, singleResult2)
|
|
41
|
+
if (expression === ExpressionAny) {
|
|
42
|
+
return expression
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return expression
|
|
49
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { ExpressionResult } from './result.ts'
|
|
2
|
+
import type { Calculator, ExpressionDelegate, ExpressionDescription } from './types.ts'
|
|
3
|
+
|
|
4
|
+
import { calculate, swap, CalculatorOperator } from './calculator.ts'
|
|
5
|
+
import { ExpressionContainedBy, ExpressionEquals, ExpressionNone } from './result.ts'
|
|
6
|
+
import { ExpressionKind } from './types.ts'
|
|
7
|
+
|
|
8
|
+
type Parent<E extends object> = {
|
|
9
|
+
readonly node: Node<E>
|
|
10
|
+
readonly index: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Node<E extends object> = {
|
|
14
|
+
readonly parent: Parent<E> | null
|
|
15
|
+
readonly swapped: boolean
|
|
16
|
+
expressions: [E, E] | null
|
|
17
|
+
calculation: Calculation | null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type Calculation = {
|
|
21
|
+
readonly operator: CalculatorOperator
|
|
22
|
+
readonly results: ExpressionResult[]
|
|
23
|
+
readonly willSwap: boolean
|
|
24
|
+
count: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const expression =
|
|
28
|
+
<E extends object>(delegate: ExpressionDelegate<E>): Calculator<E> =>
|
|
29
|
+
(e1, e2) => {
|
|
30
|
+
const rootNode: Node<E> = {
|
|
31
|
+
parent: null,
|
|
32
|
+
swapped: false,
|
|
33
|
+
expressions: null,
|
|
34
|
+
calculation: {
|
|
35
|
+
operator: CalculatorOperator.Save,
|
|
36
|
+
results: [ExpressionNone],
|
|
37
|
+
willSwap: false,
|
|
38
|
+
count: 0,
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
// Nodes awaiting expansion.
|
|
42
|
+
const extendQueue: Node<E>[] = [
|
|
43
|
+
{
|
|
44
|
+
parent: { node: rootNode, index: 0 },
|
|
45
|
+
swapped: false,
|
|
46
|
+
expressions: [e1, e2],
|
|
47
|
+
calculation: null,
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
// Nodes whose leaf results are ready to calculate.
|
|
51
|
+
const calculateQueue: Node<E>[] = []
|
|
52
|
+
|
|
53
|
+
while (extendQueue.length > 0 || calculateQueue.length > 0) {
|
|
54
|
+
while (extendQueue.length > 0) {
|
|
55
|
+
const node = extendQueue.pop()!
|
|
56
|
+
extendNode(node)
|
|
57
|
+
}
|
|
58
|
+
while (calculateQueue.length > 0) {
|
|
59
|
+
const node = calculateQueue.pop()!
|
|
60
|
+
calculateNode(node)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function extendNode(node: Node<E>): void {
|
|
65
|
+
let result: ExpressionResult = ExpressionEquals
|
|
66
|
+
const [leftExpression, rightExpression] = node.expressions!
|
|
67
|
+
|
|
68
|
+
if (!delegate.equals(leftExpression, rightExpression)) {
|
|
69
|
+
const expression1 = delegate.describe(leftExpression)
|
|
70
|
+
|
|
71
|
+
if (expression1.kind !== ExpressionKind.Leaf) {
|
|
72
|
+
const willSwap = false
|
|
73
|
+
const [calculation, expressions] = expendExpression(expression1, willSwap)
|
|
74
|
+
node.expressions = null
|
|
75
|
+
node.calculation = calculation
|
|
76
|
+
|
|
77
|
+
for (const [index, childExpression] of expressions.entries()) {
|
|
78
|
+
extendQueue.push({
|
|
79
|
+
parent: { node, index },
|
|
80
|
+
swapped: node.swapped,
|
|
81
|
+
expressions: [childExpression, rightExpression],
|
|
82
|
+
calculation: null,
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
const expression2 = delegate.describe(rightExpression)
|
|
88
|
+
|
|
89
|
+
if (expression2.kind !== ExpressionKind.Leaf) {
|
|
90
|
+
const willSwap = true
|
|
91
|
+
const [calculation, expressions] = expendExpression(expression2, willSwap)
|
|
92
|
+
node.expressions = null
|
|
93
|
+
node.calculation = calculation
|
|
94
|
+
|
|
95
|
+
for (const [index, childExpression] of expressions.entries()) {
|
|
96
|
+
extendQueue.push({
|
|
97
|
+
parent: { node, index },
|
|
98
|
+
swapped: !node.swapped,
|
|
99
|
+
expressions: [childExpression, leftExpression],
|
|
100
|
+
calculation: null,
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
result = delegate.calculate(leftExpression, rightExpression)
|
|
106
|
+
delegate.observeCalculation?.(leftExpression, rightExpression, result, node.swapped)
|
|
107
|
+
|
|
108
|
+
if (result === ExpressionNone) {
|
|
109
|
+
throw new Error('cannot response expression as none')
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
node.expressions = null
|
|
113
|
+
node.calculation = {
|
|
114
|
+
operator: CalculatorOperator.Save,
|
|
115
|
+
results: [result],
|
|
116
|
+
willSwap: false,
|
|
117
|
+
count: 0,
|
|
118
|
+
}
|
|
119
|
+
calculateQueue.push(node)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function expendExpression(description: ExpressionDescription<E>, willSwap: boolean): [Calculation, E[]] {
|
|
123
|
+
let operator: CalculatorOperator = CalculatorOperator.Save
|
|
124
|
+
let expressions: E[]
|
|
125
|
+
|
|
126
|
+
switch (description.kind) {
|
|
127
|
+
case ExpressionKind.Not: {
|
|
128
|
+
operator = CalculatorOperator.Not
|
|
129
|
+
expressions = [description.expression]
|
|
130
|
+
break
|
|
131
|
+
}
|
|
132
|
+
case ExpressionKind.AllOf: {
|
|
133
|
+
operator = CalculatorOperator.AllOf
|
|
134
|
+
expressions = [...description.expressions]
|
|
135
|
+
break
|
|
136
|
+
}
|
|
137
|
+
case ExpressionKind.AnyOf: {
|
|
138
|
+
operator = CalculatorOperator.AnyOf
|
|
139
|
+
expressions = [...description.expressions]
|
|
140
|
+
break
|
|
141
|
+
}
|
|
142
|
+
case ExpressionKind.OneOf: {
|
|
143
|
+
operator = CalculatorOperator.OneOf
|
|
144
|
+
expressions = [...description.expressions]
|
|
145
|
+
break
|
|
146
|
+
}
|
|
147
|
+
default: {
|
|
148
|
+
throw new Error(`invalid kind ${description.kind}`)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const calculation: Calculation = {
|
|
152
|
+
operator,
|
|
153
|
+
willSwap,
|
|
154
|
+
count: 0,
|
|
155
|
+
results: Array(expressions.length).fill(-1),
|
|
156
|
+
}
|
|
157
|
+
return [calculation, expressions]
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function calculateNode(node: Node<E>): void {
|
|
161
|
+
const calculation = node.calculation!
|
|
162
|
+
const parent = node.parent
|
|
163
|
+
let result = calculate(calculation.operator, calculation.results)
|
|
164
|
+
|
|
165
|
+
if (result === ExpressionNone) {
|
|
166
|
+
// AllOf assumes the left intersection is not empty, but this defensive fallback still handles an empty result.
|
|
167
|
+
// A forced None result therefore makes the left side equivalent to never.
|
|
168
|
+
result = ExpressionContainedBy
|
|
169
|
+
}
|
|
170
|
+
if (calculation.willSwap) {
|
|
171
|
+
result = swap(result)
|
|
172
|
+
}
|
|
173
|
+
if (parent) {
|
|
174
|
+
const parentCalculation = parent.node.calculation!
|
|
175
|
+
const parentResults = parentCalculation.results
|
|
176
|
+
|
|
177
|
+
parentResults[parent.index] = result
|
|
178
|
+
parentCalculation.count += 1
|
|
179
|
+
|
|
180
|
+
if (parentCalculation.count >= parentResults.length) {
|
|
181
|
+
calculateQueue.push(parent.node)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const result = rootNode.calculation!.results[0]
|
|
187
|
+
if (result === 0) {
|
|
188
|
+
throw new Error('cannot find result of root')
|
|
189
|
+
}
|
|
190
|
+
return result
|
|
191
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type { ExpressionResult } from './result.ts'
|
|
2
|
+
export type { Calculator, Describer, Equaler, ExpressionDelegate, ExpressionDescription } from './types.ts'
|
|
3
|
+
|
|
4
|
+
export { expression } from './expression.ts'
|
|
5
|
+
export { ExpressionKind } from './types.ts'
|
|
6
|
+
export { swap } from './calculator.ts'
|
|
7
|
+
export {
|
|
8
|
+
toString,
|
|
9
|
+
hasEquals,
|
|
10
|
+
hasContaining,
|
|
11
|
+
hasContainedBy,
|
|
12
|
+
hasIntersection,
|
|
13
|
+
hasRejection,
|
|
14
|
+
toExpression,
|
|
15
|
+
toSingleExpression,
|
|
16
|
+
ExpressionNone,
|
|
17
|
+
ExpressionAny,
|
|
18
|
+
ExpressionEquals,
|
|
19
|
+
ExpressionContaining,
|
|
20
|
+
ExpressionContainedBy,
|
|
21
|
+
ExpressionIntersection,
|
|
22
|
+
ExpressionRejection,
|
|
23
|
+
ExpressionMaskList,
|
|
24
|
+
ExpressionSingleResult,
|
|
25
|
+
} from './result.ts'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { DeepReadonly } from '../utils.ts'
|
|
2
|
+
|
|
3
|
+
import { deepFreeze } from '../utils.ts'
|
|
4
|
+
|
|
5
|
+
export type ExpressionResult = number
|
|
6
|
+
|
|
7
|
+
export const ExpressionSingleResult = Object.freeze({
|
|
8
|
+
Equals: 0,
|
|
9
|
+
Containing: 1,
|
|
10
|
+
ContainedBy: 2,
|
|
11
|
+
Rejection: 3,
|
|
12
|
+
Intersection: 4,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export type ExpressionSingleResult = (typeof ExpressionSingleResult)[keyof typeof ExpressionSingleResult]
|
|
16
|
+
|
|
17
|
+
export const ExpressionEquals = toExpression(ExpressionSingleResult.Equals)
|
|
18
|
+
export const ExpressionContaining = toExpression(ExpressionSingleResult.Containing)
|
|
19
|
+
export const ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy)
|
|
20
|
+
export const ExpressionRejection = toExpression(ExpressionSingleResult.Rejection)
|
|
21
|
+
export const ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection)
|
|
22
|
+
|
|
23
|
+
export const ExpressionMaskList: DeepReadonly<[ExpressionSingleResult, ExpressionResult][]> = deepFreeze([
|
|
24
|
+
[ExpressionSingleResult.Equals, ExpressionEquals],
|
|
25
|
+
[ExpressionSingleResult.Containing, ExpressionContaining],
|
|
26
|
+
[ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
|
|
27
|
+
[ExpressionSingleResult.Rejection, ExpressionRejection],
|
|
28
|
+
[ExpressionSingleResult.Intersection, ExpressionIntersection],
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
export const ExpressionNone = 0
|
|
32
|
+
export const ExpressionAny = ((): ExpressionResult => {
|
|
33
|
+
let expression = ExpressionNone
|
|
34
|
+
for (const [_, mask] of ExpressionMaskList) {
|
|
35
|
+
expression |= mask
|
|
36
|
+
}
|
|
37
|
+
return expression
|
|
38
|
+
})()
|
|
39
|
+
|
|
40
|
+
export function toString(expression: ExpressionResult): string {
|
|
41
|
+
const strList: string[] = [
|
|
42
|
+
hasEquals(expression) ? 'E' : '_',
|
|
43
|
+
hasContaining(expression) ? 'C' : '_',
|
|
44
|
+
hasContainedBy(expression) ? 'B' : '_',
|
|
45
|
+
hasRejection(expression) ? 'R' : '_',
|
|
46
|
+
hasIntersection(expression) ? 'I' : '_',
|
|
47
|
+
]
|
|
48
|
+
return strList.join('')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function hasEquals(expression: ExpressionResult): boolean {
|
|
52
|
+
return !!(expression & ExpressionEquals)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function hasContaining(expression: ExpressionResult): boolean {
|
|
56
|
+
return !!(expression & ExpressionContaining)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function hasContainedBy(expression: ExpressionResult): boolean {
|
|
60
|
+
return !!(expression & ExpressionContainedBy)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function hasRejection(expression: ExpressionResult): boolean {
|
|
64
|
+
return !!(expression & ExpressionRejection)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function hasIntersection(expression: ExpressionResult): boolean {
|
|
68
|
+
return !!(expression & ExpressionIntersection)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function toExpression(expression: ExpressionSingleResult): ExpressionResult {
|
|
72
|
+
return 1 << expression
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function toSingleExpression(expression: ExpressionResult): ExpressionSingleResult | -1 {
|
|
76
|
+
let result: ExpressionSingleResult | -1 = -1
|
|
77
|
+
for (const [singleResult, mask] of ExpressionMaskList) {
|
|
78
|
+
if (mask & expression) {
|
|
79
|
+
if (result !== -1) {
|
|
80
|
+
// A second single result means that the expression is not singular.
|
|
81
|
+
result = -1
|
|
82
|
+
break
|
|
83
|
+
}
|
|
84
|
+
result = singleResult
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result
|
|
88
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExpressionResult } from './result.ts'
|
|
2
|
+
|
|
3
|
+
export type ExpressionDescription<E> =
|
|
4
|
+
| {
|
|
5
|
+
readonly kind: typeof ExpressionKind.Leaf
|
|
6
|
+
}
|
|
7
|
+
| {
|
|
8
|
+
readonly kind: typeof ExpressionKind.Not
|
|
9
|
+
readonly expression: E
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
readonly kind: typeof ExpressionKind.AllOf | typeof ExpressionKind.AnyOf | typeof ExpressionKind.OneOf
|
|
13
|
+
readonly expressions: Iterable<E>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const ExpressionKind = Object.freeze({
|
|
17
|
+
Leaf: 0,
|
|
18
|
+
Not: 1,
|
|
19
|
+
AllOf: 2,
|
|
20
|
+
AnyOf: 3,
|
|
21
|
+
OneOf: 4,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export type ExpressionKind = (typeof ExpressionKind)[keyof typeof ExpressionKind]
|
|
25
|
+
|
|
26
|
+
export type Calculator<E> = (e1: E, e2: E) => ExpressionResult
|
|
27
|
+
export type Equaler<E> = (e1: E, e2: E) => boolean
|
|
28
|
+
export type Describer<E> = (e: E) => ExpressionDescription<E>
|
|
29
|
+
export type CalculationObserver<E> = (e1: E, e2: E, result: ExpressionResult, swapped: boolean) => void
|
|
30
|
+
|
|
31
|
+
export type ExpressionDelegate<E> = {
|
|
32
|
+
readonly describe: Describer<E>
|
|
33
|
+
readonly equals: Equaler<E>
|
|
34
|
+
readonly calculate: Calculator<E>
|
|
35
|
+
readonly observeCalculation?: CalculationObserver<E> | undefined
|
|
36
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ExpressionResult } from '../expression/index.ts'
|
|
2
|
+
import type { Schema } from '../types.ts'
|
|
3
|
+
import type { ExtendsSchema, ExtendsSchemaClass } from './types.ts'
|
|
4
|
+
|
|
5
|
+
import { toExpression, ExpressionNone, ExpressionSingleResult } from '../expression/index.ts'
|
|
6
|
+
import { createId } from '../utils.ts'
|
|
7
|
+
|
|
8
|
+
export class ExtendsContext {
|
|
9
|
+
private readonly extendsSchemaClasses: readonly ExtendsSchemaClass[]
|
|
10
|
+
|
|
11
|
+
public constructor(extendsSchemaClasses: readonly ExtendsSchemaClass[] = []) {
|
|
12
|
+
this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses])
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public tryCompiledExtendsSchema(target: object, payload?: unknown): ExtendsSchema | null {
|
|
16
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) {
|
|
17
|
+
if (extendsSchemaClass.isMatch(target)) {
|
|
18
|
+
return new extendsSchemaClass(createId(), target, payload)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public isExtendsSchema(target: object): target is ExtendsSchema {
|
|
25
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) {
|
|
26
|
+
if (target instanceof extendsSchemaClass) {
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public calculate(schema1: Schema<unknown>, schema2: Schema<unknown>): ExpressionResult {
|
|
34
|
+
const schemaClass = this.findMatchedClass(schema1, schema2)
|
|
35
|
+
const shouldSwap = !(schema1 instanceof schemaClass)
|
|
36
|
+
|
|
37
|
+
let expressionResult: ExpressionResult = ExpressionNone
|
|
38
|
+
let result: readonly ExpressionSingleResult[]
|
|
39
|
+
|
|
40
|
+
if (shouldSwap) {
|
|
41
|
+
result = (schema2 as ExtendsSchema).compare(schema1)
|
|
42
|
+
} else {
|
|
43
|
+
result = schema1.compare(schema2)
|
|
44
|
+
}
|
|
45
|
+
for (let expression of result) {
|
|
46
|
+
if (shouldSwap) {
|
|
47
|
+
expression = ExtendsContext.swap(expression)
|
|
48
|
+
}
|
|
49
|
+
expressionResult |= toExpression(expression)
|
|
50
|
+
}
|
|
51
|
+
return expressionResult
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public equals(schema1: Schema<unknown>, schema2: Schema<unknown>): boolean {
|
|
55
|
+
const schemaClass = this.findMatchedClass(schema1, schema2)
|
|
56
|
+
const shouldSwap = !(schema1 instanceof schemaClass)
|
|
57
|
+
if (shouldSwap) {
|
|
58
|
+
return (schema2 as ExtendsSchema).equals(schema1)
|
|
59
|
+
} else {
|
|
60
|
+
return schema1.equals(schema2)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private findMatchedClass(schema1: Schema<unknown>, schema2: Schema<unknown>): ExtendsSchemaClass {
|
|
65
|
+
for (const schemaClass of this.extendsSchemaClasses) {
|
|
66
|
+
if (schema1 instanceof schemaClass) {
|
|
67
|
+
return schemaClass
|
|
68
|
+
}
|
|
69
|
+
if (schema2 instanceof schemaClass) {
|
|
70
|
+
return schemaClass
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
throw new Error('Invalid schema')
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private static swap(expression: ExpressionSingleResult): ExpressionSingleResult {
|
|
77
|
+
switch (expression) {
|
|
78
|
+
case ExpressionSingleResult.Containing: {
|
|
79
|
+
return ExpressionSingleResult.ContainedBy
|
|
80
|
+
}
|
|
81
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
82
|
+
return ExpressionSingleResult.Containing
|
|
83
|
+
}
|
|
84
|
+
default: {
|
|
85
|
+
return expression
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExpressionSingleResult } from '../expression/index.ts'
|
|
2
|
+
|
|
3
|
+
export interface ExtendsSchemaClass {
|
|
4
|
+
new (id: number, value: unknown, payload?: unknown): ExtendsSchema
|
|
5
|
+
isMatch(value: unknown): boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ExtendsSchema {
|
|
9
|
+
readonly id: number
|
|
10
|
+
compare(other: unknown): readonly ExpressionSingleResult[]
|
|
11
|
+
equals(other: unknown): boolean
|
|
12
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { CompilableSchema, InputSchema } from './compiler/index.ts'
|
|
2
|
+
import type { ExtendsSchemaClass } from './extends/index.ts'
|
|
3
|
+
import type { Compiler } from './preprocessing.ts'
|
|
4
|
+
import type { Schema } from './types.ts'
|
|
5
|
+
import type { JSONDelegate } from './types.ts'
|
|
6
|
+
|
|
7
|
+
import { checkWithResult } from './checker/checker.ts'
|
|
8
|
+
import { compile } from './compiler/index.ts'
|
|
9
|
+
import { hasContainedBy, hasContaining, hasEquals, hasIntersection, hasRejection } from './expression/index.ts'
|
|
10
|
+
import { ExtendsContext } from './extends/index.ts'
|
|
11
|
+
import { preprocessSchema, preprocessSchemasPair } from './preprocessing.ts'
|
|
12
|
+
|
|
13
|
+
export type MakingParams<E> = {
|
|
14
|
+
readonly extendsSchemaClasses?: readonly ExtendsSchemaClass[]
|
|
15
|
+
readonly delegate?: JSONDelegate<E>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SubsetCompare<E> {
|
|
19
|
+
compile(schema: InputSchema, payload?: unknown, printWarnLog?: boolean): Schema<E>
|
|
20
|
+
isSubset(superSchema: CompilableSchema<E>, subSchema: CompilableSchema<E>, printWarnLog?: boolean): SubsetComparison
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SubsetComparison {
|
|
24
|
+
readonly errorPath?: readonly (string | number)[] | undefined
|
|
25
|
+
readonly result: SubsetCompareResult
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const SubsetCompareResult = Object.freeze({
|
|
29
|
+
True: 0,
|
|
30
|
+
False: 1,
|
|
31
|
+
Unknown: 2,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export type SubsetCompareResult = (typeof SubsetCompareResult)[keyof typeof SubsetCompareResult]
|
|
35
|
+
|
|
36
|
+
export function makeSubsetCompare<E = unknown>({ extendsSchemaClasses, delegate }: MakingParams<E> = {}): SubsetCompare<E> {
|
|
37
|
+
const extendsContext = new ExtendsContext(extendsSchemaClasses)
|
|
38
|
+
const comparer: SubsetCompare<E> = Object.freeze({
|
|
39
|
+
compile: (schema: InputSchema, payload?: unknown, printWarnLog?: boolean): Schema<E> => {
|
|
40
|
+
const compiler: Compiler<E> = (candidate) => compile(candidate, extendsContext, payload, delegate)
|
|
41
|
+
return preprocessSchema(schema, compiler, printWarnLog)
|
|
42
|
+
},
|
|
43
|
+
isSubset: (superSchema: CompilableSchema<E>, subSchema: CompilableSchema<E>, printWarnLog = false): SubsetComparison => {
|
|
44
|
+
const compiler: Compiler<E> = (candidate) => compile(candidate, extendsContext, undefined, delegate)
|
|
45
|
+
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog)
|
|
46
|
+
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2)
|
|
47
|
+
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression)
|
|
48
|
+
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression)
|
|
49
|
+
|
|
50
|
+
if (foundTrueExpression && !foundFalseExpression) {
|
|
51
|
+
return { result: SubsetCompareResult.True }
|
|
52
|
+
}
|
|
53
|
+
if (!foundTrueExpression && foundFalseExpression) {
|
|
54
|
+
return { errorPath, result: SubsetCompareResult.False }
|
|
55
|
+
}
|
|
56
|
+
return { result: SubsetCompareResult.Unknown }
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
return comparer
|
|
60
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { SubsetCompare, SubsetComparison } from './global.ts'
|
|
2
|
+
export type { Schema, JSONDelegate } from './types.ts'
|
|
3
|
+
export type { ExtendsSchema, ExtendsSchemaClass } from './extends/index.ts'
|
|
4
|
+
export type { InputSchema, CompiledSchema } from './compiler/index.ts'
|
|
5
|
+
export type { SchemaError } from './error.ts'
|
|
6
|
+
|
|
7
|
+
export { ExpressionSingleResult } from './expression/index.ts'
|
|
8
|
+
export { makeSubsetCompare, SubsetCompareResult } from './global.ts'
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { CompilableSchema, CompileResult } from './compiler/index.ts'
|
|
2
|
+
import type { CompiledSchemaErrorItem, SchemaErrorItem } from './error.ts'
|
|
3
|
+
import type { Schema } from './types.ts'
|
|
4
|
+
|
|
5
|
+
import { SchemaError, stringifySchemaError } from './error.ts'
|
|
6
|
+
|
|
7
|
+
export type Compiler<E> = (schema: CompilableSchema<E>) => CompileResult<E> | readonly SchemaErrorItem<E>[]
|
|
8
|
+
|
|
9
|
+
export function preprocessSchema<E>(schema: CompilableSchema<E>, compile: Compiler<E>, printWarnLog = false): Schema<E> {
|
|
10
|
+
const schemaResult = compile(schema)
|
|
11
|
+
if (Array.isArray(schemaResult)) {
|
|
12
|
+
const errorItems: SchemaErrorItem[] = []
|
|
13
|
+
collectWithPathPrefix(errorItems, schemaResult, '$')
|
|
14
|
+
throw new SchemaError(errorItems)
|
|
15
|
+
}
|
|
16
|
+
const { schema: compiledSchema, warns } = schemaResult as CompileResult<E>
|
|
17
|
+
if (printWarnLog && warns.length > 0) {
|
|
18
|
+
console.warn(`found ${warns.length} warns after compile schema`)
|
|
19
|
+
for (const warn of warns) {
|
|
20
|
+
console.warn(stringifySchemaError(warn))
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return compiledSchema
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function preprocessSchemasPair<E>(
|
|
27
|
+
schema1: CompilableSchema<E>,
|
|
28
|
+
schema2: CompilableSchema<E>,
|
|
29
|
+
compile: Compiler<E>,
|
|
30
|
+
printWarnLog = false,
|
|
31
|
+
): [Schema<E>, Schema<E>] {
|
|
32
|
+
const schemaResult1 = compile(schema1)
|
|
33
|
+
const schemaResult2 = compile(schema2)
|
|
34
|
+
|
|
35
|
+
if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
|
|
36
|
+
const errorItems: SchemaErrorItem[] = []
|
|
37
|
+
|
|
38
|
+
if (Array.isArray(schemaResult1)) {
|
|
39
|
+
collectWithPathPrefix(errorItems, schemaResult1, '$1')
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(schemaResult2)) {
|
|
42
|
+
collectWithPathPrefix(errorItems, schemaResult2, '$2')
|
|
43
|
+
}
|
|
44
|
+
throw new SchemaError(errorItems)
|
|
45
|
+
}
|
|
46
|
+
const { schema: compiledSchema1, warns: superWarns } = schemaResult1 as CompileResult<E>
|
|
47
|
+
const { schema: compiledSchema2, warns: subWarns } = schemaResult2 as CompileResult<E>
|
|
48
|
+
|
|
49
|
+
if (printWarnLog) {
|
|
50
|
+
if (superWarns.length > 0) {
|
|
51
|
+
console.warn(`found ${superWarns.length} warns after compile superSchema`)
|
|
52
|
+
}
|
|
53
|
+
for (const warn of superWarns) {
|
|
54
|
+
console.warn(stringifySchemaError(warn))
|
|
55
|
+
}
|
|
56
|
+
if (subWarns.length > 0) {
|
|
57
|
+
console.warn(`found ${subWarns.length} warns after compile subSchema`)
|
|
58
|
+
}
|
|
59
|
+
for (const warn of subWarns) {
|
|
60
|
+
console.warn(stringifySchemaError(warn))
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return [compiledSchema1, compiledSchema2]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function collectWithPathPrefix(errorItems: SchemaErrorItem[], compiledItems: readonly CompiledSchemaErrorItem[], prefix: number | string): void {
|
|
67
|
+
for (const compiledItem of compiledItems) {
|
|
68
|
+
const replacedItem: SchemaErrorItem = {
|
|
69
|
+
...compiledItem,
|
|
70
|
+
path: [prefix, ...compiledItem.path],
|
|
71
|
+
}
|
|
72
|
+
errorItems.push(replacedItem)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompiledSchema } from './compiler/index.ts'
|
|
2
|
+
import type { ExtendsSchema } from './extends/index.ts'
|
|
3
|
+
|
|
4
|
+
export type Schema<E> = ExtendsSchema | CompiledSchema<E>
|
|
5
|
+
export interface JSONDelegate<E = unknown> {
|
|
6
|
+
isSchema(schema: object): boolean | readonly E[]
|
|
7
|
+
compile(schema: object): (value: unknown) => boolean | readonly E[]
|
|
8
|
+
}
|