@awsless/awsless 0.0.368 → 0.0.370
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/dist/bin.js +681 -648
- package/dist/client.d.ts +4 -1
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/package.json +12 -12
package/dist/bin.js
CHANGED
|
@@ -8816,545 +8816,277 @@ var loadStackConfigs = async (options) => {
|
|
|
8816
8816
|
return stacks;
|
|
8817
8817
|
};
|
|
8818
8818
|
|
|
8819
|
-
// src/
|
|
8820
|
-
import {
|
|
8821
|
-
|
|
8822
|
-
const data = {
|
|
8823
|
-
App: app.name,
|
|
8824
|
-
Region: app.region,
|
|
8825
|
-
Profile: app.profile
|
|
8826
|
-
};
|
|
8827
|
-
if (opt.stage) {
|
|
8828
|
-
data.Stage = color.warning(opt.stage);
|
|
8829
|
-
}
|
|
8830
|
-
note(wrap(list(data)), "App Config");
|
|
8831
|
-
};
|
|
8832
|
-
|
|
8833
|
-
// src/cli/ui/error/error.ts
|
|
8834
|
-
import { AppError as AppError2, StackError as StackError3 } from "@awsless/formation";
|
|
8835
|
-
import { log as log6 } from "@clack/prompts";
|
|
8819
|
+
// src/feature/auth/index.ts
|
|
8820
|
+
import { aws as aws3, Node as Node2 } from "@awsless/formation";
|
|
8821
|
+
import { constantCase as constantCase2 } from "change-case";
|
|
8836
8822
|
|
|
8837
|
-
// src/
|
|
8838
|
-
|
|
8839
|
-
import { log as log3 } from "@clack/prompts";
|
|
8823
|
+
// src/feature.ts
|
|
8824
|
+
var defineFeature = (feature) => feature;
|
|
8840
8825
|
|
|
8841
|
-
// src/
|
|
8842
|
-
import {
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
const value = ` ${capitalCase2(operation)} `;
|
|
8847
|
-
switch (operation) {
|
|
8848
|
-
case "create":
|
|
8849
|
-
return color.success.bold.inverse(value);
|
|
8850
|
-
case "update":
|
|
8851
|
-
return color.warning.bold.inverse(value);
|
|
8852
|
-
case "delete":
|
|
8853
|
-
return color.error.bold.inverse(value);
|
|
8854
|
-
case "heal":
|
|
8855
|
-
return color.warning.bold.inverse(value);
|
|
8856
|
-
case "get":
|
|
8857
|
-
return color.info.bold.inverse(value);
|
|
8826
|
+
// src/type-gen/file.ts
|
|
8827
|
+
import { camelCase } from "change-case";
|
|
8828
|
+
var TypeFile = class {
|
|
8829
|
+
constructor(module) {
|
|
8830
|
+
this.module = module;
|
|
8858
8831
|
}
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
)
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8832
|
+
codes = /* @__PURE__ */ new Set();
|
|
8833
|
+
interfaces = /* @__PURE__ */ new Map();
|
|
8834
|
+
imports = /* @__PURE__ */ new Map();
|
|
8835
|
+
addImport(varName, path) {
|
|
8836
|
+
this.imports.set(varName, path);
|
|
8837
|
+
return this;
|
|
8838
|
+
}
|
|
8839
|
+
addCode(code) {
|
|
8840
|
+
this.codes.add(code);
|
|
8841
|
+
return this;
|
|
8842
|
+
}
|
|
8843
|
+
addInterface(name, type) {
|
|
8844
|
+
const value = type.toString();
|
|
8845
|
+
if (value) {
|
|
8846
|
+
this.interfaces.set(name, value);
|
|
8847
|
+
}
|
|
8848
|
+
return this;
|
|
8849
|
+
}
|
|
8850
|
+
toString() {
|
|
8851
|
+
if (this.interfaces.size === 0) {
|
|
8852
|
+
return;
|
|
8853
|
+
}
|
|
8854
|
+
const lines = [];
|
|
8855
|
+
if (this.imports.size > 0) {
|
|
8856
|
+
lines.push(
|
|
8857
|
+
...[
|
|
8858
|
+
"// Imports",
|
|
8859
|
+
...Array.from(this.imports.entries()).map(([varName, path]) => {
|
|
8860
|
+
if (typeof varName === "string") {
|
|
8861
|
+
return `import ${camelCase(varName)} from '${path}'`;
|
|
8862
|
+
}
|
|
8863
|
+
return `import { ${Object.entries(varName).map(([key, alias]) => `${key} as ${camelCase(alias)}`).join(", ")} } from '${path}'`;
|
|
8864
|
+
}),
|
|
8865
|
+
""
|
|
8866
|
+
]
|
|
8881
8867
|
);
|
|
8882
|
-
} else if (issue instanceof Error) {
|
|
8883
|
-
log2.message(wrap(color.error(issue.message), { hard: true }), {
|
|
8884
|
-
symbol: color.error(icon.error)
|
|
8885
|
-
});
|
|
8886
8868
|
}
|
|
8869
|
+
if (this.codes.size > 0) {
|
|
8870
|
+
lines.push(...["// Types", ...Array.from(this.codes).map((v) => v.trim()), ""]);
|
|
8871
|
+
}
|
|
8872
|
+
return [
|
|
8873
|
+
...lines,
|
|
8874
|
+
"// Extend module",
|
|
8875
|
+
`declare module '${this.module}' {`,
|
|
8876
|
+
Array.from(this.interfaces).map(([name, type]) => {
|
|
8877
|
+
return ` interface ${name} ${type}`;
|
|
8878
|
+
}).join("\n\n"),
|
|
8879
|
+
// ...Array.from(this.types.entries()).map(([propName, type]) => { // `\tinterface ${this.interfaceName} {`,
|
|
8880
|
+
// return `\t\t${this.readonly ? 'readonly ' : ''}${propName}: ${type}`
|
|
8881
|
+
// }),
|
|
8882
|
+
// `\t}`,
|
|
8883
|
+
`}`,
|
|
8884
|
+
"",
|
|
8885
|
+
"// Export fix",
|
|
8886
|
+
`export {}`
|
|
8887
|
+
].join("\n");
|
|
8887
8888
|
}
|
|
8888
8889
|
};
|
|
8889
8890
|
|
|
8890
|
-
// src/
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
);
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8891
|
+
// src/type-gen/object.ts
|
|
8892
|
+
import { camelCase as camelCase2, constantCase } from "change-case";
|
|
8893
|
+
var TypeObject = class {
|
|
8894
|
+
constructor(level, readonly = true) {
|
|
8895
|
+
this.level = level;
|
|
8896
|
+
this.readonly = readonly;
|
|
8897
|
+
}
|
|
8898
|
+
types = /* @__PURE__ */ new Map();
|
|
8899
|
+
add(name, type) {
|
|
8900
|
+
const value = type.toString();
|
|
8901
|
+
if (value) {
|
|
8902
|
+
this.types.set(name, value);
|
|
8903
|
+
}
|
|
8904
|
+
return this;
|
|
8905
|
+
}
|
|
8906
|
+
addType(name, type) {
|
|
8907
|
+
return this.add(camelCase2(name), type);
|
|
8908
|
+
}
|
|
8909
|
+
addConst(name, type) {
|
|
8910
|
+
return this.add(constantCase(name), type);
|
|
8911
|
+
}
|
|
8912
|
+
toString() {
|
|
8913
|
+
if (!this.types.size) {
|
|
8914
|
+
return "";
|
|
8905
8915
|
}
|
|
8916
|
+
return [
|
|
8917
|
+
"{",
|
|
8918
|
+
...Array.from(this.types.entries()).map(([propName, type]) => {
|
|
8919
|
+
return [
|
|
8920
|
+
" ".repeat(this.level + 1),
|
|
8921
|
+
this.readonly ? "readonly" : "",
|
|
8922
|
+
" ",
|
|
8923
|
+
propName,
|
|
8924
|
+
": ",
|
|
8925
|
+
type
|
|
8926
|
+
].join("");
|
|
8927
|
+
}),
|
|
8928
|
+
`${" ".repeat(this.level)}}`
|
|
8929
|
+
].join("\n");
|
|
8906
8930
|
}
|
|
8907
8931
|
};
|
|
8908
8932
|
|
|
8909
|
-
// src/
|
|
8910
|
-
import
|
|
8911
|
-
|
|
8933
|
+
// src/util/name.ts
|
|
8934
|
+
import { paramCase as paramCase3 } from "change-case";
|
|
8935
|
+
import { createHmac } from "crypto";
|
|
8936
|
+
var formatGlobalResourceName = (opt) => {
|
|
8912
8937
|
return [
|
|
8913
8938
|
//
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8939
|
+
opt.prefix,
|
|
8940
|
+
opt.appName,
|
|
8941
|
+
opt.resourceType,
|
|
8942
|
+
opt.resourceName,
|
|
8943
|
+
opt.postfix
|
|
8944
|
+
].filter((v) => typeof v === "string").map((v) => paramCase3(v)).join(opt.seperator ?? "--");
|
|
8917
8945
|
};
|
|
8918
|
-
var
|
|
8919
|
-
|
|
8920
|
-
|
|
8946
|
+
var formatLocalResourceName = (opt) => {
|
|
8947
|
+
return [
|
|
8948
|
+
//
|
|
8949
|
+
opt.prefix,
|
|
8950
|
+
opt.appName,
|
|
8951
|
+
opt.stackName,
|
|
8952
|
+
opt.resourceType,
|
|
8953
|
+
opt.resourceName,
|
|
8954
|
+
opt.postfix
|
|
8955
|
+
].filter((v) => typeof v === "string").map((v) => paramCase3(v)).join(opt.seperator ?? "--");
|
|
8956
|
+
};
|
|
8957
|
+
var generateGlobalAppId = (opt) => {
|
|
8958
|
+
return createHmac("sha1", "awsless").update(opt.accountId).update(opt.region).update(opt.appName).digest("hex").substring(0, 8);
|
|
8959
|
+
};
|
|
8960
|
+
|
|
8961
|
+
// src/feature/function/util.ts
|
|
8962
|
+
import { Asset, aws as aws2 } from "@awsless/formation";
|
|
8963
|
+
import deepmerge from "deepmerge";
|
|
8964
|
+
import { dirname as dirname7 } from "path";
|
|
8965
|
+
|
|
8966
|
+
// ../ts-file-cache/dist/index.js
|
|
8967
|
+
import { createHash } from "crypto";
|
|
8968
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
8969
|
+
import { builtinModules } from "node:module";
|
|
8970
|
+
import { relative } from "path";
|
|
8971
|
+
import { parse as parse3 } from "@swc/core";
|
|
8972
|
+
import { dirname as dirname4, resolve } from "path";
|
|
8973
|
+
|
|
8974
|
+
// ../../node_modules/.pnpm/acorn-walk@8.3.2/node_modules/acorn-walk/dist/walk.mjs
|
|
8975
|
+
function simple(node, visitors, baseVisitor, state2, override) {
|
|
8976
|
+
if (!baseVisitor) {
|
|
8977
|
+
baseVisitor = base;
|
|
8921
8978
|
}
|
|
8922
|
-
|
|
8923
|
-
|
|
8979
|
+
(function c(node2, st, override2) {
|
|
8980
|
+
var type = override2 || node2.type;
|
|
8981
|
+
baseVisitor[type](node2, st, c);
|
|
8982
|
+
if (visitors[type]) {
|
|
8983
|
+
visitors[type](node2, st);
|
|
8984
|
+
}
|
|
8985
|
+
})(node, state2, override);
|
|
8986
|
+
}
|
|
8987
|
+
function skipThrough(node, st, c) {
|
|
8988
|
+
c(node, st);
|
|
8989
|
+
}
|
|
8990
|
+
function ignore(_node, _st, _c) {
|
|
8991
|
+
}
|
|
8992
|
+
var base = {};
|
|
8993
|
+
base.Program = base.BlockStatement = base.StaticBlock = function(node, st, c) {
|
|
8994
|
+
for (var i = 0, list4 = node.body; i < list4.length; i += 1) {
|
|
8995
|
+
var stmt = list4[i];
|
|
8996
|
+
c(stmt, st, "Statement");
|
|
8924
8997
|
}
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
case "string":
|
|
8937
|
-
case "number":
|
|
8938
|
-
case "boolean":
|
|
8939
|
-
return JSON.stringify(value);
|
|
8998
|
+
};
|
|
8999
|
+
base.Statement = skipThrough;
|
|
9000
|
+
base.EmptyStatement = ignore;
|
|
9001
|
+
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression = function(node, st, c) {
|
|
9002
|
+
return c(node.expression, st, "Expression");
|
|
9003
|
+
};
|
|
9004
|
+
base.IfStatement = function(node, st, c) {
|
|
9005
|
+
c(node.test, st, "Expression");
|
|
9006
|
+
c(node.consequent, st, "Statement");
|
|
9007
|
+
if (node.alternate) {
|
|
9008
|
+
c(node.alternate, st, "Statement");
|
|
8940
9009
|
}
|
|
8941
|
-
return "";
|
|
8942
9010
|
};
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
message.push(codeLine(key + "[", index));
|
|
8963
|
-
end.unshift(codeLine("]", index));
|
|
8964
|
-
} else if (typeof context === "object") {
|
|
8965
|
-
if (inStack && index === 3) {
|
|
8966
|
-
const name = error.data.stacks[issue.path[1]].name;
|
|
8967
|
-
message.push(codeLine("name: " + color.info(`"${name}"`) + ",", index));
|
|
8968
|
-
}
|
|
8969
|
-
message.push(codeLine(key + "{", index));
|
|
8970
|
-
end.unshift(codeLine("}", index));
|
|
8971
|
-
}
|
|
8972
|
-
} else if (typeof context === "object") {
|
|
8973
|
-
message.push(codeLine("{", index));
|
|
8974
|
-
end.unshift(codeLine("}", index));
|
|
8975
|
-
} else if (typeof context === "string") {
|
|
8976
|
-
message.push(codeLine(color.warning(`"${context}"`), index));
|
|
8977
|
-
const error2 = icon.arrow.top.repeat(context.length + 2);
|
|
8978
|
-
message.push(codeLine(color.error(error2), index));
|
|
8979
|
-
}
|
|
8980
|
-
});
|
|
8981
|
-
p.log.message(
|
|
8982
|
-
wrap([...message, ...end], {
|
|
8983
|
-
trim: false
|
|
8984
|
-
}),
|
|
8985
|
-
{
|
|
8986
|
-
symbol: color.error`×`
|
|
8987
|
-
}
|
|
8988
|
-
);
|
|
9011
|
+
base.LabeledStatement = function(node, st, c) {
|
|
9012
|
+
return c(node.body, st, "Statement");
|
|
9013
|
+
};
|
|
9014
|
+
base.BreakStatement = base.ContinueStatement = ignore;
|
|
9015
|
+
base.WithStatement = function(node, st, c) {
|
|
9016
|
+
c(node.object, st, "Expression");
|
|
9017
|
+
c(node.body, st, "Statement");
|
|
9018
|
+
};
|
|
9019
|
+
base.SwitchStatement = function(node, st, c) {
|
|
9020
|
+
c(node.discriminant, st, "Expression");
|
|
9021
|
+
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
|
9022
|
+
var cs = list$1[i$1];
|
|
9023
|
+
if (cs.test) {
|
|
9024
|
+
c(cs.test, st, "Expression");
|
|
9025
|
+
}
|
|
9026
|
+
for (var i = 0, list4 = cs.consequent; i < list4.length; i += 1) {
|
|
9027
|
+
var cons = list4[i];
|
|
9028
|
+
c(cons, st, "Statement");
|
|
9029
|
+
}
|
|
8989
9030
|
}
|
|
8990
9031
|
};
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
{ symbol: color.error(icon.error) }
|
|
9000
|
-
);
|
|
9032
|
+
base.SwitchCase = function(node, st, c) {
|
|
9033
|
+
if (node.test) {
|
|
9034
|
+
c(node.test, st, "Expression");
|
|
9035
|
+
}
|
|
9036
|
+
for (var i = 0, list4 = node.consequent; i < list4.length; i += 1) {
|
|
9037
|
+
var cons = list4[i];
|
|
9038
|
+
c(cons, st, "Statement");
|
|
9039
|
+
}
|
|
9001
9040
|
};
|
|
9002
|
-
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
if (error instanceof ConfigError) {
|
|
9006
|
-
logConfigError(error);
|
|
9007
|
-
} else if (error instanceof Cancelled) {
|
|
9008
|
-
log6.message(color.error("Cancelled."), {
|
|
9009
|
-
symbol: color.error(icon.error)
|
|
9010
|
-
});
|
|
9011
|
-
} else if (error instanceof ExpectedError) {
|
|
9012
|
-
log6.message(color.error(error.message), {
|
|
9013
|
-
symbol: color.error(icon.error)
|
|
9014
|
-
});
|
|
9015
|
-
} else if (error instanceof AppError2) {
|
|
9016
|
-
logAppError(error);
|
|
9017
|
-
} else if (error instanceof StackError3) {
|
|
9018
|
-
logStackError(error);
|
|
9019
|
-
} else if (error instanceof FileError) {
|
|
9020
|
-
logFileError(error);
|
|
9021
|
-
} else if (error instanceof Error) {
|
|
9022
|
-
const message = `${error.name}: ${error.message}`;
|
|
9023
|
-
const stack = error.stack ? color.dim(error.stack.replace(message, "")) : "";
|
|
9024
|
-
log6.message(
|
|
9025
|
-
wrap([color.error(message), stack], {
|
|
9026
|
-
hard: true
|
|
9027
|
-
}),
|
|
9028
|
-
{ symbol: color.error(icon.error) }
|
|
9029
|
-
);
|
|
9030
|
-
} else if (typeof error === "string") {
|
|
9031
|
-
log6.message(wrap(color.error(error)), {
|
|
9032
|
-
symbol: color.error(icon.error)
|
|
9033
|
-
});
|
|
9034
|
-
} else {
|
|
9035
|
-
log6.message(wrap(color.error("Unknown error!")), {
|
|
9036
|
-
symbol: color.error(icon.error)
|
|
9037
|
-
});
|
|
9041
|
+
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function(node, st, c) {
|
|
9042
|
+
if (node.argument) {
|
|
9043
|
+
c(node.argument, st, "Expression");
|
|
9038
9044
|
}
|
|
9039
9045
|
};
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
var logo = () => {
|
|
9043
|
-
return `${color.primary`AWS`}${color.primary.dim`LESS`}`;
|
|
9046
|
+
base.ThrowStatement = base.SpreadElement = function(node, st, c) {
|
|
9047
|
+
return c(node.argument, st, "Expression");
|
|
9044
9048
|
};
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
const appConfig = await loadAppConfig(options);
|
|
9053
|
-
logApp(appConfig, options);
|
|
9054
|
-
const stackConfigs = await loadStackConfigs(options);
|
|
9055
|
-
const result = await cb({
|
|
9056
|
-
options,
|
|
9057
|
-
appConfig,
|
|
9058
|
-
stackConfigs
|
|
9059
|
-
});
|
|
9060
|
-
outro(result ?? void 0);
|
|
9061
|
-
} catch (error) {
|
|
9062
|
-
logError(error);
|
|
9063
|
-
outro();
|
|
9064
|
-
process.exit(1);
|
|
9049
|
+
base.TryStatement = function(node, st, c) {
|
|
9050
|
+
c(node.block, st, "Statement");
|
|
9051
|
+
if (node.handler) {
|
|
9052
|
+
c(node.handler, st);
|
|
9053
|
+
}
|
|
9054
|
+
if (node.finalizer) {
|
|
9055
|
+
c(node.finalizer, st, "Statement");
|
|
9065
9056
|
}
|
|
9066
9057
|
};
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
const credentials = getCredentials(appConfig.profile);
|
|
9073
|
-
const accountId = await getAccountId(credentials, appConfig.region);
|
|
9074
|
-
await bootstrapAwsless({
|
|
9075
|
-
credentials,
|
|
9076
|
-
region: appConfig.region,
|
|
9077
|
-
accountId
|
|
9078
|
-
});
|
|
9079
|
-
return "Ready to go!";
|
|
9080
|
-
});
|
|
9081
|
-
});
|
|
9058
|
+
base.CatchClause = function(node, st, c) {
|
|
9059
|
+
if (node.param) {
|
|
9060
|
+
c(node.param, st, "Pattern");
|
|
9061
|
+
}
|
|
9062
|
+
c(node.body, st, "Statement");
|
|
9082
9063
|
};
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
// src/feature.ts
|
|
9092
|
-
var defineFeature = (feature) => feature;
|
|
9093
|
-
|
|
9094
|
-
// src/type-gen/file.ts
|
|
9095
|
-
import { camelCase } from "change-case";
|
|
9096
|
-
var TypeFile = class {
|
|
9097
|
-
constructor(module) {
|
|
9098
|
-
this.module = module;
|
|
9064
|
+
base.WhileStatement = base.DoWhileStatement = function(node, st, c) {
|
|
9065
|
+
c(node.test, st, "Expression");
|
|
9066
|
+
c(node.body, st, "Statement");
|
|
9067
|
+
};
|
|
9068
|
+
base.ForStatement = function(node, st, c) {
|
|
9069
|
+
if (node.init) {
|
|
9070
|
+
c(node.init, st, "ForInit");
|
|
9099
9071
|
}
|
|
9100
|
-
|
|
9101
|
-
|
|
9102
|
-
imports = /* @__PURE__ */ new Map();
|
|
9103
|
-
addImport(varName, path) {
|
|
9104
|
-
this.imports.set(varName, path);
|
|
9105
|
-
return this;
|
|
9072
|
+
if (node.test) {
|
|
9073
|
+
c(node.test, st, "Expression");
|
|
9106
9074
|
}
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
return this;
|
|
9075
|
+
if (node.update) {
|
|
9076
|
+
c(node.update, st, "Expression");
|
|
9110
9077
|
}
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
if (this.imports.size > 0) {
|
|
9124
|
-
lines.push(
|
|
9125
|
-
...[
|
|
9126
|
-
"// Imports",
|
|
9127
|
-
...Array.from(this.imports.entries()).map(([varName, path]) => {
|
|
9128
|
-
if (typeof varName === "string") {
|
|
9129
|
-
return `import ${camelCase(varName)} from '${path}'`;
|
|
9130
|
-
}
|
|
9131
|
-
return `import { ${Object.entries(varName).map(([key, alias]) => `${key} as ${camelCase(alias)}`).join(", ")} } from '${path}'`;
|
|
9132
|
-
}),
|
|
9133
|
-
""
|
|
9134
|
-
]
|
|
9135
|
-
);
|
|
9136
|
-
}
|
|
9137
|
-
if (this.codes.size > 0) {
|
|
9138
|
-
lines.push(...["// Types", ...Array.from(this.codes).map((v) => v.trim()), ""]);
|
|
9139
|
-
}
|
|
9140
|
-
return [
|
|
9141
|
-
...lines,
|
|
9142
|
-
"// Extend module",
|
|
9143
|
-
`declare module '${this.module}' {`,
|
|
9144
|
-
Array.from(this.interfaces).map(([name, type]) => {
|
|
9145
|
-
return ` interface ${name} ${type}`;
|
|
9146
|
-
}).join("\n\n"),
|
|
9147
|
-
// ...Array.from(this.types.entries()).map(([propName, type]) => { // `\tinterface ${this.interfaceName} {`,
|
|
9148
|
-
// return `\t\t${this.readonly ? 'readonly ' : ''}${propName}: ${type}`
|
|
9149
|
-
// }),
|
|
9150
|
-
// `\t}`,
|
|
9151
|
-
`}`,
|
|
9152
|
-
"",
|
|
9153
|
-
"// Export fix",
|
|
9154
|
-
`export {}`
|
|
9155
|
-
].join("\n");
|
|
9156
|
-
}
|
|
9157
|
-
};
|
|
9158
|
-
|
|
9159
|
-
// src/type-gen/object.ts
|
|
9160
|
-
import { camelCase as camelCase2, constantCase } from "change-case";
|
|
9161
|
-
var TypeObject = class {
|
|
9162
|
-
constructor(level, readonly = true) {
|
|
9163
|
-
this.level = level;
|
|
9164
|
-
this.readonly = readonly;
|
|
9165
|
-
}
|
|
9166
|
-
types = /* @__PURE__ */ new Map();
|
|
9167
|
-
add(name, type) {
|
|
9168
|
-
const value = type.toString();
|
|
9169
|
-
if (value) {
|
|
9170
|
-
this.types.set(name, value);
|
|
9171
|
-
}
|
|
9172
|
-
return this;
|
|
9173
|
-
}
|
|
9174
|
-
addType(name, type) {
|
|
9175
|
-
return this.add(camelCase2(name), type);
|
|
9176
|
-
}
|
|
9177
|
-
addConst(name, type) {
|
|
9178
|
-
return this.add(constantCase(name), type);
|
|
9179
|
-
}
|
|
9180
|
-
toString() {
|
|
9181
|
-
if (!this.types.size) {
|
|
9182
|
-
return "";
|
|
9183
|
-
}
|
|
9184
|
-
return [
|
|
9185
|
-
"{",
|
|
9186
|
-
...Array.from(this.types.entries()).map(([propName, type]) => {
|
|
9187
|
-
return [
|
|
9188
|
-
" ".repeat(this.level + 1),
|
|
9189
|
-
this.readonly ? "readonly" : "",
|
|
9190
|
-
" ",
|
|
9191
|
-
propName,
|
|
9192
|
-
": ",
|
|
9193
|
-
type
|
|
9194
|
-
].join("");
|
|
9195
|
-
}),
|
|
9196
|
-
`${" ".repeat(this.level)}}`
|
|
9197
|
-
].join("\n");
|
|
9198
|
-
}
|
|
9199
|
-
};
|
|
9200
|
-
|
|
9201
|
-
// src/util/name.ts
|
|
9202
|
-
import { paramCase as paramCase3 } from "change-case";
|
|
9203
|
-
import { createHmac } from "crypto";
|
|
9204
|
-
var formatGlobalResourceName = (opt) => {
|
|
9205
|
-
return [
|
|
9206
|
-
//
|
|
9207
|
-
opt.prefix,
|
|
9208
|
-
opt.appName,
|
|
9209
|
-
opt.resourceType,
|
|
9210
|
-
opt.resourceName,
|
|
9211
|
-
opt.postfix
|
|
9212
|
-
].filter((v) => typeof v === "string").map((v) => paramCase3(v)).join(opt.seperator ?? "--");
|
|
9213
|
-
};
|
|
9214
|
-
var formatLocalResourceName = (opt) => {
|
|
9215
|
-
return [
|
|
9216
|
-
//
|
|
9217
|
-
opt.prefix,
|
|
9218
|
-
opt.appName,
|
|
9219
|
-
opt.stackName,
|
|
9220
|
-
opt.resourceType,
|
|
9221
|
-
opt.resourceName,
|
|
9222
|
-
opt.postfix
|
|
9223
|
-
].filter((v) => typeof v === "string").map((v) => paramCase3(v)).join(opt.seperator ?? "--");
|
|
9224
|
-
};
|
|
9225
|
-
var generateGlobalAppId = (opt) => {
|
|
9226
|
-
return createHmac("sha1", "awsless").update(opt.accountId).update(opt.region).update(opt.appName).digest("hex").substring(0, 8);
|
|
9227
|
-
};
|
|
9228
|
-
|
|
9229
|
-
// src/feature/function/util.ts
|
|
9230
|
-
import { Asset, aws as aws2 } from "@awsless/formation";
|
|
9231
|
-
import deepmerge from "deepmerge";
|
|
9232
|
-
import { dirname as dirname7 } from "path";
|
|
9233
|
-
|
|
9234
|
-
// ../ts-file-cache/dist/index.js
|
|
9235
|
-
import { createHash } from "crypto";
|
|
9236
|
-
import { readFile as readFile3 } from "fs/promises";
|
|
9237
|
-
import { builtinModules } from "node:module";
|
|
9238
|
-
import { relative } from "path";
|
|
9239
|
-
import { parse as parse3 } from "@swc/core";
|
|
9240
|
-
import { dirname as dirname4, resolve } from "path";
|
|
9241
|
-
|
|
9242
|
-
// ../../node_modules/.pnpm/acorn-walk@8.3.2/node_modules/acorn-walk/dist/walk.mjs
|
|
9243
|
-
function simple(node, visitors, baseVisitor, state2, override) {
|
|
9244
|
-
if (!baseVisitor) {
|
|
9245
|
-
baseVisitor = base;
|
|
9246
|
-
}
|
|
9247
|
-
(function c(node2, st, override2) {
|
|
9248
|
-
var type = override2 || node2.type;
|
|
9249
|
-
baseVisitor[type](node2, st, c);
|
|
9250
|
-
if (visitors[type]) {
|
|
9251
|
-
visitors[type](node2, st);
|
|
9252
|
-
}
|
|
9253
|
-
})(node, state2, override);
|
|
9254
|
-
}
|
|
9255
|
-
function skipThrough(node, st, c) {
|
|
9256
|
-
c(node, st);
|
|
9257
|
-
}
|
|
9258
|
-
function ignore(_node, _st, _c) {
|
|
9259
|
-
}
|
|
9260
|
-
var base = {};
|
|
9261
|
-
base.Program = base.BlockStatement = base.StaticBlock = function(node, st, c) {
|
|
9262
|
-
for (var i = 0, list4 = node.body; i < list4.length; i += 1) {
|
|
9263
|
-
var stmt = list4[i];
|
|
9264
|
-
c(stmt, st, "Statement");
|
|
9265
|
-
}
|
|
9266
|
-
};
|
|
9267
|
-
base.Statement = skipThrough;
|
|
9268
|
-
base.EmptyStatement = ignore;
|
|
9269
|
-
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression = function(node, st, c) {
|
|
9270
|
-
return c(node.expression, st, "Expression");
|
|
9271
|
-
};
|
|
9272
|
-
base.IfStatement = function(node, st, c) {
|
|
9273
|
-
c(node.test, st, "Expression");
|
|
9274
|
-
c(node.consequent, st, "Statement");
|
|
9275
|
-
if (node.alternate) {
|
|
9276
|
-
c(node.alternate, st, "Statement");
|
|
9277
|
-
}
|
|
9278
|
-
};
|
|
9279
|
-
base.LabeledStatement = function(node, st, c) {
|
|
9280
|
-
return c(node.body, st, "Statement");
|
|
9281
|
-
};
|
|
9282
|
-
base.BreakStatement = base.ContinueStatement = ignore;
|
|
9283
|
-
base.WithStatement = function(node, st, c) {
|
|
9284
|
-
c(node.object, st, "Expression");
|
|
9285
|
-
c(node.body, st, "Statement");
|
|
9286
|
-
};
|
|
9287
|
-
base.SwitchStatement = function(node, st, c) {
|
|
9288
|
-
c(node.discriminant, st, "Expression");
|
|
9289
|
-
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
|
9290
|
-
var cs = list$1[i$1];
|
|
9291
|
-
if (cs.test) {
|
|
9292
|
-
c(cs.test, st, "Expression");
|
|
9293
|
-
}
|
|
9294
|
-
for (var i = 0, list4 = cs.consequent; i < list4.length; i += 1) {
|
|
9295
|
-
var cons = list4[i];
|
|
9296
|
-
c(cons, st, "Statement");
|
|
9297
|
-
}
|
|
9298
|
-
}
|
|
9299
|
-
};
|
|
9300
|
-
base.SwitchCase = function(node, st, c) {
|
|
9301
|
-
if (node.test) {
|
|
9302
|
-
c(node.test, st, "Expression");
|
|
9303
|
-
}
|
|
9304
|
-
for (var i = 0, list4 = node.consequent; i < list4.length; i += 1) {
|
|
9305
|
-
var cons = list4[i];
|
|
9306
|
-
c(cons, st, "Statement");
|
|
9307
|
-
}
|
|
9308
|
-
};
|
|
9309
|
-
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function(node, st, c) {
|
|
9310
|
-
if (node.argument) {
|
|
9311
|
-
c(node.argument, st, "Expression");
|
|
9312
|
-
}
|
|
9313
|
-
};
|
|
9314
|
-
base.ThrowStatement = base.SpreadElement = function(node, st, c) {
|
|
9315
|
-
return c(node.argument, st, "Expression");
|
|
9316
|
-
};
|
|
9317
|
-
base.TryStatement = function(node, st, c) {
|
|
9318
|
-
c(node.block, st, "Statement");
|
|
9319
|
-
if (node.handler) {
|
|
9320
|
-
c(node.handler, st);
|
|
9321
|
-
}
|
|
9322
|
-
if (node.finalizer) {
|
|
9323
|
-
c(node.finalizer, st, "Statement");
|
|
9324
|
-
}
|
|
9325
|
-
};
|
|
9326
|
-
base.CatchClause = function(node, st, c) {
|
|
9327
|
-
if (node.param) {
|
|
9328
|
-
c(node.param, st, "Pattern");
|
|
9329
|
-
}
|
|
9330
|
-
c(node.body, st, "Statement");
|
|
9331
|
-
};
|
|
9332
|
-
base.WhileStatement = base.DoWhileStatement = function(node, st, c) {
|
|
9333
|
-
c(node.test, st, "Expression");
|
|
9334
|
-
c(node.body, st, "Statement");
|
|
9335
|
-
};
|
|
9336
|
-
base.ForStatement = function(node, st, c) {
|
|
9337
|
-
if (node.init) {
|
|
9338
|
-
c(node.init, st, "ForInit");
|
|
9339
|
-
}
|
|
9340
|
-
if (node.test) {
|
|
9341
|
-
c(node.test, st, "Expression");
|
|
9342
|
-
}
|
|
9343
|
-
if (node.update) {
|
|
9344
|
-
c(node.update, st, "Expression");
|
|
9345
|
-
}
|
|
9346
|
-
c(node.body, st, "Statement");
|
|
9347
|
-
};
|
|
9348
|
-
base.ForInStatement = base.ForOfStatement = function(node, st, c) {
|
|
9349
|
-
c(node.left, st, "ForInit");
|
|
9350
|
-
c(node.right, st, "Expression");
|
|
9351
|
-
c(node.body, st, "Statement");
|
|
9352
|
-
};
|
|
9353
|
-
base.ForInit = function(node, st, c) {
|
|
9354
|
-
if (node.type === "VariableDeclaration") {
|
|
9355
|
-
c(node, st);
|
|
9356
|
-
} else {
|
|
9357
|
-
c(node, st, "Expression");
|
|
9078
|
+
c(node.body, st, "Statement");
|
|
9079
|
+
};
|
|
9080
|
+
base.ForInStatement = base.ForOfStatement = function(node, st, c) {
|
|
9081
|
+
c(node.left, st, "ForInit");
|
|
9082
|
+
c(node.right, st, "Expression");
|
|
9083
|
+
c(node.body, st, "Statement");
|
|
9084
|
+
};
|
|
9085
|
+
base.ForInit = function(node, st, c) {
|
|
9086
|
+
if (node.type === "VariableDeclaration") {
|
|
9087
|
+
c(node, st);
|
|
9088
|
+
} else {
|
|
9089
|
+
c(node, st, "Expression");
|
|
9358
9090
|
}
|
|
9359
9091
|
};
|
|
9360
9092
|
base.DebuggerStatement = ignore;
|
|
@@ -11223,14 +10955,20 @@ var cacheFeature = defineFeature({
|
|
|
11223
10955
|
// src/feature/command/index.ts
|
|
11224
10956
|
var commandFeature = defineFeature({
|
|
11225
10957
|
name: "command",
|
|
11226
|
-
|
|
10958
|
+
onValidate(ctx) {
|
|
11227
10959
|
const names = /* @__PURE__ */ new Set();
|
|
11228
|
-
for (const
|
|
11229
|
-
|
|
11230
|
-
names.
|
|
11231
|
-
|
|
11232
|
-
|
|
10960
|
+
for (const stack of ctx.stackConfigs) {
|
|
10961
|
+
for (const name of Object.keys(stack.commands ?? {})) {
|
|
10962
|
+
if (!names.has(name)) {
|
|
10963
|
+
names.add(name);
|
|
10964
|
+
} else {
|
|
10965
|
+
throw new FileError(stack.file, `Duplicate command names aren't allowed: ${name}`);
|
|
10966
|
+
}
|
|
11233
10967
|
}
|
|
10968
|
+
}
|
|
10969
|
+
},
|
|
10970
|
+
onStack(ctx) {
|
|
10971
|
+
for (const [name, props] of Object.entries(ctx.stackConfig.commands ?? {})) {
|
|
11234
10972
|
ctx.registerCommand({ name, ...props });
|
|
11235
10973
|
}
|
|
11236
10974
|
}
|
|
@@ -12889,6 +12627,24 @@ var rpcFeature = defineFeature({
|
|
|
12889
12627
|
types2.addInterface("RpcSchema", schemas);
|
|
12890
12628
|
await ctx.write("rpc.d.ts", types2, true);
|
|
12891
12629
|
},
|
|
12630
|
+
onValidate(ctx) {
|
|
12631
|
+
const names = {};
|
|
12632
|
+
for (const id of Object.keys(ctx.appConfig.defaults.rpc ?? {})) {
|
|
12633
|
+
names[id] = /* @__PURE__ */ new Set();
|
|
12634
|
+
}
|
|
12635
|
+
for (const stack of ctx.stackConfigs) {
|
|
12636
|
+
for (const [id, queries] of Object.entries(stack.rpc ?? {})) {
|
|
12637
|
+
const list4 = names[id];
|
|
12638
|
+
for (const name of Object.keys(queries ?? {})) {
|
|
12639
|
+
if (list4.has(name)) {
|
|
12640
|
+
throw new FileError(stack.file, `Double RPC API function "${id}.${name}"`);
|
|
12641
|
+
} else {
|
|
12642
|
+
list4.add(name);
|
|
12643
|
+
}
|
|
12644
|
+
}
|
|
12645
|
+
}
|
|
12646
|
+
}
|
|
12647
|
+
},
|
|
12892
12648
|
onApp(ctx) {
|
|
12893
12649
|
for (const [id, props] of Object.entries(ctx.appConfig.defaults.rpc ?? {})) {
|
|
12894
12650
|
const group = new Node16(ctx.base, "rpc", id);
|
|
@@ -13641,146 +13397,425 @@ var topicFeature = defineFeature({
|
|
|
13641
13397
|
});
|
|
13642
13398
|
ctx.shared.set(`topic-${id}-arn`, topic.arn);
|
|
13643
13399
|
}
|
|
13644
|
-
}
|
|
13645
|
-
},
|
|
13646
|
-
onStack(ctx) {
|
|
13647
|
-
for (const id of ctx.stackConfig.topics ?? []) {
|
|
13648
|
-
ctx.onPolicy((policy) => {
|
|
13649
|
-
policy.addStatement({
|
|
13650
|
-
actions: ["sns:Publish"],
|
|
13651
|
-
resources: [ctx.shared.get(`topic-${id}-arn`)]
|
|
13652
|
-
});
|
|
13653
|
-
});
|
|
13654
|
-
}
|
|
13655
|
-
for (const [id, props] of Object.entries(ctx.stackConfig.subscribers ?? {})) {
|
|
13656
|
-
const group = new Node23(ctx.stack, "topic", id);
|
|
13657
|
-
const topicArn = ctx.shared.get(`topic-${id}-arn`);
|
|
13658
|
-
if (typeof props === "string" && isEmail(props)) {
|
|
13659
|
-
new aws23.sns.Subscription(group, id, {
|
|
13660
|
-
topicArn,
|
|
13661
|
-
protocol: "email",
|
|
13662
|
-
endpoint: props
|
|
13663
|
-
});
|
|
13664
|
-
} else if (typeof props === "object") {
|
|
13665
|
-
const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
|
|
13666
|
-
new aws23.sns.Subscription(group, id, {
|
|
13667
|
-
topicArn,
|
|
13668
|
-
protocol: "lambda",
|
|
13669
|
-
endpoint: lambda.arn
|
|
13670
|
-
});
|
|
13671
|
-
new aws23.lambda.Permission(group, id, {
|
|
13672
|
-
action: "lambda:InvokeFunction",
|
|
13673
|
-
principal: "sns.amazonaws.com",
|
|
13674
|
-
functionArn: lambda.arn,
|
|
13675
|
-
sourceArn: topicArn
|
|
13676
|
-
});
|
|
13400
|
+
}
|
|
13401
|
+
},
|
|
13402
|
+
onStack(ctx) {
|
|
13403
|
+
for (const id of ctx.stackConfig.topics ?? []) {
|
|
13404
|
+
ctx.onPolicy((policy) => {
|
|
13405
|
+
policy.addStatement({
|
|
13406
|
+
actions: ["sns:Publish"],
|
|
13407
|
+
resources: [ctx.shared.get(`topic-${id}-arn`)]
|
|
13408
|
+
});
|
|
13409
|
+
});
|
|
13410
|
+
}
|
|
13411
|
+
for (const [id, props] of Object.entries(ctx.stackConfig.subscribers ?? {})) {
|
|
13412
|
+
const group = new Node23(ctx.stack, "topic", id);
|
|
13413
|
+
const topicArn = ctx.shared.get(`topic-${id}-arn`);
|
|
13414
|
+
if (typeof props === "string" && isEmail(props)) {
|
|
13415
|
+
new aws23.sns.Subscription(group, id, {
|
|
13416
|
+
topicArn,
|
|
13417
|
+
protocol: "email",
|
|
13418
|
+
endpoint: props
|
|
13419
|
+
});
|
|
13420
|
+
} else if (typeof props === "object") {
|
|
13421
|
+
const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
|
|
13422
|
+
new aws23.sns.Subscription(group, id, {
|
|
13423
|
+
topicArn,
|
|
13424
|
+
protocol: "lambda",
|
|
13425
|
+
endpoint: lambda.arn
|
|
13426
|
+
});
|
|
13427
|
+
new aws23.lambda.Permission(group, id, {
|
|
13428
|
+
action: "lambda:InvokeFunction",
|
|
13429
|
+
principal: "sns.amazonaws.com",
|
|
13430
|
+
functionArn: lambda.arn,
|
|
13431
|
+
sourceArn: topicArn
|
|
13432
|
+
});
|
|
13433
|
+
}
|
|
13434
|
+
}
|
|
13435
|
+
}
|
|
13436
|
+
});
|
|
13437
|
+
|
|
13438
|
+
// src/feature/vpc/index.ts
|
|
13439
|
+
import { aws as aws24, combine as combine2, Node as Node24 } from "@awsless/formation";
|
|
13440
|
+
var vpcFeature = defineFeature({
|
|
13441
|
+
name: "vpc",
|
|
13442
|
+
onApp(ctx) {
|
|
13443
|
+
const group = new Node24(ctx.base, "vpc", "main");
|
|
13444
|
+
const vpc = new aws24.ec2.Vpc(group, "vpc", {
|
|
13445
|
+
name: ctx.app.name,
|
|
13446
|
+
cidrBlock: aws24.ec2.Peer.ipv4("10.0.0.0/16")
|
|
13447
|
+
// cidrBlock: aws.ec2.Peer.ipv6('fd00:10:20::/48'),
|
|
13448
|
+
// cidrBlock: aws.ec2.Peer.ipv6('2a05:d018:c69:6600::/56'),
|
|
13449
|
+
// enableDnsSupport: true,
|
|
13450
|
+
// enableDnsHostnames: true,
|
|
13451
|
+
});
|
|
13452
|
+
const privateRouteTable = new aws24.ec2.RouteTable(group, "private", {
|
|
13453
|
+
vpcId: vpc.id,
|
|
13454
|
+
name: "private"
|
|
13455
|
+
});
|
|
13456
|
+
const publicRouteTable = new aws24.ec2.RouteTable(group, "public", {
|
|
13457
|
+
vpcId: vpc.id,
|
|
13458
|
+
name: "public"
|
|
13459
|
+
});
|
|
13460
|
+
const gateway = new aws24.ec2.InternetGateway(group, "gateway");
|
|
13461
|
+
const attachment = new aws24.ec2.VPCGatewayAttachment(group, "attachment", {
|
|
13462
|
+
vpcId: vpc.id,
|
|
13463
|
+
internetGatewayId: gateway.id
|
|
13464
|
+
});
|
|
13465
|
+
new aws24.ec2.Route(group, "route", {
|
|
13466
|
+
gatewayId: gateway.id,
|
|
13467
|
+
routeTableId: publicRouteTable.id,
|
|
13468
|
+
destination: aws24.ec2.Peer.anyIpv4()
|
|
13469
|
+
// destination: aws.ec2.Peer.anyIpv6(),
|
|
13470
|
+
});
|
|
13471
|
+
ctx.shared.set(
|
|
13472
|
+
"vpc-id",
|
|
13473
|
+
// Some resources require the internet gateway to be attached.
|
|
13474
|
+
combine2([vpc.id, attachment.internetGatewayId]).apply(([id]) => id)
|
|
13475
|
+
);
|
|
13476
|
+
ctx.shared.set("vpc-security-group-id", vpc.defaultSecurityGroup);
|
|
13477
|
+
const zones = ["a", "b"];
|
|
13478
|
+
const tables = [privateRouteTable, publicRouteTable];
|
|
13479
|
+
let block = 0n;
|
|
13480
|
+
for (const table2 of tables) {
|
|
13481
|
+
for (const i in zones) {
|
|
13482
|
+
const index = Number(i) + 1;
|
|
13483
|
+
const id = `${table2.identifier}-${index}`;
|
|
13484
|
+
const subnet = new aws24.ec2.Subnet(group, id, {
|
|
13485
|
+
name: `${ctx.app.name}--${table2.identifier}-${index}`,
|
|
13486
|
+
vpcId: vpc.id,
|
|
13487
|
+
cidrBlock: aws24.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
|
|
13488
|
+
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
|
|
13489
|
+
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`2a05:d018:c69:660${++block}::/64`),
|
|
13490
|
+
// ipv6CidrBlock: ipv6CidrBlock.ipv6CidrBlock.apply(ip => ),
|
|
13491
|
+
// ipv6CidrBlock: slices.apply(list => aws.ec2.Peer.ipv6(list.get(block++).toString())),
|
|
13492
|
+
// assignIpv6AddressOnCreation: true,
|
|
13493
|
+
// ipv6Native: true,
|
|
13494
|
+
mapPublicIpOnLaunch: table2.identifier === "public",
|
|
13495
|
+
availabilityZone: ctx.appConfig.region + zones[i]
|
|
13496
|
+
});
|
|
13497
|
+
new aws24.ec2.SubnetRouteTableAssociation(group, id, {
|
|
13498
|
+
routeTableId: table2.id,
|
|
13499
|
+
subnetId: subnet.id
|
|
13500
|
+
});
|
|
13501
|
+
ctx.shared.set(`vpc-${table2.identifier}-subnet-id-${index}`, subnet.id);
|
|
13502
|
+
}
|
|
13503
|
+
}
|
|
13504
|
+
}
|
|
13505
|
+
});
|
|
13506
|
+
|
|
13507
|
+
// src/feature/index.ts
|
|
13508
|
+
var features = [
|
|
13509
|
+
// 1
|
|
13510
|
+
vpcFeature,
|
|
13511
|
+
domainFeature,
|
|
13512
|
+
commandFeature,
|
|
13513
|
+
onFailureFeature,
|
|
13514
|
+
// 2
|
|
13515
|
+
authFeature,
|
|
13516
|
+
// 3
|
|
13517
|
+
functionFeature,
|
|
13518
|
+
instanceFeature,
|
|
13519
|
+
graphqlFeature,
|
|
13520
|
+
configFeature,
|
|
13521
|
+
searchFeature,
|
|
13522
|
+
pubsubFeature,
|
|
13523
|
+
streamFeature,
|
|
13524
|
+
tableFeature,
|
|
13525
|
+
topicFeature,
|
|
13526
|
+
queueFeature,
|
|
13527
|
+
storeFeature,
|
|
13528
|
+
cacheFeature,
|
|
13529
|
+
taskFeature,
|
|
13530
|
+
testFeature,
|
|
13531
|
+
cronFeature,
|
|
13532
|
+
httpFeature,
|
|
13533
|
+
restFeature,
|
|
13534
|
+
siteFeature,
|
|
13535
|
+
// 4
|
|
13536
|
+
logSubscriptionFeature,
|
|
13537
|
+
// I think needs to be after s3 feature
|
|
13538
|
+
rpcFeature
|
|
13539
|
+
];
|
|
13540
|
+
|
|
13541
|
+
// src/feature/validate.ts
|
|
13542
|
+
var validateFeatures = (props) => {
|
|
13543
|
+
for (const feature of features) {
|
|
13544
|
+
feature.onValidate?.(props);
|
|
13545
|
+
}
|
|
13546
|
+
};
|
|
13547
|
+
|
|
13548
|
+
// src/cli/ui/app.ts
|
|
13549
|
+
import { note } from "@clack/prompts";
|
|
13550
|
+
var logApp = (app, opt) => {
|
|
13551
|
+
const data = {
|
|
13552
|
+
App: app.name,
|
|
13553
|
+
Region: app.region,
|
|
13554
|
+
Profile: app.profile
|
|
13555
|
+
};
|
|
13556
|
+
if (opt.stage) {
|
|
13557
|
+
data.Stage = color.warning(opt.stage);
|
|
13558
|
+
}
|
|
13559
|
+
note(wrap(list(data)), "App Config");
|
|
13560
|
+
};
|
|
13561
|
+
|
|
13562
|
+
// src/cli/ui/error/error.ts
|
|
13563
|
+
import { AppError as AppError2, StackError as StackError3 } from "@awsless/formation";
|
|
13564
|
+
import { log as log6 } from "@clack/prompts";
|
|
13565
|
+
|
|
13566
|
+
// src/cli/ui/error/app-error.ts
|
|
13567
|
+
import { StackError as StackError2 } from "@awsless/formation";
|
|
13568
|
+
import { log as log3 } from "@clack/prompts";
|
|
13569
|
+
|
|
13570
|
+
// src/cli/ui/error/stack-error.ts
|
|
13571
|
+
import { ResourceError } from "@awsless/formation";
|
|
13572
|
+
import { log as log2 } from "@clack/prompts";
|
|
13573
|
+
import { capitalCase as capitalCase2 } from "change-case";
|
|
13574
|
+
var formatOperation = (operation) => {
|
|
13575
|
+
const value = ` ${capitalCase2(operation)} `;
|
|
13576
|
+
switch (operation) {
|
|
13577
|
+
case "create":
|
|
13578
|
+
return color.success.bold.inverse(value);
|
|
13579
|
+
case "update":
|
|
13580
|
+
return color.warning.bold.inverse(value);
|
|
13581
|
+
case "delete":
|
|
13582
|
+
return color.error.bold.inverse(value);
|
|
13583
|
+
case "heal":
|
|
13584
|
+
return color.warning.bold.inverse(value);
|
|
13585
|
+
case "get":
|
|
13586
|
+
return color.info.bold.inverse(value);
|
|
13587
|
+
}
|
|
13588
|
+
};
|
|
13589
|
+
var logStackError = (error) => {
|
|
13590
|
+
log2.message(
|
|
13591
|
+
wrap([color.error(error.message), `Stack: ${error.stack}`].join("\n"), {
|
|
13592
|
+
hard: true
|
|
13593
|
+
}),
|
|
13594
|
+
{ symbol: color.error(icon.error) }
|
|
13595
|
+
);
|
|
13596
|
+
for (const issue of error.issues) {
|
|
13597
|
+
if (issue instanceof ResourceError) {
|
|
13598
|
+
log2.message(
|
|
13599
|
+
[
|
|
13600
|
+
formatOperation(issue.operation),
|
|
13601
|
+
"\n",
|
|
13602
|
+
wrap("URN: " + issue.urn, { hard: true }),
|
|
13603
|
+
"\n",
|
|
13604
|
+
wrap("ID: " + issue.id, { hard: true }),
|
|
13605
|
+
"\n\n",
|
|
13606
|
+
wrap(color.error(issue.message), { hard: true })
|
|
13607
|
+
// , '\n', color.error(issue.message)
|
|
13608
|
+
].join(""),
|
|
13609
|
+
{ symbol: color.error(icon.error) }
|
|
13610
|
+
);
|
|
13611
|
+
} else if (issue instanceof Error) {
|
|
13612
|
+
log2.message(wrap(color.error(issue.message), { hard: true }), {
|
|
13613
|
+
symbol: color.error(icon.error)
|
|
13614
|
+
});
|
|
13615
|
+
}
|
|
13616
|
+
}
|
|
13617
|
+
};
|
|
13618
|
+
|
|
13619
|
+
// src/cli/ui/error/app-error.ts
|
|
13620
|
+
var logAppError = (error) => {
|
|
13621
|
+
log3.message(
|
|
13622
|
+
wrap([color.error(error.message), `App: ${error.app}`].join("\n"), {
|
|
13623
|
+
hard: true
|
|
13624
|
+
}),
|
|
13625
|
+
{ symbol: color.error(icon.error) }
|
|
13626
|
+
);
|
|
13627
|
+
for (const issue of error.issues) {
|
|
13628
|
+
if (issue instanceof StackError2) {
|
|
13629
|
+
logStackError(issue);
|
|
13630
|
+
} else if (issue instanceof Error) {
|
|
13631
|
+
log3.message(wrap(color.error(issue.message), { hard: true }), {
|
|
13632
|
+
symbol: color.error(icon.error)
|
|
13633
|
+
});
|
|
13634
|
+
}
|
|
13635
|
+
}
|
|
13636
|
+
};
|
|
13637
|
+
|
|
13638
|
+
// src/cli/ui/error/config-error.ts
|
|
13639
|
+
import * as p from "@clack/prompts";
|
|
13640
|
+
var codeLine = (value, level = 0) => {
|
|
13641
|
+
return [
|
|
13642
|
+
//
|
|
13643
|
+
" ".repeat(level),
|
|
13644
|
+
value
|
|
13645
|
+
].join("");
|
|
13646
|
+
};
|
|
13647
|
+
var format = (value) => {
|
|
13648
|
+
if (Array.isArray(value)) {
|
|
13649
|
+
return "[ ... ]";
|
|
13650
|
+
}
|
|
13651
|
+
if (value === null) {
|
|
13652
|
+
return "null";
|
|
13653
|
+
}
|
|
13654
|
+
switch (typeof value) {
|
|
13655
|
+
case "function":
|
|
13656
|
+
return "() => { ... }";
|
|
13657
|
+
case "bigint":
|
|
13658
|
+
return `${value}n`;
|
|
13659
|
+
case "symbol":
|
|
13660
|
+
return "Symbol()";
|
|
13661
|
+
case "object":
|
|
13662
|
+
return "{ ... }";
|
|
13663
|
+
case "undefined":
|
|
13664
|
+
return "undefined";
|
|
13665
|
+
case "string":
|
|
13666
|
+
case "number":
|
|
13667
|
+
case "boolean":
|
|
13668
|
+
return JSON.stringify(value);
|
|
13669
|
+
}
|
|
13670
|
+
return "";
|
|
13671
|
+
};
|
|
13672
|
+
var logConfigError = (error) => {
|
|
13673
|
+
for (const issue of error.error.errors) {
|
|
13674
|
+
const message = [color.error(issue.message), color.dim(error.file), "\n{"];
|
|
13675
|
+
let context = error.data;
|
|
13676
|
+
const inStack = issue.path[0] === "stacks" && typeof issue.path[1] === "number";
|
|
13677
|
+
const length = issue.path.length;
|
|
13678
|
+
const end = ["}"];
|
|
13679
|
+
issue.path.forEach((path, i) => {
|
|
13680
|
+
const index = i + 1;
|
|
13681
|
+
context = context[path];
|
|
13682
|
+
if (typeof path === "string") {
|
|
13683
|
+
const key = path + `: `;
|
|
13684
|
+
if (index === length) {
|
|
13685
|
+
const space = " ".repeat(key.length);
|
|
13686
|
+
const value = format(context);
|
|
13687
|
+
const error2 = icon.arrow.top.repeat(value.length);
|
|
13688
|
+
message.push(codeLine(key + color.warning(value), index));
|
|
13689
|
+
message.push(codeLine(space + color.error(error2), index));
|
|
13690
|
+
} else if (Array.isArray(context)) {
|
|
13691
|
+
message.push(codeLine(key + "[", index));
|
|
13692
|
+
end.unshift(codeLine("]", index));
|
|
13693
|
+
} else if (typeof context === "object") {
|
|
13694
|
+
if (inStack && index === 3) {
|
|
13695
|
+
const name = error.data.stacks[issue.path[1]].name;
|
|
13696
|
+
message.push(codeLine("name: " + color.info(`"${name}"`) + ",", index));
|
|
13697
|
+
}
|
|
13698
|
+
message.push(codeLine(key + "{", index));
|
|
13699
|
+
end.unshift(codeLine("}", index));
|
|
13700
|
+
}
|
|
13701
|
+
} else if (typeof context === "object") {
|
|
13702
|
+
message.push(codeLine("{", index));
|
|
13703
|
+
end.unshift(codeLine("}", index));
|
|
13704
|
+
} else if (typeof context === "string") {
|
|
13705
|
+
message.push(codeLine(color.warning(`"${context}"`), index));
|
|
13706
|
+
const error2 = icon.arrow.top.repeat(context.length + 2);
|
|
13707
|
+
message.push(codeLine(color.error(error2), index));
|
|
13708
|
+
}
|
|
13709
|
+
});
|
|
13710
|
+
p.log.message(
|
|
13711
|
+
wrap([...message, ...end], {
|
|
13712
|
+
trim: false
|
|
13713
|
+
}),
|
|
13714
|
+
{
|
|
13715
|
+
symbol: color.error`×`
|
|
13677
13716
|
}
|
|
13678
|
-
|
|
13717
|
+
);
|
|
13679
13718
|
}
|
|
13680
|
-
}
|
|
13719
|
+
};
|
|
13681
13720
|
|
|
13682
|
-
// src/
|
|
13683
|
-
import {
|
|
13684
|
-
var
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13721
|
+
// src/cli/ui/error/file-error.ts
|
|
13722
|
+
import { log as log5 } from "@clack/prompts";
|
|
13723
|
+
var logFileError = (error) => {
|
|
13724
|
+
log5.message(
|
|
13725
|
+
wrap([color.error(error.message), color.dim(error.file)].join("\n"), {
|
|
13726
|
+
hard: true
|
|
13727
|
+
}),
|
|
13728
|
+
{ symbol: color.error(icon.error) }
|
|
13729
|
+
);
|
|
13730
|
+
};
|
|
13731
|
+
|
|
13732
|
+
// src/cli/ui/error/error.ts
|
|
13733
|
+
var logError = (error) => {
|
|
13734
|
+
if (error instanceof ConfigError) {
|
|
13735
|
+
logConfigError(error);
|
|
13736
|
+
} else if (error instanceof Cancelled) {
|
|
13737
|
+
log6.message(color.error("Cancelled."), {
|
|
13738
|
+
symbol: color.error(icon.error)
|
|
13695
13739
|
});
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13740
|
+
} else if (error instanceof ExpectedError) {
|
|
13741
|
+
log6.message(color.error(error.message), {
|
|
13742
|
+
symbol: color.error(icon.error)
|
|
13699
13743
|
});
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13744
|
+
} else if (error instanceof AppError2) {
|
|
13745
|
+
logAppError(error);
|
|
13746
|
+
} else if (error instanceof StackError3) {
|
|
13747
|
+
logStackError(error);
|
|
13748
|
+
} else if (error instanceof FileError) {
|
|
13749
|
+
logFileError(error);
|
|
13750
|
+
} else if (error instanceof Error) {
|
|
13751
|
+
const message = `${error.name}: ${error.message}`;
|
|
13752
|
+
const stack = error.stack ? color.dim(error.stack.replace(message, "")) : "";
|
|
13753
|
+
log6.message(
|
|
13754
|
+
wrap([color.error(message), stack], {
|
|
13755
|
+
hard: true
|
|
13756
|
+
}),
|
|
13757
|
+
{ symbol: color.error(icon.error) }
|
|
13758
|
+
);
|
|
13759
|
+
} else if (typeof error === "string") {
|
|
13760
|
+
log6.message(wrap(color.error(error)), {
|
|
13761
|
+
symbol: color.error(icon.error)
|
|
13703
13762
|
});
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
internetGatewayId: gateway.id
|
|
13763
|
+
} else {
|
|
13764
|
+
log6.message(wrap(color.error("Unknown error!")), {
|
|
13765
|
+
symbol: color.error(icon.error)
|
|
13708
13766
|
});
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13767
|
+
}
|
|
13768
|
+
};
|
|
13769
|
+
|
|
13770
|
+
// src/cli/ui/logo.ts
|
|
13771
|
+
var logo = () => {
|
|
13772
|
+
return `${color.primary`AWS`}${color.primary.dim`LESS`}`;
|
|
13773
|
+
};
|
|
13774
|
+
|
|
13775
|
+
// src/cli/ui/complex/layout.ts
|
|
13776
|
+
var layout = async (command, cb) => {
|
|
13777
|
+
console.log();
|
|
13778
|
+
intro(`${logo()} ${color.dim(command)}`);
|
|
13779
|
+
try {
|
|
13780
|
+
const options = program.optsWithGlobals();
|
|
13781
|
+
const appConfig = await loadAppConfig(options);
|
|
13782
|
+
logApp(appConfig, options);
|
|
13783
|
+
const stackConfigs = await loadStackConfigs(options);
|
|
13784
|
+
validateFeatures({
|
|
13785
|
+
appConfig,
|
|
13786
|
+
stackConfigs
|
|
13714
13787
|
});
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
);
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
for (const i in zones) {
|
|
13726
|
-
const index = Number(i) + 1;
|
|
13727
|
-
const id = `${table2.identifier}-${index}`;
|
|
13728
|
-
const subnet = new aws24.ec2.Subnet(group, id, {
|
|
13729
|
-
name: `${ctx.app.name}--${table2.identifier}-${index}`,
|
|
13730
|
-
vpcId: vpc.id,
|
|
13731
|
-
cidrBlock: aws24.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
|
|
13732
|
-
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
|
|
13733
|
-
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`2a05:d018:c69:660${++block}::/64`),
|
|
13734
|
-
// ipv6CidrBlock: ipv6CidrBlock.ipv6CidrBlock.apply(ip => ),
|
|
13735
|
-
// ipv6CidrBlock: slices.apply(list => aws.ec2.Peer.ipv6(list.get(block++).toString())),
|
|
13736
|
-
// assignIpv6AddressOnCreation: true,
|
|
13737
|
-
// ipv6Native: true,
|
|
13738
|
-
mapPublicIpOnLaunch: table2.identifier === "public",
|
|
13739
|
-
availabilityZone: ctx.appConfig.region + zones[i]
|
|
13740
|
-
});
|
|
13741
|
-
new aws24.ec2.SubnetRouteTableAssociation(group, id, {
|
|
13742
|
-
routeTableId: table2.id,
|
|
13743
|
-
subnetId: subnet.id
|
|
13744
|
-
});
|
|
13745
|
-
ctx.shared.set(`vpc-${table2.identifier}-subnet-id-${index}`, subnet.id);
|
|
13746
|
-
}
|
|
13747
|
-
}
|
|
13788
|
+
const result = await cb({
|
|
13789
|
+
options,
|
|
13790
|
+
appConfig,
|
|
13791
|
+
stackConfigs
|
|
13792
|
+
});
|
|
13793
|
+
outro(result ?? void 0);
|
|
13794
|
+
} catch (error) {
|
|
13795
|
+
logError(error);
|
|
13796
|
+
outro();
|
|
13797
|
+
process.exit(1);
|
|
13748
13798
|
}
|
|
13749
|
-
}
|
|
13799
|
+
};
|
|
13750
13800
|
|
|
13751
|
-
// src/
|
|
13752
|
-
var
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
topicFeature,
|
|
13770
|
-
queueFeature,
|
|
13771
|
-
storeFeature,
|
|
13772
|
-
cacheFeature,
|
|
13773
|
-
taskFeature,
|
|
13774
|
-
testFeature,
|
|
13775
|
-
cronFeature,
|
|
13776
|
-
httpFeature,
|
|
13777
|
-
restFeature,
|
|
13778
|
-
siteFeature,
|
|
13779
|
-
// 4
|
|
13780
|
-
logSubscriptionFeature,
|
|
13781
|
-
// I think needs to be after s3 feature
|
|
13782
|
-
rpcFeature
|
|
13783
|
-
];
|
|
13801
|
+
// src/cli/command/bootstrap.ts
|
|
13802
|
+
var bootstrap = (program2) => {
|
|
13803
|
+
program2.command("bootstrap").description("Create the awsless bootstrap stack").action(async () => {
|
|
13804
|
+
await layout("bootstrap", async ({ appConfig }) => {
|
|
13805
|
+
const credentials = getCredentials(appConfig.profile);
|
|
13806
|
+
const accountId = await getAccountId(credentials, appConfig.region);
|
|
13807
|
+
await bootstrapAwsless({
|
|
13808
|
+
credentials,
|
|
13809
|
+
region: appConfig.region,
|
|
13810
|
+
accountId
|
|
13811
|
+
});
|
|
13812
|
+
return "Ready to go!";
|
|
13813
|
+
});
|
|
13814
|
+
});
|
|
13815
|
+
};
|
|
13816
|
+
|
|
13817
|
+
// src/app.ts
|
|
13818
|
+
import { App as App2, Stack } from "@awsless/formation";
|
|
13784
13819
|
|
|
13785
13820
|
// src/shared.ts
|
|
13786
13821
|
var SharedData = class {
|
|
@@ -14803,10 +14838,8 @@ var watchConfig = async (options, resolve2, reject) => {
|
|
|
14803
14838
|
try {
|
|
14804
14839
|
const appConfig = await loadAppConfig(options);
|
|
14805
14840
|
const stackConfigs = await loadStackConfigs(options);
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
stackConfigs
|
|
14809
|
-
});
|
|
14841
|
+
validateFeatures({ appConfig, stackConfigs });
|
|
14842
|
+
resolve2({ appConfig, stackConfigs });
|
|
14810
14843
|
} catch (error) {
|
|
14811
14844
|
reject(error);
|
|
14812
14845
|
}
|