sst 2.1.21 → 2.1.22
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/cli/commands/dev.d.ts +8 -0
- package/cli/commands/dev.js +23 -0
- package/node/future/auth/session.js +1 -6
- package/package.json +1 -1
- package/runtime/handlers/node.js +7 -0
- package/sst.mjs +42 -3
- package/support/custom-resources/index.mjs +47 -21
package/cli/commands/dev.d.ts
CHANGED
package/cli/commands/dev.js
CHANGED
|
@@ -29,6 +29,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
29
29
|
const { useRDSWarmer } = await import("./plugins/warmer.js");
|
|
30
30
|
const { useProject } = await import("../../project.js");
|
|
31
31
|
const { useMetadata } = await import("../../stacks/metadata.js");
|
|
32
|
+
const { useIOT } = await import("../../iot.js");
|
|
32
33
|
const { clear } = await import("../terminal.js");
|
|
33
34
|
if (args._[0] === "start") {
|
|
34
35
|
console.log(yellow(`Warning: ${bold(`sst start`)} has been renamed to ${bold(`sst dev`)}`));
|
|
@@ -223,6 +224,27 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
223
224
|
});
|
|
224
225
|
await build();
|
|
225
226
|
});
|
|
227
|
+
const useDisconnector = Context.memo(async () => {
|
|
228
|
+
const bus = useBus();
|
|
229
|
+
const project = useProject();
|
|
230
|
+
const iot = await useIOT();
|
|
231
|
+
bus.subscribe("cli.dev", async (evt) => {
|
|
232
|
+
const topic = `${iot.prefix}/events`;
|
|
233
|
+
iot.publish(topic, "cli.dev", evt.properties);
|
|
234
|
+
});
|
|
235
|
+
bus.publish("cli.dev", {
|
|
236
|
+
stage: project.config.stage,
|
|
237
|
+
app: project.config.name,
|
|
238
|
+
});
|
|
239
|
+
bus.subscribe("cli.dev", async (evt) => {
|
|
240
|
+
if (evt.properties.stage !== project.config.stage)
|
|
241
|
+
return;
|
|
242
|
+
if (evt.properties.app !== project.config.name)
|
|
243
|
+
return;
|
|
244
|
+
Colors.line(Colors.danger(`➜ `), "Another sst dev session has been started up for this stage. Exiting");
|
|
245
|
+
process.exit(0);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
226
248
|
const [appMetadata] = await Promise.all([
|
|
227
249
|
useAppMetadata(),
|
|
228
250
|
useLocalServer({
|
|
@@ -240,6 +262,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
240
262
|
clear();
|
|
241
263
|
await printHeader({ console: true, hint: "ready!" });
|
|
242
264
|
await Promise.all([
|
|
265
|
+
useDisconnector(),
|
|
243
266
|
useRuntimeWorkers(),
|
|
244
267
|
useIOTBridge(),
|
|
245
268
|
useRuntimeServer(),
|
package/package.json
CHANGED
package/runtime/handlers/node.js
CHANGED
|
@@ -156,6 +156,13 @@ export const useNodeHandler = Context.memo(async () => {
|
|
|
156
156
|
.filter((pkg) => !external?.includes(pkg))
|
|
157
157
|
.filter((pkg) => Object.values(result.metafile?.inputs || {}).some(({ imports }) => imports.some(({ path }) => path === pkg))),
|
|
158
158
|
];
|
|
159
|
+
// TODO bubble up the warnings
|
|
160
|
+
const warnings = [];
|
|
161
|
+
Object.entries(result.metafile?.inputs || {}).forEach(([inputPath, { imports }]) => imports
|
|
162
|
+
.filter(({ path }) => path.includes("sst/constructs"))
|
|
163
|
+
.forEach(({ path }) => {
|
|
164
|
+
warnings.push(`You are importing from "${path}" in "${inputPath}". Did you mean to import from "sst/node"?`);
|
|
165
|
+
}));
|
|
159
166
|
async function find(dir, target) {
|
|
160
167
|
if (dir === "/")
|
|
161
168
|
throw new VisibleError("Could not find a package.json file");
|
package/sst.mjs
CHANGED
|
@@ -2603,6 +2603,11 @@ var init_workers = __esm({
|
|
|
2603
2603
|
});
|
|
2604
2604
|
|
|
2605
2605
|
// src/iot.ts
|
|
2606
|
+
var iot_exports = {};
|
|
2607
|
+
__export(iot_exports, {
|
|
2608
|
+
useIOT: () => useIOT,
|
|
2609
|
+
useIOTEndpoint: () => useIOTEndpoint
|
|
2610
|
+
});
|
|
2606
2611
|
import { IoTClient, DescribeEndpointCommand } from "@aws-sdk/client-iot";
|
|
2607
2612
|
import iot from "aws-iot-device-sdk";
|
|
2608
2613
|
function encode(input) {
|
|
@@ -2721,8 +2726,8 @@ var init_iot = __esm({
|
|
|
2721
2726
|
});
|
|
2722
2727
|
|
|
2723
2728
|
// src/runtime/iot.ts
|
|
2724
|
-
var
|
|
2725
|
-
__export(
|
|
2729
|
+
var iot_exports2 = {};
|
|
2730
|
+
__export(iot_exports2, {
|
|
2726
2731
|
useIOTBridge: () => useIOTBridge
|
|
2727
2732
|
});
|
|
2728
2733
|
var useIOTBridge;
|
|
@@ -5027,6 +5032,14 @@ var init_node = __esm({
|
|
|
5027
5032
|
)
|
|
5028
5033
|
)
|
|
5029
5034
|
];
|
|
5035
|
+
const warnings = [];
|
|
5036
|
+
Object.entries(result.metafile?.inputs || {}).forEach(
|
|
5037
|
+
([inputPath, { imports }]) => imports.filter(({ path: path20 }) => path20.includes("sst/constructs")).forEach(({ path: path20 }) => {
|
|
5038
|
+
warnings.push(
|
|
5039
|
+
`You are importing from "${path20}" in "${inputPath}". Did you mean to import from "sst/node"?`
|
|
5040
|
+
);
|
|
5041
|
+
})
|
|
5042
|
+
);
|
|
5030
5043
|
async function find2(dir, target2) {
|
|
5031
5044
|
if (dir === "/")
|
|
5032
5045
|
throw new VisibleError("Could not find a package.json file");
|
|
@@ -6760,7 +6773,7 @@ var dev = (program2) => program2.command(
|
|
|
6760
6773
|
const { mapValues, omitBy: omitBy2, pipe: pipe3 } = await import("remeda");
|
|
6761
6774
|
const path20 = await import("path");
|
|
6762
6775
|
const { useRuntimeWorkers: useRuntimeWorkers2 } = await Promise.resolve().then(() => (init_workers(), workers_exports));
|
|
6763
|
-
const { useIOTBridge: useIOTBridge2 } = await Promise.resolve().then(() => (init_iot2(),
|
|
6776
|
+
const { useIOTBridge: useIOTBridge2 } = await Promise.resolve().then(() => (init_iot2(), iot_exports2));
|
|
6764
6777
|
const { useRuntimeServer: useRuntimeServer2 } = await Promise.resolve().then(() => (init_server2(), server_exports2));
|
|
6765
6778
|
const { useBus: useBus2 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
|
|
6766
6779
|
const { useWatcher: useWatcher2 } = await Promise.resolve().then(() => (init_watcher(), watcher_exports));
|
|
@@ -6782,6 +6795,7 @@ var dev = (program2) => program2.command(
|
|
|
6782
6795
|
const { useRDSWarmer: useRDSWarmer2 } = await Promise.resolve().then(() => (init_warmer(), warmer_exports));
|
|
6783
6796
|
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
6784
6797
|
const { useMetadata: useMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
6798
|
+
const { useIOT: useIOT2 } = await Promise.resolve().then(() => (init_iot(), iot_exports));
|
|
6785
6799
|
const { clear: clear2 } = await Promise.resolve().then(() => (init_terminal(), terminal_exports));
|
|
6786
6800
|
if (args._[0] === "start") {
|
|
6787
6801
|
console.log(
|
|
@@ -7003,6 +7017,30 @@ var dev = (program2) => program2.command(
|
|
|
7003
7017
|
});
|
|
7004
7018
|
await build2();
|
|
7005
7019
|
});
|
|
7020
|
+
const useDisconnector = Context2.memo(async () => {
|
|
7021
|
+
const bus = useBus2();
|
|
7022
|
+
const project = useProject2();
|
|
7023
|
+
const iot2 = await useIOT2();
|
|
7024
|
+
bus.subscribe("cli.dev", async (evt) => {
|
|
7025
|
+
const topic = `${iot2.prefix}/events`;
|
|
7026
|
+
iot2.publish(topic, "cli.dev", evt.properties);
|
|
7027
|
+
});
|
|
7028
|
+
bus.publish("cli.dev", {
|
|
7029
|
+
stage: project.config.stage,
|
|
7030
|
+
app: project.config.name
|
|
7031
|
+
});
|
|
7032
|
+
bus.subscribe("cli.dev", async (evt) => {
|
|
7033
|
+
if (evt.properties.stage !== project.config.stage)
|
|
7034
|
+
return;
|
|
7035
|
+
if (evt.properties.app !== project.config.name)
|
|
7036
|
+
return;
|
|
7037
|
+
Colors2.line(
|
|
7038
|
+
Colors2.danger(`\u279C `),
|
|
7039
|
+
"Another sst dev session has been started up for this stage. Exiting"
|
|
7040
|
+
);
|
|
7041
|
+
process.exit(0);
|
|
7042
|
+
});
|
|
7043
|
+
});
|
|
7006
7044
|
const [appMetadata] = await Promise.all([
|
|
7007
7045
|
useAppMetadata2(),
|
|
7008
7046
|
useLocalServer2({
|
|
@@ -7019,6 +7057,7 @@ var dev = (program2) => program2.command(
|
|
|
7019
7057
|
clear2();
|
|
7020
7058
|
await printHeader2({ console: true, hint: "ready!" });
|
|
7021
7059
|
await Promise.all([
|
|
7060
|
+
useDisconnector(),
|
|
7022
7061
|
useRuntimeWorkers2(),
|
|
7023
7062
|
useIOTBridge2(),
|
|
7024
7063
|
useRuntimeServer2(),
|
|
@@ -30082,7 +30082,7 @@ var require_StandardRetryStrategy = __commonJS({
|
|
|
30082
30082
|
var config_1 = require_config2();
|
|
30083
30083
|
var constants_1 = require_constants3();
|
|
30084
30084
|
var defaultRetryToken_1 = require_defaultRetryToken();
|
|
30085
|
-
var
|
|
30085
|
+
var StandardRetryStrategy2 = class {
|
|
30086
30086
|
constructor(maxAttemptsProvider) {
|
|
30087
30087
|
this.maxAttemptsProvider = maxAttemptsProvider;
|
|
30088
30088
|
this.mode = config_1.RETRY_MODES.STANDARD;
|
|
@@ -30120,8 +30120,8 @@ var require_StandardRetryStrategy = __commonJS({
|
|
|
30120
30120
|
return errorType === "THROTTLING" || errorType === "TRANSIENT";
|
|
30121
30121
|
}
|
|
30122
30122
|
};
|
|
30123
|
-
__name(
|
|
30124
|
-
exports.StandardRetryStrategy =
|
|
30123
|
+
__name(StandardRetryStrategy2, "StandardRetryStrategy");
|
|
30124
|
+
exports.StandardRetryStrategy = StandardRetryStrategy2;
|
|
30125
30125
|
}
|
|
30126
30126
|
});
|
|
30127
30127
|
|
|
@@ -30283,7 +30283,7 @@ var require_StandardRetryStrategy2 = __commonJS({
|
|
|
30283
30283
|
var delayDecider_1 = require_delayDecider();
|
|
30284
30284
|
var retryDecider_1 = require_retryDecider();
|
|
30285
30285
|
var util_1 = require_util();
|
|
30286
|
-
var
|
|
30286
|
+
var StandardRetryStrategy2 = class {
|
|
30287
30287
|
constructor(maxAttemptsProvider, options) {
|
|
30288
30288
|
var _a, _b, _c;
|
|
30289
30289
|
this.maxAttemptsProvider = maxAttemptsProvider;
|
|
@@ -30351,8 +30351,8 @@ var require_StandardRetryStrategy2 = __commonJS({
|
|
|
30351
30351
|
}
|
|
30352
30352
|
}
|
|
30353
30353
|
};
|
|
30354
|
-
__name(
|
|
30355
|
-
exports.StandardRetryStrategy =
|
|
30354
|
+
__name(StandardRetryStrategy2, "StandardRetryStrategy");
|
|
30355
|
+
exports.StandardRetryStrategy = StandardRetryStrategy2;
|
|
30356
30356
|
var getDelayFromRetryAfterHeader = /* @__PURE__ */ __name((response) => {
|
|
30357
30357
|
if (!protocol_http_1.HttpResponse.isInstance(response))
|
|
30358
30358
|
return;
|
|
@@ -103057,7 +103057,7 @@ var require_StandardRetryStrategy3 = __commonJS({
|
|
|
103057
103057
|
var defaultRetryQuota_1 = require_defaultRetryQuota2();
|
|
103058
103058
|
var delayDecider_1 = require_delayDecider2();
|
|
103059
103059
|
var retryDecider_1 = require_retryDecider2();
|
|
103060
|
-
var
|
|
103060
|
+
var StandardRetryStrategy2 = class {
|
|
103061
103061
|
constructor(maxAttemptsProvider, options) {
|
|
103062
103062
|
var _a, _b, _c;
|
|
103063
103063
|
this.maxAttemptsProvider = maxAttemptsProvider;
|
|
@@ -103125,8 +103125,8 @@ var require_StandardRetryStrategy3 = __commonJS({
|
|
|
103125
103125
|
}
|
|
103126
103126
|
}
|
|
103127
103127
|
};
|
|
103128
|
-
__name(
|
|
103129
|
-
exports.StandardRetryStrategy =
|
|
103128
|
+
__name(StandardRetryStrategy2, "StandardRetryStrategy");
|
|
103129
|
+
exports.StandardRetryStrategy = StandardRetryStrategy2;
|
|
103130
103130
|
var getDelayFromRetryAfterHeader = /* @__PURE__ */ __name((response) => {
|
|
103131
103131
|
if (!protocol_http_1.HttpResponse.isInstance(response))
|
|
103132
103132
|
return;
|
|
@@ -164635,7 +164635,22 @@ __name(wait, "wait");
|
|
|
164635
164635
|
// support/custom-resources/apigateway-cloudwatch-role.ts
|
|
164636
164636
|
var import_client_api_gateway = __toESM(require_dist_cjs111(), 1);
|
|
164637
164637
|
var import_client_iam = __toESM(require_dist_cjs112(), 1);
|
|
164638
|
-
var
|
|
164638
|
+
var import_middleware_retry = __toESM(require_dist_cjs17(), 1);
|
|
164639
|
+
var apig = new import_client_api_gateway.APIGatewayClient({
|
|
164640
|
+
logger: console,
|
|
164641
|
+
retryStrategy: new import_middleware_retry.StandardRetryStrategy(async () => 1e4, {
|
|
164642
|
+
retryDecider: (e) => {
|
|
164643
|
+
if (e.name === "TooManyRequestsException" && e.message === "Too Many Requests") {
|
|
164644
|
+
console.log("Retry on error", e.name);
|
|
164645
|
+
return true;
|
|
164646
|
+
}
|
|
164647
|
+
return false;
|
|
164648
|
+
},
|
|
164649
|
+
delayDecider: (_, attempts) => {
|
|
164650
|
+
return Math.min(1.5 ** attempts * 100, 3e3);
|
|
164651
|
+
}
|
|
164652
|
+
})
|
|
164653
|
+
});
|
|
164639
164654
|
var iam = new import_client_iam.IAMClient({ logger: console });
|
|
164640
164655
|
async function ApiGatewayCloudWatchRole(cfnRequest) {
|
|
164641
164656
|
switch (cfnRequest.RequestType) {
|
|
@@ -164702,17 +164717,28 @@ async function createRole(roleName) {
|
|
|
164702
164717
|
__name(createRole, "createRole");
|
|
164703
164718
|
async function attachRoleToApiGateway(roleArn) {
|
|
164704
164719
|
console.log("attachRoleToApiGateway");
|
|
164705
|
-
|
|
164706
|
-
|
|
164707
|
-
|
|
164708
|
-
|
|
164709
|
-
|
|
164710
|
-
|
|
164711
|
-
|
|
164712
|
-
|
|
164713
|
-
|
|
164714
|
-
|
|
164715
|
-
|
|
164720
|
+
try {
|
|
164721
|
+
await apig.send(
|
|
164722
|
+
new import_client_api_gateway.UpdateAccountCommand({
|
|
164723
|
+
patchOperations: [
|
|
164724
|
+
{
|
|
164725
|
+
op: "replace",
|
|
164726
|
+
path: "/cloudwatchRoleArn",
|
|
164727
|
+
value: roleArn
|
|
164728
|
+
}
|
|
164729
|
+
]
|
|
164730
|
+
})
|
|
164731
|
+
);
|
|
164732
|
+
} catch (e) {
|
|
164733
|
+
console.log(e);
|
|
164734
|
+
if (e.name === "BadRequestException" && e.message === "The role ARN does not have required permissions configured. Please grant trust permission for API Gateway and add the required role policy.") {
|
|
164735
|
+
console.log("Retry after 1 second");
|
|
164736
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
164737
|
+
await attachRoleToApiGateway(roleArn);
|
|
164738
|
+
return;
|
|
164739
|
+
}
|
|
164740
|
+
throw e;
|
|
164741
|
+
}
|
|
164716
164742
|
}
|
|
164717
164743
|
__name(attachRoleToApiGateway, "attachRoleToApiGateway");
|
|
164718
164744
|
|