@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.
Files changed (444) hide show
  1. package/LICENSE +36 -0
  2. package/NOTICE +7 -0
  3. package/README.md +41 -0
  4. package/dist/browser/{ContentIcon-CUQHjQIw.js → ContentIcon-FCpKiwjp.js} +2 -1
  5. package/dist/browser/{FlowCanvas-Dtf8_cQp.js → FlowCanvas-dzRBnlUT.js} +1 -1
  6. package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-BeYDdUl-.js} +2 -2
  7. package/dist/browser/{dialog-CUy_fwx9.js → dialog-ZtpsFbl4.js} +337 -31
  8. package/dist/browser/{exportSvg-BOoy7-Db.js → exportSvg-DqXw1yf-.js} +2 -2
  9. package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-b_5UobFj.js} +586 -87
  10. package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-ItojZbO4.js} +21162 -20242
  11. package/dist/browser/preview.css +254 -179
  12. package/dist/browser/preview.js +22201 -20625
  13. package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
  14. package/dist/browser/ui.css +72 -2
  15. package/dist/browser/workbench.css +254 -179
  16. package/dist/browser/workbench.js +22 -78
  17. package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-M441Lz0d.js} +1 -1
  18. package/dist/command/index.js +42 -42
  19. package/dist/common/authoring.d.ts +5 -5
  20. package/dist/common/authoringExamples.d.ts +3 -2
  21. package/dist/common/authoringFields.d.ts +1 -1
  22. package/dist/common/authoringSchema.d.ts +95 -8
  23. package/dist/common/connector-proxy.d.ts +1 -1
  24. package/dist/common/control-api-conformance.d.ts +1 -1
  25. package/dist/common/control-api-conformance.js +119 -31
  26. package/dist/common/control-api.d.ts +4 -3
  27. package/dist/common/control-api.js +117 -29
  28. package/dist/common/control-requests.d.ts +5 -4
  29. package/dist/common/control-requests.js +437 -103
  30. package/dist/common/cron-trigger.d.ts +1 -1
  31. package/dist/common/decision.d.ts +1 -1
  32. package/dist/common/draftOperations.d.ts +1 -1
  33. package/dist/common/engine-contract.d.ts +4 -2
  34. package/dist/common/event-source-definition.d.ts +1 -1
  35. package/dist/common/flow-agent.d.ts +1 -1
  36. package/dist/{browser → common}/flow-authoring-node.d.ts +3 -3
  37. package/dist/{browser → common}/flow-authoring.js +131 -30
  38. package/dist/{browser → common}/flow-change-schema.d.ts +177 -6
  39. package/dist/{browser → common}/flow-change.d.ts +35 -15
  40. package/dist/{browser → common}/flow-change.js +133 -32
  41. package/dist/common/flow-connectionUsage.d.ts +1 -1
  42. package/dist/common/flow-encoding.d.ts +1 -1
  43. package/dist/common/flow-encoding.js +89 -23
  44. package/dist/common/flow-errorHandling.d.ts +1 -1
  45. package/dist/common/flow-graph.d.ts +3 -2
  46. package/dist/common/flow-modules.d.ts +1 -1
  47. package/dist/common/flow-promptTemplate.d.ts +1 -1
  48. package/dist/common/flow-retry.d.ts +2 -2
  49. package/dist/common/flow-semantics.d.ts +1 -1
  50. package/dist/common/flow-semantics.js +966 -614
  51. package/dist/common/flow-workflowFile.d.ts +1 -1
  52. package/dist/common/flowInspection.d.ts +3 -3
  53. package/dist/common/http-request.d.ts +156 -0
  54. package/dist/common/http-request.js +5254 -0
  55. package/dist/common/integration-trigger.d.ts +1 -1
  56. package/dist/common/licenses.md +118 -1
  57. package/dist/common/liveDetails.d.ts +1 -1
  58. package/dist/common/mcp.d.ts +5 -4
  59. package/dist/common/mcp.js +117 -29
  60. package/dist/common/openapi.d.ts +1 -1
  61. package/dist/common/poll-trigger.d.ts +1 -1
  62. package/dist/common/run-events.js +11 -9
  63. package/dist/common/run-results.d.ts +8 -1
  64. package/dist/common/runtime-contract.d.ts +8 -2
  65. package/dist/common/runtime-contract.js +25 -5
  66. package/dist/common/scheduler-checkpoint.d.ts +1 -1
  67. package/dist/common/scheduler-dependencies.d.ts +1 -1
  68. package/dist/common/scheduler-node-execution.d.ts +1 -1
  69. package/dist/common/scheduler.d.ts +3 -3
  70. package/dist/common/scheduler.js +101 -33
  71. package/dist/common/trigger-catalog.d.ts +1 -1
  72. package/dist/common/trigger-config-options.d.ts +1 -1
  73. package/dist/common/trigger-config.d.ts +1 -1
  74. package/dist/common/trigger-contract.d.ts +2 -2
  75. package/dist/common/trigger-localization.d.ts +1 -1
  76. package/dist/common/webhook-response.d.ts +1 -3
  77. package/dist/common/webhook-trigger.d.ts +1 -1
  78. package/dist/common/webhook-trigger.js +12 -11
  79. package/dist/common/workflow.d.ts +17 -1
  80. package/dist/common/workflow.js +68 -22
  81. package/dist/index.d.ts +6 -3
  82. package/package.json +11 -6
  83. package/skills/open-flow/references/flow-authoring.md +1 -0
  84. package/skills/open-flow/references/flow-n8n-conversion.md +19 -15
  85. package/src/base/common/json.ts +90 -0
  86. package/src/canvas/common/commands.ts +15 -0
  87. package/src/connector/common/actionSchema.ts +168 -0
  88. package/src/connector/common/proxy.ts +44 -0
  89. package/src/control/common/api.ts +1506 -0
  90. package/src/control/common/authoring.ts +923 -0
  91. package/src/control/common/authoringCondition.ts +110 -0
  92. package/src/control/common/authoringDiagnosticFields.ts +136 -0
  93. package/src/control/common/authoringExamples.ts +200 -0
  94. package/src/control/common/authoringFields.ts +53 -0
  95. package/src/control/common/authoringLlm.ts +70 -0
  96. package/src/control/common/authoringOpenApi.ts +129 -0
  97. package/src/control/common/authoringSchema.ts +410 -0
  98. package/src/control/common/authoringTools.ts +123 -0
  99. package/src/control/common/authoringTriggers.ts +26 -0
  100. package/src/control/common/checkDecoders.ts +65 -0
  101. package/src/control/common/conformance.ts +1989 -0
  102. package/src/control/common/connectorDecoders.ts +370 -0
  103. package/src/control/common/connectorQueries.ts +61 -0
  104. package/src/control/common/decoding.ts +60 -0
  105. package/src/control/common/draftOperations.ts +61 -0
  106. package/src/control/common/errors.ts +114 -0
  107. package/src/control/common/eventSourceSchemas.ts +13 -0
  108. package/src/control/common/eventSources.ts +186 -0
  109. package/src/control/common/flowDecoders.ts +153 -0
  110. package/src/control/common/flowInspection.ts +181 -0
  111. package/src/control/common/flowNotifications.ts +37 -0
  112. package/src/control/common/liveDetails.ts +124 -0
  113. package/src/control/common/mcp.ts +241 -0
  114. package/src/control/common/mcpConformance.ts +142 -0
  115. package/src/control/common/providerAccess.ts +28 -0
  116. package/src/control/common/providerIconSprite.ts +42 -0
  117. package/src/control/common/publicationDecoders.ts +98 -0
  118. package/src/control/common/random.ts +16 -0
  119. package/src/control/common/requests.ts +112 -0
  120. package/src/control/common/resultQuery.ts +8 -0
  121. package/src/control/common/results.ts +176 -0
  122. package/src/control/common/revisionDecoders.ts +52 -0
  123. package/src/control/common/runDecoders.ts +240 -0
  124. package/src/control/common/triggerCatalog.ts +89 -0
  125. package/src/control/common/triggerDecoders.ts +175 -0
  126. package/src/decision/common/decision.ts +168 -0
  127. package/src/event-source/common/catalog.generated.json +65 -0
  128. package/src/event-source/common/definition.ts +66 -0
  129. package/src/event-source/common/index.ts +99 -0
  130. package/src/execution/common/checkpoint.ts +311 -0
  131. package/src/execution/common/dependencies.ts +440 -0
  132. package/src/execution/common/engineContract.ts +84 -0
  133. package/src/execution/common/events.ts +331 -0
  134. package/src/execution/common/node-execution.ts +469 -0
  135. package/src/execution/common/runLifecycle.ts +250 -0
  136. package/src/execution/common/runtime.ts +563 -0
  137. package/src/execution/common/scheduler.ts +697 -0
  138. package/src/execution/common/wait.ts +36 -0
  139. package/src/flow/common/agent.ts +305 -0
  140. package/src/flow/common/authoring.ts +30 -0
  141. package/src/flow/common/change.ts +1037 -0
  142. package/src/flow/common/changeSchema.ts +792 -0
  143. package/src/flow/common/codePermissions.ts +2 -0
  144. package/src/flow/common/condition.ts +265 -0
  145. package/src/flow/common/connectionUsage.ts +131 -0
  146. package/src/flow/common/edgeChanges.ts +35 -0
  147. package/src/flow/common/encoding.ts +437 -0
  148. package/src/flow/common/errorHandling.ts +34 -0
  149. package/src/flow/common/graph.ts +898 -0
  150. package/src/flow/common/inputValue.ts +16 -0
  151. package/src/flow/common/json.ts +8 -0
  152. package/src/flow/common/moduleChanges.ts +31 -0
  153. package/src/flow/common/modules.ts +292 -0
  154. package/src/flow/common/nodeChanges.ts +762 -0
  155. package/src/flow/common/portChanges.ts +36 -0
  156. package/src/flow/common/promptTemplate.ts +15 -0
  157. package/src/flow/common/retry.ts +20 -0
  158. package/src/flow/common/schema.ts +162 -0
  159. package/src/flow/common/schemaCompare.ts +176 -0
  160. package/src/flow/common/schemaComparer.ts +178 -0
  161. package/src/flow/common/schemaKeywords.ts +53 -0
  162. package/src/flow/common/semantics.ts +531 -0
  163. package/src/flow/common/sourceField.ts +35 -0
  164. package/src/flow/common/triggerScheduleSchema.ts +8 -0
  165. package/src/flow/common/wait.ts +30 -0
  166. package/src/flow/common/webhookMethod.ts +7 -0
  167. package/src/flow/common/webhookResponse.ts +71 -0
  168. package/src/flow/common/workflowFile.ts +97 -0
  169. package/src/http/common/authBindings.ts +12 -0
  170. package/src/http/common/headers.ts +5 -0
  171. package/src/http/common/httpRequest.ts +251 -0
  172. package/src/json-schema-subset/checker/array.ts +142 -0
  173. package/src/json-schema-subset/checker/cache.ts +57 -0
  174. package/src/json-schema-subset/checker/checker.ts +230 -0
  175. package/src/json-schema-subset/checker/enumAndConst.ts +113 -0
  176. package/src/json-schema-subset/checker/equals.ts +93 -0
  177. package/src/json-schema-subset/checker/numeric/checker.ts +50 -0
  178. package/src/json-schema-subset/checker/numeric/float.ts +121 -0
  179. package/src/json-schema-subset/checker/numeric/index.ts +1 -0
  180. package/src/json-schema-subset/checker/numeric/integer.ts +119 -0
  181. package/src/json-schema-subset/checker/numeric/integerNormalizer.ts +72 -0
  182. package/src/json-schema-subset/checker/object.ts +354 -0
  183. package/src/json-schema-subset/checker/range.ts +91 -0
  184. package/src/json-schema-subset/checker/string.ts +60 -0
  185. package/src/json-schema-subset/checker/tools/index.ts +3 -0
  186. package/src/json-schema-subset/checker/tools/mark.ts +82 -0
  187. package/src/json-schema-subset/checker/tools/quantum.ts +106 -0
  188. package/src/json-schema-subset/checker/tools/range.ts +210 -0
  189. package/src/json-schema-subset/checker/validator.ts +23 -0
  190. package/src/json-schema-subset/compiler/array.ts +163 -0
  191. package/src/json-schema-subset/compiler/combination.ts +109 -0
  192. package/src/json-schema-subset/compiler/common.ts +99 -0
  193. package/src/json-schema-subset/compiler/compiler.ts +188 -0
  194. package/src/json-schema-subset/compiler/enumAndConst.ts +75 -0
  195. package/src/json-schema-subset/compiler/index.ts +11 -0
  196. package/src/json-schema-subset/compiler/object.ts +411 -0
  197. package/src/json-schema-subset/compiler/primitive.ts +144 -0
  198. package/src/json-schema-subset/compiler/utils.ts +24 -0
  199. package/src/json-schema-subset/compiler/wrapper.ts +192 -0
  200. package/src/json-schema-subset/error.ts +55 -0
  201. package/src/json-schema-subset/expression/calculator.ts +442 -0
  202. package/src/json-schema-subset/expression/combination.ts +49 -0
  203. package/src/json-schema-subset/expression/expression.ts +191 -0
  204. package/src/json-schema-subset/expression/index.ts +25 -0
  205. package/src/json-schema-subset/expression/result.ts +88 -0
  206. package/src/json-schema-subset/expression/types.ts +36 -0
  207. package/src/json-schema-subset/extends/extendsContext.ts +89 -0
  208. package/src/json-schema-subset/extends/index.ts +2 -0
  209. package/src/json-schema-subset/extends/types.ts +12 -0
  210. package/src/json-schema-subset/global.ts +60 -0
  211. package/src/json-schema-subset/index.ts +8 -0
  212. package/src/json-schema-subset/preprocessing.ts +74 -0
  213. package/src/json-schema-subset/types.ts +8 -0
  214. package/src/json-schema-subset/utils.ts +95 -0
  215. package/src/localization/common/languages.ts +118 -0
  216. package/src/localization/common/timeZone.ts +25 -0
  217. package/src/openapi/common/openapi.ts +459 -0
  218. package/src/trigger/common/config.ts +56 -0
  219. package/src/trigger/common/configOptions.ts +15 -0
  220. package/src/trigger/common/configSchema.ts +8 -0
  221. package/src/trigger/common/contract.ts +132 -0
  222. package/src/trigger/common/cron.ts +151 -0
  223. package/src/trigger/common/integration.ts +498 -0
  224. package/src/trigger/common/poll.ts +187 -0
  225. package/src/trigger/common/webhook.ts +413 -0
  226. package/src/trigger/providers/airtable/locales/fr.json +18 -0
  227. package/src/trigger/providers/airtable/locales/ja.json +18 -0
  228. package/src/trigger/providers/airtable/locales/ko.json +18 -0
  229. package/src/trigger/providers/airtable/locales/ru.json +18 -0
  230. package/src/trigger/providers/airtable/locales/zh-CN.json +18 -0
  231. package/src/trigger/providers/airtable/locales/zh-TW.json +18 -0
  232. package/src/trigger/providers/asana/locales/fr.json +15 -0
  233. package/src/trigger/providers/asana/locales/ja.json +15 -0
  234. package/src/trigger/providers/asana/locales/ko.json +15 -0
  235. package/src/trigger/providers/asana/locales/ru.json +15 -0
  236. package/src/trigger/providers/asana/locales/zh-CN.json +15 -0
  237. package/src/trigger/providers/asana/locales/zh-TW.json +15 -0
  238. package/src/trigger/providers/calendly/locales/fr.json +16 -0
  239. package/src/trigger/providers/calendly/locales/ja.json +16 -0
  240. package/src/trigger/providers/calendly/locales/ko.json +16 -0
  241. package/src/trigger/providers/calendly/locales/ru.json +16 -0
  242. package/src/trigger/providers/calendly/locales/zh-CN.json +16 -0
  243. package/src/trigger/providers/calendly/locales/zh-TW.json +16 -0
  244. package/src/trigger/providers/catalog.generated.json +4996 -0
  245. package/src/trigger/providers/clickup/locales/fr.json +16 -0
  246. package/src/trigger/providers/clickup/locales/ja.json +16 -0
  247. package/src/trigger/providers/clickup/locales/ko.json +16 -0
  248. package/src/trigger/providers/clickup/locales/ru.json +16 -0
  249. package/src/trigger/providers/clickup/locales/zh-CN.json +16 -0
  250. package/src/trigger/providers/clickup/locales/zh-TW.json +16 -0
  251. package/src/trigger/providers/definitions.ts +19 -0
  252. package/src/trigger/providers/feishu/locales/fr.json +20 -0
  253. package/src/trigger/providers/feishu/locales/ja.json +20 -0
  254. package/src/trigger/providers/feishu/locales/ko.json +20 -0
  255. package/src/trigger/providers/feishu/locales/ru.json +20 -0
  256. package/src/trigger/providers/feishu/locales/zh-CN.json +20 -0
  257. package/src/trigger/providers/feishu/locales/zh-TW.json +20 -0
  258. package/src/trigger/providers/fieldDescriptions.ts +392 -0
  259. package/src/trigger/providers/fieldLabels.ts +256 -0
  260. package/src/trigger/providers/fireflies/locales/fr.json +17 -0
  261. package/src/trigger/providers/fireflies/locales/ja.json +17 -0
  262. package/src/trigger/providers/fireflies/locales/ko.json +17 -0
  263. package/src/trigger/providers/fireflies/locales/ru.json +17 -0
  264. package/src/trigger/providers/fireflies/locales/zh-CN.json +17 -0
  265. package/src/trigger/providers/fireflies/locales/zh-TW.json +17 -0
  266. package/src/trigger/providers/github/locales/fr.json +30 -0
  267. package/src/trigger/providers/github/locales/ja.json +30 -0
  268. package/src/trigger/providers/github/locales/ko.json +30 -0
  269. package/src/trigger/providers/github/locales/ru.json +30 -0
  270. package/src/trigger/providers/github/locales/zh-CN.json +30 -0
  271. package/src/trigger/providers/github/locales/zh-TW.json +30 -0
  272. package/src/trigger/providers/gitlab/locales/fr.json +18 -0
  273. package/src/trigger/providers/gitlab/locales/ja.json +18 -0
  274. package/src/trigger/providers/gitlab/locales/ko.json +18 -0
  275. package/src/trigger/providers/gitlab/locales/ru.json +18 -0
  276. package/src/trigger/providers/gitlab/locales/zh-CN.json +18 -0
  277. package/src/trigger/providers/gitlab/locales/zh-TW.json +18 -0
  278. package/src/trigger/providers/gmail/locales/fr.json +18 -0
  279. package/src/trigger/providers/gmail/locales/ja.json +18 -0
  280. package/src/trigger/providers/gmail/locales/ko.json +18 -0
  281. package/src/trigger/providers/gmail/locales/ru.json +18 -0
  282. package/src/trigger/providers/gmail/locales/zh-CN.json +18 -0
  283. package/src/trigger/providers/gmail/locales/zh-TW.json +18 -0
  284. package/src/trigger/providers/google-calendar/locales/fr.json +15 -0
  285. package/src/trigger/providers/google-calendar/locales/ja.json +15 -0
  286. package/src/trigger/providers/google-calendar/locales/ko.json +15 -0
  287. package/src/trigger/providers/google-calendar/locales/ru.json +15 -0
  288. package/src/trigger/providers/google-calendar/locales/zh-CN.json +15 -0
  289. package/src/trigger/providers/google-calendar/locales/zh-TW.json +15 -0
  290. package/src/trigger/providers/google-drive/locales/fr.json +48 -0
  291. package/src/trigger/providers/google-drive/locales/ja.json +48 -0
  292. package/src/trigger/providers/google-drive/locales/ko.json +48 -0
  293. package/src/trigger/providers/google-drive/locales/ru.json +48 -0
  294. package/src/trigger/providers/google-drive/locales/zh-CN.json +48 -0
  295. package/src/trigger/providers/google-drive/locales/zh-TW.json +48 -0
  296. package/src/trigger/providers/google-sheets/locales/fr.json +19 -0
  297. package/src/trigger/providers/google-sheets/locales/ja.json +19 -0
  298. package/src/trigger/providers/google-sheets/locales/ko.json +19 -0
  299. package/src/trigger/providers/google-sheets/locales/ru.json +19 -0
  300. package/src/trigger/providers/google-sheets/locales/zh-CN.json +19 -0
  301. package/src/trigger/providers/google-sheets/locales/zh-TW.json +19 -0
  302. package/src/trigger/providers/intercom/locales/fr.json +17 -0
  303. package/src/trigger/providers/intercom/locales/ja.json +17 -0
  304. package/src/trigger/providers/intercom/locales/ko.json +17 -0
  305. package/src/trigger/providers/intercom/locales/ru.json +17 -0
  306. package/src/trigger/providers/intercom/locales/zh-CN.json +17 -0
  307. package/src/trigger/providers/intercom/locales/zh-TW.json +17 -0
  308. package/src/trigger/providers/jira/locales/fr.json +17 -0
  309. package/src/trigger/providers/jira/locales/ja.json +17 -0
  310. package/src/trigger/providers/jira/locales/ko.json +17 -0
  311. package/src/trigger/providers/jira/locales/ru.json +17 -0
  312. package/src/trigger/providers/jira/locales/zh-CN.json +17 -0
  313. package/src/trigger/providers/jira/locales/zh-TW.json +17 -0
  314. package/src/trigger/providers/linear/locales/fr.json +13 -0
  315. package/src/trigger/providers/linear/locales/ja.json +13 -0
  316. package/src/trigger/providers/linear/locales/ko.json +13 -0
  317. package/src/trigger/providers/linear/locales/ru.json +13 -0
  318. package/src/trigger/providers/linear/locales/zh-CN.json +13 -0
  319. package/src/trigger/providers/linear/locales/zh-TW.json +13 -0
  320. package/src/trigger/providers/locales/fr.ts +71 -0
  321. package/src/trigger/providers/locales/ja.ts +71 -0
  322. package/src/trigger/providers/locales/ko.ts +71 -0
  323. package/src/trigger/providers/locales/ru.ts +71 -0
  324. package/src/trigger/providers/locales/zh-CN.ts +71 -0
  325. package/src/trigger/providers/locales/zh-TW.ts +71 -0
  326. package/src/trigger/providers/localization.ts +59 -0
  327. package/src/trigger/providers/notion/locales/fr.json +16 -0
  328. package/src/trigger/providers/notion/locales/ja.json +16 -0
  329. package/src/trigger/providers/notion/locales/ko.json +16 -0
  330. package/src/trigger/providers/notion/locales/ru.json +16 -0
  331. package/src/trigger/providers/notion/locales/zh-CN.json +16 -0
  332. package/src/trigger/providers/notion/locales/zh-TW.json +16 -0
  333. package/src/trigger/providers/one-drive/locales/fr.json +16 -0
  334. package/src/trigger/providers/one-drive/locales/ja.json +16 -0
  335. package/src/trigger/providers/one-drive/locales/ko.json +16 -0
  336. package/src/trigger/providers/one-drive/locales/ru.json +16 -0
  337. package/src/trigger/providers/one-drive/locales/zh-CN.json +16 -0
  338. package/src/trigger/providers/one-drive/locales/zh-TW.json +16 -0
  339. package/src/trigger/providers/outlook/locales/fr.json +18 -0
  340. package/src/trigger/providers/outlook/locales/ja.json +18 -0
  341. package/src/trigger/providers/outlook/locales/ko.json +18 -0
  342. package/src/trigger/providers/outlook/locales/ru.json +18 -0
  343. package/src/trigger/providers/outlook/locales/zh-CN.json +18 -0
  344. package/src/trigger/providers/outlook/locales/zh-TW.json +18 -0
  345. package/src/trigger/providers/pandadoc/locales/fr.json +12 -0
  346. package/src/trigger/providers/pandadoc/locales/ja.json +12 -0
  347. package/src/trigger/providers/pandadoc/locales/ko.json +12 -0
  348. package/src/trigger/providers/pandadoc/locales/ru.json +12 -0
  349. package/src/trigger/providers/pandadoc/locales/zh-CN.json +12 -0
  350. package/src/trigger/providers/pandadoc/locales/zh-TW.json +12 -0
  351. package/src/trigger/providers/pipedrive/locales/fr.json +15 -0
  352. package/src/trigger/providers/pipedrive/locales/ja.json +15 -0
  353. package/src/trigger/providers/pipedrive/locales/ko.json +15 -0
  354. package/src/trigger/providers/pipedrive/locales/ru.json +15 -0
  355. package/src/trigger/providers/pipedrive/locales/zh-CN.json +15 -0
  356. package/src/trigger/providers/pipedrive/locales/zh-TW.json +15 -0
  357. package/src/trigger/providers/remote.ts +163 -0
  358. package/src/trigger/providers/resend/locales/fr.json +16 -0
  359. package/src/trigger/providers/resend/locales/ja.json +16 -0
  360. package/src/trigger/providers/resend/locales/ko.json +16 -0
  361. package/src/trigger/providers/resend/locales/ru.json +16 -0
  362. package/src/trigger/providers/resend/locales/zh-CN.json +16 -0
  363. package/src/trigger/providers/resend/locales/zh-TW.json +16 -0
  364. package/src/trigger/providers/sentry/locales/fr.json +19 -0
  365. package/src/trigger/providers/sentry/locales/ja.json +19 -0
  366. package/src/trigger/providers/sentry/locales/ko.json +19 -0
  367. package/src/trigger/providers/sentry/locales/ru.json +19 -0
  368. package/src/trigger/providers/sentry/locales/zh-CN.json +19 -0
  369. package/src/trigger/providers/sentry/locales/zh-TW.json +19 -0
  370. package/src/trigger/providers/shopify/locales/fr.json +18 -0
  371. package/src/trigger/providers/shopify/locales/ja.json +18 -0
  372. package/src/trigger/providers/shopify/locales/ko.json +18 -0
  373. package/src/trigger/providers/shopify/locales/ru.json +18 -0
  374. package/src/trigger/providers/shopify/locales/zh-CN.json +18 -0
  375. package/src/trigger/providers/shopify/locales/zh-TW.json +18 -0
  376. package/src/trigger/providers/slack/locales/fr.json +18 -0
  377. package/src/trigger/providers/slack/locales/ja.json +18 -0
  378. package/src/trigger/providers/slack/locales/ko.json +18 -0
  379. package/src/trigger/providers/slack/locales/ru.json +18 -0
  380. package/src/trigger/providers/slack/locales/zh-CN.json +18 -0
  381. package/src/trigger/providers/slack/locales/zh-TW.json +18 -0
  382. package/src/trigger/providers/slackbot/locales/fr.json +23 -0
  383. package/src/trigger/providers/slackbot/locales/ja.json +23 -0
  384. package/src/trigger/providers/slackbot/locales/ko.json +23 -0
  385. package/src/trigger/providers/slackbot/locales/ru.json +23 -0
  386. package/src/trigger/providers/slackbot/locales/zh-CN.json +23 -0
  387. package/src/trigger/providers/slackbot/locales/zh-TW.json +23 -0
  388. package/src/trigger/providers/source-events.ts +25 -0
  389. package/src/trigger/providers/stripe/locales/fr.json +17 -0
  390. package/src/trigger/providers/stripe/locales/ja.json +17 -0
  391. package/src/trigger/providers/stripe/locales/ko.json +17 -0
  392. package/src/trigger/providers/stripe/locales/ru.json +17 -0
  393. package/src/trigger/providers/stripe/locales/zh-CN.json +17 -0
  394. package/src/trigger/providers/stripe/locales/zh-TW.json +17 -0
  395. package/src/trigger/providers/tally/locales/fr.json +12 -0
  396. package/src/trigger/providers/tally/locales/ja.json +12 -0
  397. package/src/trigger/providers/tally/locales/ko.json +12 -0
  398. package/src/trigger/providers/tally/locales/ru.json +12 -0
  399. package/src/trigger/providers/tally/locales/zh-CN.json +12 -0
  400. package/src/trigger/providers/tally/locales/zh-TW.json +12 -0
  401. package/src/trigger/providers/telegram/locales/fr.json +17 -0
  402. package/src/trigger/providers/telegram/locales/ja.json +17 -0
  403. package/src/trigger/providers/telegram/locales/ko.json +17 -0
  404. package/src/trigger/providers/telegram/locales/ru.json +17 -0
  405. package/src/trigger/providers/telegram/locales/zh-CN.json +17 -0
  406. package/src/trigger/providers/telegram/locales/zh-TW.json +17 -0
  407. package/src/trigger/providers/typeform/locales/fr.json +12 -0
  408. package/src/trigger/providers/typeform/locales/ja.json +12 -0
  409. package/src/trigger/providers/typeform/locales/ko.json +12 -0
  410. package/src/trigger/providers/typeform/locales/ru.json +12 -0
  411. package/src/trigger/providers/typeform/locales/zh-CN.json +12 -0
  412. package/src/trigger/providers/typeform/locales/zh-TW.json +12 -0
  413. package/src/trigger/providers/vercel/locales/fr.json +18 -0
  414. package/src/trigger/providers/vercel/locales/ja.json +18 -0
  415. package/src/trigger/providers/vercel/locales/ko.json +18 -0
  416. package/src/trigger/providers/vercel/locales/ru.json +18 -0
  417. package/src/trigger/providers/vercel/locales/zh-CN.json +18 -0
  418. package/src/trigger/providers/vercel/locales/zh-TW.json +18 -0
  419. package/src/trigger/providers/woocommerce/locales/fr.json +19 -0
  420. package/src/trigger/providers/woocommerce/locales/ja.json +19 -0
  421. package/src/trigger/providers/woocommerce/locales/ko.json +19 -0
  422. package/src/trigger/providers/woocommerce/locales/ru.json +19 -0
  423. package/src/trigger/providers/woocommerce/locales/zh-CN.json +19 -0
  424. package/src/trigger/providers/woocommerce/locales/zh-TW.json +19 -0
  425. package/src/trigger/providers/zendesk/locales/fr.json +15 -0
  426. package/src/trigger/providers/zendesk/locales/ja.json +15 -0
  427. package/src/trigger/providers/zendesk/locales/ko.json +15 -0
  428. package/src/trigger/providers/zendesk/locales/ru.json +15 -0
  429. package/src/trigger/providers/zendesk/locales/zh-CN.json +15 -0
  430. package/src/trigger/providers/zendesk/locales/zh-TW.json +15 -0
  431. package/src/trigger/providers/zoom/locales/fr.json +17 -0
  432. package/src/trigger/providers/zoom/locales/ja.json +17 -0
  433. package/src/trigger/providers/zoom/locales/ko.json +17 -0
  434. package/src/trigger/providers/zoom/locales/ru.json +17 -0
  435. package/src/trigger/providers/zoom/locales/zh-CN.json +17 -0
  436. package/src/trigger/providers/zoom/locales/zh-TW.json +17 -0
  437. package/src/types/index.ts +112 -0
  438. package/src/workflow/common/workflow.ts +273 -0
  439. package/dist/browser/lib-DrKav3HG.js +0 -11403
  440. /package/dist/{browser → common}/flow-authoring-edge.d.ts +0 -0
  441. /package/dist/{browser → common}/flow-authoring-module.d.ts +0 -0
  442. /package/dist/{browser → common}/flow-authoring.d.ts +0 -0
  443. /package/dist/{browser → common}/flow-input-value.d.ts +0 -0
  444. /package/dist/{browser → common}/webhook-method.d.ts +0 -0
