From 38967e627c59476f0da676ae576f963b9de85014 Mon Sep 17 00:00:00 2001 From: wingbot <109207340+monadabot@users.noreply.github.com> Date: Tue, 6 Aug 2024 09:39:17 +0200 Subject: [PATCH] feat(docs): update docs (#978) feat(docs): update docs Updates the Wing docs. See details in [workflow run]. [Workflow Run]: https://github.com/winglang/docsite/actions/runs/10262297812 ------ *Automatically created via the "update-docs" workflow* --- .../03-language/10-using-javascript.md | 69 ------------------- .../04-standard-library/std/resource.md | 45 ------------ .../version-latest/04-winglibs/04-toc.md | 4 +- 3 files changed, 2 insertions(+), 116 deletions(-) diff --git a/api_versioned_docs/version-latest/03-language/10-using-javascript.md b/api_versioned_docs/version-latest/03-language/10-using-javascript.md index b8e9022c..812d8f6a 100644 --- a/api_versioned_docs/version-latest/03-language/10-using-javascript.md +++ b/api_versioned_docs/version-latest/03-language/10-using-javascript.md @@ -4,75 +4,6 @@ id: using-javascript keywords: [example, javascript, extern, typescript, js, ts] --- -## Creating inflight function from JavaScript/TypeScript file - -Inflight closures are an extremely important Wing functionality. Consider the following simple wing program: - -```wing example -// main.w -bring cloud; -let bucket = new cloud.Bucket(); - -bucket.onCreate(inflight (file) => { - log(file); -}); -``` - -Being able to write inflight wing alongside the preflight code is beautiful, but you may want to write the inflight function in a separate file and *language*. The `@inflight` intrinsic function can be used to create an inflight closure from a JavaScript/TypeScript: - -```wing -// main.w -bring cloud; -let bucket = new cloud.Bucket(); - -bucket.onCreate(@inflight("./bucket_create.ts")); -// ^ onCreate expects an `inflight (str): void` function, so the file must export a function with a typescript signature that matches -// ^ Relative (to current file) path to javascript or typescript file -// Note: This must be a static string -``` - -`wing compile` will generate `.bucket_create.inflight.ts` which will contain all of the information needed for TypeScript type checking and IDE support. -With that, you can create the `bucket_create.ts` file: - -```ts -// bucket_create.ts -import inflight from "./.bucket_create.inflight"; - -export default inflight(async ({}, file) => { -// ^ This is known to be a string, the first positional argument needed for `onCreate` - console.log(file); -}); -``` - -Something missing here is the ability to reference preflight resources inside an inflight function. -Let's create a Queue and pass it to the inflight function while exploring other options: - -```wing -// main.w -bring cloud; -let bucket = new cloud.Bucket(); -let queue = new cloud.Queue(); - -bucket.onCreate(@inflight("./bucket_create.ts", - export: "default", -// ^ Optional named export from the file, "default" is the default export - lifts:[{ obj: queue, alias: "myQueue", ops: ["push"] }], -// ^ object to lift, can be any preflight expression -// ^ Optional alias, by default, this will be the variable name passed to obj -// ^ methods to lift, if not provided then all methods will be granted -)); -``` - -```ts -// bucket_create.ts -import inflight from "./bucket_create.inflight"; - -export default inflight(async ({ myQueue }, file) => { -// ^ inflight interface to your preflight queue - await myQueue.push(file); -}); -``` - ## Using `extern` to expose JavaScript/TypeScript functions in preflight and inflight When you want to use a JavaScript/TypeScript file anywhere in Wing, you can use the `extern` keyword to expose functions from that file. diff --git a/api_versioned_docs/version-latest/04-standard-library/std/resource.md b/api_versioned_docs/version-latest/04-standard-library/std/resource.md index 2399a81f..68a8b0c7 100644 --- a/api_versioned_docs/version-latest/04-standard-library/std/resource.md +++ b/api_versioned_docs/version-latest/04-standard-library/std/resource.md @@ -9,51 +9,6 @@ id: resource ## Structs -### ImportInflightOptions - -Options for the `@inflight` intrinsic. - -#### Initializer - -```wing -let ImportInflightOptions = ImportInflightOptions{ ... }; -``` - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| export | str | Name of exported function. | -| lifts | MutArray<LiftAnnotation> | Mapping of available symbols to a lift declaration. | - ---- - -##### `export`Optional - -```wing -export: str; -``` - -- *Type:* str -- *Default:* "default" - -Name of exported function. - ---- - -##### `lifts`Optional - -```wing -lifts: MutArray; -``` - -- *Type:* MutArray<LiftAnnotation> -- *Default:* * All possible operations will be available - -Mapping of available symbols to a lift declaration. - ---- - ### LiftAnnotation Annotations about preflight data and desired inflight operations. diff --git a/versioned_docs/version-latest/04-winglibs/04-toc.md b/versioned_docs/version-latest/04-winglibs/04-toc.md index d1baf9b7..ed9b9072 100644 --- a/versioned_docs/version-latest/04-winglibs/04-toc.md +++ b/versioned_docs/version-latest/04-winglibs/04-toc.md @@ -8,10 +8,10 @@ keywords: [winglib, Wing library] | Library | Package name | Version | Description | Supported Wing platforms | | -------- | ------- | ------- | ------- | ------- | -| [Amazon Bedrock](/docs/winglibs/winglibs/bedrock) | [@winglibs/bedrock](/docs/winglibs/winglibs/bedrock) | v0.0.9 | A Wing library for Amazon Bedrock | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | +| [Amazon Bedrock](/docs/winglibs/winglibs/bedrock) | [@winglibs/bedrock](/docs/winglibs/winglibs/bedrock) | v0.1.0 | A Wing library for Amazon Bedrock | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | | [AWS Budget](/docs/winglibs/winglibs/budget) | [@winglibs/budget](/docs/winglibs/winglibs/budget) | v0.1.5 | A Wing library for working with [AWS Budgets] | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | | [Cloud checks](/docs/winglibs/winglibs/checks) | [@winglibs/checks](/docs/winglibs/winglibs/checks) | v0.0.16 | A self-validation mechanism for cloud applications | [*](/docs/platforms/platforms) | -| [cloudv2](/docs/winglibs/winglibs/cloudv2) | [@winglibs/cloudv2](/docs/winglibs/winglibs/cloudv2) | v0.0.2 | Standard cloud library for Wing | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | +| [cloudv2](/docs/winglibs/winglibs/cloudv2) | [@winglibs/cloudv2](/docs/winglibs/winglibs/cloudv2) | v0.1.0 | Standard cloud library for Wing | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | | [Amazon Cognito](/docs/winglibs/winglibs/cognito) | [@winglibs/cognito](/docs/winglibs/winglibs/cognito) | v0.0.14 | A wing library to work with Amazon Cognito | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | | [Containers](/docs/winglibs/winglibs/containers) | [@winglibs/containers](/docs/winglibs/winglibs/containers) | v0.1.5 | Deploy containers with Wing | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) | | [Amazon DynamoDB](/docs/winglibs/winglibs/dynamodb) | [@winglibs/dynamodb](/docs/winglibs/winglibs/dynamodb) | v0.2.1 | A Wing library for Amazon DynamoDB | [sim](/docs/platforms/sim), [tf-aws](/docs/platforms/AWS/tf-aws) |