alchemy 0.62.2 → 0.63.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/bin/alchemy.js +1518 -1204
- package/bin/commands/deploy.ts +2 -0
- package/bin/commands/dev.ts +2 -0
- package/bin/services/execute-alchemy.ts +11 -0
- package/bin/services/template-manager.ts +2 -0
- package/bin/types.ts +2 -1
- package/lib/alchemy.d.ts +6 -22
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +65 -169
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts +0 -2
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +2 -16
- package/lib/apply.js.map +1 -1
- package/lib/aws/account-id.d.ts.map +1 -1
- package/lib/aws/account-id.js +3 -2
- package/lib/aws/account-id.js.map +1 -1
- package/lib/aws/bucket.d.ts +8 -2
- package/lib/aws/bucket.d.ts.map +1 -1
- package/lib/aws/bucket.js +21 -14
- package/lib/aws/bucket.js.map +1 -1
- package/lib/aws/ec2/security-group.d.ts +8 -2
- package/lib/aws/ec2/security-group.d.ts.map +1 -1
- package/lib/aws/ec2/security-group.js +7 -2
- package/lib/aws/ec2/security-group.js.map +1 -1
- package/lib/aws/function.d.ts +9 -3
- package/lib/aws/function.d.ts.map +1 -1
- package/lib/aws/function.js +35 -26
- package/lib/aws/function.js.map +1 -1
- package/lib/aws/policy-attachment.d.ts.map +1 -1
- package/lib/aws/policy-attachment.js +2 -1
- package/lib/aws/policy-attachment.js.map +1 -1
- package/lib/aws/policy.d.ts +8 -2
- package/lib/aws/policy.d.ts.map +1 -1
- package/lib/aws/policy.js +13 -4
- package/lib/aws/policy.js.map +1 -1
- package/lib/aws/queue.d.ts +8 -2
- package/lib/aws/queue.d.ts.map +1 -1
- package/lib/aws/queue.js +22 -14
- package/lib/aws/queue.js.map +1 -1
- package/lib/aws/role.d.ts +8 -2
- package/lib/aws/role.d.ts.map +1 -1
- package/lib/aws/role.js +10 -3
- package/lib/aws/role.js.map +1 -1
- package/lib/aws/ses.d.ts +1 -1
- package/lib/aws/ses.d.ts.map +1 -1
- package/lib/aws/ses.js +2 -1
- package/lib/aws/ses.js.map +1 -1
- package/lib/aws/ssm-parameter.d.ts +8 -2
- package/lib/aws/ssm-parameter.d.ts.map +1 -1
- package/lib/aws/ssm-parameter.js +15 -10
- package/lib/aws/ssm-parameter.js.map +1 -1
- package/lib/aws/table.d.ts +8 -2
- package/lib/aws/table.d.ts.map +1 -1
- package/lib/aws/table.js +17 -9
- package/lib/aws/table.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts +2 -2
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js +7 -6
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/ai-gateway.d.ts +9 -4
- package/lib/cloudflare/ai-gateway.d.ts.map +1 -1
- package/lib/cloudflare/ai-gateway.js +20 -24
- package/lib/cloudflare/ai-gateway.js.map +1 -1
- package/lib/cloudflare/api-schema.d.ts +2 -2
- package/lib/cloudflare/api-schema.d.ts.map +1 -1
- package/lib/cloudflare/api-schema.js +6 -2
- package/lib/cloudflare/api-schema.js.map +1 -1
- package/lib/cloudflare/api-shield.d.ts +5 -1
- package/lib/cloudflare/api-shield.d.ts.map +1 -1
- package/lib/cloudflare/api-shield.js +6 -1
- package/lib/cloudflare/api-shield.js.map +1 -1
- package/lib/cloudflare/assets.d.ts +1 -1
- package/lib/cloudflare/assets.d.ts.map +1 -1
- package/lib/cloudflare/astro/astro.d.ts.map +1 -1
- package/lib/cloudflare/astro/astro.js +3 -1
- package/lib/cloudflare/astro/astro.js.map +1 -1
- package/lib/cloudflare/astro/plugin.d.ts +2 -1
- package/lib/cloudflare/astro/plugin.d.ts.map +1 -1
- package/lib/cloudflare/astro/plugin.js.map +1 -1
- package/lib/cloudflare/bindings.d.ts +2 -2
- package/lib/cloudflare/bindings.d.ts.map +1 -1
- package/lib/cloudflare/bound.d.ts +1 -1
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +120 -1
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +80 -2
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/container.d.ts +10 -4
- package/lib/cloudflare/container.d.ts.map +1 -1
- package/lib/cloudflare/container.js +12 -9
- package/lib/cloudflare/container.js.map +1 -1
- package/lib/cloudflare/custom-domain.js +2 -1
- package/lib/cloudflare/custom-domain.js.map +1 -1
- package/lib/cloudflare/d1-database.d.ts +1 -1
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +7 -3
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/dispatch-namespace.d.ts +2 -0
- package/lib/cloudflare/dispatch-namespace.d.ts.map +1 -1
- package/lib/cloudflare/dispatch-namespace.js +7 -5
- package/lib/cloudflare/dispatch-namespace.js.map +1 -1
- package/lib/cloudflare/hyperdrive.d.ts +7 -1
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js +2 -1
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +3 -0
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv-namespace.js +11 -2
- package/lib/cloudflare/kv-namespace.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +3 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
- package/lib/cloudflare/miniflare/paths.d.ts +4 -0
- package/lib/cloudflare/miniflare/paths.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/paths.js +11 -0
- package/lib/cloudflare/miniflare/paths.js.map +1 -1
- package/lib/cloudflare/pipeline.d.ts +14 -3
- package/lib/cloudflare/pipeline.d.ts.map +1 -1
- package/lib/cloudflare/pipeline.js +31 -2
- package/lib/cloudflare/pipeline.js.map +1 -1
- package/lib/cloudflare/queue-consumer.js +1 -1
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/queue.d.ts +6 -4
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +13 -9
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/react-router/plugin.d.ts +1 -1
- package/lib/cloudflare/react-router/plugin.d.ts.map +1 -1
- package/lib/cloudflare/react-router/react-router.d.ts.map +1 -1
- package/lib/cloudflare/react-router/react-router.js +32 -2
- package/lib/cloudflare/react-router/react-router.js.map +1 -1
- package/lib/cloudflare/redwood/plugin.d.ts +2 -1
- package/lib/cloudflare/redwood/plugin.d.ts.map +1 -1
- package/lib/cloudflare/redwood/plugin.js.map +1 -1
- package/lib/cloudflare/route.js +1 -1
- package/lib/cloudflare/route.js.map +1 -1
- package/lib/cloudflare/ruleset.d.ts +3 -1
- package/lib/cloudflare/ruleset.d.ts.map +1 -1
- package/lib/cloudflare/ruleset.js +3 -2
- package/lib/cloudflare/ruleset.js.map +1 -1
- package/lib/cloudflare/secret.d.ts +6 -23
- package/lib/cloudflare/secret.d.ts.map +1 -1
- package/lib/cloudflare/secret.js +8 -4
- package/lib/cloudflare/secret.js.map +1 -1
- package/lib/cloudflare/secrets-store.d.ts +1 -1
- package/lib/cloudflare/secrets-store.d.ts.map +1 -1
- package/lib/cloudflare/secrets-store.js +5 -2
- package/lib/cloudflare/secrets-store.js.map +1 -1
- package/lib/cloudflare/tunnel.d.ts +5 -1
- package/lib/cloudflare/tunnel.d.ts.map +1 -1
- package/lib/cloudflare/tunnel.js +5 -1
- package/lib/cloudflare/tunnel.js.map +1 -1
- package/lib/cloudflare/vectorize-index.d.ts +7 -1
- package/lib/cloudflare/vectorize-index.d.ts.map +1 -1
- package/lib/cloudflare/vectorize-index.js +5 -2
- package/lib/cloudflare/vectorize-index.js.map +1 -1
- package/lib/cloudflare/vite/plugin.d.ts +2 -1
- package/lib/cloudflare/vite/plugin.d.ts.map +1 -1
- package/lib/cloudflare/vite/plugin.js.map +1 -1
- package/lib/cloudflare/vite/vite.d.ts +1 -1
- package/lib/cloudflare/vite/vite.d.ts.map +1 -1
- package/lib/cloudflare/vite/vite.js +1 -1
- package/lib/cloudflare/vite/vite.js.map +1 -1
- package/lib/cloudflare/website.js +1 -1
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +1 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +12 -7
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +1 -1
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +5 -3
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/docker/container.d.ts +6 -0
- package/lib/docker/container.d.ts.map +1 -1
- package/lib/docker/container.js +5 -1
- package/lib/docker/container.js.map +1 -1
- package/lib/docker/network.d.ts +8 -2
- package/lib/docker/network.d.ts.map +1 -1
- package/lib/docker/network.js +7 -2
- package/lib/docker/network.js.map +1 -1
- package/lib/docker/volume.d.ts +8 -2
- package/lib/docker/volume.d.ts.map +1 -1
- package/lib/docker/volume.js +6 -4
- package/lib/docker/volume.js.map +1 -1
- package/lib/esbuild/bundle.d.ts +1 -1
- package/lib/fs/index.d.ts +0 -8
- package/lib/fs/index.d.ts.map +1 -1
- package/lib/fs/index.js +0 -8
- package/lib/fs/index.js.map +1 -1
- package/lib/github/client.d.ts +1 -1
- package/lib/github/client.d.ts.map +1 -1
- package/lib/github/client.js +2 -1
- package/lib/github/client.js.map +1 -1
- package/lib/github/repository-environment.d.ts +8 -2
- package/lib/github/repository-environment.d.ts.map +1 -1
- package/lib/github/repository-environment.js +16 -12
- package/lib/github/repository-environment.js.map +1 -1
- package/lib/neon/project.d.ts +7 -1
- package/lib/neon/project.d.ts.map +1 -1
- package/lib/neon/project.js +10 -6
- package/lib/neon/project.js.map +1 -1
- package/lib/planetscale/branch.d.ts +4 -2
- package/lib/planetscale/branch.d.ts.map +1 -1
- package/lib/planetscale/branch.js +18 -12
- package/lib/planetscale/branch.js.map +1 -1
- package/lib/planetscale/database.d.ts +8 -2
- package/lib/planetscale/database.d.ts.map +1 -1
- package/lib/planetscale/database.js +24 -16
- package/lib/planetscale/database.js.map +1 -1
- package/lib/planetscale/password.d.ts +8 -2
- package/lib/planetscale/password.d.ts.map +1 -1
- package/lib/planetscale/password.js +2 -2
- package/lib/planetscale/password.js.map +1 -1
- package/lib/resource.d.ts +0 -2
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js +1 -9
- package/lib/resource.js.map +1 -1
- package/lib/scope.d.ts +9 -3
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +21 -34
- package/lib/scope.js.map +1 -1
- package/lib/sentry/client-key.d.ts +7 -1
- package/lib/sentry/client-key.d.ts.map +1 -1
- package/lib/sentry/client-key.js +45 -6
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/sentry/project.d.ts +8 -2
- package/lib/sentry/project.d.ts.map +1 -1
- package/lib/sentry/project.js +35 -5
- package/lib/sentry/project.js.map +1 -1
- package/lib/sentry/team.d.ts +8 -2
- package/lib/sentry/team.d.ts.map +1 -1
- package/lib/sentry/team.js +36 -6
- package/lib/sentry/team.js.map +1 -1
- package/lib/serde.d.ts +0 -5
- package/lib/serde.d.ts.map +1 -1
- package/lib/serde.js +0 -28
- package/lib/serde.js.map +1 -1
- package/lib/state/d1-state-store.d.ts +1 -1
- package/lib/state/d1-state-store.d.ts.map +1 -1
- package/lib/state/d1-state-store.js +5 -5
- package/lib/state/d1-state-store.js.map +1 -1
- package/lib/state/sqlite-state-store.d.ts.map +1 -1
- package/lib/state/sqlite-state-store.js +7 -11
- package/lib/state/sqlite-state-store.js.map +1 -1
- package/lib/stripe/card.d.ts.map +1 -1
- package/lib/stripe/card.js +3 -2
- package/lib/stripe/card.js.map +1 -1
- package/lib/stripe/client.d.ts +2 -2
- package/lib/stripe/client.d.ts.map +1 -1
- package/lib/stripe/client.js +4 -3
- package/lib/stripe/client.js.map +1 -1
- package/lib/stripe/coupon.d.ts.map +1 -1
- package/lib/stripe/coupon.js +4 -3
- package/lib/stripe/coupon.js.map +1 -1
- package/lib/stripe/customer.js +2 -2
- package/lib/stripe/customer.js.map +1 -1
- package/lib/stripe/entitlements-feature.d.ts.map +1 -1
- package/lib/stripe/entitlements-feature.js +3 -2
- package/lib/stripe/entitlements-feature.js.map +1 -1
- package/lib/stripe/file.d.ts.map +1 -1
- package/lib/stripe/file.js +3 -2
- package/lib/stripe/file.js.map +1 -1
- package/lib/stripe/meter.js +2 -2
- package/lib/stripe/meter.js.map +1 -1
- package/lib/stripe/portal-configuration.d.ts.map +1 -1
- package/lib/stripe/portal-configuration.js +3 -2
- package/lib/stripe/portal-configuration.js.map +1 -1
- package/lib/stripe/price.d.ts.map +1 -1
- package/lib/stripe/price.js +3 -2
- package/lib/stripe/price.js.map +1 -1
- package/lib/stripe/product-feature.d.ts.map +1 -1
- package/lib/stripe/product-feature.js +3 -2
- package/lib/stripe/product-feature.js.map +1 -1
- package/lib/stripe/product.d.ts.map +1 -1
- package/lib/stripe/product.js +3 -2
- package/lib/stripe/product.js.map +1 -1
- package/lib/stripe/promotion-code.d.ts.map +1 -1
- package/lib/stripe/promotion-code.js +3 -2
- package/lib/stripe/promotion-code.js.map +1 -1
- package/lib/stripe/shipping-rate.d.ts.map +1 -1
- package/lib/stripe/shipping-rate.js +4 -3
- package/lib/stripe/shipping-rate.js.map +1 -1
- package/lib/stripe/tax-rate.d.ts.map +1 -1
- package/lib/stripe/tax-rate.js +3 -2
- package/lib/stripe/tax-rate.js.map +1 -1
- package/lib/stripe/webhook.d.ts.map +1 -1
- package/lib/stripe/webhook.js +4 -3
- package/lib/stripe/webhook.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js +1 -0
- package/lib/test/vitest.js.map +1 -1
- package/lib/upstash/redis.d.ts +8 -2
- package/lib/upstash/redis.d.ts.map +1 -1
- package/lib/upstash/redis.js +5 -4
- package/lib/upstash/redis.js.map +1 -1
- package/lib/util/ignore-matcher.d.ts.map +1 -1
- package/lib/util/ignore-matcher.js +3 -1
- package/lib/util/ignore-matcher.js.map +1 -1
- package/lib/util/peer.d.ts +10 -0
- package/lib/util/peer.d.ts.map +1 -0
- package/lib/util/peer.js +42 -0
- package/lib/util/peer.js.map +1 -0
- package/lib/util/telemetry/constants.d.ts.map +1 -1
- package/lib/util/telemetry/constants.js +2 -2
- package/lib/util/telemetry/constants.js.map +1 -1
- package/lib/vercel/project.d.ts +7 -1
- package/lib/vercel/project.d.ts.map +1 -1
- package/lib/vercel/project.js +28 -0
- package/lib/vercel/project.js.map +1 -1
- package/package.json +88 -74
- package/src/alchemy.ts +76 -222
- package/src/apply.ts +6 -19
- package/src/aws/account-id.ts +6 -3
- package/src/aws/bucket.ts +43 -32
- package/src/aws/ec2/security-group.ts +15 -3
- package/src/aws/function.ts +65 -39
- package/src/aws/policy-attachment.ts +10 -6
- package/src/aws/policy.ts +33 -15
- package/src/aws/queue.ts +50 -29
- package/src/aws/role.ts +37 -20
- package/src/aws/ses.ts +24 -20
- package/src/aws/ssm-parameter.ts +40 -20
- package/src/aws/table.ts +35 -17
- package/src/cloudflare/account-api-token.ts +9 -7
- package/src/cloudflare/ai-gateway.ts +37 -34
- package/src/cloudflare/api-schema.ts +33 -26
- package/src/cloudflare/api-shield.ts +15 -2
- package/src/cloudflare/astro/astro.ts +5 -1
- package/src/cloudflare/astro/plugin.ts +2 -1
- package/src/cloudflare/bindings.ts +2 -2
- package/src/cloudflare/bound.ts +1 -1
- package/src/cloudflare/bucket.ts +242 -3
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/container.ts +23 -12
- package/src/cloudflare/custom-domain.ts +2 -2
- package/src/cloudflare/d1-database.ts +11 -4
- package/src/cloudflare/dispatch-namespace.ts +10 -7
- package/src/cloudflare/hyperdrive.ts +13 -3
- package/src/cloudflare/kv-namespace.ts +25 -2
- package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +3 -1
- package/src/cloudflare/miniflare/paths.ts +13 -0
- package/src/cloudflare/pipeline.ts +76 -28
- package/src/cloudflare/queue-consumer.ts +1 -1
- package/src/cloudflare/queue.ts +65 -54
- package/src/cloudflare/react-router/react-router.ts +28 -2
- package/src/cloudflare/redwood/plugin.ts +3 -2
- package/src/cloudflare/route.ts +1 -1
- package/src/cloudflare/ruleset.ts +7 -2
- package/src/cloudflare/secret.ts +20 -31
- package/src/cloudflare/secrets-store.ts +7 -3
- package/src/cloudflare/tunnel.ts +13 -2
- package/src/cloudflare/vectorize-index.ts +14 -3
- package/src/cloudflare/vite/plugin.ts +3 -2
- package/src/cloudflare/vite/vite.ts +2 -3
- package/src/cloudflare/website.ts +1 -1
- package/src/cloudflare/worker.ts +35 -23
- package/src/cloudflare/wrangler.json.ts +7 -4
- package/src/docker/container.ts +13 -1
- package/src/docker/network.ts +18 -3
- package/src/docker/volume.ts +17 -6
- package/src/fs/index.ts +0 -8
- package/src/github/client.ts +6 -2
- package/src/github/repository-environment.ts +27 -13
- package/src/neon/project.ts +20 -6
- package/src/planetscale/branch.ts +24 -13
- package/src/planetscale/database.ts +38 -17
- package/src/planetscale/password.ts +10 -3
- package/src/resource.ts +1 -10
- package/src/scope.ts +29 -38
- package/src/sentry/client-key.ts +74 -6
- package/src/sentry/project.ts +59 -6
- package/src/sentry/team.ts +55 -7
- package/src/serde.ts +0 -44
- package/src/state/d1-state-store.ts +13 -6
- package/src/state/sqlite-state-store.ts +16 -17
- package/src/stripe/card.ts +5 -2
- package/src/stripe/client.ts +10 -3
- package/src/stripe/coupon.ts +4 -3
- package/src/stripe/customer.ts +2 -2
- package/src/stripe/entitlements-feature.ts +5 -2
- package/src/stripe/file.ts +3 -2
- package/src/stripe/meter.ts +2 -2
- package/src/stripe/portal-configuration.ts +5 -2
- package/src/stripe/price.ts +3 -2
- package/src/stripe/product-feature.ts +5 -2
- package/src/stripe/product.ts +3 -2
- package/src/stripe/promotion-code.ts +3 -2
- package/src/stripe/shipping-rate.ts +4 -3
- package/src/stripe/tax-rate.ts +3 -2
- package/src/stripe/webhook.ts +4 -3
- package/src/test/vitest.ts +1 -0
- package/src/upstash/redis.ts +15 -5
- package/src/util/ignore-matcher.ts +3 -1
- package/src/util/peer.ts +53 -0
- package/src/util/telemetry/constants.ts +2 -2
- package/src/vercel/project.ts +46 -1
- package/templates/astro/_gitignore +2 -1
- package/templates/hono/README.md +19 -0
- package/templates/hono/_env +1 -0
- package/templates/hono/_env.example +1 -0
- package/templates/hono/_gitignore +34 -0
- package/templates/hono/alchemy.run.ts +22 -0
- package/templates/hono/package.json +18 -0
- package/templates/hono/src/index.ts +17 -0
- package/templates/hono/tsconfig.json +13 -0
- package/templates/hono/types/env.d.ts +16 -0
- package/templates/nuxt/_gitignore +2 -1
- package/templates/react-router/_gitignore +1 -0
- package/templates/react-router/vite.config.ts +5 -3
- package/templates/rwsdk/_gitignore +2 -3
- package/templates/sveltekit/_gitignore +2 -1
- package/templates/tanstack-start/_gitignore +2 -1
- package/templates/typescript/_gitignore +2 -1
- package/templates/vite/_gitignore +2 -1
- package/workers/cloudflare-state-store.js +69 -74
- package/workers/dofs-state-store.js +1 -1
- package/bin/bootstrap-s3.ts +0 -255
- package/lib/ai/ark.d.ts +0 -12
- package/lib/ai/ark.d.ts.map +0 -1
- package/lib/ai/ark.js +0 -87
- package/lib/ai/ark.js.map +0 -1
- package/lib/ai/astro-file.d.ts +0 -138
- package/lib/ai/astro-file.d.ts.map +0 -1
- package/lib/ai/astro-file.js +0 -158
- package/lib/ai/astro-file.js.map +0 -1
- package/lib/ai/client.d.ts +0 -51
- package/lib/ai/client.d.ts.map +0 -1
- package/lib/ai/client.js +0 -58
- package/lib/ai/client.js.map +0 -1
- package/lib/ai/css-file.d.ts +0 -132
- package/lib/ai/css-file.d.ts.map +0 -1
- package/lib/ai/css-file.js +0 -142
- package/lib/ai/css-file.js.map +0 -1
- package/lib/ai/data.d.ts +0 -152
- package/lib/ai/data.d.ts.map +0 -1
- package/lib/ai/data.js +0 -120
- package/lib/ai/data.js.map +0 -1
- package/lib/ai/document.d.ts +0 -208
- package/lib/ai/document.d.ts.map +0 -1
- package/lib/ai/document.js +0 -206
- package/lib/ai/document.js.map +0 -1
- package/lib/ai/html-file.d.ts +0 -129
- package/lib/ai/html-file.d.ts.map +0 -1
- package/lib/ai/html-file.js +0 -139
- package/lib/ai/html-file.js.map +0 -1
- package/lib/ai/index.d.ts +0 -11
- package/lib/ai/index.d.ts.map +0 -1
- package/lib/ai/index.js +0 -11
- package/lib/ai/index.js.map +0 -1
- package/lib/ai/json-file.d.ts +0 -161
- package/lib/ai/json-file.d.ts.map +0 -1
- package/lib/ai/json-file.js +0 -188
- package/lib/ai/json-file.js.map +0 -1
- package/lib/ai/typescript-file.d.ts +0 -140
- package/lib/ai/typescript-file.d.ts.map +0 -1
- package/lib/ai/typescript-file.js +0 -146
- package/lib/ai/typescript-file.js.map +0 -1
- package/lib/ai/vue-file.d.ts +0 -127
- package/lib/ai/vue-file.d.ts.map +0 -1
- package/lib/ai/vue-file.js +0 -137
- package/lib/ai/vue-file.js.map +0 -1
- package/lib/ai/yaml-file.d.ts +0 -170
- package/lib/ai/yaml-file.d.ts.map +0 -1
- package/lib/ai/yaml-file.js +0 -201
- package/lib/ai/yaml-file.js.map +0 -1
- package/lib/fs/static-astro-file.d.ts +0 -35
- package/lib/fs/static-astro-file.d.ts.map +0 -1
- package/lib/fs/static-astro-file.js +0 -40
- package/lib/fs/static-astro-file.js.map +0 -1
- package/lib/fs/static-css-file.d.ts +0 -25
- package/lib/fs/static-css-file.d.ts.map +0 -1
- package/lib/fs/static-css-file.js +0 -30
- package/lib/fs/static-css-file.js.map +0 -1
- package/lib/fs/static-html-file.d.ts +0 -32
- package/lib/fs/static-html-file.d.ts.map +0 -1
- package/lib/fs/static-html-file.js +0 -37
- package/lib/fs/static-html-file.js.map +0 -1
- package/lib/fs/static-json-file.d.ts +0 -18
- package/lib/fs/static-json-file.d.ts.map +0 -1
- package/lib/fs/static-json-file.js +0 -19
- package/lib/fs/static-json-file.js.map +0 -1
- package/lib/fs/static-text-file.d.ts +0 -13
- package/lib/fs/static-text-file.d.ts.map +0 -1
- package/lib/fs/static-text-file.js +0 -9
- package/lib/fs/static-text-file.js.map +0 -1
- package/lib/fs/static-typescript-file.d.ts +0 -20
- package/lib/fs/static-typescript-file.d.ts.map +0 -1
- package/lib/fs/static-typescript-file.js +0 -16
- package/lib/fs/static-typescript-file.js.map +0 -1
- package/lib/fs/static-vue-file.d.ts +0 -29
- package/lib/fs/static-vue-file.d.ts.map +0 -1
- package/lib/fs/static-vue-file.js +0 -34
- package/lib/fs/static-vue-file.js.map +0 -1
- package/lib/fs/static-yaml-file.d.ts +0 -23
- package/lib/fs/static-yaml-file.d.ts.map +0 -1
- package/lib/fs/static-yaml-file.js +0 -10
- package/lib/fs/static-yaml-file.js.map +0 -1
- package/lib/internal/docs/providers.d.ts +0 -34
- package/lib/internal/docs/providers.d.ts.map +0 -1
- package/lib/internal/docs/providers.js +0 -200
- package/lib/internal/docs/providers.js.map +0 -1
- package/lib/runtime/bind.d.ts +0 -25
- package/lib/runtime/bind.d.ts.map +0 -1
- package/lib/runtime/bind.js +0 -76
- package/lib/runtime/bind.js.map +0 -1
- package/lib/runtime/global.d.ts +0 -8
- package/lib/runtime/global.d.ts.map +0 -1
- package/lib/runtime/global.js +0 -3
- package/lib/runtime/global.js.map +0 -1
- package/lib/runtime/plugin.d.ts +0 -35
- package/lib/runtime/plugin.d.ts.map +0 -1
- package/lib/runtime/plugin.js +0 -134
- package/lib/runtime/plugin.js.map +0 -1
- package/lib/runtime/shims.d.ts +0 -6
- package/lib/runtime/shims.d.ts.map +0 -1
- package/lib/runtime/shims.js +0 -27
- package/lib/runtime/shims.js.map +0 -1
- package/lib/runtime/state.d.ts +0 -5
- package/lib/runtime/state.d.ts.map +0 -1
- package/lib/runtime/state.js +0 -4
- package/lib/runtime/state.js.map +0 -1
- package/lib/web/astro.d.ts +0 -148
- package/lib/web/astro.d.ts.map +0 -1
- package/lib/web/astro.js +0 -419
- package/lib/web/astro.js.map +0 -1
- package/lib/web/shadcn-component.d.ts +0 -30
- package/lib/web/shadcn-component.d.ts.map +0 -1
- package/lib/web/shadcn-component.js +0 -25
- package/lib/web/shadcn-component.js.map +0 -1
- package/lib/web/shadcn.d.ts +0 -98
- package/lib/web/shadcn.d.ts.map +0 -1
- package/lib/web/shadcn.js +0 -102
- package/lib/web/shadcn.js.map +0 -1
- package/lib/web/tailwind.d.ts +0 -65
- package/lib/web/tailwind.d.ts.map +0 -1
- package/lib/web/tailwind.js +0 -98
- package/lib/web/tailwind.js.map +0 -1
- package/lib/web/vite.d.ts +0 -96
- package/lib/web/vite.d.ts.map +0 -1
- package/lib/web/vite.js +0 -232
- package/lib/web/vite.js.map +0 -1
- package/lib/web/vitepress/config.d.ts +0 -12
- package/lib/web/vitepress/config.d.ts.map +0 -1
- package/lib/web/vitepress/config.js +0 -33
- package/lib/web/vitepress/config.js.map +0 -1
- package/lib/web/vitepress/custom-theme.d.ts +0 -174
- package/lib/web/vitepress/custom-theme.d.ts.map +0 -1
- package/lib/web/vitepress/custom-theme.js +0 -337
- package/lib/web/vitepress/custom-theme.js.map +0 -1
- package/lib/web/vitepress/dependencies.d.ts +0 -13
- package/lib/web/vitepress/dependencies.d.ts.map +0 -1
- package/lib/web/vitepress/dependencies.js +0 -37
- package/lib/web/vitepress/dependencies.js.map +0 -1
- package/lib/web/vitepress/home-page.d.ts +0 -247
- package/lib/web/vitepress/home-page.d.ts.map +0 -1
- package/lib/web/vitepress/home-page.js +0 -146
- package/lib/web/vitepress/home-page.js.map +0 -1
- package/lib/web/vitepress/index.d.ts +0 -6
- package/lib/web/vitepress/index.d.ts.map +0 -1
- package/lib/web/vitepress/index.js +0 -6
- package/lib/web/vitepress/index.js.map +0 -1
- package/lib/web/vitepress/process-front-matter-files.d.ts +0 -19
- package/lib/web/vitepress/process-front-matter-files.d.ts.map +0 -1
- package/lib/web/vitepress/process-front-matter-files.js +0 -73
- package/lib/web/vitepress/process-front-matter-files.js.map +0 -1
- package/lib/web/vitepress/vitepress.d.ts +0 -75
- package/lib/web/vitepress/vitepress.d.ts.map +0 -1
- package/lib/web/vitepress/vitepress.js +0 -254
- package/lib/web/vitepress/vitepress.js.map +0 -1
- package/src/ai/ark.ts +0 -118
- package/src/ai/astro-file.ts +0 -270
- package/src/ai/client.ts +0 -117
- package/src/ai/css-file.ts +0 -247
- package/src/ai/data.ts +0 -221
- package/src/ai/document.ts +0 -367
- package/src/ai/html-file.ts +0 -244
- package/src/ai/index.ts +0 -10
- package/src/ai/json-file.ts +0 -325
- package/src/ai/typescript-file.ts +0 -259
- package/src/ai/vue-file.ts +0 -242
- package/src/ai/yaml-file.ts +0 -328
- package/src/fs/static-astro-file.ts +0 -45
- package/src/fs/static-css-file.ts +0 -35
- package/src/fs/static-html-file.ts +0 -42
- package/src/fs/static-json-file.ts +0 -38
- package/src/fs/static-text-file.ts +0 -23
- package/src/fs/static-typescript-file.ts +0 -37
- package/src/fs/static-vue-file.ts +0 -39
- package/src/fs/static-yaml-file.ts +0 -33
- package/src/internal/docs/providers.ts +0 -286
- package/src/runtime/bind.ts +0 -95
- package/src/runtime/global.ts +0 -10
- package/src/runtime/plugin.ts +0 -163
- package/src/runtime/shims.js +0 -34
- package/src/runtime/state.ts +0 -9
- package/src/web/astro.ts +0 -643
- package/src/web/shadcn-component.ts +0 -72
- package/src/web/shadcn.ts +0 -221
- package/src/web/tailwind.ts +0 -167
- package/src/web/vite.ts +0 -407
- package/src/web/vitepress/config.ts +0 -50
- package/src/web/vitepress/custom-theme.ts +0 -514
- package/src/web/vitepress/dependencies.ts +0 -69
- package/src/web/vitepress/home-page.ts +0 -378
- package/src/web/vitepress/index.ts +0 -5
- package/src/web/vitepress/process-front-matter-files.ts +0 -107
- package/src/web/vitepress/vitepress.ts +0 -372
- package/templates/sveltekit/bun.lock +0 -1099
package/lib/ai/html-file.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { generateText } from "ai";
|
|
2
|
-
import { StaticHTMLFile } from "../fs/static-html-file.js";
|
|
3
|
-
import { Resource } from "../resource.js";
|
|
4
|
-
import { createModel } from "./client.js";
|
|
5
|
-
/**
|
|
6
|
-
* Default system prompt for HTML file generation
|
|
7
|
-
*/
|
|
8
|
-
const DEFAULT_HTML_SYSTEM_PROMPT = "You are an HTML code generator. Create HTML code based on the user's requirements. Your response MUST include only HTML code inside ```html fences. Do not include any other text, explanations, or multiple code blocks.";
|
|
9
|
-
/**
|
|
10
|
-
* Resource for generating HTML files using AI models.
|
|
11
|
-
* Extracts HTML code from between ```html fences and validates the response.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Create a simple landing page
|
|
15
|
-
* const landingPage = await HTMLFile("landing-page", {
|
|
16
|
-
* path: "./public/index.html",
|
|
17
|
-
* prompt: await alchemy`
|
|
18
|
-
* Generate a modern landing page for a SaaS product with:
|
|
19
|
-
* - Hero section with headline and call-to-action
|
|
20
|
-
* - Features section with 3 key features
|
|
21
|
-
* - Pricing section with 3 tiers
|
|
22
|
-
* - Testimonials section with 2 customer quotes
|
|
23
|
-
* - Contact form and footer
|
|
24
|
-
* `,
|
|
25
|
-
* model: {
|
|
26
|
-
* id: "gpt-4o",
|
|
27
|
-
* provider: "openai"
|
|
28
|
-
* }
|
|
29
|
-
* });
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // Generate an HTML email template
|
|
33
|
-
* const emailTemplate = await HTMLFile("welcome-email", {
|
|
34
|
-
* path: "./emails/welcome.html",
|
|
35
|
-
* prompt: await alchemy`
|
|
36
|
-
* Create an HTML email template for welcoming new users to our platform.
|
|
37
|
-
* The email should include:
|
|
38
|
-
* - Company logo and branding
|
|
39
|
-
* - Personalized welcome message (use {{name}} placeholder)
|
|
40
|
-
* - Three steps to get started
|
|
41
|
-
* - Support contact information
|
|
42
|
-
* - Unsubscribe footer
|
|
43
|
-
*
|
|
44
|
-
* Make sure it's responsive and works in all major email clients.
|
|
45
|
-
* `,
|
|
46
|
-
* temperature: 0.2
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Generate an HTML component with custom system prompt
|
|
51
|
-
* const navComponent = await HTMLFile("navigation", {
|
|
52
|
-
* path: "./components/nav.html",
|
|
53
|
-
* prompt: await alchemy`
|
|
54
|
-
* Create a responsive navigation component with:
|
|
55
|
-
* - Logo in the left corner
|
|
56
|
-
* - Navigation links: Home, Products, Services, About, Contact
|
|
57
|
-
* - Mobile hamburger menu that expands/collapses
|
|
58
|
-
* - Login/signup buttons on the right side
|
|
59
|
-
* - Dark/light mode toggle
|
|
60
|
-
* `,
|
|
61
|
-
* system: "You are an expert HTML/CSS developer specializing in responsive components. Create a single HTML file inside ```html fences with no additional text. Use modern HTML5 semantic elements and inline CSS if needed.",
|
|
62
|
-
* model: {
|
|
63
|
-
* id: "claude-3-opus-20240229",
|
|
64
|
-
* provider: "anthropic"
|
|
65
|
-
* }
|
|
66
|
-
* });
|
|
67
|
-
*/
|
|
68
|
-
export const HTMLFile = Resource("ai::HTMLFile", async function (_id, props) {
|
|
69
|
-
// Handle deletion phase
|
|
70
|
-
if (this.phase === "delete") {
|
|
71
|
-
return this.destroy();
|
|
72
|
-
}
|
|
73
|
-
// Use provided system prompt or default
|
|
74
|
-
const system = props.system || DEFAULT_HTML_SYSTEM_PROMPT;
|
|
75
|
-
// Generate initial content
|
|
76
|
-
const { text } = await generateText({
|
|
77
|
-
model: createModel(props),
|
|
78
|
-
prompt: props.prompt,
|
|
79
|
-
system,
|
|
80
|
-
providerOptions: props.model?.options,
|
|
81
|
-
...(props.temperature === undefined
|
|
82
|
-
? {}
|
|
83
|
-
: { temperature: props.temperature }),
|
|
84
|
-
});
|
|
85
|
-
// Extract and validate HTML code
|
|
86
|
-
let { code, error } = await extractHTMLCode(text);
|
|
87
|
-
// Re-prompt if there are validation errors
|
|
88
|
-
if (error) {
|
|
89
|
-
const errorSystem = `${system}\n\nERROR: ${error}\n\nPlease try again and ensure your response contains exactly one HTML code block inside \`\`\`html fences.`;
|
|
90
|
-
const { text: retryText } = await generateText({
|
|
91
|
-
model: createModel(props),
|
|
92
|
-
prompt: props.prompt,
|
|
93
|
-
system: errorSystem,
|
|
94
|
-
providerOptions: props.model?.options,
|
|
95
|
-
...(props.temperature === undefined
|
|
96
|
-
? {}
|
|
97
|
-
: { temperature: props.temperature }),
|
|
98
|
-
});
|
|
99
|
-
const retryResult = await extractHTMLCode(retryText);
|
|
100
|
-
if (retryResult.error) {
|
|
101
|
-
throw new Error(`Failed to generate valid HTML code: ${retryResult.error}`);
|
|
102
|
-
}
|
|
103
|
-
code = retryResult.code;
|
|
104
|
-
}
|
|
105
|
-
// Use StaticHTMLFile to create/update the file
|
|
106
|
-
const file = await StaticHTMLFile("file", props.path, code);
|
|
107
|
-
// Return the resource
|
|
108
|
-
return this({
|
|
109
|
-
...props,
|
|
110
|
-
content: file.content,
|
|
111
|
-
createdAt: Date.now(),
|
|
112
|
-
updatedAt: Date.now(),
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
/**
|
|
116
|
-
* Extracts HTML code from between ```html fences
|
|
117
|
-
* Validates that exactly one HTML code block exists
|
|
118
|
-
*
|
|
119
|
-
* @param text The text to extract HTML code from
|
|
120
|
-
* @returns The extracted HTML code or error message
|
|
121
|
-
*/
|
|
122
|
-
async function extractHTMLCode(text) {
|
|
123
|
-
const htmlCodeRegex = /```html\s*([\s\S]*?)```/g;
|
|
124
|
-
const matches = Array.from(text.matchAll(htmlCodeRegex));
|
|
125
|
-
if (matches.length === 0) {
|
|
126
|
-
return {
|
|
127
|
-
code: "",
|
|
128
|
-
error: "No HTML code block found in the response. Please include your code within ```html fences.",
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
if (matches.length > 1) {
|
|
132
|
-
return {
|
|
133
|
-
code: "",
|
|
134
|
-
error: "Multiple HTML code blocks found in the response. Please provide exactly one code block within ```html fences.",
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
return { code: matches[0][1].trim() };
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=html-file.js.map
|
package/lib/ai/html-file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-file.js","sourceRoot":"","sources":["../../src/ai/html-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAoB,WAAW,EAAE,MAAM,aAAa,CAAC;AA4E5D;;GAEG;AACH,MAAM,0BAA0B,GAC9B,2NAA2N,CAAC;AAE9N;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAC9B,cAAc,EACd,KAAK,WAEH,GAAW,EACX,KAAoB;IAEpB,wBAAwB;IACxB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAED,wCAAwC;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,0BAA0B,CAAC;IAE1D,2BAA2B;IAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CAAC;QAClC,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC;QACzB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM;QACN,eAAe,EAAE,KAAK,CAAC,KAAK,EAAE,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;QACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF;;;;;;GAMG;AACH,KAAK,UAAU,eAAe,CAC5B,IAAY;IAEZ,MAAM,aAAa,GAAG,0BAA0B,CAAC;IACjD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;IAEzD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,IAAI,EAAE,EAAE;YACR,KAAK,EACH,2FAA2F;SAC9F,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,IAAI,EAAE,EAAE;YACR,KAAK,EACH,+GAA+G;SAClH,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AACxC,CAAC"}
|
package/lib/ai/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./ark.ts";
|
|
2
|
-
export * from "./astro-file.ts";
|
|
3
|
-
export * from "./css-file.ts";
|
|
4
|
-
export * from "./data.ts";
|
|
5
|
-
export * from "./document.ts";
|
|
6
|
-
export * from "./html-file.ts";
|
|
7
|
-
export * from "./json-file.ts";
|
|
8
|
-
export * from "./typescript-file.ts";
|
|
9
|
-
export * from "./vue-file.ts";
|
|
10
|
-
export * from "./yaml-file.ts";
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/ai/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
package/lib/ai/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./ark.js";
|
|
2
|
-
export * from "./astro-file.js";
|
|
3
|
-
export * from "./css-file.js";
|
|
4
|
-
export * from "./data.js";
|
|
5
|
-
export * from "./document.js";
|
|
6
|
-
export * from "./html-file.js";
|
|
7
|
-
export * from "./json-file.js";
|
|
8
|
-
export * from "./typescript-file.js";
|
|
9
|
-
export * from "./vue-file.js";
|
|
10
|
-
export * from "./yaml-file.js";
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/lib/ai/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
package/lib/ai/json-file.d.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import type { JsonSchema, Type, type } from "arktype";
|
|
2
|
-
import type { Context } from "../context.ts";
|
|
3
|
-
import { Resource } from "../resource.ts";
|
|
4
|
-
import type { Secret } from "../secret.ts";
|
|
5
|
-
import { type ModelConfig } from "./client.ts";
|
|
6
|
-
/**
|
|
7
|
-
* Properties for creating or updating a JSONFile
|
|
8
|
-
*/
|
|
9
|
-
export interface JSONFileProps<T extends Type<any, any> | undefined = undefined> {
|
|
10
|
-
/**
|
|
11
|
-
* Path to the JSON file
|
|
12
|
-
*/
|
|
13
|
-
path: string;
|
|
14
|
-
/**
|
|
15
|
-
* Optional ArkType schema to validate and structure the generated JSON
|
|
16
|
-
* When provided, the resource will use generateObject with schema validation
|
|
17
|
-
* When not provided, it will extract JSON from between ```json fences
|
|
18
|
-
*/
|
|
19
|
-
schema?: T;
|
|
20
|
-
/**
|
|
21
|
-
* Base URL for the OpenAI API
|
|
22
|
-
* @default 'https://api.openai.com/v1'
|
|
23
|
-
*/
|
|
24
|
-
baseURL?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Prompt for generating content
|
|
27
|
-
* Use alchemy template literals to include file context:
|
|
28
|
-
* @example
|
|
29
|
-
* prompt: await alchemy`
|
|
30
|
-
* Generate a JSON configuration for:
|
|
31
|
-
* ${alchemy.file("src/config.ts")}
|
|
32
|
-
* `
|
|
33
|
-
*/
|
|
34
|
-
prompt: string;
|
|
35
|
-
/**
|
|
36
|
-
* System prompt for the model
|
|
37
|
-
* This is used to provide instructions to the model about how to format the response
|
|
38
|
-
* @default Depends on whether schema is provided
|
|
39
|
-
*/
|
|
40
|
-
system?: string;
|
|
41
|
-
/**
|
|
42
|
-
* OpenAI API key to use for generating content
|
|
43
|
-
* If not provided, will use OPENAI_API_KEY environment variable
|
|
44
|
-
*/
|
|
45
|
-
apiKey?: Secret;
|
|
46
|
-
/**
|
|
47
|
-
* Model configuration
|
|
48
|
-
*/
|
|
49
|
-
model?: ModelConfig;
|
|
50
|
-
/**
|
|
51
|
-
* Temperature for controlling randomness in generation.
|
|
52
|
-
* Higher values (e.g., 0.8) make output more random,
|
|
53
|
-
* lower values (e.g., 0.2) make it more deterministic.
|
|
54
|
-
* @default 0.7
|
|
55
|
-
*/
|
|
56
|
-
temperature?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Whether to pretty-print the JSON with indentation
|
|
59
|
-
* @default true
|
|
60
|
-
*/
|
|
61
|
-
pretty?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Number of spaces to use for indentation when pretty-printing
|
|
64
|
-
* @default 2
|
|
65
|
-
*/
|
|
66
|
-
indent?: number;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* A JSON file that can be created, updated, and deleted
|
|
70
|
-
*/
|
|
71
|
-
export interface JSONFile<T = any> extends Omit<JSONFileProps, "schema">, Resource<"ai::JSONFile"> {
|
|
72
|
-
/**
|
|
73
|
-
* Content of the JSON file as a string
|
|
74
|
-
*/
|
|
75
|
-
content: string;
|
|
76
|
-
/**
|
|
77
|
-
* Parsed JSON object
|
|
78
|
-
*/
|
|
79
|
-
json: T;
|
|
80
|
-
/**
|
|
81
|
-
* Schema used to validate the JSON (if provided)
|
|
82
|
-
*/
|
|
83
|
-
schema?: JsonSchema;
|
|
84
|
-
/**
|
|
85
|
-
* Time at which the file was created
|
|
86
|
-
*/
|
|
87
|
-
createdAt: number;
|
|
88
|
-
/**
|
|
89
|
-
* Time at which the file was last updated
|
|
90
|
-
*/
|
|
91
|
-
updatedAt: number;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Resource for generating JSON files using AI models.
|
|
95
|
-
* Can operate in two modes:
|
|
96
|
-
* 1. With schema: Uses generateObject with type validation
|
|
97
|
-
* 2. Without schema: Extracts JSON from between ```json fences
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* // Generate a configuration file with freeform JSON
|
|
101
|
-
* const config = await JSONFile("app-config", {
|
|
102
|
-
* path: "./config/app.json",
|
|
103
|
-
* prompt: await alchemy`
|
|
104
|
-
* Generate a configuration for a web application with:
|
|
105
|
-
* - Server settings (port, host, timeout)
|
|
106
|
-
* - Database connection details (redact any passwords)
|
|
107
|
-
* - Logging configuration
|
|
108
|
-
* - Feature flags
|
|
109
|
-
* `,
|
|
110
|
-
* model: {
|
|
111
|
-
* id: "gpt-4o",
|
|
112
|
-
* provider: "openai"
|
|
113
|
-
* }
|
|
114
|
-
* });
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* // Generate JSON with schema validation
|
|
118
|
-
* import { type } from "arktype";
|
|
119
|
-
*
|
|
120
|
-
* const userSchema = type({
|
|
121
|
-
* users: [{
|
|
122
|
-
* id: "string",
|
|
123
|
-
* name: "string",
|
|
124
|
-
* email: "string",
|
|
125
|
-
* role: "'admin' | 'user' | 'guest'",
|
|
126
|
-
* permissions: "string[]",
|
|
127
|
-
* active: "boolean"
|
|
128
|
-
* }]
|
|
129
|
-
* });
|
|
130
|
-
*
|
|
131
|
-
* const userData = await JSONFile("user-data", {
|
|
132
|
-
* path: "./data/users.json",
|
|
133
|
-
* schema: userSchema,
|
|
134
|
-
* prompt: "Generate sample user data for an application with various roles and permissions",
|
|
135
|
-
* temperature: 0.2
|
|
136
|
-
* });
|
|
137
|
-
*
|
|
138
|
-
* // Type-safe access to the generated data
|
|
139
|
-
* console.log(userData.json.users[0].role); // Typed as 'admin' | 'user' | 'guest'
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* // Generate API mock data with custom system prompt
|
|
143
|
-
* const apiMock = await JSONFile("api-mock", {
|
|
144
|
-
* path: "./mocks/products-api.json",
|
|
145
|
-
* prompt: await alchemy`
|
|
146
|
-
* Create mock data for a product catalog API response with:
|
|
147
|
-
* - 10 products with different categories
|
|
148
|
-
* - Each product should have id, name, price, category, inventory, and image_url
|
|
149
|
-
* - Include pagination metadata (total, page, limit)
|
|
150
|
-
* `,
|
|
151
|
-
* system: "You are an API design expert. Create realistic mock JSON data that follows REST API best practices. Your response must be valid JSON inside ```json fences.",
|
|
152
|
-
* model: {
|
|
153
|
-
* id: "claude-3-opus-20240229",
|
|
154
|
-
* provider: "anthropic"
|
|
155
|
-
* },
|
|
156
|
-
* pretty: true,
|
|
157
|
-
* indent: 4
|
|
158
|
-
* });
|
|
159
|
-
*/
|
|
160
|
-
export declare const JSONFile: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | (<const T extends Type<any, any> | undefined = undefined>(this: Context<JSONFile<T extends Type<any, any> ? type.infer<T> : any>>, _id: string, props: JSONFileProps<T>) => Promise<JSONFile<T extends Type<any, any> ? type.infer<T> : any>>);
|
|
161
|
-
//# sourceMappingURL=json-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-file.d.ts","sourceRoot":"","sources":["../../src/ai/json-file.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,aAAa,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,aAAa,CAC5B,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,GAAG,SAAS;IAEhD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC;IAEX;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;;;;;OAQG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,GAAG,CAC/B,SAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,EACnC,QAAQ,CAAC,cAAc,CAAC;IAC1B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;IAEpB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,eAAO,MAAM,QAAQ,yFACb,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,oBACpC,OAAO,CAAC,QAAQ,CAAC,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,MAAM,SAAS,aAAa,CAAC,CAAC,CAAC,KAAG,OAAO,CACvH,QAAQ,CAAC,CAAC,SAAS,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CACzD,CAyFC,CAAC"}
|
package/lib/ai/json-file.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { generateObject, generateText } from "ai";
|
|
2
|
-
import { StaticJsonFile } from "../fs/static-json-file.js";
|
|
3
|
-
import { Resource } from "../resource.js";
|
|
4
|
-
import { ark } from "./ark.js";
|
|
5
|
-
import { createModel } from "./client.js";
|
|
6
|
-
/**
|
|
7
|
-
* Default system prompt for JSON file generation without schema
|
|
8
|
-
*/
|
|
9
|
-
const DEFAULT_JSON_SYSTEM_PROMPT = "You are a JSON generator. Create valid JSON based on the user's requirements. Your response MUST include only JSON inside ```json fences. Do not include any other text, explanations, or multiple code blocks.";
|
|
10
|
-
/**
|
|
11
|
-
* Resource for generating JSON files using AI models.
|
|
12
|
-
* Can operate in two modes:
|
|
13
|
-
* 1. With schema: Uses generateObject with type validation
|
|
14
|
-
* 2. Without schema: Extracts JSON from between ```json fences
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* // Generate a configuration file with freeform JSON
|
|
18
|
-
* const config = await JSONFile("app-config", {
|
|
19
|
-
* path: "./config/app.json",
|
|
20
|
-
* prompt: await alchemy`
|
|
21
|
-
* Generate a configuration for a web application with:
|
|
22
|
-
* - Server settings (port, host, timeout)
|
|
23
|
-
* - Database connection details (redact any passwords)
|
|
24
|
-
* - Logging configuration
|
|
25
|
-
* - Feature flags
|
|
26
|
-
* `,
|
|
27
|
-
* model: {
|
|
28
|
-
* id: "gpt-4o",
|
|
29
|
-
* provider: "openai"
|
|
30
|
-
* }
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* // Generate JSON with schema validation
|
|
35
|
-
* import { type } from "arktype";
|
|
36
|
-
*
|
|
37
|
-
* const userSchema = type({
|
|
38
|
-
* users: [{
|
|
39
|
-
* id: "string",
|
|
40
|
-
* name: "string",
|
|
41
|
-
* email: "string",
|
|
42
|
-
* role: "'admin' | 'user' | 'guest'",
|
|
43
|
-
* permissions: "string[]",
|
|
44
|
-
* active: "boolean"
|
|
45
|
-
* }]
|
|
46
|
-
* });
|
|
47
|
-
*
|
|
48
|
-
* const userData = await JSONFile("user-data", {
|
|
49
|
-
* path: "./data/users.json",
|
|
50
|
-
* schema: userSchema,
|
|
51
|
-
* prompt: "Generate sample user data for an application with various roles and permissions",
|
|
52
|
-
* temperature: 0.2
|
|
53
|
-
* });
|
|
54
|
-
*
|
|
55
|
-
* // Type-safe access to the generated data
|
|
56
|
-
* console.log(userData.json.users[0].role); // Typed as 'admin' | 'user' | 'guest'
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* // Generate API mock data with custom system prompt
|
|
60
|
-
* const apiMock = await JSONFile("api-mock", {
|
|
61
|
-
* path: "./mocks/products-api.json",
|
|
62
|
-
* prompt: await alchemy`
|
|
63
|
-
* Create mock data for a product catalog API response with:
|
|
64
|
-
* - 10 products with different categories
|
|
65
|
-
* - Each product should have id, name, price, category, inventory, and image_url
|
|
66
|
-
* - Include pagination metadata (total, page, limit)
|
|
67
|
-
* `,
|
|
68
|
-
* system: "You are an API design expert. Create realistic mock JSON data that follows REST API best practices. Your response must be valid JSON inside ```json fences.",
|
|
69
|
-
* model: {
|
|
70
|
-
* id: "claude-3-opus-20240229",
|
|
71
|
-
* provider: "anthropic"
|
|
72
|
-
* },
|
|
73
|
-
* pretty: true,
|
|
74
|
-
* indent: 4
|
|
75
|
-
* });
|
|
76
|
-
*/
|
|
77
|
-
export const JSONFile = Resource("ai::JSONFile", async function (_id, props) {
|
|
78
|
-
// Handle deletion phase
|
|
79
|
-
if (this.phase === "delete") {
|
|
80
|
-
return this.destroy();
|
|
81
|
-
}
|
|
82
|
-
let jsonContent;
|
|
83
|
-
let jsonObject;
|
|
84
|
-
// Check if schema is provided
|
|
85
|
-
if (props.schema) {
|
|
86
|
-
// Use schema-based generation
|
|
87
|
-
const { object } = await generateObject({
|
|
88
|
-
model: createModel(props),
|
|
89
|
-
schema: ark.schema(props.schema),
|
|
90
|
-
providerOptions: props.model?.options,
|
|
91
|
-
system: props.system ||
|
|
92
|
-
"Generate a valid JSON object based on the provided requirements.",
|
|
93
|
-
prompt: props.prompt,
|
|
94
|
-
...(props.temperature === undefined
|
|
95
|
-
? {}
|
|
96
|
-
: { temperature: props.temperature }),
|
|
97
|
-
});
|
|
98
|
-
jsonObject = object;
|
|
99
|
-
// Use StaticJsonFile to create the file
|
|
100
|
-
const file = await StaticJsonFile("file", props.path, jsonObject);
|
|
101
|
-
jsonContent = file.content;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
// Use fence-based extraction
|
|
105
|
-
// Use provided system prompt or default
|
|
106
|
-
const system = props.system || DEFAULT_JSON_SYSTEM_PROMPT;
|
|
107
|
-
// Generate initial content
|
|
108
|
-
const { text } = await generateText({
|
|
109
|
-
model: createModel(props),
|
|
110
|
-
prompt: props.prompt,
|
|
111
|
-
system,
|
|
112
|
-
providerOptions: props.model?.options,
|
|
113
|
-
...(props.temperature === undefined
|
|
114
|
-
? {}
|
|
115
|
-
: { temperature: props.temperature }),
|
|
116
|
-
});
|
|
117
|
-
// Extract and validate JSON content
|
|
118
|
-
let { content, error } = await extractJSONContent(text);
|
|
119
|
-
// Re-prompt if there are validation errors
|
|
120
|
-
if (error) {
|
|
121
|
-
const errorSystem = `${system}\n\nERROR: ${error}\n\nPlease try again and ensure your response contains exactly one valid JSON block inside \`\`\`json fences.`;
|
|
122
|
-
const { text: retryText } = await generateText({
|
|
123
|
-
model: createModel(props),
|
|
124
|
-
prompt: props.prompt,
|
|
125
|
-
system: errorSystem,
|
|
126
|
-
providerOptions: props.model?.options,
|
|
127
|
-
...(props.temperature === undefined
|
|
128
|
-
? {}
|
|
129
|
-
: { temperature: props.temperature }),
|
|
130
|
-
});
|
|
131
|
-
const retryResult = await extractJSONContent(retryText);
|
|
132
|
-
if (retryResult.error) {
|
|
133
|
-
throw new Error(`Failed to generate valid JSON: ${retryResult.error}`);
|
|
134
|
-
}
|
|
135
|
-
content = retryResult.content;
|
|
136
|
-
}
|
|
137
|
-
// Parse JSON to get the object representation
|
|
138
|
-
jsonObject = JSON.parse(content);
|
|
139
|
-
// Use StaticJsonFile to create the file
|
|
140
|
-
const file = await StaticJsonFile("file", props.path, jsonObject);
|
|
141
|
-
jsonContent = file.content;
|
|
142
|
-
}
|
|
143
|
-
// Return the resource
|
|
144
|
-
return this({
|
|
145
|
-
...props,
|
|
146
|
-
schema: props.schema,
|
|
147
|
-
content: jsonContent,
|
|
148
|
-
json: jsonObject,
|
|
149
|
-
createdAt: Date.now(),
|
|
150
|
-
updatedAt: Date.now(),
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
/**
|
|
154
|
-
* Extracts JSON content from between ```json fences
|
|
155
|
-
* Validates that exactly one JSON code block exists
|
|
156
|
-
*
|
|
157
|
-
* @param text The text to extract JSON from
|
|
158
|
-
* @returns The extracted JSON or error message
|
|
159
|
-
*/
|
|
160
|
-
async function extractJSONContent(text) {
|
|
161
|
-
const jsonCodeRegex = /```json\s*([\s\S]*?)```/g;
|
|
162
|
-
const matches = Array.from(text.matchAll(jsonCodeRegex));
|
|
163
|
-
if (matches.length === 0) {
|
|
164
|
-
return {
|
|
165
|
-
content: "",
|
|
166
|
-
error: "No JSON code block found in the response. Please include your JSON within ```json fences.",
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
if (matches.length > 1) {
|
|
170
|
-
return {
|
|
171
|
-
content: "",
|
|
172
|
-
error: "Multiple JSON code blocks found in the response. Please provide exactly one JSON block within ```json fences.",
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
const content = matches[0][1].trim();
|
|
176
|
-
// Validate JSON can be parsed
|
|
177
|
-
try {
|
|
178
|
-
JSON.parse(content);
|
|
179
|
-
return { content };
|
|
180
|
-
}
|
|
181
|
-
catch (e) {
|
|
182
|
-
return {
|
|
183
|
-
content: "",
|
|
184
|
-
error: `Invalid JSON: ${e.message}. Please provide valid JSON syntax.`,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=json-file.js.map
|
package/lib/ai/json-file.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-file.js","sourceRoot":"","sources":["../../src/ai/json-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,U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IACrB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO;YACL,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,iBAAkB,CAAW,CAAC,OAAO,qCAAqC;SAClF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import type { Context } from "../context.ts";
|
|
2
|
-
import { Resource } from "../resource.ts";
|
|
3
|
-
import type { Secret } from "../secret.ts";
|
|
4
|
-
import { type ModelConfig } from "./client.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Properties for creating or updating a TypeScriptFile
|
|
7
|
-
*/
|
|
8
|
-
export interface TypeScriptFileProps {
|
|
9
|
-
/**
|
|
10
|
-
* Path to the TypeScript file
|
|
11
|
-
*/
|
|
12
|
-
path: string;
|
|
13
|
-
/**
|
|
14
|
-
* Base URL for the OpenAI API
|
|
15
|
-
* @default 'https://api.openai.com/v1'
|
|
16
|
-
*/
|
|
17
|
-
baseURL?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Prompt for generating content
|
|
20
|
-
* Use alchemy template literals to include file context:
|
|
21
|
-
* @example
|
|
22
|
-
* prompt: await alchemy`
|
|
23
|
-
* Generate a TypeScript utility function using:
|
|
24
|
-
* ${alchemy.file("src/types.ts")}
|
|
25
|
-
* `
|
|
26
|
-
*/
|
|
27
|
-
prompt: string;
|
|
28
|
-
/**
|
|
29
|
-
* System prompt for the model
|
|
30
|
-
* This is used to provide instructions to the model about how to format the response
|
|
31
|
-
* The default system prompt instructs the model to return TypeScript code inside ```ts fences
|
|
32
|
-
* @default "You are a TypeScript code generator. Create TypeScript code based on the user's requirements. Your response MUST include only TypeScript code inside ```ts fences. Do not include any other text, explanations, or multiple code blocks."
|
|
33
|
-
*/
|
|
34
|
-
system?: string;
|
|
35
|
-
/**
|
|
36
|
-
* OpenAI API key to use for generating content
|
|
37
|
-
* If not provided, will use OPENAI_API_KEY environment variable
|
|
38
|
-
*/
|
|
39
|
-
apiKey?: Secret;
|
|
40
|
-
/**
|
|
41
|
-
* Model configuration
|
|
42
|
-
*/
|
|
43
|
-
model?: ModelConfig;
|
|
44
|
-
/**
|
|
45
|
-
* Temperature for controlling randomness in generation.
|
|
46
|
-
* Higher values (e.g., 0.8) make output more random,
|
|
47
|
-
* lower values (e.g., 0.2) make it more deterministic.
|
|
48
|
-
* @default 0.7
|
|
49
|
-
*/
|
|
50
|
-
temperature?: number;
|
|
51
|
-
/**
|
|
52
|
-
* Prettier configuration to use for formatting the TypeScript code
|
|
53
|
-
* If not provided, will use the default Prettier configuration
|
|
54
|
-
*/
|
|
55
|
-
prettierConfig?: object;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* A TypeScript file that can be created, updated, and deleted
|
|
59
|
-
*/
|
|
60
|
-
export interface TypeScriptFile extends TypeScriptFileProps, Resource<"ai::TypeScriptFile"> {
|
|
61
|
-
/**
|
|
62
|
-
* Content of the TypeScript file
|
|
63
|
-
*/
|
|
64
|
-
content: string;
|
|
65
|
-
/**
|
|
66
|
-
* Time at which the file was created
|
|
67
|
-
*/
|
|
68
|
-
createdAt: number;
|
|
69
|
-
/**
|
|
70
|
-
* Time at which the file was last updated
|
|
71
|
-
*/
|
|
72
|
-
updatedAt: number;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Resource for generating TypeScript files using AI models.
|
|
76
|
-
* Extracts TypeScript code from between ```ts fences, validates the response,
|
|
77
|
-
* and formats the code with Prettier.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* // Create a utility function
|
|
81
|
-
* const utils = await TypeScriptFile("string-utils", {
|
|
82
|
-
* path: "./src/utils/string-utils.ts",
|
|
83
|
-
* prompt: await alchemy`
|
|
84
|
-
* Generate TypeScript utility functions for string manipulation:
|
|
85
|
-
* - Capitalize first letter
|
|
86
|
-
* - Truncate with ellipsis
|
|
87
|
-
* - Convert to camelCase and kebab-case
|
|
88
|
-
* - Remove special characters
|
|
89
|
-
* `,
|
|
90
|
-
* model: {
|
|
91
|
-
* id: "gpt-4o",
|
|
92
|
-
* provider: "openai"
|
|
93
|
-
* }
|
|
94
|
-
* });
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* // Generate a TypeScript class with custom formatting
|
|
98
|
-
* const userService = await TypeScriptFile("user-service", {
|
|
99
|
-
* path: "./src/services/UserService.ts",
|
|
100
|
-
* prompt: await alchemy`
|
|
101
|
-
* Create a UserService class that handles user authentication and profile management.
|
|
102
|
-
* The service should use the User type from:
|
|
103
|
-
* ${alchemy.file("src/types/User.ts")}
|
|
104
|
-
*
|
|
105
|
-
* Include methods for:
|
|
106
|
-
* - login(email, password)
|
|
107
|
-
* - register(user)
|
|
108
|
-
* - updateProfile(userId, profileData)
|
|
109
|
-
* - deleteAccount(userId)
|
|
110
|
-
* `,
|
|
111
|
-
* temperature: 0.2,
|
|
112
|
-
* prettierConfig: {
|
|
113
|
-
* semi: false,
|
|
114
|
-
* singleQuote: true,
|
|
115
|
-
* printWidth: 120
|
|
116
|
-
* }
|
|
117
|
-
* });
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* // Generate a React hook with custom system prompt
|
|
121
|
-
* const useFormHook = await TypeScriptFile("use-form", {
|
|
122
|
-
* path: "./src/hooks/useForm.ts",
|
|
123
|
-
* prompt: await alchemy`
|
|
124
|
-
* Create a custom React hook called useForm that handles form state, validation, and submission.
|
|
125
|
-
* It should support:
|
|
126
|
-
* - Initial values
|
|
127
|
-
* - Validation rules
|
|
128
|
-
* - Field errors
|
|
129
|
-
* - Form submission with loading state
|
|
130
|
-
* - Reset functionality
|
|
131
|
-
* `,
|
|
132
|
-
* system: "You are an expert React developer specializing in TypeScript hooks. Create a single TypeScript file inside ```ts fences with no additional text. Follow React best practices and include proper typing.",
|
|
133
|
-
* model: {
|
|
134
|
-
* id: "claude-3-opus-20240229",
|
|
135
|
-
* provider: "anthropic"
|
|
136
|
-
* }
|
|
137
|
-
* });
|
|
138
|
-
*/
|
|
139
|
-
export declare const TypeScriptFile: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<TypeScriptFile>, _id: string, props: TypeScriptFileProps) => Promise<TypeScriptFile>);
|
|
140
|
-
//# sourceMappingURL=typescript-file.d.ts.map
|