alchemy 0.2.2 → 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/ai/index.d.ts +2 -0
- package/lib/ai/index.js +2 -0
- package/lib/ai/object.d.ts +101 -0
- package/lib/ai/object.js +70 -0
- package/lib/alchemy.d.ts +84 -2
- package/lib/alchemy.js +114 -10
- package/lib/apply.d.ts +1 -1
- package/lib/apply.js +13 -10
- 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/context.d.ts +9 -4
- package/lib/context.js +4 -2
- package/lib/destroy.js +9 -8
- 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 +78 -5
- package/lib/fs/file.js +39 -3
- package/lib/fs/folder.d.ts +37 -5
- package/lib/fs/folder.js +28 -3
- 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 +2 -2
- package/lib/resource.js +4 -0
- package/lib/scope.d.ts +1 -1
- package/lib/scope.js +6 -6
- package/lib/secret.d.ts +67 -0
- package/lib/secret.js +67 -0
- package/lib/shadcn/component.d.ts +1 -1
- package/lib/state.d.ts +1 -1
- package/lib/state.js +8 -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.d.ts +3 -1
- package/lib/util/serde.js +20 -4
- package/lib/vite/vite.d.ts +1 -1
- package/lib/vitepress/dependencies.d.ts +12 -0
- package/lib/vitepress/dependencies.js +35 -0
- package/lib/vitepress/home-page.d.ts +133 -0
- package/lib/vitepress/home-page.js +11 -0
- package/lib/vitepress/index.d.ts +2 -0
- package/lib/vitepress/index.js +2 -0
- package/lib/vitepress/vitepress.d.ts +71 -0
- package/lib/vitepress/vitepress.js +266 -0
- package/package.json +22 -10
- package/src/ai/ark.ts +118 -0
- package/src/ai/client.ts +78 -0
- package/src/ai/document.ts +160 -0
- package/src/ai/index.ts +2 -0
- package/src/ai/object.ts +149 -0
- package/src/alchemy.ts +192 -17
- package/src/apply.ts +25 -13
- 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/context.ts +30 -10
- package/src/destroy.ts +11 -8
- 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 +107 -6
- package/src/fs/folder.ts +45 -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 +7 -2
- package/src/scope.ts +9 -9
- package/src/secret.ts +67 -0
- package/src/state.ts +9 -2
- 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 +30 -4
- package/src/vitepress/dependencies.ts +68 -0
- package/src/vitepress/home-page.ts +166 -0
- package/src/vitepress/index.md +75 -0
- package/src/vitepress/index.ts +2 -0
- package/src/vitepress/vitepress.ts +382 -0
- package/lib/project/vite.d.ts +0 -90
- package/lib/project/vite.js +0 -228
- package/src/project/vite.ts +0 -406
package/lib/aws/ses.js
CHANGED
|
@@ -2,7 +2,48 @@ import { CreateConfigurationSetCommand, CreateEmailIdentityCommand, DeleteConfig
|
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
3
|
import { ignore } from "../util/ignore";
|
|
4
4
|
/**
|
|
5
|
-
* AWS SES
|
|
5
|
+
* AWS SES Resource
|
|
6
|
+
*
|
|
7
|
+
* Creates and manages Amazon Simple Email Service (SES) configuration sets and email identities.
|
|
8
|
+
* Supports email sending configuration, DKIM signing, and identity verification.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Create a configuration set with sending options
|
|
12
|
+
* const configSet = await SES("email-config", {
|
|
13
|
+
* configurationSetName: "my-email-config",
|
|
14
|
+
* sendingOptions: {
|
|
15
|
+
* SendingEnabled: true
|
|
16
|
+
* },
|
|
17
|
+
* tags: {
|
|
18
|
+
* Environment: "production",
|
|
19
|
+
* Project: "notifications"
|
|
20
|
+
* }
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Create and verify a domain identity with DKIM
|
|
25
|
+
* const domainIdentity = await SES("domain-identity", {
|
|
26
|
+
* emailIdentity: "example.com",
|
|
27
|
+
* enableDkim: true,
|
|
28
|
+
* tags: {
|
|
29
|
+
* Environment: "production",
|
|
30
|
+
* Project: "transactional-emails"
|
|
31
|
+
* }
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Update configuration set sending options
|
|
36
|
+
* const updatedConfig = await SES("email-config", {
|
|
37
|
+
* configurationSetName: "my-email-config",
|
|
38
|
+
* sendingOptions: {
|
|
39
|
+
* SendingEnabled: false
|
|
40
|
+
* },
|
|
41
|
+
* tags: {
|
|
42
|
+
* Environment: "production",
|
|
43
|
+
* Project: "notifications",
|
|
44
|
+
* Updated: "true"
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
6
47
|
*/
|
|
7
48
|
export const SES = Resource("aws::SES", async function (id, props) {
|
|
8
49
|
// Create SES client
|
package/lib/aws/table.d.ts
CHANGED
|
@@ -1,23 +1,118 @@
|
|
|
1
1
|
import type { Context } from "../context";
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
|
+
/**
|
|
4
|
+
* Properties for creating or updating a DynamoDB table
|
|
5
|
+
*/
|
|
3
6
|
export interface TableProps {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the DynamoDB table
|
|
9
|
+
*/
|
|
4
10
|
tableName: string;
|
|
11
|
+
/**
|
|
12
|
+
* Primary partition key (hash key) configuration
|
|
13
|
+
* Defines the main identifier for items in the table
|
|
14
|
+
*/
|
|
5
15
|
partitionKey: {
|
|
16
|
+
/**
|
|
17
|
+
* Name of the partition key attribute
|
|
18
|
+
*/
|
|
6
19
|
name: string;
|
|
20
|
+
/**
|
|
21
|
+
* Data type of the partition key
|
|
22
|
+
* S: String, N: Number, B: Binary
|
|
23
|
+
*/
|
|
7
24
|
type: "S" | "N" | "B";
|
|
8
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Optional sort key (range key) configuration
|
|
28
|
+
* Used to sort items with the same partition key
|
|
29
|
+
*/
|
|
9
30
|
sortKey?: {
|
|
31
|
+
/**
|
|
32
|
+
* Name of the sort key attribute
|
|
33
|
+
*/
|
|
10
34
|
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Data type of the sort key
|
|
37
|
+
* S: String, N: Number, B: Binary
|
|
38
|
+
*/
|
|
11
39
|
type: "S" | "N" | "B";
|
|
12
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Billing mode for the table
|
|
43
|
+
* PROVISIONED: Set read/write capacity units
|
|
44
|
+
* PAY_PER_REQUEST: Pay per request pricing
|
|
45
|
+
*/
|
|
13
46
|
billingMode?: "PROVISIONED" | "PAY_PER_REQUEST";
|
|
47
|
+
/**
|
|
48
|
+
* Read capacity units when using PROVISIONED billing mode
|
|
49
|
+
* Default: 5
|
|
50
|
+
*/
|
|
14
51
|
readCapacity?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Write capacity units when using PROVISIONED billing mode
|
|
54
|
+
* Default: 5
|
|
55
|
+
*/
|
|
15
56
|
writeCapacity?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Tags to apply to the table
|
|
59
|
+
* Key-value pairs for resource organization
|
|
60
|
+
*/
|
|
16
61
|
tags?: Record<string, string>;
|
|
17
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Output returned after DynamoDB table creation/update
|
|
65
|
+
*/
|
|
18
66
|
export interface Table extends Resource<"dynamo::Table">, TableProps {
|
|
67
|
+
/**
|
|
68
|
+
* ARN of the table
|
|
69
|
+
* Format: arn:aws:dynamodb:region:account-id:table/table-name
|
|
70
|
+
*/
|
|
19
71
|
arn: string;
|
|
72
|
+
/**
|
|
73
|
+
* ARN of the table's stream if enabled
|
|
74
|
+
* Format: arn:aws:dynamodb:region:account-id:table/table-name/stream/timestamp
|
|
75
|
+
*/
|
|
20
76
|
streamArn?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Unique identifier for the table
|
|
79
|
+
*/
|
|
21
80
|
tableId: string;
|
|
22
81
|
}
|
|
23
|
-
|
|
82
|
+
/**
|
|
83
|
+
* AWS DynamoDB Table Resource
|
|
84
|
+
*
|
|
85
|
+
* Creates and manages DynamoDB tables with support for partition and sort keys,
|
|
86
|
+
* flexible billing modes, and automatic table status monitoring.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Create a table with partition and sort key
|
|
90
|
+
* const table = await Table("user-events", {
|
|
91
|
+
* tableName: "user-events",
|
|
92
|
+
* partitionKey: {
|
|
93
|
+
* name: "id",
|
|
94
|
+
* type: "S"
|
|
95
|
+
* },
|
|
96
|
+
* sortKey: {
|
|
97
|
+
* name: "timestamp",
|
|
98
|
+
* type: "N"
|
|
99
|
+
* },
|
|
100
|
+
* tags: {
|
|
101
|
+
* Environment: "test"
|
|
102
|
+
* }
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Create a table with provisioned capacity
|
|
107
|
+
* const table = await Table("high-throughput", {
|
|
108
|
+
* tableName: "high-throughput",
|
|
109
|
+
* partitionKey: {
|
|
110
|
+
* name: "userId",
|
|
111
|
+
* type: "S"
|
|
112
|
+
* },
|
|
113
|
+
* billingMode: "PROVISIONED",
|
|
114
|
+
* readCapacity: 100,
|
|
115
|
+
* writeCapacity: 50
|
|
116
|
+
* });
|
|
117
|
+
*/
|
|
118
|
+
export declare const Table: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Table>, id: string, props: TableProps) => Promise<Table>);
|
package/lib/aws/table.js
CHANGED
|
@@ -2,6 +2,42 @@ import { CreateTableCommand, DeleteTableCommand, DescribeTableCommand, DynamoDBC
|
|
|
2
2
|
import { Resource } from "../resource";
|
|
3
3
|
import { ignore } from "../util/ignore";
|
|
4
4
|
import { withExponentialBackoff } from "../util/retry";
|
|
5
|
+
/**
|
|
6
|
+
* AWS DynamoDB Table Resource
|
|
7
|
+
*
|
|
8
|
+
* Creates and manages DynamoDB tables with support for partition and sort keys,
|
|
9
|
+
* flexible billing modes, and automatic table status monitoring.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Create a table with partition and sort key
|
|
13
|
+
* const table = await Table("user-events", {
|
|
14
|
+
* tableName: "user-events",
|
|
15
|
+
* partitionKey: {
|
|
16
|
+
* name: "id",
|
|
17
|
+
* type: "S"
|
|
18
|
+
* },
|
|
19
|
+
* sortKey: {
|
|
20
|
+
* name: "timestamp",
|
|
21
|
+
* type: "N"
|
|
22
|
+
* },
|
|
23
|
+
* tags: {
|
|
24
|
+
* Environment: "test"
|
|
25
|
+
* }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Create a table with provisioned capacity
|
|
30
|
+
* const table = await Table("high-throughput", {
|
|
31
|
+
* tableName: "high-throughput",
|
|
32
|
+
* partitionKey: {
|
|
33
|
+
* name: "userId",
|
|
34
|
+
* type: "S"
|
|
35
|
+
* },
|
|
36
|
+
* billingMode: "PROVISIONED",
|
|
37
|
+
* readCapacity: 100,
|
|
38
|
+
* writeCapacity: 50
|
|
39
|
+
* });
|
|
40
|
+
*/
|
|
5
41
|
export const Table = Resource("dynamo::Table", async function (id, props) {
|
|
6
42
|
const client = new DynamoDBClient({});
|
|
7
43
|
if (this.phase === "delete") {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/cloudflare/bound.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -43,4 +43,40 @@ export interface R2Bucket extends Resource<"cloudflare::R2Bucket">, BucketProps
|
|
|
43
43
|
*/
|
|
44
44
|
creationDate: number;
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Creates and manages Cloudflare R2 Buckets for object storage.
|
|
48
|
+
*
|
|
49
|
+
* R2 Buckets provide S3-compatible object storage with automatic data replication
|
|
50
|
+
* across multiple regions for high availability and durability.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Create a basic R2 bucket with default settings
|
|
54
|
+
* const basicBucket = await R2Bucket("my-app-data", {
|
|
55
|
+
* name: "my-app-data"
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Create a bucket with location hint for optimal performance
|
|
60
|
+
* const euBucket = await R2Bucket("eu-user-data", {
|
|
61
|
+
* name: "eu-user-data",
|
|
62
|
+
* locationHint: "eu",
|
|
63
|
+
* jurisdiction: "eu"
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Create a development bucket with public access enabled
|
|
68
|
+
* const publicBucket = await R2Bucket("public-assets", {
|
|
69
|
+
* name: "public-assets",
|
|
70
|
+
* allowPublicAccess: true
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Create a FedRAMP compliant bucket for government workloads
|
|
75
|
+
* const fedRampBucket = await R2Bucket("gov-data", {
|
|
76
|
+
* name: "gov-data",
|
|
77
|
+
* jurisdiction: "fedramp"
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* @see https://developers.cloudflare.com/r2/buckets/
|
|
81
|
+
*/
|
|
82
|
+
export declare const R2Bucket: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<R2Bucket>, id: string, props: BucketProps) => Promise<R2Bucket>);
|
package/lib/cloudflare/bucket.js
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
import { Resource } from "../resource";
|
|
2
2
|
import { createCloudflareApi } from "./api";
|
|
3
|
+
/**
|
|
4
|
+
* Creates and manages Cloudflare R2 Buckets for object storage.
|
|
5
|
+
*
|
|
6
|
+
* R2 Buckets provide S3-compatible object storage with automatic data replication
|
|
7
|
+
* across multiple regions for high availability and durability.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // Create a basic R2 bucket with default settings
|
|
11
|
+
* const basicBucket = await R2Bucket("my-app-data", {
|
|
12
|
+
* name: "my-app-data"
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Create a bucket with location hint for optimal performance
|
|
17
|
+
* const euBucket = await R2Bucket("eu-user-data", {
|
|
18
|
+
* name: "eu-user-data",
|
|
19
|
+
* locationHint: "eu",
|
|
20
|
+
* jurisdiction: "eu"
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Create a development bucket with public access enabled
|
|
25
|
+
* const publicBucket = await R2Bucket("public-assets", {
|
|
26
|
+
* name: "public-assets",
|
|
27
|
+
* allowPublicAccess: true
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Create a FedRAMP compliant bucket for government workloads
|
|
32
|
+
* const fedRampBucket = await R2Bucket("gov-data", {
|
|
33
|
+
* name: "gov-data",
|
|
34
|
+
* jurisdiction: "fedramp"
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* @see https://developers.cloudflare.com/r2/buckets/
|
|
38
|
+
*/
|
|
3
39
|
export const R2Bucket = Resource("cloudflare::R2Bucket", async function (id, props) {
|
|
4
40
|
// Create Cloudflare API client with automatic account discovery
|
|
5
41
|
const api = await createCloudflareApi();
|
|
@@ -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;
|
|
@@ -5,6 +8,28 @@ export interface DurableObjectNamespaceInput {
|
|
|
5
8
|
sqlite?: boolean | undefined;
|
|
6
9
|
namespaceId?: string | undefined;
|
|
7
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @example
|
|
13
|
+
* // Create a basic Durable Object namespace for stateful chat rooms
|
|
14
|
+
* const rooms = new DurableObjectNamespace("chat-rooms", {
|
|
15
|
+
* className: "ChatRoom"
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create a Durable Object with SQLite storage for user data
|
|
20
|
+
* const users = new DurableObjectNamespace("user-store", {
|
|
21
|
+
* className: "User",
|
|
22
|
+
* sqlite: true
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Create a Durable Object in production for game state management
|
|
27
|
+
* const game = new DurableObjectNamespace("game-state", {
|
|
28
|
+
* className: "GameState",
|
|
29
|
+
* scriptName: "game-worker",
|
|
30
|
+
* environment: "production"
|
|
31
|
+
* });
|
|
32
|
+
*/
|
|
8
33
|
export declare class DurableObjectNamespace implements DurableObjectNamespaceInput {
|
|
9
34
|
readonly id: string;
|
|
10
35
|
readonly type: "durable_object_namespace";
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* // Create a basic Durable Object namespace for stateful chat rooms
|
|
4
|
+
* const rooms = new DurableObjectNamespace("chat-rooms", {
|
|
5
|
+
* className: "ChatRoom"
|
|
6
|
+
* });
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Create a Durable Object with SQLite storage for user data
|
|
10
|
+
* const users = new DurableObjectNamespace("user-store", {
|
|
11
|
+
* className: "User",
|
|
12
|
+
* sqlite: true
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Create a Durable Object in production for game state management
|
|
17
|
+
* const game = new DurableObjectNamespace("game-state", {
|
|
18
|
+
* className: "GameState",
|
|
19
|
+
* scriptName: "game-worker",
|
|
20
|
+
* environment: "production"
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
1
23
|
export class DurableObjectNamespace {
|
|
2
24
|
id;
|
|
3
25
|
type = "durable_object_namespace";
|
|
@@ -58,4 +58,40 @@ export interface KVNamespace extends Resource<"cloudflare::KVNamespace">, KVName
|
|
|
58
58
|
*/
|
|
59
59
|
modifiedAt: number;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* A Cloudflare KV Namespace is a key-value store that can be used to store data for your application.
|
|
63
|
+
*
|
|
64
|
+
* @see https://developers.cloudflare.com/kv/concepts/kv-namespaces/
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Create a basic KV namespace for storing user data
|
|
68
|
+
* const users = await KVNamespace("users", {
|
|
69
|
+
* title: "user-data"
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* // Create a KV namespace with initial values and TTL
|
|
74
|
+
* const sessions = await KVNamespace("sessions", {
|
|
75
|
+
* title: "user-sessions",
|
|
76
|
+
* values: [{
|
|
77
|
+
* key: "session_123",
|
|
78
|
+
* value: { userId: "user_456", role: "admin" },
|
|
79
|
+
* expirationTtl: 3600 // Expires in 1 hour
|
|
80
|
+
* }]
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* // Create a KV namespace with metadata for caching
|
|
85
|
+
* const assets = await KVNamespace("assets", {
|
|
86
|
+
* title: "static-assets",
|
|
87
|
+
* values: [{
|
|
88
|
+
* key: "main.js",
|
|
89
|
+
* value: "content...",
|
|
90
|
+
* metadata: {
|
|
91
|
+
* contentType: "application/javascript",
|
|
92
|
+
* etag: "abc123"
|
|
93
|
+
* }
|
|
94
|
+
* }]
|
|
95
|
+
* });
|
|
96
|
+
*/
|
|
97
|
+
export declare const KVNamespace: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<KVNamespace>, id: string, props: KVNamespaceProps) => Promise<KVNamespace>);
|
|
@@ -4,6 +4,42 @@ import { createCloudflareApi } from "./api";
|
|
|
4
4
|
export function isKVNamespace(resource) {
|
|
5
5
|
return (resource && typeof resource === "object" && resource.type === "kv_namespace");
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* A Cloudflare KV Namespace is a key-value store that can be used to store data for your application.
|
|
9
|
+
*
|
|
10
|
+
* @see https://developers.cloudflare.com/kv/concepts/kv-namespaces/
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Create a basic KV namespace for storing user data
|
|
14
|
+
* const users = await KVNamespace("users", {
|
|
15
|
+
* title: "user-data"
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Create a KV namespace with initial values and TTL
|
|
20
|
+
* const sessions = await KVNamespace("sessions", {
|
|
21
|
+
* title: "user-sessions",
|
|
22
|
+
* values: [{
|
|
23
|
+
* key: "session_123",
|
|
24
|
+
* value: { userId: "user_456", role: "admin" },
|
|
25
|
+
* expirationTtl: 3600 // Expires in 1 hour
|
|
26
|
+
* }]
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Create a KV namespace with metadata for caching
|
|
31
|
+
* const assets = await KVNamespace("assets", {
|
|
32
|
+
* title: "static-assets",
|
|
33
|
+
* values: [{
|
|
34
|
+
* key: "main.js",
|
|
35
|
+
* value: "content...",
|
|
36
|
+
* metadata: {
|
|
37
|
+
* contentType: "application/javascript",
|
|
38
|
+
* etag: "abc123"
|
|
39
|
+
* }
|
|
40
|
+
* }]
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
7
43
|
export const KVNamespace = Resource("cloudflare::KVNamespace", async function (id, props) {
|
|
8
44
|
// Create Cloudflare API client with automatic account discovery
|
|
9
45
|
const api = await createCloudflareApi();
|
|
@@ -157,4 +157,56 @@ export interface StaticSite extends Resource<"cloudflare::StaticSite"> {
|
|
|
157
157
|
*/
|
|
158
158
|
routes?: Record<string, string>;
|
|
159
159
|
}
|
|
160
|
-
|
|
160
|
+
/**
|
|
161
|
+
* A StaticSite resource deploys static web content to Cloudflare Workers, using KV for asset storage.
|
|
162
|
+
* It provides an efficient way to serve static websites with global distribution and caching.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* // Create a basic static site with default settings
|
|
166
|
+
* const basicSite = await StaticSite("my-site", {
|
|
167
|
+
* name: "my-site",
|
|
168
|
+
* dir: "./dist",
|
|
169
|
+
* url: true
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // Create a static site with custom build command and minification disabled
|
|
174
|
+
* const devSite = await StaticSite("dev-site", {
|
|
175
|
+
* name: "dev-site",
|
|
176
|
+
* dir: "./public",
|
|
177
|
+
* build: {
|
|
178
|
+
* command: "npm run build"
|
|
179
|
+
* },
|
|
180
|
+
* bundle: {
|
|
181
|
+
* minify: false
|
|
182
|
+
* }
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* // Create a static site with a backend API worker
|
|
187
|
+
* const backend = await Worker("api-backend", {
|
|
188
|
+
* name: "api-backend",
|
|
189
|
+
* entrypoint: "./src/api.ts"
|
|
190
|
+
* });
|
|
191
|
+
*
|
|
192
|
+
* const fullSite = await StaticSite("full-site", {
|
|
193
|
+
* name: "full-site",
|
|
194
|
+
* dir: "./dist",
|
|
195
|
+
* routes: {
|
|
196
|
+
* "/api/*": backend
|
|
197
|
+
* }
|
|
198
|
+
* });
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // Create a static site with custom error page and index
|
|
202
|
+
* const customSite = await StaticSite("custom-site", {
|
|
203
|
+
* name: "custom-site",
|
|
204
|
+
* dir: "./www",
|
|
205
|
+
* errorPage: "404.html",
|
|
206
|
+
* indexPage: "home.html",
|
|
207
|
+
* domain: "www.example.com"
|
|
208
|
+
* });
|
|
209
|
+
*
|
|
210
|
+
* @see https://developers.cloudflare.com/workers/platform/sites
|
|
211
|
+
*/
|
|
212
|
+
export declare const StaticSite: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<StaticSite>, id: string, props: StaticSiteProps) => Promise<StaticSite>);
|
|
@@ -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 { Resource } from "../resource";
|
|
6
6
|
import { createCloudflareApi } from "./api";
|
|
@@ -9,6 +9,58 @@ import { KVNamespace } from "./kv-namespace";
|
|
|
9
9
|
import { uploadAssetManifest } from "./upload-asset-manifest";
|
|
10
10
|
import { Worker } from "./worker";
|
|
11
11
|
const __dirname = import.meta.dirname;
|
|
12
|
+
/**
|
|
13
|
+
* A StaticSite resource deploys static web content to Cloudflare Workers, using KV for asset storage.
|
|
14
|
+
* It provides an efficient way to serve static websites with global distribution and caching.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Create a basic static site with default settings
|
|
18
|
+
* const basicSite = await StaticSite("my-site", {
|
|
19
|
+
* name: "my-site",
|
|
20
|
+
* dir: "./dist",
|
|
21
|
+
* url: true
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Create a static site with custom build command and minification disabled
|
|
26
|
+
* const devSite = await StaticSite("dev-site", {
|
|
27
|
+
* name: "dev-site",
|
|
28
|
+
* dir: "./public",
|
|
29
|
+
* build: {
|
|
30
|
+
* command: "npm run build"
|
|
31
|
+
* },
|
|
32
|
+
* bundle: {
|
|
33
|
+
* minify: false
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Create a static site with a backend API worker
|
|
39
|
+
* const backend = await Worker("api-backend", {
|
|
40
|
+
* name: "api-backend",
|
|
41
|
+
* entrypoint: "./src/api.ts"
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* const fullSite = await StaticSite("full-site", {
|
|
45
|
+
* name: "full-site",
|
|
46
|
+
* dir: "./dist",
|
|
47
|
+
* routes: {
|
|
48
|
+
* "/api/*": backend
|
|
49
|
+
* }
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Create a static site with custom error page and index
|
|
54
|
+
* const customSite = await StaticSite("custom-site", {
|
|
55
|
+
* name: "custom-site",
|
|
56
|
+
* dir: "./www",
|
|
57
|
+
* errorPage: "404.html",
|
|
58
|
+
* indexPage: "home.html",
|
|
59
|
+
* domain: "www.example.com"
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* @see https://developers.cloudflare.com/workers/platform/sites
|
|
63
|
+
*/
|
|
12
64
|
export const StaticSite = Resource("cloudflare::StaticSite", {
|
|
13
65
|
alwaysUpdate: true,
|
|
14
66
|
}, async function (id, props) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -105,4 +105,67 @@ export interface Worker<B extends Bindings = Bindings> extends Resource<"cloudfl
|
|
|
105
105
|
[bindingName in keyof B]: Bound<B[bindingName]>;
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
/**
|
|
109
|
+
* A Cloudflare Worker is a serverless function that can be deployed to the Cloudflare network.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Create a basic HTTP handler worker with custom domain routing
|
|
113
|
+
* // and workers.dev URL:
|
|
114
|
+
* const api = await Worker("api", {
|
|
115
|
+
* name: "api-worker",
|
|
116
|
+
* entrypoint: "./src/api.ts",
|
|
117
|
+
* routes: ["api.example.com/*"],
|
|
118
|
+
* url: true
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* // Create a real-time chat worker using Durable Objects
|
|
123
|
+
* // for state management:
|
|
124
|
+
* const chatRooms = new DurableObjectNamespace("chat-rooms");
|
|
125
|
+
* const userStore = new DurableObjectNamespace("user-store");
|
|
126
|
+
*
|
|
127
|
+
* const chat = await Worker("chat", {
|
|
128
|
+
* name: "chat-worker",
|
|
129
|
+
* entrypoint: "./src/chat.ts",
|
|
130
|
+
* bindings: {
|
|
131
|
+
* ROOMS: chatRooms,
|
|
132
|
+
* USERS: userStore
|
|
133
|
+
* },
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Create a worker with KV namespace for caching and data storage:
|
|
138
|
+
* const cache = await KVNamespace("cache-store");
|
|
139
|
+
* const settings = await KVNamespace("user-settings");
|
|
140
|
+
*
|
|
141
|
+
* const cacheWorker = await Worker("cache", {
|
|
142
|
+
* name: "cache-worker",
|
|
143
|
+
* entrypoint: "./src/cache.ts",
|
|
144
|
+
* bindings: {
|
|
145
|
+
* CACHE: cache,
|
|
146
|
+
* SETTINGS: settings
|
|
147
|
+
* }
|
|
148
|
+
* });
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // Create a worker with R2 bucket for object storage:
|
|
152
|
+
* const uploads = await R2Bucket("uploads", {
|
|
153
|
+
* name: "user-uploads"
|
|
154
|
+
* });
|
|
155
|
+
* const assets = await R2Bucket("assets", {
|
|
156
|
+
* name: "static-assets",
|
|
157
|
+
* allowPublicAccess: true
|
|
158
|
+
* });
|
|
159
|
+
*
|
|
160
|
+
* const storageWorker = await Worker("storage", {
|
|
161
|
+
* name: "storage-worker",
|
|
162
|
+
* entrypoint: "./src/storage.ts",
|
|
163
|
+
* bindings: {
|
|
164
|
+
* UPLOADS: uploads,
|
|
165
|
+
* ASSETS: assets
|
|
166
|
+
* }
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* @see https://developers.cloudflare.com/workers/
|
|
170
|
+
*/
|
|
171
|
+
export declare const Worker: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | (<const B extends Bindings>(this: Context<Worker<NoInfer<B>>>, id: string, props: WorkerProps<B>) => Promise<Worker<B>>);
|