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
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import alchemy from "alchemy";
|
|
2
|
-
import { Data, Document } from "alchemy/ai";
|
|
3
|
-
import { Folder } from "alchemy/fs";
|
|
4
|
-
import { type } from "arktype";
|
|
5
|
-
import fs from "fs/promises";
|
|
6
|
-
import path from "path";
|
|
7
|
-
|
|
8
|
-
export interface DocsProps {
|
|
9
|
-
/**
|
|
10
|
-
* The output directory for the docs.
|
|
11
|
-
*/
|
|
12
|
-
outDir: string | Folder;
|
|
13
|
-
/**
|
|
14
|
-
* Whether to filter the docs.
|
|
15
|
-
* If true, include all docs.
|
|
16
|
-
* If false, include none.
|
|
17
|
-
* If a number, include that many providers.
|
|
18
|
-
*
|
|
19
|
-
* @default true (all docs)
|
|
20
|
-
*/
|
|
21
|
-
filter?: boolean | number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type AlchemyProviderDocs = {
|
|
25
|
-
dir: string;
|
|
26
|
-
provider: string;
|
|
27
|
-
documents: Document[];
|
|
28
|
-
}[];
|
|
29
|
-
|
|
30
|
-
export async function AlchemyProviderDocs({
|
|
31
|
-
outDir,
|
|
32
|
-
filter,
|
|
33
|
-
}: DocsProps): Promise<AlchemyProviderDocs> {
|
|
34
|
-
outDir = typeof outDir === "string" ? outDir : outDir.path;
|
|
35
|
-
const providersDir = (await Folder(path.join(outDir, "providers"))).path;
|
|
36
|
-
|
|
37
|
-
const exclude = ["util", "test", "vitepress", "vite", "shadcn", "internal"];
|
|
38
|
-
|
|
39
|
-
// Get all folders in the alchemy/src directory
|
|
40
|
-
let providers = (
|
|
41
|
-
await fs.readdir(path.resolve("..", "alchemy", "src"), {
|
|
42
|
-
withFileTypes: true,
|
|
43
|
-
})
|
|
44
|
-
)
|
|
45
|
-
.filter((dirent) => dirent.isDirectory() && !exclude.includes(dirent.name))
|
|
46
|
-
.map((dirent) => path.join(dirent.parentPath, dirent.name));
|
|
47
|
-
|
|
48
|
-
// For each provider, list all files
|
|
49
|
-
if (filter === false) {
|
|
50
|
-
return [];
|
|
51
|
-
} else if (typeof filter === "number") {
|
|
52
|
-
providers = providers.slice(0, filter);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return await Promise.all(
|
|
56
|
-
providers.map(async (provider) => {
|
|
57
|
-
const providerName = path.basename(provider);
|
|
58
|
-
const files = (
|
|
59
|
-
await fs.readdir(path.resolve(provider), {
|
|
60
|
-
withFileTypes: true,
|
|
61
|
-
})
|
|
62
|
-
)
|
|
63
|
-
.filter((dirent) => dirent.isFile())
|
|
64
|
-
.map((dirent) =>
|
|
65
|
-
path.relative(process.cwd(), path.resolve(provider, dirent.name)),
|
|
66
|
-
)
|
|
67
|
-
.filter((file) => file.endsWith(".ts") && !file.endsWith("index.ts"));
|
|
68
|
-
|
|
69
|
-
const {
|
|
70
|
-
object: { groups },
|
|
71
|
-
} = await Data(`docs/${providerName}`, {
|
|
72
|
-
model: {
|
|
73
|
-
id: "gpt-4o",
|
|
74
|
-
provider: "openai",
|
|
75
|
-
// options: {
|
|
76
|
-
// reasoningEffort: "high",
|
|
77
|
-
// },
|
|
78
|
-
},
|
|
79
|
-
temperature: 0.1,
|
|
80
|
-
schema: type({
|
|
81
|
-
groups: type({
|
|
82
|
-
title: type("string").describe(
|
|
83
|
-
"The title of the group, should be the Resource Name exactly as it's defined in code (const ResourceName translates to 'Resource Name') without spaces, e.g. Bucket or Static Site.",
|
|
84
|
-
),
|
|
85
|
-
filename: type("string").describe(
|
|
86
|
-
"The filename of the Resource's Document, e.g. bucket.md or static-site.md",
|
|
87
|
-
),
|
|
88
|
-
category: type("'Resource'|'Client'|'Utility'|'Types'").describe(
|
|
89
|
-
"The classification of the Resource's Document, one of: Resource, Client, Utility, or Types.",
|
|
90
|
-
),
|
|
91
|
-
}).array(),
|
|
92
|
-
}),
|
|
93
|
-
system: await alchemy`
|
|
94
|
-
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.
|
|
95
|
-
You will be provided with a list of documents and instructions on how to classify them.
|
|
96
|
-
Each document has a title, file name, and category.
|
|
97
|
-
`,
|
|
98
|
-
prompt: await alchemy`
|
|
99
|
-
Identify and classify the documents that need to be written for the '${provider}' Service's Alchemy Resources.
|
|
100
|
-
For background knowledge on Alchemy, see ${alchemy.file("../README.md")}.
|
|
101
|
-
For background knowledge on the structure of an Alchemy Resource, see ${alchemy.file("../.cursorrules")}.
|
|
102
|
-
|
|
103
|
-
The ${provider} Service has the following resources:
|
|
104
|
-
${alchemy.files(files)}
|
|
105
|
-
|
|
106
|
-
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(...).
|
|
107
|
-
A file is considered a "Client" if it exposes a wrapper around creating a SDK client or fetch.
|
|
108
|
-
A file is considered a "Utility" if it contains utility functions that are not resources or clients.
|
|
109
|
-
A file is considered a "Types" if it contains just type definitions and maybe helpers around working with those types.
|
|
110
|
-
|
|
111
|
-
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.
|
|
112
|
-
|
|
113
|
-
// "Resource Name"
|
|
114
|
-
const ResourceName = Resource(...)
|
|
115
|
-
`,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// console.log(groups);
|
|
119
|
-
|
|
120
|
-
const providerDocsDir = (
|
|
121
|
-
await Folder(path.join(providersDir, providerName))
|
|
122
|
-
).path;
|
|
123
|
-
|
|
124
|
-
const documents = await Promise.all(
|
|
125
|
-
groups
|
|
126
|
-
.filter((g) => g.category === "Resource")
|
|
127
|
-
.map(async (g) =>
|
|
128
|
-
Document(`docs/${providerName}/${g.title}`, {
|
|
129
|
-
title: g.title,
|
|
130
|
-
path: path.join(
|
|
131
|
-
providerDocsDir,
|
|
132
|
-
`${g.filename.replace(".ts", "").replace(".md", "")}.md`,
|
|
133
|
-
),
|
|
134
|
-
prompt: await alchemy`
|
|
135
|
-
You are a technical writer writing API documentation for an Alchemy IaC Resource.
|
|
136
|
-
See ${alchemy.file("../README.md")} to understand the overview of Alchemy.
|
|
137
|
-
See ${alchemy.file("../.cursorrules")} to better understand the structure and convention of an Alchemy Resource.
|
|
138
|
-
|
|
139
|
-
Relevant files for the ${providerName} Service:
|
|
140
|
-
${alchemy.files(files)}
|
|
141
|
-
|
|
142
|
-
Write concise documentation for the "${g.title}" Resource.
|
|
143
|
-
|
|
144
|
-
> [!CAUTION]
|
|
145
|
-
> Avoid the temptation to over explain or over describe. Focus on concise, simple, high value snippets. One heading and 0-1 descriptions per snippet.
|
|
146
|
-
|
|
147
|
-
> [!TIP]
|
|
148
|
-
> Make sure the examples follow a natural progression from the minimal example to logical next steps of how the Resource might be used.
|
|
149
|
-
|
|
150
|
-
Each document must follow the following format:
|
|
151
|
-
|
|
152
|
-
# ${g.title}
|
|
153
|
-
|
|
154
|
-
(simple description with an external link to the provider's website)
|
|
155
|
-
e.g.
|
|
156
|
-
The Efs component lets you add [Amazon Elastic File System (EFS)](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html) to your app.
|
|
157
|
-
|
|
158
|
-
# Minimal Example
|
|
159
|
-
|
|
160
|
-
\`\`\`ts
|
|
161
|
-
import { ${g.title.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
162
|
-
|
|
163
|
-
(example)
|
|
164
|
-
\`\`\`
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
# Create the ${g.title}
|
|
168
|
-
|
|
169
|
-
\`\`\`ts
|
|
170
|
-
import { ${g.title.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
171
|
-
|
|
172
|
-
(example)
|
|
173
|
-
\`\`\`
|
|
174
|
-
|
|
175
|
-
${
|
|
176
|
-
providerName === "cloudflare"
|
|
177
|
-
? await alchemy`# Bind to a Worker
|
|
178
|
-
(if it is a Cloudflare Resource)
|
|
179
|
-
|
|
180
|
-
\`\`\`ts
|
|
181
|
-
import { Worker, ${g.title.replaceAll(" ", "")} } from "alchemy/${providerName}";
|
|
182
|
-
|
|
183
|
-
const myResource = await ${g.title.replaceAll(" ", "")}("my-resource", {
|
|
184
|
-
// ...
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
await Worker("my-worker", {
|
|
188
|
-
name: "my-worker",
|
|
189
|
-
script: "console.log('Hello, world!')",
|
|
190
|
-
bindings: {
|
|
191
|
-
myResource,
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
\`\`\``
|
|
195
|
-
: ""
|
|
196
|
-
}
|
|
197
|
-
`,
|
|
198
|
-
}),
|
|
199
|
-
),
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
return {
|
|
203
|
-
dir: providerDocsDir,
|
|
204
|
-
provider: providerName,
|
|
205
|
-
documents,
|
|
206
|
-
} as const;
|
|
207
|
-
}),
|
|
208
|
-
);
|
|
209
|
-
}
|
|
File without changes
|