alchemy 0.7.3 → 0.8.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/lib/aws/table.js +22 -5
- package/lib/esbuild/bundle.d.ts +11 -14
- package/lib/esbuild/bundle.js +6 -3
- package/lib/web/vitepress/process-front-matter-files.js +1 -1
- package/package.json +1 -1
- package/src/aws/table.ts +34 -16
- package/src/esbuild/bundle.ts +6 -3
- package/src/web/vitepress/process-front-matter-files.ts +1 -1
package/lib/aws/table.js
CHANGED
|
@@ -45,9 +45,9 @@ export const Table = Resource("dynamo::Table", async function (id, props) {
|
|
|
45
45
|
await ignore(ResourceNotFoundException.name, () => client.send(new DeleteTableCommand({
|
|
46
46
|
TableName: props.tableName,
|
|
47
47
|
})));
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
}, isRetryableError, 10, // Max attempts
|
|
49
|
+
200 // Initial delay in ms
|
|
50
|
+
);
|
|
51
51
|
// Wait for table to be deleted
|
|
52
52
|
let tableDeleted = false;
|
|
53
53
|
let retryCount = 0;
|
|
@@ -143,8 +143,9 @@ export const Table = Resource("dynamo::Table", async function (id, props) {
|
|
|
143
143
|
throw error;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
},
|
|
147
|
-
200
|
|
146
|
+
}, isRetryableError, 10, // Max attempts
|
|
147
|
+
200 // Initial delay in ms
|
|
148
|
+
);
|
|
148
149
|
// Wait for table to be active with timeout
|
|
149
150
|
let tableActive = false;
|
|
150
151
|
let tableDescription;
|
|
@@ -185,3 +186,19 @@ export const Table = Resource("dynamo::Table", async function (id, props) {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
});
|
|
189
|
+
const retryableErrors = [
|
|
190
|
+
"ResourceInUseException",
|
|
191
|
+
"ResourceNotFoundException",
|
|
192
|
+
"InternalServerError",
|
|
193
|
+
"ThrottlingException",
|
|
194
|
+
"ProvisionedThroughputExceededException",
|
|
195
|
+
"LimitExceededException",
|
|
196
|
+
"RequestLimitExceeded",
|
|
197
|
+
];
|
|
198
|
+
function isRetryableError(error) {
|
|
199
|
+
return (error instanceof ResourceInUseException ||
|
|
200
|
+
error instanceof InternalServerError ||
|
|
201
|
+
retryableErrors.includes(error?.name) ||
|
|
202
|
+
retryableErrors.includes(error?.code) ||
|
|
203
|
+
error?.$metadata?.httpStatusCode === 500);
|
|
204
|
+
}
|
package/lib/esbuild/bundle.d.ts
CHANGED
|
@@ -94,14 +94,21 @@ export interface Bundle extends Resource<"esbuild::Bundle"> {
|
|
|
94
94
|
*/
|
|
95
95
|
export declare const Bundle: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<Bundle>, id: string, props: BundleProps) => Promise<Bundle>);
|
|
96
96
|
export declare function bundle(props: BundleProps): Promise<esbuild.BuildResult<{
|
|
97
|
-
|
|
97
|
+
entryPoints: string[];
|
|
98
|
+
outfile: string;
|
|
99
|
+
bundle: true;
|
|
100
|
+
format: "iife" | "cjs" | "esm" | undefined;
|
|
101
|
+
target: string | string[] | undefined;
|
|
102
|
+
minify: boolean | undefined;
|
|
103
|
+
sourcemap: boolean | "inline" | "external" | "both" | undefined;
|
|
104
|
+
external: string[];
|
|
105
|
+
platform: "browser" | "node" | "neutral" | undefined;
|
|
106
|
+
metafile: true;
|
|
107
|
+
write: true;
|
|
98
108
|
splitting?: boolean;
|
|
99
109
|
preserveSymlinks?: boolean;
|
|
100
|
-
outfile: string;
|
|
101
|
-
metafile: boolean;
|
|
102
110
|
outdir?: string;
|
|
103
111
|
outbase?: string;
|
|
104
|
-
external: string[];
|
|
105
112
|
packages?: "bundle" | "external";
|
|
106
113
|
alias?: Record<string, string>;
|
|
107
114
|
loader?: {
|
|
@@ -110,7 +117,6 @@ export declare function bundle(props: BundleProps): Promise<esbuild.BuildResult<
|
|
|
110
117
|
resolveExtensions?: string[];
|
|
111
118
|
mainFields?: string[];
|
|
112
119
|
conditions?: string[];
|
|
113
|
-
write: boolean;
|
|
114
120
|
allowOverwrite?: boolean;
|
|
115
121
|
tsconfig?: string;
|
|
116
122
|
outExtension?: {
|
|
@@ -127,30 +133,21 @@ export declare function bundle(props: BundleProps): Promise<esbuild.BuildResult<
|
|
|
127
133
|
footer?: {
|
|
128
134
|
[type: string]: string;
|
|
129
135
|
};
|
|
130
|
-
entryPoints: string[] | Record<string, string> | {
|
|
131
|
-
in: string;
|
|
132
|
-
out: string;
|
|
133
|
-
}[];
|
|
134
136
|
stdin?: esbuild.StdinOptions;
|
|
135
137
|
plugins?: esbuild.Plugin[];
|
|
136
138
|
absWorkingDir?: string;
|
|
137
139
|
nodePaths?: string[];
|
|
138
|
-
sourcemap: boolean | "linked" | "inline" | "external" | "both";
|
|
139
140
|
legalComments?: "none" | "inline" | "eof" | "linked" | "external";
|
|
140
141
|
sourceRoot?: string;
|
|
141
142
|
sourcesContent?: boolean;
|
|
142
|
-
format: esbuild.Format;
|
|
143
143
|
globalName?: string;
|
|
144
|
-
target: string | string[];
|
|
145
144
|
supported?: Record<string, boolean>;
|
|
146
|
-
platform: esbuild.Platform;
|
|
147
145
|
mangleProps?: RegExp;
|
|
148
146
|
reserveProps?: RegExp;
|
|
149
147
|
mangleQuoted?: boolean;
|
|
150
148
|
mangleCache?: Record<string, string | false>;
|
|
151
149
|
drop?: esbuild.Drop[];
|
|
152
150
|
dropLabels?: string[];
|
|
153
|
-
minify: boolean;
|
|
154
151
|
minifyWhitespace?: boolean;
|
|
155
152
|
minifyIdentifiers?: boolean;
|
|
156
153
|
minifySyntax?: boolean;
|
package/lib/esbuild/bundle.js
CHANGED
|
@@ -47,8 +47,8 @@ export const Bundle = Resource("esbuild::Bundle", {
|
|
|
47
47
|
});
|
|
48
48
|
export async function bundle(props) {
|
|
49
49
|
const outputPath = getOutputPath(props);
|
|
50
|
-
// Build the bundle
|
|
51
50
|
return await esbuild.build({
|
|
51
|
+
...props.options,
|
|
52
52
|
entryPoints: [props.entryPoint],
|
|
53
53
|
outfile: outputPath,
|
|
54
54
|
bundle: true,
|
|
@@ -56,11 +56,14 @@ export async function bundle(props) {
|
|
|
56
56
|
target: props.target,
|
|
57
57
|
minify: props.minify,
|
|
58
58
|
sourcemap: props.sourcemap,
|
|
59
|
-
external:
|
|
59
|
+
external: [
|
|
60
|
+
"node:async_hooks",
|
|
61
|
+
...(props.external ?? []),
|
|
62
|
+
...(props.options?.external ?? []),
|
|
63
|
+
],
|
|
60
64
|
platform: props.platform,
|
|
61
65
|
metafile: true,
|
|
62
66
|
write: true,
|
|
63
|
-
...props.options,
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
function getOutputPath(props) {
|
|
@@ -35,7 +35,7 @@ export async function processFrontmatterFiles(directoryPath, linkPrefix) {
|
|
|
35
35
|
const frontmatter = frontmatterMatch[1];
|
|
36
36
|
const orderMatch = frontmatter.match(/order:\s*(\d+)/);
|
|
37
37
|
if (orderMatch) {
|
|
38
|
-
order =
|
|
38
|
+
order = parseFloat(orderMatch[1]);
|
|
39
39
|
}
|
|
40
40
|
const titleMatch = frontmatter.match(/title:\s*(.+)/);
|
|
41
41
|
if (titleMatch) {
|
package/package.json
CHANGED
package/src/aws/table.ts
CHANGED
|
@@ -143,7 +143,7 @@ export const Table = Resource(
|
|
|
143
143
|
async function (
|
|
144
144
|
this: Context<Table>,
|
|
145
145
|
id: string,
|
|
146
|
-
props: TableProps
|
|
146
|
+
props: TableProps
|
|
147
147
|
): Promise<Table> {
|
|
148
148
|
const client = new DynamoDBClient({});
|
|
149
149
|
|
|
@@ -154,15 +154,13 @@ export const Table = Resource(
|
|
|
154
154
|
client.send(
|
|
155
155
|
new DeleteTableCommand({
|
|
156
156
|
TableName: props.tableName,
|
|
157
|
-
})
|
|
158
|
-
)
|
|
157
|
+
})
|
|
158
|
+
)
|
|
159
159
|
);
|
|
160
160
|
},
|
|
161
|
-
|
|
162
|
-
error instanceof ResourceInUseException ||
|
|
163
|
-
error instanceof InternalServerError,
|
|
161
|
+
isRetryableError,
|
|
164
162
|
10, // Max attempts
|
|
165
|
-
200
|
|
163
|
+
200 // Initial delay in ms
|
|
166
164
|
);
|
|
167
165
|
|
|
168
166
|
// Wait for table to be deleted
|
|
@@ -175,7 +173,7 @@ export const Table = Resource(
|
|
|
175
173
|
await client.send(
|
|
176
174
|
new DescribeTableCommand({
|
|
177
175
|
TableName: props.tableName,
|
|
178
|
-
})
|
|
176
|
+
})
|
|
179
177
|
);
|
|
180
178
|
// If we get here, table still exists
|
|
181
179
|
retryCount++;
|
|
@@ -193,7 +191,7 @@ export const Table = Resource(
|
|
|
193
191
|
|
|
194
192
|
if (!tableDeleted) {
|
|
195
193
|
throw new Error(
|
|
196
|
-
`Timed out waiting for table ${props.tableName} to be deleted
|
|
194
|
+
`Timed out waiting for table ${props.tableName} to be deleted`
|
|
197
195
|
);
|
|
198
196
|
}
|
|
199
197
|
|
|
@@ -233,7 +231,7 @@ export const Table = Resource(
|
|
|
233
231
|
const describeResponse = await client.send(
|
|
234
232
|
new DescribeTableCommand({
|
|
235
233
|
TableName: props.tableName,
|
|
236
|
-
})
|
|
234
|
+
})
|
|
237
235
|
);
|
|
238
236
|
|
|
239
237
|
// If table exists and is ACTIVE, no need to create it
|
|
@@ -267,16 +265,16 @@ export const Table = Resource(
|
|
|
267
265
|
Value,
|
|
268
266
|
}))
|
|
269
267
|
: undefined,
|
|
270
|
-
})
|
|
268
|
+
})
|
|
271
269
|
);
|
|
272
270
|
} else {
|
|
273
271
|
throw error;
|
|
274
272
|
}
|
|
275
273
|
}
|
|
276
274
|
},
|
|
277
|
-
|
|
275
|
+
isRetryableError,
|
|
278
276
|
10, // Max attempts
|
|
279
|
-
200
|
|
277
|
+
200 // Initial delay in ms
|
|
280
278
|
);
|
|
281
279
|
|
|
282
280
|
// Wait for table to be active with timeout
|
|
@@ -290,7 +288,7 @@ export const Table = Resource(
|
|
|
290
288
|
const response = await client.send(
|
|
291
289
|
new DescribeTableCommand({
|
|
292
290
|
TableName: props.tableName,
|
|
293
|
-
})
|
|
291
|
+
})
|
|
294
292
|
);
|
|
295
293
|
|
|
296
294
|
tableActive = response.Table?.TableStatus === "ACTIVE";
|
|
@@ -313,7 +311,7 @@ export const Table = Resource(
|
|
|
313
311
|
|
|
314
312
|
if (!tableActive) {
|
|
315
313
|
throw new Error(
|
|
316
|
-
`Timed out waiting for table ${props.tableName} to become active
|
|
314
|
+
`Timed out waiting for table ${props.tableName} to become active`
|
|
317
315
|
);
|
|
318
316
|
}
|
|
319
317
|
|
|
@@ -324,5 +322,25 @@ export const Table = Resource(
|
|
|
324
322
|
tableId: tableDescription!.TableId!,
|
|
325
323
|
});
|
|
326
324
|
}
|
|
327
|
-
}
|
|
325
|
+
}
|
|
328
326
|
);
|
|
327
|
+
|
|
328
|
+
const retryableErrors = [
|
|
329
|
+
"ResourceInUseException",
|
|
330
|
+
"ResourceNotFoundException",
|
|
331
|
+
"InternalServerError",
|
|
332
|
+
"ThrottlingException",
|
|
333
|
+
"ProvisionedThroughputExceededException",
|
|
334
|
+
"LimitExceededException",
|
|
335
|
+
"RequestLimitExceeded",
|
|
336
|
+
];
|
|
337
|
+
|
|
338
|
+
function isRetryableError(error: any) {
|
|
339
|
+
return (
|
|
340
|
+
error instanceof ResourceInUseException ||
|
|
341
|
+
error instanceof InternalServerError ||
|
|
342
|
+
retryableErrors.includes(error?.name) ||
|
|
343
|
+
retryableErrors.includes(error?.code) ||
|
|
344
|
+
error?.$metadata?.httpStatusCode === 500
|
|
345
|
+
);
|
|
346
|
+
}
|
package/src/esbuild/bundle.ts
CHANGED
|
@@ -150,8 +150,8 @@ export const Bundle = Resource(
|
|
|
150
150
|
|
|
151
151
|
export async function bundle(props: BundleProps) {
|
|
152
152
|
const outputPath = getOutputPath(props);
|
|
153
|
-
// Build the bundle
|
|
154
153
|
return await esbuild.build({
|
|
154
|
+
...props.options,
|
|
155
155
|
entryPoints: [props.entryPoint],
|
|
156
156
|
outfile: outputPath,
|
|
157
157
|
bundle: true,
|
|
@@ -159,11 +159,14 @@ export async function bundle(props: BundleProps) {
|
|
|
159
159
|
target: props.target,
|
|
160
160
|
minify: props.minify,
|
|
161
161
|
sourcemap: props.sourcemap,
|
|
162
|
-
external:
|
|
162
|
+
external: [
|
|
163
|
+
"node:async_hooks",
|
|
164
|
+
...(props.external ?? []),
|
|
165
|
+
...(props.options?.external ?? []),
|
|
166
|
+
],
|
|
163
167
|
platform: props.platform,
|
|
164
168
|
metafile: true,
|
|
165
169
|
write: true,
|
|
166
|
-
...props.options,
|
|
167
170
|
});
|
|
168
171
|
}
|
|
169
172
|
|
|
@@ -58,7 +58,7 @@ export async function processFrontmatterFiles(
|
|
|
58
58
|
const frontmatter = frontmatterMatch[1];
|
|
59
59
|
const orderMatch = frontmatter.match(/order:\s*(\d+)/);
|
|
60
60
|
if (orderMatch) {
|
|
61
|
-
order =
|
|
61
|
+
order = parseFloat(orderMatch[1]);
|
|
62
62
|
}
|
|
63
63
|
const titleMatch = frontmatter.match(/title:\s*(.+)/);
|
|
64
64
|
if (titleMatch) {
|