@openapi-flow/core 0.1.0 → 0.2.0

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 (239) hide show
  1. package/README.md +27 -5
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/arguments/list-api-request-media-types.d.ts +2 -0
  4. package/dist/arguments/list-api-request-media-types.js +8 -0
  5. package/dist/arguments/request-contract.d.ts +4 -0
  6. package/dist/arguments/request-contract.js +38 -0
  7. package/dist/arguments/request-media-type-priority.d.ts +2 -0
  8. package/dist/arguments/request-media-type-priority.js +8 -0
  9. package/dist/arguments/select-default-api-request-media-type.d.ts +3 -0
  10. package/dist/arguments/select-default-api-request-media-type.js +17 -0
  11. package/dist/arguments/validate-api-arguments.d.ts +2 -0
  12. package/dist/arguments/validate-api-arguments.js +140 -0
  13. package/dist/bindings/combine-binding-schemas.d.ts +4 -0
  14. package/dist/bindings/combine-binding-schemas.js +17 -0
  15. package/dist/bindings/create-native-array-item-schema.d.ts +4 -0
  16. package/dist/bindings/create-native-array-item-schema.js +16 -0
  17. package/dist/bindings/json-pointer.d.ts +3 -0
  18. package/dist/bindings/json-pointer.js +24 -0
  19. package/dist/bindings/materialize-api-arguments.d.ts +4 -0
  20. package/dist/bindings/materialize-api-arguments.js +54 -0
  21. package/dist/bindings/native-binding-schema.d.ts +3 -0
  22. package/dist/bindings/native-binding-schema.js +6 -0
  23. package/dist/bindings/project-array-item-schema.d.ts +5 -0
  24. package/dist/bindings/project-array-item-schema.js +67 -0
  25. package/dist/bindings/request-binding-schema.d.ts +2 -0
  26. package/dist/bindings/request-binding-schema.js +23 -0
  27. package/dist/bindings/request-container-kind.d.ts +3 -0
  28. package/dist/bindings/request-container-kind.js +17 -0
  29. package/dist/bindings/resources/clone-schema-resource.d.ts +3 -0
  30. package/dist/bindings/resources/clone-schema-resource.js +38 -0
  31. package/dist/bindings/resources/create-schema-resource-context.d.ts +4 -0
  32. package/dist/bindings/resources/create-schema-resource-context.js +130 -0
  33. package/dist/bindings/response-binding-schema.d.ts +3 -0
  34. package/dist/bindings/response-binding-schema.js +21 -0
  35. package/dist/bindings/schema-allows-container.d.ts +3 -0
  36. package/dist/bindings/schema-allows-container.js +20 -0
  37. package/dist/bindings/schema-at-pointer.d.ts +4 -0
  38. package/dist/bindings/schema-at-pointer.js +89 -0
  39. package/dist/bindings/validate-api-binding-assignments.d.ts +2 -0
  40. package/dist/bindings/validate-api-binding-assignments.js +81 -0
  41. package/dist/bindings/validate-api-binding-gaps.d.ts +2 -0
  42. package/dist/bindings/validate-api-binding-gaps.js +10 -0
  43. package/dist/bindings/validate-api-binding-plan.d.ts +3 -0
  44. package/dist/bindings/validate-api-binding-plan.js +11 -0
  45. package/dist/bindings/validate-native-output-contracts.d.ts +3 -0
  46. package/dist/bindings/validate-native-output-contracts.js +16 -0
  47. package/dist/internal-api.d.ts +30 -0
  48. package/dist/internal-api.js +25 -0
  49. package/dist/openapi/catalog/create-api-catalog.d.ts +2 -0
  50. package/dist/openapi/catalog/create-api-catalog.js +34 -0
  51. package/dist/openapi/catalog/list-api-operations.d.ts +2 -0
  52. package/dist/openapi/catalog/list-api-operations.js +3 -0
  53. package/dist/openapi/common/check-oas-value.d.ts +3 -0
  54. package/dist/openapi/common/check-oas-value.js +6 -0
  55. package/dist/openapi/common/check-schema-value.d.ts +2 -0
  56. package/dist/openapi/common/check-schema-value.js +12 -0
  57. package/dist/openapi/common/create-oas-value-validator.d.ts +3 -0
  58. package/dist/openapi/common/create-oas-value-validator.js +39 -0
  59. package/dist/openapi/common/normalize-oas-value-schema.d.ts +4 -0
  60. package/dist/openapi/common/normalize-oas-value-schema.js +50 -0
  61. package/dist/openapi/common/operation-metadata.d.ts +2 -0
  62. package/dist/openapi/common/operation-metadata.js +25 -0
  63. package/dist/openapi/common/operation-reference.d.ts +3 -0
  64. package/dist/openapi/{operation-reference.js → common/operation-reference.js} +1 -4
  65. package/dist/openapi/common/parse-spec-utils.d.ts +3 -0
  66. package/dist/openapi/common/parse-spec-utils.js +12 -0
  67. package/dist/openapi/common/resolve-openapi-security.d.ts +3 -0
  68. package/dist/openapi/common/resolve-openapi-security.js +28 -0
  69. package/dist/openapi/common/unsupported-operation-error.d.ts +4 -0
  70. package/dist/openapi/common/unsupported-operation-error.js +8 -0
  71. package/dist/openapi/common/validate-spec.d.ts +3 -0
  72. package/dist/openapi/{validate-spec.js → common/validate-spec.js} +2 -1
  73. package/dist/openapi/inbound/callback/parse-callback-operations.d.ts +3 -0
  74. package/dist/openapi/inbound/callback/parse-callback-operations.js +31 -0
  75. package/dist/openapi/inbound/inbound-path-item-operations.d.ts +4 -0
  76. package/dist/openapi/inbound/inbound-path-item-operations.js +31 -0
  77. package/dist/openapi/inbound/list-inbound-operations.d.ts +4 -0
  78. package/dist/openapi/inbound/list-inbound-operations.js +13 -0
  79. package/dist/openapi/inbound/webhook/parse-webhook-operations.d.ts +3 -0
  80. package/dist/openapi/inbound/webhook/parse-webhook-operations.js +13 -0
  81. package/dist/openapi/request/create-operation-catalog.d.ts +2 -0
  82. package/dist/openapi/request/create-operation-catalog.js +24 -0
  83. package/dist/openapi/request/encode-form-field.d.ts +2 -0
  84. package/dist/openapi/request/encode-form-field.js +6 -0
  85. package/dist/openapi/request/map-http-operation-contract.d.ts +4 -0
  86. package/dist/openapi/request/map-http-operation-contract.js +21 -0
  87. package/dist/openapi/request/operation-mapping.d.ts +3 -0
  88. package/dist/openapi/request/operation-mapping.js +10 -0
  89. package/dist/openapi/request/parse-operation-responses.d.ts +3 -0
  90. package/dist/openapi/request/parse-operation-responses.js +30 -0
  91. package/dist/openapi/request/parse-request-body.d.ts +3 -0
  92. package/dist/openapi/request/parse-request-body.js +29 -0
  93. package/dist/openapi/request/parse-request-operations.d.ts +7 -0
  94. package/dist/openapi/request/parse-request-operations.js +50 -0
  95. package/dist/openapi/request/parse-request-parameters.d.ts +3 -0
  96. package/dist/openapi/request/parse-request-parameters.js +93 -0
  97. package/dist/openapi/request/parse-security.d.ts +3 -0
  98. package/dist/openapi/request/parse-security.js +31 -0
  99. package/dist/openapi/request/request-operation-reference.d.ts +1 -0
  100. package/dist/openapi/request/request-operation-reference.js +4 -0
  101. package/dist/openapi/request/response-contract.d.ts +6 -0
  102. package/dist/openapi/request/response-contract.js +32 -0
  103. package/dist/openapi/request/scalar-response-schema.d.ts +2 -0
  104. package/dist/openapi/request/scalar-response-schema.js +20 -0
  105. package/dist/openapi/request/serialize-form-body.d.ts +3 -0
  106. package/dist/openapi/request/serialize-form-body.js +89 -0
  107. package/dist/openapi/request/serialize-parameter.d.ts +5 -0
  108. package/dist/openapi/request/serialize-parameter.js +145 -0
  109. package/dist/openapi/resolve-api-operations.d.ts +3 -0
  110. package/dist/openapi/resolve-api-operations.js +84 -0
  111. package/dist/openapi/response/api-response-validation-value.d.ts +3 -0
  112. package/dist/openapi/response/api-response-validation-value.js +21 -0
  113. package/dist/openapi/response/create-api-response-schema.d.ts +4 -0
  114. package/dist/openapi/response/create-api-response-schema.js +114 -0
  115. package/dist/openapi/response/create-response-array-item-schema.d.ts +4 -0
  116. package/dist/openapi/response/create-response-array-item-schema.js +12 -0
  117. package/dist/openapi/response/create-response-value-schema.d.ts +4 -0
  118. package/dist/openapi/response/create-response-value-schema.js +8 -0
  119. package/dist/openapi/response/list-api-response-pointers.d.ts +4 -0
  120. package/dist/openapi/response/list-api-response-pointers.js +30 -0
  121. package/dist/openapi/response/list-declared-schema-pointers.d.ts +4 -0
  122. package/dist/openapi/response/list-declared-schema-pointers.js +91 -0
  123. package/dist/public-api.d.ts +49 -7
  124. package/dist/public-api.js +35 -5
  125. package/dist/runtime-api.d.ts +6 -0
  126. package/dist/runtime-api.js +7 -0
  127. package/dist/schemas/create-api-argument-generation-contract.d.ts +4 -0
  128. package/dist/schemas/create-api-argument-generation-contract.js +72 -0
  129. package/dist/schemas/create-api-arguments-schema.d.ts +3 -0
  130. package/dist/schemas/create-api-arguments-schema.js +4 -0
  131. package/dist/schemas/create-api-request-schema.d.ts +4 -0
  132. package/dist/schemas/create-api-request-schema.js +50 -0
  133. package/dist/schemas/create-oas-value-schema.d.ts +6 -0
  134. package/dist/schemas/create-oas-value-schema.js +25 -0
  135. package/dist/schemas/operation-plan-schema.d.ts +8 -0
  136. package/dist/schemas/operation-plan-schema.js +99 -0
  137. package/dist/schemas/project-literal-array-schema.d.ts +4 -0
  138. package/dist/schemas/project-literal-array-schema.js +55 -0
  139. package/dist/schemas/project-literal-input-schema.d.ts +3 -0
  140. package/dist/schemas/project-literal-input-schema.js +129 -0
  141. package/dist/types/api-argument-generation.d.ts +13 -0
  142. package/dist/types/api-arguments.d.ts +42 -0
  143. package/dist/types/api-arguments.js +1 -0
  144. package/dist/types/api-bindings.d.ts +34 -0
  145. package/dist/types/api-bindings.js +1 -0
  146. package/dist/types/api-catalog.d.ts +34 -0
  147. package/dist/types/api-catalog.js +1 -0
  148. package/dist/types/api-operation.d.ts +26 -0
  149. package/dist/types/api-operation.js +1 -0
  150. package/dist/types/api-response-pointers.d.ts +20 -0
  151. package/dist/types/api-response-pointers.js +1 -0
  152. package/dist/types/api-response.d.ts +14 -0
  153. package/dist/types/api-response.js +1 -0
  154. package/dist/types/array-projection.d.ts +5 -0
  155. package/dist/types/array-projection.js +1 -0
  156. package/dist/types/catalog.d.ts +17 -0
  157. package/dist/types/catalog.js +1 -0
  158. package/dist/types/inbound.d.ts +18 -0
  159. package/dist/types/inbound.js +1 -0
  160. package/dist/types/legacy-plan.d.ts +47 -0
  161. package/dist/types/legacy-plan.js +1 -0
  162. package/dist/types/node-output.d.ts +11 -0
  163. package/dist/types/node-output.js +1 -0
  164. package/dist/types/oas-value-validation.d.ts +8 -0
  165. package/dist/types/oas-value-validation.js +1 -0
  166. package/dist/types/openapi.d.ts +7 -23
  167. package/dist/types/request.d.ts +41 -0
  168. package/dist/types/request.js +1 -0
  169. package/dist/types/reviewable-workflow.d.ts +53 -0
  170. package/dist/types/reviewable-workflow.js +1 -0
  171. package/dist/types/schema-dialect.d.ts +1 -0
  172. package/dist/types/schema-dialect.js +1 -0
  173. package/dist/types/schema-json.d.ts +4 -0
  174. package/dist/types/schema-json.js +1 -0
  175. package/dist/types/schema-resource.d.ts +12 -0
  176. package/dist/types/schema-resource.js +1 -0
  177. package/dist/types/security.d.ts +17 -0
  178. package/dist/types/security.js +1 -0
  179. package/dist/types/workflow-capability-planning.d.ts +10 -0
  180. package/dist/types/workflow-capability-planning.js +1 -0
  181. package/dist/types/workflow-plan.d.ts +104 -0
  182. package/dist/types/workflow-plan.js +1 -0
  183. package/dist/utils/is-object.d.ts +2 -0
  184. package/dist/utils/is-object.js +3 -0
  185. package/dist/utils/json-values-equal.d.ts +2 -0
  186. package/dist/utils/json-values-equal.js +16 -0
  187. package/dist/workflow/assert-api-call-identities.d.ts +1 -0
  188. package/dist/workflow/assert-api-call-identities.js +6 -0
  189. package/dist/workflow/create-native-output-contracts.d.ts +3 -0
  190. package/dist/workflow/create-native-output-contracts.js +23 -0
  191. package/dist/workflow/create-reviewable-node-contracts.d.ts +3 -0
  192. package/dist/workflow/create-reviewable-node-contracts.js +36 -0
  193. package/dist/workflow/create-reviewable-workflow-graph-plan.d.ts +2 -0
  194. package/dist/workflow/create-reviewable-workflow-graph-plan.js +29 -0
  195. package/dist/workflow/create-workflow-graph-plan.d.ts +2 -0
  196. package/dist/workflow/create-workflow-graph-plan.js +17 -0
  197. package/dist/workflow/create-workflow-node-contracts.d.ts +2 -0
  198. package/dist/workflow/create-workflow-node-contracts.js +50 -0
  199. package/dist/workflow/create-workflow-planning-capabilities.d.ts +3 -0
  200. package/dist/workflow/create-workflow-planning-capabilities.js +20 -0
  201. package/dist/workflow/parse-native-node-parameters.d.ts +3 -0
  202. package/dist/workflow/parse-native-node-parameters.js +7 -0
  203. package/dist/workflow/validate-exclusive-output-rejoin.d.ts +3 -0
  204. package/dist/workflow/validate-exclusive-output-rejoin.js +26 -0
  205. package/dist/workflow/validate-native-api-response-references.d.ts +2 -0
  206. package/dist/workflow/validate-native-api-response-references.js +26 -0
  207. package/dist/workflow/validate-reviewable-workflow-graph-plan.d.ts +2 -0
  208. package/dist/workflow/validate-reviewable-workflow-graph-plan.js +98 -0
  209. package/dist/workflow/validate-workflow-edges.d.ts +2 -0
  210. package/dist/workflow/validate-workflow-edges.js +19 -0
  211. package/dist/workflow/validate-workflow-graph-plan.d.ts +3 -0
  212. package/dist/workflow/validate-workflow-graph-plan.js +41 -0
  213. package/dist/workflow/validate-workflow-topology.d.ts +2 -0
  214. package/dist/workflow/validate-workflow-topology.js +105 -0
  215. package/package.json +19 -25
  216. package/dist/openapi/operation-reference.d.ts +0 -3
  217. package/dist/openapi/parse-spec-utils.d.ts +0 -5
  218. package/dist/openapi/parse-spec-utils.js +0 -52
  219. package/dist/openapi/parse-spec.d.ts +0 -5
  220. package/dist/openapi/parse-spec.js +0 -182
  221. package/dist/openapi/validate-spec.d.ts +0 -3
  222. package/dist/planning/generate-workflow.d.ts +0 -2
  223. package/dist/planning/generate-workflow.js +0 -126
  224. package/dist/schemas/planning-schemas.d.ts +0 -62
  225. package/dist/schemas/planning-schemas.js +0 -48
  226. package/dist/types/workflow.d.ts +0 -75
  227. package/dist/utils/validation.d.ts +0 -7
  228. package/dist/utils/validation.js +0 -44
  229. package/dist/utils/workflow-id.d.ts +0 -1
  230. package/dist/utils/workflow-id.js +0 -8
  231. package/dist/workflow/compile-sequence.d.ts +0 -2
  232. package/dist/workflow/compile-sequence.js +0 -167
  233. package/dist/workflow/compile-workflow.d.ts +0 -4
  234. package/dist/workflow/compile-workflow.js +0 -128
  235. package/dist/workflow/sequence-url.d.ts +0 -3
  236. package/dist/workflow/sequence-url.js +0 -81
  237. package/dist/workflow/workflow-helpers.d.ts +0 -6
  238. package/dist/workflow/workflow-helpers.js +0 -81
  239. /package/dist/types/{workflow.js → api-argument-generation.js} +0 -0
