alchemy 0.3.0 → 0.4.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 +8 -3
- package/lib/ai/astro-file.js +7 -24
- package/lib/ai/client.d.ts +7 -0
- package/lib/ai/client.js +45 -0
- package/lib/ai/css-file.js +7 -24
- package/lib/ai/data.d.ts +26 -21
- package/lib/ai/data.js +33 -22
- package/lib/ai/document.d.ts +76 -5
- package/lib/ai/document.js +112 -56
- package/lib/ai/html-file.js +7 -24
- package/lib/ai/json-file.js +11 -32
- package/lib/ai/typescript-file.d.ts +1 -2
- package/lib/ai/typescript-file.js +8 -39
- package/lib/ai/vue-file.js +7 -24
- package/lib/ai/yaml-file.js +12 -48
- package/lib/alchemy.d.ts +5 -0
- package/lib/alchemy.js +61 -3
- package/lib/apply.js +18 -11
- package/lib/aws/account-id.d.ts +4 -1
- package/lib/aws/account-id.js +1 -1
- package/lib/aws/credentials.d.ts +5 -0
- package/lib/aws/credentials.js +0 -0
- package/lib/aws/oidc/oidc-provider.js +2 -2
- package/lib/aws/role.js +35 -23
- package/lib/cloudflare/account-api-token.d.ts +168 -0
- package/lib/cloudflare/account-api-token.js +179 -0
- package/lib/cloudflare/account-id.d.ts +1 -0
- package/lib/cloudflare/account-id.js +0 -0
- package/lib/cloudflare/api.d.ts +38 -1
- package/lib/cloudflare/api.js +55 -4
- package/lib/cloudflare/bucket.d.ts +118 -3
- package/lib/cloudflare/bucket.js +269 -89
- package/lib/cloudflare/custom-domain.d.ts +75 -0
- package/lib/cloudflare/custom-domain.js +154 -0
- package/lib/cloudflare/{dns.js → dns-records.js} +14 -1
- package/lib/cloudflare/generate-asset-manifest.js +1 -1
- package/lib/cloudflare/index.d.ts +5 -1
- package/lib/cloudflare/index.js +5 -1
- package/lib/cloudflare/permission-groups.d.ts +78 -0
- package/lib/cloudflare/permission-groups.js +48 -0
- package/lib/cloudflare/r2-rest-state-store.d.ts +2 -1
- package/lib/cloudflare/r2-rest-state-store.js +3 -2
- package/lib/cloudflare/static-site-router.js +16 -7
- package/lib/cloudflare/static-site.d.ts +17 -18
- package/lib/cloudflare/static-site.js +19 -7
- package/lib/cloudflare/upload-asset-manifest.js +4 -2
- package/lib/{util/encrypt.d.ts → encrypt.d.ts} +1 -1
- package/lib/{util/encrypt.js → encrypt.js} +1 -1
- package/lib/fs/copy-file.d.ts +54 -0
- package/lib/fs/copy-file.js +63 -0
- package/lib/fs/file-system-state-store.js +1 -1
- package/lib/fs/file.d.ts +31 -0
- package/lib/fs/file.js +30 -5
- package/lib/fs/index.d.ts +6 -0
- package/lib/fs/index.js +6 -0
- package/lib/fs/static-astro-file.d.ts +34 -0
- package/lib/fs/static-astro-file.js +39 -0
- package/lib/fs/static-css-file.d.ts +24 -0
- package/lib/fs/static-css-file.js +29 -0
- package/lib/fs/static-html-file.d.ts +31 -0
- package/lib/fs/static-html-file.js +36 -0
- package/lib/fs/static-json-file.d.ts +2 -2
- package/lib/fs/static-json-file.js +3 -2
- package/lib/fs/static-text-file.d.ts +1 -1
- package/lib/fs/static-text-file.js +3 -2
- package/lib/fs/static-typescript-file.d.ts +2 -2
- package/lib/fs/static-typescript-file.js +3 -2
- package/lib/fs/static-vue-file.d.ts +28 -0
- package/lib/fs/static-vue-file.js +33 -0
- package/lib/fs/static-yaml-file.d.ts +11 -8
- package/lib/fs/static-yaml-file.js +3 -2
- package/lib/internal/{providers.d.ts → docs/providers.d.ts} +14 -4
- package/lib/internal/docs/providers.js +196 -0
- package/lib/secret.d.ts +3 -0
- package/lib/secret.js +13 -0
- package/lib/{util/serde.d.ts → serde.d.ts} +1 -1
- package/lib/{util/serde.js → serde.js} +12 -4
- package/lib/test/bun.js +3 -2
- package/lib/util/sha256.d.ts +1 -0
- package/lib/util/sha256.js +4 -0
- package/lib/web/vitepress/config.d.ts +11 -0
- package/lib/web/vitepress/config.js +32 -0
- package/lib/web/vitepress/home-page.d.ts +5 -3
- package/lib/web/vitepress/home-page.js +48 -35
- package/lib/web/vitepress/index.d.ts +2 -0
- package/lib/web/vitepress/index.js +2 -0
- package/lib/web/vitepress/process-front-matter-files.d.ts +18 -0
- package/lib/web/vitepress/process-front-matter-files.js +68 -0
- package/lib/web/vitepress/vitepress.d.ts +5 -4
- package/lib/web/vitepress/vitepress.js +20 -36
- package/package.json +8 -4
- package/src/ai/astro-file.ts +11 -30
- package/src/ai/client.ts +59 -0
- package/src/ai/css-file.ts +11 -30
- package/src/ai/data.ts +50 -25
- package/src/ai/document.ts +171 -66
- package/src/ai/html-file.ts +11 -30
- package/src/ai/json-file.ts +13 -37
- package/src/ai/typescript-file.ts +14 -48
- package/src/ai/vue-file.ts +11 -30
- package/src/ai/yaml-file.ts +13 -53
- package/src/alchemy.ts +74 -9
- package/src/apply.ts +27 -26
- package/src/aws/account-id.ts +6 -2
- package/src/aws/credentials.ts +6 -0
- package/src/aws/oidc/oidc-provider.ts +17 -17
- package/src/aws/role.ts +68 -54
- package/src/cloudflare/account-api-token.ts +365 -0
- package/src/cloudflare/account-id.ts +0 -0
- package/src/cloudflare/api.ts +88 -17
- package/src/cloudflare/bucket.ts +493 -133
- package/src/cloudflare/custom-domain.ts +318 -0
- package/src/cloudflare/{dns.ts → dns-records.ts} +36 -22
- package/src/cloudflare/generate-asset-manifest.ts +4 -4
- package/src/cloudflare/index.ts +5 -1
- package/src/cloudflare/permission-groups.ts +137 -0
- package/src/cloudflare/r2-rest-state-store.ts +14 -13
- package/src/cloudflare/static-site-router.ts +18 -8
- package/src/cloudflare/static-site.ts +27 -35
- package/src/cloudflare/upload-asset-manifest.ts +6 -4
- package/src/cloudflare/worker.ts +44 -43
- package/src/dns/import-dns.ts +4 -4
- package/src/{util/encrypt.ts → encrypt.ts} +7 -10
- package/src/fs/copy-file.ts +115 -0
- package/src/fs/file-system-state-store.ts +5 -5
- package/src/fs/file.ts +64 -9
- package/src/fs/index.ts +6 -0
- package/src/fs/static-astro-file.ts +45 -0
- package/src/fs/static-css-file.ts +35 -0
- package/src/fs/static-html-file.ts +42 -0
- package/src/fs/static-json-file.ts +4 -3
- package/src/fs/static-text-file.ts +5 -2
- package/src/fs/static-typescript-file.ts +4 -3
- package/src/fs/static-vue-file.ts +39 -0
- package/src/fs/static-yaml-file.ts +13 -9
- package/src/internal/docs/providers.ts +281 -0
- package/src/secret.ts +16 -0
- package/src/{util/serde.ts → serde.ts} +16 -10
- package/src/test/bun.ts +8 -7
- package/src/util/sha256.ts +5 -0
- package/src/web/vitepress/config.ts +50 -0
- package/src/web/vitepress/home-page.ts +54 -42
- package/src/web/vitepress/index.ts +2 -0
- package/src/web/vitepress/process-front-matter-files.ts +98 -0
- package/src/web/vitepress/vitepress.ts +34 -50
- package/lib/internal/getting-started.d.ts +0 -10
- package/lib/internal/getting-started.js +0 -94
- package/lib/internal/project.d.ts +0 -13
- package/lib/internal/project.js +0 -101
- package/lib/internal/providers.js +0 -148
- package/src/internal/getting-started.ts +0 -107
- package/src/internal/project.ts +0 -119
- package/src/internal/providers.ts +0 -209
- /package/lib/cloudflare/{dns.d.ts → dns-records.d.ts} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticAstroFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static Astro component file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create an Astro component file with content
|
|
8
|
+
* const header = await StaticAstroFile("Header.astro",
|
|
9
|
+
* `---
|
|
10
|
+
* import Logo from '../components/Logo.astro';
|
|
11
|
+
* const navItems = ['Home', 'About', 'Contact'];
|
|
12
|
+
* ---
|
|
13
|
+
*
|
|
14
|
+
* <header class="header">
|
|
15
|
+
* <Logo />
|
|
16
|
+
* <nav>
|
|
17
|
+
* <ul>
|
|
18
|
+
* {navItems.map(item => (
|
|
19
|
+
* <li><a href={`/${item.toLowerCase()}`}>{item}</a></li>
|
|
20
|
+
* ))}
|
|
21
|
+
* </ul>
|
|
22
|
+
* </nav>
|
|
23
|
+
* </header>
|
|
24
|
+
*
|
|
25
|
+
* <style>
|
|
26
|
+
* .header {
|
|
27
|
+
* display: flex;
|
|
28
|
+
* justify-content: space-between;
|
|
29
|
+
* padding: 1rem;
|
|
30
|
+
* }
|
|
31
|
+
* </style>`
|
|
32
|
+
* );
|
|
33
|
+
*/
|
|
34
|
+
export declare function StaticAstroFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticAstroFile>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static Astro component file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create an Astro component file with content
|
|
7
|
+
* const header = await StaticAstroFile("Header.astro",
|
|
8
|
+
* `---
|
|
9
|
+
* import Logo from '../components/Logo.astro';
|
|
10
|
+
* const navItems = ['Home', 'About', 'Contact'];
|
|
11
|
+
* ---
|
|
12
|
+
*
|
|
13
|
+
* <header class="header">
|
|
14
|
+
* <Logo />
|
|
15
|
+
* <nav>
|
|
16
|
+
* <ul>
|
|
17
|
+
* {navItems.map(item => (
|
|
18
|
+
* <li><a href={`/${item.toLowerCase()}`}>{item}</a></li>
|
|
19
|
+
* ))}
|
|
20
|
+
* </ul>
|
|
21
|
+
* </nav>
|
|
22
|
+
* </header>
|
|
23
|
+
*
|
|
24
|
+
* <style>
|
|
25
|
+
* .header {
|
|
26
|
+
* display: flex;
|
|
27
|
+
* justify-content: space-between;
|
|
28
|
+
* padding: 1rem;
|
|
29
|
+
* }
|
|
30
|
+
* </style>`
|
|
31
|
+
* );
|
|
32
|
+
*/
|
|
33
|
+
export function StaticAstroFile(id, ...args) {
|
|
34
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
35
|
+
return File(id, {
|
|
36
|
+
path,
|
|
37
|
+
content,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticCSSFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static CSS file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a CSS file with styles
|
|
8
|
+
* const styles = await StaticCSSFile("styles.css",
|
|
9
|
+
* `.container {
|
|
10
|
+
* max-width: 1200px;
|
|
11
|
+
* margin: 0 auto;
|
|
12
|
+
* padding: 0 1rem;
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* .button {
|
|
16
|
+
* background-color: #0062ff;
|
|
17
|
+
* color: white;
|
|
18
|
+
* border: none;
|
|
19
|
+
* padding: 0.5rem 1rem;
|
|
20
|
+
* border-radius: 4px;
|
|
21
|
+
* }`
|
|
22
|
+
* );
|
|
23
|
+
*/
|
|
24
|
+
export declare function StaticCSSFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticCSSFile>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static CSS file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create a CSS file with styles
|
|
7
|
+
* const styles = await StaticCSSFile("styles.css",
|
|
8
|
+
* `.container {
|
|
9
|
+
* max-width: 1200px;
|
|
10
|
+
* margin: 0 auto;
|
|
11
|
+
* padding: 0 1rem;
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* .button {
|
|
15
|
+
* background-color: #0062ff;
|
|
16
|
+
* color: white;
|
|
17
|
+
* border: none;
|
|
18
|
+
* padding: 0.5rem 1rem;
|
|
19
|
+
* border-radius: 4px;
|
|
20
|
+
* }`
|
|
21
|
+
* );
|
|
22
|
+
*/
|
|
23
|
+
export function StaticCSSFile(id, ...args) {
|
|
24
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
25
|
+
return File(id, {
|
|
26
|
+
path,
|
|
27
|
+
content,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticHTMLFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static HTML file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create an HTML file with content
|
|
8
|
+
* const page = await StaticHTMLFile("index.html",
|
|
9
|
+
* `<!DOCTYPE html>
|
|
10
|
+
* <html lang="en">
|
|
11
|
+
* <head>
|
|
12
|
+
* <meta charset="UTF-8">
|
|
13
|
+
* <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
14
|
+
* <title>My Website</title>
|
|
15
|
+
* <link rel="stylesheet" href="styles.css">
|
|
16
|
+
* </head>
|
|
17
|
+
* <body>
|
|
18
|
+
* <header>
|
|
19
|
+
* <h1>Welcome to My Website</h1>
|
|
20
|
+
* </header>
|
|
21
|
+
* <main>
|
|
22
|
+
* <p>This is the main content of the page.</p>
|
|
23
|
+
* </main>
|
|
24
|
+
* <footer>
|
|
25
|
+
* <p>© 2024 My Company</p>
|
|
26
|
+
* </footer>
|
|
27
|
+
* </body>
|
|
28
|
+
* </html>`
|
|
29
|
+
* );
|
|
30
|
+
*/
|
|
31
|
+
export declare function StaticHTMLFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticHTMLFile>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static HTML file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create an HTML file with content
|
|
7
|
+
* const page = await StaticHTMLFile("index.html",
|
|
8
|
+
* `<!DOCTYPE html>
|
|
9
|
+
* <html lang="en">
|
|
10
|
+
* <head>
|
|
11
|
+
* <meta charset="UTF-8">
|
|
12
|
+
* <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
13
|
+
* <title>My Website</title>
|
|
14
|
+
* <link rel="stylesheet" href="styles.css">
|
|
15
|
+
* </head>
|
|
16
|
+
* <body>
|
|
17
|
+
* <header>
|
|
18
|
+
* <h1>Welcome to My Website</h1>
|
|
19
|
+
* </header>
|
|
20
|
+
* <main>
|
|
21
|
+
* <p>This is the main content of the page.</p>
|
|
22
|
+
* </main>
|
|
23
|
+
* <footer>
|
|
24
|
+
* <p>© 2024 My Company</p>
|
|
25
|
+
* </footer>
|
|
26
|
+
* </body>
|
|
27
|
+
* </html>`
|
|
28
|
+
* );
|
|
29
|
+
*/
|
|
30
|
+
export function StaticHTMLFile(id, ...args) {
|
|
31
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
32
|
+
return File(id, {
|
|
33
|
+
path,
|
|
34
|
+
content,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -4,7 +4,7 @@ import { File } from "./file";
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* // Create a JSON configuration file
|
|
7
|
-
* const config = await
|
|
7
|
+
* const config = await StaticJsonFile("config.json", {
|
|
8
8
|
* api: {
|
|
9
9
|
* endpoint: "https://api.example.com",
|
|
10
10
|
* version: "v1"
|
|
@@ -13,4 +13,4 @@ import { File } from "./file";
|
|
|
13
13
|
* });
|
|
14
14
|
*/
|
|
15
15
|
export type StaticJsonFile = File;
|
|
16
|
-
export declare function StaticJsonFile(id: string, content: any): Promise<StaticJsonFile>;
|
|
16
|
+
export declare function StaticJsonFile(id: string, ...args: [content: any] | [path: string, content: any]): Promise<StaticJsonFile>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { File } from "./file";
|
|
2
|
-
export async function StaticJsonFile(id,
|
|
2
|
+
export async function StaticJsonFile(id, ...args) {
|
|
3
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
3
4
|
const prettier = await import("prettier");
|
|
4
5
|
return File(id, {
|
|
5
|
-
path
|
|
6
|
+
path,
|
|
6
7
|
content: await prettier.format(JSON.stringify(content), {
|
|
7
8
|
parser: "json",
|
|
8
9
|
editor: {
|
|
@@ -9,4 +9,4 @@ import { File } from "./file";
|
|
|
9
9
|
* );
|
|
10
10
|
*/
|
|
11
11
|
export type StaticTextFile = File;
|
|
12
|
-
export declare function StaticTextFile(id: string, content: string): Promise<StaticTextFile>;
|
|
12
|
+
export declare function StaticTextFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticTextFile>;
|
|
@@ -4,7 +4,7 @@ import { File } from "./file";
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* // Create a TypeScript file
|
|
7
|
-
* const component = await
|
|
7
|
+
* const component = await StaticTypeScriptFile("Component.ts", `
|
|
8
8
|
* interface Props {
|
|
9
9
|
* name: string;
|
|
10
10
|
* age: number;
|
|
@@ -16,4 +16,4 @@ import { File } from "./file";
|
|
|
16
16
|
* `);
|
|
17
17
|
*/
|
|
18
18
|
export type StaticTypeScriptFile = File;
|
|
19
|
-
export declare function StaticTypeScriptFile(id: string, content: string): Promise<StaticTypeScriptFile>;
|
|
19
|
+
export declare function StaticTypeScriptFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticTypeScriptFile>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { File } from "./file";
|
|
2
|
-
export async function StaticTypeScriptFile(id,
|
|
2
|
+
export async function StaticTypeScriptFile(id, ...args) {
|
|
3
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
3
4
|
const prettier = await import("prettier");
|
|
4
5
|
return File(id, {
|
|
5
|
-
path
|
|
6
|
+
path,
|
|
6
7
|
content: await prettier.format(content, {
|
|
7
8
|
parser: "typescript",
|
|
8
9
|
editor: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
export type StaticVueFile = File;
|
|
3
|
+
/**
|
|
4
|
+
* Creates a static Vue component file
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Create a Vue component file with content
|
|
8
|
+
* const button = await StaticVueFile("Button.vue",
|
|
9
|
+
* `<template>
|
|
10
|
+
* <button class="btn">{{ text }}</button>
|
|
11
|
+
* </template>
|
|
12
|
+
*
|
|
13
|
+
* <script>
|
|
14
|
+
* export default {
|
|
15
|
+
* props: {
|
|
16
|
+
* text: String
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <style>
|
|
22
|
+
* .btn {
|
|
23
|
+
* padding: 0.5rem 1rem;
|
|
24
|
+
* }
|
|
25
|
+
* </style>`
|
|
26
|
+
* );
|
|
27
|
+
*/
|
|
28
|
+
export declare function StaticVueFile(id: string, ...args: [content: string] | [path: string, content: string]): Promise<StaticVueFile>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { File } from "./file";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a static Vue component file
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Create a Vue component file with content
|
|
7
|
+
* const button = await StaticVueFile("Button.vue",
|
|
8
|
+
* `<template>
|
|
9
|
+
* <button class="btn">{{ text }}</button>
|
|
10
|
+
* </template>
|
|
11
|
+
*
|
|
12
|
+
* <script>
|
|
13
|
+
* export default {
|
|
14
|
+
* props: {
|
|
15
|
+
* text: String
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* </script>
|
|
19
|
+
*
|
|
20
|
+
* <style>
|
|
21
|
+
* .btn {
|
|
22
|
+
* padding: 0.5rem 1rem;
|
|
23
|
+
* }
|
|
24
|
+
* </style>`
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
27
|
+
export function StaticVueFile(id, ...args) {
|
|
28
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
29
|
+
return File(id, {
|
|
30
|
+
path,
|
|
31
|
+
content,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -4,16 +4,19 @@ import { File } from "./file";
|
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* // Create a YAML configuration file
|
|
7
|
-
* const config = await
|
|
8
|
-
* server:
|
|
9
|
-
* host: "localhost"
|
|
7
|
+
* const config = await StaticYamlFile("config.yaml", {
|
|
8
|
+
* server: {
|
|
9
|
+
* host: "localhost",
|
|
10
10
|
* port: 3000
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* },
|
|
12
|
+
* database: {
|
|
13
|
+
* url: "postgresql://localhost:5432/db",
|
|
14
|
+
* pool: {
|
|
15
|
+
* min: 1,
|
|
15
16
|
* max: 10
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
16
19
|
* });
|
|
17
20
|
*/
|
|
18
21
|
export type StaticYamlFile = File;
|
|
19
|
-
export declare function StaticYamlFile(id: string, content: any): Promise<StaticYamlFile>;
|
|
22
|
+
export declare function StaticYamlFile(id: string, ...args: [content: any] | [path: string, content: any]): Promise<StaticYamlFile>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { File } from "./file";
|
|
2
|
-
export async function StaticYamlFile(id,
|
|
2
|
+
export async function StaticYamlFile(id, ...args) {
|
|
3
|
+
const [path, content] = args.length === 1 ? [id, args[0]] : args;
|
|
3
4
|
const yaml = await import("yaml");
|
|
4
5
|
return File(id, {
|
|
5
|
-
path
|
|
6
|
+
path,
|
|
6
7
|
content: yaml.stringify(content),
|
|
7
8
|
});
|
|
8
9
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { Document } from "
|
|
2
|
-
import { Folder } from "
|
|
1
|
+
import { Document } from "../../ai";
|
|
2
|
+
import { Folder } from "../../fs";
|
|
3
3
|
export interface DocsProps {
|
|
4
4
|
/**
|
|
5
5
|
* The output directory for the docs.
|
|
6
6
|
*/
|
|
7
7
|
outDir: string | Folder;
|
|
8
|
+
/**
|
|
9
|
+
* The source directory for the docs.
|
|
10
|
+
*/
|
|
11
|
+
srcDir: string;
|
|
8
12
|
/**
|
|
9
13
|
* Whether to filter the docs.
|
|
10
14
|
* If true, include all docs.
|
|
@@ -14,10 +18,16 @@ export interface DocsProps {
|
|
|
14
18
|
* @default true (all docs)
|
|
15
19
|
*/
|
|
16
20
|
filter?: boolean | number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to run in parallel.
|
|
23
|
+
*
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
parallel?: boolean;
|
|
17
27
|
}
|
|
18
|
-
export type
|
|
28
|
+
export type Providers = {
|
|
19
29
|
dir: string;
|
|
20
30
|
provider: string;
|
|
21
31
|
documents: Document[];
|
|
22
32
|
}[];
|
|
23
|
-
export declare function
|
|
33
|
+
export declare function Providers({ srcDir, outDir, filter, parallel, }: DocsProps): Promise<Providers>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { type } from "arktype";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { Data, Document } from "../../ai";
|
|
5
|
+
import { alchemy } from "../../alchemy";
|
|
6
|
+
import { Folder } from "../../fs";
|
|
7
|
+
export async function Providers({ srcDir, outDir, filter, parallel = true, }) {
|
|
8
|
+
outDir = typeof outDir === "string" ? outDir : outDir.path;
|
|
9
|
+
const exclude = [
|
|
10
|
+
"util",
|
|
11
|
+
"test",
|
|
12
|
+
"vitepress",
|
|
13
|
+
"vite",
|
|
14
|
+
"shadcn",
|
|
15
|
+
"internal",
|
|
16
|
+
"web",
|
|
17
|
+
];
|
|
18
|
+
// Get all folders in the alchemy/src directory
|
|
19
|
+
let providers = (await fs.readdir(srcDir, {
|
|
20
|
+
withFileTypes: true,
|
|
21
|
+
}))
|
|
22
|
+
.filter((dirent) => dirent.isDirectory() && !exclude.includes(dirent.name))
|
|
23
|
+
.map((dirent) => path.join(dirent.parentPath, dirent.name));
|
|
24
|
+
// For each provider, list all files
|
|
25
|
+
if (filter === false) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
else if (typeof filter === "number") {
|
|
29
|
+
providers = providers.slice(0, filter);
|
|
30
|
+
}
|
|
31
|
+
if (parallel) {
|
|
32
|
+
return await Promise.all(providers.map((provider) => generateProviderDocs({ provider, outDir, parallel })));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const generatedProviders = [];
|
|
36
|
+
for (const provider of providers) {
|
|
37
|
+
generatedProviders.push(await generateProviderDocs({ provider, outDir, parallel }));
|
|
38
|
+
}
|
|
39
|
+
return generatedProviders;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function generateProviderDocs({ provider, outDir, parallel, }) {
|
|
43
|
+
const providerName = path.basename(provider);
|
|
44
|
+
const files = (await fs.readdir(path.resolve(provider), {
|
|
45
|
+
withFileTypes: true,
|
|
46
|
+
}))
|
|
47
|
+
.filter((dirent) => dirent.isFile())
|
|
48
|
+
.map((dirent) => path.relative(process.cwd(), path.resolve(provider, dirent.name)))
|
|
49
|
+
.filter((file) => file.endsWith(".ts") && !file.endsWith("index.ts"));
|
|
50
|
+
const { object: { groups }, } = await Data(`docs/${providerName}`, {
|
|
51
|
+
model: {
|
|
52
|
+
id: "o3-mini",
|
|
53
|
+
provider: "openai",
|
|
54
|
+
options: {
|
|
55
|
+
reasoningEffort: "high",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
temperature: 0.1,
|
|
59
|
+
schema: type({
|
|
60
|
+
groups: type({
|
|
61
|
+
identifier: type("string").describe("The identifier of the file's primary exported Resource/Function/Type, e.g. Bucket or StaticSite, AstroFile, TypeScriptFile"),
|
|
62
|
+
filename: type("string").describe("The filename of the Resource's Document, e.g. bucket.md or static-site.md"),
|
|
63
|
+
category: type("'Resource'|'Client'|'Utility'|'Types'").describe("The classification of the Resource's Document, one of: Resource, Client, Utility, or Types."),
|
|
64
|
+
}).array(),
|
|
65
|
+
}),
|
|
66
|
+
system: await alchemy `
|
|
67
|
+
You are a technical writer tasked with identifying the distinct documents that need to be written for a document group (folder) in a documentation site.
|
|
68
|
+
You will be provided with a list of documents and instructions on how to classify them.
|
|
69
|
+
Each document has a title, file name, and category.
|
|
70
|
+
`,
|
|
71
|
+
prompt: await alchemy `
|
|
72
|
+
Identify and classify the documents that need to be written for the '${provider}' Service's Alchemy Resources.
|
|
73
|
+
For background knowledge on Alchemy, see ${alchemy.file("./README.md")}.
|
|
74
|
+
For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("./.cursorrules")}.
|
|
75
|
+
|
|
76
|
+
The ${provider} Service has the following resources:
|
|
77
|
+
${alchemy.files(files)}
|
|
78
|
+
|
|
79
|
+
A file is considered a "Resource" if it contains a const <ResourceName> = Resource(...) call or if it is a function that calls a Resource function, e.g. const TypeScriptFile = () => File(...).
|
|
80
|
+
A file is considered a "Client" if it exposes a wrapper around creating a SDK client or fetch.
|
|
81
|
+
A file is considered a "Utility" if it contains utility functions that are not resources or clients.
|
|
82
|
+
A file is considered a "Types" if it contains just type definitions and maybe helpers around working with those types.
|
|
83
|
+
|
|
84
|
+
The title should be simply the name of the resource's const in code (with spaces added in between each word), e.g. "Bucket" or "Function", except with spaces, e.g. "Static Site" for "const StaticSite". Maintain all other casing.
|
|
85
|
+
|
|
86
|
+
// "Resource Name"
|
|
87
|
+
const ResourceName = Resource(...)
|
|
88
|
+
`,
|
|
89
|
+
});
|
|
90
|
+
const providerDocsDir = (await Folder(path.join(outDir, providerName))).path;
|
|
91
|
+
let documents = [];
|
|
92
|
+
if (parallel) {
|
|
93
|
+
documents = await Promise.all(groups.filter((g) => g.category === "Resource").map(generateDocument));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
for (const g of groups.filter((g) => g.category === "Resource")) {
|
|
97
|
+
documents.push(await generateDocument(g));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function generateDocument(g) {
|
|
101
|
+
return Document(`docs/${providerName}/${g.identifier}`, {
|
|
102
|
+
title: g.identifier,
|
|
103
|
+
path: path.join(providerDocsDir, `${g.filename.replace(".ts", "").replace(".md", "")}.md`),
|
|
104
|
+
freeze: true,
|
|
105
|
+
model: {
|
|
106
|
+
id: "claude-3-5-sonnet-latest",
|
|
107
|
+
provider: "anthropic",
|
|
108
|
+
// options: {
|
|
109
|
+
// reasoningEffort: "high",
|
|
110
|
+
// },
|
|
111
|
+
},
|
|
112
|
+
prompt: await alchemy `
|
|
113
|
+
You are a technical writer writing API documentation for an Alchemy IaC Resource.
|
|
114
|
+
See ${alchemy.file("./README.md")} to understand the overview of Alchemy.
|
|
115
|
+
See ${alchemy.file("./.cursorrules")} to better understand the structure and convention of an Alchemy Resource.
|
|
116
|
+
|
|
117
|
+
Relevant files for the ${providerName} Service:
|
|
118
|
+
${alchemy.files(files)}
|
|
119
|
+
|
|
120
|
+
Write concise documentation for the "${g.identifier}" Resource.
|
|
121
|
+
|
|
122
|
+
> [!CAUTION]
|
|
123
|
+
> Avoid the temptation to over explain or over describe. Focus on concise, simple, high value snippets. One heading and 0-1 descriptions per snippet.
|
|
124
|
+
|
|
125
|
+
> [!TIP]
|
|
126
|
+
> Make sure the examples follow a natural progression from the minimal example to logical next steps of how the Resource might be used.
|
|
127
|
+
|
|
128
|
+
Each document must follow the following format:
|
|
129
|
+
|
|
130
|
+
# ${g.identifier}
|
|
131
|
+
|
|
132
|
+
(simple description with an external link to the provider's website)
|
|
133
|
+
e.g.
|
|
134
|
+
The Efs component lets you add [Amazon Elastic File System (EFS)](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html) to your app.
|
|
135
|
+
|
|
136
|
+
# Minimal Example
|
|
137
|
+
|
|
138
|
+
(brief 1-2 sentences of what it does)
|
|
139
|
+
|
|
140
|
+
\`\`\`ts
|
|
141
|
+
import { ${g.identifier.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
142
|
+
|
|
143
|
+
(example)
|
|
144
|
+
\`\`\`
|
|
145
|
+
|
|
146
|
+
# (one heading per variation)
|
|
147
|
+
|
|
148
|
+
(brief 1-2 sentences of what it does)
|
|
149
|
+
|
|
150
|
+
\`\`\`ts
|
|
151
|
+
import { ${g.identifier.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
152
|
+
|
|
153
|
+
(example)
|
|
154
|
+
\`\`\`
|
|
155
|
+
|
|
156
|
+
Before writing the document, think through:
|
|
157
|
+
1. What is the minimal, most common example use case for this resource?
|
|
158
|
+
2. What are the variations (e.g. combination of different options) that are also commonly used, e.g. specifying the memory size of a lambda function.
|
|
159
|
+
3. Make sure to draw from the examples and your understanding of Alchemy.
|
|
160
|
+
|
|
161
|
+
Refer to alchemy docs to understand the context of how this documentation is consumed:
|
|
162
|
+
- ${alchemy.file("./alchemy-web/docs/what-is-alchemy.md")}
|
|
163
|
+
- ${alchemy.file("./alchemy-web/docs/getting-started.md")}
|
|
164
|
+
- ${alchemy.folder("./alchemy-web/docs/concepts/")}
|
|
165
|
+
|
|
166
|
+
${providerName === "cloudflare"
|
|
167
|
+
? await alchemy `# Bind to a Worker
|
|
168
|
+
(if it is a Cloudflare Resource)
|
|
169
|
+
|
|
170
|
+
(brief 1-2 sentences of what it does)
|
|
171
|
+
|
|
172
|
+
\`\`\`ts
|
|
173
|
+
import { Worker, ${g.identifier.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
174
|
+
|
|
175
|
+
const myResource = await ${g.identifier.replaceAll(" ", "")}("my-resource", {
|
|
176
|
+
// ...
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
await Worker("my-worker", {
|
|
180
|
+
name: "my-worker",
|
|
181
|
+
script: "console.log('Hello, world!')",
|
|
182
|
+
bindings: {
|
|
183
|
+
myResource,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
\`\`\``
|
|
187
|
+
: ""}
|
|
188
|
+
`,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
dir: providerDocsDir,
|
|
193
|
+
provider: providerName,
|
|
194
|
+
documents,
|
|
195
|
+
};
|
|
196
|
+
}
|
package/lib/secret.d.ts
CHANGED
|
@@ -72,3 +72,6 @@ export declare function isSecret(binding: any): binding is Secret;
|
|
|
72
72
|
* @throws {Error} If no password is set in the alchemy application options or current scope
|
|
73
73
|
*/
|
|
74
74
|
export declare function secret<S extends string | undefined>(unencrypted: S): Secret;
|
|
75
|
+
export declare namespace secret {
|
|
76
|
+
function env(name: string, value?: string, error?: string): Promise<Secret>;
|
|
77
|
+
}
|
package/lib/secret.js
CHANGED
|
@@ -82,3 +82,16 @@ export function secret(unencrypted) {
|
|
|
82
82
|
}
|
|
83
83
|
return new Secret(unencrypted);
|
|
84
84
|
}
|
|
85
|
+
(function (secret) {
|
|
86
|
+
async function env(name, value, error) {
|
|
87
|
+
const alchemy = await import("./alchemy");
|
|
88
|
+
const result = await alchemy.env(name, value, error);
|
|
89
|
+
if (typeof result === "string") {
|
|
90
|
+
return secret(result);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
throw new Error(`Secret environment variable ${name} is not a string`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
secret.env = env;
|
|
97
|
+
})(secret || (secret = {}));
|