@cloudflare/workers-shared
Advanced tools
Comparing version 0.0.0-7f0bde5b5 to 0.0.0-7f565c5c8
import { z } from "zod"; | ||
export declare const RoutingConfigSchema: z.ZodObject<{ | ||
has_user_worker: z.ZodOptional<z.ZodBoolean>; | ||
invoke_user_worker_ahead_of_assets: z.ZodOptional<z.ZodBoolean>; | ||
export declare const RouterConfigSchema: z.ZodObject<{ | ||
account_id: z.ZodOptional<z.ZodNumber>; | ||
script_id: z.ZodOptional<z.ZodNumber>; | ||
invoke_user_worker_ahead_of_assets: z.ZodOptional<z.ZodBoolean>; | ||
has_user_worker: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
has_user_worker?: boolean; | ||
invoke_user_worker_ahead_of_assets?: boolean; | ||
account_id?: number; | ||
script_id?: number; | ||
invoke_user_worker_ahead_of_assets?: boolean; | ||
has_user_worker?: boolean; | ||
}, { | ||
has_user_worker?: boolean; | ||
invoke_user_worker_ahead_of_assets?: boolean; | ||
account_id?: number; | ||
script_id?: number; | ||
invoke_user_worker_ahead_of_assets?: boolean; | ||
has_user_worker?: boolean; | ||
}>; | ||
export declare const AssetConfigSchema: z.ZodObject<{ | ||
html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>; | ||
not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>; | ||
serve_directly: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash"; | ||
not_found_handling?: "none" | "single-page-application" | "404-page"; | ||
serve_directly?: boolean; | ||
}, { | ||
html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash"; | ||
not_found_handling?: "none" | "single-page-application" | "404-page"; | ||
serve_directly?: boolean; | ||
}>; | ||
export declare const InternalConfigSchema: z.ZodObject<{ | ||
account_id: z.ZodOptional<z.ZodNumber>; | ||
script_id: z.ZodOptional<z.ZodNumber>; | ||
}, "strip", z.ZodTypeAny, { | ||
account_id?: number; | ||
script_id?: number; | ||
}, { | ||
account_id?: number; | ||
script_id?: number; | ||
}>; | ||
export declare const AssetWorkerConfigShema: z.ZodObject<{ | ||
account_id: z.ZodOptional<z.ZodNumber>; | ||
script_id: z.ZodOptional<z.ZodNumber>; | ||
compatibility_date: z.ZodOptional<z.ZodString>; | ||
compatibility_flags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; | ||
html_handling: z.ZodOptional<z.ZodEnum<["auto-trailing-slash", "force-trailing-slash", "drop-trailing-slash", "none"]>>; | ||
not_found_handling: z.ZodOptional<z.ZodEnum<["single-page-application", "404-page", "none"]>>; | ||
serve_directly: z.ZodOptional<z.ZodBoolean>; | ||
}, "strip", z.ZodTypeAny, { | ||
account_id?: number; | ||
script_id?: number; | ||
compatibility_date?: string; | ||
compatibility_flags?: string[]; | ||
html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash"; | ||
not_found_handling?: "none" | "single-page-application" | "404-page"; | ||
serve_directly?: boolean; | ||
}, { | ||
account_id?: number; | ||
script_id?: number; | ||
compatibility_date?: string; | ||
compatibility_flags?: string[]; | ||
html_handling?: "none" | "auto-trailing-slash" | "force-trailing-slash" | "drop-trailing-slash"; | ||
not_found_handling?: "none" | "single-page-application" | "404-page"; | ||
serve_directly?: boolean; | ||
}>; | ||
export type RoutingConfig = z.infer<typeof RoutingConfigSchema>; | ||
export type RouterConfig = z.infer<typeof RouterConfigSchema>; | ||
export type AssetConfig = z.infer<typeof AssetConfigSchema>; | ||
export type AssetWorkerConfig = z.infer<typeof AssetWorkerConfigShema>; | ||
export interface UnsafePerformanceTimer { | ||
@@ -64,0 +43,0 @@ readonly timeOrigin: number; |
{ | ||
"name": "@cloudflare/workers-shared", | ||
"version": "0.0.0-7f0bde5b5", | ||
"version": "0.0.0-7f565c5c8", | ||
"description": "Package that is used at Cloudflare to power some internal features of Cloudflare Workers.", | ||
@@ -30,4 +30,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"@cloudflare/vitest-pool-workers": "^0.5.31", | ||
"@cloudflare/workers-types": "^4.20250121.0", | ||
"@cloudflare/vitest-pool-workers": "^0.5.41", | ||
"@cloudflare/workers-types": "^4.20250214.0", | ||
"@sentry/cli": "^2.37.0", | ||
"@types/mime": "^3.0.4", | ||
@@ -37,5 +38,5 @@ "concurrently": "^8.2.2", | ||
"rimraf": "^5.0.10", | ||
"toucan-js": "^3.3.1", | ||
"typescript": "~5.6.3", | ||
"vitest": "~2.1.8", | ||
"toucan-js": "4.0.0", | ||
"typescript": "^5.7.2", | ||
"vitest": "~2.1.0", | ||
"@cloudflare/eslint-config-worker": "1.1.0", | ||
@@ -64,9 +65,12 @@ "@cloudflare/workers-tsconfig": "0.0.0" | ||
"clean": "rimraf dist", | ||
"deploy": "pnpm run deploy:router-worker && pnpm run deploy:asset-worker", | ||
"deploy:asset-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload -c asset-worker/wrangler.toml", | ||
"deploy": "pnpm run generate-sourcemaps && pnpm run deploy:router-worker && pnpm run deploy:asset-worker && pnpm run upload-sourcemaps", | ||
"deploy:asset-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload -c asset-worker/wrangler.toml --tag aw-$(node -r esbuild-register ./scripts/get-version-tag.ts)", | ||
"deploy:asset-worker-staging": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler deploy -c asset-worker/wrangler.toml -e staging", | ||
"deploy:router-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload -c router-worker/wrangler.toml", | ||
"deploy:router-worker": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler versions upload -c router-worker/wrangler.toml --tag rw-$(node -r esbuild-register ./scripts/get-version-tag.ts)", | ||
"deploy:router-worker-staging": "CLOUDFLARE_API_TOKEN=$WORKERS_DEPLOY_AND_CONFIG_CLOUDFLARE_API_TOKEN pnpx wrangler deploy -c router-worker/wrangler.toml -e staging", | ||
"deploy:staging": "pnpm run deploy:router-worker-staging && pnpm run deploy:asset-worker-staging", | ||
"dev": "pnpm run clean && concurrently -n bundle:asset-worker,bundle:router-worker -c blue,magenta \"pnpm run bundle:asset-worker --watch\" \"pnpm run bundle:router-worker --watch\"", | ||
"generate-sourcemaps": "pnpm run generate-sourcemaps:asset-worker && pnpm generate-sourcemaps:router-worker", | ||
"generate-sourcemaps:asset-worker": "pnpx wrangler versions upload -c asset-worker/wrangler.toml --dry-run --outdir=./dist", | ||
"generate-sourcemaps:router-worker": "pnpx wrangler versions upload -c router-worker/wrangler.toml --dry-run --outdir=./dist", | ||
"test": "concurrently --group -n router-worker,asset-worker \"pnpm run test:router-worker\" \"pnpm run test:asset-worker\"", | ||
@@ -76,4 +80,7 @@ "test:asset-worker": "vitest -c asset-worker/vitest.config.mts --dir asset-worker", | ||
"test:router-worker": "vitest -c router-worker/vitest.config.mts --dir router-worker", | ||
"types:emit": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir ./dist" | ||
"types:emit": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir ./dist", | ||
"upload-sourcemaps": "pnpm run upload-sourcemaps:asset-worker && pnpm run upload-sourcemaps:router-worker", | ||
"upload-sourcemaps:asset-worker": "node -r esbuild-register ./scripts/upload-sourcemaps.ts --worker asset-worker --tag aw-$(node -r esbuild-register ./scripts/get-version-tag.ts)", | ||
"upload-sourcemaps:router-worker": "node -r esbuild-register ./scripts/upload-sourcemaps.ts --worker router-worker --tag rw-$(node -r esbuild-register ./scripts/get-version-tag.ts)" | ||
} | ||
} |
@@ -5,2 +5,6 @@ # `@cloudflare/workers-shared` | ||
> [!NOTE] | ||
> Since code in this package is used by the Workers infrastructure, it is important that PRs are given careful review with regards to how they could cause a failure in production. | ||
> Ideally, there should be comprehensive tests for changes being made to give extra confidence about the behavior. | ||
## `asset-worker` | ||
@@ -18,4 +22,13 @@ | ||
> [!NOTE] | ||
> Since code in this package is used by the Workers infrastructure, it is important that PRs are given careful review with regards to how they could cause a failure in production. | ||
> Ideally, there should be comprehensive tests for changes being made to give extra confidence about the behavior. | ||
## `Worker Deployment` | ||
Router-worker and asset-worker are both version uploaded through the run `deploy` target in this package, which uploads a new version of these Workers. | ||
There are two ways that the `deploy` script target can be invoked: | ||
- The `changesets` workflow will execute whenever there is a release of `@cloudflare/workers-shared` | ||
- If a change is needed prior to a workers-shared release, it can be done manually, via the `workers-shared-deploy-production` workflow. This workflow will upload new vesions of asset-worker and router-worker based on the code in the `main` branch. (Note, a duplicate version may be uploaded on the next workers-shared release, if there is an associated changeset) | ||
The pnpm `deploy` script should not be run manually. | ||
Once new versions are uploaded (through either the manual workflow, or the changesets workflow), they can be safely deployed and monitored using Gradual Deployments through Health Mediated Deployments. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
33
980299
12
592