@awsless/awsless 0.0.33 → 0.0.35
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.cjs +86 -75
- package/dist/bin.js +73 -62
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -1022,6 +1022,56 @@ var hasOnFailure = (config) => {
|
|
|
1022
1022
|
|
|
1023
1023
|
// src/plugins/function.ts
|
|
1024
1024
|
var import_change_case3 = require("change-case");
|
|
1025
|
+
|
|
1026
|
+
// src/util/path.ts
|
|
1027
|
+
var import_promises2 = require("fs/promises");
|
|
1028
|
+
var import_path2 = require("path");
|
|
1029
|
+
var root = process.cwd();
|
|
1030
|
+
var directories = {
|
|
1031
|
+
root,
|
|
1032
|
+
get output() {
|
|
1033
|
+
return (0, import_path2.join)(this.root, ".awsless");
|
|
1034
|
+
},
|
|
1035
|
+
get cache() {
|
|
1036
|
+
return (0, import_path2.join)(this.output, "cache");
|
|
1037
|
+
},
|
|
1038
|
+
get asset() {
|
|
1039
|
+
return (0, import_path2.join)(this.output, "asset");
|
|
1040
|
+
},
|
|
1041
|
+
get types() {
|
|
1042
|
+
return (0, import_path2.join)(this.output, "types");
|
|
1043
|
+
},
|
|
1044
|
+
get template() {
|
|
1045
|
+
return (0, import_path2.join)(this.output, "template");
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
var setRoot = (path = root) => {
|
|
1049
|
+
directories.root = path;
|
|
1050
|
+
};
|
|
1051
|
+
var findRootDir = async (path, configFile, level = 5) => {
|
|
1052
|
+
if (!level) {
|
|
1053
|
+
throw new TypeError("No awsless project found");
|
|
1054
|
+
}
|
|
1055
|
+
const file = (0, import_path2.join)(path, configFile);
|
|
1056
|
+
const exists = await fileExist(file);
|
|
1057
|
+
if (exists) {
|
|
1058
|
+
return path;
|
|
1059
|
+
}
|
|
1060
|
+
return findRootDir((0, import_path2.normalize)((0, import_path2.join)(path, "..")), configFile, level - 1);
|
|
1061
|
+
};
|
|
1062
|
+
var fileExist = async (file) => {
|
|
1063
|
+
try {
|
|
1064
|
+
const stat = await (0, import_promises2.lstat)(file);
|
|
1065
|
+
if (stat.isFile()) {
|
|
1066
|
+
return true;
|
|
1067
|
+
}
|
|
1068
|
+
} catch (error) {
|
|
1069
|
+
}
|
|
1070
|
+
return false;
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1073
|
+
// src/plugins/function.ts
|
|
1074
|
+
var import_path4 = require("path");
|
|
1025
1075
|
var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum memory size is 10 GB");
|
|
1026
1076
|
var TimeoutSchema = DurationSchema.refine(durationMin(Duration.seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
|
|
1027
1077
|
var EphemeralStorageSizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(512)), "Minimum ephemeral storage size is 512 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
|
|
@@ -1166,9 +1216,11 @@ var functionPlugin = definePlugin({
|
|
|
1166
1216
|
const functions = [];
|
|
1167
1217
|
for (const [name, fileOrProps] of Object.entries(stack.functions || {})) {
|
|
1168
1218
|
const varName = (0, import_change_case3.camelCase)(`${stack.name}-${name}`);
|
|
1219
|
+
const funcName = (0, import_change_case3.paramCase)(`${config.name}-${stack.name}--${name}`);
|
|
1169
1220
|
const file = typeof fileOrProps === "string" ? fileOrProps : fileOrProps.file;
|
|
1170
|
-
|
|
1171
|
-
|
|
1221
|
+
const relFile = (0, import_path4.relative)(directories.types, file);
|
|
1222
|
+
imports.push(`import ${varName} from '${relFile}'`);
|
|
1223
|
+
functions.push(` readonly ${(0, import_change_case3.camelCase)(name)}: Invoke<'${funcName}', typeof ${varName}>`);
|
|
1172
1224
|
}
|
|
1173
1225
|
if (functions.length > 0) {
|
|
1174
1226
|
props.push(` readonly ${(0, import_change_case3.camelCase)(stack.name)}: {
|
|
@@ -1186,14 +1238,15 @@ ${imports.join("\n")}
|
|
|
1186
1238
|
|
|
1187
1239
|
import { InvokeOptions } from '@awsless/lambda'
|
|
1188
1240
|
|
|
1189
|
-
type
|
|
1241
|
+
type Options = Omit<InvokeOptions, 'name' | 'payload'>
|
|
1190
1242
|
|
|
1191
|
-
type Invoke<Func extends (...args: any[]) => any> = {
|
|
1192
|
-
|
|
1243
|
+
type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
|
|
1244
|
+
name: Name
|
|
1245
|
+
invoke: (event: Parameters<Func>[0], options?: Options) => ReturnType<Func>
|
|
1193
1246
|
}
|
|
1194
1247
|
|
|
1195
1248
|
declare module '@awsless/awsless' {
|
|
1196
|
-
interface
|
|
1249
|
+
interface FunctionResources {
|
|
1197
1250
|
${props.join("\n")}
|
|
1198
1251
|
}
|
|
1199
1252
|
}`
|
|
@@ -2297,7 +2350,7 @@ var RecordSet = class extends Resource {
|
|
|
2297
2350
|
|
|
2298
2351
|
// src/formation/resource/appsync/graphql-schema.ts
|
|
2299
2352
|
var import_graphql = require("graphql");
|
|
2300
|
-
var
|
|
2353
|
+
var import_promises3 = require("fs/promises");
|
|
2301
2354
|
var import_merge = require("@graphql-tools/merge");
|
|
2302
2355
|
var GraphQLSchema = class extends Resource {
|
|
2303
2356
|
constructor(logicalId, props) {
|
|
@@ -2322,7 +2375,7 @@ var Definition = class extends Asset {
|
|
|
2322
2375
|
async build({ write }) {
|
|
2323
2376
|
const files = [this.files].flat();
|
|
2324
2377
|
const schemas = await Promise.all(files.map((file) => {
|
|
2325
|
-
return (0,
|
|
2378
|
+
return (0, import_promises3.readFile)(file, "utf8");
|
|
2326
2379
|
}));
|
|
2327
2380
|
const defs = (0, import_merge.mergeTypeDefs)(schemas);
|
|
2328
2381
|
const schema2 = (0, import_graphql.print)(defs);
|
|
@@ -2342,7 +2395,7 @@ var Definition = class extends Asset {
|
|
|
2342
2395
|
};
|
|
2343
2396
|
|
|
2344
2397
|
// src/formation/resource/appsync/code.ts
|
|
2345
|
-
var
|
|
2398
|
+
var import_promises4 = require("fs/promises");
|
|
2346
2399
|
var Code2 = class {
|
|
2347
2400
|
static fromFile(id, file) {
|
|
2348
2401
|
return new FileCode2(id, file);
|
|
@@ -2369,7 +2422,7 @@ var FileCode2 = class extends Asset {
|
|
|
2369
2422
|
}
|
|
2370
2423
|
code;
|
|
2371
2424
|
async build() {
|
|
2372
|
-
const code = await (0,
|
|
2425
|
+
const code = await (0, import_promises4.readFile)(this.file);
|
|
2373
2426
|
this.code = code.toString("utf8");
|
|
2374
2427
|
return {
|
|
2375
2428
|
size: formatByteSize(code.byteLength)
|
|
@@ -4111,7 +4164,7 @@ var toApp = async (config, filters) => {
|
|
|
4111
4164
|
};
|
|
4112
4165
|
|
|
4113
4166
|
// src/config.ts
|
|
4114
|
-
var
|
|
4167
|
+
var import_path7 = require("path");
|
|
4115
4168
|
|
|
4116
4169
|
// src/util/account.ts
|
|
4117
4170
|
var import_client_sts = require("@aws-sdk/client-sts");
|
|
@@ -4198,57 +4251,8 @@ var AppSchema = import_zod23.z.object({
|
|
|
4198
4251
|
var import_rollup3 = require("rollup");
|
|
4199
4252
|
var import_rollup_plugin_swc32 = require("rollup-plugin-swc3");
|
|
4200
4253
|
var import_rollup_plugin_replace = __toESM(require("rollup-plugin-replace"), 1);
|
|
4201
|
-
var
|
|
4254
|
+
var import_path5 = require("path");
|
|
4202
4255
|
var import_promises5 = require("fs/promises");
|
|
4203
|
-
|
|
4204
|
-
// src/util/path.ts
|
|
4205
|
-
var import_promises4 = require("fs/promises");
|
|
4206
|
-
var import_path2 = require("path");
|
|
4207
|
-
var root = process.cwd();
|
|
4208
|
-
var directories = {
|
|
4209
|
-
root,
|
|
4210
|
-
get output() {
|
|
4211
|
-
return (0, import_path2.join)(this.root, ".awsless");
|
|
4212
|
-
},
|
|
4213
|
-
get cache() {
|
|
4214
|
-
return (0, import_path2.join)(this.output, "cache");
|
|
4215
|
-
},
|
|
4216
|
-
get asset() {
|
|
4217
|
-
return (0, import_path2.join)(this.output, "asset");
|
|
4218
|
-
},
|
|
4219
|
-
get types() {
|
|
4220
|
-
return (0, import_path2.join)(this.output, "types");
|
|
4221
|
-
},
|
|
4222
|
-
get template() {
|
|
4223
|
-
return (0, import_path2.join)(this.output, "template");
|
|
4224
|
-
}
|
|
4225
|
-
};
|
|
4226
|
-
var setRoot = (path = root) => {
|
|
4227
|
-
directories.root = path;
|
|
4228
|
-
};
|
|
4229
|
-
var findRootDir = async (path, configFile, level = 5) => {
|
|
4230
|
-
if (!level) {
|
|
4231
|
-
throw new TypeError("No awsless project found");
|
|
4232
|
-
}
|
|
4233
|
-
const file = (0, import_path2.join)(path, configFile);
|
|
4234
|
-
const exists = await fileExist(file);
|
|
4235
|
-
if (exists) {
|
|
4236
|
-
return path;
|
|
4237
|
-
}
|
|
4238
|
-
return findRootDir((0, import_path2.normalize)((0, import_path2.join)(path, "..")), configFile, level - 1);
|
|
4239
|
-
};
|
|
4240
|
-
var fileExist = async (file) => {
|
|
4241
|
-
try {
|
|
4242
|
-
const stat = await (0, import_promises4.lstat)(file);
|
|
4243
|
-
if (stat.isFile()) {
|
|
4244
|
-
return true;
|
|
4245
|
-
}
|
|
4246
|
-
} catch (error) {
|
|
4247
|
-
}
|
|
4248
|
-
return false;
|
|
4249
|
-
};
|
|
4250
|
-
|
|
4251
|
-
// src/util/import.ts
|
|
4252
4256
|
var importFile = async (path) => {
|
|
4253
4257
|
const bundle = await (0, import_rollup3.rollup)({
|
|
4254
4258
|
input: path,
|
|
@@ -4257,17 +4261,17 @@ var importFile = async (path) => {
|
|
|
4257
4261
|
},
|
|
4258
4262
|
plugins: [
|
|
4259
4263
|
(0, import_rollup_plugin_replace.default)({
|
|
4260
|
-
__dirname: (id) => `'${(0,
|
|
4264
|
+
__dirname: (id) => `'${(0, import_path5.dirname)(id)}'`
|
|
4261
4265
|
}),
|
|
4262
4266
|
(0, import_rollup_plugin_swc32.swc)({
|
|
4263
4267
|
minify: false,
|
|
4264
4268
|
jsc: {
|
|
4265
|
-
baseUrl: (0,
|
|
4269
|
+
baseUrl: (0, import_path5.dirname)(path)
|
|
4266
4270
|
}
|
|
4267
4271
|
})
|
|
4268
4272
|
]
|
|
4269
4273
|
});
|
|
4270
|
-
const outputFile = (0,
|
|
4274
|
+
const outputFile = (0, import_path5.join)(directories.cache, "config.js");
|
|
4271
4275
|
const result = await bundle.generate({
|
|
4272
4276
|
format: "esm",
|
|
4273
4277
|
exports: "default"
|
|
@@ -4288,7 +4292,7 @@ var importConfig = async (options) => {
|
|
|
4288
4292
|
setRoot(root2);
|
|
4289
4293
|
debug("CWD:", style.info(root2));
|
|
4290
4294
|
debug("Import config file");
|
|
4291
|
-
const fileName = (0,
|
|
4295
|
+
const fileName = (0, import_path7.join)(root2, configFile);
|
|
4292
4296
|
const module2 = await importFile(fileName);
|
|
4293
4297
|
const appConfig = typeof module2.default === "function" ? await module2.default(options) : module2.default;
|
|
4294
4298
|
debug("Validate config file");
|
|
@@ -4812,7 +4816,7 @@ var flexLine = (term, left, right, reserveSpace = 0) => {
|
|
|
4812
4816
|
};
|
|
4813
4817
|
|
|
4814
4818
|
// src/cli/ui/complex/builder.ts
|
|
4815
|
-
var
|
|
4819
|
+
var import_path10 = require("path");
|
|
4816
4820
|
var assetBuilder = (app) => {
|
|
4817
4821
|
return async (term) => {
|
|
4818
4822
|
const assets = [];
|
|
@@ -4875,8 +4879,8 @@ var assetBuilder = (app) => {
|
|
|
4875
4879
|
try {
|
|
4876
4880
|
const data = await asset.build({
|
|
4877
4881
|
async write(file, data2) {
|
|
4878
|
-
const fullpath = (0,
|
|
4879
|
-
const basepath = (0,
|
|
4882
|
+
const fullpath = (0, import_path10.join)(directories.asset, asset.type, app.name, stack.name, asset.id, file);
|
|
4883
|
+
const basepath = (0, import_path10.dirname)(fullpath);
|
|
4880
4884
|
await (0, import_promises6.mkdir)(basepath, { recursive: true });
|
|
4881
4885
|
await (0, import_promises6.writeFile)(fullpath, data2);
|
|
4882
4886
|
}
|
|
@@ -4923,14 +4927,14 @@ var cleanUp = async () => {
|
|
|
4923
4927
|
|
|
4924
4928
|
// src/cli/ui/complex/template.ts
|
|
4925
4929
|
var import_promises8 = require("fs/promises");
|
|
4926
|
-
var
|
|
4930
|
+
var import_path13 = require("path");
|
|
4927
4931
|
var templateBuilder = (app) => {
|
|
4928
4932
|
return async (term) => {
|
|
4929
4933
|
const done = term.out.write(loadingDialog("Building stack templates..."));
|
|
4930
4934
|
await Promise.all(app.stacks.map(async (stack) => {
|
|
4931
4935
|
const template = stack.toString(true);
|
|
4932
|
-
const path = (0,
|
|
4933
|
-
const file = (0,
|
|
4936
|
+
const path = (0, import_path13.join)(directories.template, app.name);
|
|
4937
|
+
const file = (0, import_path13.join)(path, `${stack.name}.json`);
|
|
4934
4938
|
await (0, import_promises8.mkdir)(path, { recursive: true });
|
|
4935
4939
|
await (0, import_promises8.writeFile)(file, template);
|
|
4936
4940
|
}));
|
|
@@ -4940,19 +4944,26 @@ var templateBuilder = (app) => {
|
|
|
4940
4944
|
|
|
4941
4945
|
// src/util/type-gen.ts
|
|
4942
4946
|
var import_promises9 = require("fs/promises");
|
|
4943
|
-
var
|
|
4947
|
+
var import_path15 = require("path");
|
|
4944
4948
|
var generateResourceTypes = async (config) => {
|
|
4945
4949
|
const plugins = [
|
|
4946
4950
|
...defaultPlugins,
|
|
4947
4951
|
...config.plugins || []
|
|
4948
4952
|
];
|
|
4953
|
+
const files = [];
|
|
4949
4954
|
for (const plugin of plugins) {
|
|
4950
4955
|
const code = plugin.onTypeGen?.({ config });
|
|
4951
4956
|
if (code) {
|
|
4957
|
+
const file = (0, import_path15.join)(directories.types, `${plugin.name}.d.ts`);
|
|
4958
|
+
files.push((0, import_path15.relative)(directories.root, file));
|
|
4952
4959
|
await (0, import_promises9.mkdir)(directories.types, { recursive: true });
|
|
4953
|
-
await (0, import_promises9.writeFile)(
|
|
4960
|
+
await (0, import_promises9.writeFile)(file, code);
|
|
4954
4961
|
}
|
|
4955
4962
|
}
|
|
4963
|
+
if (files.length) {
|
|
4964
|
+
const code = files.map((file) => `import '${file}';`).join("\n");
|
|
4965
|
+
await (0, import_promises9.writeFile)((0, import_path15.join)(directories.root, `awsless.d.ts`), code);
|
|
4966
|
+
}
|
|
4956
4967
|
};
|
|
4957
4968
|
|
|
4958
4969
|
// src/cli/ui/complex/types.ts
|
|
@@ -5468,7 +5479,7 @@ var status = (program2) => {
|
|
|
5468
5479
|
|
|
5469
5480
|
// src/cli/ui/complex/publisher.ts
|
|
5470
5481
|
var import_promises10 = require("fs/promises");
|
|
5471
|
-
var
|
|
5482
|
+
var import_path17 = require("path");
|
|
5472
5483
|
var import_client_s32 = require("@aws-sdk/client-s3");
|
|
5473
5484
|
var assetPublisher = (config, app) => {
|
|
5474
5485
|
const client = new import_client_s32.S3Client({
|
|
@@ -5481,7 +5492,7 @@ var assetPublisher = (config, app) => {
|
|
|
5481
5492
|
await Promise.all([...stack.assets].map(async (asset) => {
|
|
5482
5493
|
await asset.publish?.({
|
|
5483
5494
|
async read(file) {
|
|
5484
|
-
const path = (0,
|
|
5495
|
+
const path = (0, import_path17.join)(directories.asset, asset.type, app.name, stack.name, asset.id, file);
|
|
5485
5496
|
const data = await (0, import_promises10.readFile)(path);
|
|
5486
5497
|
return data;
|
|
5487
5498
|
},
|
package/dist/bin.js
CHANGED
|
@@ -998,7 +998,57 @@ var hasOnFailure = (config) => {
|
|
|
998
998
|
};
|
|
999
999
|
|
|
1000
1000
|
// src/plugins/function.ts
|
|
1001
|
-
import { camelCase } from "change-case";
|
|
1001
|
+
import { camelCase, paramCase as paramCase3 } from "change-case";
|
|
1002
|
+
|
|
1003
|
+
// src/util/path.ts
|
|
1004
|
+
import { lstat } from "fs/promises";
|
|
1005
|
+
import { join, normalize } from "path";
|
|
1006
|
+
var root = process.cwd();
|
|
1007
|
+
var directories = {
|
|
1008
|
+
root,
|
|
1009
|
+
get output() {
|
|
1010
|
+
return join(this.root, ".awsless");
|
|
1011
|
+
},
|
|
1012
|
+
get cache() {
|
|
1013
|
+
return join(this.output, "cache");
|
|
1014
|
+
},
|
|
1015
|
+
get asset() {
|
|
1016
|
+
return join(this.output, "asset");
|
|
1017
|
+
},
|
|
1018
|
+
get types() {
|
|
1019
|
+
return join(this.output, "types");
|
|
1020
|
+
},
|
|
1021
|
+
get template() {
|
|
1022
|
+
return join(this.output, "template");
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
var setRoot = (path = root) => {
|
|
1026
|
+
directories.root = path;
|
|
1027
|
+
};
|
|
1028
|
+
var findRootDir = async (path, configFile, level = 5) => {
|
|
1029
|
+
if (!level) {
|
|
1030
|
+
throw new TypeError("No awsless project found");
|
|
1031
|
+
}
|
|
1032
|
+
const file = join(path, configFile);
|
|
1033
|
+
const exists = await fileExist(file);
|
|
1034
|
+
if (exists) {
|
|
1035
|
+
return path;
|
|
1036
|
+
}
|
|
1037
|
+
return findRootDir(normalize(join(path, "..")), configFile, level - 1);
|
|
1038
|
+
};
|
|
1039
|
+
var fileExist = async (file) => {
|
|
1040
|
+
try {
|
|
1041
|
+
const stat = await lstat(file);
|
|
1042
|
+
if (stat.isFile()) {
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
1045
|
+
} catch (error) {
|
|
1046
|
+
}
|
|
1047
|
+
return false;
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
// src/plugins/function.ts
|
|
1051
|
+
import { relative } from "path";
|
|
1002
1052
|
var MemorySizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(128)), "Minimum memory size is 128 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum memory size is 10 GB");
|
|
1003
1053
|
var TimeoutSchema = DurationSchema.refine(durationMin(Duration.seconds(10)), "Minimum timeout duration is 10 seconds").refine(durationMax(Duration.minutes(15)), "Maximum timeout duration is 15 minutes");
|
|
1004
1054
|
var EphemeralStorageSizeSchema = SizeSchema.refine(sizeMin(Size.megaBytes(512)), "Minimum ephemeral storage size is 512 MB").refine(sizeMax(Size.gigaBytes(10)), "Minimum ephemeral storage size is 10 GB");
|
|
@@ -1143,9 +1193,11 @@ var functionPlugin = definePlugin({
|
|
|
1143
1193
|
const functions = [];
|
|
1144
1194
|
for (const [name, fileOrProps] of Object.entries(stack.functions || {})) {
|
|
1145
1195
|
const varName = camelCase(`${stack.name}-${name}`);
|
|
1196
|
+
const funcName = paramCase3(`${config.name}-${stack.name}--${name}`);
|
|
1146
1197
|
const file = typeof fileOrProps === "string" ? fileOrProps : fileOrProps.file;
|
|
1147
|
-
|
|
1148
|
-
|
|
1198
|
+
const relFile = relative(directories.types, file);
|
|
1199
|
+
imports.push(`import ${varName} from '${relFile}'`);
|
|
1200
|
+
functions.push(` readonly ${camelCase(name)}: Invoke<'${funcName}', typeof ${varName}>`);
|
|
1149
1201
|
}
|
|
1150
1202
|
if (functions.length > 0) {
|
|
1151
1203
|
props.push(` readonly ${camelCase(stack.name)}: {
|
|
@@ -1163,14 +1215,15 @@ ${imports.join("\n")}
|
|
|
1163
1215
|
|
|
1164
1216
|
import { InvokeOptions } from '@awsless/lambda'
|
|
1165
1217
|
|
|
1166
|
-
type
|
|
1218
|
+
type Options = Omit<InvokeOptions, 'name' | 'payload'>
|
|
1167
1219
|
|
|
1168
|
-
type Invoke<Func extends (...args: any[]) => any> = {
|
|
1169
|
-
|
|
1220
|
+
type Invoke<Name extends string, Func extends (...args: any[]) => any> = {
|
|
1221
|
+
name: Name
|
|
1222
|
+
invoke: (event: Parameters<Func>[0], options?: Options) => ReturnType<Func>
|
|
1170
1223
|
}
|
|
1171
1224
|
|
|
1172
1225
|
declare module '@awsless/awsless' {
|
|
1173
|
-
interface
|
|
1226
|
+
interface FunctionResources {
|
|
1174
1227
|
${props.join("\n")}
|
|
1175
1228
|
}
|
|
1176
1229
|
}`
|
|
@@ -2198,7 +2251,7 @@ var toArray = (value) => {
|
|
|
2198
2251
|
};
|
|
2199
2252
|
|
|
2200
2253
|
// src/plugins/graphql.ts
|
|
2201
|
-
import { paramCase as
|
|
2254
|
+
import { paramCase as paramCase4 } from "change-case";
|
|
2202
2255
|
|
|
2203
2256
|
// src/formation/resource/appsync/graphql-api.ts
|
|
2204
2257
|
import { constantCase as constantCase3 } from "change-case";
|
|
@@ -2631,7 +2684,7 @@ var graphqlPlugin = definePlugin({
|
|
|
2631
2684
|
const apiId = bootstrap2.import(`graphql-${id}`);
|
|
2632
2685
|
for (const [typeAndField, functionProps] of Object.entries(props.resolvers || {})) {
|
|
2633
2686
|
const [typeName, fieldName] = typeAndField.split(/[\s]+/g);
|
|
2634
|
-
const entryId =
|
|
2687
|
+
const entryId = paramCase4(`${id}-${typeName}-${fieldName}`);
|
|
2635
2688
|
const lambda = toLambdaFunction(ctx, `graphql-${entryId}`, functionProps);
|
|
2636
2689
|
const source = new AppsyncEventSource(entryId, lambda, {
|
|
2637
2690
|
apiId,
|
|
@@ -4177,55 +4230,6 @@ import { swc as swc2 } from "rollup-plugin-swc3";
|
|
|
4177
4230
|
import replace from "rollup-plugin-replace";
|
|
4178
4231
|
import { dirname as dirname2, join as join2 } from "path";
|
|
4179
4232
|
import { mkdir, writeFile } from "fs/promises";
|
|
4180
|
-
|
|
4181
|
-
// src/util/path.ts
|
|
4182
|
-
import { lstat } from "fs/promises";
|
|
4183
|
-
import { join, normalize } from "path";
|
|
4184
|
-
var root = process.cwd();
|
|
4185
|
-
var directories = {
|
|
4186
|
-
root,
|
|
4187
|
-
get output() {
|
|
4188
|
-
return join(this.root, ".awsless");
|
|
4189
|
-
},
|
|
4190
|
-
get cache() {
|
|
4191
|
-
return join(this.output, "cache");
|
|
4192
|
-
},
|
|
4193
|
-
get asset() {
|
|
4194
|
-
return join(this.output, "asset");
|
|
4195
|
-
},
|
|
4196
|
-
get types() {
|
|
4197
|
-
return join(this.output, "types");
|
|
4198
|
-
},
|
|
4199
|
-
get template() {
|
|
4200
|
-
return join(this.output, "template");
|
|
4201
|
-
}
|
|
4202
|
-
};
|
|
4203
|
-
var setRoot = (path = root) => {
|
|
4204
|
-
directories.root = path;
|
|
4205
|
-
};
|
|
4206
|
-
var findRootDir = async (path, configFile, level = 5) => {
|
|
4207
|
-
if (!level) {
|
|
4208
|
-
throw new TypeError("No awsless project found");
|
|
4209
|
-
}
|
|
4210
|
-
const file = join(path, configFile);
|
|
4211
|
-
const exists = await fileExist(file);
|
|
4212
|
-
if (exists) {
|
|
4213
|
-
return path;
|
|
4214
|
-
}
|
|
4215
|
-
return findRootDir(normalize(join(path, "..")), configFile, level - 1);
|
|
4216
|
-
};
|
|
4217
|
-
var fileExist = async (file) => {
|
|
4218
|
-
try {
|
|
4219
|
-
const stat = await lstat(file);
|
|
4220
|
-
if (stat.isFile()) {
|
|
4221
|
-
return true;
|
|
4222
|
-
}
|
|
4223
|
-
} catch (error) {
|
|
4224
|
-
}
|
|
4225
|
-
return false;
|
|
4226
|
-
};
|
|
4227
|
-
|
|
4228
|
-
// src/util/import.ts
|
|
4229
4233
|
var importFile = async (path) => {
|
|
4230
4234
|
const bundle = await rollup2({
|
|
4231
4235
|
input: path,
|
|
@@ -4917,19 +4921,26 @@ var templateBuilder = (app) => {
|
|
|
4917
4921
|
|
|
4918
4922
|
// src/util/type-gen.ts
|
|
4919
4923
|
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
4920
|
-
import { join as join6 } from "path";
|
|
4924
|
+
import { join as join6, relative as relative2 } from "path";
|
|
4921
4925
|
var generateResourceTypes = async (config) => {
|
|
4922
4926
|
const plugins = [
|
|
4923
4927
|
...defaultPlugins,
|
|
4924
4928
|
...config.plugins || []
|
|
4925
4929
|
];
|
|
4930
|
+
const files = [];
|
|
4926
4931
|
for (const plugin of plugins) {
|
|
4927
4932
|
const code = plugin.onTypeGen?.({ config });
|
|
4928
4933
|
if (code) {
|
|
4934
|
+
const file = join6(directories.types, `${plugin.name}.d.ts`);
|
|
4935
|
+
files.push(relative2(directories.root, file));
|
|
4929
4936
|
await mkdir5(directories.types, { recursive: true });
|
|
4930
|
-
await writeFile4(
|
|
4937
|
+
await writeFile4(file, code);
|
|
4931
4938
|
}
|
|
4932
4939
|
}
|
|
4940
|
+
if (files.length) {
|
|
4941
|
+
const code = files.map((file) => `import '${file}';`).join("\n");
|
|
4942
|
+
await writeFile4(join6(directories.root, `awsless.d.ts`), code);
|
|
4943
|
+
}
|
|
4933
4944
|
};
|
|
4934
4945
|
|
|
4935
4946
|
// src/cli/ui/complex/types.ts
|
|
@@ -4984,7 +4995,7 @@ var shouldDeployBootstrap = async (client, stack) => {
|
|
|
4984
4995
|
// src/formation/client.ts
|
|
4985
4996
|
import { CloudFormationClient, CreateStackCommand, DeleteStackCommand, DescribeStackEventsCommand, DescribeStacksCommand, GetTemplateCommand, OnFailure, TemplateStage, UpdateStackCommand, ValidateTemplateCommand, waitUntilStackCreateComplete, waitUntilStackDeleteComplete, waitUntilStackUpdateComplete } from "@aws-sdk/client-cloudformation";
|
|
4986
4997
|
import { S3Client, PutObjectCommand, ObjectCannedACL, StorageClass } from "@aws-sdk/client-s3";
|
|
4987
|
-
import { paramCase as
|
|
4998
|
+
import { paramCase as paramCase5 } from "change-case";
|
|
4988
4999
|
var StackClient = class {
|
|
4989
5000
|
constructor(app, account, region, credentials) {
|
|
4990
5001
|
this.app = app;
|
|
@@ -5017,7 +5028,7 @@ var StackClient = class {
|
|
|
5017
5028
|
};
|
|
5018
5029
|
}
|
|
5019
5030
|
stackName(stackName) {
|
|
5020
|
-
return
|
|
5031
|
+
return paramCase5(`${this.app.name}-${stackName}`);
|
|
5021
5032
|
}
|
|
5022
5033
|
tags(stack) {
|
|
5023
5034
|
const tags = [];
|
package/dist/index.cjs
CHANGED
|
@@ -46,10 +46,10 @@ var import_change_case = require("change-case");
|
|
|
46
46
|
var APP = process.env.APP || "app";
|
|
47
47
|
var STACK = process.env.STACK || "stack";
|
|
48
48
|
var getLocalResourceName = (name, stack = STACK) => {
|
|
49
|
-
return `${APP}
|
|
49
|
+
return `${APP}-${(0, import_change_case.paramCase)(stack)}-${(0, import_change_case.paramCase)(name)}`;
|
|
50
50
|
};
|
|
51
51
|
var getGlobalResourceName = (name) => {
|
|
52
|
-
return `${APP}
|
|
52
|
+
return `${APP}-${(0, import_change_case.paramCase)(name)}`;
|
|
53
53
|
};
|
|
54
54
|
var getSearchName = getLocalResourceName;
|
|
55
55
|
var getStoreName = getLocalResourceName;
|
package/dist/index.d.ts
CHANGED
|
@@ -2470,24 +2470,24 @@ type Plugin<S extends AnyZodObject | undefined = undefined> = {
|
|
|
2470
2470
|
};
|
|
2471
2471
|
declare const definePlugin: <S extends AnyZodObject | undefined = undefined>(plugin: Plugin<S>) => Plugin<S>;
|
|
2472
2472
|
|
|
2473
|
-
declare const getLocalResourceName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app
|
|
2474
|
-
declare const getGlobalResourceName: <N extends string>(name: N) => `app
|
|
2475
|
-
declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app
|
|
2476
|
-
declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app
|
|
2477
|
-
declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app
|
|
2478
|
-
declare const getTopicName: <N extends string>(name: N) => `app
|
|
2473
|
+
declare const getLocalResourceName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
|
|
2474
|
+
declare const getGlobalResourceName: <N extends string>(name: N) => `app-${N}`;
|
|
2475
|
+
declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
|
|
2476
|
+
declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
|
|
2477
|
+
declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
|
|
2478
|
+
declare const getTopicName: <N extends string>(name: N) => `app-${N}`;
|
|
2479
2479
|
declare const getSecretName: (name: string) => string;
|
|
2480
2480
|
declare const getCacheProps: (name: string, stack?: "stack") => {
|
|
2481
2481
|
readonly host: string;
|
|
2482
2482
|
readonly port: number;
|
|
2483
2483
|
};
|
|
2484
2484
|
|
|
2485
|
-
declare const getFunctionName: <S extends string, N extends string>(stack: S, name: N) => `app
|
|
2485
|
+
declare const getFunctionName: <S extends string, N extends string>(stack: S, name: N) => `app-${S}-${N}`;
|
|
2486
2486
|
interface FunctionResources {
|
|
2487
2487
|
}
|
|
2488
2488
|
declare const Function: FunctionResources;
|
|
2489
2489
|
|
|
2490
|
-
declare const getTableName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app
|
|
2490
|
+
declare const getTableName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app-${S}-${N}`;
|
|
2491
2491
|
interface TableResources {
|
|
2492
2492
|
}
|
|
2493
2493
|
declare const Table: TableResources;
|
package/dist/index.js
CHANGED
|
@@ -7,10 +7,10 @@ import { paramCase } from "change-case";
|
|
|
7
7
|
var APP = process.env.APP || "app";
|
|
8
8
|
var STACK = process.env.STACK || "stack";
|
|
9
9
|
var getLocalResourceName = (name, stack = STACK) => {
|
|
10
|
-
return `${APP}
|
|
10
|
+
return `${APP}-${paramCase(stack)}-${paramCase(name)}`;
|
|
11
11
|
};
|
|
12
12
|
var getGlobalResourceName = (name) => {
|
|
13
|
-
return `${APP}
|
|
13
|
+
return `${APP}-${paramCase(name)}`;
|
|
14
14
|
};
|
|
15
15
|
var getSearchName = getLocalResourceName;
|
|
16
16
|
var getStoreName = getLocalResourceName;
|