@cloudflare/config 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.d.mts +620 -0
- package/dist/index.mjs +3699 -0
- package/dist/public-CFHebTo4.mjs +230 -0
- package/dist/public-YTdTOrcv.d.mts +1524 -0
- package/dist/public.d.mts +2 -0
- package/dist/public.mjs +3 -0
- package/package.json +52 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
//#region src/bindings.ts
|
|
2
|
+
const bindings = {
|
|
3
|
+
agentMemory: (options) => ({
|
|
4
|
+
type: "agent-memory",
|
|
5
|
+
...options
|
|
6
|
+
}),
|
|
7
|
+
ai: (options) => ({
|
|
8
|
+
type: "ai",
|
|
9
|
+
...options
|
|
10
|
+
}),
|
|
11
|
+
aiSearch: (options) => ({
|
|
12
|
+
type: "ai-search",
|
|
13
|
+
...options
|
|
14
|
+
}),
|
|
15
|
+
aiSearchNamespace: (options) => ({
|
|
16
|
+
type: "ai-search-namespace",
|
|
17
|
+
...options
|
|
18
|
+
}),
|
|
19
|
+
analyticsEngineDataset: (options) => ({
|
|
20
|
+
type: "analytics-engine-dataset",
|
|
21
|
+
...options
|
|
22
|
+
}),
|
|
23
|
+
artifacts: (options) => ({
|
|
24
|
+
type: "artifacts",
|
|
25
|
+
...options
|
|
26
|
+
}),
|
|
27
|
+
assets: () => ({ type: "assets" }),
|
|
28
|
+
browser: (options) => ({
|
|
29
|
+
type: "browser",
|
|
30
|
+
...options
|
|
31
|
+
}),
|
|
32
|
+
d1: (options) => ({
|
|
33
|
+
type: "d1",
|
|
34
|
+
...options
|
|
35
|
+
}),
|
|
36
|
+
dispatchNamespace: (options) => ({
|
|
37
|
+
type: "dispatch-namespace",
|
|
38
|
+
...options
|
|
39
|
+
}),
|
|
40
|
+
durableObject: (options) => ({
|
|
41
|
+
type: "durable-object",
|
|
42
|
+
...options
|
|
43
|
+
}),
|
|
44
|
+
flagship: (options) => ({
|
|
45
|
+
type: "flagship",
|
|
46
|
+
...options
|
|
47
|
+
}),
|
|
48
|
+
hyperdrive: (options) => ({
|
|
49
|
+
type: "hyperdrive",
|
|
50
|
+
...options
|
|
51
|
+
}),
|
|
52
|
+
images: (options) => ({
|
|
53
|
+
type: "images",
|
|
54
|
+
...options
|
|
55
|
+
}),
|
|
56
|
+
json: (value) => ({
|
|
57
|
+
type: "json",
|
|
58
|
+
value
|
|
59
|
+
}),
|
|
60
|
+
kv: (options) => ({
|
|
61
|
+
type: "kv",
|
|
62
|
+
...options
|
|
63
|
+
}),
|
|
64
|
+
logfwdr: (options) => ({
|
|
65
|
+
type: "logfwdr",
|
|
66
|
+
...options
|
|
67
|
+
}),
|
|
68
|
+
media: (options) => ({
|
|
69
|
+
type: "media",
|
|
70
|
+
...options
|
|
71
|
+
}),
|
|
72
|
+
mtlsCertificate: (options) => ({
|
|
73
|
+
type: "mtls-certificate",
|
|
74
|
+
...options
|
|
75
|
+
}),
|
|
76
|
+
pipeline: (options) => ({
|
|
77
|
+
type: "pipeline",
|
|
78
|
+
...options
|
|
79
|
+
}),
|
|
80
|
+
queue: (options) => ({
|
|
81
|
+
type: "queue",
|
|
82
|
+
...options
|
|
83
|
+
}),
|
|
84
|
+
rateLimit: (options) => ({
|
|
85
|
+
type: "rate-limit",
|
|
86
|
+
...options
|
|
87
|
+
}),
|
|
88
|
+
r2: (options) => ({
|
|
89
|
+
type: "r2",
|
|
90
|
+
...options
|
|
91
|
+
}),
|
|
92
|
+
secret: () => ({ type: "secret" }),
|
|
93
|
+
secretsStoreSecret: (options) => ({
|
|
94
|
+
type: "secrets-store-secret",
|
|
95
|
+
...options
|
|
96
|
+
}),
|
|
97
|
+
sendEmail: (options) => ({
|
|
98
|
+
type: "send-email",
|
|
99
|
+
...options
|
|
100
|
+
}),
|
|
101
|
+
stream: (options) => ({
|
|
102
|
+
type: "stream",
|
|
103
|
+
...options
|
|
104
|
+
}),
|
|
105
|
+
text: (value) => ({
|
|
106
|
+
type: "text",
|
|
107
|
+
value
|
|
108
|
+
}),
|
|
109
|
+
vectorize: (options) => ({
|
|
110
|
+
type: "vectorize",
|
|
111
|
+
...options
|
|
112
|
+
}),
|
|
113
|
+
versionMetadata: () => ({ type: "version-metadata" }),
|
|
114
|
+
vpcService: (options) => ({
|
|
115
|
+
type: "vpc-service",
|
|
116
|
+
...options
|
|
117
|
+
}),
|
|
118
|
+
vpcNetwork: (options) => ({
|
|
119
|
+
type: "vpc-network",
|
|
120
|
+
...options
|
|
121
|
+
}),
|
|
122
|
+
webSearch: (options) => ({
|
|
123
|
+
type: "web-search",
|
|
124
|
+
...options
|
|
125
|
+
}),
|
|
126
|
+
worker: (options) => ({
|
|
127
|
+
type: "worker",
|
|
128
|
+
...options
|
|
129
|
+
}),
|
|
130
|
+
workerLoader: () => ({ type: "worker-loader" })
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/triggers.ts
|
|
135
|
+
/**
|
|
136
|
+
* Triggers builder for configuring event triggers.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* import { defineWorker, triggers } from "@cloudflare/config";
|
|
141
|
+
*
|
|
142
|
+
* export default defineWorker({
|
|
143
|
+
* triggers: [
|
|
144
|
+
* triggers.fetch({ pattern: "example.com/*", zone: "example.com" }),
|
|
145
|
+
* triggers.queue({ name: "my-queue" }),
|
|
146
|
+
* triggers.scheduled({ schedule: "0 * * * *" }),
|
|
147
|
+
* triggers.scheduled({ schedule: "30 0 * * *" }),
|
|
148
|
+
* ],
|
|
149
|
+
* });
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
const triggers = {
|
|
153
|
+
fetch: (options) => ({
|
|
154
|
+
type: "fetch",
|
|
155
|
+
...options
|
|
156
|
+
}),
|
|
157
|
+
queue: (options) => ({
|
|
158
|
+
type: "queue",
|
|
159
|
+
...options
|
|
160
|
+
}),
|
|
161
|
+
scheduled: (options) => ({
|
|
162
|
+
type: "scheduled",
|
|
163
|
+
...options
|
|
164
|
+
})
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/exports.ts
|
|
169
|
+
function durableObject(options) {
|
|
170
|
+
return {
|
|
171
|
+
type: "durable-object",
|
|
172
|
+
...options
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function worker(options = {}) {
|
|
176
|
+
return {
|
|
177
|
+
type: "worker",
|
|
178
|
+
...options
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Exports builder for configuring Worker exports.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* import { defineWorker, exports } from "@cloudflare/config";
|
|
187
|
+
*
|
|
188
|
+
* export default defineWorker({
|
|
189
|
+
* exports: {
|
|
190
|
+
* MyDurableObject: exports.durableObject({ storage: "sqlite" }),
|
|
191
|
+
* OldClass: exports.durableObject({ state: "deleted" }),
|
|
192
|
+
* OldName: exports.durableObject({ state: "renamed", renamedTo: "NewName" }),
|
|
193
|
+
* Outgoing: exports.durableObject({ state: "transferred", transferredTo: "target-worker" }),
|
|
194
|
+
* Incoming: exports.durableObject({ state: "expecting-transfer", storage: "sqlite", transferFrom: "source-worker" }),
|
|
195
|
+
* },
|
|
196
|
+
* });
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
const exports = {
|
|
200
|
+
durableObject,
|
|
201
|
+
worker
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/worker-definition.ts
|
|
206
|
+
const CONFIG = Symbol.for("@cloudflare/config:worker-config");
|
|
207
|
+
function defineWorker(config) {
|
|
208
|
+
return {
|
|
209
|
+
[CONFIG]: config,
|
|
210
|
+
durableObject(options) {
|
|
211
|
+
return {
|
|
212
|
+
type: "durable-object",
|
|
213
|
+
...options
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
worker(options) {
|
|
217
|
+
return {
|
|
218
|
+
type: "worker",
|
|
219
|
+
...options
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
async function resolveWorkerDefinition(def, ctx) {
|
|
225
|
+
const raw = typeof def === "object" && def !== null && CONFIG in def ? def[CONFIG] : def;
|
|
226
|
+
return await (typeof raw === "function" ? raw(ctx) : raw);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
export { bindings as a, triggers as i, resolveWorkerDefinition as n, exports as r, defineWorker as t };
|