alchemy 0.2.3 → 0.2.4
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/lib/ai/ark.d.ts +11 -0
- package/lib/ai/ark.js +86 -0
- package/lib/ai/client.d.ts +51 -0
- package/lib/ai/client.js +29 -0
- package/lib/ai/document.d.ts +97 -0
- package/lib/ai/document.js +82 -0
- package/lib/{docs → ai}/index.d.ts +1 -0
- package/lib/{docs → ai}/index.js +1 -0
- package/lib/ai/object.d.ts +101 -0
- package/lib/ai/object.js +70 -0
- package/lib/alchemy.d.ts +83 -2
- package/lib/alchemy.js +31 -3
- package/lib/aws/bucket.d.ts +87 -1
- package/lib/aws/bucket.js +48 -1
- package/lib/aws/function.d.ts +186 -1
- package/lib/aws/function.js +62 -8
- package/lib/aws/oidc/github-oidc-provider.d.ts +81 -0
- package/lib/aws/oidc/github-oidc-provider.js +68 -0
- package/lib/aws/oidc/oidc-provider.d.ts +14 -6
- package/lib/aws/oidc/oidc-provider.js +26 -5
- package/lib/aws/policy-attachment.d.ts +44 -1
- package/lib/aws/policy-attachment.js +31 -0
- package/lib/aws/policy.d.ts +160 -1
- package/lib/aws/policy.js +78 -0
- package/lib/aws/queue.d.ts +83 -1
- package/lib/aws/queue.js +39 -0
- package/lib/aws/role.d.ts +162 -1
- package/lib/aws/role.js +114 -0
- package/lib/aws/ses.d.ts +57 -2
- package/lib/aws/ses.js +42 -1
- package/lib/aws/table.d.ts +96 -1
- package/lib/aws/table.js +36 -0
- package/lib/cloudflare/asset-manifest.js +0 -1
- package/lib/cloudflare/bound.js +0 -1
- package/lib/cloudflare/bucket.d.ts +37 -1
- package/lib/cloudflare/bucket.js +36 -0
- package/lib/cloudflare/durable-object-namespace.d.ts +25 -0
- package/lib/cloudflare/durable-object-namespace.js +22 -0
- package/lib/cloudflare/kv-namespace.d.ts +37 -1
- package/lib/cloudflare/kv-namespace.js +36 -0
- package/lib/cloudflare/static-site.d.ts +53 -1
- package/lib/cloudflare/static-site.js +53 -1
- package/lib/cloudflare/worker-metadata.js +0 -1
- package/lib/cloudflare/worker.d.ts +64 -1
- package/lib/cloudflare/worker.js +63 -0
- package/lib/cloudflare/wrangler.json.d.ts +1 -1
- package/lib/cloudflare/zone-settings.js +0 -1
- package/lib/cloudflare/zone.d.ts +56 -1
- package/lib/cloudflare/zone.js +55 -0
- package/lib/destroy.js +1 -1
- package/lib/esbuild/bundle.d.ts +43 -4
- package/lib/esbuild/bundle.js +16 -0
- package/lib/fs/file-collection.d.ts +16 -0
- package/lib/fs/file-collection.js +6 -0
- package/lib/fs/file-ref.d.ts +14 -0
- package/lib/fs/file-ref.js +6 -0
- package/lib/fs/file.d.ts +71 -25
- package/lib/fs/file.js +20 -44
- package/lib/fs/folder.d.ts +37 -5
- package/lib/fs/folder.js +26 -2
- package/lib/fs/index.d.ts +6 -0
- package/lib/fs/index.js +6 -0
- package/lib/fs/json-file.d.ts +16 -0
- package/lib/fs/json-file.js +7 -0
- package/lib/fs/text-file.d.ts +12 -0
- package/lib/fs/text-file.js +7 -0
- package/lib/fs/typescript-file.d.ts +19 -0
- package/lib/fs/typescript-file.js +14 -0
- package/lib/fs/yaml-file.d.ts +19 -0
- package/lib/fs/yaml-file.js +8 -0
- package/lib/github/secret.d.ts +63 -2
- package/lib/github/secret.js +61 -1
- package/lib/internal/docs.d.ts +5 -0
- package/lib/internal/docs.js +324 -0
- package/lib/resource.d.ts +1 -1
- package/lib/secret.d.ts +67 -0
- package/lib/secret.js +67 -0
- package/lib/shadcn/component.d.ts +1 -1
- package/lib/stripe/price.d.ts +51 -1
- package/lib/stripe/price.js +50 -0
- package/lib/stripe/product.d.ts +39 -1
- package/lib/stripe/product.js +38 -0
- package/lib/stripe/webhook.d.ts +46 -1
- package/lib/stripe/webhook.js +45 -0
- package/lib/test/bun.d.ts +64 -0
- package/lib/test/bun.js +35 -3
- package/lib/util/serde.js +14 -0
- package/lib/vite/vite.d.ts +1 -1
- package/lib/vitepress/dependencies.d.ts +2 -6
- package/lib/vitepress/vitepress.d.ts +12 -1
- package/lib/vitepress/vitepress.js +29 -23
- package/package.json +8 -3
- package/src/ai/ark.ts +118 -0
- package/src/ai/client.ts +78 -0
- package/src/ai/document.ts +160 -0
- package/src/{docs → ai}/index.ts +1 -0
- package/src/ai/object.ts +149 -0
- package/src/alchemy.ts +88 -5
- package/src/aws/bucket.ts +111 -7
- package/src/aws/function.ts +231 -10
- package/src/aws/oidc/github-oidc-provider.ts +83 -0
- package/src/aws/oidc/oidc-provider.ts +39 -7
- package/src/aws/policy-attachment.ts +44 -1
- package/src/aws/policy.ts +177 -2
- package/src/aws/queue.ts +89 -0
- package/src/aws/role.ts +174 -2
- package/src/aws/ses.ts +56 -1
- package/src/aws/table.ts +103 -0
- package/src/cloudflare/bucket.ts +36 -0
- package/src/cloudflare/durable-object-namespace.ts +25 -0
- package/src/cloudflare/kv-namespace.ts +36 -0
- package/src/cloudflare/static-site.ts +53 -1
- package/src/cloudflare/worker.ts +63 -0
- package/src/cloudflare/zone.ts +55 -0
- package/src/destroy.ts +1 -1
- package/src/esbuild/bundle.ts +53 -3
- package/src/fs/file-collection.ts +24 -0
- package/src/fs/file-ref.ts +22 -0
- package/src/fs/file.ts +70 -77
- package/src/fs/folder.ts +44 -5
- package/src/fs/index.ts +6 -0
- package/src/fs/json-file.ts +23 -0
- package/src/fs/text-file.ts +19 -0
- package/src/fs/typescript-file.ts +36 -0
- package/src/fs/yaml-file.ts +26 -0
- package/src/github/secret.ts +65 -2
- package/src/internal/docs.ts +369 -0
- package/src/resource.ts +1 -1
- package/src/secret.ts +67 -0
- package/src/stripe/price.ts +50 -0
- package/src/stripe/product.ts +38 -0
- package/src/stripe/webhook.ts +45 -0
- package/src/test/bun.ts +83 -3
- package/src/util/serde.ts +17 -0
- package/src/vitepress/vitepress.ts +47 -26
- package/lib/docs/document.d.ts +0 -123
- package/lib/docs/document.js +0 -67
- package/src/docs/document.ts +0 -225
package/src/aws/table.ts
CHANGED
|
@@ -13,28 +13,131 @@ import { Resource } from "../resource";
|
|
|
13
13
|
import { ignore } from "../util/ignore";
|
|
14
14
|
import { withExponentialBackoff } from "../util/retry";
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Properties for creating or updating a DynamoDB table
|
|
18
|
+
*/
|
|
16
19
|
export interface TableProps {
|
|
20
|
+
/**
|
|
21
|
+
* Name of the DynamoDB table
|
|
22
|
+
*/
|
|
17
23
|
tableName: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Primary partition key (hash key) configuration
|
|
27
|
+
* Defines the main identifier for items in the table
|
|
28
|
+
*/
|
|
18
29
|
partitionKey: {
|
|
30
|
+
/**
|
|
31
|
+
* Name of the partition key attribute
|
|
32
|
+
*/
|
|
19
33
|
name: string;
|
|
34
|
+
/**
|
|
35
|
+
* Data type of the partition key
|
|
36
|
+
* S: String, N: Number, B: Binary
|
|
37
|
+
*/
|
|
20
38
|
type: "S" | "N" | "B";
|
|
21
39
|
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Optional sort key (range key) configuration
|
|
43
|
+
* Used to sort items with the same partition key
|
|
44
|
+
*/
|
|
22
45
|
sortKey?: {
|
|
46
|
+
/**
|
|
47
|
+
* Name of the sort key attribute
|
|
48
|
+
*/
|
|
23
49
|
name: string;
|
|
50
|
+
/**
|
|
51
|
+
* Data type of the sort key
|
|
52
|
+
* S: String, N: Number, B: Binary
|
|
53
|
+
*/
|
|
24
54
|
type: "S" | "N" | "B";
|
|
25
55
|
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Billing mode for the table
|
|
59
|
+
* PROVISIONED: Set read/write capacity units
|
|
60
|
+
* PAY_PER_REQUEST: Pay per request pricing
|
|
61
|
+
*/
|
|
26
62
|
billingMode?: "PROVISIONED" | "PAY_PER_REQUEST";
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Read capacity units when using PROVISIONED billing mode
|
|
66
|
+
* Default: 5
|
|
67
|
+
*/
|
|
27
68
|
readCapacity?: number;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Write capacity units when using PROVISIONED billing mode
|
|
72
|
+
* Default: 5
|
|
73
|
+
*/
|
|
28
74
|
writeCapacity?: number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Tags to apply to the table
|
|
78
|
+
* Key-value pairs for resource organization
|
|
79
|
+
*/
|
|
29
80
|
tags?: Record<string, string>;
|
|
30
81
|
}
|
|
31
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Output returned after DynamoDB table creation/update
|
|
85
|
+
*/
|
|
32
86
|
export interface Table extends Resource<"dynamo::Table">, TableProps {
|
|
87
|
+
/**
|
|
88
|
+
* ARN of the table
|
|
89
|
+
* Format: arn:aws:dynamodb:region:account-id:table/table-name
|
|
90
|
+
*/
|
|
33
91
|
arn: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* ARN of the table's stream if enabled
|
|
95
|
+
* Format: arn:aws:dynamodb:region:account-id:table/table-name/stream/timestamp
|
|
96
|
+
*/
|
|
34
97
|
streamArn?: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Unique identifier for the table
|
|
101
|
+
*/
|
|
35
102
|
tableId: string;
|
|
36
103
|
}
|
|
37
104
|
|
|
105
|
+
/**
|
|
106
|
+
* AWS DynamoDB Table Resource
|
|
107
|
+
*
|
|
108
|
+
* Creates and manages DynamoDB tables with support for partition and sort keys,
|
|
109
|
+
* flexible billing modes, and automatic table status monitoring.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Create a table with partition and sort key
|
|
113
|
+
* const table = await Table("user-events", {
|
|
114
|
+
* tableName: "user-events",
|
|
115
|
+
* partitionKey: {
|
|
116
|
+
* name: "id",
|
|
117
|
+
* type: "S"
|
|
118
|
+
* },
|
|
119
|
+
* sortKey: {
|
|
120
|
+
* name: "timestamp",
|
|
121
|
+
* type: "N"
|
|
122
|
+
* },
|
|
123
|
+
* tags: {
|
|
124
|
+
* Environment: "test"
|
|
125
|
+
* }
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // Create a table with provisioned capacity
|
|
130
|
+
* const table = await Table("high-throughput", {
|
|
131
|
+
* tableName: "high-throughput",
|
|
132
|
+
* partitionKey: {
|
|
133
|
+
* name: "userId",
|
|
134
|
+
* type: "S"
|
|
135
|
+
* },
|
|
136
|
+
* billingMode: "PROVISIONED",
|
|
137
|
+
* readCapacity: 100,
|
|
138
|
+
* writeCapacity: 50
|
|
139
|
+
* });
|
|
140
|
+
*/
|
|
38
141
|
export const Table = Resource(
|
|
39
142
|
"dynamo::Table",
|
|
40
143
|
async function (
|
package/src/cloudflare/bucket.ts
CHANGED
|
@@ -54,6 +54,42 @@ export interface R2Bucket
|
|
|
54
54
|
creationDate: number;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Creates and manages Cloudflare R2 Buckets for object storage.
|
|
59
|
+
*
|
|
60
|
+
* R2 Buckets provide S3-compatible object storage with automatic data replication
|
|
61
|
+
* across multiple regions for high availability and durability.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Create a basic R2 bucket with default settings
|
|
65
|
+
* const basicBucket = await R2Bucket("my-app-data", {
|
|
66
|
+
* name: "my-app-data"
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Create a bucket with location hint for optimal performance
|
|
71
|
+
* const euBucket = await R2Bucket("eu-user-data", {
|
|
72
|
+
* name: "eu-user-data",
|
|
73
|
+
* locationHint: "eu",
|
|
74
|
+
* jurisdiction: "eu"
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Create a development bucket with public access enabled
|
|
79
|
+
* const publicBucket = await R2Bucket("public-assets", {
|
|
80
|
+
* name: "public-assets",
|
|
81
|
+
* allowPublicAccess: true
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // Create a FedRAMP compliant bucket for government workloads
|
|
86
|
+
* const fedRampBucket = await R2Bucket("gov-data", {
|
|
87
|
+
* name: "gov-data",
|
|
88
|
+
* jurisdiction: "fedramp"
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* @see https://developers.cloudflare.com/r2/buckets/
|
|
92
|
+
*/
|
|
57
93
|
export const R2Bucket = Resource(
|
|
58
94
|
"cloudflare::R2Bucket",
|
|
59
95
|
async function (
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties for creating a Durable Object Namespace
|
|
3
|
+
*/
|
|
1
4
|
export interface DurableObjectNamespaceInput {
|
|
2
5
|
className: string;
|
|
3
6
|
scriptName?: string | undefined;
|
|
@@ -6,6 +9,28 @@ export interface DurableObjectNamespaceInput {
|
|
|
6
9
|
namespaceId?: string | undefined;
|
|
7
10
|
}
|
|
8
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @example
|
|
14
|
+
* // Create a basic Durable Object namespace for stateful chat rooms
|
|
15
|
+
* const rooms = new DurableObjectNamespace("chat-rooms", {
|
|
16
|
+
* className: "ChatRoom"
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Create a Durable Object with SQLite storage for user data
|
|
21
|
+
* const users = new DurableObjectNamespace("user-store", {
|
|
22
|
+
* className: "User",
|
|
23
|
+
* sqlite: true
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Create a Durable Object in production for game state management
|
|
28
|
+
* const game = new DurableObjectNamespace("game-state", {
|
|
29
|
+
* className: "GameState",
|
|
30
|
+
* scriptName: "game-worker",
|
|
31
|
+
* environment: "production"
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
9
34
|
export class DurableObjectNamespace implements DurableObjectNamespaceInput {
|
|
10
35
|
public readonly type = "durable_object_namespace" as const;
|
|
11
36
|
// alias for bindingName to be consistent with other bindings
|
|
@@ -78,6 +78,42 @@ export interface KVNamespace
|
|
|
78
78
|
modifiedAt: number;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* A Cloudflare KV Namespace is a key-value store that can be used to store data for your application.
|
|
83
|
+
*
|
|
84
|
+
* @see https://developers.cloudflare.com/kv/concepts/kv-namespaces/
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Create a basic KV namespace for storing user data
|
|
88
|
+
* const users = await KVNamespace("users", {
|
|
89
|
+
* title: "user-data"
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* // Create a KV namespace with initial values and TTL
|
|
94
|
+
* const sessions = await KVNamespace("sessions", {
|
|
95
|
+
* title: "user-sessions",
|
|
96
|
+
* values: [{
|
|
97
|
+
* key: "session_123",
|
|
98
|
+
* value: { userId: "user_456", role: "admin" },
|
|
99
|
+
* expirationTtl: 3600 // Expires in 1 hour
|
|
100
|
+
* }]
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* // Create a KV namespace with metadata for caching
|
|
105
|
+
* const assets = await KVNamespace("assets", {
|
|
106
|
+
* title: "static-assets",
|
|
107
|
+
* values: [{
|
|
108
|
+
* key: "main.js",
|
|
109
|
+
* value: "content...",
|
|
110
|
+
* metadata: {
|
|
111
|
+
* contentType: "application/javascript",
|
|
112
|
+
* etag: "abc123"
|
|
113
|
+
* }
|
|
114
|
+
* }]
|
|
115
|
+
* });
|
|
116
|
+
*/
|
|
81
117
|
export const KVNamespace = Resource(
|
|
82
118
|
"cloudflare::KVNamespace",
|
|
83
119
|
async function (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { exec } from "child_process";
|
|
2
2
|
import { promises as fs } from "fs";
|
|
3
|
-
import path from "path";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
import { promisify } from "util";
|
|
5
5
|
import type { Context } from "../context";
|
|
6
6
|
import type { BundleProps } from "../esbuild/bundle";
|
|
@@ -202,6 +202,58 @@ export interface StaticSite extends Resource<"cloudflare::StaticSite"> {
|
|
|
202
202
|
routes?: Record<string, string>;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* A StaticSite resource deploys static web content to Cloudflare Workers, using KV for asset storage.
|
|
207
|
+
* It provides an efficient way to serve static websites with global distribution and caching.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* // Create a basic static site with default settings
|
|
211
|
+
* const basicSite = await StaticSite("my-site", {
|
|
212
|
+
* name: "my-site",
|
|
213
|
+
* dir: "./dist",
|
|
214
|
+
* url: true
|
|
215
|
+
* });
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* // Create a static site with custom build command and minification disabled
|
|
219
|
+
* const devSite = await StaticSite("dev-site", {
|
|
220
|
+
* name: "dev-site",
|
|
221
|
+
* dir: "./public",
|
|
222
|
+
* build: {
|
|
223
|
+
* command: "npm run build"
|
|
224
|
+
* },
|
|
225
|
+
* bundle: {
|
|
226
|
+
* minify: false
|
|
227
|
+
* }
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* // Create a static site with a backend API worker
|
|
232
|
+
* const backend = await Worker("api-backend", {
|
|
233
|
+
* name: "api-backend",
|
|
234
|
+
* entrypoint: "./src/api.ts"
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* const fullSite = await StaticSite("full-site", {
|
|
238
|
+
* name: "full-site",
|
|
239
|
+
* dir: "./dist",
|
|
240
|
+
* routes: {
|
|
241
|
+
* "/api/*": backend
|
|
242
|
+
* }
|
|
243
|
+
* });
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* // Create a static site with custom error page and index
|
|
247
|
+
* const customSite = await StaticSite("custom-site", {
|
|
248
|
+
* name: "custom-site",
|
|
249
|
+
* dir: "./www",
|
|
250
|
+
* errorPage: "404.html",
|
|
251
|
+
* indexPage: "home.html",
|
|
252
|
+
* domain: "www.example.com"
|
|
253
|
+
* });
|
|
254
|
+
*
|
|
255
|
+
* @see https://developers.cloudflare.com/workers/platform/sites
|
|
256
|
+
*/
|
|
205
257
|
export const StaticSite = Resource(
|
|
206
258
|
"cloudflare::StaticSite",
|
|
207
259
|
{
|
package/src/cloudflare/worker.ts
CHANGED
|
@@ -138,6 +138,69 @@ export interface Worker<B extends Bindings = Bindings>
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* A Cloudflare Worker is a serverless function that can be deployed to the Cloudflare network.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* // Create a basic HTTP handler worker with custom domain routing
|
|
146
|
+
* // and workers.dev URL:
|
|
147
|
+
* const api = await Worker("api", {
|
|
148
|
+
* name: "api-worker",
|
|
149
|
+
* entrypoint: "./src/api.ts",
|
|
150
|
+
* routes: ["api.example.com/*"],
|
|
151
|
+
* url: true
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* // Create a real-time chat worker using Durable Objects
|
|
156
|
+
* // for state management:
|
|
157
|
+
* const chatRooms = new DurableObjectNamespace("chat-rooms");
|
|
158
|
+
* const userStore = new DurableObjectNamespace("user-store");
|
|
159
|
+
*
|
|
160
|
+
* const chat = await Worker("chat", {
|
|
161
|
+
* name: "chat-worker",
|
|
162
|
+
* entrypoint: "./src/chat.ts",
|
|
163
|
+
* bindings: {
|
|
164
|
+
* ROOMS: chatRooms,
|
|
165
|
+
* USERS: userStore
|
|
166
|
+
* },
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* // Create a worker with KV namespace for caching and data storage:
|
|
171
|
+
* const cache = await KVNamespace("cache-store");
|
|
172
|
+
* const settings = await KVNamespace("user-settings");
|
|
173
|
+
*
|
|
174
|
+
* const cacheWorker = await Worker("cache", {
|
|
175
|
+
* name: "cache-worker",
|
|
176
|
+
* entrypoint: "./src/cache.ts",
|
|
177
|
+
* bindings: {
|
|
178
|
+
* CACHE: cache,
|
|
179
|
+
* SETTINGS: settings
|
|
180
|
+
* }
|
|
181
|
+
* });
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* // Create a worker with R2 bucket for object storage:
|
|
185
|
+
* const uploads = await R2Bucket("uploads", {
|
|
186
|
+
* name: "user-uploads"
|
|
187
|
+
* });
|
|
188
|
+
* const assets = await R2Bucket("assets", {
|
|
189
|
+
* name: "static-assets",
|
|
190
|
+
* allowPublicAccess: true
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* const storageWorker = await Worker("storage", {
|
|
194
|
+
* name: "storage-worker",
|
|
195
|
+
* entrypoint: "./src/storage.ts",
|
|
196
|
+
* bindings: {
|
|
197
|
+
* UPLOADS: uploads,
|
|
198
|
+
* ASSETS: assets
|
|
199
|
+
* }
|
|
200
|
+
* });
|
|
201
|
+
*
|
|
202
|
+
* @see https://developers.cloudflare.com/workers/
|
|
203
|
+
*/
|
|
141
204
|
export const Worker = Resource(
|
|
142
205
|
"cloudflare::Worker",
|
|
143
206
|
{
|
package/src/cloudflare/zone.ts
CHANGED
|
@@ -245,6 +245,61 @@ export interface Zone extends Resource<"cloudflare::Zone"> {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
+
/**
|
|
249
|
+
* A Cloudflare Zone represents a domain and its configuration settings on Cloudflare.
|
|
250
|
+
* Zones allow you to manage DNS, SSL/TLS, caching, security and other settings for a domain.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // Create a basic zone with default settings
|
|
254
|
+
* const basicZone = await Zone("example.com", {
|
|
255
|
+
* name: "example.com",
|
|
256
|
+
* type: "full",
|
|
257
|
+
* jumpStart: true
|
|
258
|
+
* });
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // Create a zone with enhanced security settings
|
|
262
|
+
* const secureZone = await Zone("secure.example.com", {
|
|
263
|
+
* name: "secure.example.com",
|
|
264
|
+
* type: "full",
|
|
265
|
+
* settings: {
|
|
266
|
+
* ssl: "strict",
|
|
267
|
+
* alwaysUseHttps: "on",
|
|
268
|
+
* automaticHttpsRewrites: "on",
|
|
269
|
+
* minTlsVersion: "1.3",
|
|
270
|
+
* tls13: "zrt"
|
|
271
|
+
* }
|
|
272
|
+
* });
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* // Create a zone with optimized performance settings
|
|
276
|
+
* const fastZone = await Zone("fast.example.com", {
|
|
277
|
+
* name: "fast.example.com",
|
|
278
|
+
* settings: {
|
|
279
|
+
* browserCacheTtl: 7200,
|
|
280
|
+
* brotli: "on",
|
|
281
|
+
* zeroRtt: "on",
|
|
282
|
+
* http2: "on",
|
|
283
|
+
* http3: "on",
|
|
284
|
+
* earlyHints: "on"
|
|
285
|
+
* }
|
|
286
|
+
* });
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* // Create a development zone with specific features
|
|
290
|
+
* const devZone = await Zone("dev.example.com", {
|
|
291
|
+
* name: "dev.example.com",
|
|
292
|
+
* settings: {
|
|
293
|
+
* developmentMode: "on",
|
|
294
|
+
* emailObfuscation: "on",
|
|
295
|
+
* hotlinkProtection: "on",
|
|
296
|
+
* ipv6: "on",
|
|
297
|
+
* websockets: "on"
|
|
298
|
+
* }
|
|
299
|
+
* });
|
|
300
|
+
*
|
|
301
|
+
* @see https://developers.cloudflare.com/dns/zone-setups/
|
|
302
|
+
*/
|
|
248
303
|
export const Zone = Resource(
|
|
249
304
|
"cloudflare::Zone",
|
|
250
305
|
async function (
|
package/src/destroy.ts
CHANGED
|
@@ -55,7 +55,7 @@ export async function destroy<Type extends string>(
|
|
|
55
55
|
const Provider: Provider<Type> | undefined = PROVIDERS.get(instance.Kind);
|
|
56
56
|
if (!Provider) {
|
|
57
57
|
throw new Error(
|
|
58
|
-
`Cannot destroy resource type ${instance.Kind} - no provider found. You may need to import the provider in your alchemy.config.ts.`,
|
|
58
|
+
`Cannot destroy resource "${instance.FQN}" type ${instance.Kind} - no provider found. You may need to import the provider in your alchemy.config.ts.`,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
package/src/esbuild/bundle.ts
CHANGED
|
@@ -4,60 +4,110 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import type { Context } from "../context";
|
|
6
6
|
import { Resource } from "../resource";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Properties for creating or updating an esbuild bundle
|
|
10
|
+
*/
|
|
7
11
|
export interface BundleProps {
|
|
8
12
|
/**
|
|
9
13
|
* Entry point for the bundle
|
|
14
|
+
* Path to the source file to bundle (e.g., "src/handler.ts")
|
|
10
15
|
*/
|
|
11
16
|
entryPoint: string;
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* Output directory for the bundle
|
|
20
|
+
* Directory where the bundled file will be written
|
|
14
21
|
*/
|
|
15
22
|
outdir?: string;
|
|
23
|
+
|
|
16
24
|
/**
|
|
17
25
|
* Output filename for the bundle
|
|
26
|
+
* Full path to the output file, overrides outdir if specified
|
|
18
27
|
*/
|
|
19
28
|
outfile?: string;
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
|
-
* Bundle format
|
|
31
|
+
* Bundle format
|
|
32
|
+
* iife: Immediately Invoked Function Expression
|
|
33
|
+
* cjs: CommonJS
|
|
34
|
+
* esm: ECMAScript Modules
|
|
22
35
|
*/
|
|
23
36
|
format?: "iife" | "cjs" | "esm";
|
|
37
|
+
|
|
24
38
|
/**
|
|
25
|
-
* Target environment
|
|
39
|
+
* Target environment
|
|
40
|
+
* Examples: 'node16', 'node18', 'es2020'
|
|
26
41
|
*/
|
|
27
42
|
target?: string | string[];
|
|
43
|
+
|
|
28
44
|
/**
|
|
29
45
|
* Whether to minify the output
|
|
30
46
|
*/
|
|
31
47
|
minify?: boolean;
|
|
48
|
+
|
|
32
49
|
/**
|
|
33
50
|
* Whether to generate sourcemaps
|
|
51
|
+
* inline: Include sourcemap in bundle
|
|
52
|
+
* external: Generate separate .map file
|
|
53
|
+
* both: Generate both inline and external
|
|
34
54
|
*/
|
|
35
55
|
sourcemap?: boolean | "inline" | "external" | "both";
|
|
56
|
+
|
|
36
57
|
/**
|
|
37
58
|
* External packages to exclude from bundle
|
|
59
|
+
* Array of package names to mark as external
|
|
38
60
|
*/
|
|
39
61
|
external?: string[];
|
|
62
|
+
|
|
40
63
|
/**
|
|
41
|
-
* Platform to target
|
|
64
|
+
* Platform to target
|
|
65
|
+
* browser: Browser environment
|
|
66
|
+
* node: Node.js environment
|
|
67
|
+
* neutral: Platform-agnostic
|
|
42
68
|
*/
|
|
43
69
|
platform?: "browser" | "node" | "neutral";
|
|
70
|
+
|
|
44
71
|
/**
|
|
45
72
|
* Additional esbuild options
|
|
73
|
+
* Any other valid esbuild BuildOptions
|
|
46
74
|
*/
|
|
47
75
|
options?: Partial<esbuild.BuildOptions>;
|
|
48
76
|
}
|
|
49
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Output returned after bundle creation/update
|
|
80
|
+
*/
|
|
50
81
|
export interface Bundle extends Resource<"esbuild::Bundle"> {
|
|
51
82
|
/**
|
|
52
83
|
* Path to the bundled file
|
|
84
|
+
* Absolute or relative path to the generated bundle
|
|
53
85
|
*/
|
|
54
86
|
path: string;
|
|
87
|
+
|
|
55
88
|
/**
|
|
56
89
|
* SHA-256 hash of the bundle contents
|
|
90
|
+
* Used for cache busting and content verification
|
|
57
91
|
*/
|
|
58
92
|
hash: string;
|
|
59
93
|
}
|
|
60
94
|
|
|
95
|
+
/**
|
|
96
|
+
* esbuild Bundle Resource
|
|
97
|
+
*
|
|
98
|
+
* Creates and manages bundled JavaScript/TypeScript files using esbuild.
|
|
99
|
+
* Supports various output formats, sourcemaps, and platform targets.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Bundle a TypeScript file for Node.js
|
|
103
|
+
* const bundle = await Bundle("handler", {
|
|
104
|
+
* entryPoint: "src/handler.ts",
|
|
105
|
+
* outdir: ".alchemy/.out",
|
|
106
|
+
* format: "esm",
|
|
107
|
+
* platform: "node",
|
|
108
|
+
* target: "node18"
|
|
109
|
+
* });
|
|
110
|
+
*/
|
|
61
111
|
export const Bundle = Resource(
|
|
62
112
|
"esbuild::Bundle",
|
|
63
113
|
{
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collection of files with their contents
|
|
3
|
+
*/
|
|
4
|
+
export type FileCollection = {
|
|
5
|
+
/**
|
|
6
|
+
* Type identifier for FileCollection
|
|
7
|
+
*/
|
|
8
|
+
type: "fs::FileCollection";
|
|
9
|
+
/**
|
|
10
|
+
* Map of relative paths to file contents
|
|
11
|
+
*/
|
|
12
|
+
files: {
|
|
13
|
+
[relativePath: string]: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function isFileCollection(value: unknown): value is FileCollection {
|
|
18
|
+
return (
|
|
19
|
+
typeof value === "object" &&
|
|
20
|
+
value !== null &&
|
|
21
|
+
"type" in value &&
|
|
22
|
+
value.type === "fs::FileCollection"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference to a file in the filesystem
|
|
3
|
+
*/
|
|
4
|
+
export type FileRef = {
|
|
5
|
+
/**
|
|
6
|
+
* Type identifier for FileRef
|
|
7
|
+
*/
|
|
8
|
+
kind: "fs::FileRef";
|
|
9
|
+
/**
|
|
10
|
+
* Path to the file
|
|
11
|
+
*/
|
|
12
|
+
path: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function isFileRef(value: unknown): value is FileRef {
|
|
16
|
+
return (
|
|
17
|
+
typeof value === "object" &&
|
|
18
|
+
value !== null &&
|
|
19
|
+
"kind" in value &&
|
|
20
|
+
value.kind === "fs::FileRef"
|
|
21
|
+
);
|
|
22
|
+
}
|