@copilotkit/shared 2.0.0-next.1 → 2.0.0-rc.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.
- package/LICENSE +21 -0
- package/README.md +93 -12
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/a2ui-envelope.cjs +154 -0
- package/dist/a2ui-envelope.cjs.map +1 -0
- package/dist/a2ui-envelope.d.cts +101 -0
- package/dist/a2ui-envelope.d.cts.map +1 -0
- package/dist/a2ui-envelope.d.mts +101 -0
- package/dist/a2ui-envelope.d.mts.map +1 -0
- package/dist/a2ui-envelope.mjs +151 -0
- package/dist/a2ui-envelope.mjs.map +1 -0
- package/dist/a2ui-prompts.cjs +259 -0
- package/dist/a2ui-prompts.cjs.map +1 -0
- package/dist/a2ui-prompts.d.cts +79 -0
- package/dist/a2ui-prompts.d.cts.map +1 -0
- package/dist/a2ui-prompts.d.mts +79 -0
- package/dist/a2ui-prompts.d.mts.map +1 -0
- package/dist/a2ui-prompts.mjs +251 -0
- package/dist/a2ui-prompts.mjs.map +1 -0
- package/dist/attachments/content.cjs +17 -0
- package/dist/attachments/content.cjs.map +1 -0
- package/dist/attachments/content.d.cts +9 -0
- package/dist/attachments/content.d.cts.map +1 -0
- package/dist/attachments/content.d.mts +9 -0
- package/dist/attachments/content.d.mts.map +1 -0
- package/dist/attachments/content.mjs +16 -0
- package/dist/attachments/content.mjs.map +1 -0
- package/dist/attachments/types.d.cts +64 -0
- package/dist/attachments/types.d.cts.map +1 -0
- package/dist/attachments/types.d.mts +64 -0
- package/dist/attachments/types.d.mts.map +1 -0
- package/dist/attachments/utils.cjs +137 -0
- package/dist/attachments/utils.cjs.map +1 -0
- package/dist/attachments/utils.d.cts +44 -0
- package/dist/attachments/utils.d.cts.map +1 -0
- package/dist/attachments/utils.d.mts +44 -0
- package/dist/attachments/utils.d.mts.map +1 -0
- package/dist/attachments/utils.mjs +129 -0
- package/dist/attachments/utils.mjs.map +1 -0
- package/dist/constants/index.cjs +25 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +17 -0
- package/dist/constants/index.d.cts.map +1 -0
- package/dist/constants/index.d.mts +17 -0
- package/dist/constants/index.d.mts.map +1 -0
- package/dist/constants/index.mjs +17 -12
- package/dist/constants/index.mjs.map +1 -1
- package/dist/debug-event-envelope.d.cts +13 -0
- package/dist/debug-event-envelope.d.cts.map +1 -0
- package/dist/debug-event-envelope.d.mts +13 -0
- package/dist/debug-event-envelope.d.mts.map +1 -0
- package/dist/debug.cjs +38 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.d.cts +29 -0
- package/dist/debug.d.cts.map +1 -0
- package/dist/debug.d.mts +29 -0
- package/dist/debug.d.mts.map +1 -0
- package/dist/debug.mjs +37 -0
- package/dist/debug.mjs.map +1 -0
- package/dist/event-transforms/index.cjs +15 -0
- package/dist/event-transforms/index.d.cts +4 -0
- package/dist/event-transforms/index.d.mts +4 -0
- package/dist/event-transforms/index.mjs +5 -0
- package/dist/event-transforms/open-generative-ui-middleware.cjs +286 -0
- package/dist/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.cts +60 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.mts +60 -0
- package/dist/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
- package/dist/event-transforms/open-generative-ui-middleware.mjs +283 -0
- package/dist/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
- package/dist/event-transforms/recorded-events.cjs +59 -0
- package/dist/event-transforms/recorded-events.cjs.map +1 -0
- package/dist/event-transforms/recorded-events.d.cts +23 -0
- package/dist/event-transforms/recorded-events.d.cts.map +1 -0
- package/dist/event-transforms/recorded-events.d.mts +23 -0
- package/dist/event-transforms/recorded-events.d.mts.map +1 -0
- package/dist/event-transforms/recorded-events.mjs +58 -0
- package/dist/event-transforms/recorded-events.mjs.map +1 -0
- package/dist/finalize-events.cjs +186 -0
- package/dist/finalize-events.cjs.map +1 -0
- package/dist/finalize-events.d.cts +40 -0
- package/dist/finalize-events.d.cts.map +1 -0
- package/dist/finalize-events.d.mts +40 -0
- package/dist/finalize-events.d.mts.map +1 -0
- package/dist/finalize-events.mjs +184 -0
- package/dist/finalize-events.mjs.map +1 -0
- package/dist/generative-ui/basic-functions.cjs +177 -0
- package/dist/generative-ui/basic-functions.cjs.map +1 -0
- package/dist/generative-ui/basic-functions.d.cts +108 -0
- package/dist/generative-ui/basic-functions.d.cts.map +1 -0
- package/dist/generative-ui/basic-functions.d.mts +108 -0
- package/dist/generative-ui/basic-functions.d.mts.map +1 -0
- package/dist/generative-ui/basic-functions.mjs +167 -0
- package/dist/generative-ui/basic-functions.mjs.map +1 -0
- package/dist/generative-ui/child-refs.cjs +161 -0
- package/dist/generative-ui/child-refs.cjs.map +1 -0
- package/dist/generative-ui/child-refs.d.cts +68 -0
- package/dist/generative-ui/child-refs.d.cts.map +1 -0
- package/dist/generative-ui/child-refs.d.mts +68 -0
- package/dist/generative-ui/child-refs.d.mts.map +1 -0
- package/dist/generative-ui/child-refs.mjs +152 -0
- package/dist/generative-ui/child-refs.mjs.map +1 -0
- package/dist/generative-ui/is-record.cjs +10 -0
- package/dist/generative-ui/is-record.cjs.map +1 -0
- package/dist/generative-ui/is-record.mjs +9 -0
- package/dist/generative-ui/is-record.mjs.map +1 -0
- package/dist/generative-ui/prompt.cjs +91 -0
- package/dist/generative-ui/prompt.cjs.map +1 -0
- package/dist/generative-ui/prompt.d.cts +13 -0
- package/dist/generative-ui/prompt.d.cts.map +1 -0
- package/dist/generative-ui/prompt.d.mts +13 -0
- package/dist/generative-ui/prompt.d.mts.map +1 -0
- package/dist/generative-ui/prompt.mjs +90 -0
- package/dist/generative-ui/prompt.mjs.map +1 -0
- package/dist/generative-ui/render-ui-args.cjs +160 -0
- package/dist/generative-ui/render-ui-args.cjs.map +1 -0
- package/dist/generative-ui/render-ui-args.d.cts +40 -0
- package/dist/generative-ui/render-ui-args.d.cts.map +1 -0
- package/dist/generative-ui/render-ui-args.d.mts +40 -0
- package/dist/generative-ui/render-ui-args.d.mts.map +1 -0
- package/dist/generative-ui/render-ui-args.mjs +159 -0
- package/dist/generative-ui/render-ui-args.mjs.map +1 -0
- package/dist/generative-ui/types.cjs +101 -0
- package/dist/generative-ui/types.cjs.map +1 -0
- package/dist/generative-ui/types.d.cts +270 -0
- package/dist/generative-ui/types.d.cts.map +1 -0
- package/dist/generative-ui/types.d.mts +270 -0
- package/dist/generative-ui/types.d.mts.map +1 -0
- package/dist/generative-ui/types.mjs +86 -0
- package/dist/generative-ui/types.mjs.map +1 -0
- package/dist/generative-ui/validate-operation.cjs +405 -0
- package/dist/generative-ui/validate-operation.cjs.map +1 -0
- package/dist/generative-ui/validate-operation.d.cts +86 -0
- package/dist/generative-ui/validate-operation.d.cts.map +1 -0
- package/dist/generative-ui/validate-operation.d.mts +86 -0
- package/dist/generative-ui/validate-operation.d.mts.map +1 -0
- package/dist/generative-ui/validate-operation.mjs +399 -0
- package/dist/generative-ui/validate-operation.mjs.map +1 -0
- package/dist/index.cjs +233 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +80 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +80 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +78 -123
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +3979 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/intelligence-routing-fields.cjs +35 -0
- package/dist/intelligence-routing-fields.cjs.map +1 -0
- package/dist/intelligence-routing-fields.d.cts +18 -0
- package/dist/intelligence-routing-fields.d.cts.map +1 -0
- package/dist/intelligence-routing-fields.d.mts +18 -0
- package/dist/intelligence-routing-fields.d.mts.map +1 -0
- package/dist/intelligence-routing-fields.mjs +34 -0
- package/dist/intelligence-routing-fields.mjs.map +1 -0
- package/dist/logger.cjs +7 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +5 -0
- package/dist/logger.d.cts.map +1 -0
- package/dist/logger.d.mts +5 -0
- package/dist/logger.d.mts.map +1 -0
- package/dist/logger.mjs +6 -0
- package/dist/logger.mjs.map +1 -0
- package/dist/open-generative-ui-prompts.cjs +8 -0
- package/dist/open-generative-ui-prompts.cjs.map +1 -0
- package/dist/open-generative-ui-prompts.d.cts +6 -0
- package/dist/open-generative-ui-prompts.d.cts.map +1 -0
- package/dist/open-generative-ui-prompts.d.mts +6 -0
- package/dist/open-generative-ui-prompts.d.mts.map +1 -0
- package/dist/open-generative-ui-prompts.mjs +7 -0
- package/dist/open-generative-ui-prompts.mjs.map +1 -0
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/standard-schema.cjs +31 -0
- package/dist/standard-schema.cjs.map +1 -0
- package/dist/standard-schema.d.cts +33 -0
- package/dist/standard-schema.d.cts.map +1 -0
- package/dist/standard-schema.d.mts +33 -0
- package/dist/standard-schema.d.mts.map +1 -0
- package/dist/standard-schema.mjs +30 -0
- package/dist/standard-schema.mjs.map +1 -0
- package/dist/telemetry/events.d.cts +72 -0
- package/dist/telemetry/events.d.cts.map +1 -0
- package/dist/telemetry/events.d.mts +72 -0
- package/dist/telemetry/events.d.mts.map +1 -0
- package/dist/telemetry/index.cjs +18 -0
- package/dist/telemetry/index.d.cts +5 -0
- package/dist/telemetry/index.d.mts +5 -0
- package/dist/telemetry/index.mjs +6 -12
- package/dist/telemetry/lambda-client.cjs +91 -0
- package/dist/telemetry/lambda-client.cjs.map +1 -0
- package/dist/telemetry/lambda-client.d.cts +31 -0
- package/dist/telemetry/lambda-client.d.cts.map +1 -0
- package/dist/telemetry/lambda-client.d.mts +31 -0
- package/dist/telemetry/lambda-client.d.mts.map +1 -0
- package/dist/telemetry/lambda-client.mjs +87 -0
- package/dist/telemetry/lambda-client.mjs.map +1 -0
- package/dist/telemetry/model-host.cjs +104 -0
- package/dist/telemetry/model-host.cjs.map +1 -0
- package/dist/telemetry/model-host.d.cts +26 -0
- package/dist/telemetry/model-host.d.cts.map +1 -0
- package/dist/telemetry/model-host.d.mts +26 -0
- package/dist/telemetry/model-host.d.mts.map +1 -0
- package/dist/telemetry/model-host.mjs +102 -0
- package/dist/telemetry/model-host.mjs.map +1 -0
- package/dist/telemetry/sampling.cjs +50 -0
- package/dist/telemetry/sampling.cjs.map +1 -0
- package/dist/telemetry/sampling.d.cts +57 -0
- package/dist/telemetry/sampling.d.cts.map +1 -0
- package/dist/telemetry/sampling.d.mts +57 -0
- package/dist/telemetry/sampling.d.mts.map +1 -0
- package/dist/telemetry/sampling.mjs +44 -0
- package/dist/telemetry/sampling.mjs.map +1 -0
- package/dist/telemetry/telemetry-client.cjs +165 -0
- package/dist/telemetry/telemetry-client.cjs.map +1 -0
- package/dist/telemetry/telemetry-client.d.cts +87 -0
- package/dist/telemetry/telemetry-client.d.cts.map +1 -0
- package/dist/telemetry/telemetry-client.d.mts +87 -0
- package/dist/telemetry/telemetry-client.d.mts.map +1 -0
- package/dist/telemetry/telemetry-client.mjs +162 -9
- package/dist/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/telemetry/telemetry-disabled.cjs +20 -0
- package/dist/telemetry/telemetry-disabled.cjs.map +1 -0
- package/dist/telemetry/telemetry-disabled.d.cts +16 -0
- package/dist/telemetry/telemetry-disabled.d.cts.map +1 -0
- package/dist/telemetry/telemetry-disabled.d.mts +16 -0
- package/dist/telemetry/telemetry-disabled.d.mts.map +1 -0
- package/dist/telemetry/telemetry-disabled.mjs +19 -0
- package/dist/telemetry/telemetry-disabled.mjs.map +1 -0
- package/dist/telemetry/utils.cjs +14 -0
- package/dist/telemetry/utils.cjs.map +1 -0
- package/dist/telemetry/utils.mjs +12 -8
- package/dist/telemetry/utils.mjs.map +1 -1
- package/dist/transcription-errors.cjs +84 -0
- package/dist/transcription-errors.cjs.map +1 -0
- package/dist/transcription-errors.d.cts +52 -0
- package/dist/transcription-errors.d.cts.map +1 -0
- package/dist/transcription-errors.d.mts +52 -0
- package/dist/transcription-errors.d.mts.map +1 -0
- package/dist/transcription-errors.mjs +82 -0
- package/dist/transcription-errors.mjs.map +1 -0
- package/dist/types/{action.d.ts → action.d.cts} +32 -32
- package/dist/types/action.d.cts.map +1 -0
- package/dist/types/action.d.mts +59 -0
- package/dist/types/action.d.mts.map +1 -0
- package/dist/types/copilot-cloud-config.d.cts +15 -0
- package/dist/types/copilot-cloud-config.d.cts.map +1 -0
- package/dist/types/copilot-cloud-config.d.mts +15 -0
- package/dist/types/copilot-cloud-config.d.mts.map +1 -0
- package/dist/types/error.d.cts +57 -0
- package/dist/types/error.d.cts.map +1 -0
- package/dist/types/error.d.mts +57 -0
- package/dist/types/error.d.mts.map +1 -0
- package/dist/types/message.d.cts +42 -0
- package/dist/types/message.d.cts.map +1 -0
- package/dist/types/message.d.mts +42 -0
- package/dist/types/message.d.mts.map +1 -0
- package/dist/types/openai-assistant.d.cts +55 -0
- package/dist/types/openai-assistant.d.cts.map +1 -0
- package/dist/types/openai-assistant.d.mts +55 -0
- package/dist/types/openai-assistant.d.mts.map +1 -0
- package/dist/types/utility.d.cts +6 -0
- package/dist/types/utility.d.cts.map +1 -0
- package/dist/types/utility.d.mts +6 -0
- package/dist/types/utility.d.mts.map +1 -0
- package/dist/utils/clipboard.cjs +28 -0
- package/dist/utils/clipboard.cjs.map +1 -0
- package/dist/utils/clipboard.d.cts +14 -0
- package/dist/utils/clipboard.d.cts.map +1 -0
- package/dist/utils/clipboard.d.mts +14 -0
- package/dist/utils/clipboard.d.mts.map +1 -0
- package/dist/utils/clipboard.mjs +27 -0
- package/dist/utils/clipboard.mjs.map +1 -0
- package/dist/utils/conditions.cjs +32 -0
- package/dist/utils/conditions.cjs.map +1 -0
- package/dist/utils/{conditions.d.ts → conditions.d.cts} +16 -11
- package/dist/utils/conditions.d.cts.map +1 -0
- package/dist/utils/conditions.d.mts +31 -0
- package/dist/utils/conditions.d.mts.map +1 -0
- package/dist/utils/conditions.mjs +30 -6
- package/dist/utils/conditions.mjs.map +1 -1
- package/dist/utils/console-styling.cjs +91 -0
- package/dist/utils/console-styling.cjs.map +1 -0
- package/dist/utils/console-styling.d.cts +65 -0
- package/dist/utils/console-styling.d.cts.map +1 -0
- package/dist/utils/console-styling.d.mts +65 -0
- package/dist/utils/console-styling.d.mts.map +1 -0
- package/dist/utils/console-styling.mjs +83 -15
- package/dist/utils/console-styling.mjs.map +1 -1
- package/dist/utils/dashboard-url.cjs +19 -0
- package/dist/utils/dashboard-url.cjs.map +1 -0
- package/dist/utils/dashboard-url.mjs +18 -0
- package/dist/utils/dashboard-url.mjs.map +1 -0
- package/dist/utils/errors.cjs +439 -0
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/{errors.d.ts → errors.d.cts} +188 -156
- package/dist/utils/errors.d.cts.map +1 -0
- package/dist/utils/errors.d.mts +312 -0
- package/dist/utils/errors.d.mts.map +1 -0
- package/dist/utils/errors.mjs +416 -63
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/index.cjs +105 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +58 -0
- package/dist/utils/index.d.cts.map +1 -0
- package/dist/utils/index.d.mts +58 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +97 -107
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/inspector-learning.cjs +217 -0
- package/dist/utils/inspector-learning.cjs.map +1 -0
- package/dist/utils/inspector-learning.d.cts +104 -0
- package/dist/utils/inspector-learning.d.cts.map +1 -0
- package/dist/utils/inspector-learning.d.mts +104 -0
- package/dist/utils/inspector-learning.d.mts.map +1 -0
- package/dist/utils/inspector-learning.mjs +215 -0
- package/dist/utils/inspector-learning.mjs.map +1 -0
- package/dist/utils/inspector-metadata.cjs +146 -0
- package/dist/utils/inspector-metadata.cjs.map +1 -0
- package/dist/utils/inspector-metadata.d.cts +55 -0
- package/dist/utils/inspector-metadata.d.cts.map +1 -0
- package/dist/utils/inspector-metadata.d.mts +55 -0
- package/dist/utils/inspector-metadata.d.mts.map +1 -0
- package/dist/utils/inspector-metadata.mjs +146 -0
- package/dist/utils/inspector-metadata.mjs.map +1 -0
- package/dist/utils/inspector-visibility.cjs +13 -0
- package/dist/utils/inspector-visibility.cjs.map +1 -0
- package/dist/utils/inspector-visibility.d.cts +18 -0
- package/dist/utils/inspector-visibility.d.cts.map +1 -0
- package/dist/utils/inspector-visibility.d.mts +18 -0
- package/dist/utils/inspector-visibility.d.mts.map +1 -0
- package/dist/utils/inspector-visibility.mjs +12 -0
- package/dist/utils/inspector-visibility.mjs.map +1 -0
- package/dist/utils/json-schema.cjs +215 -0
- package/dist/utils/json-schema.cjs.map +1 -0
- package/dist/utils/{json-schema.d.ts → json-schema.d.cts} +20 -18
- package/dist/utils/json-schema.d.cts.map +1 -0
- package/dist/utils/json-schema.d.mts +36 -0
- package/dist/utils/json-schema.d.mts.map +1 -0
- package/dist/utils/json-schema.mjs +210 -12
- package/dist/utils/json-schema.mjs.map +1 -1
- package/dist/utils/random-id.cjs +38 -0
- package/dist/utils/random-id.cjs.map +1 -0
- package/dist/utils/{random-id.d.ts → random-id.d.cts} +3 -1
- package/dist/utils/random-id.d.cts.map +1 -0
- package/dist/utils/random-id.d.mts +8 -0
- package/dist/utils/random-id.d.mts.map +1 -0
- package/dist/utils/random-id.mjs +33 -12
- package/dist/utils/random-id.mjs.map +1 -1
- package/dist/utils/requests.cjs +58 -0
- package/dist/utils/requests.cjs.map +1 -0
- package/dist/utils/{requests.d.ts → requests.d.cts} +3 -1
- package/dist/utils/requests.d.cts.map +1 -0
- package/dist/utils/requests.d.mts +12 -0
- package/dist/utils/requests.d.mts.map +1 -0
- package/dist/utils/requests.mjs +56 -6
- package/dist/utils/requests.mjs.map +1 -1
- package/dist/utils/row-render-keys.cjs +206 -0
- package/dist/utils/row-render-keys.cjs.map +1 -0
- package/dist/utils/row-render-keys.d.cts +65 -0
- package/dist/utils/row-render-keys.d.cts.map +1 -0
- package/dist/utils/row-render-keys.d.mts +65 -0
- package/dist/utils/row-render-keys.d.mts.map +1 -0
- package/dist/utils/row-render-keys.mjs +201 -0
- package/dist/utils/row-render-keys.mjs.map +1 -0
- package/dist/utils/types.cjs +9 -0
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +122 -0
- package/dist/utils/types.d.cts.map +1 -0
- package/dist/utils/types.d.mts +122 -0
- package/dist/utils/types.d.mts.map +1 -0
- package/dist/utils/types.mjs +6 -1
- package/dist/utils/types.mjs.map +1 -1
- package/package.json +74 -40
- package/scripts/verify-cjs-exports.cjs +16 -0
- package/src/__tests__/a2ui-envelope.test.ts +434 -0
- package/src/__tests__/a2ui-prompts.test.ts +362 -0
- package/src/__tests__/debug.test.ts +116 -0
- package/src/__tests__/license-context.test.ts +253 -0
- package/src/__tests__/root-entry-browser-safety.test.ts +91 -0
- package/src/__tests__/standard-schema-types.test.ts +144 -0
- package/src/__tests__/standard-schema.test.ts +359 -0
- package/src/__tests__/zod-regression.test.ts +319 -0
- package/src/a2ui-envelope.ts +309 -0
- package/src/a2ui-prompts.ts +322 -0
- package/src/attachments/__tests__/utils.test.ts +214 -0
- package/src/attachments/content.test.ts +48 -0
- package/src/attachments/content.ts +16 -0
- package/src/attachments/index.ts +21 -0
- package/src/attachments/types.ts +77 -0
- package/src/attachments/utils.ts +169 -0
- package/src/constants/index.ts +14 -1
- package/src/debug-event-envelope.ts +9 -0
- package/src/debug.ts +55 -0
- package/src/event-transforms/index.ts +5 -0
- package/src/event-transforms/open-generative-ui-middleware.ts +392 -0
- package/src/event-transforms/recorded-events.test.ts +166 -0
- package/src/event-transforms/recorded-events.ts +74 -0
- package/src/finalize-events.test.ts +284 -0
- package/src/finalize-events.ts +260 -0
- package/src/generative-ui/__tests__/render-ui-args.test.ts +175 -0
- package/src/generative-ui/__tests__/validate-operation.test.ts +977 -0
- package/src/generative-ui/basic-functions.ts +282 -0
- package/src/generative-ui/child-refs.ts +210 -0
- package/src/generative-ui/index.ts +6 -0
- package/src/generative-ui/is-record.ts +4 -0
- package/src/generative-ui/prompt.ts +174 -0
- package/src/generative-ui/render-ui-args.ts +199 -0
- package/src/generative-ui/types.ts +314 -0
- package/src/generative-ui/validate-operation.ts +723 -0
- package/src/index.ts +190 -1
- package/src/intelligence-routing-fields.test.ts +51 -0
- package/src/intelligence-routing-fields.ts +40 -0
- package/src/logger.ts +1 -0
- package/src/open-generative-ui-prompts.ts +20 -0
- package/src/standard-schema.ts +82 -0
- package/src/telemetry/events.ts +37 -10
- package/src/telemetry/index.ts +8 -0
- package/src/telemetry/lambda-client.test.ts +446 -0
- package/src/telemetry/lambda-client.ts +194 -0
- package/src/telemetry/model-host.test.ts +145 -0
- package/src/telemetry/model-host.ts +156 -0
- package/src/telemetry/sampling.test.ts +65 -0
- package/src/telemetry/sampling.ts +103 -0
- package/src/telemetry/telemetry-blank-license-identity.test.ts +128 -0
- package/src/telemetry/telemetry-client.test.ts +798 -0
- package/src/telemetry/telemetry-client.ts +223 -37
- package/src/telemetry/telemetry-disabled.ts +22 -0
- package/src/telemetry/utils.ts +0 -24
- package/src/transcription-errors.ts +99 -0
- package/src/types/__tests__/message.test.ts +62 -0
- package/src/types/action.ts +9 -5
- package/src/types/error.ts +11 -2
- package/src/types/message.ts +33 -5
- package/src/types/openai-assistant.ts +6 -2
- package/src/utils/__tests__/clipboard.test.ts +87 -0
- package/src/utils/__tests__/conditions.test.ts +161 -0
- package/src/utils/__tests__/json-schema.test.ts +812 -0
- package/src/utils/__tests__/row-render-keys.test.ts +388 -0
- package/src/utils/clipboard.ts +23 -0
- package/src/utils/conditions.ts +27 -9
- package/src/utils/console-styling.ts +10 -8
- package/src/utils/dashboard-url.ts +17 -0
- package/src/utils/errors.ts +55 -22
- package/src/utils/index.ts +70 -1
- package/src/utils/inspector-learning.test.ts +423 -0
- package/src/utils/inspector-learning.ts +523 -0
- package/src/utils/inspector-metadata.test.ts +743 -0
- package/src/utils/inspector-metadata.ts +263 -0
- package/src/utils/inspector-visibility.test.ts +43 -0
- package/src/utils/inspector-visibility.ts +17 -0
- package/src/utils/json-schema.ts +156 -12
- package/src/utils/random-id.ts +5 -2
- package/src/utils/requests.ts +3 -1
- package/src/utils/row-render-keys.ts +263 -0
- package/src/utils/types.ts +128 -1
- package/src/utils.test.ts +137 -0
- package/tsconfig.json +10 -2
- package/tsdown.config.ts +49 -0
- package/vitest.config.mjs +11 -0
- package/CHANGELOG.md +0 -1817
- package/dist/chunk-2OJ5OJ2D.mjs +0 -1
- package/dist/chunk-2OJ5OJ2D.mjs.map +0 -1
- package/dist/chunk-64DYJ27R.mjs +0 -201
- package/dist/chunk-64DYJ27R.mjs.map +0 -1
- package/dist/chunk-6QGXWNS5.mjs +0 -34
- package/dist/chunk-6QGXWNS5.mjs.map +0 -1
- package/dist/chunk-6W2UEO2M.mjs +0 -94
- package/dist/chunk-6W2UEO2M.mjs.map +0 -1
- package/dist/chunk-7DJDTRNX.mjs +0 -426
- package/dist/chunk-7DJDTRNX.mjs.map +0 -1
- package/dist/chunk-A66772CV.mjs +0 -107
- package/dist/chunk-A66772CV.mjs.map +0 -1
- package/dist/chunk-BOKE4OKY.mjs +0 -41
- package/dist/chunk-BOKE4OKY.mjs.map +0 -1
- package/dist/chunk-FCCOSO5L.mjs +0 -1
- package/dist/chunk-FCCOSO5L.mjs.map +0 -1
- package/dist/chunk-GYZIHHE6.mjs +0 -13
- package/dist/chunk-GYZIHHE6.mjs.map +0 -1
- package/dist/chunk-IAFBVORQ.mjs +0 -1
- package/dist/chunk-IAFBVORQ.mjs.map +0 -1
- package/dist/chunk-JAAUCDUR.mjs +0 -38
- package/dist/chunk-JAAUCDUR.mjs.map +0 -1
- package/dist/chunk-MSUB6DGR.mjs +0 -1
- package/dist/chunk-MSUB6DGR.mjs.map +0 -1
- package/dist/chunk-N5EP5OD5.mjs +0 -1
- package/dist/chunk-N5EP5OD5.mjs.map +0 -1
- package/dist/chunk-NAFEBKSO.mjs +0 -1
- package/dist/chunk-NAFEBKSO.mjs.map +0 -1
- package/dist/chunk-P7STFMPO.mjs +0 -1
- package/dist/chunk-P7STFMPO.mjs.map +0 -1
- package/dist/chunk-PL5WNHFZ.mjs +0 -50
- package/dist/chunk-PL5WNHFZ.mjs.map +0 -1
- package/dist/chunk-UYARLQNA.mjs +0 -1
- package/dist/chunk-UYARLQNA.mjs.map +0 -1
- package/dist/chunk-XEMZTHQZ.mjs +0 -67
- package/dist/chunk-XEMZTHQZ.mjs.map +0 -1
- package/dist/chunk-XTHC46M2.mjs +0 -1
- package/dist/chunk-XTHC46M2.mjs.map +0 -1
- package/dist/constants/index.d.ts +0 -6
- package/dist/constants/index.js +0 -40
- package/dist/constants/index.js.map +0 -1
- package/dist/index.d.ts +0 -25
- package/dist/index.js +0 -1098
- package/dist/index.js.map +0 -1
- package/dist/telemetry/events.d.ts +0 -45
- package/dist/telemetry/events.js +0 -19
- package/dist/telemetry/events.js.map +0 -1
- package/dist/telemetry/events.mjs +0 -1
- package/dist/telemetry/events.mjs.map +0 -1
- package/dist/telemetry/index.d.ts +0 -3
- package/dist/telemetry/index.js +0 -188
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/index.mjs.map +0 -1
- package/dist/telemetry/scarf-client.d.ts +0 -7
- package/dist/telemetry/scarf-client.js +0 -59
- package/dist/telemetry/scarf-client.js.map +0 -1
- package/dist/telemetry/scarf-client.mjs +0 -7
- package/dist/telemetry/scarf-client.mjs.map +0 -1
- package/dist/telemetry/security-check.d.ts +0 -2
- package/dist/telemetry/security-check.js +0 -2
- package/dist/telemetry/security-check.js.map +0 -1
- package/dist/telemetry/security-check.mjs +0 -1
- package/dist/telemetry/security-check.mjs.map +0 -1
- package/dist/telemetry/telemetry-client.d.ts +0 -40
- package/dist/telemetry/telemetry-client.js +0 -186
- package/dist/telemetry/telemetry-client.js.map +0 -1
- package/dist/telemetry/utils.d.ts +0 -8
- package/dist/telemetry/utils.js +0 -69
- package/dist/telemetry/utils.js.map +0 -1
- package/dist/types/action.js +0 -19
- package/dist/types/action.js.map +0 -1
- package/dist/types/action.mjs +0 -2
- package/dist/types/action.mjs.map +0 -1
- package/dist/types/copilot-cloud-config.d.ts +0 -13
- package/dist/types/copilot-cloud-config.js +0 -19
- package/dist/types/copilot-cloud-config.js.map +0 -1
- package/dist/types/copilot-cloud-config.mjs +0 -2
- package/dist/types/copilot-cloud-config.mjs.map +0 -1
- package/dist/types/error.d.ts +0 -55
- package/dist/types/error.js +0 -19
- package/dist/types/error.js.map +0 -1
- package/dist/types/error.mjs +0 -2
- package/dist/types/error.mjs.map +0 -1
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -19
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -8
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/message.d.ts +0 -26
- package/dist/types/message.js +0 -19
- package/dist/types/message.js.map +0 -1
- package/dist/types/message.mjs +0 -2
- package/dist/types/message.mjs.map +0 -1
- package/dist/types/openai-assistant.d.ts +0 -53
- package/dist/types/openai-assistant.js +0 -19
- package/dist/types/openai-assistant.js.map +0 -1
- package/dist/types/openai-assistant.mjs +0 -2
- package/dist/types/openai-assistant.mjs.map +0 -1
- package/dist/types/utility.d.ts +0 -6
- package/dist/types/utility.js +0 -19
- package/dist/types/utility.js.map +0 -1
- package/dist/types/utility.mjs +0 -2
- package/dist/types/utility.mjs.map +0 -1
- package/dist/utils/conditions.js +0 -74
- package/dist/utils/conditions.js.map +0 -1
- package/dist/utils/console-styling.d.ts +0 -84
- package/dist/utils/console-styling.js +0 -123
- package/dist/utils/console-styling.js.map +0 -1
- package/dist/utils/errors.js +0 -443
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -32
- package/dist/utils/index.js +0 -927
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/json-schema.js +0 -228
- package/dist/utils/json-schema.js.map +0 -1
- package/dist/utils/random-id.js +0 -68
- package/dist/utils/random-id.js.map +0 -1
- package/dist/utils/requests.js +0 -91
- package/dist/utils/requests.js.map +0 -1
- package/dist/utils/types.d.ts +0 -20
- package/dist/utils/types.js +0 -19
- package/dist/utils/types.js.map +0 -1
- package/jest.config.js +0 -5
- package/src/telemetry/scarf-client.ts +0 -39
- package/src/telemetry/security-check.ts +0 -0
- package/src/utils/json-schema.test.ts +0 -383
- package/tsup.config.ts +0 -11
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import { createLicenseContextValue } from "../index";
|
|
3
|
+
import type {
|
|
4
|
+
RuntimeEntitlementResponse,
|
|
5
|
+
RuntimeLicenseStatus,
|
|
6
|
+
} from "../utils/types";
|
|
7
|
+
|
|
8
|
+
test("license context fails open when no status is known", () => {
|
|
9
|
+
for (const status of [null, undefined] as const) {
|
|
10
|
+
const ctx = createLicenseContextValue(status);
|
|
11
|
+
expect(ctx.status).toBeNull();
|
|
12
|
+
expect(ctx.license).toBeNull();
|
|
13
|
+
expect(ctx.checkFeature("chat")).toBe(true);
|
|
14
|
+
expect(ctx.getLimit("chat")).toBeNull();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test.each(["valid", "none", "expiring", "unknown"] as RuntimeLicenseStatus[])(
|
|
19
|
+
"license context enables features for %s status",
|
|
20
|
+
(status) => {
|
|
21
|
+
const ctx = createLicenseContextValue(status);
|
|
22
|
+
expect(ctx.status).toBe(status);
|
|
23
|
+
expect(ctx.checkFeature("chat")).toBe(true);
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
test.each(["expired", "invalid"] as RuntimeLicenseStatus[])(
|
|
28
|
+
"license context disables features for %s status",
|
|
29
|
+
(status) => {
|
|
30
|
+
const ctx = createLicenseContextValue(status);
|
|
31
|
+
expect(ctx.status).toBe(status);
|
|
32
|
+
expect(ctx.checkFeature("chat")).toBe(false);
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
test("license context uses ready active feature grants and numeric limits", () => {
|
|
37
|
+
const ctx = createLicenseContextValue("valid", {
|
|
38
|
+
status: "ready",
|
|
39
|
+
entitlement: {
|
|
40
|
+
active: true,
|
|
41
|
+
source: "managedOrgSubscription",
|
|
42
|
+
features: {
|
|
43
|
+
chat: true,
|
|
44
|
+
threads: false,
|
|
45
|
+
},
|
|
46
|
+
limits: {
|
|
47
|
+
threads: 25,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(ctx.checkFeature("chat")).toBe(true);
|
|
53
|
+
expect(ctx.checkFeature("threads")).toBe(false);
|
|
54
|
+
expect(ctx.checkFeature("unknown")).toBe(false);
|
|
55
|
+
expect(ctx.getLimit("threads")).toBe(25);
|
|
56
|
+
expect(ctx.getLimit("unknown")).toBeNull();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test.each([0, 25])(
|
|
60
|
+
"license context treats an own threads.max_count limit of %s as a thread grant",
|
|
61
|
+
(threadLimit) => {
|
|
62
|
+
const ctx = createLicenseContextValue("valid", {
|
|
63
|
+
status: "ready",
|
|
64
|
+
entitlement: {
|
|
65
|
+
active: true,
|
|
66
|
+
source: "managedOrgSubscription",
|
|
67
|
+
features: {},
|
|
68
|
+
limits: { "threads.max_count": threadLimit },
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(ctx.checkFeature("threads")).toBe(true);
|
|
73
|
+
expect(ctx.getLimit("threads.max_count")).toBe(threadLimit);
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
test.each([
|
|
78
|
+
{
|
|
79
|
+
source: "managedOrgSubscription" as const,
|
|
80
|
+
features: {},
|
|
81
|
+
limits: {
|
|
82
|
+
"threads.retention_hours": 72,
|
|
83
|
+
"threads.max_count": 200,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
source: "selfHostedDeploymentLicense" as const,
|
|
88
|
+
features: {
|
|
89
|
+
deployment_via_helm_chart: true,
|
|
90
|
+
msteams: true,
|
|
91
|
+
},
|
|
92
|
+
limits: {
|
|
93
|
+
"threads.retention_hours": 336,
|
|
94
|
+
"threads.max_count": 25000,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
])(
|
|
98
|
+
"license context preserves legacy UI features for an active $source payload",
|
|
99
|
+
(entitlement) => {
|
|
100
|
+
const ctx = createLicenseContextValue("valid", {
|
|
101
|
+
status: "ready",
|
|
102
|
+
entitlement: {
|
|
103
|
+
active: true,
|
|
104
|
+
...entitlement,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
for (const feature of ["chat", "popup", "sidebar", "threads"]) {
|
|
109
|
+
expect(ctx.checkFeature(feature)).toBe(true);
|
|
110
|
+
}
|
|
111
|
+
expect(ctx.checkFeature("unknown")).toBe(false);
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
test.each(["chat", "popup", "sidebar"])(
|
|
116
|
+
"license context preserves an explicit %s denial",
|
|
117
|
+
(feature) => {
|
|
118
|
+
const ctx = createLicenseContextValue("valid", {
|
|
119
|
+
status: "ready",
|
|
120
|
+
entitlement: {
|
|
121
|
+
active: true,
|
|
122
|
+
source: "managedOrgSubscription",
|
|
123
|
+
features: { [feature]: false },
|
|
124
|
+
limits: {},
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(ctx.checkFeature(feature)).toBe(false);
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
test.each([true, false])(
|
|
133
|
+
"license context preserves a legacy threads feature value of %s",
|
|
134
|
+
(threads) => {
|
|
135
|
+
const ctx = createLicenseContextValue("valid", {
|
|
136
|
+
status: "ready",
|
|
137
|
+
entitlement: {
|
|
138
|
+
active: true,
|
|
139
|
+
source: "selfHostedDeploymentLicense",
|
|
140
|
+
features: { threads },
|
|
141
|
+
limits: {},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
expect(ctx.checkFeature("threads")).toBe(threads);
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
test("license context denies features and limits for a ready inactive entitlement", () => {
|
|
150
|
+
const ctx = createLicenseContextValue("none", {
|
|
151
|
+
status: "ready",
|
|
152
|
+
entitlement: {
|
|
153
|
+
active: false,
|
|
154
|
+
source: "managedOrgSubscription",
|
|
155
|
+
features: {
|
|
156
|
+
chat: true,
|
|
157
|
+
},
|
|
158
|
+
limits: {
|
|
159
|
+
threads: 25,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
expect(ctx.checkFeature("chat")).toBe(false);
|
|
165
|
+
expect(ctx.getLimit("threads")).toBeNull();
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("license context does not fall back for an inactive AWS Marketplace entitlement", () => {
|
|
169
|
+
const marketplaceEntitlements = {
|
|
170
|
+
status: "ready",
|
|
171
|
+
entitlement: {
|
|
172
|
+
active: false,
|
|
173
|
+
source: "awsMarketplaceDeploymentLicense",
|
|
174
|
+
features: {},
|
|
175
|
+
limits: {},
|
|
176
|
+
},
|
|
177
|
+
} as const satisfies RuntimeEntitlementResponse;
|
|
178
|
+
|
|
179
|
+
const ctx = createLicenseContextValue("valid", marketplaceEntitlements);
|
|
180
|
+
|
|
181
|
+
expect(ctx.status).toBe("none");
|
|
182
|
+
expect(ctx.checkFeature("threads")).toBe(false);
|
|
183
|
+
expect(ctx.getLimit("threads")).toBeNull();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test.each(["valid", "expiring"] as RuntimeLicenseStatus[])(
|
|
187
|
+
"license context preserves a %s legacy fallback for an inactive self-hosted entitlement",
|
|
188
|
+
(status) => {
|
|
189
|
+
const ctx = createLicenseContextValue(status, {
|
|
190
|
+
status: "ready",
|
|
191
|
+
entitlement: {
|
|
192
|
+
active: false,
|
|
193
|
+
source: "selfHostedDeploymentLicense",
|
|
194
|
+
features: {
|
|
195
|
+
threads: false,
|
|
196
|
+
},
|
|
197
|
+
limits: {
|
|
198
|
+
threads: 0,
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(ctx.status).toBe(status);
|
|
204
|
+
expect(ctx.checkFeature("threads")).toBe(true);
|
|
205
|
+
expect(ctx.getLimit("threads")).toBeNull();
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
test.each([
|
|
210
|
+
{ status: undefined, expectedStatus: "none" },
|
|
211
|
+
{ status: "none", expectedStatus: "none" },
|
|
212
|
+
{ status: "expired", expectedStatus: "expired" },
|
|
213
|
+
{ status: "invalid", expectedStatus: "invalid" },
|
|
214
|
+
{ status: "unknown", expectedStatus: "unknown" },
|
|
215
|
+
] as const)(
|
|
216
|
+
"license context denies an inactive self-hosted entitlement with $status legacy status",
|
|
217
|
+
({ status, expectedStatus }) => {
|
|
218
|
+
const ctx = createLicenseContextValue(status, {
|
|
219
|
+
status: "ready",
|
|
220
|
+
entitlement: {
|
|
221
|
+
active: false,
|
|
222
|
+
source: "selfHostedDeploymentLicense",
|
|
223
|
+
features: {
|
|
224
|
+
threads: true,
|
|
225
|
+
},
|
|
226
|
+
limits: {
|
|
227
|
+
threads: 25,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
expect(ctx.status).toBe(expectedStatus);
|
|
233
|
+
expect(ctx.checkFeature("threads")).toBe(false);
|
|
234
|
+
expect(ctx.getLimit("threads")).toBeNull();
|
|
235
|
+
},
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
test("license context ignores inherited feature and limit keys", () => {
|
|
239
|
+
const ctx = createLicenseContextValue("valid", {
|
|
240
|
+
status: "ready",
|
|
241
|
+
entitlement: {
|
|
242
|
+
active: true,
|
|
243
|
+
source: "managedOrgSubscription",
|
|
244
|
+
features: {},
|
|
245
|
+
limits: {},
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
for (const feature of ["toString", "constructor"]) {
|
|
250
|
+
expect(ctx.checkFeature(feature)).toBe(false);
|
|
251
|
+
expect(ctx.getLimit(feature)).toBeNull();
|
|
252
|
+
}
|
|
253
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `@copilotkit/shared` is imported by browser-facing packages such as
|
|
7
|
+
* `@copilotkit/react-core`. Browser bundlers resolve the whole static module
|
|
8
|
+
* graph before they tree-shake, so a single static edge from this entry to a
|
|
9
|
+
* Node-only package makes every dependent browser build print "Module ... has
|
|
10
|
+
* been externalized for browser compatibility" warnings, even when the
|
|
11
|
+
* consumer never touches the offending code. That was issue #4151, caused by
|
|
12
|
+
* the root entry re-exporting `telemetry/telemetry-client.ts`.
|
|
13
|
+
*
|
|
14
|
+
* Deferring the import does not help: a dynamic import keeps the graph edge.
|
|
15
|
+
* The edge itself has to stay out of this entry. This test walks the static,
|
|
16
|
+
* value-level graph from `src/index.ts` and fails if it reaches a Node-only
|
|
17
|
+
* package. Type-only edges are erased at build time and are therefore fine.
|
|
18
|
+
*/
|
|
19
|
+
const NODE_ONLY_PACKAGES = [
|
|
20
|
+
"@segment/analytics-node",
|
|
21
|
+
"node-fetch",
|
|
22
|
+
"@ag-ui/a2ui-middleware",
|
|
23
|
+
"clarinet",
|
|
24
|
+
"rxjs",
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const SRC = resolve(__dirname, "..");
|
|
28
|
+
|
|
29
|
+
function resolveRelative(fromFile: string, specifier: string): string | null {
|
|
30
|
+
const base = join(dirname(fromFile), specifier);
|
|
31
|
+
for (const candidate of [
|
|
32
|
+
`${base}.ts`,
|
|
33
|
+
`${base}.tsx`,
|
|
34
|
+
join(base, "index.ts"),
|
|
35
|
+
base,
|
|
36
|
+
]) {
|
|
37
|
+
if (existsSync(candidate) && !candidate.endsWith("/")) {
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Bare specifiers reachable from `entry` through value (non-type) edges. */
|
|
45
|
+
function collectRuntimeDependencies(entry: string): Set<string> {
|
|
46
|
+
const bare = new Set<string>();
|
|
47
|
+
const seen = new Set<string>();
|
|
48
|
+
const queue = [entry];
|
|
49
|
+
|
|
50
|
+
while (queue.length > 0) {
|
|
51
|
+
const file = queue.pop()!;
|
|
52
|
+
if (seen.has(file)) continue;
|
|
53
|
+
seen.add(file);
|
|
54
|
+
|
|
55
|
+
const source = readFileSync(file, "utf8");
|
|
56
|
+
// `import ... from "x"`, `export ... from "x"`, `import("x")`. The
|
|
57
|
+
// negative lookahead drops `import type` / `export type`, which the
|
|
58
|
+
// compiler erases.
|
|
59
|
+
const pattern =
|
|
60
|
+
/(?:\b(?:import|export)\b(?!\s+type\b)[\s\S]*?\bfrom\s*|\bimport\s*\(\s*)["']([^"']+)["']/g;
|
|
61
|
+
|
|
62
|
+
for (const match of source.matchAll(pattern)) {
|
|
63
|
+
const specifier = match[1];
|
|
64
|
+
if (specifier.startsWith(".")) {
|
|
65
|
+
const target = resolveRelative(file, specifier);
|
|
66
|
+
if (target) queue.push(target);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
bare.add(specifier);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return bare;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe("root entry browser safety (#4151)", () => {
|
|
77
|
+
it("does not reach Node-only packages through value imports", () => {
|
|
78
|
+
const reachable = collectRuntimeDependencies(join(SRC, "index.ts"));
|
|
79
|
+
const offenders = NODE_ONLY_PACKAGES.filter((pkg) => reachable.has(pkg));
|
|
80
|
+
expect(offenders).toEqual([]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("still reaches Node-only packages from the telemetry subpath entry", () => {
|
|
84
|
+
// Guards the test itself: the walker has to be able to see the edge it is
|
|
85
|
+
// asserting the absence of above.
|
|
86
|
+
const reachable = collectRuntimeDependencies(
|
|
87
|
+
join(SRC, "telemetry", "index.ts"),
|
|
88
|
+
);
|
|
89
|
+
expect(reachable).toContain("@segment/analytics-node");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, it, expectTypeOf } from "vitest";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
import { type } from "arktype";
|
|
5
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
|
+
import type { InferSchemaOutput } from "../standard-schema";
|
|
7
|
+
|
|
8
|
+
describe("InferSchemaOutput type inference", () => {
|
|
9
|
+
describe("Zod schemas", () => {
|
|
10
|
+
it("infers output type from a Zod object schema", () => {
|
|
11
|
+
const schema = z.object({
|
|
12
|
+
city: z.string(),
|
|
13
|
+
count: z.number(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
17
|
+
city: string;
|
|
18
|
+
count: number;
|
|
19
|
+
}>();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("infers output type with optional fields", () => {
|
|
23
|
+
const schema = z.object({
|
|
24
|
+
name: z.string(),
|
|
25
|
+
age: z.number().optional(),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
29
|
+
name: string;
|
|
30
|
+
age?: number | undefined;
|
|
31
|
+
}>();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("infers output type with enums", () => {
|
|
35
|
+
const schema = z.object({
|
|
36
|
+
unit: z.enum(["celsius", "fahrenheit"]),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
40
|
+
unit: "celsius" | "fahrenheit";
|
|
41
|
+
}>();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("infers output type with nested objects", () => {
|
|
45
|
+
const schema = z.object({
|
|
46
|
+
user: z.object({
|
|
47
|
+
name: z.string(),
|
|
48
|
+
email: z.string(),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
53
|
+
user: { name: string; email: string };
|
|
54
|
+
}>();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("infers output type with arrays", () => {
|
|
58
|
+
const schema = z.object({
|
|
59
|
+
tags: z.array(z.string()),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
63
|
+
tags: string[];
|
|
64
|
+
}>();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("Valibot schemas", () => {
|
|
69
|
+
it("infers output type from a Valibot object schema", () => {
|
|
70
|
+
const schema = v.object({
|
|
71
|
+
query: v.string(),
|
|
72
|
+
limit: v.number(),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
76
|
+
query: string;
|
|
77
|
+
limit: number;
|
|
78
|
+
}>();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("infers output type with optional fields", () => {
|
|
82
|
+
const schema = v.object({
|
|
83
|
+
name: v.string(),
|
|
84
|
+
age: v.optional(v.number()),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
88
|
+
name: string;
|
|
89
|
+
age?: number | undefined;
|
|
90
|
+
}>();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("infers output type with nested objects", () => {
|
|
94
|
+
const schema = v.object({
|
|
95
|
+
user: v.object({
|
|
96
|
+
name: v.string(),
|
|
97
|
+
email: v.string(),
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
102
|
+
user: { name: string; email: string };
|
|
103
|
+
}>();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe("ArkType schemas", () => {
|
|
108
|
+
it("infers output type from an ArkType object schema", () => {
|
|
109
|
+
const schema = type({
|
|
110
|
+
query: "string",
|
|
111
|
+
limit: "number",
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
115
|
+
query: string;
|
|
116
|
+
limit: number;
|
|
117
|
+
}>();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("infers output type with optional fields", () => {
|
|
121
|
+
const schema = type({
|
|
122
|
+
name: "string",
|
|
123
|
+
"age?": "number",
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expectTypeOf<InferSchemaOutput<typeof schema>>().toEqualTypeOf<{
|
|
127
|
+
name: string;
|
|
128
|
+
age?: number;
|
|
129
|
+
}>();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("StandardSchemaV1 compatibility", () => {
|
|
134
|
+
it("all schema types satisfy StandardSchemaV1", () => {
|
|
135
|
+
expectTypeOf(
|
|
136
|
+
z.object({ a: z.string() }),
|
|
137
|
+
).toMatchTypeOf<StandardSchemaV1>();
|
|
138
|
+
expectTypeOf(
|
|
139
|
+
v.object({ a: v.string() }),
|
|
140
|
+
).toMatchTypeOf<StandardSchemaV1>();
|
|
141
|
+
expectTypeOf(type({ a: "string" })).toMatchTypeOf<StandardSchemaV1>();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|