alchemy 0.1.16 → 0.1.17
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/$.d.ts +12 -0
- package/lib/$.d.ts.map +1 -0
- package/lib/$.js +42 -0
- package/lib/$.js.map +1 -0
- package/lib/alchemize.d.ts +43 -0
- package/lib/alchemize.d.ts.map +1 -0
- package/lib/alchemize.js +112 -0
- package/lib/alchemize.js.map +1 -0
- package/lib/apply.d.ts +23 -0
- package/lib/aws/account-id.d.ts +5 -0
- package/lib/aws/account-id.d.ts.map +1 -0
- package/lib/aws/account-id.js +10 -0
- package/lib/aws/account-id.js.map +1 -0
- package/lib/aws/bucket.d.ts +21 -0
- package/lib/aws/bucket.d.ts.map +1 -0
- package/lib/aws/bucket.js +114 -0
- package/lib/aws/bucket.js.map +1 -0
- package/lib/aws/function.d.ts +53 -0
- package/lib/aws/function.d.ts.map +1 -0
- package/lib/aws/function.js +195 -0
- package/lib/aws/function.js.map +1 -0
- package/lib/aws/index.d.ts +9 -0
- package/lib/aws/index.d.ts.map +1 -0
- package/lib/aws/index.js +9 -0
- package/lib/aws/index.js.map +1 -0
- package/lib/aws/oidc/github-oidc-provider.d.ts +11 -0
- package/lib/aws/oidc/github-oidc-provider.d.ts.map +1 -0
- package/lib/aws/oidc/github-oidc-provider.js +22 -0
- package/lib/aws/oidc/github-oidc-provider.js.map +1 -0
- package/lib/aws/oidc/index.d.ts +3 -0
- package/lib/aws/oidc/index.d.ts.map +1 -0
- package/lib/aws/oidc/index.js +3 -0
- package/lib/aws/oidc/index.js.map +1 -0
- package/lib/aws/oidc/oidc-provider.d.ts +60 -0
- package/lib/aws/oidc/oidc-provider.d.ts.map +1 -0
- package/lib/aws/oidc/oidc-provider.js +140 -0
- package/lib/aws/oidc/oidc-provider.js.map +1 -0
- package/lib/aws/policy.d.ts +46 -0
- package/lib/aws/policy.d.ts.map +1 -0
- package/lib/aws/policy.js +139 -0
- package/lib/aws/policy.js.map +1 -0
- package/lib/aws/queue.d.ts +62 -0
- package/lib/aws/queue.d.ts.map +1 -0
- package/lib/aws/queue.js +167 -0
- package/lib/aws/queue.js.map +1 -0
- package/lib/aws/role.d.ts +27 -0
- package/lib/aws/role.d.ts.map +1 -0
- package/lib/aws/role.js +197 -0
- package/lib/aws/role.js.map +1 -0
- package/lib/aws/ses.d.ts +75 -0
- package/lib/aws/ses.d.ts.map +1 -0
- package/lib/aws/ses.js +189 -0
- package/lib/aws/ses.js.map +1 -0
- package/lib/aws/table.d.ts +26 -0
- package/lib/aws/table.d.ts.map +1 -0
- package/lib/aws/table.js +154 -0
- package/lib/aws/table.js.map +1 -0
- package/lib/cloudflare/api.d.ts +88 -0
- package/lib/cloudflare/api.d.ts.map +1 -0
- package/lib/cloudflare/api.js +184 -0
- package/lib/cloudflare/api.js.map +1 -0
- package/lib/cloudflare/asset-manifest.d.ts +15 -0
- package/lib/cloudflare/asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/asset-manifest.js +2 -0
- package/lib/cloudflare/asset-manifest.js.map +1 -0
- package/lib/cloudflare/auth.d.ts +52 -0
- package/lib/cloudflare/auth.d.ts.map +1 -0
- package/lib/cloudflare/auth.js +114 -0
- package/lib/cloudflare/auth.js.map +1 -0
- package/lib/cloudflare/bindings.d.ts +260 -0
- package/lib/cloudflare/bindings.d.ts.map +1 -0
- package/lib/cloudflare/bindings.js +2 -0
- package/lib/cloudflare/bindings.js.map +1 -0
- package/lib/cloudflare/bucket.d.ts +54 -0
- package/lib/cloudflare/bucket.d.ts.map +1 -0
- package/lib/cloudflare/bucket.js +120 -0
- package/lib/cloudflare/bucket.js.map +1 -0
- package/lib/cloudflare/durable-object-namespace.d.ts +20 -0
- package/lib/cloudflare/durable-object-namespace.d.ts.map +1 -0
- package/lib/cloudflare/durable-object-namespace.js +21 -0
- package/lib/cloudflare/durable-object-namespace.js.map +1 -0
- package/lib/cloudflare/generate-asset-manifest.d.ts +3 -0
- package/lib/cloudflare/generate-asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/generate-asset-manifest.js +69 -0
- package/lib/cloudflare/generate-asset-manifest.js.map +1 -0
- package/lib/cloudflare/index.d.ts +8 -0
- package/lib/cloudflare/index.d.ts.map +1 -0
- package/lib/cloudflare/index.js +8 -0
- package/lib/cloudflare/index.js.map +1 -0
- package/lib/cloudflare/kv-namespace.d.ts +64 -0
- package/lib/cloudflare/kv-namespace.d.ts.map +1 -0
- package/lib/cloudflare/kv-namespace.js +114 -0
- package/lib/cloudflare/kv-namespace.js.map +1 -0
- package/lib/cloudflare/state.d.ts +83 -0
- package/lib/cloudflare/state.d.ts.map +1 -0
- package/lib/cloudflare/state.js +109 -0
- package/lib/cloudflare/state.js.map +1 -0
- package/lib/cloudflare/static-site-router.d.ts +19 -0
- package/lib/cloudflare/static-site-router.d.ts.map +1 -0
- package/lib/cloudflare/static-site-router.js +110 -0
- package/lib/cloudflare/static-site-router.js.map +1 -0
- package/lib/cloudflare/static-site.d.ts +166 -0
- package/lib/cloudflare/static-site.d.ts.map +1 -0
- package/lib/cloudflare/static-site.js +161 -0
- package/lib/cloudflare/static-site.js.map +1 -0
- package/lib/cloudflare/types.d.ts +52 -0
- package/lib/cloudflare/types.d.ts.map +1 -0
- package/lib/cloudflare/types.js +21 -0
- package/lib/cloudflare/types.js.map +1 -0
- package/lib/cloudflare/upload-asset-manifest.d.ts +12 -0
- package/lib/cloudflare/upload-asset-manifest.d.ts.map +1 -0
- package/lib/cloudflare/upload-asset-manifest.js +55 -0
- package/lib/cloudflare/upload-asset-manifest.js.map +1 -0
- package/lib/cloudflare/worker-metadata.d.ts +130 -0
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -0
- package/lib/cloudflare/worker-metadata.js +2 -0
- package/lib/cloudflare/worker-metadata.js.map +1 -0
- package/lib/cloudflare/worker-migration.d.ts +110 -0
- package/lib/cloudflare/worker-migration.d.ts.map +1 -0
- package/lib/cloudflare/worker-migration.js +11 -0
- package/lib/cloudflare/worker-migration.js.map +1 -0
- package/lib/cloudflare/worker.d.ts +108 -0
- package/lib/cloudflare/worker.d.ts.map +1 -0
- package/lib/cloudflare/worker.js +407 -0
- package/lib/cloudflare/worker.js.map +1 -0
- package/lib/destroy.d.ts +19 -0
- package/lib/error.d.ts +2 -0
- package/lib/error.d.ts.map +1 -0
- package/lib/error.js +13 -0
- package/lib/error.js.map +1 -0
- package/lib/esbuild.d.ts +152 -0
- package/lib/esbuild.d.ts.map +1 -0
- package/lib/esbuild.js +67 -0
- package/lib/esbuild.js.map +1 -0
- package/lib/fs.d.ts +12 -0
- package/lib/fs.d.ts.map +1 -0
- package/lib/fs.js +41 -0
- package/lib/fs.js.map +1 -0
- package/lib/github/client.d.ts +34 -0
- package/lib/github/client.d.ts.map +1 -0
- package/lib/github/client.js +91 -0
- package/lib/github/client.js.map +1 -0
- package/lib/github/index.d.ts +2 -0
- package/lib/github/index.d.ts.map +1 -0
- package/lib/github/index.js +2 -0
- package/lib/github/index.js.map +1 -0
- package/lib/github/secret.d.ts +46 -0
- package/lib/github/secret.d.ts.map +1 -0
- package/lib/github/secret.js +103 -0
- package/lib/github/secret.js.map +1 -0
- package/lib/global.d.ts +16 -0
- package/lib/global.d.ts.map +1 -0
- package/lib/global.js +42 -0
- package/lib/global.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/lib/input.d.ts +6 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +2 -0
- package/lib/input.js.map +1 -0
- package/lib/main.d.ts +3 -0
- package/lib/main.d.ts.map +1 -0
- package/lib/main.js +32 -0
- package/lib/main.js.map +1 -0
- package/lib/output.d.ts +24 -0
- package/lib/output.d.ts.map +1 -0
- package/lib/output.js +23 -0
- package/lib/output.js.map +1 -0
- package/lib/print.d.ts +7 -0
- package/lib/print.d.ts.map +1 -0
- package/lib/print.js +10 -0
- package/lib/print.js.map +1 -0
- package/lib/resource.d.ts +71 -0
- package/lib/resource.d.ts.map +1 -0
- package/lib/resource.js +276 -0
- package/lib/resource.js.map +1 -0
- package/lib/scope.d.ts +18 -0
- package/lib/scope.d.ts.map +1 -0
- package/lib/scope.js +30 -0
- package/lib/scope.js.map +1 -0
- package/lib/slug.d.ts +2 -0
- package/lib/slug.d.ts.map +1 -0
- package/lib/slug.js +4 -0
- package/lib/slug.js.map +1 -0
- package/lib/state.d.ts +40 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +73 -0
- package/lib/state.js.map +1 -0
- package/lib/stripe/index.d.ts +4 -0
- package/lib/stripe/index.d.ts.map +1 -0
- package/lib/stripe/index.js +4 -0
- package/lib/stripe/index.js.map +1 -0
- package/lib/stripe/price.d.ts +109 -0
- package/lib/stripe/price.d.ts.map +1 -0
- package/lib/stripe/price.js +112 -0
- package/lib/stripe/price.js.map +1 -0
- package/lib/stripe/product.d.ts +86 -0
- package/lib/stripe/product.d.ts.map +1 -0
- package/lib/stripe/product.js +90 -0
- package/lib/stripe/product.js.map +1 -0
- package/lib/stripe/webhook.d.ts +73 -0
- package/lib/stripe/webhook.d.ts.map +1 -0
- package/lib/stripe/webhook.js +94 -0
- package/lib/stripe/webhook.js.map +1 -0
- package/lib/utils/content-type.d.ts +8 -0
- package/lib/utils/content-type.d.ts.map +1 -0
- package/lib/utils/content-type.js +41 -0
- package/lib/utils/content-type.js.map +1 -0
- package/lib/utils/retry.d.ts +13 -0
- package/lib/utils/retry.d.ts.map +1 -0
- package/lib/utils/retry.js +32 -0
- package/lib/utils/retry.js.map +1 -0
- package/package.json +1 -1
- package/src/cloudflare/bindings.ts +7 -1
- package/src/cloudflare/bucket.ts +240 -0
- package/src/cloudflare/index.ts +1 -0
- package/src/cloudflare/static-site.ts +13 -1
- package/src/cloudflare/worker.ts +7 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { getCloudflareHeaders } from "./auth";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a CloudflareApi instance with automatic account ID discovery if not provided
|
|
4
|
+
*
|
|
5
|
+
* @param options API options
|
|
6
|
+
* @returns Promise resolving to a CloudflareApi instance
|
|
7
|
+
*/
|
|
8
|
+
export async function createCloudflareApi(options = {}) {
|
|
9
|
+
try {
|
|
10
|
+
return new CloudflareApi({
|
|
11
|
+
...options,
|
|
12
|
+
accountId: options.accountId ||
|
|
13
|
+
process.env.CLOUDFLARE_ACCOUNT_ID ||
|
|
14
|
+
(await fetchAccountId()),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error("Error during Cloudflare account ID discovery:", error);
|
|
19
|
+
throw new Error("Failed to automatically discover Cloudflare account ID. Please provide an account ID explicitly or ensure your API token/key has sufficient permissions.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Cloudflare API client using raw fetch
|
|
24
|
+
*/
|
|
25
|
+
export class CloudflareApi {
|
|
26
|
+
/** Base URL for Cloudflare API */
|
|
27
|
+
baseUrl;
|
|
28
|
+
/** Cloudflare API Key */
|
|
29
|
+
apiKey;
|
|
30
|
+
/** Cloudflare account ID */
|
|
31
|
+
accountId;
|
|
32
|
+
/** Cloudflare zone ID (if provided) */
|
|
33
|
+
zoneId;
|
|
34
|
+
/** User email (when using API Key auth) */
|
|
35
|
+
email;
|
|
36
|
+
/** Auth options for making requests */
|
|
37
|
+
authOptions;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new Cloudflare API client
|
|
40
|
+
* Use createCloudflareApi factory function instead of direct constructor
|
|
41
|
+
* for automatic account ID discovery.
|
|
42
|
+
*
|
|
43
|
+
* @param options API options
|
|
44
|
+
*/
|
|
45
|
+
constructor(options = {}) {
|
|
46
|
+
this.baseUrl = "https://api.cloudflare.com/client/v4";
|
|
47
|
+
const apiKey = options.apiKey || process.env.CLOUDFLARE_API_KEY || undefined;
|
|
48
|
+
if (!apiKey) {
|
|
49
|
+
throw new Error("No API key provided. Use createCloudflareApi() instead for automatic account discovery.");
|
|
50
|
+
}
|
|
51
|
+
this.apiKey = apiKey;
|
|
52
|
+
this.email = options.email || process.env.CLOUDFLARE_EMAIL;
|
|
53
|
+
if (!this.email) {
|
|
54
|
+
throw new Error("No email provided. Use createCloudflareApi() instead for automatic account discovery.");
|
|
55
|
+
}
|
|
56
|
+
// Get account ID from options or environment
|
|
57
|
+
this.accountId =
|
|
58
|
+
options.accountId || process.env.CLOUDFLARE_ACCOUNT_ID || "";
|
|
59
|
+
if (!this.accountId) {
|
|
60
|
+
throw new Error("No account ID provided. Use createCloudflareApi() instead for automatic account discovery.");
|
|
61
|
+
}
|
|
62
|
+
// Zone ID is optional for some operations
|
|
63
|
+
this.zoneId = options.zoneId || process.env.CLOUDFLARE_ZONE_ID || null;
|
|
64
|
+
// Store auth options for later use
|
|
65
|
+
this.authOptions = {
|
|
66
|
+
email: this.email,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Make a fetch request to the Cloudflare API
|
|
71
|
+
*
|
|
72
|
+
* @param path API path (without base URL)
|
|
73
|
+
* @param init Fetch init options
|
|
74
|
+
* @returns Raw Response object from fetch
|
|
75
|
+
*/
|
|
76
|
+
async fetch(path, init = {}) {
|
|
77
|
+
// Get content type from init headers or default to application/json
|
|
78
|
+
let contentType = "application/json";
|
|
79
|
+
if (init.headers) {
|
|
80
|
+
const initHeaders = init.headers;
|
|
81
|
+
if (initHeaders["Content-Type"]) {
|
|
82
|
+
contentType = initHeaders["Content-Type"];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Get auth headers (async now)
|
|
86
|
+
const authHeaders = await getCloudflareHeaders(contentType, this.authOptions);
|
|
87
|
+
// Combine all headers
|
|
88
|
+
const combinedHeaders = {
|
|
89
|
+
...authHeaders,
|
|
90
|
+
};
|
|
91
|
+
// Add headers from init if provided
|
|
92
|
+
if (init.headers) {
|
|
93
|
+
const initHeadersObj = init.headers;
|
|
94
|
+
Object.keys(initHeadersObj).forEach((key) => {
|
|
95
|
+
combinedHeaders[key] = initHeadersObj[key];
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
// If using FormData, remove Content-Type to let browser set it with boundary
|
|
99
|
+
if (init.body instanceof FormData) {
|
|
100
|
+
delete combinedHeaders["Content-Type"];
|
|
101
|
+
}
|
|
102
|
+
const url = `${this.baseUrl}${path}`;
|
|
103
|
+
// Make the request
|
|
104
|
+
return fetch(url, {
|
|
105
|
+
...init,
|
|
106
|
+
headers: combinedHeaders,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Helper for GET requests
|
|
111
|
+
*/
|
|
112
|
+
async get(path, init = {}) {
|
|
113
|
+
return this.fetch(path, { ...init, method: "GET" });
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Helper for HEAD requests
|
|
117
|
+
*/
|
|
118
|
+
async head(path, init = {}) {
|
|
119
|
+
return this.fetch(path, { ...init, method: "HEAD" });
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Helper for POST requests
|
|
123
|
+
*/
|
|
124
|
+
async post(path, body, init = {}) {
|
|
125
|
+
const requestBody = body instanceof FormData
|
|
126
|
+
? body
|
|
127
|
+
: typeof body === "string"
|
|
128
|
+
? body
|
|
129
|
+
: JSON.stringify(body);
|
|
130
|
+
return this.fetch(path, { ...init, method: "POST", body: requestBody });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Helper for PUT requests
|
|
134
|
+
*/
|
|
135
|
+
async put(path, body, init = {}) {
|
|
136
|
+
const requestBody = body instanceof FormData ? body : JSON.stringify(body);
|
|
137
|
+
return this.fetch(path, { ...init, method: "PUT", body: requestBody });
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Helper for PATCH requests
|
|
141
|
+
*/
|
|
142
|
+
async patch(path, body, init = {}) {
|
|
143
|
+
return this.fetch(path, {
|
|
144
|
+
...init,
|
|
145
|
+
method: "PATCH",
|
|
146
|
+
body: JSON.stringify(body),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Helper for DELETE requests
|
|
151
|
+
*/
|
|
152
|
+
async delete(path, init = {}) {
|
|
153
|
+
return this.fetch(path, { ...init, method: "DELETE" });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Create a temporary API client for bootstrapping
|
|
158
|
+
* This client can only be used to fetch the account ID
|
|
159
|
+
*/
|
|
160
|
+
async function fetchAccountId() {
|
|
161
|
+
// Create a minimal API client for bootstrapping
|
|
162
|
+
const baseUrl = "https://api.cloudflare.com/client/v4";
|
|
163
|
+
// Get content type and auth headers
|
|
164
|
+
const authHeaders = await getCloudflareHeaders("application/json");
|
|
165
|
+
// Make the request to get accounts
|
|
166
|
+
const response = await fetch(`${baseUrl}/accounts`, {
|
|
167
|
+
method: "GET",
|
|
168
|
+
headers: authHeaders,
|
|
169
|
+
});
|
|
170
|
+
if (!response.ok) {
|
|
171
|
+
const errorData = await response.json().catch(() => ({
|
|
172
|
+
errors: [{ message: response.statusText }],
|
|
173
|
+
}));
|
|
174
|
+
throw new Error(`Error fetching Cloudflare accounts: ${errorData.errors?.[0]?.message || response.statusText}`);
|
|
175
|
+
}
|
|
176
|
+
const data = await response.json();
|
|
177
|
+
const accounts = data.result;
|
|
178
|
+
if (!accounts || accounts.length === 0) {
|
|
179
|
+
throw new Error("No Cloudflare accounts found. Check your API token/key permissions.");
|
|
180
|
+
}
|
|
181
|
+
// Return the first account ID
|
|
182
|
+
return accounts[0].id;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/cloudflare/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAqC1E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC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AC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAA6B,CAAC;IAEpD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type AssetManifest = AssetManifestEntry[];
|
|
2
|
+
export interface AssetManifestEntry {
|
|
3
|
+
source: string;
|
|
4
|
+
key: string;
|
|
5
|
+
hash: string;
|
|
6
|
+
cacheControl: string;
|
|
7
|
+
contentType?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface FileOption {
|
|
10
|
+
files: string | string[];
|
|
11
|
+
cacheControl: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
ignore?: string[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=asset-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-manifest.d.ts","sourceRoot":"","sources":["../../src/cloudflare/asset-manifest.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-manifest.js","sourceRoot":"","sources":["../../src/cloudflare/asset-manifest.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication options for Cloudflare API
|
|
3
|
+
*/
|
|
4
|
+
export interface CloudflareAuthOptions {
|
|
5
|
+
/**
|
|
6
|
+
* If true, throw an error when no authentication is found
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
required?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Email to use with API Key
|
|
12
|
+
* If not provided, will attempt to discover from Cloudflare API
|
|
13
|
+
*/
|
|
14
|
+
email?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Authentication headers for Cloudflare API
|
|
18
|
+
*/
|
|
19
|
+
export interface CloudflareAuthHeaders {
|
|
20
|
+
/**
|
|
21
|
+
* Authentication headers to use with fetch
|
|
22
|
+
*/
|
|
23
|
+
headers: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Type of authentication being used
|
|
26
|
+
*/
|
|
27
|
+
type: "token" | "key" | "none";
|
|
28
|
+
/**
|
|
29
|
+
* User email (only present when using API Key auth)
|
|
30
|
+
*/
|
|
31
|
+
email?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get authentication headers for Cloudflare API
|
|
35
|
+
*
|
|
36
|
+
* Priority:
|
|
37
|
+
* 1. API Token (CLOUDFLARE_API_TOKEN) - Recommended by Cloudflare
|
|
38
|
+
* 2. API Key (CLOUDFLARE_API_KEY) - Will attempt to discover email automatically
|
|
39
|
+
*
|
|
40
|
+
* @param options Authentication options
|
|
41
|
+
* @returns Authentication headers
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCloudflareAuth(options?: CloudflareAuthOptions): Promise<CloudflareAuthHeaders>;
|
|
44
|
+
/**
|
|
45
|
+
* Get headers for a Cloudflare API request, including content-type
|
|
46
|
+
*
|
|
47
|
+
* @param contentType Content type for the request
|
|
48
|
+
* @param options Authentication options
|
|
49
|
+
* @returns Complete headers for the request
|
|
50
|
+
*/
|
|
51
|
+
export declare function getCloudflareHeaders(contentType?: string, options?: CloudflareAuthOptions): Promise<Record<string, string>>;
|
|
52
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/cloudflare/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,qBAAqB,CAAC,CAkEhC;AAyCD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,SAAqB,EAChC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAOjC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get authentication headers for Cloudflare API
|
|
3
|
+
*
|
|
4
|
+
* Priority:
|
|
5
|
+
* 1. API Token (CLOUDFLARE_API_TOKEN) - Recommended by Cloudflare
|
|
6
|
+
* 2. API Key (CLOUDFLARE_API_KEY) - Will attempt to discover email automatically
|
|
7
|
+
*
|
|
8
|
+
* @param options Authentication options
|
|
9
|
+
* @returns Authentication headers
|
|
10
|
+
*/
|
|
11
|
+
export async function getCloudflareAuth(options = {}) {
|
|
12
|
+
const { required = true } = options;
|
|
13
|
+
// Check for API Token (preferred method)
|
|
14
|
+
const apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
15
|
+
if (apiToken) {
|
|
16
|
+
return {
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${apiToken}`,
|
|
19
|
+
},
|
|
20
|
+
type: "token",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Check for API Key
|
|
24
|
+
const apiKey = process.env.CLOUDFLARE_API_KEY;
|
|
25
|
+
if (apiKey) {
|
|
26
|
+
// If email is provided directly, use it
|
|
27
|
+
const providedEmail = options.email || process.env.CLOUDFLARE_EMAIL;
|
|
28
|
+
if (providedEmail) {
|
|
29
|
+
return {
|
|
30
|
+
headers: {
|
|
31
|
+
"X-Auth-Key": apiKey,
|
|
32
|
+
"X-Auth-Email": providedEmail,
|
|
33
|
+
},
|
|
34
|
+
type: "key",
|
|
35
|
+
email: providedEmail,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Otherwise, try to discover email from Cloudflare API
|
|
39
|
+
try {
|
|
40
|
+
const email = await getUserEmailFromApiKey(apiKey);
|
|
41
|
+
return {
|
|
42
|
+
headers: {
|
|
43
|
+
"X-Auth-Key": apiKey,
|
|
44
|
+
"X-Auth-Email": email,
|
|
45
|
+
},
|
|
46
|
+
type: "key",
|
|
47
|
+
email,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error("Failed to discover email from API key:", error);
|
|
52
|
+
throw new Error("Failed to automatically discover email for API Key authentication.\n" +
|
|
53
|
+
"Options:\n" +
|
|
54
|
+
"1. Set CLOUDFLARE_EMAIL environment variable\n" +
|
|
55
|
+
"2. Use CLOUDFLARE_API_TOKEN instead (recommended by Cloudflare)");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// No authentication found
|
|
59
|
+
if (required) {
|
|
60
|
+
throw new Error("Cloudflare authentication required. Set either:\n" +
|
|
61
|
+
"1. CLOUDFLARE_API_TOKEN (recommended by Cloudflare)\n" +
|
|
62
|
+
" Generate a token at: https://dash.cloudflare.com/profile/api-tokens\n" +
|
|
63
|
+
"2. CLOUDFLARE_API_KEY environment variable");
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
headers: {},
|
|
67
|
+
type: "none",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Fetch the user's email from Cloudflare API using API Key
|
|
72
|
+
*
|
|
73
|
+
* @param apiKey The Cloudflare API key
|
|
74
|
+
* @returns The user's email
|
|
75
|
+
*/
|
|
76
|
+
async function getUserEmailFromApiKey(apiKey) {
|
|
77
|
+
try {
|
|
78
|
+
const baseUrl = "https://api.cloudflare.com/client/v4";
|
|
79
|
+
// Call the /user endpoint to get user information
|
|
80
|
+
const response = await fetch(`${baseUrl}/user`, {
|
|
81
|
+
headers: {
|
|
82
|
+
"Content-Type": "application/json",
|
|
83
|
+
"X-Auth-Key": apiKey,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new Error(`Failed to get user information: ${response.status} ${response.statusText}`);
|
|
88
|
+
}
|
|
89
|
+
const data = (await response.json());
|
|
90
|
+
if (!data.success || !data.result || !data.result.email) {
|
|
91
|
+
throw new Error("Cloudflare API did not return valid user information");
|
|
92
|
+
}
|
|
93
|
+
return data.result.email;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error("Error retrieving email from Cloudflare API:", error);
|
|
97
|
+
throw new Error("Failed to automatically discover email for API Key authentication");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get headers for a Cloudflare API request, including content-type
|
|
102
|
+
*
|
|
103
|
+
* @param contentType Content type for the request
|
|
104
|
+
* @param options Authentication options
|
|
105
|
+
* @returns Complete headers for the request
|
|
106
|
+
*/
|
|
107
|
+
export async function getCloudflareHeaders(contentType = "application/json", options = {}) {
|
|
108
|
+
const auth = await getCloudflareAuth(options);
|
|
109
|
+
return {
|
|
110
|
+
"Content-Type": contentType,
|
|
111
|
+
...auth.headers,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/cloudflare/auth.ts"],"names":[],"mappings":"AAkDA;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAiC,EAAE;IAEnC,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEpC,yCAAyC;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAClD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,QAAQ,EAAE;aACpC;YACD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;IAED,oBAAoB;IACpB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC9C,IAAI,MAAM,EAAE,CAAC;QACX,wCAAwC;QACxC,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;QACpE,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE;oBACP,YAAY,EAAE,MAAM;oBACpB,cAAc,EAAE,aAAa;iBAC9B;gBACD,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,aAAa;aACrB,CAAC;QACJ,CAA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,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;QACpE,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,WAAW,GAAG,kBAAkB,EAChC,UAAiC,EAAE;IAEnC,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE9C,OAAO;QACL,cAAc,EAAE,WAAW;QAC3B,GAAG,IAAI,CAAC,OAAO;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Cloudflare Worker bindings
|
|
3
|
+
* Based on Cloudflare API documentation:
|
|
4
|
+
* https://developers.cloudflare.com/api/resources/workers/subresources/scripts/methods/update/
|
|
5
|
+
*/
|
|
6
|
+
import type { Bucket } from "./bucket";
|
|
7
|
+
import type { DurableObjectNamespace } from "./durable-object-namespace";
|
|
8
|
+
import type { KVNamespace } from "./kv-namespace";
|
|
9
|
+
import type { Worker } from "./worker";
|
|
10
|
+
export type Bindings = {
|
|
11
|
+
[bindingName: string]: Binding;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* L2 Binding Resources.
|
|
15
|
+
*/
|
|
16
|
+
export type Binding = DurableObjectNamespace | KVNamespace | Worker | Bucket | string;
|
|
17
|
+
/**
|
|
18
|
+
* Union type for all Worker binding types (API spec)
|
|
19
|
+
*/
|
|
20
|
+
export type WorkerBindingSpec = WorkerBindingAI | WorkerBindingAnalyticsEngine | WorkerBindingAssets | WorkerBindingBrowserRendering | WorkerBindingD1 | WorkerBindingDispatchNamespace | WorkerBindingDurableObjectNamespace | WorkerBindingHyperdrive | WorkerBindingJson | WorkerBindingKVNamespace | WorkerBindingMTLSCertificate | WorkerBindingPlainText | WorkerBindingQueue | WorkerBindingR2Bucket | WorkerBindingSecretText | WorkerBindingService | WorkerBindingStaticContent | WorkerBindingTailConsumer | WorkerBindingVectorize | WorkerBindingVersionMetadata | WorkerBindingWasmModule;
|
|
21
|
+
/**
|
|
22
|
+
* AI binding type
|
|
23
|
+
*/
|
|
24
|
+
export interface WorkerBindingAI {
|
|
25
|
+
/** The name of the binding */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Type identifier for AI binding */
|
|
28
|
+
type: "ai";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Analytics Engine binding type
|
|
32
|
+
*/
|
|
33
|
+
export interface WorkerBindingAnalyticsEngine {
|
|
34
|
+
/** The name of the binding */
|
|
35
|
+
name: string;
|
|
36
|
+
/** Type identifier for Analytics Engine binding */
|
|
37
|
+
type: "analytics_engine";
|
|
38
|
+
/** Dataset name */
|
|
39
|
+
dataset: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Assets binding type
|
|
43
|
+
*/
|
|
44
|
+
export interface WorkerBindingAssets {
|
|
45
|
+
/** The name of the binding */
|
|
46
|
+
name: string;
|
|
47
|
+
/** Type identifier for Assets binding */
|
|
48
|
+
type: "assets";
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Browser Rendering binding type
|
|
52
|
+
*/
|
|
53
|
+
export interface WorkerBindingBrowserRendering {
|
|
54
|
+
/** The name of the binding */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Type identifier for Browser Rendering binding */
|
|
57
|
+
type: "browser_rendering";
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* D1 database binding type
|
|
61
|
+
*/
|
|
62
|
+
export interface WorkerBindingD1 {
|
|
63
|
+
/** The name of the binding */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Type identifier for D1 binding */
|
|
66
|
+
type: "d1";
|
|
67
|
+
/** D1 database ID */
|
|
68
|
+
id: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Dispatch Namespace binding type
|
|
72
|
+
*/
|
|
73
|
+
export interface WorkerBindingDispatchNamespace {
|
|
74
|
+
/** The name of the binding */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Type identifier for Dispatch Namespace binding */
|
|
77
|
+
type: "dispatch_namespace";
|
|
78
|
+
/** Namespace identifier */
|
|
79
|
+
namespace: string;
|
|
80
|
+
/** Optional outbound service */
|
|
81
|
+
outbound?: any;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Durable Object Namespace binding type
|
|
85
|
+
*/
|
|
86
|
+
export interface WorkerBindingDurableObjectNamespace {
|
|
87
|
+
/**
|
|
88
|
+
* The stable ID of the binding
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
stableId?: string;
|
|
92
|
+
/** The name of the binding */
|
|
93
|
+
name: string;
|
|
94
|
+
/** Type identifier for Durable Object Namespace binding */
|
|
95
|
+
type: "durable_object_namespace";
|
|
96
|
+
/** Durable Object class name */
|
|
97
|
+
class_name: string;
|
|
98
|
+
/** Script name that contains the Durable Object */
|
|
99
|
+
script_name?: string;
|
|
100
|
+
/** Environment */
|
|
101
|
+
environment?: string;
|
|
102
|
+
/** Namespace ID */
|
|
103
|
+
namespace_id?: string;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Hyperdrive binding type
|
|
107
|
+
*/
|
|
108
|
+
export interface WorkerBindingHyperdrive {
|
|
109
|
+
/** The name of the binding */
|
|
110
|
+
name: string;
|
|
111
|
+
/** Type identifier for Hyperdrive binding */
|
|
112
|
+
type: "hyperdrive";
|
|
113
|
+
/** Hyperdrive ID */
|
|
114
|
+
id: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* JSON binding type
|
|
118
|
+
*/
|
|
119
|
+
export interface WorkerBindingJson {
|
|
120
|
+
/** The name of the binding */
|
|
121
|
+
name: string;
|
|
122
|
+
/** Type identifier for JSON binding */
|
|
123
|
+
type: "json";
|
|
124
|
+
/** JSON value */
|
|
125
|
+
json: any;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* KV Namespace binding type
|
|
129
|
+
*/
|
|
130
|
+
export interface WorkerBindingKVNamespace {
|
|
131
|
+
/** The name of the binding */
|
|
132
|
+
name: string;
|
|
133
|
+
/** Type identifier for KV Namespace binding */
|
|
134
|
+
type: "kv_namespace";
|
|
135
|
+
/** KV Namespace ID */
|
|
136
|
+
namespace_id: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* MTLS Certificate binding type
|
|
140
|
+
*/
|
|
141
|
+
export interface WorkerBindingMTLSCertificate {
|
|
142
|
+
/** The name of the binding */
|
|
143
|
+
name: string;
|
|
144
|
+
/** Type identifier for MTLS Certificate binding */
|
|
145
|
+
type: "mtls_certificate";
|
|
146
|
+
/** Certificate ID */
|
|
147
|
+
certificate_id: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Plain Text binding type
|
|
151
|
+
*/
|
|
152
|
+
export interface WorkerBindingPlainText {
|
|
153
|
+
/** The name of the binding */
|
|
154
|
+
name: string;
|
|
155
|
+
/** Type identifier for Plain Text binding */
|
|
156
|
+
type: "plain_text";
|
|
157
|
+
/** Text content */
|
|
158
|
+
text: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Queue binding type
|
|
162
|
+
*/
|
|
163
|
+
export interface WorkerBindingQueue {
|
|
164
|
+
/** The name of the binding */
|
|
165
|
+
name: string;
|
|
166
|
+
/** Type identifier for Queue binding */
|
|
167
|
+
type: "queue";
|
|
168
|
+
/** Queue name */
|
|
169
|
+
queue_name: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* R2 Bucket binding type
|
|
173
|
+
*/
|
|
174
|
+
export interface WorkerBindingR2Bucket {
|
|
175
|
+
/** The name of the binding */
|
|
176
|
+
name: string;
|
|
177
|
+
/** Type identifier for R2 Bucket binding */
|
|
178
|
+
type: "r2_bucket";
|
|
179
|
+
/** Bucket name */
|
|
180
|
+
bucket_name: string;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Secret Text binding type
|
|
184
|
+
*/
|
|
185
|
+
export interface WorkerBindingSecretText {
|
|
186
|
+
/** The name of the binding */
|
|
187
|
+
name: string;
|
|
188
|
+
/** Type identifier for Secret Text binding */
|
|
189
|
+
type: "secret_text";
|
|
190
|
+
/** Secret value */
|
|
191
|
+
text: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Service binding type
|
|
195
|
+
*/
|
|
196
|
+
export interface WorkerBindingService {
|
|
197
|
+
/** The name of the binding */
|
|
198
|
+
name: string;
|
|
199
|
+
/** Type identifier for Service binding */
|
|
200
|
+
type: "service";
|
|
201
|
+
/** Service name */
|
|
202
|
+
service: string;
|
|
203
|
+
/** Environment */
|
|
204
|
+
environment?: string;
|
|
205
|
+
/** Service namespace */
|
|
206
|
+
namespace?: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Tail Consumer binding type
|
|
210
|
+
*/
|
|
211
|
+
export interface WorkerBindingTailConsumer {
|
|
212
|
+
/** The name of the binding */
|
|
213
|
+
name: string;
|
|
214
|
+
/** Type identifier for Tail Consumer binding */
|
|
215
|
+
type: "tail_consumer";
|
|
216
|
+
/** Service name */
|
|
217
|
+
service: string;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Vectorize binding type
|
|
221
|
+
*/
|
|
222
|
+
export interface WorkerBindingVectorize {
|
|
223
|
+
/** The name of the binding */
|
|
224
|
+
name: string;
|
|
225
|
+
/** Type identifier for Vectorize binding */
|
|
226
|
+
type: "vectorize";
|
|
227
|
+
/** Index name */
|
|
228
|
+
index_name: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Version Metadata binding type
|
|
232
|
+
*/
|
|
233
|
+
export interface WorkerBindingVersionMetadata {
|
|
234
|
+
/** The name of the binding */
|
|
235
|
+
name: string;
|
|
236
|
+
/** Type identifier for Version Metadata binding */
|
|
237
|
+
type: "version_metadata";
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* WASM Module binding type
|
|
241
|
+
*/
|
|
242
|
+
export interface WorkerBindingWasmModule {
|
|
243
|
+
/** The name of the binding */
|
|
244
|
+
name: string;
|
|
245
|
+
/** Type identifier for WASM Module binding */
|
|
246
|
+
type: "wasm_module";
|
|
247
|
+
/** Module name */
|
|
248
|
+
module: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Static content binding for Cloudflare Workers
|
|
252
|
+
* Used for Workers Sites and static assets
|
|
253
|
+
*/
|
|
254
|
+
export interface WorkerBindingStaticContent {
|
|
255
|
+
/** The name of the binding */
|
|
256
|
+
name: string;
|
|
257
|
+
/** Type identifier for Static Content binding */
|
|
258
|
+
type: "static_content";
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../src/cloudflare/bindings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,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,WAAW,sBAAsB;IACrC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,EAAE,WAAW,CAAC;IAClB,iBAAiB;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,IAAI,EAAE,aAAa,CAAC;IACpB,kBAAkB;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,IAAI,EAAE,gBAAgB,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/cloudflare/bindings.ts"],"names":[],"mappings":""}
|