Skip to content

Commit

Permalink
Added in Type & MetaInfo highlighting (#17073)
Browse files Browse the repository at this point in the history
* Added in Type & MetaInfo highlighting

* Adding missing components from Import section

* Removed unnecessary slash
  • Loading branch information
dcpena authored Sep 24, 2024
1 parent 0ff3751 commit 6966349
Show file tree
Hide file tree
Showing 14 changed files with 579 additions and 568 deletions.
7 changes: 4 additions & 3 deletions src/content/docs/kv/concepts/kv-namespaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sidebar:
order: 7

---
import { Type, MetaInfo } from "~/components";

A KV namespace is a key-value database replicated to Cloudflare’s global network.

Expand All @@ -20,15 +21,15 @@ KV namespace IDs are public and bound to your account.

To bind KV namespaces to your Worker, assign an array of the below object to the `kv_namespaces` key.

* `binding` string required
* `binding` <Type text="string" /> <MetaInfo text="required" />

* The binding name used to refer to the KV namespace.

* `id` string required
* `id` <Type text="string" /> <MetaInfo text="required" />

* The ID of the KV namespace.

* `preview_id` string optional
* `preview_id` <Type text="string" /> <MetaInfo text="optional" />

* The ID of the KV namespace used during `wrangler dev`.

Expand Down
32 changes: 16 additions & 16 deletions src/content/docs/pages/functions/wrangler-configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar:
order: 6
---

import { Render, TabItem, Tabs } from "~/components";
import { Render, TabItem, Tabs, Type, MetaInfo } from "~/components";

:::caution

Expand Down Expand Up @@ -278,23 +278,23 @@ API_KEY = "6567875fvgt"

Inheritable keys are configurable at the top-level, and can be inherited (or overridden) by environment-specific configuration.

- `name` string required
- `name` <Type text="string" /> <MetaInfo text="required" />

- The name of your Pages project. Alphanumeric and dashes only.

- `pages_build_output_dir` string required
- `pages_build_output_dir` <Type text="string" /> <MetaInfo text="required" />

- The path to your project's build output folder. For example: `./dist`.

- `compatibility_date` string required
- `compatibility_date` <Type text="string" /> <MetaInfo text="required" />

- A date in the form `yyyy-mm-dd`, which will be used to determine which version of the Workers runtime is used. Refer to [Compatibility dates](/workers/configuration/compatibility-dates/).

- `compatibility_flags` string\[] optional

- A list of flags that enable features from upcoming features of the Workers runtime, usually used together with `compatibility_date`. Refer to [compatibility dates](/workers/configuration/compatibility-dates/).

- `send_metrics` boolean optional
- `send_metrics` <Type text="boolean" /> <MetaInfo text="optional" />

- Whether Wrangler should send usage metrics to Cloudflare for this project.

Expand Down Expand Up @@ -335,47 +335,47 @@ API_KEY = "8901234bfgd"

This will work for local development, but will fail to validate when you try to deploy.

- `vars` object optional
- `vars` <Type text="object" /> <MetaInfo text="optional" />

- A map of environment variables to set when deploying your Function. Refer to [Environment variables](/pages/functions/bindings/#environment-variables).

- `d1_databases` object optional
- `d1_databases` <Type text="object" /> <MetaInfo text="optional" />

- A list of D1 databases that your Function should be bound to. Refer to [D1 databases](/pages/functions/bindings/#d1-databases).

- `durable_objects` object optional
- `durable_objects` <Type text="object" /> <MetaInfo text="optional" />

- A list of Durable Objects that your Function should be bound to. Refer to [Durable Objects](/pages/functions/bindings/#durable-objects).

- `hyperdrive` object optional
- `hyperdrive` <Type text="object" /> <MetaInfo text="optional" />

- Specifies Hyperdrive configs that your Function should be bound to. Refer to [Hyperdrive](/pages/functions/bindings/#r2-buckets).

- `kv_namespaces` object optional
- `kv_namespaces` <Type text="object" /> <MetaInfo text="optional" />

- A list of KV namespaces that your Function should be bound to. Refer to [KV namespaces](/pages/functions/bindings/#kv-namespaces).

- `queues.producers` object optional
- `queues.producers` <Type text="object" /> <MetaInfo text="optional" />

- Specifies Queues Producers that are bound to this Function. Refer to [Queues Producers](/queues/get-started/#4-set-up-your-producer-worker).

- `r2_buckets` object optional
- `r2_buckets` <Type text="object" /> <MetaInfo text="optional" />

- A list of R2 buckets that your Function should be bound to. Refer to [R2 buckets](/pages/functions/bindings/#r2-buckets).

- `vectorize` object optional
- `vectorize` <Type text="object" /> <MetaInfo text="optional" />

- A list of Vectorize indexes that your Function should be bound to. Refer to [Vectorize indexes](/vectorize/get-started/intro/#3-bind-your-worker-to-your-index).

- `services` object optional
- `services` <Type text="object" /> <MetaInfo text="optional" />

- A list of service bindings that your Function should be bound to. Refer to [service bindings](/pages/functions/bindings/#service-bindings).

- `analytics_engine_datasets` object optional
- `analytics_engine_datasets` <Type text="object" /> <MetaInfo text="optional" />

- Specifies analytics engine datasets that are bound to this Function. Refer to [Workers Analytics Engine](/analytics/analytics-engine/get-started/).

- `ai` object optional
- `ai` <Type text="object" /> <MetaInfo text="optional" />

- Specifies an AI binding to this Function. Refer to [Workers AI](/pages/functions/bindings/#workers-ai).

Expand Down
20 changes: 10 additions & 10 deletions src/content/docs/pages/get-started/c3.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description: Use C3 (`create-cloudflare` CLI) to set up and deploy new
deployment.
---

import { Render, TabItem, Tabs } from "~/components";
import { Render, TabItem, Tabs, Type, MetaInfo } from "~/components";

Cloudflare provides a CLI command for creating new Workers and Pages projects — `npm create cloudflare`, powered by the [`create-cloudflare` package](https://www.npmjs.com/package/create-cloudflare).

Expand Down Expand Up @@ -90,15 +90,15 @@ bun create cloudflare@latest [--] [<DIRECTORY>] [OPTIONS] [-- <NESTED ARGS...>]

</TabItem> </Tabs>

- `DIRECTORY` string optional
- `DIRECTORY` <Type text="string" /> <MetaInfo text="optional" />

- The directory where the application should be created. The name of the application is taken from the directory name.

- `NESTED ARGS..` string\[] optional

- CLI arguments to pass to eventual third party CLIs C3 might invoke (in the case of full-stack applications).

- `--category` string optional
- `--category` <Type text="string" /> <MetaInfo text="optional" />

- The kind of templates that should be created.

Expand All @@ -109,7 +109,7 @@ bun create cloudflare@latest [--] [<DIRECTORY>] [OPTIONS] [-- <NESTED ARGS...>]
- `demo`: Application Starter
- `remote-template`: Template from a GitHub repo

- `--type` string optional
- `--type` <Type text="string" /> <MetaInfo text="optional" />

- The type of application that should be created.

Expand All @@ -123,7 +123,7 @@ bun create cloudflare@latest [--] [<DIRECTORY>] [OPTIONS] [-- <NESTED ARGS...>]
- `openapi`: A Worker implementing an OpenAPI REST endpoint.
- `pre-existing`: Fetch a Worker initialized from the Cloudflare dashboard.

- `--framework` string optional
- `--framework` <Type text="string" /> <MetaInfo text="optional" />

- The type of framework to use to create a web application (when using this option, `--type` is ignored).

Expand All @@ -143,7 +143,7 @@ bun create cloudflare@latest [--] [<DIRECTORY>] [OPTIONS] [-- <NESTED ARGS...>]
- `svelte`
- `vue`

- `--template` string optional
- `--template` <Type text="string" /> <MetaInfo text="optional" />

- Create a new project via an external template hosted in a git repository

Expand Down Expand Up @@ -194,25 +194,25 @@ bun create cloudflare@latest [--] [<DIRECTORY>] [OPTIONS] [-- <NESTED ARGS...>]

- Open with your browser the deployed application (this option is ignored if the application is not deployed).

- `--existing-script` string optional
- `--existing-script` <Type text="string" /> <MetaInfo text="optional" />

- The name of an existing Cloudflare Workers script to clone locally. When using this option, `--type` is coerced to `pre-existing`.

- When `--existing-script` is specified, `deploy` will be ignored.

- `-y`, `--accept-defaults` boolean optional
- `-y`, `--accept-defaults` <Type text="boolean" /> <MetaInfo text="optional" />

- Use all the default C3 options each can also be overridden by specifying it.

- `--auto-update` boolean (default: true) optional

- Automatically uses the latest version of C3.

- `-v`, `--version` boolean optional
- `-v`, `--version` <Type text="boolean" /> <MetaInfo text="optional" />

- Show version number.

- `-h`, `--help` boolean optional
- `-h`, `--help` <Type text="boolean" /> <MetaInfo text="optional" />

- Show a help message.

Expand Down
6 changes: 4 additions & 2 deletions src/content/docs/workers-ai/configuration/bindings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ sidebar:

---

import { Type, MetaInfo } from "~/components";

## Workers

[Workers](/workers/) provides a serverless execution environment that allows you to create new applications or augment existing ones.
Expand Down Expand Up @@ -41,13 +43,13 @@ const answer = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {



* `model` string required
* `model` <Type text="string" /> <MetaInfo text="required" />

* The model to run.

**Supported options**

* `stream` boolean optional
* `stream` <Type text="boolean" /> <MetaInfo text="optional" />
* Returns a stream of results as they are available.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title: Multipart upload metadata

---

import { Type, MetaInfo } from "~/components";

If you're using the [Workers Script Upload API](/api/operations/worker-script-upload-worker-module) or [Version Upload API](/api/operations/worker-versions-upload-version) directly, `multipart/form-data` uploads require you to specify a `metadata` part. This metadata defines the Worker's configuration in JSON format, analogue to the [wrangler.toml file](/workers/wrangler/configuration/).

## Sample `metadata`
Expand Down Expand Up @@ -33,28 +35,28 @@ At a minimum, the `main_module` key is required to upload a Worker.



* `main_module` string required
* `main_module` <Type text="string" /> <MetaInfo text="required" />

* The part name that contains the module entry point of the Worker that will be executed. For example, `main.js`.

* `bindings` array\[object] optional

* [Bindings](#bindings) to expose in the Worker.

* `placement` object optional
* `placement` <Type text="object" /> <MetaInfo text="optional" />

* [Smart placement](/workers/configuration/smart-placement/) object for the Worker.
* `mode` field only supports `smart` for automatic placement.

* `compatibility_date` string optional
* `compatibility_date` <Type text="string" /> <MetaInfo text="optional" />

* [Compatibility Date](/workers/configuration/compatibility-dates/#setting-compatibility-date) indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. Highly recommended to set a `compatibility_date`, otherwise if on upload via the API, it defaults to the oldest compatibility date before any flags took effect (2021-11-02).

* `compatibility_flags` array\[string] optional

* [Compatibility Flags](/workers/configuration/compatibility-dates/#setting-compatibility-flags) that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a `compatibility_date`.

* `usage_model` string optional
* `usage_model` <Type text="string" /> <MetaInfo text="optional" />

* Usage model to apply to invocations, only allowed value is `standard`.

Expand All @@ -75,7 +77,7 @@ These attributes are **not available** for version uploads.

* [Durable Objects migrations](/durable-objects/reference/durable-objects-migrations/) to apply.

* `logpush` boolean optional
* `logpush` <Type text="boolean" /> <MetaInfo text="optional" />

* Whether [Logpush](/cloudflare-for-platforms/cloudflare-for-saas/hostname-analytics/#logpush) is turned on for the Worker.

Expand All @@ -100,7 +102,7 @@ These attributes are **not available** for immediately deployed uploads.



* `annotations` object optional
* `annotations` <Type text="object" /> <MetaInfo text="optional" />

* Annotations object specific to the Worker version.
* `workers/message` specifies a custom message for the version.
Expand Down
24 changes: 13 additions & 11 deletions src/content/docs/workers/runtime-apis/request.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ description: Interface that represents an HTTP request.

---

import { Type, MetaInfo } from "~/components";

The [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request) interface represents an HTTP request and is part of the [Fetch API](/workers/runtime-apis/fetch/).

## Background
Expand Down Expand Up @@ -66,7 +68,7 @@ An object containing properties that you want to apply to the request.

* Cloudflare-specific properties that can be set on the `Request` that control how Cloudflare’s global network handles the request.

* `method` string optional
* `method` <Type text="string" /> <MetaInfo text="optional" />

* The HTTP request method. The default is `GET`. In Workers, all [HTTP request methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) are supported, except for [`CONNECT`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).

Expand All @@ -79,7 +81,7 @@ An object containing properties that you want to apply to the request.
* The request body, if any.
* Note that a request using the GET or HEAD method cannot have a body.

* `redirect` string optional
* `redirect` <Type text="string" /> <MetaInfo text="optional" />

* The redirect mode to use: `follow`, `error`, or `manual`. The default for a new `Request` object is `follow`. Note, however, that the incoming `Request` property of a `FetchEvent` will have redirect mode `manual`.

Expand All @@ -98,24 +100,24 @@ Invalid or incorrectly-named keys in the `cf` object will be silently ignored. C



* `apps` boolean optional
* `apps` <Type text="boolean" /> <MetaInfo text="optional" />

* Whether [Cloudflare Apps](https://www.cloudflare.com/apps/) should be enabled for this request. Defaults to `true`.

* `cacheEverything` boolean optional
* `cacheEverything` <Type text="boolean" /> <MetaInfo text="optional" />

* Treats all content as static and caches all [file types](/cache/concepts/default-cache-behavior#default-cached-file-extensions) beyond the Cloudflare default cached content. Respects cache headers from the origin web server. This is equivalent to setting the Page Rule [**Cache Level** (to **Cache Everything**)](/rules/page-rules/reference/settings/). Defaults to `false`.
This option applies to `GET` and `HEAD` request methods only.

* `cacheKey` string optional
* `cacheKey` <Type text="string" /> <MetaInfo text="optional" />

* A request’s cache key is what determines if two requests are the same for caching purposes. If a request has the same cache key as some previous request, then Cloudflare can serve the same cached response for both.

* `cacheTags` Array\<string> optional

* This option appends additional [**Cache-Tag**](/cache/how-to/purge-cache/purge-by-tags/) headers to the response from the origin server. This allows for purges of cached content based on tags provided by the Worker, without modifications to the origin server. This is performed using the [**Purge by Tag**](/cache/how-to/purge-cache/purge-by-tags/#purge-using-cache-tags) feature, which is currently only available to Enterprise zones. If this option is used in a non-Enterprise zone, the additional headers will not be appended.

* `cacheTtl` number optional
* `cacheTtl` <Type text="number" /> <MetaInfo text="optional" />

* This option forces Cloudflare to cache the response for this request, regardless of what headers are seen on the response. This is equivalent to setting two Page Rules: [**Edge Cache TTL**](/cache/how-to/edge-browser-cache-ttl/) and [**Cache Level** (to **Cache Everything**)](/rules/page-rules/reference/settings/). The value must be zero or a positive number. A value of `0` indicates that the cache asset expires immediately. This option applies to `GET` and `HEAD` request methods only.

Expand All @@ -127,23 +129,23 @@ Invalid or incorrectly-named keys in the `cf` object will be silently ignored. C

* Enables [Image Resizing](/images/transform-images/) for this request. The possible values are described in [Transform images via Workers](/images/transform-images/transform-via-workers/) documentation.

* `mirage` boolean optional
* `mirage` <Type text="boolean" /> <MetaInfo text="optional" />

* Whether [Mirage](https://www.cloudflare.com/website-optimization/mirage/) should be enabled for this request, if otherwise configured for this zone. Defaults to `true`.

* `polish` string optional
* `polish` <Type text="string" /> <MetaInfo text="optional" />

* Sets [Polish](https://blog.cloudflare.com/introducing-polish-automatic-image-optimizati/) mode. The possible values are `lossy`, `lossless` or `off`.

* `resolveOverride` string optional
* `resolveOverride` <Type text="string" /> <MetaInfo text="optional" />

* Directs the request to an alternate origin server by overriding the DNS lookup. The value of `resolveOverride` specifies an alternate hostname which will be used when determining the origin IP address, instead of using the hostname specified in the URL. The `Host` header of the request will still match what is in the URL. Thus, `resolveOverride` allows a request to be sent to a different server than the URL / `Host` header specifies. However, `resolveOverride` will only take effect if both the URL host and the host specified by `resolveOverride` are within your zone. If either specifies a host from a different zone / domain, then the option will be ignored for security reasons. If you need to direct a request to a host outside your zone (while keeping the `Host` header pointing within your zone), first create a CNAME record within your zone pointing to the outside host, and then set `resolveOverride` to point at the CNAME record. Note that, for security reasons, it is not possible to set the `Host` header to specify a host outside of your zone unless the request is actually being sent to that host.

* `scrapeShield` boolean optional
* `scrapeShield` <Type text="boolean" /> <MetaInfo text="optional" />

* Whether [ScrapeShield](https://blog.cloudflare.com/introducing-scrapeshield-discover-defend-dete/) should be enabled for this request, if otherwise configured for this zone. Defaults to `true`.

* `webp` boolean optional
* `webp` <Type text="boolean" /> <MetaInfo text="optional" />

* Enables or disables [WebP](https://blog.cloudflare.com/a-very-webp-new-year-from-cloudflare/) image format in [Polish](/images/polish/).

Expand Down
Loading

0 comments on commit 6966349

Please sign in to comment.