@oomol-lab/open-flow 0.1.0-beta.73 → 0.1.0-beta.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +36 -0
- package/NOTICE +7 -0
- package/README.md +40 -0
- package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-DI9pL-Yr.js} +2 -2
- package/dist/browser/{dialog-CUy_fwx9.js → dialog-BYJGvItc.js} +54 -19
- package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-RL-H4CjD.js} +306 -48
- package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-BkDsETj0.js} +20745 -20186
- package/dist/browser/preview.css +73 -3
- package/dist/browser/preview.js +21410 -20607
- package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
- package/dist/browser/ui.css +72 -2
- package/dist/browser/workbench.css +73 -3
- package/dist/browser/workbench.js +14 -76
- package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-BcWPWGzw.js} +1 -1
- package/dist/command/index.js +34 -34
- package/dist/common/authoring.d.ts +1 -1
- package/dist/common/authoringFields.d.ts +1 -1
- package/dist/common/authoringSchema.d.ts +28 -4
- package/dist/common/connector-proxy.d.ts +1 -1
- package/dist/common/control-api-conformance.d.ts +1 -1
- package/dist/common/control-api-conformance.js +61 -24
- package/dist/common/control-api.d.ts +4 -3
- package/dist/common/control-api.js +59 -22
- package/dist/common/control-requests.d.ts +2 -1
- package/dist/common/control-requests.js +204 -42
- package/dist/common/cron-trigger.d.ts +1 -1
- package/dist/common/decision.d.ts +1 -1
- package/dist/common/draftOperations.d.ts +1 -1
- package/dist/common/engine-contract.d.ts +3 -2
- package/dist/common/event-source-definition.d.ts +1 -1
- package/dist/common/flow-agent.d.ts +1 -1
- package/dist/{browser → common}/flow-authoring-node.d.ts +3 -3
- package/dist/{browser → common}/flow-authoring.js +75 -23
- package/dist/{browser → common}/flow-change-schema.d.ts +177 -6
- package/dist/{browser → common}/flow-change.d.ts +35 -15
- package/dist/{browser → common}/flow-change.js +77 -25
- package/dist/common/flow-connectionUsage.d.ts +1 -1
- package/dist/common/flow-encoding.d.ts +1 -1
- package/dist/common/flow-encoding.js +34 -16
- package/dist/common/flow-errorHandling.d.ts +1 -1
- package/dist/common/flow-graph.d.ts +1 -1
- package/dist/common/flow-modules.d.ts +1 -1
- package/dist/common/flow-promptTemplate.d.ts +1 -1
- package/dist/common/flow-retry.d.ts +1 -1
- package/dist/common/flow-semantics.d.ts +1 -1
- package/dist/common/flow-semantics.js +151 -32
- package/dist/common/flow-workflowFile.d.ts +1 -1
- package/dist/common/flowInspection.d.ts +3 -3
- package/dist/common/integration-trigger.d.ts +1 -1
- package/dist/common/licenses.md +118 -1
- package/dist/common/liveDetails.d.ts +1 -1
- package/dist/common/mcp.d.ts +2 -1
- package/dist/common/mcp.js +59 -22
- package/dist/common/openapi.d.ts +1 -1
- package/dist/common/poll-trigger.d.ts +1 -1
- package/dist/common/run-results.d.ts +8 -1
- package/dist/common/runtime-contract.d.ts +8 -2
- package/dist/common/runtime-contract.js +22 -5
- package/dist/common/scheduler-checkpoint.d.ts +1 -1
- package/dist/common/scheduler-dependencies.d.ts +1 -1
- package/dist/common/scheduler-node-execution.d.ts +1 -1
- package/dist/common/scheduler.d.ts +2 -2
- package/dist/common/scheduler.js +31 -12
- package/dist/common/trigger-catalog.d.ts +1 -1
- package/dist/common/trigger-config-options.d.ts +1 -1
- package/dist/common/trigger-config.d.ts +1 -1
- package/dist/common/trigger-contract.d.ts +2 -2
- package/dist/common/trigger-localization.d.ts +1 -1
- package/dist/common/webhook-response.d.ts +1 -1
- package/dist/common/webhook-trigger.d.ts +1 -1
- package/dist/common/workflow.d.ts +17 -1
- package/dist/common/workflow.js +68 -22
- package/dist/index.d.ts +6 -3
- package/package.json +7 -6
- package/src/base/common/json.ts +90 -0
- package/src/canvas/common/commands.ts +15 -0
- package/src/connector/common/actionSchema.ts +168 -0
- package/src/connector/common/proxy.ts +44 -0
- package/src/control/common/api.ts +1505 -0
- package/src/control/common/authoring.ts +912 -0
- package/src/control/common/authoringCondition.ts +110 -0
- package/src/control/common/authoringDiagnosticFields.ts +136 -0
- package/src/control/common/authoringExamples.ts +192 -0
- package/src/control/common/authoringFields.ts +53 -0
- package/src/control/common/authoringLlm.ts +70 -0
- package/src/control/common/authoringOpenApi.ts +129 -0
- package/src/control/common/authoringSchema.ts +404 -0
- package/src/control/common/authoringTools.ts +123 -0
- package/src/control/common/authoringTriggers.ts +26 -0
- package/src/control/common/checkDecoders.ts +65 -0
- package/src/control/common/conformance.ts +1989 -0
- package/src/control/common/connectorDecoders.ts +370 -0
- package/src/control/common/connectorQueries.ts +61 -0
- package/src/control/common/decoding.ts +60 -0
- package/src/control/common/draftOperations.ts +61 -0
- package/src/control/common/errors.ts +114 -0
- package/src/control/common/eventSourceSchemas.ts +13 -0
- package/src/control/common/eventSources.ts +186 -0
- package/src/control/common/flowDecoders.ts +153 -0
- package/src/control/common/flowInspection.ts +181 -0
- package/src/control/common/flowNotifications.ts +37 -0
- package/src/control/common/liveDetails.ts +124 -0
- package/src/control/common/mcp.ts +241 -0
- package/src/control/common/mcpConformance.ts +142 -0
- package/src/control/common/providerAccess.ts +28 -0
- package/src/control/common/providerIconSprite.ts +42 -0
- package/src/control/common/publicationDecoders.ts +98 -0
- package/src/control/common/random.ts +16 -0
- package/src/control/common/requests.ts +112 -0
- package/src/control/common/resultQuery.ts +8 -0
- package/src/control/common/results.ts +176 -0
- package/src/control/common/revisionDecoders.ts +52 -0
- package/src/control/common/runDecoders.ts +240 -0
- package/src/control/common/triggerCatalog.ts +89 -0
- package/src/control/common/triggerDecoders.ts +175 -0
- package/src/decision/common/decision.ts +168 -0
- package/src/event-source/common/catalog.generated.json +65 -0
- package/src/event-source/common/definition.ts +66 -0
- package/src/event-source/common/index.ts +99 -0
- package/src/execution/common/checkpoint.ts +311 -0
- package/src/execution/common/dependencies.ts +440 -0
- package/src/execution/common/engineContract.ts +80 -0
- package/src/execution/common/events.ts +328 -0
- package/src/execution/common/node-execution.ts +467 -0
- package/src/execution/common/runLifecycle.ts +250 -0
- package/src/execution/common/runtime.ts +563 -0
- package/src/execution/common/scheduler.ts +696 -0
- package/src/execution/common/wait.ts +36 -0
- package/src/flow/common/agent.ts +305 -0
- package/src/flow/common/authoring.ts +30 -0
- package/src/flow/common/change.ts +1036 -0
- package/src/flow/common/changeSchema.ts +783 -0
- package/src/flow/common/codePermissions.ts +2 -0
- package/src/flow/common/condition.ts +265 -0
- package/src/flow/common/connectionUsage.ts +131 -0
- package/src/flow/common/edgeChanges.ts +35 -0
- package/src/flow/common/encoding.ts +437 -0
- package/src/flow/common/errorHandling.ts +34 -0
- package/src/flow/common/graph.ts +892 -0
- package/src/flow/common/inputValue.ts +16 -0
- package/src/flow/common/json.ts +8 -0
- package/src/flow/common/moduleChanges.ts +31 -0
- package/src/flow/common/modules.ts +292 -0
- package/src/flow/common/nodeChanges.ts +762 -0
- package/src/flow/common/portChanges.ts +36 -0
- package/src/flow/common/promptTemplate.ts +15 -0
- package/src/flow/common/retry.ts +20 -0
- package/src/flow/common/schema.ts +162 -0
- package/src/flow/common/schemaCompare.ts +176 -0
- package/src/flow/common/schemaComparer.ts +178 -0
- package/src/flow/common/schemaKeywords.ts +53 -0
- package/src/flow/common/semantics.ts +474 -0
- package/src/flow/common/sourceField.ts +35 -0
- package/src/flow/common/triggerScheduleSchema.ts +8 -0
- package/src/flow/common/wait.ts +30 -0
- package/src/flow/common/webhookMethod.ts +7 -0
- package/src/flow/common/webhookResponse.ts +75 -0
- package/src/flow/common/workflowFile.ts +97 -0
- package/src/json-schema-subset/checker/array.ts +142 -0
- package/src/json-schema-subset/checker/cache.ts +57 -0
- package/src/json-schema-subset/checker/checker.ts +230 -0
- package/src/json-schema-subset/checker/enumAndConst.ts +113 -0
- package/src/json-schema-subset/checker/equals.ts +93 -0
- package/src/json-schema-subset/checker/numeric/checker.ts +50 -0
- package/src/json-schema-subset/checker/numeric/float.ts +121 -0
- package/src/json-schema-subset/checker/numeric/index.ts +1 -0
- package/src/json-schema-subset/checker/numeric/integer.ts +119 -0
- package/src/json-schema-subset/checker/numeric/integerNormalizer.ts +72 -0
- package/src/json-schema-subset/checker/object.ts +354 -0
- package/src/json-schema-subset/checker/range.ts +91 -0
- package/src/json-schema-subset/checker/string.ts +60 -0
- package/src/json-schema-subset/checker/tools/index.ts +3 -0
- package/src/json-schema-subset/checker/tools/mark.ts +82 -0
- package/src/json-schema-subset/checker/tools/quantum.ts +106 -0
- package/src/json-schema-subset/checker/tools/range.ts +210 -0
- package/src/json-schema-subset/checker/validator.ts +23 -0
- package/src/json-schema-subset/compiler/array.ts +163 -0
- package/src/json-schema-subset/compiler/combination.ts +109 -0
- package/src/json-schema-subset/compiler/common.ts +99 -0
- package/src/json-schema-subset/compiler/compiler.ts +188 -0
- package/src/json-schema-subset/compiler/enumAndConst.ts +75 -0
- package/src/json-schema-subset/compiler/index.ts +11 -0
- package/src/json-schema-subset/compiler/object.ts +411 -0
- package/src/json-schema-subset/compiler/primitive.ts +144 -0
- package/src/json-schema-subset/compiler/utils.ts +24 -0
- package/src/json-schema-subset/compiler/wrapper.ts +192 -0
- package/src/json-schema-subset/error.ts +55 -0
- package/src/json-schema-subset/expression/calculator.ts +442 -0
- package/src/json-schema-subset/expression/combination.ts +49 -0
- package/src/json-schema-subset/expression/expression.ts +191 -0
- package/src/json-schema-subset/expression/index.ts +25 -0
- package/src/json-schema-subset/expression/result.ts +88 -0
- package/src/json-schema-subset/expression/types.ts +36 -0
- package/src/json-schema-subset/extends/extendsContext.ts +89 -0
- package/src/json-schema-subset/extends/index.ts +2 -0
- package/src/json-schema-subset/extends/types.ts +12 -0
- package/src/json-schema-subset/global.ts +60 -0
- package/src/json-schema-subset/index.ts +8 -0
- package/src/json-schema-subset/preprocessing.ts +74 -0
- package/src/json-schema-subset/types.ts +8 -0
- package/src/json-schema-subset/utils.ts +95 -0
- package/src/localization/common/languages.ts +118 -0
- package/src/localization/common/timeZone.ts +25 -0
- package/src/openapi/common/authBindings.ts +12 -0
- package/src/openapi/common/openapi.ts +459 -0
- package/src/trigger/common/config.ts +56 -0
- package/src/trigger/common/configOptions.ts +15 -0
- package/src/trigger/common/configSchema.ts +8 -0
- package/src/trigger/common/contract.ts +132 -0
- package/src/trigger/common/cron.ts +151 -0
- package/src/trigger/common/integration.ts +498 -0
- package/src/trigger/common/poll.ts +187 -0
- package/src/trigger/common/webhook.ts +412 -0
- package/src/trigger/providers/airtable/locales/fr.json +18 -0
- package/src/trigger/providers/airtable/locales/ja.json +18 -0
- package/src/trigger/providers/airtable/locales/ko.json +18 -0
- package/src/trigger/providers/airtable/locales/ru.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-CN.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-TW.json +18 -0
- package/src/trigger/providers/asana/locales/fr.json +15 -0
- package/src/trigger/providers/asana/locales/ja.json +15 -0
- package/src/trigger/providers/asana/locales/ko.json +15 -0
- package/src/trigger/providers/asana/locales/ru.json +15 -0
- package/src/trigger/providers/asana/locales/zh-CN.json +15 -0
- package/src/trigger/providers/asana/locales/zh-TW.json +15 -0
- package/src/trigger/providers/calendly/locales/fr.json +16 -0
- package/src/trigger/providers/calendly/locales/ja.json +16 -0
- package/src/trigger/providers/calendly/locales/ko.json +16 -0
- package/src/trigger/providers/calendly/locales/ru.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-CN.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-TW.json +16 -0
- package/src/trigger/providers/catalog.generated.json +4996 -0
- package/src/trigger/providers/clickup/locales/fr.json +16 -0
- package/src/trigger/providers/clickup/locales/ja.json +16 -0
- package/src/trigger/providers/clickup/locales/ko.json +16 -0
- package/src/trigger/providers/clickup/locales/ru.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-CN.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-TW.json +16 -0
- package/src/trigger/providers/definitions.ts +19 -0
- package/src/trigger/providers/feishu/locales/fr.json +20 -0
- package/src/trigger/providers/feishu/locales/ja.json +20 -0
- package/src/trigger/providers/feishu/locales/ko.json +20 -0
- package/src/trigger/providers/feishu/locales/ru.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-CN.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-TW.json +20 -0
- package/src/trigger/providers/fieldDescriptions.ts +392 -0
- package/src/trigger/providers/fieldLabels.ts +256 -0
- package/src/trigger/providers/fireflies/locales/fr.json +17 -0
- package/src/trigger/providers/fireflies/locales/ja.json +17 -0
- package/src/trigger/providers/fireflies/locales/ko.json +17 -0
- package/src/trigger/providers/fireflies/locales/ru.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-CN.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-TW.json +17 -0
- package/src/trigger/providers/github/locales/fr.json +30 -0
- package/src/trigger/providers/github/locales/ja.json +30 -0
- package/src/trigger/providers/github/locales/ko.json +30 -0
- package/src/trigger/providers/github/locales/ru.json +30 -0
- package/src/trigger/providers/github/locales/zh-CN.json +30 -0
- package/src/trigger/providers/github/locales/zh-TW.json +30 -0
- package/src/trigger/providers/gitlab/locales/fr.json +18 -0
- package/src/trigger/providers/gitlab/locales/ja.json +18 -0
- package/src/trigger/providers/gitlab/locales/ko.json +18 -0
- package/src/trigger/providers/gitlab/locales/ru.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-TW.json +18 -0
- package/src/trigger/providers/gmail/locales/fr.json +18 -0
- package/src/trigger/providers/gmail/locales/ja.json +18 -0
- package/src/trigger/providers/gmail/locales/ko.json +18 -0
- package/src/trigger/providers/gmail/locales/ru.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-TW.json +18 -0
- package/src/trigger/providers/google-calendar/locales/fr.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ja.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ko.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ru.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-CN.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-TW.json +15 -0
- package/src/trigger/providers/google-drive/locales/fr.json +48 -0
- package/src/trigger/providers/google-drive/locales/ja.json +48 -0
- package/src/trigger/providers/google-drive/locales/ko.json +48 -0
- package/src/trigger/providers/google-drive/locales/ru.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-CN.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-TW.json +48 -0
- package/src/trigger/providers/google-sheets/locales/fr.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ja.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ko.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ru.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-CN.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-TW.json +19 -0
- package/src/trigger/providers/intercom/locales/fr.json +17 -0
- package/src/trigger/providers/intercom/locales/ja.json +17 -0
- package/src/trigger/providers/intercom/locales/ko.json +17 -0
- package/src/trigger/providers/intercom/locales/ru.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-TW.json +17 -0
- package/src/trigger/providers/jira/locales/fr.json +17 -0
- package/src/trigger/providers/jira/locales/ja.json +17 -0
- package/src/trigger/providers/jira/locales/ko.json +17 -0
- package/src/trigger/providers/jira/locales/ru.json +17 -0
- package/src/trigger/providers/jira/locales/zh-CN.json +17 -0
- package/src/trigger/providers/jira/locales/zh-TW.json +17 -0
- package/src/trigger/providers/linear/locales/fr.json +13 -0
- package/src/trigger/providers/linear/locales/ja.json +13 -0
- package/src/trigger/providers/linear/locales/ko.json +13 -0
- package/src/trigger/providers/linear/locales/ru.json +13 -0
- package/src/trigger/providers/linear/locales/zh-CN.json +13 -0
- package/src/trigger/providers/linear/locales/zh-TW.json +13 -0
- package/src/trigger/providers/locales/fr.ts +71 -0
- package/src/trigger/providers/locales/ja.ts +71 -0
- package/src/trigger/providers/locales/ko.ts +71 -0
- package/src/trigger/providers/locales/ru.ts +71 -0
- package/src/trigger/providers/locales/zh-CN.ts +71 -0
- package/src/trigger/providers/locales/zh-TW.ts +71 -0
- package/src/trigger/providers/localization.ts +59 -0
- package/src/trigger/providers/notion/locales/fr.json +16 -0
- package/src/trigger/providers/notion/locales/ja.json +16 -0
- package/src/trigger/providers/notion/locales/ko.json +16 -0
- package/src/trigger/providers/notion/locales/ru.json +16 -0
- package/src/trigger/providers/notion/locales/zh-CN.json +16 -0
- package/src/trigger/providers/notion/locales/zh-TW.json +16 -0
- package/src/trigger/providers/one-drive/locales/fr.json +16 -0
- package/src/trigger/providers/one-drive/locales/ja.json +16 -0
- package/src/trigger/providers/one-drive/locales/ko.json +16 -0
- package/src/trigger/providers/one-drive/locales/ru.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-CN.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-TW.json +16 -0
- package/src/trigger/providers/outlook/locales/fr.json +18 -0
- package/src/trigger/providers/outlook/locales/ja.json +18 -0
- package/src/trigger/providers/outlook/locales/ko.json +18 -0
- package/src/trigger/providers/outlook/locales/ru.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-CN.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-TW.json +18 -0
- package/src/trigger/providers/pandadoc/locales/fr.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ja.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ko.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ru.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-CN.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-TW.json +12 -0
- package/src/trigger/providers/pipedrive/locales/fr.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ja.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ko.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ru.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-CN.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-TW.json +15 -0
- package/src/trigger/providers/remote.ts +163 -0
- package/src/trigger/providers/resend/locales/fr.json +16 -0
- package/src/trigger/providers/resend/locales/ja.json +16 -0
- package/src/trigger/providers/resend/locales/ko.json +16 -0
- package/src/trigger/providers/resend/locales/ru.json +16 -0
- package/src/trigger/providers/resend/locales/zh-CN.json +16 -0
- package/src/trigger/providers/resend/locales/zh-TW.json +16 -0
- package/src/trigger/providers/sentry/locales/fr.json +19 -0
- package/src/trigger/providers/sentry/locales/ja.json +19 -0
- package/src/trigger/providers/sentry/locales/ko.json +19 -0
- package/src/trigger/providers/sentry/locales/ru.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-CN.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-TW.json +19 -0
- package/src/trigger/providers/shopify/locales/fr.json +18 -0
- package/src/trigger/providers/shopify/locales/ja.json +18 -0
- package/src/trigger/providers/shopify/locales/ko.json +18 -0
- package/src/trigger/providers/shopify/locales/ru.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-CN.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slack/locales/fr.json +18 -0
- package/src/trigger/providers/slack/locales/ja.json +18 -0
- package/src/trigger/providers/slack/locales/ko.json +18 -0
- package/src/trigger/providers/slack/locales/ru.json +18 -0
- package/src/trigger/providers/slack/locales/zh-CN.json +18 -0
- package/src/trigger/providers/slack/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slackbot/locales/fr.json +23 -0
- package/src/trigger/providers/slackbot/locales/ja.json +23 -0
- package/src/trigger/providers/slackbot/locales/ko.json +23 -0
- package/src/trigger/providers/slackbot/locales/ru.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-CN.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-TW.json +23 -0
- package/src/trigger/providers/source-events.ts +25 -0
- package/src/trigger/providers/stripe/locales/fr.json +17 -0
- package/src/trigger/providers/stripe/locales/ja.json +17 -0
- package/src/trigger/providers/stripe/locales/ko.json +17 -0
- package/src/trigger/providers/stripe/locales/ru.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-CN.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-TW.json +17 -0
- package/src/trigger/providers/tally/locales/fr.json +12 -0
- package/src/trigger/providers/tally/locales/ja.json +12 -0
- package/src/trigger/providers/tally/locales/ko.json +12 -0
- package/src/trigger/providers/tally/locales/ru.json +12 -0
- package/src/trigger/providers/tally/locales/zh-CN.json +12 -0
- package/src/trigger/providers/tally/locales/zh-TW.json +12 -0
- package/src/trigger/providers/telegram/locales/fr.json +17 -0
- package/src/trigger/providers/telegram/locales/ja.json +17 -0
- package/src/trigger/providers/telegram/locales/ko.json +17 -0
- package/src/trigger/providers/telegram/locales/ru.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-CN.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-TW.json +17 -0
- package/src/trigger/providers/typeform/locales/fr.json +12 -0
- package/src/trigger/providers/typeform/locales/ja.json +12 -0
- package/src/trigger/providers/typeform/locales/ko.json +12 -0
- package/src/trigger/providers/typeform/locales/ru.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-CN.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-TW.json +12 -0
- package/src/trigger/providers/vercel/locales/fr.json +18 -0
- package/src/trigger/providers/vercel/locales/ja.json +18 -0
- package/src/trigger/providers/vercel/locales/ko.json +18 -0
- package/src/trigger/providers/vercel/locales/ru.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-CN.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-TW.json +18 -0
- package/src/trigger/providers/woocommerce/locales/fr.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ja.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ko.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ru.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-CN.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-TW.json +19 -0
- package/src/trigger/providers/zendesk/locales/fr.json +15 -0
- package/src/trigger/providers/zendesk/locales/ja.json +15 -0
- package/src/trigger/providers/zendesk/locales/ko.json +15 -0
- package/src/trigger/providers/zendesk/locales/ru.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-CN.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-TW.json +15 -0
- package/src/trigger/providers/zoom/locales/fr.json +17 -0
- package/src/trigger/providers/zoom/locales/ja.json +17 -0
- package/src/trigger/providers/zoom/locales/ko.json +17 -0
- package/src/trigger/providers/zoom/locales/ru.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-TW.json +17 -0
- package/src/types/index.ts +112 -0
- package/src/workflow/common/workflow.ts +273 -0
- package/dist/browser/lib-DrKav3HG.js +0 -11403
- /package/dist/{browser → common}/flow-authoring-edge.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring-module.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring.d.ts +0 -0
- /package/dist/{browser → common}/flow-input-value.d.ts +0 -0
- /package/dist/{browser → common}/webhook-method.d.ts +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { GraphNode, InputMapping, JsonValue, RevisionContent } from './change.ts'
|
|
2
|
+
|
|
3
|
+
import { dequal } from 'dequal/lite'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
import { clearTriggerExternalConfig } from '../../trigger/common/config.ts'
|
|
6
|
+
import { decodeRevisionContent } from './changeSchema.ts'
|
|
7
|
+
import { clearConditionBindings } from './condition.ts'
|
|
8
|
+
import { clearNodeConnections } from './connectionUsage.ts'
|
|
9
|
+
import { checkJsonDepth } from './json.ts'
|
|
10
|
+
|
|
11
|
+
export interface WorkflowFile {
|
|
12
|
+
readonly kind: 'open-flow-workflow'
|
|
13
|
+
readonly version: 1
|
|
14
|
+
readonly name?: string
|
|
15
|
+
readonly content: RevisionContent
|
|
16
|
+
readonly presentation?: Readonly<Record<string, JsonValue>>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface WorkflowCleanupSummary {
|
|
20
|
+
readonly changedNodeIds: readonly string[]
|
|
21
|
+
readonly removedBindings: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const envelope = z.strictObject({
|
|
25
|
+
kind: z.literal('open-flow-workflow'),
|
|
26
|
+
version: z.literal(1),
|
|
27
|
+
name: z.string().optional(),
|
|
28
|
+
content: z.unknown(),
|
|
29
|
+
presentation: z.record(z.string(), z.json()).optional(),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
/** Structural decoding only: incomplete drafts are supported, repair is never attempted. */
|
|
33
|
+
export function decodeWorkflowFile(value: unknown): WorkflowFile {
|
|
34
|
+
checkJsonDepth(value, -1)
|
|
35
|
+
const file = envelope.parse(value)
|
|
36
|
+
return { ...file, content: decodeRevisionContent(file.content) }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function parseWorkflowFile(text: string): WorkflowFile {
|
|
40
|
+
return decodeWorkflowFile(JSON.parse(text))
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function cleanInput(input: InputMapping): InputMapping {
|
|
44
|
+
if (input.kind != 'sources' || !input.sources.some((source) => source.kind == 'binding')) return input
|
|
45
|
+
const sources = input.sources.filter((source) => source.kind != 'binding')
|
|
46
|
+
return sources.length == 0 ? { kind: 'unset' } : { kind: 'sources', sources }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Clear only owned structured references, never strings in code or business values. */
|
|
50
|
+
export function cleanWorkflowFile(value: unknown): { readonly file: WorkflowFile; readonly summary: WorkflowCleanupSummary } {
|
|
51
|
+
const file = decodeWorkflowFile(value)
|
|
52
|
+
const original = file.content.document.graph
|
|
53
|
+
const graph = clearNodeConnections(original)
|
|
54
|
+
const nodes = Object.fromEntries(
|
|
55
|
+
Object.entries(graph.nodes).map(([id, source]) => {
|
|
56
|
+
let node: GraphNode = source
|
|
57
|
+
if ('inputs' in node) node = { ...node, inputs: Object.fromEntries(Object.entries(node.inputs).map(([key, input]) => [key, cleanInput(input)])) }
|
|
58
|
+
if (node.kind == 'outputs')
|
|
59
|
+
node = { ...node, outputMappings: Object.fromEntries(Object.entries(node.outputMappings).map(([key, input]) => [key, cleanInput(input)])) }
|
|
60
|
+
if (node.kind == 'condition') node = clearConditionBindings(node)
|
|
61
|
+
if (node.kind == 'error' && node.sourceFlowIds != null) node = { ...node, sourceFlowIds: [] }
|
|
62
|
+
if (node.kind == 'poll' || node.kind == 'integration') node = { ...node, config: clearTriggerExternalConfig(node.definition.key, node.config) }
|
|
63
|
+
return [id, node]
|
|
64
|
+
}),
|
|
65
|
+
)
|
|
66
|
+
return {
|
|
67
|
+
file: {
|
|
68
|
+
...file,
|
|
69
|
+
content: {
|
|
70
|
+
...file.content,
|
|
71
|
+
document: {
|
|
72
|
+
...file.content.document,
|
|
73
|
+
bindings: {},
|
|
74
|
+
graph: { ...graph, nodes },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
summary: {
|
|
79
|
+
changedNodeIds: Object.keys(nodes).filter((id) => !dequal(nodes[id], original.nodes[id])),
|
|
80
|
+
removedBindings: Object.keys(file.content.document.bindings).length,
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function encodeWorkflowFile(file: WorkflowFile): string {
|
|
86
|
+
return `${JSON.stringify(cleanWorkflowFile(file).file, null, 2)}\n`
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function workflowFileName(name: string): string {
|
|
90
|
+
// Control characters are forbidden in download filenames.
|
|
91
|
+
// oxlint-disable-next-line no-control-regex
|
|
92
|
+
return `${name.replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_').replace(/[. ]+$/g, '') || 'workflow'}.openflow.json`
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function workflowNameFromFile(name: string): string {
|
|
96
|
+
return name.replace(/(?:\.openflow)?\.json$/i, '')
|
|
97
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { CompiledSchema } from '../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../expression/index.ts'
|
|
3
|
+
import type { Schema } from '../types.ts'
|
|
4
|
+
import type { Context } from './cache.ts'
|
|
5
|
+
|
|
6
|
+
import { ANY } from '../compiler/index.ts'
|
|
7
|
+
import {
|
|
8
|
+
ExpressionNone,
|
|
9
|
+
ExpressionContainedBy,
|
|
10
|
+
ExpressionContaining,
|
|
11
|
+
ExpressionEquals,
|
|
12
|
+
ExpressionIntersection,
|
|
13
|
+
ExpressionRejection,
|
|
14
|
+
ExpressionSingleResult,
|
|
15
|
+
} from '../expression/index.ts'
|
|
16
|
+
import { createRangeSplitter, toExpressionSingleResult } from './range.ts'
|
|
17
|
+
import { makeQuantum } from './tools/index.ts'
|
|
18
|
+
|
|
19
|
+
const splitRange = createRangeSplitter(0)
|
|
20
|
+
const quantum = makeQuantum(['hasCommon', 'hasExtra1', 'hasExtra2', 'hasRejection', 'hasCommonBroken'])
|
|
21
|
+
|
|
22
|
+
export function calculateArray<E>({ calculate }: Context<E>, schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
|
|
23
|
+
const splitResult = splitRange(schema1.minItems, schema1.maxItems, schema2.minItems, schema2.maxItems)
|
|
24
|
+
const splitExpression = toExpressionSingleResult(splitResult)
|
|
25
|
+
|
|
26
|
+
if (splitExpression === ExpressionSingleResult.Rejection) {
|
|
27
|
+
return ExpressionRejection
|
|
28
|
+
}
|
|
29
|
+
const [items1, additionalItems1] = normalizeArray(schema1)
|
|
30
|
+
const [items2, additionalItems2] = normalizeArray(schema2)
|
|
31
|
+
|
|
32
|
+
// The final slot compares additionalItems without a tuple item.
|
|
33
|
+
const itemsLength = Math.max(items1.length, items2.length) + 1
|
|
34
|
+
const length = Math.min(itemsLength, splitResult.intersection!.max)
|
|
35
|
+
const quantumVariable = quantum.variable({})
|
|
36
|
+
const minItems = Math.min(schema1.minItems ?? 0, schema2.minItems ?? 0)
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < length; i++) {
|
|
39
|
+
const subSchema1 = items1[i] ?? additionalItems1
|
|
40
|
+
const subSchema2 = items2[i] ?? additionalItems2
|
|
41
|
+
const expression = calculate(subSchema1, subSchema2)
|
|
42
|
+
|
|
43
|
+
quantumVariable.push(expression, (singleExpression, variable) => {
|
|
44
|
+
switch (singleExpression) {
|
|
45
|
+
case ExpressionSingleResult.Equals: {
|
|
46
|
+
if (!variable.hasRejection) {
|
|
47
|
+
variable.hasCommon = true
|
|
48
|
+
}
|
|
49
|
+
break
|
|
50
|
+
}
|
|
51
|
+
case ExpressionSingleResult.Containing: {
|
|
52
|
+
if (!variable.hasRejection) {
|
|
53
|
+
variable.hasCommon = true
|
|
54
|
+
}
|
|
55
|
+
variable.hasExtra1 = true
|
|
56
|
+
break
|
|
57
|
+
}
|
|
58
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
59
|
+
if (!variable.hasRejection) {
|
|
60
|
+
variable.hasCommon = true
|
|
61
|
+
}
|
|
62
|
+
variable.hasExtra2 = true
|
|
63
|
+
break
|
|
64
|
+
}
|
|
65
|
+
case ExpressionSingleResult.Intersection: {
|
|
66
|
+
if (!variable.hasRejection) {
|
|
67
|
+
variable.hasCommon = true
|
|
68
|
+
}
|
|
69
|
+
variable.hasExtra1 = true
|
|
70
|
+
variable.hasExtra2 = true
|
|
71
|
+
break
|
|
72
|
+
}
|
|
73
|
+
case ExpressionSingleResult.Rejection: {
|
|
74
|
+
if (i < minItems) {
|
|
75
|
+
variable.hasCommonBroken = true
|
|
76
|
+
}
|
|
77
|
+
variable.hasRejection = true
|
|
78
|
+
variable.hasExtra1 = true
|
|
79
|
+
variable.hasExtra2 = true
|
|
80
|
+
break
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
quantumVariable.update((variable) => {
|
|
86
|
+
switch (splitExpression) {
|
|
87
|
+
case ExpressionSingleResult.Containing: {
|
|
88
|
+
variable.hasExtra1 = true
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
case ExpressionSingleResult.ContainedBy: {
|
|
92
|
+
variable.hasExtra2 = true
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
case ExpressionSingleResult.Intersection: {
|
|
96
|
+
variable.hasExtra1 = true
|
|
97
|
+
variable.hasExtra2 = true
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true
|
|
102
|
+
else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true
|
|
103
|
+
if (schema1.maxItems === 0 || schema2.maxItems === 0) {
|
|
104
|
+
// An unconstrained empty array can match any array schema.
|
|
105
|
+
variable.hasCommon = true
|
|
106
|
+
if (schema1.maxItems !== 0) {
|
|
107
|
+
variable.hasExtra1 = true
|
|
108
|
+
}
|
|
109
|
+
if (schema2.maxItems !== 0) {
|
|
110
|
+
variable.hasExtra2 = true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
let expression = ExpressionNone
|
|
115
|
+
|
|
116
|
+
for (const { hasExtra1, hasExtra2, hasCommon, hasCommonBroken } of quantumVariable) {
|
|
117
|
+
let finalHasCommon = hasCommon
|
|
118
|
+
if (hasCommonBroken) {
|
|
119
|
+
finalHasCommon = false
|
|
120
|
+
}
|
|
121
|
+
if (!finalHasCommon) {
|
|
122
|
+
expression |= ExpressionRejection
|
|
123
|
+
} else if (hasExtra1 && hasExtra2) {
|
|
124
|
+
expression |= ExpressionIntersection
|
|
125
|
+
} else if (hasExtra1) {
|
|
126
|
+
expression |= ExpressionContaining
|
|
127
|
+
} else if (hasExtra2) {
|
|
128
|
+
expression |= ExpressionContainedBy
|
|
129
|
+
} else {
|
|
130
|
+
expression |= ExpressionEquals
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return expression
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function normalizeArray<E>({ items, additionalItems }: CompiledSchema<E>): [readonly Schema<E>[], Schema<E>] {
|
|
137
|
+
if (Array.isArray(items)) {
|
|
138
|
+
return [items as readonly Schema<E>[], (additionalItems ?? ANY) as Schema<E>]
|
|
139
|
+
} else {
|
|
140
|
+
return [[], (items ?? ANY) as Schema<E>]
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { CompiledObject, CompiledSchema, CompiledValue } from '../compiler/index.ts'
|
|
2
|
+
import type { ExpressionResult } from '../expression/index.ts'
|
|
3
|
+
import type { ExtendsSchema } from '../extends/index.ts'
|
|
4
|
+
import type { Schema } from '../types.ts'
|
|
5
|
+
import type { DeepReadonly } from '../utils.ts'
|
|
6
|
+
|
|
7
|
+
import { getId, isCompiledObject } from '../compiler/index.ts'
|
|
8
|
+
|
|
9
|
+
export type Context<E> = {
|
|
10
|
+
readonly isEquals: EqualsChecker
|
|
11
|
+
readonly calculate: SchemaCalculator<E>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type EqualsChecker = (value1: CompiledValue, value2: CompiledValue) => boolean
|
|
15
|
+
export type SchemaCalculator<E> = (superSchema: Schema<E>, subSchema: Schema<E>) => ExpressionResult
|
|
16
|
+
|
|
17
|
+
export function wrapEqualsCheckerWithCache(check: (object1: CompiledObject, object2: CompiledObject) => boolean): EqualsChecker {
|
|
18
|
+
const map = new Map<string, boolean>()
|
|
19
|
+
|
|
20
|
+
return (value1, value2) => {
|
|
21
|
+
const isObject1 = isCompiledObject(value1)
|
|
22
|
+
const isObject2 = isCompiledObject(value2)
|
|
23
|
+
|
|
24
|
+
if (isObject1 !== isObject2) {
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
27
|
+
if (!isObject1) {
|
|
28
|
+
return value1 === value2
|
|
29
|
+
}
|
|
30
|
+
const object1 = value1 as CompiledObject
|
|
31
|
+
const object2 = value2 as CompiledObject
|
|
32
|
+
|
|
33
|
+
return getWithCache(map, object1, object2, check)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function wrapSchemaCalculatorWithCache<E>(check: SchemaCalculator<E>): SchemaCalculator<E> {
|
|
38
|
+
const map = new Map<string, ExpressionResult>()
|
|
39
|
+
return (schema1, schema2) => getWithCache(map, schema1, schema2, check)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getWithCache<R, E, N extends ExtendsSchema | DeepReadonly<CompiledSchema<E>> | DeepReadonly<CompiledObject>>(
|
|
43
|
+
map: Map<string, R>,
|
|
44
|
+
node1: N,
|
|
45
|
+
node2: N,
|
|
46
|
+
check: (n1: N, n2: N) => R,
|
|
47
|
+
): R {
|
|
48
|
+
const id1 = getId(node1)
|
|
49
|
+
const id2 = getId(node2)
|
|
50
|
+
const key = `${id1}/${id2}`
|
|
51
|
+
|
|
52
|
+
let result = map.get(key)
|
|
53
|
+
if (result === undefined) {
|
|
54
|
+
map.set(key, (result = check(node1, node2)))
|
|
55
|
+
}
|
|
56
|
+
return result
|
|
57
|
+
}
|
|
@@ -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
|
+
}
|