This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: supports non inheritable keys (#13)
* refactor: separate folder by whether they are inheritable or not * feat: add non inheritable properties * chore: changeset
- Loading branch information
Showing
25 changed files
with
250 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"twrangler": patch | ||
--- | ||
|
||
Supports non inheritable keys | ||
|
||
- Multi Environments Configuration | ||
- Bindings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { z } from "zod"; | ||
import { buildSchema } from "./build"; | ||
import { | ||
compatibilityDateSchema, | ||
compatibilityFlagsSchema, | ||
} from "./capability"; | ||
import { limitsSchema } from "./limits"; | ||
import { routeSchema, routesSchema } from "./route"; | ||
import { rulesSchema } from "./rule"; | ||
import { triggersSchema } from "./trigger"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#inheritable-keys | ||
export const inheritableKeysSchema = z.object({ | ||
name: z.string(), | ||
main: z.string(), | ||
compatibility_date: compatibilityDateSchema, | ||
account_id: z.string().optional(), | ||
compatibility_flags: compatibilityFlagsSchema.optional(), | ||
workers_dev: z.boolean().optional(), | ||
route: routeSchema.optional(), | ||
routes: routesSchema.optional(), | ||
tsconfig: z.string().optional(), | ||
triggers: triggersSchema.optional(), | ||
rules: rulesSchema.optional(), | ||
build: buildSchema.optional(), | ||
no_bundle: z.boolean().optional(), | ||
minify: z.boolean().optional(), | ||
node_compat: z.boolean().optional(), | ||
preserve_file_names: z.boolean().optional(), | ||
send_metrics: z.boolean().optional(), | ||
keep_vars: z.boolean().optional(), | ||
logpush: z.boolean().optional(), | ||
limits: limitsSchema.optional(), | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
packages/schema/src/trigger.ts → ...es/schema/src/inheritable-keys/trigger.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#triggers | ||
export const triggersSchema = z.object({ | ||
crons: z.array(z.string()), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai | ||
export const aiSchema = z.object({ | ||
binding: z.string(), | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/schema/src/non-inheritable-keys/bindings/analytics-engine-datasets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets | ||
export const analyticsEngineDatasetsSchema = z.array( | ||
z.object({ | ||
binding: z.string(), | ||
dataset: z.string().optional(), | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering | ||
export const browserSchema = z.object({ | ||
binding: z.string(), | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/schema/src/non-inheritable-keys/bindings/d1-database.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases | ||
const d1DatabaseSchema = z.object({ | ||
binding: z.string(), | ||
database_name: z.string(), | ||
database_id: z.string(), | ||
preview_database_id: z.string().optional(), | ||
}); | ||
|
||
export const d1DatabasesSchema = z.array(d1DatabaseSchema); |
7 changes: 7 additions & 0 deletions
7
packages/schema/src/non-inheritable-keys/bindings/dispatch-namespaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms | ||
export const dispatchNamespacesSchema = z.object({ | ||
binding: z.string(), | ||
namespace: z.string(), | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/schema/src/non-inheritable-keys/bindings/durable-object.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects | ||
const durableObjectsBindingsSchema = z.object({ | ||
name: z.string(), | ||
class_name: z.string(), | ||
script_name: z.string().optional(), | ||
environment: z.string().optional(), | ||
}); | ||
|
||
export const durableObjectsSchema = z.object({ | ||
bindings: z.record(durableObjectsBindingsSchema), | ||
}); | ||
|
||
export const migrationsSchema = z.object({ | ||
tag: z.string(), | ||
new_classes: z.array(z.string()).optional(), | ||
renamed_classes: z | ||
.array( | ||
z.object({ | ||
from: z.string(), | ||
to: z.string(), | ||
}), | ||
) | ||
.optional(), | ||
deleted_classes: z.array(z.string()).optional(), | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/schema/src/non-inheritable-keys/bindings/email.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings | ||
const emailSchema = z.object({ | ||
name: z.string(), | ||
destination_address: z.string().optional(), | ||
allowed_destination_addresses: z.array(z.string()).optional(), | ||
}); | ||
|
||
export const sendEmailSchema = z.array(emailSchema); |
7 changes: 7 additions & 0 deletions
7
packages/schema/src/non-inheritable-keys/bindings/hyperdrive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#email-bindings | ||
export const hyperdriveSchema = z.object({ | ||
binding: z.string(), | ||
id: z.string(), | ||
}); |
33 changes: 33 additions & 0 deletions
33
packages/schema/src/non-inheritable-keys/bindings/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { z } from "zod"; | ||
import { aiSchema } from "./ai"; | ||
import { analyticsEngineDatasetsSchema } from "./analytics-engine-datasets"; | ||
import { browserSchema } from "./browser"; | ||
import { d1DatabasesSchema } from "./d1-database"; | ||
import { dispatchNamespacesSchema } from "./dispatch-namespaces"; | ||
import { durableObjectsSchema, migrationsSchema } from "./durable-object"; | ||
import { sendEmailSchema } from "./email"; | ||
import { hyperdriveSchema } from "./hyperdrive"; | ||
import { kvNamespacesSchema } from "./kv-namespaces"; | ||
import { mtlsCertificatesSchema } from "./mtls-certificates"; | ||
import { queuesSchema } from "./queues"; | ||
import { r2BucketsSchema } from "./r2-buckets"; | ||
import { vectorizeSchema } from "./vectorize-indexes"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#non-inheritable-keys | ||
export const bindingsKeysSchema = z.object({ | ||
vars: z.record(z.any()).optional(), | ||
browser: browserSchema.optional(), | ||
d1_databases: d1DatabasesSchema.optional(), | ||
durable_objects: durableObjectsSchema.optional(), | ||
dispatch_namespaces: dispatchNamespacesSchema.optional(), | ||
migrations: migrationsSchema.optional(), | ||
send_email: sendEmailSchema.optional(), | ||
hyperdrive: hyperdriveSchema.optional(), | ||
kv_namespaces: kvNamespacesSchema.optional(), | ||
queues: queuesSchema.optional(), | ||
r2_buckets: r2BucketsSchema.optional(), | ||
vectorize: vectorizeSchema.optional(), | ||
analytics_engine_datasets: analyticsEngineDatasetsSchema.optional(), | ||
mtls_certificates: mtlsCertificatesSchema.optional(), | ||
ai: aiSchema.optional(), | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/schema/src/non-inheritable-keys/bindings/kv-namespaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces | ||
const kvNamespaceSchema = z.object({ | ||
binding: z.string(), | ||
id: z.string(), | ||
preview_id: z.string().optional(), | ||
}); | ||
|
||
export const kvNamespacesSchema = z.array(kvNamespaceSchema); |
9 changes: 9 additions & 0 deletions
9
packages/schema/src/non-inheritable-keys/bindings/mtls-certificates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates | ||
export const mtlsCertificatesSchema = z.array( | ||
z.object({ | ||
binding: z.string(), | ||
certificate_id: z.string(), | ||
}), | ||
); |
27 changes: 27 additions & 0 deletions
27
packages/schema/src/non-inheritable-keys/bindings/queues.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#queues | ||
const producersSchema = z.array( | ||
z.object({ | ||
binding: z.string(), | ||
queue: z.string(), | ||
delivery_delay: z.number().optional(), | ||
}), | ||
); | ||
|
||
const consumersSchema = z.array( | ||
z.object({ | ||
queue: z.string(), | ||
max_batch_size: z.number().optional(), | ||
max_batch_timeout: z.number().optional(), | ||
max_retries: z.number().optional(), | ||
dead_letter_queue: z.string().optional(), | ||
max_concurrency: z.number().optional(), | ||
retry_delay: z.number().optional(), | ||
}), | ||
); | ||
|
||
export const queuesSchema = z.object({ | ||
producers: z.array(producersSchema).optional(), | ||
consumers: z.array(consumersSchema).optional(), | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/schema/src/non-inheritable-keys/bindings/r2-buckets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets | ||
export const r2BucketsSchema = z.array( | ||
z.object({ | ||
binding: z.string(), | ||
bucket_name: z.string(), | ||
}), | ||
); |
10 changes: 10 additions & 0 deletions
10
packages/schema/src/non-inheritable-keys/bindings/service-bindings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings | ||
export const serviceBindingsSchema = z.array( | ||
z.object({ | ||
binding: z.string(), | ||
service: z.string(), | ||
entrypoint: z.string().optional(), | ||
}), | ||
); |
9 changes: 9 additions & 0 deletions
9
packages/schema/src/non-inheritable-keys/bindings/vectorize-indexes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { z } from "zod"; | ||
|
||
// ref: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes | ||
export const vectorizeSchema = z.array( | ||
z.object({ | ||
binding: z.string(), | ||
index_name: z.string(), | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from "zod"; | ||
|
||
import { bindingsKeysSchema } from "./bindings"; | ||
|
||
export const nonInheritableKeysSchema = bindingsKeysSchema.extend({ | ||
define: z.record(z.string()).optional(), | ||
}); |