@@ -0,0 +1,119 @@
1
+ import type { CompiledSchema } from '../../compiler/index.ts'
2
+ import type { ExpressionResult } from '../../expression/index.ts'
3
+ import type { Range } from '../tools/index.ts'
4
+ import type { Integer } from './integerNormalizer.ts'
5
+
6
+ import { ExpressionEquals, ExpressionContaining, ExpressionContainedBy, ExpressionIntersection, ExpressionRejection } from '../../expression/index.ts'
7
+ import { splitRange } from '../tools/index.ts'
8
+ import { cutRange, normalizeInteger } from './integerNormalizer.ts'
9
+
10
+ export function calculateInteger<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
11
+ const integer1 = normalizeInteger(schema1)
12
+ const integer2 = normalizeInteger(schema2)
13
+
14
+ if (!integer1 && !integer2) {
15
+ return ExpressionEquals
16
+ }
17
+ if (!integer1) {
18
+ return ExpressionContainedBy
19
+ }
20
+ if (!integer2) {
21
+ return ExpressionContaining
22
+ }
23
+ const { range: range1, multipleOf: multipleOf1 } = integer1
24
+ const { range: range2, multipleOf: multipleOf2 } = integer2
25
+ const result = splitRange(range1, range2)
26
+
27
+ let centerRange: Range | undefined
28
+ let lcm = 0
29
+
30
+ if (result.center) {
31
+ lcm = getLCM(multipleOf1, multipleOf2)
32
+ centerRange = cutRange(result.center, lcm)
33
+ }
34
+ if (!centerRange) {
35
+ return ExpressionRejection
36
+ }
37
+ let extraLeft = false
38
+ let extraRight = false
39
+
40
+ const { left, right } = result
41
+
42
+ if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
43
+ if (left.fromLeft) {
44
+ extraLeft = true
45
+ } else {
46
+ extraRight = true
47
+ }
48
+ }
49
+ if (right && cutRange(right.range, right.fromLeft ? multipleOf1 : multipleOf2)) {
50
+ if (right.fromLeft) {
51
+ extraLeft = true
52
+ } else {
53
+ extraRight = true
54
+ }
55
+ }
56
+ extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm)
57
+ extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm)
58
+
59
+ if (extraLeft && extraRight) {
60
+ return ExpressionIntersection
61
+ }
62
+ if (extraLeft) {
63
+ return ExpressionContaining
64
+ }
65
+ if (extraRight) {
66
+ return ExpressionContainedBy
67
+ }
68
+ return ExpressionEquals
69
+ }
70
+
71
+ function hasExtraIntegersOnCenter({ range, multipleOf }: Integer, lcmCenterRange: Range, lcm: number): boolean {
72
+ const result = splitRange(range, lcmCenterRange)
73
+
74
+ if (cutRange(result.left?.range, multipleOf)) {
75
+ return true
76
+ }
77
+ if (cutRange(result.right?.range, multipleOf)) {
78
+ return true
79
+ }
80
+ const center = cutRange(result.center, multipleOf)
81
+
82
+ if (!center) {
83
+ return false
84
+ }
85
+ const lcmCenterLength = rangeLength(lcmCenterRange)
86
+
87
+ if (rangeLength(center) > lcmCenterLength) {
88
+ return true
89
+ }
90
+ if (lcmCenterLength === 1) {
91
+ return false
92
+ }
93
+ if (multipleOf < lcm) {
94
+ return true
95
+ }
96
+ return false
97
+ }
98
+
99
+ /** Returns the least common multiple. */
100
+ function getLCM(a: number, b: number): number {
101
+ return (a * b) / getGCD(a, b)
102
+ }
103
+
104
+ /** @returns The greatest common divisor. */
105
+ function getGCD(a: number, b: number): number {
106
+ if (a === 0) {
107
+ return b
108
+ }
109
+ return getGCD(b % a, a)
110
+ }
111
+
112
+ function rangeLength(range?: Range): number {
113
+ if (!range) {
114
+ return 0
115
+ }
116
+ const [point1, point2] = range
117
+ // Both endpoints are inclusive, so the range length includes one extra value.
118
+ return point2.num - point1.num + 1
119
+ }
@@ -0,0 +1,72 @@
1
+ import type { CompiledSchema } from '../../compiler/index.ts'
2
+ import type { Range } from '../tools/index.ts'
3
+
4
+ import { pickRange } from './float.ts'
5
+
6
+ export type Integer = {
7
+ readonly multipleOf: number
8
+ readonly range: Range
9
+ }
10
+
11
+ export function normalizeInteger<E>(schema: CompiledSchema<E>): Integer | null {
12
+ const floatRange = pickRange(schema)
13
+ const multipleOf = schema.multipleOf ?? 1
14
+ const range = cutRange(floatRange, multipleOf)
15
+
16
+ if (!range) {
17
+ return null
18
+ }
19
+ return { multipleOf, range }
20
+ }
21
+
22
+ export function isPointRange([point1, point2]: Range): boolean {
23
+ if (point1.num !== point2.num) {
24
+ return false
25
+ }
26
+ if (point1.exclusive) {
27
+ return false
28
+ }
29
+ if (point2.exclusive) {
30
+ return false
31
+ }
32
+ return true
33
+ }
34
+
35
+ export function cutRange(range: Range | undefined, multipleOf: number): Range | undefined {
36
+ if (!range) {
37
+ return undefined
38
+ }
39
+ const [originMin, originMax] = range
40
+ let min = nextInteger(originMin.num, multipleOf)
41
+ let max = previousInteger(originMax.num, multipleOf)
42
+
43
+ if (min === originMin.num && originMin.exclusive) {
44
+ min += multipleOf
45
+ }
46
+ if (max === originMax.num && originMax.exclusive) {
47
+ max -= multipleOf
48
+ }
49
+ if (min > max) {
50
+ return undefined
51
+ }
52
+ if (min === max) {
53
+ if (min === Number.POSITIVE_INFINITY) {
54
+ return undefined
55
+ }
56
+ if (min === Number.NEGATIVE_INFINITY) {
57
+ return undefined
58
+ }
59
+ }
60
+ return [
61
+ { num: min, exclusive: false },
62
+ { num: max, exclusive: false },
63
+ ]
64
+ }
65
+
66
+ function nextInteger(float: number, multipleOf: number): number {
67
+ return Math.ceil(float / multipleOf) * multipleOf
68
+ }
69
+
70
+ function previousInteger(float: number, multipleOf: number): number {
71
+ return Math.floor(float / multipleOf) * multipleOf
72
+ }
@@ -0,0 +1,354 @@
1
+ import type { CompiledSchema } from '../compiler/index.ts'
2
+ import type { ExpressionResult } from '../expression/index.ts'
3
+ import type { Schema } from '../types.ts'
4
+ import type { Context } from './cache.ts'
5
+ import type { QuantumVariableType } from './tools/index.ts'
6
+
7
+ import { getKind, ANY, NEVER, CompiledKind } from '../compiler/index.ts'
8
+ import {
9
+ ExpressionNone,
10
+ ExpressionEquals,
11
+ ExpressionContaining,
12
+ ExpressionContainedBy,
13
+ ExpressionIntersection,
14
+ ExpressionRejection,
15
+ ExpressionSingleResult,
16
+ } from '../expression/index.ts'
17
+ import { createRangeSplitter, toExpressionSingleResult } from './range.ts'
18
+ import { makeQuantum } from './tools/index.ts'
19
+ import { ValidResult, valid } from './validator.ts'
20
+
21
+ const splitRange = createRangeSplitter(0)
22
+ const quantum = makeQuantum(['hasCommonInRequired', 'hasCommonOutRequired', 'hasExtra1', 'hasExtra2', 'hasRejection'])
23
+
24
+ // TODO: Handle object schemas introduced by the unsupported dependencies keyword.
25
+ export function calculateObject<E>(context: Context<E>, schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
26
+ if (isPropertiesCountCannotMatch(schema1, schema2)) {
27
+ return ExpressionRejection
28
+ }
29
+ const splitRequiredResult = splitRequired(schema1, schema2)
30
+
31
+ if (!splitRequiredResult) {
32
+ return ExpressionRejection
33
+ }
34
+ const getProperty1 = createPropertySchemaGetter(schema1)
35
+ const getProperty2 = createPropertySchemaGetter(schema2)
36
+ const calculateKey = (key: string): ExpressionResult => {
37
+ const propertySchema1 = getProperty1(key)
38
+ const propertySchema2 = getProperty2(key)
39
+
40
+ if (areNotBothNever(propertySchema1, propertySchema2)) {
41
+ return context.calculate(propertySchema1, propertySchema2)
42
+ } else {
43
+ return ExpressionNone
44
+ }
45
+ }
46
+ const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult
47
+ const quantumVariable = quantum.variable({})
48
+
49
+ for (const requiredKey of [...commonRequired].toSorted()) {
50
+ quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression)
51
+ }
52
+ for (const requiredKey of [...extraRequired1].toSorted()) {
53
+ quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1)
54
+ }
55
+ for (const requiredKey of [...extraRequired2].toSorted()) {
56
+ quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2)
57
+ }
58
+ const { hasOptional1, hasOptional2 } = splitRequiredResult
59
+
60
+ if (hasOptional1 || hasOptional2) {
61
+ const calculator = calculateOptionalExpression(hasOptional1, hasOptional2)
62
+
63
+ for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
64
+ const expression = calculateKey(optionalKey)
65
+ if (expression !== ExpressionNone) {
66
+ quantumVariable.push(expression, calculator)
67
+ }
68
+ }
69
+ const additionalProperties1 = (schema1.additionalProperties as Schema<E>) ?? ANY
70
+ const additionalProperties2 = (schema2.additionalProperties as Schema<E>) ?? ANY
71
+
72
+ if (areNotBothNever(additionalProperties1, additionalProperties2)) {
73
+ const expression = context.calculate(additionalProperties1, additionalProperties2)
74
+ quantumVariable.push(expression, calculator)
75
+ }
76
+ }
77
+ quantumVariable.update((variable) => {
78
+ if (!variable.hasRejection) {
79
+ // Fewer required properties leave more possibilities outside the common set.
80
+ if (extraRequired1.size > 0) {
81
+ variable.hasExtra2 = true
82
+ }
83
+ if (extraRequired2.size > 0) {
84
+ variable.hasExtra1 = true
85
+ }
86
+ }
87
+ })
88
+ const { requiredKeysCount } = splitRequiredResult
89
+ let expression = ExpressionNone
90
+
91
+ for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) {
92
+ if (!hasCommonInRequired && requiredKeysCount > 0) {
93
+ expression |= ExpressionRejection
94
+ } else if (!hasCommonOutRequired && requiredKeysCount === 0) {
95
+ expression |= ExpressionRejection
96
+ } else if (hasRejection) {
97
+ expression |= ExpressionRejection
98
+ } else if (hasExtra1 && hasExtra2) {
99
+ expression |= ExpressionIntersection
100
+ } else if (hasExtra1) {
101
+ expression |= ExpressionContaining
102
+ } else if (hasExtra2) {
103
+ expression |= ExpressionContainedBy
104
+ } else {
105
+ expression |= ExpressionEquals
106
+ }
107
+ }
108
+ return expression
109
+ }
110
+
111
+ function isPropertiesCountCannotMatch<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): boolean {
112
+ const splitResult = splitRange(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)
113
+ const splitExpression = toExpressionSingleResult(splitResult)
114
+
115
+ return splitExpression === ExpressionSingleResult.Rejection
116
+ }
117
+
118
+ type SplitRequiredResult = {
119
+ readonly requiredKeysCount: number
120
+ readonly commonRequired: Set<string>
121
+ readonly extraRequired1: Set<string>
122
+ readonly extraRequired2: Set<string>
123
+ readonly hasOptional1: boolean
124
+ readonly hasOptional2: boolean
125
+ }
126
+
127
+ function splitRequired<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): SplitRequiredResult | null {
128
+ const extraRequired1 = new Set<string>(schema1.required)
129
+ const extraRequired2 = new Set<string>(schema2.required)
130
+ const commonRequired = new Set<string>()
131
+ const wholeRequired = new Set<string>()
132
+
133
+ const requiredCount1 = extraRequired1.size
134
+ const requiredCount2 = extraRequired2.size
135
+
136
+ for (const key of extraRequired1) {
137
+ if (extraRequired2.has(key)) {
138
+ commonRequired.add(key)
139
+ }
140
+ wholeRequired.add(key)
141
+ }
142
+ for (const key of extraRequired2) {
143
+ if (extraRequired1.has(key)) {
144
+ commonRequired.add(key)
145
+ }
146
+ wholeRequired.add(key)
147
+ }
148
+ const requiredKeysCount = wholeRequired.size
149
+
150
+ for (const key of commonRequired) {
151
+ extraRequired1.delete(key)
152
+ extraRequired2.delete(key)
153
+ }
154
+ const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER
155
+ const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER
156
+
157
+ if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) {
158
+ return null
159
+ }
160
+ return {
161
+ requiredKeysCount,
162
+ extraRequired1,
163
+ extraRequired2,
164
+ commonRequired,
165
+ hasOptional1: maxProperties1 > requiredCount1,
166
+ hasOptional2: maxProperties2 > requiredCount2,
167
+ }
168
+ }
169
+
170
+ function getOptionalKeys<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): Set<string> {
171
+ const optionalKeys = new Set<string>(schema1.required)
172
+ const properties1 = schema1.properties
173
+ const properties2 = schema2.properties
174
+ const required1 = schema1.required
175
+ const required2 = schema2.required
176
+
177
+ if (properties1) {
178
+ for (const key in properties1) {
179
+ optionalKeys.add(key)
180
+ }
181
+ }
182
+ if (properties2) {
183
+ for (const key in properties2) {
184
+ optionalKeys.add(key)
185
+ }
186
+ }
187
+ if (required1) {
188
+ for (const key of required1) {
189
+ optionalKeys.delete(key)
190
+ }
191
+ }
192
+ if (required2) {
193
+ for (const key of required2) {
194
+ optionalKeys.delete(key)
195
+ }
196
+ }
197
+ return optionalKeys
198
+ }
199
+
200
+ const calculateCommonRequiredExpression = (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
201
+ switch (singleExpression) {
202
+ case ExpressionSingleResult.Equals: {
203
+ variable.hasCommonInRequired = true
204
+ break
205
+ }
206
+ case ExpressionSingleResult.Containing: {
207
+ variable.hasExtra1 = true
208
+ variable.hasCommonInRequired = true
209
+ break
210
+ }
211
+ case ExpressionSingleResult.ContainedBy: {
212
+ variable.hasExtra2 = true
213
+ variable.hasCommonInRequired = true
214
+ break
215
+ }
216
+ case ExpressionSingleResult.Intersection: {
217
+ variable.hasExtra1 = true
218
+ variable.hasExtra2 = true
219
+ variable.hasCommonInRequired = true
220
+ break
221
+ }
222
+ case ExpressionSingleResult.Rejection: {
223
+ variable.hasRejection = true
224
+ break
225
+ }
226
+ }
227
+ }
228
+
229
+ const calculateExtraRequiredExpression1 = (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
230
+ switch (singleExpression) {
231
+ case ExpressionSingleResult.Equals:
232
+ case ExpressionSingleResult.ContainedBy: {
233
+ variable.hasCommonInRequired = true
234
+ break
235
+ }
236
+ case ExpressionSingleResult.Intersection:
237
+ case ExpressionSingleResult.Containing: {
238
+ variable.hasExtra1 = true
239
+ variable.hasCommonInRequired = true
240
+ break
241
+ }
242
+ case ExpressionSingleResult.Rejection: {
243
+ variable.hasRejection = true
244
+ break
245
+ }
246
+ }
247
+ }
248
+
249
+ const calculateExtraRequiredExpression2 = (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
250
+ switch (singleExpression) {
251
+ case ExpressionSingleResult.Equals:
252
+ case ExpressionSingleResult.Containing: {
253
+ variable.hasCommonInRequired = true
254
+ break
255
+ }
256
+ case ExpressionSingleResult.Intersection:
257
+ case ExpressionSingleResult.ContainedBy: {
258
+ variable.hasExtra2 = true
259
+ variable.hasCommonInRequired = true
260
+ break
261
+ }
262
+ case ExpressionSingleResult.Rejection: {
263
+ variable.hasRejection = true
264
+ break
265
+ }
266
+ }
267
+ }
268
+
269
+ const calculateOptionalExpression =
270
+ (hasOptional1: boolean, hasOptional2: boolean) =>
271
+ (singleExpression: ExpressionSingleResult, variable: QuantumVariableType<typeof quantum>): void => {
272
+ if (variable.hasRejection) {
273
+ return
274
+ }
275
+ let foundExtraPossibility1 = false
276
+ let foundExtraPossibility2 = false
277
+ let foundCommonPossibility = false
278
+
279
+ switch (singleExpression) {
280
+ case ExpressionSingleResult.Equals: {
281
+ foundCommonPossibility = true
282
+ break
283
+ }
284
+ case ExpressionSingleResult.Containing: {
285
+ foundExtraPossibility1 = true
286
+ foundCommonPossibility = true
287
+ break
288
+ }
289
+ case ExpressionSingleResult.ContainedBy: {
290
+ foundExtraPossibility2 = true
291
+ foundCommonPossibility = true
292
+ break
293
+ }
294
+ case ExpressionSingleResult.Intersection: {
295
+ foundExtraPossibility1 = true
296
+ foundExtraPossibility2 = true
297
+ foundCommonPossibility = true
298
+ break
299
+ }
300
+ case ExpressionSingleResult.Rejection: {
301
+ foundExtraPossibility1 = true
302
+ foundExtraPossibility2 = true
303
+ break
304
+ }
305
+ }
306
+ if (hasOptional1 && foundExtraPossibility1) {
307
+ variable.hasExtra1 = true
308
+ }
309
+ if (hasOptional2 && foundExtraPossibility2) {
310
+ variable.hasExtra2 = true
311
+ }
312
+ if (hasOptional1 && hasOptional2 && foundCommonPossibility) {
313
+ variable.hasCommonOutRequired = true
314
+ }
315
+ }
316
+
317
+ type PropertySchemaGetter<E> = (key: string) => Schema<E>
318
+
319
+ function createPropertySchemaGetter<E>(schema: CompiledSchema<E>): PropertySchemaGetter<E> {
320
+ const properties = schema.properties as Readonly<{ [key: string]: CompiledSchema<E> }> | undefined
321
+ const propertyNames = schema.propertyNames as CompiledSchema<E> | undefined
322
+ const additionalProperties = schema.additionalProperties as Schema<E> | undefined
323
+ const patternProperties: { pattern: RegExp; schema: Schema<E> }[] = []
324
+
325
+ if (schema.patternProperties) {
326
+ for (const pattern in schema.patternProperties) {
327
+ const valueSchema = schema.patternProperties[pattern] as Schema<E>
328
+ const regExp = new RegExp(pattern, 'i')
329
+ patternProperties.push({ pattern: regExp, schema: valueSchema })
330
+ }
331
+ }
332
+ return (key) => {
333
+ if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) {
334
+ return NEVER
335
+ }
336
+ for (const { pattern, schema: patternSchema } of patternProperties) {
337
+ if (pattern.test(key)) {
338
+ return patternSchema
339
+ }
340
+ }
341
+ const propertySchema = (properties && properties[key]) ?? additionalProperties
342
+
343
+ if (!propertySchema) {
344
+ return ANY
345
+ }
346
+ return propertySchema
347
+ }
348
+ }
349
+
350
+ function areNotBothNever<E>(schema1: Schema<E>, schema2: Schema<E>): boolean {
351
+ const kind1 = getKind(schema1)
352
+ const kind2 = getKind(schema2)
353
+ return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never
354
+ }
@@ -0,0 +1,91 @@
1
+ import { ExpressionSingleResult } from '../expression/index.ts'
2
+ import { splitRange } from './tools/index.ts'
3
+
4
+ export type RangeSplitter = (min1?: number, max1?: number, min2?: number, max2?: number) => RangeSplitResult
5
+ export type RangeSplitResult = {
6
+ readonly left?: RangeItem & { readonly isFrom1: boolean }
7
+ readonly right?: RangeItem & { readonly isFrom1: boolean }
8
+ readonly intersection?: RangeItem
9
+ }
10
+
11
+ export type RangeItem = {
12
+ readonly min: number
13
+ readonly max: number
14
+ }
15
+
16
+ export const createRangeSplitter =
17
+ (undefinedMin: number): RangeSplitter =>
18
+ (min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
19
+ const { left, center, right } = splitRange(
20
+ [
21
+ { num: min1, exclusive: false },
22
+ { num: max1, exclusive: false },
23
+ ],
24
+ [
25
+ { num: min2, exclusive: false },
26
+ { num: max2, exclusive: false },
27
+ ],
28
+ )
29
+ let leftItem: RangeSplitResult['left']
30
+ let rightItem: RangeSplitResult['right']
31
+ let intersectionItem: RangeSplitResult['intersection']
32
+
33
+ if (left) {
34
+ leftItem = {
35
+ min: left.range[0].num,
36
+ max: left.range[1].num,
37
+ isFrom1: left.fromLeft,
38
+ }
39
+ }
40
+ if (right) {
41
+ rightItem = {
42
+ min: right.range[0].num,
43
+ max: right.range[1].num,
44
+ isFrom1: right.fromLeft,
45
+ }
46
+ }
47
+ if (center) {
48
+ intersectionItem = {
49
+ min: center[0].num,
50
+ max: center[1].num,
51
+ }
52
+ }
53
+ return {
54
+ left: leftItem,
55
+ right: rightItem,
56
+ intersection: intersectionItem,
57
+ }
58
+ }
59
+
60
+ export function toExpressionSingleResult({ left, right, intersection }: RangeSplitResult): ExpressionSingleResult {
61
+ if (!intersection) {
62
+ return ExpressionSingleResult.Rejection
63
+ }
64
+ let extra1 = false
65
+ let extra2 = false
66
+
67
+ if (left) {
68
+ if (left.isFrom1) {
69
+ extra1 = true
70
+ } else {
71
+ extra2 = true
72
+ }
73
+ }
74
+ if (right) {
75
+ if (right.isFrom1) {
76
+ extra1 = true
77
+ } else {
78
+ extra2 = true
79
+ }
80
+ }
81
+ if (extra1 && extra2) {
82
+ return ExpressionSingleResult.Intersection
83
+ }
84
+ if (extra1) {
85
+ return ExpressionSingleResult.Containing
86
+ }
87
+ if (extra2) {
88
+ return ExpressionSingleResult.ContainedBy
89
+ }
90
+ return ExpressionSingleResult.Equals
91
+ }
@@ -0,0 +1,60 @@
1
+ import type { CompiledSchema } from '../compiler/index.ts'
2
+ import type { ExpressionResult } from '../expression/index.ts'
3
+
4
+ import {
5
+ ExpressionAny,
6
+ ExpressionEquals,
7
+ ExpressionContaining,
8
+ ExpressionContainedBy,
9
+ ExpressionIntersection,
10
+ ExpressionRejection,
11
+ ExpressionSingleResult,
12
+ } from '../expression/index.ts'
13
+ import { createRangeSplitter, toExpressionSingleResult } from './range.ts'
14
+
15
+ const splitRange = createRangeSplitter(0)
16
+
17
+ export function calculateString<E>(schema1: CompiledSchema<E>, schema2: CompiledSchema<E>): ExpressionResult {
18
+ if (schema2.format && !schema1.format) return ExpressionContaining
19
+ if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny
20
+ const splitResult = splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength)
21
+ const expression = toExpressionSingleResult(splitResult)
22
+ const hasPattern1 = !!schema1.pattern
23
+ const hasPattern2 = !!schema2.pattern
24
+
25
+ switch (expression) {
26
+ case ExpressionSingleResult.Rejection: {
27
+ return ExpressionRejection
28
+ }
29
+ case ExpressionSingleResult.Containing: {
30
+ return hasPattern1 ? ExpressionAny : ExpressionContaining
31
+ }
32
+ case ExpressionSingleResult.ContainedBy: {
33
+ return hasPattern2 ? ExpressionAny : ExpressionContainedBy
34
+ }
35
+ case ExpressionSingleResult.Equals: {
36
+ if (hasPattern1 && hasPattern2) {
37
+ return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny
38
+ }
39
+ if (hasPattern1) {
40
+ return ExpressionEquals | ExpressionContainedBy
41
+ }
42
+ if (hasPattern2) {
43
+ return ExpressionEquals | ExpressionContaining
44
+ }
45
+ return ExpressionEquals
46
+ }
47
+ case ExpressionSingleResult.Intersection: {
48
+ if (hasPattern1 && hasPattern2) {
49
+ return ExpressionAny
50
+ }
51
+ if (hasPattern1) {
52
+ return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy
53
+ }
54
+ if (hasPattern2) {
55
+ return ExpressionIntersection | ExpressionRejection | ExpressionContaining
56
+ }
57
+ return ExpressionIntersection
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,3 @@
1
+ export * from './mark.ts'
2
+ export * from './quantum.ts'
3
+ export * from './range.ts'