@@ -1,81 +0,0 @@
1
- import { checkPrimitive, isObject, looksLikeCredential, } from '../utils/validation.js';
2
- export function isSafeMethod(method) {
3
- return ['GET', 'HEAD', 'OPTIONS', 'TRACE', 'QUERY'].includes(method);
4
- }
5
- export function makeUrl(operation, origin, inputs, missing) {
6
- let path = operation.path;
7
- for (const parameter of operation.parameters) {
8
- const key = parameter.in + '.' + parameter.name;
9
- const value = inputs[key];
10
- if (value === undefined) {
11
- if (parameter.required)
12
- missing.push(key);
13
- continue;
14
- }
15
- checkPrimitive(value, parameter.schema, 'plan.inputs.' + key);
16
- if (parameter.in === 'path')
17
- path = path.replace('{' + parameter.name + '}', encodeURIComponent(String(value)));
18
- }
19
- const url = new URL(path, origin);
20
- for (const parameter of operation.parameters) {
21
- if (parameter.in !== 'query')
22
- continue;
23
- const key = 'query.' + parameter.name;
24
- if (inputs[key] !== undefined)
25
- url.searchParams.set(parameter.name, String(inputs[key]));
26
- }
27
- return url.href;
28
- }
29
- export function makeBody(operation, inputs, missing) {
30
- if (!operation.body)
31
- return undefined;
32
- const value = inputs.body;
33
- if (value === undefined) {
34
- if (operation.body.required)
35
- missing.push('body');
36
- return undefined;
37
- }
38
- if (!isObject(value))
39
- throw new Error('plan.inputs.body must be an object');
40
- for (const [name, field] of Object.entries(value)) {
41
- const schema = operation.body.properties[name];
42
- if (!schema)
43
- throw new Error('plan.inputs.body.' + name + ' is not declared in the OAS schema');
44
- if (looksLikeCredential(name)) {
45
- throw new Error('plan.inputs.body.' +
46
- name +
47
- ' looks like a credential; v1 has no credential binding');
48
- }
49
- checkPrimitive(field, schema, 'plan.inputs.body.' + name);
50
- }
51
- for (const name of operation.body.requiredProperties) {
52
- if (!Object.hasOwn(value, name))
53
- missing.push('body.' + name);
54
- }
55
- return JSON.stringify(value);
56
- }
57
- export function assertionCode(status, expectedBody, requiredFields = {}) {
58
- const expected = JSON.stringify(expectedBody);
59
- const required = JSON.stringify(requiredFields);
60
- return [
61
- 'const items = $input.all();',
62
- "if (items.length !== 1) throw new Error('Expected one response item');",
63
- 'const response = items[0].json;',
64
- 'if (response.statusCode !== ' +
65
- status +
66
- ') throw new Error("Expected HTTP ' +
67
- status +
68
- ', got " + response.statusCode);',
69
- 'const expected = ' + expected + ';',
70
- 'const required = ' + required + ';',
71
- 'for (const [key, type] of Object.entries(required)) {',
72
- ' const value = response.body?.[key];',
73
- ' const valid = type === "integer" ? Number.isSafeInteger(value) : type === "number" ? typeof value === "number" && Number.isFinite(value) : typeof value === type;',
74
- ' if (!valid) throw new Error("Missing or invalid response body field: " + key);',
75
- '}',
76
- 'for (const [key, value] of Object.entries(expected)) {',
77
- ' if (response.body?.[key] !== value) throw new Error("Unexpected response body field: " + key);',
78
- '}',
79
- 'return items;',
80
- ].join('\n');
81
- }