@takeshape/schema 12.1.1 → 12.1.5
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/dist/agents.d.ts +62 -0
- package/dist/agents.js +346 -0
- package/dist/api-version.d.ts +5 -0
- package/dist/api-version.js +17 -0
- package/dist/auth-schemas.d.ts +144 -0
- package/dist/auth-schemas.js +7 -0
- package/dist/auth-utils.d.ts +19 -0
- package/dist/auth-utils.js +26 -0
- package/dist/builtin-schema.d.ts +18 -0
- package/dist/builtin-schema.js +710 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/content-schema-transform.d.ts +35 -0
- package/dist/content-schema-transform.js +162 -0
- package/dist/create-input-schema.d.ts +9 -0
- package/dist/create-input-schema.js +68 -0
- package/dist/enum.d.ts +2 -0
- package/dist/enum.js +9 -0
- package/dist/flatten-templates.d.ts +2 -0
- package/dist/flatten-templates.js +20 -0
- package/dist/get-is-leaf.d.ts +3 -0
- package/dist/get-is-leaf.js +56 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +61 -0
- package/dist/interfaces.d.ts +14 -0
- package/dist/interfaces.js +86 -0
- package/dist/layers/layers.d.ts +26 -0
- package/dist/layers/layers.js +301 -0
- package/dist/layers/refs.d.ts +102 -0
- package/dist/layers/refs.js +220 -0
- package/dist/layers/type-utils.d.ts +59 -0
- package/dist/layers/type-utils.js +118 -0
- package/dist/layers/visitor.d.ts +5 -0
- package/dist/layers/visitor.js +38 -0
- package/dist/migration/index.d.ts +79 -0
- package/dist/migration/index.js +110 -0
- package/dist/migration/to/v3.0.0.d.ts +4 -0
- package/dist/migration/to/v3.0.0.js +212 -0
- package/dist/migration/to/v3.1.0.d.ts +4 -0
- package/dist/migration/to/v3.1.0.js +194 -0
- package/dist/migration/to/v3.10.0.d.ts +4 -0
- package/dist/migration/to/v3.10.0.js +67 -0
- package/dist/migration/to/v3.11.0.d.ts +4 -0
- package/dist/migration/to/v3.11.0.js +85 -0
- package/dist/migration/to/v3.12.3.d.ts +4 -0
- package/dist/migration/to/v3.12.3.js +87 -0
- package/dist/migration/to/v3.13.0.d.ts +4 -0
- package/dist/migration/to/v3.13.0.js +17 -0
- package/dist/migration/to/v3.17.0.d.ts +4 -0
- package/dist/migration/to/v3.17.0.js +22 -0
- package/dist/migration/to/v3.18.0.d.ts +4 -0
- package/dist/migration/to/v3.18.0.js +64 -0
- package/dist/migration/to/v3.18.1.d.ts +4 -0
- package/dist/migration/to/v3.18.1.js +12 -0
- package/dist/migration/to/v3.18.2.d.ts +4 -0
- package/dist/migration/to/v3.18.2.js +19 -0
- package/dist/migration/to/v3.20.0.d.ts +4 -0
- package/dist/migration/to/v3.20.0.js +24 -0
- package/dist/migration/to/v3.22.0.d.ts +4 -0
- package/dist/migration/to/v3.22.0.js +25 -0
- package/dist/migration/to/v3.24.0.d.ts +4 -0
- package/dist/migration/to/v3.24.0.js +11 -0
- package/dist/migration/to/v3.25.0.d.ts +4 -0
- package/dist/migration/to/v3.25.0.js +11 -0
- package/dist/migration/to/v3.3.0.d.ts +4 -0
- package/dist/migration/to/v3.3.0.js +13 -0
- package/dist/migration/to/v3.31.0.d.ts +4 -0
- package/dist/migration/to/v3.31.0.js +38 -0
- package/dist/migration/to/v3.32.0.d.ts +4 -0
- package/dist/migration/to/v3.32.0.js +59 -0
- package/dist/migration/to/v3.34.0.d.ts +6 -0
- package/dist/migration/to/v3.34.0.js +111 -0
- package/dist/migration/to/v3.36.0.d.ts +4 -0
- package/dist/migration/to/v3.36.0.js +22 -0
- package/dist/migration/to/v3.39.0.d.ts +4 -0
- package/dist/migration/to/v3.39.0.js +45 -0
- package/dist/migration/to/v3.40.0.d.ts +4 -0
- package/dist/migration/to/v3.40.0.js +26 -0
- package/dist/migration/to/v3.46.0.d.ts +4 -0
- package/dist/migration/to/v3.46.0.js +35 -0
- package/dist/migration/to/v3.57.0.d.ts +4 -0
- package/dist/migration/to/v3.57.0.js +18 -0
- package/dist/migration/to/v3.60.0.d.ts +4 -0
- package/dist/migration/to/v3.60.0.js +129 -0
- package/dist/migration/to/v3.9.0.d.ts +4 -0
- package/dist/migration/to/v3.9.0.js +79 -0
- package/dist/migration/types.d.ts +26 -0
- package/dist/migration/types.js +3 -0
- package/dist/migration/utils.d.ts +2 -0
- package/dist/migration/utils.js +6 -0
- package/dist/mocks.d.ts +14 -0
- package/dist/mocks.js +58 -0
- package/dist/models/agent.d.ts +3 -0
- package/dist/models/agent.js +73 -0
- package/dist/models/project-schema.d.ts +28 -0
- package/dist/models/project-schema.js +186 -0
- package/dist/models/query.d.ts +3 -0
- package/dist/models/query.js +46 -0
- package/dist/models/runtime-schema.d.ts +9 -0
- package/dist/models/runtime-schema.js +20 -0
- package/dist/models/shape.d.ts +4 -0
- package/dist/models/shape.js +36 -0
- package/dist/models/tool.d.ts +4 -0
- package/dist/models/tool.js +147 -0
- package/dist/models/types.d.ts +97 -0
- package/dist/models/types.js +1 -0
- package/dist/models/user-schema.d.ts +7 -0
- package/dist/models/user-schema.js +9 -0
- package/dist/patterns.d.ts +12 -0
- package/dist/patterns.js +1 -0
- package/dist/project-schema/index.d.ts +229 -0
- package/dist/project-schema/index.js +89 -0
- package/dist/project-schema/latest.d.ts +2762 -0
- package/dist/project-schema/latest.js +7 -0
- package/dist/project-schema/migrate.d.ts +4 -0
- package/dist/project-schema/migrate.js +236 -0
- package/dist/project-schema/v1.0.0.d.ts +299 -0
- package/dist/project-schema/v1.0.0.js +7 -0
- package/dist/project-schema/v3.0.0.d.ts +478 -0
- package/dist/project-schema/v3.0.0.js +7 -0
- package/dist/project-schema/v3.1.0.d.ts +621 -0
- package/dist/project-schema/v3.1.0.js +7 -0
- package/dist/project-schema/v3.10.0.d.ts +1201 -0
- package/dist/project-schema/v3.10.0.js +7 -0
- package/dist/project-schema/v3.11.0.d.ts +1210 -0
- package/dist/project-schema/v3.11.0.js +7 -0
- package/dist/project-schema/v3.12.0.d.ts +1214 -0
- package/dist/project-schema/v3.12.0.js +7 -0
- package/dist/project-schema/v3.12.1.d.ts +1273 -0
- package/dist/project-schema/v3.12.1.js +7 -0
- package/dist/project-schema/v3.12.2.d.ts +1283 -0
- package/dist/project-schema/v3.12.2.js +7 -0
- package/dist/project-schema/v3.12.3.d.ts +1306 -0
- package/dist/project-schema/v3.12.3.js +7 -0
- package/dist/project-schema/v3.13.0.d.ts +1317 -0
- package/dist/project-schema/v3.13.0.js +7 -0
- package/dist/project-schema/v3.13.1.d.ts +1412 -0
- package/dist/project-schema/v3.13.1.js +7 -0
- package/dist/project-schema/v3.14.0.d.ts +1436 -0
- package/dist/project-schema/v3.14.0.js +7 -0
- package/dist/project-schema/v3.15.0.d.ts +1458 -0
- package/dist/project-schema/v3.15.0.js +7 -0
- package/dist/project-schema/v3.16.0.d.ts +1470 -0
- package/dist/project-schema/v3.16.0.js +7 -0
- package/dist/project-schema/v3.17.0.d.ts +1467 -0
- package/dist/project-schema/v3.17.0.js +7 -0
- package/dist/project-schema/v3.17.1.d.ts +1468 -0
- package/dist/project-schema/v3.17.1.js +7 -0
- package/dist/project-schema/v3.18.0.d.ts +1333 -0
- package/dist/project-schema/v3.18.0.js +7 -0
- package/dist/project-schema/v3.18.1.d.ts +1332 -0
- package/dist/project-schema/v3.18.1.js +7 -0
- package/dist/project-schema/v3.18.2.d.ts +1332 -0
- package/dist/project-schema/v3.18.2.js +7 -0
- package/dist/project-schema/v3.19.0.d.ts +1336 -0
- package/dist/project-schema/v3.19.0.js +7 -0
- package/dist/project-schema/v3.2.0.d.ts +632 -0
- package/dist/project-schema/v3.2.0.js +7 -0
- package/dist/project-schema/v3.20.0.d.ts +1336 -0
- package/dist/project-schema/v3.20.0.js +7 -0
- package/dist/project-schema/v3.21.0.d.ts +1338 -0
- package/dist/project-schema/v3.21.0.js +7 -0
- package/dist/project-schema/v3.22.0.d.ts +1344 -0
- package/dist/project-schema/v3.22.0.js +7 -0
- package/dist/project-schema/v3.23.0.d.ts +1376 -0
- package/dist/project-schema/v3.23.0.js +7 -0
- package/dist/project-schema/v3.24.0.d.ts +1364 -0
- package/dist/project-schema/v3.24.0.js +7 -0
- package/dist/project-schema/v3.25.0.d.ts +1363 -0
- package/dist/project-schema/v3.25.0.js +7 -0
- package/dist/project-schema/v3.26.0.d.ts +1388 -0
- package/dist/project-schema/v3.26.0.js +7 -0
- package/dist/project-schema/v3.27.0.d.ts +1397 -0
- package/dist/project-schema/v3.27.0.js +7 -0
- package/dist/project-schema/v3.28.0.d.ts +1416 -0
- package/dist/project-schema/v3.28.0.js +7 -0
- package/dist/project-schema/v3.29.0.d.ts +1423 -0
- package/dist/project-schema/v3.29.0.js +7 -0
- package/dist/project-schema/v3.3.0.d.ts +632 -0
- package/dist/project-schema/v3.3.0.js +7 -0
- package/dist/project-schema/v3.30.0.d.ts +1416 -0
- package/dist/project-schema/v3.30.0.js +7 -0
- package/dist/project-schema/v3.31.0.d.ts +1448 -0
- package/dist/project-schema/v3.31.0.js +7 -0
- package/dist/project-schema/v3.32.0.d.ts +1439 -0
- package/dist/project-schema/v3.32.0.js +7 -0
- package/dist/project-schema/v3.33.0.d.ts +1445 -0
- package/dist/project-schema/v3.33.0.js +7 -0
- package/dist/project-schema/v3.34.0.d.ts +1445 -0
- package/dist/project-schema/v3.34.0.js +7 -0
- package/dist/project-schema/v3.35.0.d.ts +1464 -0
- package/dist/project-schema/v3.35.0.js +7 -0
- package/dist/project-schema/v3.36.0.d.ts +1470 -0
- package/dist/project-schema/v3.36.0.js +7 -0
- package/dist/project-schema/v3.37.0.d.ts +1522 -0
- package/dist/project-schema/v3.37.0.js +7 -0
- package/dist/project-schema/v3.38.0.d.ts +1522 -0
- package/dist/project-schema/v3.38.0.js +7 -0
- package/dist/project-schema/v3.39.0.d.ts +1529 -0
- package/dist/project-schema/v3.39.0.js +7 -0
- package/dist/project-schema/v3.4.0.d.ts +624 -0
- package/dist/project-schema/v3.4.0.js +7 -0
- package/dist/project-schema/v3.40.0.d.ts +1530 -0
- package/dist/project-schema/v3.40.0.js +7 -0
- package/dist/project-schema/v3.41.0.d.ts +1530 -0
- package/dist/project-schema/v3.41.0.js +7 -0
- package/dist/project-schema/v3.42.0.d.ts +1534 -0
- package/dist/project-schema/v3.42.0.js +7 -0
- package/dist/project-schema/v3.43.0.d.ts +1536 -0
- package/dist/project-schema/v3.43.0.js +7 -0
- package/dist/project-schema/v3.44.0.d.ts +1621 -0
- package/dist/project-schema/v3.44.0.js +7 -0
- package/dist/project-schema/v3.45.0.d.ts +1650 -0
- package/dist/project-schema/v3.45.0.js +7 -0
- package/dist/project-schema/v3.46.0.d.ts +1703 -0
- package/dist/project-schema/v3.46.0.js +7 -0
- package/dist/project-schema/v3.47.0.d.ts +1736 -0
- package/dist/project-schema/v3.47.0.js +7 -0
- package/dist/project-schema/v3.48.0.d.ts +2208 -0
- package/dist/project-schema/v3.48.0.js +7 -0
- package/dist/project-schema/v3.49.0.d.ts +2217 -0
- package/dist/project-schema/v3.49.0.js +7 -0
- package/dist/project-schema/v3.5.0.d.ts +649 -0
- package/dist/project-schema/v3.5.0.js +7 -0
- package/dist/project-schema/v3.5.1.d.ts +649 -0
- package/dist/project-schema/v3.5.1.js +7 -0
- package/dist/project-schema/v3.50.0.d.ts +2269 -0
- package/dist/project-schema/v3.50.0.js +7 -0
- package/dist/project-schema/v3.51.0.d.ts +2269 -0
- package/dist/project-schema/v3.51.0.js +7 -0
- package/dist/project-schema/v3.52.0.d.ts +2269 -0
- package/dist/project-schema/v3.52.0.js +7 -0
- package/dist/project-schema/v3.53.0.d.ts +2350 -0
- package/dist/project-schema/v3.53.0.js +7 -0
- package/dist/project-schema/v3.54.0.d.ts +2369 -0
- package/dist/project-schema/v3.54.0.js +7 -0
- package/dist/project-schema/v3.55.0.d.ts +2369 -0
- package/dist/project-schema/v3.55.0.js +7 -0
- package/dist/project-schema/v3.56.0.d.ts +2405 -0
- package/dist/project-schema/v3.56.0.js +7 -0
- package/dist/project-schema/v3.57.0.d.ts +2601 -0
- package/dist/project-schema/v3.57.0.js +7 -0
- package/dist/project-schema/v3.58.0.d.ts +2601 -0
- package/dist/project-schema/v3.58.0.js +7 -0
- package/dist/project-schema/v3.59.0.d.ts +2650 -0
- package/dist/project-schema/v3.59.0.js +7 -0
- package/dist/project-schema/v3.6.0.d.ts +658 -0
- package/dist/project-schema/v3.6.0.js +7 -0
- package/dist/project-schema/v3.60.0.d.ts +2678 -0
- package/dist/project-schema/v3.60.0.js +7 -0
- package/dist/project-schema/v3.61.0.d.ts +2678 -0
- package/dist/project-schema/v3.61.0.js +7 -0
- package/dist/project-schema/v3.62.0.d.ts +2693 -0
- package/dist/project-schema/v3.62.0.js +7 -0
- package/dist/project-schema/v3.63.0.d.ts +2701 -0
- package/dist/project-schema/v3.63.0.js +7 -0
- package/dist/project-schema/v3.64.0.d.ts +2710 -0
- package/dist/project-schema/v3.64.0.js +7 -0
- package/dist/project-schema/v3.65.0.d.ts +2762 -0
- package/dist/project-schema/v3.65.0.js +7 -0
- package/dist/project-schema/v3.7.0.d.ts +961 -0
- package/dist/project-schema/v3.7.0.js +7 -0
- package/dist/project-schema/v3.8.0.d.ts +979 -0
- package/dist/project-schema/v3.8.0.js +7 -0
- package/dist/project-schema/v3.9.0.d.ts +1178 -0
- package/dist/project-schema/v3.9.0.js +7 -0
- package/dist/project-schema/v4.0.0.d.ts +1328 -0
- package/dist/project-schema/v4.0.0.js +7 -0
- package/dist/refs.d.ts +220 -0
- package/dist/refs.js +648 -0
- package/dist/relationships.d.ts +40 -0
- package/dist/relationships.js +302 -0
- package/dist/resolvers/ai/abort-agent-message-args.d.ts +16 -0
- package/dist/resolvers/ai/abort-agent-message-args.js +13 -0
- package/dist/resolvers/ai/abort-agent-message-response.d.ts +39 -0
- package/dist/resolvers/ai/abort-agent-message-response.js +19 -0
- package/dist/resolvers/ai/agent-attachment.d.ts +27 -0
- package/dist/resolvers/ai/agent-attachment.js +22 -0
- package/dist/resolvers/ai/agent-chat-args.d.ts +62 -0
- package/dist/resolvers/ai/agent-chat-args.js +30 -0
- package/dist/resolvers/ai/agent-chat-payload.d.ts +35 -0
- package/dist/resolvers/ai/agent-chat-payload.js +26 -0
- package/dist/resolvers/ai/agent-chat-response.d.ts +366 -0
- package/dist/resolvers/ai/agent-chat-response.js +21 -0
- package/dist/resolvers/ai/agent-generate-args.d.ts +62 -0
- package/dist/resolvers/ai/agent-generate-args.js +30 -0
- package/dist/resolvers/ai/agent-message-input.d.ts +73 -0
- package/dist/resolvers/ai/agent-message-input.js +39 -0
- package/dist/resolvers/ai/agent-message-output.d.ts +169 -0
- package/dist/resolvers/ai/agent-message-output.js +77 -0
- package/dist/resolvers/ai/agent-message-payload.d.ts +849 -0
- package/dist/resolvers/ai/agent-message-payload.js +167 -0
- package/dist/resolvers/ai/agent-run-mode.d.ts +8 -0
- package/dist/resolvers/ai/agent-run-mode.js +9 -0
- package/dist/resolvers/ai/agent-session-payload.d.ts +840 -0
- package/dist/resolvers/ai/agent-session-payload.js +218 -0
- package/dist/resolvers/ai/ai-usage-item.d.ts +70 -0
- package/dist/resolvers/ai/ai-usage-item.js +70 -0
- package/dist/resolvers/ai/create-agent-session-response.d.ts +276 -0
- package/dist/resolvers/ai/create-agent-session-response.js +9 -0
- package/dist/resolvers/ai/embedding-search.d.ts +54 -0
- package/dist/resolvers/ai/embedding-search.js +46 -0
- package/dist/resolvers/ai/get-agent-message-args.d.ts +16 -0
- package/dist/resolvers/ai/get-agent-message-args.js +13 -0
- package/dist/resolvers/ai/get-agent-message-response.d.ts +1253 -0
- package/dist/resolvers/ai/get-agent-message-response.js +79 -0
- package/dist/resolvers/ai/inspect-agent-args.d.ts +16 -0
- package/dist/resolvers/ai/inspect-agent-args.js +13 -0
- package/dist/resolvers/ai/inspect-agent-response.d.ts +631 -0
- package/dist/resolvers/ai/inspect-agent-response.js +48 -0
- package/dist/resolvers/ai/send-agent-feedback-args.d.ts +52 -0
- package/dist/resolvers/ai/send-agent-feedback-args.js +16 -0
- package/dist/resolvers/ai/send-agent-message-args.d.ts +48 -0
- package/dist/resolvers/ai/send-agent-message-args.js +36 -0
- package/dist/resolvers/ai/send-agent-message-response.d.ts +432 -0
- package/dist/resolvers/ai/send-agent-message-response.js +51 -0
- package/dist/resolvers/ai/types.d.ts +8 -0
- package/dist/resolvers/ai/types.js +1 -0
- package/dist/resolvers/takeshape/assets/asset-image-meta.d.ts +79 -0
- package/dist/resolvers/takeshape/assets/asset-image-meta.js +98 -0
- package/dist/resolvers/takeshape/assets/asset-image-params.d.ts +901 -0
- package/dist/resolvers/takeshape/assets/asset-image-params.js +726 -0
- package/dist/resolvers/takeshape/assets/asset-image.d.ts +17 -0
- package/dist/resolvers/takeshape/assets/asset-image.js +15 -0
- package/dist/resolvers/takeshape/assets/asset.d.ts +125 -0
- package/dist/resolvers/takeshape/assets/asset.js +107 -0
- package/dist/resolvers/takeshape/assets/constants.d.ts +11 -0
- package/dist/resolvers/takeshape/assets/constants.js +11 -0
- package/dist/resolvers/takeshape/builtins/constants.d.ts +1 -0
- package/dist/resolvers/takeshape/builtins/constants.js +1 -0
- package/dist/runtime-schema.d.ts +6 -0
- package/dist/runtime-schema.js +85 -0
- package/dist/scalars.d.ts +2 -0
- package/dist/scalars.js +4 -0
- package/dist/schema-transform.d.ts +19 -0
- package/dist/schema-transform.js +74 -0
- package/dist/schema-util.d.ts +266 -0
- package/dist/schema-util.js +1127 -0
- package/dist/schemas/auth-schemas.json +400 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.js +182 -0
- package/dist/schemas/project-schema/experimental-2025-07.json +1297 -0
- package/dist/schemas/project-schema/latest.d.ts +245 -0
- package/dist/schemas/project-schema/latest.js +25 -0
- package/dist/schemas/project-schema/latest.json +5109 -0
- package/dist/schemas/project-schema/meta-schema-v1.0.0.json +193 -0
- package/dist/schemas/project-schema/meta-schema-v3.0.0.json +608 -0
- package/dist/schemas/project-schema/meta-schema-v3.1.0.json +608 -0
- package/dist/schemas/project-schema/meta-schema-v3.2.0.json +612 -0
- package/dist/schemas/project-schema/meta-schema-v3.3.0.json +612 -0
- package/dist/schemas/project-schema/meta-schema-v3.4.0.json +637 -0
- package/dist/schemas/project-schema/meta-schema-v3.5.0.json +626 -0
- package/dist/schemas/project-schema/meta-schema-v3.5.1.json +626 -0
- package/dist/schemas/project-schema/meta-schema-v3.6.0.json +629 -0
- package/dist/schemas/project-schema/meta-schema-v3.7.0.json +1137 -0
- package/dist/schemas/project-schema/meta-schema-v3.8.0.json +1137 -0
- package/dist/schemas/project-schema/meta-schema-v3.9.0.json +1477 -0
- package/dist/schemas/project-schema/v1.0.0.json +321 -0
- package/dist/schemas/project-schema/v3.0.0.json +414 -0
- package/dist/schemas/project-schema/v3.1.0.json +572 -0
- package/dist/schemas/project-schema/v3.10.0.json +2097 -0
- package/dist/schemas/project-schema/v3.11.0.json +2141 -0
- package/dist/schemas/project-schema/v3.12.0.json +2144 -0
- package/dist/schemas/project-schema/v3.12.1.json +2282 -0
- package/dist/schemas/project-schema/v3.12.2.json +2304 -0
- package/dist/schemas/project-schema/v3.12.3.json +2357 -0
- package/dist/schemas/project-schema/v3.13.0.json +2377 -0
- package/dist/schemas/project-schema/v3.14.0.json +2385 -0
- package/dist/schemas/project-schema/v3.15.0.json +2365 -0
- package/dist/schemas/project-schema/v3.16.0.json +2373 -0
- package/dist/schemas/project-schema/v3.17.0.json +2378 -0
- package/dist/schemas/project-schema/v3.17.1.json +2380 -0
- package/dist/schemas/project-schema/v3.18.0.json +2356 -0
- package/dist/schemas/project-schema/v3.18.1.json +2357 -0
- package/dist/schemas/project-schema/v3.18.2.json +2357 -0
- package/dist/schemas/project-schema/v3.19.0.json +2369 -0
- package/dist/schemas/project-schema/v3.2.0.json +580 -0
- package/dist/schemas/project-schema/v3.20.0.json +2369 -0
- package/dist/schemas/project-schema/v3.21.0.json +2376 -0
- package/dist/schemas/project-schema/v3.22.0.json +2381 -0
- package/dist/schemas/project-schema/v3.23.0.json +2456 -0
- package/dist/schemas/project-schema/v3.24.0.json +2556 -0
- package/dist/schemas/project-schema/v3.25.0.json +2552 -0
- package/dist/schemas/project-schema/v3.26.0.json +2599 -0
- package/dist/schemas/project-schema/v3.27.0.json +2611 -0
- package/dist/schemas/project-schema/v3.28.0.json +2656 -0
- package/dist/schemas/project-schema/v3.29.0.json +2670 -0
- package/dist/schemas/project-schema/v3.3.0.json +581 -0
- package/dist/schemas/project-schema/v3.30.0.json +2656 -0
- package/dist/schemas/project-schema/v3.31.0.json +2714 -0
- package/dist/schemas/project-schema/v3.32.0.json +2708 -0
- package/dist/schemas/project-schema/v3.33.0.json +2715 -0
- package/dist/schemas/project-schema/v3.34.0.json +2715 -0
- package/dist/schemas/project-schema/v3.35.0.json +2748 -0
- package/dist/schemas/project-schema/v3.36.0.json +2756 -0
- package/dist/schemas/project-schema/v3.37.0.json +2821 -0
- package/dist/schemas/project-schema/v3.38.0.json +2819 -0
- package/dist/schemas/project-schema/v3.39.0.json +2827 -0
- package/dist/schemas/project-schema/v3.4.0.json +571 -0
- package/dist/schemas/project-schema/v3.40.0.json +2830 -0
- package/dist/schemas/project-schema/v3.41.0.json +2830 -0
- package/dist/schemas/project-schema/v3.42.0.json +2835 -0
- package/dist/schemas/project-schema/v3.43.0.json +2841 -0
- package/dist/schemas/project-schema/v3.44.0.json +3013 -0
- package/dist/schemas/project-schema/v3.45.0.json +3064 -0
- package/dist/schemas/project-schema/v3.46.0.json +3136 -0
- package/dist/schemas/project-schema/v3.47.0.json +3189 -0
- package/dist/schemas/project-schema/v3.48.0.json +3196 -0
- package/dist/schemas/project-schema/v3.49.0.json +3239 -0
- package/dist/schemas/project-schema/v3.5.0.json +571 -0
- package/dist/schemas/project-schema/v3.5.1.json +571 -0
- package/dist/schemas/project-schema/v3.50.0.json +3320 -0
- package/dist/schemas/project-schema/v3.51.0.json +3326 -0
- package/dist/schemas/project-schema/v3.52.0.json +3326 -0
- package/dist/schemas/project-schema/v3.53.0.json +3476 -0
- package/dist/schemas/project-schema/v3.54.0.json +3512 -0
- package/dist/schemas/project-schema/v3.55.0.json +3515 -0
- package/dist/schemas/project-schema/v3.56.0.json +3530 -0
- package/dist/schemas/project-schema/v3.57.0.json +4815 -0
- package/dist/schemas/project-schema/v3.58.0.json +4815 -0
- package/dist/schemas/project-schema/v3.59.0.json +4912 -0
- package/dist/schemas/project-schema/v3.6.0.json +587 -0
- package/dist/schemas/project-schema/v3.60.0.json +4974 -0
- package/dist/schemas/project-schema/v3.61.0.json +4974 -0
- package/dist/schemas/project-schema/v3.62.0.json +5007 -0
- package/dist/schemas/project-schema/v3.63.0.json +5020 -0
- package/dist/schemas/project-schema/v3.64.0.json +5032 -0
- package/dist/schemas/project-schema/v3.65.0.json +5109 -0
- package/dist/schemas/project-schema/v3.7.0.json +587 -0
- package/dist/schemas/project-schema/v3.8.0.json +604 -0
- package/dist/schemas/project-schema/v3.9.0.json +604 -0
- package/dist/schemas/project-schema/v4.0.0.json +2316 -0
- package/dist/schemas/project-schema.json +232 -0
- package/dist/service-dependencies.d.ts +13 -0
- package/dist/service-dependencies.js +165 -0
- package/dist/services/services.d.ts +31 -0
- package/dist/services/services.js +145 -0
- package/dist/services/types.d.ts +11 -0
- package/dist/services/types.js +1 -0
- package/dist/services/util.d.ts +16 -0
- package/dist/services/util.js +36 -0
- package/dist/shape-paths.d.ts +7 -0
- package/dist/shape-paths.js +40 -0
- package/dist/taxonomies.d.ts +15 -0
- package/dist/taxonomies.js +24 -0
- package/dist/template-shapes/index.d.ts +7 -0
- package/dist/template-shapes/index.js +33 -0
- package/dist/template-shapes/names.d.ts +10 -0
- package/dist/template-shapes/names.js +21 -0
- package/dist/template-shapes/templates.d.ts +32 -0
- package/dist/template-shapes/templates.js +316 -0
- package/dist/template-shapes/types.d.ts +15 -0
- package/dist/template-shapes/types.js +7 -0
- package/dist/template-shapes/where.d.ts +37 -0
- package/dist/template-shapes/where.js +415 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +2 -0
- package/dist/types/transforms.d.ts +15 -0
- package/dist/types/transforms.js +1 -0
- package/dist/types/types.d.ts +206 -0
- package/dist/types/types.js +10 -0
- package/dist/types/utils.d.ts +112 -0
- package/dist/types/utils.js +269 -0
- package/dist/unions.d.ts +14 -0
- package/dist/unions.js +77 -0
- package/dist/util/agent-utils.d.ts +2 -0
- package/dist/util/agent-utils.js +7 -0
- package/dist/util/api-indexing.d.ts +9 -0
- package/dist/util/api-indexing.js +57 -0
- package/dist/util/coerce-value.d.ts +9 -0
- package/dist/util/coerce-value.js +32 -0
- package/dist/util/detect-cycles.d.ts +7 -0
- package/dist/util/detect-cycles.js +45 -0
- package/dist/util/expressions.d.ts +34 -0
- package/dist/util/expressions.js +350 -0
- package/dist/util/find-shape-at-path.d.ts +21 -0
- package/dist/util/find-shape-at-path.js +53 -0
- package/dist/util/form-config.d.ts +11 -0
- package/dist/util/form-config.js +62 -0
- package/dist/util/get-conflicting-properties.d.ts +6 -0
- package/dist/util/get-conflicting-properties.js +55 -0
- package/dist/util/get-return-shape.d.ts +4 -0
- package/dist/util/get-return-shape.js +30 -0
- package/dist/util/graphql-string.d.ts +6 -0
- package/dist/util/graphql-string.js +75 -0
- package/dist/util/has-arg.d.ts +6 -0
- package/dist/util/has-arg.js +25 -0
- package/dist/util/is-asset-property.d.ts +3 -0
- package/dist/util/is-asset-property.js +11 -0
- package/dist/util/merge.d.ts +17 -0
- package/dist/util/merge.js +278 -0
- package/dist/util/patch-schema.d.ts +13 -0
- package/dist/util/patch-schema.js +89 -0
- package/dist/util/query-field-path.d.ts +9 -0
- package/dist/util/query-field-path.js +23 -0
- package/dist/util/shapes.d.ts +5 -0
- package/dist/util/shapes.js +22 -0
- package/dist/util/tools.d.ts +10 -0
- package/dist/util/tools.js +39 -0
- package/dist/validate/ai.d.ts +6 -0
- package/dist/validate/ai.js +221 -0
- package/dist/validate/errors.d.ts +3 -0
- package/dist/validate/errors.js +20 -0
- package/dist/validate/types.d.ts +43 -0
- package/dist/validate/types.js +1 -0
- package/dist/validate/util.d.ts +9 -0
- package/dist/validate/util.js +62 -0
- package/dist/validate/validate.d.ts +41 -0
- package/dist/validate/validate.js +1042 -0
- package/dist/versions.d.ts +4 -0
- package/dist/versions.js +4 -0
- package/dist/workflows.d.ts +14 -0
- package/dist/workflows.js +66 -0
- package/package.json +6 -6
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Kind, parse } from '@0no-co/graphql.web';
|
|
2
|
+
// TODO consider moving this to @takeshape/graphql
|
|
3
|
+
export function getVariablesSchema(runtimeSchema, queryStr) {
|
|
4
|
+
const doc = parse(queryStr);
|
|
5
|
+
const op = doc.definitions.find((def) => def.kind === 'OperationDefinition');
|
|
6
|
+
return op?.variableDefinitions && variablesToPropertySchema(runtimeSchema, op.variableDefinitions);
|
|
7
|
+
}
|
|
8
|
+
function variablesToPropertySchema(runtimeSchema, nodes) {
|
|
9
|
+
const properties = {};
|
|
10
|
+
const required = [];
|
|
11
|
+
let argsAreFromShape = false;
|
|
12
|
+
for (const node of nodes) {
|
|
13
|
+
let typeNode = node.type;
|
|
14
|
+
let isRequired = false;
|
|
15
|
+
if (typeNode.kind === Kind.NON_NULL_TYPE) {
|
|
16
|
+
isRequired = true;
|
|
17
|
+
typeNode = typeNode.type;
|
|
18
|
+
}
|
|
19
|
+
const { propertySchema, isFromShape } = graphqlTypeNodeToPropertySchemaWithShapeInfo(runtimeSchema, typeNode);
|
|
20
|
+
if (propertySchema) {
|
|
21
|
+
const name = node.variable.name.value;
|
|
22
|
+
properties[name] = propertySchema;
|
|
23
|
+
if (isRequired) {
|
|
24
|
+
required.push(name);
|
|
25
|
+
}
|
|
26
|
+
if (isFromShape) {
|
|
27
|
+
argsAreFromShape = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { argsSchema: { type: 'object', properties, required }, argsAreFromShape };
|
|
32
|
+
}
|
|
33
|
+
const scalarTypeMap = {
|
|
34
|
+
String: 'string',
|
|
35
|
+
Int: 'integer',
|
|
36
|
+
Float: 'number',
|
|
37
|
+
Boolean: 'boolean',
|
|
38
|
+
ID: 'string',
|
|
39
|
+
JSON: 'object',
|
|
40
|
+
JSONObject: 'object'
|
|
41
|
+
};
|
|
42
|
+
function graphqlTypeNodeToPropertySchema(runtimeSchema, node) {
|
|
43
|
+
const { propertySchema } = graphqlTypeNodeToPropertySchemaWithShapeInfo(runtimeSchema, node);
|
|
44
|
+
return propertySchema;
|
|
45
|
+
}
|
|
46
|
+
function graphqlTypeNodeToPropertySchemaWithShapeInfo(runtimeSchema, node) {
|
|
47
|
+
// Handle NonNullType (e.g., String!)
|
|
48
|
+
if (node.kind === Kind.NON_NULL_TYPE) {
|
|
49
|
+
return graphqlTypeNodeToPropertySchemaWithShapeInfo(runtimeSchema, node.type);
|
|
50
|
+
}
|
|
51
|
+
// Handle ListType (e.g., [String])
|
|
52
|
+
if (node.kind === Kind.LIST_TYPE) {
|
|
53
|
+
const { propertySchema, isFromShape } = graphqlTypeNodeToPropertySchemaWithShapeInfo(runtimeSchema, node.type);
|
|
54
|
+
return {
|
|
55
|
+
propertySchema: propertySchema
|
|
56
|
+
? {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: propertySchema
|
|
59
|
+
}
|
|
60
|
+
: undefined,
|
|
61
|
+
isFromShape
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const typeName = node.name.value;
|
|
65
|
+
const jsonType = scalarTypeMap[typeName];
|
|
66
|
+
if (jsonType) {
|
|
67
|
+
return { propertySchema: { type: jsonType }, isFromShape: false };
|
|
68
|
+
}
|
|
69
|
+
// TODO this lookup needs to account for Input suffixes and inline object shapes
|
|
70
|
+
const shape = runtimeSchema.getShape(typeName);
|
|
71
|
+
if (shape) {
|
|
72
|
+
return { propertySchema: { '@ref': shape.ref }, isFromShape: true };
|
|
73
|
+
}
|
|
74
|
+
return { propertySchema: undefined, isFromShape: false };
|
|
75
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Args, ObjectSchema, ProjectSchemaJSON } from '../project-schema/index.ts';
|
|
2
|
+
import { type ServicesShapesContext } from '../refs.ts';
|
|
3
|
+
import { type SchemaWithArgs } from '../types/index.ts';
|
|
4
|
+
export declare function getArgs(prop: SchemaWithArgs): Args | undefined;
|
|
5
|
+
export declare function getArgsSchema(projectSchema: ServicesShapesContext, args: Args): ObjectSchema | undefined;
|
|
6
|
+
export declare function hasArg(projectSchema: ProjectSchemaJSON, prop: SchemaWithArgs, argPath: string | string[]): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dereferenceObjectSchema, parseRef, refItemToShape } from "../refs.js";
|
|
2
|
+
import { isObjectSchema } from "../types/index.js";
|
|
3
|
+
import { findSchemaAtPath } from "./find-shape-at-path.js";
|
|
4
|
+
export function getArgs(prop) {
|
|
5
|
+
return '@args' in prop ? prop['@args'] : 'args' in prop ? prop.args : undefined;
|
|
6
|
+
}
|
|
7
|
+
export function getArgsSchema(projectSchema, args) {
|
|
8
|
+
if (typeof args === 'object') {
|
|
9
|
+
return dereferenceObjectSchema(projectSchema, args);
|
|
10
|
+
}
|
|
11
|
+
const ref = parseRef(projectSchema, args);
|
|
12
|
+
const shapeSchema = refItemToShape(projectSchema, ref)?.schema;
|
|
13
|
+
if (shapeSchema && isObjectSchema(shapeSchema)) {
|
|
14
|
+
return shapeSchema;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function hasArg(projectSchema, prop, argPath) {
|
|
18
|
+
const args = getArgs(prop);
|
|
19
|
+
if (!args) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const schema = getArgsSchema(projectSchema, args);
|
|
23
|
+
const pathArray = Array.isArray(argPath) ? argPath : argPath.split('.');
|
|
24
|
+
return Boolean(schema && findSchemaAtPath(projectSchema, schema, pathArray));
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getRef, parseRef } from "../refs.js";
|
|
2
|
+
export function isAssetProperty(prop) {
|
|
3
|
+
const ref = getRef({}, prop.oneOf?.[0] ?? prop);
|
|
4
|
+
return Boolean(ref && isAssetRefItem(ref));
|
|
5
|
+
}
|
|
6
|
+
export function isAssetRef(str) {
|
|
7
|
+
return isAssetRefItem(parseRef({}, str));
|
|
8
|
+
}
|
|
9
|
+
function isAssetRefItem(ref) {
|
|
10
|
+
return ref.layerId === 'local' && ref.shapeName === 'Asset';
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FormConfig, ObjectSchema, ProjectSchemaJSON } from '../project-schema/index.ts';
|
|
2
|
+
export declare function omitObjectSchema(schema: ObjectSchema, names: string[]): ObjectSchema;
|
|
3
|
+
export declare function pickObjectSchema(schema: ObjectSchema, names: string[]): ObjectSchema;
|
|
4
|
+
export declare function mergeObjectSchemas(...args: Array<ObjectSchema | undefined>): ObjectSchema;
|
|
5
|
+
export declare function mergeDeepObjectSchemas(...args: Array<ObjectSchema | undefined>): ObjectSchema;
|
|
6
|
+
export declare function mergeSchemaProperties(parent: ObjectSchema, overrides: ObjectSchema, deep?: boolean): ObjectSchema;
|
|
7
|
+
export declare function rebaseSchemaProperties(base: ObjectSchema, parent: ObjectSchema, head: ObjectSchema): ObjectSchema;
|
|
8
|
+
export declare function mergeFormProperties(parent: FormConfig, overrides: FormConfig): FormConfig;
|
|
9
|
+
export declare function rebaseFormProperties(base: FormConfig, parent: FormConfig, head: FormConfig): FormConfig;
|
|
10
|
+
export declare function mergeFormConfigs(...configs: FormConfig[]): FormConfig;
|
|
11
|
+
export declare function mergeProjectSchemas(base: ProjectSchemaJSON, parent: ProjectSchemaJSON, head: ProjectSchemaJSON): {
|
|
12
|
+
error: string;
|
|
13
|
+
mergedSchema: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
error: undefined;
|
|
16
|
+
mergedSchema: ProjectSchemaJSON;
|
|
17
|
+
};
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { assert, deepClone, isDefined, rebaseArray, rebaseObject } from '@takeshape/util';
|
|
2
|
+
import assignWith from 'lodash/assignWith.js';
|
|
3
|
+
import difference from 'lodash/difference.js';
|
|
4
|
+
import intersection from 'lodash/intersection.js';
|
|
5
|
+
import isEqual from 'lodash/isEqual.js';
|
|
6
|
+
import last from 'lodash/last.js';
|
|
7
|
+
import omit from 'lodash/omit.js';
|
|
8
|
+
import pick from 'lodash/pick.js';
|
|
9
|
+
import pickBy from 'lodash/pickBy.js';
|
|
10
|
+
import set from 'lodash/set.js';
|
|
11
|
+
import union from 'lodash/union.js';
|
|
12
|
+
import unset from 'lodash/unset.js';
|
|
13
|
+
import { isExtendsSchema, isObjectSchema, isRefSchema } from "../types/index.js";
|
|
14
|
+
export function omitObjectSchema(schema, names) {
|
|
15
|
+
const { properties, required, ...rest } = schema;
|
|
16
|
+
const filteredSchema = {
|
|
17
|
+
...rest,
|
|
18
|
+
properties: omit(properties, names)
|
|
19
|
+
};
|
|
20
|
+
if (required) {
|
|
21
|
+
filteredSchema.required = difference(required, names);
|
|
22
|
+
}
|
|
23
|
+
return filteredSchema;
|
|
24
|
+
}
|
|
25
|
+
export function pickObjectSchema(schema, names) {
|
|
26
|
+
const { properties, required, ...rest } = schema;
|
|
27
|
+
const filteredSchema = {
|
|
28
|
+
...rest,
|
|
29
|
+
properties: pick(properties, names)
|
|
30
|
+
};
|
|
31
|
+
if (required) {
|
|
32
|
+
filteredSchema.required = intersection(required, names);
|
|
33
|
+
}
|
|
34
|
+
return filteredSchema;
|
|
35
|
+
}
|
|
36
|
+
export function mergeObjectSchemas(...args) {
|
|
37
|
+
return args.filter(isDefined).reduce((parent, schemas) => mergeSchemaProperties(parent, schemas), {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function mergeDeepObjectSchemas(...args) {
|
|
43
|
+
return args.filter(isDefined).reduce((parent, schemas) => mergeSchemaProperties(parent, schemas, true), {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function mergeSchemaProperties(parent, overrides, deep = false) {
|
|
49
|
+
const result = {
|
|
50
|
+
...parent,
|
|
51
|
+
properties: deep
|
|
52
|
+
? assignWith({}, parent.properties, overrides.properties, (objValue, srcValue) => {
|
|
53
|
+
// merge objects if possible
|
|
54
|
+
if (objValue !== undefined && srcValue !== undefined) {
|
|
55
|
+
// skip merging if they are equal this avoids allOf with duplicate refs
|
|
56
|
+
if (isEqual(objValue, srcValue)) {
|
|
57
|
+
return objValue;
|
|
58
|
+
}
|
|
59
|
+
if (isObjectSchema(objValue) && isObjectSchema(srcValue)) {
|
|
60
|
+
return mergeObjectSchemas(objValue, srcValue);
|
|
61
|
+
}
|
|
62
|
+
if ((isObjectSchema(objValue) || isRefSchema(objValue)) &&
|
|
63
|
+
(isObjectSchema(srcValue) || isRefSchema(srcValue))) {
|
|
64
|
+
return { allOf: [objValue, srcValue] };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
: { ...parent.properties, ...overrides.properties }
|
|
69
|
+
};
|
|
70
|
+
const required = union(parent.required, overrides.required);
|
|
71
|
+
if (required.length) {
|
|
72
|
+
result.required = required;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
export function rebaseSchemaProperties(base, parent, head) {
|
|
77
|
+
const { properties: toProperties, required: toRequired, ...toOther } = base;
|
|
78
|
+
const { properties: baseProperties, required: baseRequired, ...baseOther } = parent;
|
|
79
|
+
const { properties: fromProperties, required: fromRequired, ...fromOther } = head;
|
|
80
|
+
const newSchema = {
|
|
81
|
+
...rebaseObject(toOther, baseOther, fromOther),
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: rebaseObject(toProperties, baseProperties, fromProperties)
|
|
84
|
+
};
|
|
85
|
+
const required = rebaseArray(toRequired ?? [], baseRequired ?? [], fromRequired ?? []);
|
|
86
|
+
if (required.length) {
|
|
87
|
+
newSchema.required = required;
|
|
88
|
+
}
|
|
89
|
+
return newSchema;
|
|
90
|
+
}
|
|
91
|
+
export function mergeFormProperties(parent, overrides) {
|
|
92
|
+
const result = {
|
|
93
|
+
...parent,
|
|
94
|
+
properties: {
|
|
95
|
+
...parent.properties,
|
|
96
|
+
...overrides.properties
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const order = union(parent.order, overrides.order);
|
|
100
|
+
if (order.length) {
|
|
101
|
+
result.order = order;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
export function rebaseFormProperties(base, parent, head) {
|
|
106
|
+
const { properties: toProperties, order: toOrder, ...toOther } = base;
|
|
107
|
+
const { properties: baseProperties, order: baseOrder, ...baseOther } = parent;
|
|
108
|
+
const { properties: fromProperties, order: fromOrder, ...fromOther } = head;
|
|
109
|
+
const newForm = {
|
|
110
|
+
...rebaseObject(toOther, baseOther, fromOther),
|
|
111
|
+
properties: rebaseObject(toProperties, baseProperties, fromProperties)
|
|
112
|
+
};
|
|
113
|
+
const order = rebaseArray(toOrder ?? [], baseOrder ?? [], fromOrder ?? []);
|
|
114
|
+
if (order.length) {
|
|
115
|
+
newForm.order = order;
|
|
116
|
+
}
|
|
117
|
+
return newForm;
|
|
118
|
+
}
|
|
119
|
+
export function mergeFormConfigs(...configs) {
|
|
120
|
+
return configs.reduce(mergeFormProperties, { properties: {}, order: [] });
|
|
121
|
+
}
|
|
122
|
+
const mergeableSections = ['shapes', 'mutations', 'queries', 'forms', 'services'];
|
|
123
|
+
const isMergeableSection = (str) => {
|
|
124
|
+
return mergeableSections.includes(str);
|
|
125
|
+
};
|
|
126
|
+
const pickUnmergeable = (projectSchema) => {
|
|
127
|
+
return pickBy(projectSchema, (_value, key) => !isMergeableSection(key));
|
|
128
|
+
};
|
|
129
|
+
function compareSection(section, original, updated) {
|
|
130
|
+
const changes = [];
|
|
131
|
+
const originalKeys = Object.keys(original);
|
|
132
|
+
const updatedKeys = Object.keys(updated);
|
|
133
|
+
for (const removedKey of difference(originalKeys, updatedKeys)) {
|
|
134
|
+
changes.push({ path: [section, removedKey], section, op: 'remove' });
|
|
135
|
+
}
|
|
136
|
+
for (const [key, value] of Object.entries(updated)) {
|
|
137
|
+
if (!original[key]) {
|
|
138
|
+
changes.push({ path: [section, key], section, op: 'add', value });
|
|
139
|
+
}
|
|
140
|
+
else if (!isEqual(original[key], updated[key])) {
|
|
141
|
+
changes.push({ path: [section, key], section, op: 'update', value });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return changes;
|
|
145
|
+
}
|
|
146
|
+
function compareSections(parent, branch) {
|
|
147
|
+
return mergeableSections.flatMap((section) => (parent[section] ?? branch[section]) ? compareSection(section, parent[section] ?? {}, branch[section] ?? {}) : []);
|
|
148
|
+
}
|
|
149
|
+
function findChangedShape(schema, change) {
|
|
150
|
+
return schema.shapes[change.path[1]];
|
|
151
|
+
}
|
|
152
|
+
function getChangedShape(schema, change) {
|
|
153
|
+
const shape = findChangedShape(schema, change);
|
|
154
|
+
assert(shape, 'Expected shape not found');
|
|
155
|
+
return shape;
|
|
156
|
+
}
|
|
157
|
+
function rebaseShapeProperties(toShape, fromShape, baseShape) {
|
|
158
|
+
return baseShape
|
|
159
|
+
? rebaseObject(omit(toShape, 'schema'), omit(baseShape, 'schema'), omit(fromShape, 'schema'))
|
|
160
|
+
: { ...toShape, ...fromShape };
|
|
161
|
+
}
|
|
162
|
+
function attemptToMerge(base, parent, head, change) {
|
|
163
|
+
const toShape = getChangedShape(base, change);
|
|
164
|
+
const fromShape = getChangedShape(head, change);
|
|
165
|
+
const toSchema = toShape.schema;
|
|
166
|
+
const fromSchema = fromShape.schema;
|
|
167
|
+
if (isEqual(toSchema, fromSchema)) {
|
|
168
|
+
const baseShape = findChangedShape(parent, change);
|
|
169
|
+
return {
|
|
170
|
+
...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
171
|
+
schema: toSchema
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (isObjectSchema(toSchema) && isObjectSchema(fromSchema)) {
|
|
175
|
+
const baseShape = findChangedShape(parent, change);
|
|
176
|
+
const baseSchema = baseShape?.schema;
|
|
177
|
+
return {
|
|
178
|
+
...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
179
|
+
schema: change.op === 'update' && baseSchema && isObjectSchema(baseSchema)
|
|
180
|
+
? rebaseSchemaProperties(toSchema, baseSchema, fromSchema)
|
|
181
|
+
: mergeSchemaProperties(toSchema, fromSchema)
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
if (isExtendsSchema(toSchema) &&
|
|
185
|
+
isExtendsSchema(fromSchema) &&
|
|
186
|
+
toSchema.extends.length === fromSchema.extends.length) {
|
|
187
|
+
const fromExtends = fromSchema.extends;
|
|
188
|
+
const toObj = last(toSchema.extends);
|
|
189
|
+
const fromObj = last(fromSchema.extends);
|
|
190
|
+
if (toObj &&
|
|
191
|
+
isObjectSchema(toObj) &&
|
|
192
|
+
fromObj &&
|
|
193
|
+
isObjectSchema(fromObj) &&
|
|
194
|
+
toSchema.extends.slice(0, toSchema.extends.length - 1).every((item, i) => isEqual(item, fromExtends[i]))) {
|
|
195
|
+
let mergedObjSchema;
|
|
196
|
+
const baseShape = findChangedShape(parent, change);
|
|
197
|
+
const baseSchema = baseShape?.schema;
|
|
198
|
+
if (change.op === 'update' && baseSchema && isExtendsSchema(baseSchema)) {
|
|
199
|
+
const baseObj = last(baseSchema.extends);
|
|
200
|
+
if (baseObj && isObjectSchema(baseObj)) {
|
|
201
|
+
mergedObjSchema = rebaseSchemaProperties(toObj, baseObj, fromObj);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
mergedObjSchema ||= mergeSchemaProperties(toObj, fromObj);
|
|
205
|
+
return {
|
|
206
|
+
...rebaseShapeProperties(toShape, fromShape, baseShape),
|
|
207
|
+
schema: {
|
|
208
|
+
extends: [...toSchema.extends.slice(0, toSchema.extends.length - 1), mergedObjSchema]
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function applyChange(base, parent, head, change) {
|
|
215
|
+
if (change.op === 'remove') {
|
|
216
|
+
unset(base, change.path);
|
|
217
|
+
}
|
|
218
|
+
else if (change.op === 'add') {
|
|
219
|
+
set(base, change.path, change.value);
|
|
220
|
+
}
|
|
221
|
+
else if (change.op === 'update') {
|
|
222
|
+
if (change.section === 'shapes') {
|
|
223
|
+
const mergedShape = attemptToMerge(base, parent, head, change);
|
|
224
|
+
if (mergedShape) {
|
|
225
|
+
set(base, change.path, mergedShape);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
else if (change.section === 'forms') {
|
|
230
|
+
const shapeName = change.path[1];
|
|
231
|
+
const toForm = base.forms?.[shapeName]?.default;
|
|
232
|
+
const fromForm = head.forms?.[shapeName]?.default;
|
|
233
|
+
if (toForm && fromForm) {
|
|
234
|
+
const baseForm = parent.forms?.[shapeName]?.default;
|
|
235
|
+
set(base, change.path, {
|
|
236
|
+
default: baseForm ? rebaseFormProperties(toForm, baseForm, fromForm) : mergeFormConfigs(toForm, fromForm)
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
set(base, change.path, change.value);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
export function mergeProjectSchemas(base, parent, head) {
|
|
245
|
+
const changesTo = compareSections(parent, base);
|
|
246
|
+
const changesFrom = compareSections(parent, head);
|
|
247
|
+
const mergedSchema = deepClone(base);
|
|
248
|
+
for (let change of changesFrom) {
|
|
249
|
+
const potentialConflict = changesTo.find((changeTo) => isEqual(changeTo.path, change.path));
|
|
250
|
+
if (potentialConflict) {
|
|
251
|
+
if (potentialConflict.op === 'remove' && change.op !== 'remove') {
|
|
252
|
+
return {
|
|
253
|
+
error: `Attempting to ${change.op} ${change.path.join('.')} which has already been removed`,
|
|
254
|
+
mergedSchema: undefined
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if ((potentialConflict.op === 'add' && change.op === 'add') ||
|
|
258
|
+
(potentialConflict.op === 'update' && change.op === 'update')) {
|
|
259
|
+
if (change.section === 'shapes') {
|
|
260
|
+
const mergedValue = attemptToMerge(base, parent, head, change);
|
|
261
|
+
if (!mergedValue) {
|
|
262
|
+
return {
|
|
263
|
+
error: `Unable to merge ${change.path.join('.')} schemas conflict`,
|
|
264
|
+
mergedSchema: undefined
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
change = { ...change, op: 'add', value: mergedValue };
|
|
268
|
+
}
|
|
269
|
+
else if (change.section === 'forms') {
|
|
270
|
+
change = { ...change, op: 'update' };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
applyChange(mergedSchema, parent, head, change);
|
|
275
|
+
}
|
|
276
|
+
Object.assign(mergedSchema, rebaseObject(pickUnmergeable(base), pickUnmergeable(parent), pickUnmergeable(head)));
|
|
277
|
+
return { error: undefined, mergedSchema };
|
|
278
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ProjectSchemaUpdate } from '../migration/types.ts';
|
|
2
|
+
import type { ProjectSchemaJSON } from '../project-schema/index.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Apply a schema update to a schema. This can operate on a schema with frozen properties,
|
|
5
|
+
* such as one produced by immer. Resulting schema is not assumed to be valid and should
|
|
6
|
+
* be validated if appropriate.
|
|
7
|
+
*/
|
|
8
|
+
export declare function patchSchema<T extends ProjectSchemaJSON>(projectSchema: T, schemaUpdate: ProjectSchemaUpdate): T;
|
|
9
|
+
export type ApplyToProjectSchemaOptions = {
|
|
10
|
+
mode?: 'replace' | 'preserve' | 'fail';
|
|
11
|
+
servicesMode?: 'replace' | 'preserve' | 'fail';
|
|
12
|
+
};
|
|
13
|
+
export declare function getSchemaUpdateFromPattern(currentSchema: ProjectSchemaJSON, patternSchema: ProjectSchemaJSON, options: ApplyToProjectSchemaOptions): ProjectSchemaUpdate | undefined;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import set from 'lodash/fp/set.js';
|
|
2
|
+
import get from 'lodash/get.js';
|
|
3
|
+
import intersection from 'lodash/intersection.js';
|
|
4
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
5
|
+
import isEqual from 'lodash/isEqual.js';
|
|
6
|
+
import omit from 'lodash/omit.js';
|
|
7
|
+
import omitBy from 'lodash/omitBy.js';
|
|
8
|
+
import unset from 'lodash/unset.js';
|
|
9
|
+
import { AGENTS_UPDATE_KEY, GUARDS_UPDATE_KEY, TOOLS_UPDATE_KEY } from "../migration/types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Array of lodash.get paths to keys that are merged when applying a schema update.
|
|
12
|
+
*/
|
|
13
|
+
const MERGED_KEYS = [
|
|
14
|
+
'queries',
|
|
15
|
+
'mutations',
|
|
16
|
+
'shapes',
|
|
17
|
+
'workflows',
|
|
18
|
+
'forms',
|
|
19
|
+
'services',
|
|
20
|
+
AGENTS_UPDATE_KEY,
|
|
21
|
+
GUARDS_UPDATE_KEY,
|
|
22
|
+
TOOLS_UPDATE_KEY
|
|
23
|
+
];
|
|
24
|
+
function shallowMerge(original, update) {
|
|
25
|
+
const result = { ...original };
|
|
26
|
+
for (const [key, obj] of Object.entries(update)) {
|
|
27
|
+
// Null is a sentinel value to indicate delete
|
|
28
|
+
if (obj === null) {
|
|
29
|
+
unset(result, key);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
result[key] = obj;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Apply a schema update to a schema. This can operate on a schema with frozen properties,
|
|
39
|
+
* such as one produced by immer. Resulting schema is not assumed to be valid and should
|
|
40
|
+
* be validated if appropriate.
|
|
41
|
+
*/
|
|
42
|
+
export function patchSchema(projectSchema, schemaUpdate) {
|
|
43
|
+
// Patch old schema with update
|
|
44
|
+
let updatedSchema = {
|
|
45
|
+
...projectSchema,
|
|
46
|
+
...omit(schemaUpdate, MERGED_KEYS)
|
|
47
|
+
};
|
|
48
|
+
for (const key of MERGED_KEYS) {
|
|
49
|
+
const update = get(schemaUpdate, key);
|
|
50
|
+
if (update) {
|
|
51
|
+
updatedSchema = set(key, shallowMerge(get(projectSchema, key) ?? {}, update), updatedSchema);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return updatedSchema;
|
|
55
|
+
}
|
|
56
|
+
const DEFAULT_OPTIONS = {
|
|
57
|
+
mode: 'preserve',
|
|
58
|
+
servicesMode: 'preserve'
|
|
59
|
+
};
|
|
60
|
+
function setSectionUpdate(update, patternKey, currentValues, patternValues, options) {
|
|
61
|
+
const { mode, servicesMode } = { ...DEFAULT_OPTIONS, ...options };
|
|
62
|
+
const keyMode = patternKey === 'services' ? servicesMode : mode;
|
|
63
|
+
// Check for conflict in "fail" mode
|
|
64
|
+
if (keyMode === 'fail' && currentValues && patternValues) {
|
|
65
|
+
const wouldBeOverwritten = intersection(Object.keys(currentValues), Object.keys(patternValues));
|
|
66
|
+
if (wouldBeOverwritten.length > 0) {
|
|
67
|
+
throw new Error(`The following ${patternKey} would be overwritten: ${wouldBeOverwritten.join(', ')}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Add values to update
|
|
71
|
+
if (patternValues) {
|
|
72
|
+
const updateValues = keyMode === 'preserve' && currentValues
|
|
73
|
+
? omit(patternValues, Object.keys(currentValues))
|
|
74
|
+
: omitBy(patternValues, (value, key) => isEqual(currentValues?.[key], value));
|
|
75
|
+
if (!isEmpty(updateValues)) {
|
|
76
|
+
update[patternKey] = updateValues;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function isEmptyUpdate(update) {
|
|
81
|
+
return MERGED_KEYS.every((key) => isEmpty(update[key]));
|
|
82
|
+
}
|
|
83
|
+
export function getSchemaUpdateFromPattern(currentSchema, patternSchema, options) {
|
|
84
|
+
const update = {};
|
|
85
|
+
for (const path of MERGED_KEYS) {
|
|
86
|
+
setSectionUpdate(update, path, get(currentSchema, path), get(patternSchema, path), options);
|
|
87
|
+
}
|
|
88
|
+
return isEmptyUpdate(update) ? undefined : update;
|
|
89
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProjectSchemaJSON } from '../project-schema/index.ts';
|
|
2
|
+
export declare function getQueryFieldPath(operation: 'query' | 'mutation', fieldName: string): ['queries' | 'mutations', ...string[]];
|
|
3
|
+
/**
|
|
4
|
+
* Get a query or property schema
|
|
5
|
+
* @param schema
|
|
6
|
+
* @param queryFieldPath
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function findSchemaAtQueryFieldPath(schema: Pick<ProjectSchemaJSON, 'queries' | 'mutations' | 'services' | 'shapes'>, queryFieldPath: ReturnType<typeof getQueryFieldPath>): import("../project-schema/latest.ts").PropertySchema | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { findSchemaAtPath } from "./find-shape-at-path.js";
|
|
2
|
+
import { getReturnShape } from "./get-return-shape.js";
|
|
3
|
+
function parseFieldName(fieldName) {
|
|
4
|
+
return fieldName.split('.');
|
|
5
|
+
}
|
|
6
|
+
export function getQueryFieldPath(operation, fieldName) {
|
|
7
|
+
return [operation === 'query' ? 'queries' : 'mutations', ...parseFieldName(fieldName)];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get a query or property schema
|
|
11
|
+
* @param schema
|
|
12
|
+
* @param queryFieldPath
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export function findSchemaAtQueryFieldPath(schema, queryFieldPath) {
|
|
16
|
+
const [operationName, queryName, ...fieldPath] = queryFieldPath;
|
|
17
|
+
const queryOrMutation = schema[operationName]?.[queryName];
|
|
18
|
+
if (!queryOrMutation) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const shape = getReturnShape(schema, queryOrMutation);
|
|
22
|
+
return shape ? findSchemaAtPath(schema, shape.schema, fieldPath) : undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProjectSchemaJSON, ShapeJSON } from '../project-schema/index.ts';
|
|
2
|
+
export declare function getShapeById(projectSchema: Pick<ProjectSchemaJSON, 'shapes'>, shapeId: string): ShapeJSON | undefined;
|
|
3
|
+
export declare function getShape(context: Pick<ProjectSchemaJSON, 'shapes'>, name: string): ShapeJSON | undefined;
|
|
4
|
+
export declare function ensureShape(projectSchema: Pick<ProjectSchemaJSON, 'shapes'>, name: string): ShapeJSON;
|
|
5
|
+
export declare function ensureShapeById(projectSchema: Pick<ProjectSchemaJSON, 'shapes'>, shapeId: string): ShapeJSON;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NotFoundError } from '@takeshape/errors';
|
|
2
|
+
import find from 'lodash/find.js';
|
|
3
|
+
export function getShapeById(projectSchema, shapeId) {
|
|
4
|
+
return find(projectSchema.shapes, (shape) => shape.id === shapeId);
|
|
5
|
+
}
|
|
6
|
+
export function getShape(context, name) {
|
|
7
|
+
return context.shapes[name];
|
|
8
|
+
}
|
|
9
|
+
export function ensureShape(projectSchema, name) {
|
|
10
|
+
const shape = getShape(projectSchema, name);
|
|
11
|
+
if (!shape) {
|
|
12
|
+
throw new NotFoundError(`Shape "${name}" Not found`);
|
|
13
|
+
}
|
|
14
|
+
return shape;
|
|
15
|
+
}
|
|
16
|
+
export function ensureShapeById(projectSchema, shapeId) {
|
|
17
|
+
const shape = getShapeById(projectSchema, shapeId);
|
|
18
|
+
if (!shape) {
|
|
19
|
+
throw new NotFoundError(`Shape with id "${shapeId}" Not found`);
|
|
20
|
+
}
|
|
21
|
+
return shape;
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ToolMap } from '../project-schema/index.ts';
|
|
2
|
+
import type { LayerSchema, NamedToolJSON } from '../types/index.ts';
|
|
3
|
+
export declare const TOOL_SCHEMA_PATH: readonly ["tools"];
|
|
4
|
+
export declare function getToolMap(projectSchema: LayerSchema): ToolMap | undefined;
|
|
5
|
+
export declare function getTools(projectSchema: LayerSchema): NamedToolJSON[];
|
|
6
|
+
export declare function getToolNames(projectSchema: LayerSchema): string[];
|
|
7
|
+
export declare function getTool(layer: LayerSchema, toolRef: string): NamedToolJSON | undefined;
|
|
8
|
+
export declare function setTools<S extends Partial<LayerSchema>>(layer: S, tools: NamedToolJSON[]): S;
|
|
9
|
+
export declare function setTool<S extends Partial<LayerSchema>>(layer: S, namedTool: NamedToolJSON): S;
|
|
10
|
+
export declare function removeTools<S extends Partial<LayerSchema>>(layer: S, toolNames: string[]): S;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import omit from 'lodash/omit.js';
|
|
2
|
+
import { parsePropertyRef } from "../refs.js";
|
|
3
|
+
export const TOOL_SCHEMA_PATH = ['tools'];
|
|
4
|
+
export function getToolMap(projectSchema) {
|
|
5
|
+
return projectSchema.tools;
|
|
6
|
+
}
|
|
7
|
+
export function getTools(projectSchema) {
|
|
8
|
+
const { tools } = projectSchema;
|
|
9
|
+
return tools ? Object.keys(tools).map((name) => ({ name, ...tools[name] })) : [];
|
|
10
|
+
}
|
|
11
|
+
export function getToolNames(projectSchema) {
|
|
12
|
+
return projectSchema.tools ? Object.keys(projectSchema.tools) : [];
|
|
13
|
+
}
|
|
14
|
+
export function getTool(layer, toolRef) {
|
|
15
|
+
const parsed = parsePropertyRef(toolRef, 'Tool');
|
|
16
|
+
if (!parsed) {
|
|
17
|
+
throw new Error(`Invalid tool ref "${toolRef}"`);
|
|
18
|
+
}
|
|
19
|
+
const toolName = parsed.propertyName;
|
|
20
|
+
const tool = layer.tools?.[toolName];
|
|
21
|
+
return tool ? { ...tool, name: toolName } : undefined;
|
|
22
|
+
}
|
|
23
|
+
export function setTools(layer, tools) {
|
|
24
|
+
return {
|
|
25
|
+
...layer,
|
|
26
|
+
tools: tools.reduce((acc, { name, ...tool }) => {
|
|
27
|
+
acc[name] = tool;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function setTool(layer, namedTool) {
|
|
33
|
+
const { name, ...tool } = namedTool;
|
|
34
|
+
return { ...layer, tools: { ...(layer.tools ?? {}), [name]: tool } };
|
|
35
|
+
}
|
|
36
|
+
export function removeTools(layer, toolNames) {
|
|
37
|
+
const newTools = omit(layer.tools ?? {}, toolNames);
|
|
38
|
+
return { ...layer, tools: newTools };
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SchemaValidationErrorItem } from '@takeshape/errors';
|
|
2
|
+
import type { AgentToolConfig, ProjectSchemaJSON, ToolJSON } from '../project-schema/latest.ts';
|
|
3
|
+
import type { Path, ValidateReferencesContext } from './types.ts';
|
|
4
|
+
export declare function validateAIToolConfig(projectSchema: ProjectSchemaJSON, toolConfig: AgentToolConfig, basePath: Path): SchemaValidationErrorItem | undefined;
|
|
5
|
+
export declare function validateToolQuery(context: ValidateReferencesContext, tool: ToolJSON, basePath: Path): Promise<SchemaValidationErrorItem | undefined>;
|
|
6
|
+
export declare function validateAgents(projectSchema: ProjectSchemaJSON): SchemaValidationErrorItem[];
|