@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,230 @@
|
|
|
1
|
+
import type { JSONSchema7Definition } from 'json-schema'
|
|
2
|
+
import type { CompiledSchema, SchemaPath } from '../compiler/index.ts'
|
|
3
|
+
import type { Calculator, Describer, ExpressionDescription, ExpressionResult } from '../expression/index.ts'
|
|
4
|
+
import type { ExtendsContext } from '../extends/index.ts'
|
|
5
|
+
import type { Schema } from '../types.ts'
|
|
6
|
+
import type { DeepReadonly } from '../utils.ts'
|
|
7
|
+
import type { Context } from './cache.ts'
|
|
8
|
+
|
|
9
|
+
import { CompiledKind, getKind, getPath } from '../compiler/index.ts'
|
|
10
|
+
import {
|
|
11
|
+
swap,
|
|
12
|
+
expression,
|
|
13
|
+
ExpressionKind,
|
|
14
|
+
ExpressionEquals,
|
|
15
|
+
ExpressionContaining,
|
|
16
|
+
ExpressionContainedBy,
|
|
17
|
+
ExpressionRejection,
|
|
18
|
+
hasContainedBy,
|
|
19
|
+
hasEquals,
|
|
20
|
+
hasContaining,
|
|
21
|
+
hasIntersection,
|
|
22
|
+
hasRejection,
|
|
23
|
+
} from '../expression/index.ts'
|
|
24
|
+
import { isDeepEquals } from '../utils.ts'
|
|
25
|
+
import { calculateArray } from './array.ts'
|
|
26
|
+
import { wrapEqualsCheckerWithCache, wrapSchemaCalculatorWithCache } from './cache.ts'
|
|
27
|
+
import { calculateEnumAndEnum, calculateEnumAndSchema } from './enumAndConst.ts'
|
|
28
|
+
import { schemaEqualsChecker } from './equals.ts'
|
|
29
|
+
import { calculateNumeric } from './numeric/index.ts'
|
|
30
|
+
import { calculateObject } from './object.ts'
|
|
31
|
+
import { calculateString } from './string.ts'
|
|
32
|
+
|
|
33
|
+
export type Options = {
|
|
34
|
+
readonly printWarnLog?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CheckResult {
|
|
38
|
+
readonly errorPath?: SchemaPath | undefined
|
|
39
|
+
readonly expression: ExpressionResult
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
type WritableContext<E> = { -readonly [K in keyof Context<E>]?: Context<E>[K] }
|
|
43
|
+
|
|
44
|
+
export function checkWithResult<E>(extendsContext: ExtendsContext, schema1: Schema<E>, schema2: Schema<E>): CheckResult {
|
|
45
|
+
const context: WritableContext<E> = {}
|
|
46
|
+
const errorPaths: SchemaPath[] = []
|
|
47
|
+
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context as Context<E>))
|
|
48
|
+
const describe = describer<E>()
|
|
49
|
+
const equals = schemaEqualsChecker<E>(extendsContext)
|
|
50
|
+
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals)
|
|
51
|
+
context.calculate = expression({
|
|
52
|
+
describe,
|
|
53
|
+
equals,
|
|
54
|
+
calculate,
|
|
55
|
+
observeCalculation: (left, right, result, swapped) => {
|
|
56
|
+
const comparisonResult = swapped ? swap(result) : result
|
|
57
|
+
if (!isDecisiveMismatch(comparisonResult)) return
|
|
58
|
+
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right)
|
|
59
|
+
if (errorPath) errorPaths.push(errorPath)
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
Object.freeze(context)
|
|
63
|
+
const comparisonExpression = context.calculate(schema1, schema2)
|
|
64
|
+
return { errorPath: errorPaths[0], expression: comparisonExpression }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const describer =
|
|
68
|
+
<E>(): Describer<Schema<E>> =>
|
|
69
|
+
(schema: Schema<E>) => {
|
|
70
|
+
let description: ExpressionDescription<Schema<E>>
|
|
71
|
+
switch (getKind(schema)) {
|
|
72
|
+
case CompiledKind.Not: {
|
|
73
|
+
description = {
|
|
74
|
+
kind: ExpressionKind.Not,
|
|
75
|
+
expression: (schema as CompiledSchema<E>).not as Schema<E>,
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
}
|
|
79
|
+
case CompiledKind.Combination: {
|
|
80
|
+
if ('allOf' in schema) {
|
|
81
|
+
description = {
|
|
82
|
+
kind: ExpressionKind.AllOf,
|
|
83
|
+
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any),
|
|
84
|
+
}
|
|
85
|
+
} else if ('anyOf' in schema) {
|
|
86
|
+
description = {
|
|
87
|
+
kind: ExpressionKind.AnyOf,
|
|
88
|
+
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never),
|
|
89
|
+
}
|
|
90
|
+
} else if ('oneOf' in schema) {
|
|
91
|
+
description = {
|
|
92
|
+
kind: ExpressionKind.OneOf,
|
|
93
|
+
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never),
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`)
|
|
97
|
+
}
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
default: {
|
|
101
|
+
description = { kind: ExpressionKind.Leaf }
|
|
102
|
+
break
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return description
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const calculator =
|
|
109
|
+
<E>(extendsContext: ExtendsContext, context: Context<E>): Calculator<Schema<E>> =>
|
|
110
|
+
(schema1, schema2) => {
|
|
111
|
+
const kind1 = getKind(schema1)
|
|
112
|
+
const kind2 = getKind(schema2)
|
|
113
|
+
|
|
114
|
+
if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) {
|
|
115
|
+
return extendsContext.calculate(schema1, schema2)
|
|
116
|
+
}
|
|
117
|
+
switch (kind1) {
|
|
118
|
+
case CompiledKind.Any: {
|
|
119
|
+
return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining
|
|
120
|
+
}
|
|
121
|
+
case CompiledKind.Never: {
|
|
122
|
+
return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
switch (kind2) {
|
|
126
|
+
case CompiledKind.Any: {
|
|
127
|
+
return ExpressionContainedBy
|
|
128
|
+
}
|
|
129
|
+
case CompiledKind.Never: {
|
|
130
|
+
return ExpressionContaining
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) {
|
|
134
|
+
return calculateEnumAndEnum(context, schema1 as CompiledSchema<E>, schema2 as CompiledSchema<E>)
|
|
135
|
+
}
|
|
136
|
+
if (kind1 === CompiledKind.EnumOrConst) {
|
|
137
|
+
return calculateEnumAndSchema(schema1 as CompiledSchema<E>, schema2 as CompiledSchema<E>)
|
|
138
|
+
}
|
|
139
|
+
if (kind2 === CompiledKind.EnumOrConst) {
|
|
140
|
+
return swap(calculateEnumAndSchema(schema2 as CompiledSchema<E>, schema1 as CompiledSchema<E>))
|
|
141
|
+
}
|
|
142
|
+
if (kind1 !== kind2) {
|
|
143
|
+
return ExpressionRejection
|
|
144
|
+
}
|
|
145
|
+
switch (kind1) {
|
|
146
|
+
case CompiledKind.Null: {
|
|
147
|
+
return ExpressionEquals
|
|
148
|
+
}
|
|
149
|
+
case CompiledKind.Numeric: {
|
|
150
|
+
return calculateNumeric(schema1 as CompiledSchema<E>, schema2 as CompiledSchema<E>)
|
|
151
|
+
}
|
|
152
|
+
case CompiledKind.String: {
|
|
153
|
+
return calculateString(schema1 as CompiledSchema<E>, schema2 as CompiledSchema<E>)
|
|
154
|
+
}
|
|
155
|
+
case CompiledKind.Boolean: {
|
|
156
|
+
return ExpressionEquals
|
|
157
|
+
}
|
|
158
|
+
case CompiledKind.Object: {
|
|
159
|
+
return calculateObject(context, schema1 as CompiledSchema<E>, schema2 as CompiledSchema<E>)
|
|
160
|
+
}
|
|
161
|
+
case CompiledKind.Array: {
|
|
162
|
+
return calculateArray(context, schema1 as CompiledSchema<E>, schema2 as CompiledSchema<E>)
|
|
163
|
+
}
|
|
164
|
+
default: {
|
|
165
|
+
throw new Error(`invalid kind ${kind1}`)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function rejectInSchemaList<E>(schemaList: DeepReadonly<JSONSchema7Definition[]> | undefined, kind: CompiledKind): CompiledSchema<E>[] {
|
|
171
|
+
return (schemaList as CompiledSchema<E>[]).filter((e) => getKind(e) !== kind)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function isDecisiveMismatch(result: ExpressionResult): boolean {
|
|
175
|
+
return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function findMismatchPath<E>(source: Schema<E>, target: Schema<E>): SchemaPath | undefined {
|
|
179
|
+
const targetPath = getPath(target)
|
|
180
|
+
if (!targetPath) return undefined
|
|
181
|
+
const sourceKind = getKind(source)
|
|
182
|
+
const targetKind = getKind(target)
|
|
183
|
+
if (sourceKind !== targetKind) return [...targetPath, 'type']
|
|
184
|
+
|
|
185
|
+
const sourceSchema = source as CompiledSchema<E>
|
|
186
|
+
const targetSchema = target as CompiledSchema<E>
|
|
187
|
+
switch (targetKind) {
|
|
188
|
+
case CompiledKind.String: {
|
|
189
|
+
if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, 'minLength']
|
|
190
|
+
if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, 'maxLength']
|
|
191
|
+
if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, 'pattern']
|
|
192
|
+
if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, 'format']
|
|
193
|
+
break
|
|
194
|
+
}
|
|
195
|
+
case CompiledKind.Numeric: {
|
|
196
|
+
if (
|
|
197
|
+
(sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) <
|
|
198
|
+
(targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)
|
|
199
|
+
) {
|
|
200
|
+
return [...targetPath, targetSchema.exclusiveMinimum == null ? 'minimum' : 'exclusiveMinimum']
|
|
201
|
+
}
|
|
202
|
+
if (
|
|
203
|
+
(sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) >
|
|
204
|
+
(targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)
|
|
205
|
+
) {
|
|
206
|
+
return [...targetPath, targetSchema.exclusiveMaximum == null ? 'maximum' : 'exclusiveMaximum']
|
|
207
|
+
}
|
|
208
|
+
if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, 'multipleOf']
|
|
209
|
+
break
|
|
210
|
+
}
|
|
211
|
+
case CompiledKind.Array: {
|
|
212
|
+
if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, 'minItems']
|
|
213
|
+
if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, 'maxItems']
|
|
214
|
+
if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, 'uniqueItems']
|
|
215
|
+
break
|
|
216
|
+
}
|
|
217
|
+
case CompiledKind.Object: {
|
|
218
|
+
const sourceRequired = new Set(sourceSchema.required ?? [])
|
|
219
|
+
if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, 'required']
|
|
220
|
+
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, 'minProperties']
|
|
221
|
+
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY))
|
|
222
|
+
return [...targetPath, 'maxProperties']
|
|
223
|
+
break
|
|
224
|
+
}
|
|
225
|
+
case CompiledKind.EnumOrConst: {
|
|
226
|
+
return [...targetPath, targetSchema.const === undefined ? 'enum' : 'const']
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return targetPath
|
|
230
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { CompiledSchema, CompiledValue } from '../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../expression/index.ts'
|
|
3
|
+
import type { Context } from './cache.ts'
|
|
4
|
+
|
|
5
|
+
import { getKind, CompiledKind } from '../compiler/index.ts'
|
|
6
|
+
import {
|
|
7
|
+
ExpressionAny,
|
|
8
|
+
ExpressionEquals,
|
|
9
|
+
ExpressionContaining,
|
|
10
|
+
ExpressionContainedBy,
|
|
11
|
+
ExpressionIntersection,
|
|
12
|
+
ExpressionRejection,
|
|
13
|
+
} from '../expression/index.ts'
|
|
14
|
+
import { valid, ValidResult } from './validator.ts'
|
|
15
|
+
|
|
16
|
+
export function calculateEnumAndEnum<E>(context: Context<E>, schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
17
|
+
const enumList1 = normalizeEnumList(schema1)
|
|
18
|
+
const enumList2 = normalizeEnumList(schema2)
|
|
19
|
+
|
|
20
|
+
let foundExtra1 = false
|
|
21
|
+
let foundExtra2 = false
|
|
22
|
+
let foundIntersection = false
|
|
23
|
+
|
|
24
|
+
for (const enum1 of enumList1) {
|
|
25
|
+
if (hasEqualsEnum(context, enumList2, enum1)) {
|
|
26
|
+
foundIntersection = true
|
|
27
|
+
} else {
|
|
28
|
+
foundExtra1 = true
|
|
29
|
+
}
|
|
30
|
+
if (foundExtra1 && foundIntersection) {
|
|
31
|
+
break
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const enum2 of enumList2) {
|
|
35
|
+
if (hasEqualsEnum(context, enumList1, enum2)) {
|
|
36
|
+
foundIntersection = true
|
|
37
|
+
} else {
|
|
38
|
+
foundExtra2 = true
|
|
39
|
+
}
|
|
40
|
+
if (foundExtra2 && foundIntersection) {
|
|
41
|
+
break
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (!foundIntersection) {
|
|
45
|
+
return ExpressionRejection
|
|
46
|
+
}
|
|
47
|
+
if (foundExtra1 && foundExtra2) {
|
|
48
|
+
return ExpressionIntersection
|
|
49
|
+
}
|
|
50
|
+
if (foundExtra1) {
|
|
51
|
+
return ExpressionContaining
|
|
52
|
+
}
|
|
53
|
+
if (foundExtra2) {
|
|
54
|
+
return ExpressionContainedBy
|
|
55
|
+
}
|
|
56
|
+
return ExpressionEquals
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function calculateEnumAndSchema<E>(enumSchema: CompiledSchema<E>, schema: CompiledSchema<E>): ExpressionResult {
|
|
60
|
+
let hasValid = false
|
|
61
|
+
let hasInvalid = false
|
|
62
|
+
|
|
63
|
+
for (const enumValue of normalizeEnumList(enumSchema)) {
|
|
64
|
+
switch (valid(schema, enumValue)) {
|
|
65
|
+
case ValidResult.Valid: {
|
|
66
|
+
hasValid = true
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
case ValidResult.Invalid: {
|
|
70
|
+
hasInvalid = true
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
case ValidResult.Unknown: {
|
|
74
|
+
return ExpressionAny
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (hasValid && hasInvalid) {
|
|
78
|
+
break
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (hasValid && hasInvalid) {
|
|
82
|
+
return ExpressionIntersection
|
|
83
|
+
}
|
|
84
|
+
if (hasValid) {
|
|
85
|
+
return ExpressionEquals | ExpressionContainedBy
|
|
86
|
+
}
|
|
87
|
+
if (hasInvalid) {
|
|
88
|
+
return ExpressionRejection
|
|
89
|
+
}
|
|
90
|
+
if (getKind(schema) === CompiledKind.Never) {
|
|
91
|
+
return ExpressionEquals
|
|
92
|
+
}
|
|
93
|
+
return ExpressionContainedBy
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function normalizeEnumList<E>({ const: constValue, enum: enumList }: CompiledSchema<E>): CompiledValue[] {
|
|
97
|
+
if (constValue !== undefined) {
|
|
98
|
+
return [constValue as CompiledValue]
|
|
99
|
+
}
|
|
100
|
+
if (enumList) {
|
|
101
|
+
return enumList as CompiledValue[]
|
|
102
|
+
}
|
|
103
|
+
throw new Error('invalid branch')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function hasEqualsEnum<E>({ isEquals }: Context<E>, enumList: CompiledValue[], checkedEnum: CompiledValue): boolean {
|
|
107
|
+
for (const searchedEnum of enumList) {
|
|
108
|
+
if (isEquals(searchedEnum, checkedEnum)) {
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { CompiledSchema } from '../compiler/index.ts'
|
|
2
|
+
import type { ExtendsContext } from '../extends/index.ts'
|
|
3
|
+
import type { Schema } from '../types.ts'
|
|
4
|
+
|
|
5
|
+
import { getId, isCompiledSchema } from '../compiler/index.ts'
|
|
6
|
+
|
|
7
|
+
export function schemaEqualsChecker<E>(extendsContext: ExtendsContext): (schema1: Schema<E>, schema2: Schema<E>) => boolean {
|
|
8
|
+
function isSchemaEquals(schema1: Schema<E>, schema2: Schema<E>): boolean {
|
|
9
|
+
const isExtends1 = extendsContext.isExtendsSchema(schema1)
|
|
10
|
+
const isExtends2 = extendsContext.isExtendsSchema(schema2)
|
|
11
|
+
|
|
12
|
+
if (isExtends1 || isExtends2) {
|
|
13
|
+
return extendsContext.equals(schema1, schema2)
|
|
14
|
+
} else {
|
|
15
|
+
return isCompiledSchemaEquals(schema1, schema2)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const equalsMap = new Map<string, boolean>()
|
|
19
|
+
|
|
20
|
+
function isCompiledSchemaEquals(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): boolean {
|
|
21
|
+
const id1 = getId(schema1)
|
|
22
|
+
const id2 = getId(schema2)
|
|
23
|
+
|
|
24
|
+
if (id1 === id2) {
|
|
25
|
+
return true
|
|
26
|
+
}
|
|
27
|
+
const key = `${id1}/${id2}`
|
|
28
|
+
let isEquals = equalsMap.get(key)
|
|
29
|
+
|
|
30
|
+
if (isEquals === undefined) {
|
|
31
|
+
isEquals = isObjectLikeEquals(schema1, schema2)
|
|
32
|
+
equalsMap.set(key, isEquals)
|
|
33
|
+
}
|
|
34
|
+
return isEquals
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isObjectLikeEquals(object1: object, object2: object): boolean {
|
|
38
|
+
if (Array.isArray(object1)) {
|
|
39
|
+
if (!Array.isArray(object2)) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
if (object1.length !== object2.length) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
for (const [i, value1Element] of object1.entries()) {
|
|
46
|
+
if (!isValueEquals(value1Element, object2[i])) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
if (Array.isArray(object2)) {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
for (const key in object1) {
|
|
55
|
+
if (!(key in object2)) {
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
const value1: unknown = Reflect.get(object1, key)
|
|
59
|
+
const value2: unknown = Reflect.get(object2, key)
|
|
60
|
+
if (!isValueEquals(value1, value2)) {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
for (const key in object2) {
|
|
65
|
+
if (!(key in object1)) {
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return true
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
function isValueEquals(value1: any, value2: any): boolean {
|
|
75
|
+
if (value1 === value2) {
|
|
76
|
+
return true
|
|
77
|
+
}
|
|
78
|
+
if (value1 === null || value2 === null) {
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
if (typeof value1 !== 'object') {
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
if (typeof value1 !== typeof value2) {
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
if (isCompiledSchema<E>(value1) && isCompiledSchema<E>(value2)) {
|
|
88
|
+
return isCompiledSchemaEquals(value1, value2)
|
|
89
|
+
}
|
|
90
|
+
return isObjectLikeEquals(value1, value2)
|
|
91
|
+
}
|
|
92
|
+
return isSchemaEquals
|
|
93
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { CompiledSchema } from '../../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../../expression/index.ts'
|
|
3
|
+
|
|
4
|
+
import { swap, ExpressionAny } from '../../expression/index.ts'
|
|
5
|
+
import { calculateFloat, calculateFloatAndInteger } from './float.ts'
|
|
6
|
+
import { calculateInteger } from './integer.ts'
|
|
7
|
+
|
|
8
|
+
export function calculateNumeric<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
9
|
+
if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) {
|
|
10
|
+
return ExpressionAny
|
|
11
|
+
}
|
|
12
|
+
const isFloat1 = isFloat(schema1)
|
|
13
|
+
const isFloat2 = isFloat(schema2)
|
|
14
|
+
|
|
15
|
+
if (isFloat1 && isFloat2) {
|
|
16
|
+
return calculateFloat(schema1, schema2)
|
|
17
|
+
} else if (isFloat1) {
|
|
18
|
+
return calculateFloatAndInteger(schema1, schema2)
|
|
19
|
+
} else if (isFloat2) {
|
|
20
|
+
return swap(calculateFloatAndInteger(schema2, schema1))
|
|
21
|
+
} else {
|
|
22
|
+
return calculateInteger(schema1, schema2)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isUndefinedNumber<E>(schema: CompiledSchema<E>): boolean {
|
|
27
|
+
const { multipleOf } = schema
|
|
28
|
+
if (multipleOf === undefined) {
|
|
29
|
+
return false
|
|
30
|
+
}
|
|
31
|
+
if (!Number.isInteger(multipleOf)) {
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
if (multipleOf < 0) {
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function isFloat<E>(schema: CompiledSchema<E>): boolean {
|
|
41
|
+
const { multipleOf } = schema
|
|
42
|
+
|
|
43
|
+
if (multipleOf !== undefined && Number.isInteger(multipleOf)) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
if (schema.type === 'integer') {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { CompiledSchema } from '../../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../../expression/index.ts'
|
|
3
|
+
import type { Point, Range, SplitterSide } from '../tools/index.ts'
|
|
4
|
+
|
|
5
|
+
import { ExpressionEquals, ExpressionContaining, ExpressionContainedBy, ExpressionIntersection, ExpressionRejection } from '../../expression/index.ts'
|
|
6
|
+
import { splitRange } from '../tools/index.ts'
|
|
7
|
+
import { isPointRange, cutRange, normalizeInteger } from './integerNormalizer.ts'
|
|
8
|
+
|
|
9
|
+
export function calculateFloat<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
10
|
+
const range1 = pickRange(schema1)
|
|
11
|
+
const range2 = pickRange(schema2)
|
|
12
|
+
const { left, right, center } = splitRange(range1, range2)
|
|
13
|
+
|
|
14
|
+
if (!center) {
|
|
15
|
+
return ExpressionRejection
|
|
16
|
+
}
|
|
17
|
+
let extraLeft = false
|
|
18
|
+
let extraRight = false
|
|
19
|
+
|
|
20
|
+
if (left) {
|
|
21
|
+
if (left.fromLeft) {
|
|
22
|
+
extraLeft = true
|
|
23
|
+
} else {
|
|
24
|
+
extraRight = true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (right) {
|
|
28
|
+
if (right.fromLeft) {
|
|
29
|
+
extraLeft = true
|
|
30
|
+
} else {
|
|
31
|
+
extraRight = true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (extraLeft && extraRight) {
|
|
35
|
+
return ExpressionIntersection
|
|
36
|
+
}
|
|
37
|
+
if (extraLeft) {
|
|
38
|
+
return ExpressionContaining
|
|
39
|
+
}
|
|
40
|
+
if (extraRight) {
|
|
41
|
+
return ExpressionContainedBy
|
|
42
|
+
}
|
|
43
|
+
return ExpressionEquals
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function calculateFloatAndInteger<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
47
|
+
const floatRange = pickRange(schema1)
|
|
48
|
+
const integer = normalizeInteger(schema2)
|
|
49
|
+
|
|
50
|
+
if (!integer) {
|
|
51
|
+
return ExpressionContaining
|
|
52
|
+
}
|
|
53
|
+
const result = splitRange(floatRange, integer.range)
|
|
54
|
+
const intCenter = cutRange(result.center, integer.multipleOf)
|
|
55
|
+
const leftIntRange = unwrapAndCutRange(result.left, integer.multipleOf)
|
|
56
|
+
const rightIntRange = unwrapAndCutRange(result.right, integer.multipleOf)
|
|
57
|
+
|
|
58
|
+
if (!result.center) {
|
|
59
|
+
return ExpressionRejection
|
|
60
|
+
}
|
|
61
|
+
let extraFloat = false
|
|
62
|
+
let extraInteger = false
|
|
63
|
+
|
|
64
|
+
if (result.left?.fromLeft) {
|
|
65
|
+
extraFloat = true
|
|
66
|
+
}
|
|
67
|
+
if (result.right?.fromLeft) {
|
|
68
|
+
extraFloat = true
|
|
69
|
+
}
|
|
70
|
+
if (!intCenter || !isPointRange(result.center)) {
|
|
71
|
+
extraFloat = true
|
|
72
|
+
}
|
|
73
|
+
if (leftIntRange) {
|
|
74
|
+
extraInteger = true
|
|
75
|
+
}
|
|
76
|
+
if (rightIntRange) {
|
|
77
|
+
extraInteger = true
|
|
78
|
+
}
|
|
79
|
+
if (extraFloat && extraInteger) {
|
|
80
|
+
return ExpressionIntersection
|
|
81
|
+
}
|
|
82
|
+
if (extraFloat) {
|
|
83
|
+
return ExpressionContaining
|
|
84
|
+
}
|
|
85
|
+
if (extraInteger) {
|
|
86
|
+
return ExpressionContainedBy
|
|
87
|
+
}
|
|
88
|
+
return ExpressionEquals
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function pickRange<E>(schema: CompiledSchema<E>): Range {
|
|
92
|
+
let point1: Point
|
|
93
|
+
let point2: Point
|
|
94
|
+
|
|
95
|
+
if (schema.exclusiveMinimum !== undefined) {
|
|
96
|
+
point1 = { num: schema.exclusiveMinimum, exclusive: true }
|
|
97
|
+
} else if (schema.minimum !== undefined) {
|
|
98
|
+
point1 = { num: schema.minimum, exclusive: false }
|
|
99
|
+
} else {
|
|
100
|
+
point1 = { num: Number.NEGATIVE_INFINITY, exclusive: true }
|
|
101
|
+
}
|
|
102
|
+
if (schema.exclusiveMaximum !== undefined) {
|
|
103
|
+
point2 = { num: schema.exclusiveMaximum, exclusive: true }
|
|
104
|
+
} else if (schema.maximum !== undefined) {
|
|
105
|
+
point2 = { num: schema.maximum, exclusive: false }
|
|
106
|
+
} else {
|
|
107
|
+
point2 = { num: Number.POSITIVE_INFINITY, exclusive: true }
|
|
108
|
+
}
|
|
109
|
+
return [point1, point2]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function unwrapAndCutRange(side: SplitterSide | undefined, multipleOf: number): Range | undefined {
|
|
113
|
+
if (!side) {
|
|
114
|
+
return undefined
|
|
115
|
+
}
|
|
116
|
+
if (side.fromLeft) {
|
|
117
|
+
// left is always float in this file
|
|
118
|
+
return undefined
|
|
119
|
+
}
|
|
120
|
+
return cutRange(side.range, multipleOf)
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { calculateNumeric } from './checker.ts'
|