@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,411 @@
|
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema'
|
|
2
|
+
import type { Schema } from '../types.ts'
|
|
3
|
+
import type { Context } from './common.ts'
|
|
4
|
+
import type { InputSchema } from './compiler.ts'
|
|
5
|
+
import type { CompiledSchema } from './wrapper.ts'
|
|
6
|
+
|
|
7
|
+
import { ValidResult, valid } from '../checker/validator.ts'
|
|
8
|
+
import { recordWarn, isJSONSchemaKey, joinPath, unwrapJSONSchema7Definition } from './common.ts'
|
|
9
|
+
import { compileSchema } from './compiler.ts'
|
|
10
|
+
import { cleanEmptyValues } from './utils.ts'
|
|
11
|
+
import { NEVER, wrapCompiledSchema, toNever, CompiledKind, getKind } from './wrapper.ts'
|
|
12
|
+
|
|
13
|
+
type ObjectKeys =
|
|
14
|
+
| 'type'
|
|
15
|
+
| 'maxProperties'
|
|
16
|
+
| 'minProperties'
|
|
17
|
+
| 'required'
|
|
18
|
+
| 'properties'
|
|
19
|
+
| 'patternProperties'
|
|
20
|
+
| 'additionalProperties'
|
|
21
|
+
| 'dependencies'
|
|
22
|
+
| 'propertyNames'
|
|
23
|
+
|
|
24
|
+
const OBJECT_KEYS = new Set<ObjectKeys>([
|
|
25
|
+
'type',
|
|
26
|
+
'maxProperties',
|
|
27
|
+
'minProperties',
|
|
28
|
+
'required',
|
|
29
|
+
'properties',
|
|
30
|
+
'patternProperties',
|
|
31
|
+
'additionalProperties',
|
|
32
|
+
'dependencies',
|
|
33
|
+
'propertyNames',
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
type PatternProperties<E> = {
|
|
37
|
+
[key: string]: [Schema<E>, RegExp]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type CompiledSchemaMap<E> = {
|
|
41
|
+
[key: string]: Schema<E>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// This internal shape simplifies dependency handling without exposing unsupported schema keywords.
|
|
45
|
+
type DependentRequired = {
|
|
46
|
+
[key: string]: string[]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type DependentTuple<E> = [DependentRequired, CompiledSchemaMap<E>]
|
|
50
|
+
type BanChecker = (key: string) => boolean
|
|
51
|
+
|
|
52
|
+
export function compileObjectSchema<E>(context: Context<E>, schema: InputSchema): CompiledSchema<E> | null {
|
|
53
|
+
const rejectKeys = Object.keys(schema).filter((k) => !OBJECT_KEYS.has(k as ObjectKeys) && isJSONSchemaKey(k))
|
|
54
|
+
if (rejectKeys.length > 0) {
|
|
55
|
+
recordWarn(context, `type="object" will exclude other keys: ${rejectKeys.toSorted().join(', ')}`)
|
|
56
|
+
}
|
|
57
|
+
const maxProperties = getPropertiesLimit(context, 'maxProperties', schema)
|
|
58
|
+
const minProperties = getPropertiesLimit(context, 'minProperties', schema)
|
|
59
|
+
const additionalPropertiesSchema = compileAdditionalProperties(context, schema)
|
|
60
|
+
const patternProperties = compilePatternProperties(context, schema)
|
|
61
|
+
const propertyNames = compilePropertyNames(context, schema)
|
|
62
|
+
const dependentTuple = compileDependencies(context, schema)
|
|
63
|
+
|
|
64
|
+
if (!additionalPropertiesSchema || !patternProperties || !propertyNames || !dependentTuple) {
|
|
65
|
+
return null
|
|
66
|
+
}
|
|
67
|
+
const properties = compileProperties(context, patternProperties, propertyNames, schema)
|
|
68
|
+
|
|
69
|
+
if (!properties) {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
72
|
+
const isBanKey = createBanKeyChecker(additionalPropertiesSchema, patternProperties, propertyNames, properties)
|
|
73
|
+
const required = compileRequired(context, isBanKey, dependentTuple, schema)
|
|
74
|
+
const kind = checkSchemaIsNever(context, additionalPropertiesSchema, properties, required, maxProperties, minProperties)
|
|
75
|
+
? CompiledKind.Never
|
|
76
|
+
: CompiledKind.Object
|
|
77
|
+
|
|
78
|
+
const mergedSchema = cleanEmptyValues({
|
|
79
|
+
type: 'object',
|
|
80
|
+
required,
|
|
81
|
+
properties,
|
|
82
|
+
minProperties,
|
|
83
|
+
maxProperties,
|
|
84
|
+
additionalProperties: additionalPropertiesSchema,
|
|
85
|
+
patternProperties: unwrapPatternProperties(patternProperties),
|
|
86
|
+
dependencies: mergeDependentTuple(dependentTuple, schema),
|
|
87
|
+
propertyNames: propertyNames,
|
|
88
|
+
})
|
|
89
|
+
return wrapCompiledSchema(kind, mergedSchema as JSONSchema7, context.delegate, context.path)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function getPropertiesLimit<E>(context: Context<E>, name: 'maxProperties' | 'minProperties', schema: InputSchema): number | undefined {
|
|
93
|
+
const propertiesLimit = schema[name]
|
|
94
|
+
if (propertiesLimit === undefined) {
|
|
95
|
+
return undefined
|
|
96
|
+
}
|
|
97
|
+
if (Number.isNaN(propertiesLimit)) {
|
|
98
|
+
recordWarn(context, 'find NaN', name)
|
|
99
|
+
return undefined
|
|
100
|
+
}
|
|
101
|
+
if (propertiesLimit < 0) {
|
|
102
|
+
recordWarn(context, `find invalid number ${propertiesLimit}`, name)
|
|
103
|
+
return undefined
|
|
104
|
+
}
|
|
105
|
+
return propertiesLimit
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function compileAdditionalProperties<E>(context: Context<E>, { additionalProperties }: InputSchema): Schema<E> | null {
|
|
109
|
+
if (additionalProperties === false) {
|
|
110
|
+
return wrapCompiledSchema(CompiledKind.Never, { type: 'string', maxLength: 0, minLength: 1 }, context.delegate, context.path)
|
|
111
|
+
}
|
|
112
|
+
if (typeof additionalProperties !== 'object') {
|
|
113
|
+
return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path)
|
|
114
|
+
}
|
|
115
|
+
const subContext = joinPath(context, 'additionalProperties')
|
|
116
|
+
const schema = unwrapJSONSchema7Definition(additionalProperties)
|
|
117
|
+
|
|
118
|
+
return compileSchema(subContext, schema)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function compilePatternProperties<E>(context: Context<E>, { patternProperties }: InputSchema): PatternProperties<E> | null {
|
|
122
|
+
let foundSubError = false
|
|
123
|
+
const target: PatternProperties<E> = {}
|
|
124
|
+
|
|
125
|
+
for (const key in patternProperties) {
|
|
126
|
+
const regExp = wrapRegExp(key)
|
|
127
|
+
if (regExp instanceof Error) {
|
|
128
|
+
recordWarn(context, `property name invalid. ${key}`, 'patternProperties', key)
|
|
129
|
+
continue
|
|
130
|
+
}
|
|
131
|
+
const schema = unwrapJSONSchema7Definition(patternProperties[key])
|
|
132
|
+
const subContext = joinPath(context, 'patternProperties', key)
|
|
133
|
+
const compiledSchema = compileSchema(subContext, schema)
|
|
134
|
+
if (!compiledSchema) {
|
|
135
|
+
foundSubError = true
|
|
136
|
+
continue
|
|
137
|
+
}
|
|
138
|
+
target[key] = [compiledSchema, regExp]
|
|
139
|
+
}
|
|
140
|
+
if (foundSubError) {
|
|
141
|
+
return null
|
|
142
|
+
}
|
|
143
|
+
return target
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function compilePropertyNames<E>(context: Context<E>, { propertyNames }: InputSchema): CompiledSchema<E> | null {
|
|
147
|
+
if (!propertyNames) {
|
|
148
|
+
return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path)
|
|
149
|
+
}
|
|
150
|
+
propertyNames = unwrapJSONSchema7Definition(propertyNames)
|
|
151
|
+
|
|
152
|
+
const subContext = joinPath(context, 'propertyNames')
|
|
153
|
+
const schema = compileSchema(subContext, propertyNames)
|
|
154
|
+
|
|
155
|
+
if (!schema) {
|
|
156
|
+
return null
|
|
157
|
+
}
|
|
158
|
+
const kind = getKind(schema)
|
|
159
|
+
if (kind !== CompiledKind.String && kind !== CompiledKind.Any) {
|
|
160
|
+
// JSON property names can only be strings, so other types cannot match any property.
|
|
161
|
+
return toNever(schema as CompiledSchema<E>)
|
|
162
|
+
}
|
|
163
|
+
return schema as CompiledSchema<E>
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function compileProperties<E>(
|
|
167
|
+
context: Context<E>,
|
|
168
|
+
patternProperties: PatternProperties<E>,
|
|
169
|
+
propertyNamesSchema: CompiledSchema<E>,
|
|
170
|
+
{ properties }: InputSchema,
|
|
171
|
+
): CompiledSchemaMap<E> | null {
|
|
172
|
+
let foundSubError = false
|
|
173
|
+
if (!properties) {
|
|
174
|
+
return {}
|
|
175
|
+
}
|
|
176
|
+
const target: CompiledSchemaMap<E> = {}
|
|
177
|
+
|
|
178
|
+
for (const key in properties) {
|
|
179
|
+
if (valid(propertyNamesSchema, key) === ValidResult.Invalid) {
|
|
180
|
+
recordWarn(context, `key ${JSON.stringify(key)} cannot pass JSON schema from propertyNames`, 'properties')
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
const patternSchema = findPatternSchema(patternProperties, key)
|
|
184
|
+
|
|
185
|
+
if (patternSchema && getKind(patternSchema) === CompiledKind.Never) {
|
|
186
|
+
recordWarn(context, `key ${JSON.stringify(key)} matches a pattern that has a impossible(never) schema`, 'properties')
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
const schema = unwrapJSONSchema7Definition(properties[key])
|
|
190
|
+
const subContext = joinPath(context, 'properties', key)
|
|
191
|
+
const compiledSchema = compileSchema(subContext, schema)
|
|
192
|
+
|
|
193
|
+
if (!compiledSchema) {
|
|
194
|
+
foundSubError = true
|
|
195
|
+
continue
|
|
196
|
+
}
|
|
197
|
+
target[key] = compiledSchema
|
|
198
|
+
}
|
|
199
|
+
if (foundSubError) {
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
|
+
return target
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function compileDependencies<E>(context: Context<E>, { dependencies }: InputSchema): DependentTuple<E> | null {
|
|
206
|
+
if (!dependencies) {
|
|
207
|
+
return [{}, {}]
|
|
208
|
+
}
|
|
209
|
+
const dependentRequired: DependentRequired = {}
|
|
210
|
+
const dependentSchemas: CompiledSchemaMap<E> = {}
|
|
211
|
+
|
|
212
|
+
for (const key in dependencies) {
|
|
213
|
+
const dependency = unwrapJSONSchema7Definition(dependencies[key])
|
|
214
|
+
|
|
215
|
+
if (Array.isArray(dependency)) {
|
|
216
|
+
const { keys, duplicated } = checkUniqueKeys(dependency)
|
|
217
|
+
if (duplicated) {
|
|
218
|
+
recordWarn(context, `found duplicated property names: ${duplicated.join(', ')}`, 'dependencies', key)
|
|
219
|
+
}
|
|
220
|
+
dependentRequired[key] = keys
|
|
221
|
+
} else {
|
|
222
|
+
const subContext = joinPath(context, 'dependencies', key)
|
|
223
|
+
const compiledSchema = compileSchema(subContext, dependency as InputSchema)
|
|
224
|
+
if (compiledSchema) {
|
|
225
|
+
const kind = getKind(compiledSchema)
|
|
226
|
+
if (kind === CompiledKind.Object || kind === CompiledKind.Any) {
|
|
227
|
+
dependentSchemas[key] = compiledSchema
|
|
228
|
+
} else if (kind === CompiledKind.Extends) {
|
|
229
|
+
dependentSchemas[key] = NEVER
|
|
230
|
+
} else {
|
|
231
|
+
dependentSchemas[key] = toNever(compiledSchema as CompiledSchema<E>)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return [dependentRequired, dependentSchemas]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function createBanKeyChecker<E>(
|
|
240
|
+
additionalPropertiesSchema: Schema<E>,
|
|
241
|
+
patternProperties: PatternProperties<E>,
|
|
242
|
+
propertyNamesSchema: CompiledSchema<E>,
|
|
243
|
+
properties: CompiledSchemaMap<E>,
|
|
244
|
+
): BanChecker {
|
|
245
|
+
return (key: string): boolean => {
|
|
246
|
+
if (valid(propertyNamesSchema, key) === ValidResult.Invalid) {
|
|
247
|
+
return true
|
|
248
|
+
}
|
|
249
|
+
const patternSchema = findPatternSchema(patternProperties, key)
|
|
250
|
+
if (patternSchema && getKind(patternSchema) === CompiledKind.Never) {
|
|
251
|
+
return true
|
|
252
|
+
}
|
|
253
|
+
const propertySchema = properties[key] ?? additionalPropertiesSchema
|
|
254
|
+
if (getKind(propertySchema) === CompiledKind.Never) {
|
|
255
|
+
return true
|
|
256
|
+
}
|
|
257
|
+
return false
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function compileRequired<E>(context: Context<E>, isBan: BanChecker, dependentTuple: DependentTuple<E>, { required }: InputSchema): string[] {
|
|
262
|
+
if (!required) {
|
|
263
|
+
return []
|
|
264
|
+
}
|
|
265
|
+
const uniqueCheckedResult = checkUniqueKeys(required)
|
|
266
|
+
if (uniqueCheckedResult.duplicated) {
|
|
267
|
+
recordWarn(context, `found duplicated required keys: ${uniqueCheckedResult.duplicated.join(', ')}`, 'required')
|
|
268
|
+
}
|
|
269
|
+
const requiredKeys: string[] = []
|
|
270
|
+
const banKeys: string[] = []
|
|
271
|
+
|
|
272
|
+
for (const requiredKey of uniqueCheckedResult.keys) {
|
|
273
|
+
const dependentKeys = collectDependencies(dependentTuple, requiredKey)
|
|
274
|
+
if (dependentKeys.some((key) => isBan(key))) {
|
|
275
|
+
banKeys.push(requiredKey)
|
|
276
|
+
} else {
|
|
277
|
+
requiredKeys.push(requiredKey)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (banKeys.length > 0) {
|
|
281
|
+
recordWarn(context, `key ${banKeys.map((k) => JSON.stringify(k)).join(', ')} will ban by another condition`, 'required')
|
|
282
|
+
}
|
|
283
|
+
return requiredKeys
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function checkSchemaIsNever<E>(
|
|
287
|
+
context: Context<E>,
|
|
288
|
+
additionalPropertiesSchema: Schema<E>,
|
|
289
|
+
properties: CompiledSchemaMap<E>,
|
|
290
|
+
required: string[],
|
|
291
|
+
maxProperties?: number,
|
|
292
|
+
minProperties?: number,
|
|
293
|
+
): boolean {
|
|
294
|
+
if (maxProperties !== undefined && minProperties !== undefined && maxProperties < minProperties) {
|
|
295
|
+
recordWarn(context, `maxProperties(${maxProperties}) is less than minProperties(${minProperties})`)
|
|
296
|
+
return true
|
|
297
|
+
}
|
|
298
|
+
if (maxProperties !== undefined && required.length > maxProperties) {
|
|
299
|
+
recordWarn(context, `length(${required.length}) of required is greater than maxProperties(${maxProperties})`)
|
|
300
|
+
return true
|
|
301
|
+
}
|
|
302
|
+
if (minProperties !== undefined && required.length < minProperties) {
|
|
303
|
+
recordWarn(context, `length(${required.length}) of required is less than minProperties(${minProperties})`)
|
|
304
|
+
return true
|
|
305
|
+
}
|
|
306
|
+
if (getKind(additionalPropertiesSchema) !== CompiledKind.Never) {
|
|
307
|
+
return false
|
|
308
|
+
}
|
|
309
|
+
for (const key in properties) {
|
|
310
|
+
const compiledSchema = properties[key]
|
|
311
|
+
if (getKind(compiledSchema) !== CompiledKind.Never) {
|
|
312
|
+
return false
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return true
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function collectDependencies<E>([dependentRequired, dependentSchemas]: DependentTuple<E>, seedKey: string): string[] {
|
|
319
|
+
const queue: string[] = [seedKey]
|
|
320
|
+
const collection = new Set<string>(queue)
|
|
321
|
+
|
|
322
|
+
while (queue.length > 0) {
|
|
323
|
+
const key = queue.pop()!
|
|
324
|
+
const schema = dependentSchemas[key]
|
|
325
|
+
const requiredKeys = dependentRequired[key]
|
|
326
|
+
|
|
327
|
+
if (schema) {
|
|
328
|
+
if (getKind(schema) === CompiledKind.Object) {
|
|
329
|
+
collectKeys((schema as CompiledSchema<E>).required)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (requiredKeys) {
|
|
333
|
+
collectKeys(requiredKeys)
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function collectKeys(keys: string[] | undefined): void {
|
|
337
|
+
if (keys) {
|
|
338
|
+
for (const key of keys) {
|
|
339
|
+
if (!collection.has(key)) {
|
|
340
|
+
collection.add(key)
|
|
341
|
+
queue.push(key)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return [...collection]
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function checkUniqueKeys(keys: readonly string[]): { keys: string[]; duplicated: string[] | null } {
|
|
350
|
+
const checking = new Set<string>()
|
|
351
|
+
const duplicated = new Set<string>()
|
|
352
|
+
|
|
353
|
+
for (const e of keys) {
|
|
354
|
+
if (checking.has(e)) {
|
|
355
|
+
duplicated.add(e)
|
|
356
|
+
} else {
|
|
357
|
+
checking.add(e)
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
if (duplicated.size === 0) {
|
|
361
|
+
return {
|
|
362
|
+
keys: [...keys],
|
|
363
|
+
duplicated: null,
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
return {
|
|
367
|
+
keys: [...checking],
|
|
368
|
+
duplicated: [...duplicated],
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function findPatternSchema<E>(patternProperties: PatternProperties<E>, checkedKey: string): Schema<E> | null {
|
|
374
|
+
for (const key in patternProperties) {
|
|
375
|
+
const [schema, regExp] = patternProperties[key]
|
|
376
|
+
if (regExp.test(checkedKey)) {
|
|
377
|
+
return schema
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return null
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function wrapRegExp(pattern: string): RegExp | Error {
|
|
384
|
+
try {
|
|
385
|
+
return new RegExp(pattern, 'i')
|
|
386
|
+
} catch (error) {
|
|
387
|
+
if (error instanceof SyntaxError) {
|
|
388
|
+
return error
|
|
389
|
+
} else {
|
|
390
|
+
throw error
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function unwrapPatternProperties<E>(patternProperties: PatternProperties<E>): JSONSchema7['patternProperties'] {
|
|
396
|
+
const target: JSONSchema7['patternProperties'] = {}
|
|
397
|
+
for (const key in patternProperties) {
|
|
398
|
+
target[key] = patternProperties[key][0] as JSONSchema7
|
|
399
|
+
}
|
|
400
|
+
return target
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function mergeDependentTuple<E>([dependentRequired, dependentSchemas]: DependentTuple<E>, { dependencies }: InputSchema): JSONSchema7['dependencies'] {
|
|
404
|
+
const target: JSONSchema7['dependencies'] = {}
|
|
405
|
+
for (const key in dependencies) {
|
|
406
|
+
const required = dependentRequired[key]
|
|
407
|
+
const schema = dependentSchemas[key]
|
|
408
|
+
target[key] = required || schema
|
|
409
|
+
}
|
|
410
|
+
return target
|
|
411
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { JSONSchema7, JSONSchema7TypeName } from 'json-schema'
|
|
2
|
+
import type { Context } from './common.ts'
|
|
3
|
+
import type { InputSchema } from './compiler.ts'
|
|
4
|
+
import type { CompiledSchema } from './wrapper.ts'
|
|
5
|
+
|
|
6
|
+
import { pick } from '../utils.ts'
|
|
7
|
+
import { recordError, isJSONSchemaKey, recordWarn } from './common.ts'
|
|
8
|
+
import { CompiledKind, wrapCompiledSchema } from './wrapper.ts'
|
|
9
|
+
|
|
10
|
+
type NumericKeys = 'type' | 'multipleOf' | 'maximum' | 'exclusiveMaximum' | 'minimum' | 'exclusiveMinimum'
|
|
11
|
+
type StringKeys = 'type' | 'format' | 'maxLength' | 'minLength' | 'pattern'
|
|
12
|
+
|
|
13
|
+
const NUMERIC_KEYS = new Set<NumericKeys>(['type', 'multipleOf', 'maximum', 'exclusiveMaximum', 'minimum', 'exclusiveMinimum'])
|
|
14
|
+
const STRING_KEYS = new Set<StringKeys>(['type', 'format', 'maxLength', 'minLength', 'pattern'])
|
|
15
|
+
|
|
16
|
+
export type PrimitiveInputSchema = InputSchema & {
|
|
17
|
+
readonly type: Exclude<JSONSchema7TypeName, 'object' | 'array'>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function compilePrimitiveSchema<E>(context: Context<E>, schema: PrimitiveInputSchema): CompiledSchema<E> | null {
|
|
21
|
+
const { type } = schema
|
|
22
|
+
switch (type) {
|
|
23
|
+
case 'number':
|
|
24
|
+
case 'integer': {
|
|
25
|
+
return compileNumericSchema(context, schema)
|
|
26
|
+
}
|
|
27
|
+
case 'string': {
|
|
28
|
+
return compileStringSchema(context, schema)
|
|
29
|
+
}
|
|
30
|
+
case 'boolean':
|
|
31
|
+
case 'null': {
|
|
32
|
+
const rejectKeys = Object.keys(schema).filter((k) => isJSONSchemaKey(k) && k !== 'type')
|
|
33
|
+
if (rejectKeys.length > 0) {
|
|
34
|
+
recordWarn(context, `key "type" will exclude other keys: ${rejectKeys.toSorted().join(', ')}`)
|
|
35
|
+
}
|
|
36
|
+
const kind = type === 'null' ? CompiledKind.Null : CompiledKind.Boolean
|
|
37
|
+
const compiledSchema = { type }
|
|
38
|
+
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path)
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
recordError(context, `invalid type ${JSON.stringify(type)}`)
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function compileNumericSchema<E>(context: Context<E>, schema: PrimitiveInputSchema): CompiledSchema<E> | null {
|
|
48
|
+
const rejectKeys = Object.keys(schema).filter((k) => !NUMERIC_KEYS.has(k as NumericKeys) && isJSONSchemaKey(k))
|
|
49
|
+
if (rejectKeys.length > 0) {
|
|
50
|
+
recordWarn(context, `type=${JSON.stringify(schema.type)} will exclude other keys: ${rejectKeys.toSorted().join(', ')}`)
|
|
51
|
+
}
|
|
52
|
+
const compiledSchema = pick(schema, NUMERIC_KEYS)
|
|
53
|
+
|
|
54
|
+
for (const key of NUMERIC_KEYS) {
|
|
55
|
+
const value = compiledSchema[key]
|
|
56
|
+
if (key !== 'type' && value !== undefined && Number.isNaN(value)) {
|
|
57
|
+
recordWarn(context, 'found NaN', key)
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
+
delete (compiledSchema as any)[key]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const { maximum, exclusiveMaximum, minimum, exclusiveMinimum } = compiledSchema
|
|
63
|
+
|
|
64
|
+
if (maximum !== undefined && exclusiveMaximum !== undefined) {
|
|
65
|
+
if (maximum === exclusiveMaximum) {
|
|
66
|
+
delete compiledSchema.maximum
|
|
67
|
+
} else if (maximum < exclusiveMaximum) {
|
|
68
|
+
delete compiledSchema.exclusiveMaximum
|
|
69
|
+
} else if (maximum > exclusiveMaximum) {
|
|
70
|
+
delete compiledSchema.maximum
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (minimum !== undefined && exclusiveMinimum !== undefined) {
|
|
74
|
+
if (minimum === exclusiveMinimum) {
|
|
75
|
+
delete compiledSchema.minimum
|
|
76
|
+
} else if (minimum < exclusiveMinimum) {
|
|
77
|
+
delete compiledSchema.exclusiveMinimum
|
|
78
|
+
} else if (minimum > exclusiveMinimum) {
|
|
79
|
+
delete compiledSchema.minimum
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const { multipleOf } = compiledSchema
|
|
83
|
+
|
|
84
|
+
if (multipleOf === 0) {
|
|
85
|
+
delete compiledSchema.multipleOf
|
|
86
|
+
compiledSchema.type = 'number'
|
|
87
|
+
recordWarn(context, 'cannot be 0', 'multipleOf')
|
|
88
|
+
}
|
|
89
|
+
let kind: CompiledKind = CompiledKind.Numeric
|
|
90
|
+
if (!isNumericPossibleInvalid(compiledSchema)) {
|
|
91
|
+
kind = CompiledKind.Never
|
|
92
|
+
}
|
|
93
|
+
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function isNumericPossibleInvalid(compiledSchema: JSONSchema7): boolean {
|
|
97
|
+
const { maximum, exclusiveMaximum, minimum, exclusiveMinimum } = compiledSchema
|
|
98
|
+
|
|
99
|
+
if (maximum !== undefined && minimum !== undefined) {
|
|
100
|
+
return maximum >= minimum
|
|
101
|
+
} else if (exclusiveMaximum !== undefined && minimum !== undefined) {
|
|
102
|
+
return exclusiveMaximum > minimum
|
|
103
|
+
} else if (maximum !== undefined && exclusiveMinimum !== undefined) {
|
|
104
|
+
return maximum > exclusiveMinimum
|
|
105
|
+
} else if (exclusiveMaximum !== undefined && exclusiveMinimum !== undefined) {
|
|
106
|
+
return exclusiveMaximum > exclusiveMinimum
|
|
107
|
+
} else {
|
|
108
|
+
return true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function compileStringSchema<E>(context: Context<E>, schema: PrimitiveInputSchema): CompiledSchema<E> | null {
|
|
113
|
+
const rejectKeys = Object.keys(schema).filter((k) => !STRING_KEYS.has(k as StringKeys) && isJSONSchemaKey(k))
|
|
114
|
+
if (rejectKeys.length > 0) {
|
|
115
|
+
recordWarn(context, `type="string" will exclude other keys: ${rejectKeys.toSorted().join(', ')}`)
|
|
116
|
+
}
|
|
117
|
+
const compiledSchema = pick(schema, STRING_KEYS)
|
|
118
|
+
|
|
119
|
+
cleanInvalidLength(context, compiledSchema, 'maxLength')
|
|
120
|
+
cleanInvalidLength(context, compiledSchema, 'minLength')
|
|
121
|
+
|
|
122
|
+
const max = compiledSchema.maxLength
|
|
123
|
+
const min = compiledSchema.minLength
|
|
124
|
+
let kind: CompiledKind = CompiledKind.String
|
|
125
|
+
|
|
126
|
+
if (max !== undefined) {
|
|
127
|
+
if (max < 0) {
|
|
128
|
+
kind = CompiledKind.Never
|
|
129
|
+
} else if (max !== undefined && min !== undefined && max < min) {
|
|
130
|
+
kind = CompiledKind.Never
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function cleanInvalidLength<E>(context: Context<E>, compiledSchema: JSONSchema7, key: 'maxLength' | 'minLength'): void {
|
|
137
|
+
const length = compiledSchema[key]
|
|
138
|
+
if (length !== undefined) {
|
|
139
|
+
if (Number.isNaN(length)) {
|
|
140
|
+
recordWarn(context, 'found NaN', key)
|
|
141
|
+
delete compiledSchema[key]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function cleanEmptyValues<T extends object>(origin: T): Partial<T> {
|
|
2
|
+
for (const key in origin) {
|
|
3
|
+
const value = origin[key]
|
|
4
|
+
if (value === undefined) {
|
|
5
|
+
delete origin[key]
|
|
6
|
+
} else if (value && typeof value === 'object') {
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
if (value.length === 0) {
|
|
9
|
+
delete origin[key]
|
|
10
|
+
}
|
|
11
|
+
} else if (isEmptyObject(value)) {
|
|
12
|
+
delete origin[key]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return origin
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isEmptyObject(object: object): boolean {
|
|
20
|
+
for (const _ in object) {
|
|
21
|
+
return false
|
|
22
|
+
}
|
|
23
|
+
return true
|
|
24
|
+
}
|