sst 2.24.10 → 2.24.12
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/bootstrap.js +2 -0
- package/constructs/Stack.js +2 -0
- package/node/event-bus/index.d.ts +3 -2
- package/node/event-bus/index.js +41 -21
- package/node/service/index.d.ts +3 -0
- package/node/service/index.js +4 -0
- package/node/util/loader.d.ts +2 -0
- package/node/util/loader.js +51 -0
- package/package.json +1 -1
- package/project.d.ts +2 -0
- package/support/bootstrap-metadata-function/index.mjs +98 -71
- package/support/bridge/bridge.mjs +36 -36
- package/support/custom-resources/index.mjs +98 -71
- package/support/event-bus-retrier/index.mjs +24 -24
- package/support/job-manager/index.mjs +98 -71
- package/support/rds-migrator/index.mjs +15 -15
- package/support/script-function/index.mjs +98 -71
package/bootstrap.js
CHANGED
|
@@ -161,10 +161,12 @@ export async function bootstrapSST(cdkBucket) {
|
|
|
161
161
|
},
|
|
162
162
|
synthesizer: new DefaultStackSynthesizer({
|
|
163
163
|
qualifier: cdk?.qualifier,
|
|
164
|
+
bootstrapStackVersionSsmParameter: cdk?.bootstrapStackVersionSsmParameter,
|
|
164
165
|
fileAssetsBucketName: cdk?.fileAssetsBucketName,
|
|
165
166
|
deployRoleArn: cdk?.deployRoleArn,
|
|
166
167
|
fileAssetPublishingRoleArn: cdk?.fileAssetPublishingRoleArn,
|
|
167
168
|
imageAssetPublishingRoleArn: cdk?.imageAssetPublishingRoleArn,
|
|
169
|
+
imageAssetsRepositoryName: cdk?.imageAssetsRepositoryName,
|
|
168
170
|
cloudFormationExecutionRole: cdk?.cloudFormationExecutionRole,
|
|
169
171
|
lookupRoleArn: cdk?.lookupRoleArn,
|
|
170
172
|
}),
|
package/constructs/Stack.js
CHANGED
|
@@ -205,10 +205,12 @@ export class Stack extends CDKStack {
|
|
|
205
205
|
const { config } = useProject();
|
|
206
206
|
const props = {
|
|
207
207
|
qualifier: config.cdk?.qualifier,
|
|
208
|
+
bootstrapStackVersionSsmParameter: config.cdk?.bootstrapStackVersionSsmParameter,
|
|
208
209
|
fileAssetsBucketName: config.cdk?.fileAssetsBucketName,
|
|
209
210
|
deployRoleArn: config.cdk?.deployRoleArn,
|
|
210
211
|
fileAssetPublishingRoleArn: config.cdk?.fileAssetPublishingRoleArn,
|
|
211
212
|
imageAssetPublishingRoleArn: config.cdk?.imageAssetPublishingRoleArn,
|
|
213
|
+
imageAssetsRepositoryName: config.cdk?.imageAssetsRepositoryName,
|
|
212
214
|
cloudFormationExecutionRole: config.cdk?.cloudFormationExecutionRole,
|
|
213
215
|
lookupRoleArn: config.cdk?.lookupRoleArn,
|
|
214
216
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface EventBusResources {
|
|
2
2
|
}
|
|
3
3
|
export declare const EventBus: EventBusResources;
|
|
4
|
+
import { PutEventsCommandOutput } from "@aws-sdk/client-eventbridge";
|
|
4
5
|
import { EventBridgeEvent } from "aws-lambda";
|
|
5
6
|
import { ZodAny, ZodObject, ZodRawShape, z } from "zod";
|
|
6
7
|
export declare function createEventBuilder<Bus extends keyof typeof EventBus, MetadataShape extends ZodRawShape | undefined, MetadataFunction extends () => any>(props: {
|
|
@@ -8,10 +9,10 @@ export declare function createEventBuilder<Bus extends keyof typeof EventBus, Me
|
|
|
8
9
|
metadata?: MetadataShape;
|
|
9
10
|
metadataFn?: MetadataFunction;
|
|
10
11
|
}): <Type extends string, Shape extends ZodRawShape, Properties = z.objectOutputType<Shape, ZodAny, "strip">>(type: Type, properties: Shape) => {
|
|
11
|
-
publish: undefined extends MetadataShape ? (properties: Properties) => Promise<
|
|
12
|
+
publish: undefined extends MetadataShape ? (properties: Properties) => Promise<PutEventsCommandOutput> : (properties: Properties, metadata: z.infer<ZodObject<Exclude<MetadataShape, undefined>, "strip", ZodAny>>) => Promise<void>;
|
|
12
13
|
type: Type;
|
|
13
14
|
shape: {
|
|
14
|
-
metadata: Parameters<undefined extends MetadataShape ? (properties: Properties) => Promise<
|
|
15
|
+
metadata: Parameters<undefined extends MetadataShape ? (properties: Properties) => Promise<PutEventsCommandOutput> : (properties: Properties, metadata: z.infer<ZodObject<Exclude<MetadataShape, undefined>, "strip", ZodAny>>) => Promise<void>>[1];
|
|
15
16
|
properties: Properties;
|
|
16
17
|
metadataFn: ReturnType<MetadataFunction>;
|
|
17
18
|
};
|
package/node/event-bus/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export const EventBus =
|
|
|
3
3
|
/* @__PURE__ */ createProxy("EventBus");
|
|
4
4
|
import { EventBridgeClient, PutEventsCommand, } from "@aws-sdk/client-eventbridge";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
+
import { useLoader } from "../util/loader.js";
|
|
7
|
+
import { Config } from "../config/index.js";
|
|
6
8
|
const client = new EventBridgeClient({});
|
|
7
9
|
export function createEventBuilder(props) {
|
|
8
10
|
return function createEvent(type, properties) {
|
|
@@ -12,27 +14,45 @@ export function createEventBuilder(props) {
|
|
|
12
14
|
: undefined;
|
|
13
15
|
const publish = async (properties, metadata) => {
|
|
14
16
|
console.log("publishing", type, properties);
|
|
15
|
-
await
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
17
|
+
const result = await useLoader("sst.bus.publish", async (input) => {
|
|
18
|
+
const size = 10;
|
|
19
|
+
const promises = [];
|
|
20
|
+
for (let i = 0; i < input.length; i += size) {
|
|
21
|
+
const chunk = input.slice(i, i + size);
|
|
22
|
+
promises.push(client.send(new PutEventsCommand({
|
|
23
|
+
Entries: chunk,
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
const settled = await Promise.allSettled(promises);
|
|
27
|
+
const result = new Array(input.length);
|
|
28
|
+
for (let i = 0; i < result.length; i++) {
|
|
29
|
+
const item = settled[Math.floor(i / 10)];
|
|
30
|
+
if (item.status === "rejected") {
|
|
31
|
+
result[i] = item.reason;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
result[i] = item.value;
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
})({
|
|
38
|
+
// @ts-expect-error
|
|
39
|
+
EventBusName: EventBus[props.bus].eventBusName,
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
Source: Config.APP,
|
|
42
|
+
Detail: JSON.stringify({
|
|
43
|
+
properties: propertiesSchema.parse(properties),
|
|
44
|
+
metadata: (() => {
|
|
45
|
+
if (metadataSchema) {
|
|
46
|
+
return metadataSchema.parse(metadata);
|
|
47
|
+
}
|
|
48
|
+
if (props.metadataFn) {
|
|
49
|
+
return props.metadataFn();
|
|
50
|
+
}
|
|
51
|
+
})(),
|
|
52
|
+
}),
|
|
53
|
+
DetailType: type,
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
36
56
|
};
|
|
37
57
|
return {
|
|
38
58
|
publish: publish,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Context } from "../../context/context.js";
|
|
2
|
+
const LoaderContext = Context.create(() => {
|
|
3
|
+
const loaders = new Map();
|
|
4
|
+
return loaders;
|
|
5
|
+
}, "loader-context");
|
|
6
|
+
export function createLoader(batchFn) {
|
|
7
|
+
let current;
|
|
8
|
+
async function run() {
|
|
9
|
+
const batch = current;
|
|
10
|
+
if (!batch)
|
|
11
|
+
return;
|
|
12
|
+
const result = await batchFn(batch.keys);
|
|
13
|
+
for (let i = 0; i < result.length; i++) {
|
|
14
|
+
batch.promises[i](result[i]);
|
|
15
|
+
}
|
|
16
|
+
current = undefined;
|
|
17
|
+
}
|
|
18
|
+
function getBatch() {
|
|
19
|
+
if (current)
|
|
20
|
+
return current;
|
|
21
|
+
process.nextTick(run);
|
|
22
|
+
current = {
|
|
23
|
+
keys: [],
|
|
24
|
+
promises: [],
|
|
25
|
+
};
|
|
26
|
+
return current;
|
|
27
|
+
}
|
|
28
|
+
return (key) => {
|
|
29
|
+
const batch = getBatch();
|
|
30
|
+
batch.keys.push(key);
|
|
31
|
+
const promise = new Promise((resolve, reject) => {
|
|
32
|
+
batch.promises.push((val) => {
|
|
33
|
+
if (val instanceof Error) {
|
|
34
|
+
reject(val);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
resolve(val);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return promise;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function useLoader(key, batchFn) {
|
|
44
|
+
const loaders = LoaderContext.use();
|
|
45
|
+
if (loaders.has(key)) {
|
|
46
|
+
return loaders.get(key);
|
|
47
|
+
}
|
|
48
|
+
const loader = createLoader(batchFn);
|
|
49
|
+
loaders.set(key, loader);
|
|
50
|
+
return loader;
|
|
51
|
+
}
|
package/package.json
CHANGED
package/project.d.ts
CHANGED
|
@@ -24,12 +24,14 @@ export interface ConfigOptions {
|
|
|
24
24
|
cdk?: {
|
|
25
25
|
toolkitStackName?: string;
|
|
26
26
|
qualifier?: string;
|
|
27
|
+
bootstrapStackVersionSsmParameter?: string;
|
|
27
28
|
fileAssetsBucketName?: string;
|
|
28
29
|
customPermissionsBoundary?: string;
|
|
29
30
|
publicAccessBlockConfiguration?: boolean;
|
|
30
31
|
deployRoleArn?: string;
|
|
31
32
|
fileAssetPublishingRoleArn?: string;
|
|
32
33
|
imageAssetPublishingRoleArn?: string;
|
|
34
|
+
imageAssetsRepositoryName?: string;
|
|
33
35
|
cloudFormationExecutionRole?: string;
|
|
34
36
|
lookupRoleArn?: string;
|
|
35
37
|
pathMetadata?: boolean;
|