@awsless/awsless 0.0.247 → 0.0.249
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/auth-b89f6013.d.ts +11 -0
- package/dist/bin.js +299 -174
- package/dist/build-json-schema.js +8 -0
- package/dist/chunk-RRXFYZJQ.js +61 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +5 -0
- package/dist/server.d.ts +2 -12
- package/dist/server.js +22 -62
- package/package.json +10 -9
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const getAuthName: <N extends string>(name: N) => `app--auth--${N}`;
|
|
2
|
+
interface AuthResources {
|
|
3
|
+
}
|
|
4
|
+
declare const Auth: AuthResources;
|
|
5
|
+
declare const getAuthProps: (name: string) => {
|
|
6
|
+
readonly name: `app--auth--${string}`;
|
|
7
|
+
readonly userPoolId: string;
|
|
8
|
+
readonly clientId: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { Auth as A, getAuthProps as a, AuthResources as b, getAuthName as g };
|
package/dist/bin.js
CHANGED
|
@@ -990,6 +990,14 @@ var SitesSchema = z27.record(
|
|
|
990
990
|
z27.object({
|
|
991
991
|
domain: ResourceIdSchema.describe("The domain id to link your site with."),
|
|
992
992
|
subDomain: z27.string().optional(),
|
|
993
|
+
// bind: z
|
|
994
|
+
// .object({
|
|
995
|
+
// auth: z.array(ResourceIdSchema),
|
|
996
|
+
// graphql: z.array(ResourceIdSchema),
|
|
997
|
+
// // http: z.array(ResourceIdSchema),
|
|
998
|
+
// // rest: z.array(ResourceIdSchema),
|
|
999
|
+
// })
|
|
1000
|
+
// .optional(),
|
|
993
1001
|
static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
|
|
994
1002
|
ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
|
|
995
1003
|
// bind: z.object({
|
|
@@ -1793,13 +1801,13 @@ var TypeObject = class {
|
|
|
1793
1801
|
|
|
1794
1802
|
// src/util/name.ts
|
|
1795
1803
|
import { paramCase as paramCase3 } from "change-case";
|
|
1796
|
-
var formatGlobalResourceName = (appName, ns, id) => {
|
|
1804
|
+
var formatGlobalResourceName = (appName, ns, id, seperator = "--") => {
|
|
1797
1805
|
return [
|
|
1798
1806
|
//
|
|
1799
1807
|
appName,
|
|
1800
1808
|
ns,
|
|
1801
1809
|
id
|
|
1802
|
-
].map((v) => paramCase3(v)).join(
|
|
1810
|
+
].map((v) => paramCase3(v)).join(seperator);
|
|
1803
1811
|
};
|
|
1804
1812
|
var formatLocalResourceName = (appName, stackName, ns, id, seperator = "--") => {
|
|
1805
1813
|
return [
|
|
@@ -1882,6 +1890,104 @@ import { Node as Node3, aws as aws3 } from "@awsless/formation";
|
|
|
1882
1890
|
// src/feature/function/util.ts
|
|
1883
1891
|
import { Asset, aws as aws2 } from "@awsless/formation";
|
|
1884
1892
|
import deepmerge from "deepmerge";
|
|
1893
|
+
import { basename as basename4, dirname as dirname6, extname as extname3 } from "path";
|
|
1894
|
+
import { exec } from "promisify-child-process";
|
|
1895
|
+
|
|
1896
|
+
// src/build/index.ts
|
|
1897
|
+
import { mkdir, readFile as readFile2, writeFile } from "fs/promises";
|
|
1898
|
+
import { dirname as dirname3, join as join5 } from "path";
|
|
1899
|
+
|
|
1900
|
+
// old/util/timer.ts
|
|
1901
|
+
import hrtime from "pretty-hrtime";
|
|
1902
|
+
|
|
1903
|
+
// old/cli/style.ts
|
|
1904
|
+
import chalk2 from "chalk";
|
|
1905
|
+
var style = {
|
|
1906
|
+
primary: chalk2.bold.hex("#FF9000"),
|
|
1907
|
+
// title: chalk.white,
|
|
1908
|
+
normal: chalk2.white,
|
|
1909
|
+
label: chalk2.white.bold,
|
|
1910
|
+
placeholder: chalk2.dim,
|
|
1911
|
+
link: chalk2.cyan,
|
|
1912
|
+
info: chalk2.blue,
|
|
1913
|
+
success: chalk2.green,
|
|
1914
|
+
warning: chalk2.yellow,
|
|
1915
|
+
error: chalk2.red,
|
|
1916
|
+
attr: chalk2.yellow,
|
|
1917
|
+
cursor: chalk2.bgWhite.blackBright
|
|
1918
|
+
};
|
|
1919
|
+
|
|
1920
|
+
// old/util/timer.ts
|
|
1921
|
+
var createTimer = () => {
|
|
1922
|
+
const start = process.hrtime();
|
|
1923
|
+
return () => {
|
|
1924
|
+
const end = process.hrtime(start);
|
|
1925
|
+
const [time, unit] = hrtime(end).split(" ");
|
|
1926
|
+
return style.attr(time) + style.attr.dim(unit);
|
|
1927
|
+
};
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
// src/build/index.ts
|
|
1931
|
+
var readCache = async (file) => {
|
|
1932
|
+
try {
|
|
1933
|
+
const value = await readFile2(file, "utf8");
|
|
1934
|
+
return JSON.parse(value);
|
|
1935
|
+
} catch (_) {
|
|
1936
|
+
return void 0;
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
var writeCache = async (file, version, data) => {
|
|
1940
|
+
const cache = JSON.stringify({ version, data });
|
|
1941
|
+
const base = dirname3(file);
|
|
1942
|
+
await mkdir(base, { recursive: true });
|
|
1943
|
+
await writeFile(file, cache, "utf8");
|
|
1944
|
+
};
|
|
1945
|
+
var getBuildPath = (type, name, file) => {
|
|
1946
|
+
return join5(directories.build, type, name, file);
|
|
1947
|
+
};
|
|
1948
|
+
var build = (type, name, builder) => {
|
|
1949
|
+
return builder(async (version, callback) => {
|
|
1950
|
+
const cacheFile = getBuildPath(type, name, "cache.json");
|
|
1951
|
+
const cache = await readCache(cacheFile);
|
|
1952
|
+
if (cache && cache.version === version && !process.env.NO_CACHE) {
|
|
1953
|
+
return {
|
|
1954
|
+
...cache.data,
|
|
1955
|
+
cached: true
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
const time = createTimer();
|
|
1959
|
+
const meta = await callback(async (file, data2) => {
|
|
1960
|
+
const path = getBuildPath(type, name, file);
|
|
1961
|
+
const base = dirname3(path);
|
|
1962
|
+
await mkdir(base, { recursive: true });
|
|
1963
|
+
await writeFile(path, data2);
|
|
1964
|
+
});
|
|
1965
|
+
const data = { ...meta, buildTime: time() };
|
|
1966
|
+
await writeCache(cacheFile, version, data);
|
|
1967
|
+
return {
|
|
1968
|
+
...data,
|
|
1969
|
+
cached: false
|
|
1970
|
+
};
|
|
1971
|
+
});
|
|
1972
|
+
};
|
|
1973
|
+
|
|
1974
|
+
// src/util/byte-size.ts
|
|
1975
|
+
import { filesize } from "filesize";
|
|
1976
|
+
var formatByteSize = (size) => {
|
|
1977
|
+
const [number, unit] = filesize(size).toString().split(" ");
|
|
1978
|
+
return color.attr(number) + color.attr.dim(unit);
|
|
1979
|
+
};
|
|
1980
|
+
|
|
1981
|
+
// src/feature/on-failure/util.ts
|
|
1982
|
+
var getGlobalOnFailure = (ctx) => {
|
|
1983
|
+
return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
|
|
1984
|
+
};
|
|
1985
|
+
var hasOnFailure = (stacks) => {
|
|
1986
|
+
const onFailure = stacks.find((stack) => {
|
|
1987
|
+
return typeof stack.onFailure !== "undefined";
|
|
1988
|
+
});
|
|
1989
|
+
return !!onFailure;
|
|
1990
|
+
};
|
|
1885
1991
|
|
|
1886
1992
|
// src/feature/function/build/typescript/bundle.ts
|
|
1887
1993
|
import { rollup } from "rollup";
|
|
@@ -1890,7 +1996,7 @@ import { swc, minify as swcMinify } from "rollup-plugin-swc3";
|
|
|
1890
1996
|
import json from "@rollup/plugin-json";
|
|
1891
1997
|
import commonjs from "@rollup/plugin-commonjs";
|
|
1892
1998
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
1893
|
-
import { dirname as
|
|
1999
|
+
import { dirname as dirname4 } from "path";
|
|
1894
2000
|
var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file }) => {
|
|
1895
2001
|
const bundle = await rollup({
|
|
1896
2002
|
input: file,
|
|
@@ -1913,7 +2019,7 @@ var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file })
|
|
|
1913
2019
|
// minify,
|
|
1914
2020
|
// module: true,
|
|
1915
2021
|
jsc: {
|
|
1916
|
-
baseUrl:
|
|
2022
|
+
baseUrl: dirname4(file),
|
|
1917
2023
|
minify: { sourceMap: true }
|
|
1918
2024
|
},
|
|
1919
2025
|
sourceMaps: true
|
|
@@ -1957,26 +2063,10 @@ var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file })
|
|
|
1957
2063
|
};
|
|
1958
2064
|
};
|
|
1959
2065
|
|
|
1960
|
-
// src/feature/function/build/zip.ts
|
|
1961
|
-
import JSZip from "jszip";
|
|
1962
|
-
var zipFiles = (files) => {
|
|
1963
|
-
const zip = new JSZip();
|
|
1964
|
-
for (const file of files) {
|
|
1965
|
-
zip.file(file.name, file.code);
|
|
1966
|
-
}
|
|
1967
|
-
return zip.generateAsync({
|
|
1968
|
-
type: "nodebuffer",
|
|
1969
|
-
compression: "DEFLATE",
|
|
1970
|
-
compressionOptions: {
|
|
1971
|
-
level: 9
|
|
1972
|
-
}
|
|
1973
|
-
});
|
|
1974
|
-
};
|
|
1975
|
-
|
|
1976
2066
|
// src/feature/function/build/typescript/fingerprint.ts
|
|
1977
2067
|
import { createHash as createHash2 } from "crypto";
|
|
1978
|
-
import { readFile as
|
|
1979
|
-
import { basename as basename3, dirname as
|
|
2068
|
+
import { readFile as readFile3, readdir, stat as stat3 } from "fs/promises";
|
|
2069
|
+
import { basename as basename3, dirname as dirname5, extname as extname2, join as join6 } from "path";
|
|
1980
2070
|
import parseStaticImports from "parse-static-imports";
|
|
1981
2071
|
var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
|
|
1982
2072
|
var generateFileHashes = async (file, hashes) => {
|
|
@@ -2007,17 +2097,17 @@ var readModuleFile = (file) => {
|
|
|
2007
2097
|
return readFiles([
|
|
2008
2098
|
file,
|
|
2009
2099
|
...extensions.map((exp) => `${file}.${exp}`),
|
|
2010
|
-
...extensions.map((exp) =>
|
|
2100
|
+
...extensions.map((exp) => join6(file, `/index.${exp}`))
|
|
2011
2101
|
]);
|
|
2012
2102
|
}
|
|
2013
|
-
return
|
|
2103
|
+
return readFile3(file, "utf8");
|
|
2014
2104
|
};
|
|
2015
2105
|
var readFiles = async (files) => {
|
|
2016
2106
|
for (const file of files) {
|
|
2017
2107
|
try {
|
|
2018
2108
|
const s = await stat3(file);
|
|
2019
2109
|
if (s.isFile()) {
|
|
2020
|
-
return
|
|
2110
|
+
return readFile3(file, "utf8");
|
|
2021
2111
|
}
|
|
2022
2112
|
} catch (_) {
|
|
2023
2113
|
continue;
|
|
@@ -2027,103 +2117,23 @@ var readFiles = async (files) => {
|
|
|
2027
2117
|
};
|
|
2028
2118
|
var findDependencies = async (file, code) => {
|
|
2029
2119
|
const imports = await parseStaticImports(code);
|
|
2030
|
-
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ?
|
|
2031
|
-
};
|
|
2032
|
-
|
|
2033
|
-
// src/util/byte-size.ts
|
|
2034
|
-
import { filesize } from "filesize";
|
|
2035
|
-
var formatByteSize = (size) => {
|
|
2036
|
-
const [number, unit] = filesize(size).toString().split(" ");
|
|
2037
|
-
return color.attr(number) + color.attr.dim(unit);
|
|
2038
|
-
};
|
|
2039
|
-
|
|
2040
|
-
// src/build/index.ts
|
|
2041
|
-
import { mkdir, readFile as readFile3, writeFile } from "fs/promises";
|
|
2042
|
-
import { dirname as dirname5, join as join6 } from "path";
|
|
2043
|
-
|
|
2044
|
-
// old/util/timer.ts
|
|
2045
|
-
import hrtime from "pretty-hrtime";
|
|
2046
|
-
|
|
2047
|
-
// old/cli/style.ts
|
|
2048
|
-
import chalk2 from "chalk";
|
|
2049
|
-
var style = {
|
|
2050
|
-
primary: chalk2.bold.hex("#FF9000"),
|
|
2051
|
-
// title: chalk.white,
|
|
2052
|
-
normal: chalk2.white,
|
|
2053
|
-
label: chalk2.white.bold,
|
|
2054
|
-
placeholder: chalk2.dim,
|
|
2055
|
-
link: chalk2.cyan,
|
|
2056
|
-
info: chalk2.blue,
|
|
2057
|
-
success: chalk2.green,
|
|
2058
|
-
warning: chalk2.yellow,
|
|
2059
|
-
error: chalk2.red,
|
|
2060
|
-
attr: chalk2.yellow,
|
|
2061
|
-
cursor: chalk2.bgWhite.blackBright
|
|
2062
|
-
};
|
|
2063
|
-
|
|
2064
|
-
// old/util/timer.ts
|
|
2065
|
-
var createTimer = () => {
|
|
2066
|
-
const start = process.hrtime();
|
|
2067
|
-
return () => {
|
|
2068
|
-
const end = process.hrtime(start);
|
|
2069
|
-
const [time, unit] = hrtime(end).split(" ");
|
|
2070
|
-
return style.attr(time) + style.attr.dim(unit);
|
|
2071
|
-
};
|
|
2120
|
+
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join6(dirname5(file), value) : value);
|
|
2072
2121
|
};
|
|
2073
2122
|
|
|
2074
|
-
// src/build/
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
return void 0;
|
|
2123
|
+
// src/feature/function/build/zip.ts
|
|
2124
|
+
import JSZip from "jszip";
|
|
2125
|
+
var zipFiles = (files) => {
|
|
2126
|
+
const zip = new JSZip();
|
|
2127
|
+
for (const file of files) {
|
|
2128
|
+
zip.file(file.name, file.code);
|
|
2081
2129
|
}
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
await writeFile(file, cache, "utf8");
|
|
2088
|
-
};
|
|
2089
|
-
var getBuildPath = (type, name, file) => {
|
|
2090
|
-
return join6(directories.build, type, name, file);
|
|
2091
|
-
};
|
|
2092
|
-
var build = (type, name, builder) => {
|
|
2093
|
-
return builder(async (version, callback) => {
|
|
2094
|
-
const cacheFile = getBuildPath(type, name, "cache.json");
|
|
2095
|
-
const cache = await readCache(cacheFile);
|
|
2096
|
-
if (cache && cache.version === version && !process.env.NO_CACHE) {
|
|
2097
|
-
return {
|
|
2098
|
-
...cache.data,
|
|
2099
|
-
cached: true
|
|
2100
|
-
};
|
|
2130
|
+
return zip.generateAsync({
|
|
2131
|
+
type: "nodebuffer",
|
|
2132
|
+
compression: "DEFLATE",
|
|
2133
|
+
compressionOptions: {
|
|
2134
|
+
level: 9
|
|
2101
2135
|
}
|
|
2102
|
-
const time = createTimer();
|
|
2103
|
-
const meta = await callback(async (file, data2) => {
|
|
2104
|
-
const path = getBuildPath(type, name, file);
|
|
2105
|
-
const base = dirname5(path);
|
|
2106
|
-
await mkdir(base, { recursive: true });
|
|
2107
|
-
await writeFile(path, data2);
|
|
2108
|
-
});
|
|
2109
|
-
const data = { ...meta, buildTime: time() };
|
|
2110
|
-
await writeCache(cacheFile, version, data);
|
|
2111
|
-
return {
|
|
2112
|
-
...data,
|
|
2113
|
-
cached: false
|
|
2114
|
-
};
|
|
2115
|
-
});
|
|
2116
|
-
};
|
|
2117
|
-
|
|
2118
|
-
// src/feature/on-failure/util.ts
|
|
2119
|
-
var getGlobalOnFailure = (ctx) => {
|
|
2120
|
-
return hasOnFailure(ctx.stackConfigs) ? ctx.shared.get("on-failure-queue-arn") : void 0;
|
|
2121
|
-
};
|
|
2122
|
-
var hasOnFailure = (stacks) => {
|
|
2123
|
-
const onFailure = stacks.find((stack) => {
|
|
2124
|
-
return typeof stack.onFailure !== "undefined";
|
|
2125
2136
|
});
|
|
2126
|
-
return !!onFailure;
|
|
2127
2137
|
};
|
|
2128
2138
|
|
|
2129
2139
|
// src/feature/function/util.ts
|
|
@@ -2135,26 +2145,56 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2135
2145
|
name = formatGlobalResourceName(ctx.appConfig.name, ns, id);
|
|
2136
2146
|
}
|
|
2137
2147
|
const props = deepmerge(ctx.appConfig.defaults.function, local2);
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2148
|
+
const ext = extname3(props.file);
|
|
2149
|
+
let code;
|
|
2150
|
+
if ([".ts", ".js", ".tsx", ".sx"].includes(ext)) {
|
|
2151
|
+
ctx.registerBuild("function", name, async (build3) => {
|
|
2152
|
+
const version = await fingerprintFromFile(props.file);
|
|
2153
|
+
return build3(version, async (write) => {
|
|
2154
|
+
const bundle = await bundleTypeScript({ file: props.file });
|
|
2155
|
+
const archive = await zipFiles(bundle.files);
|
|
2156
|
+
await Promise.all([
|
|
2157
|
+
write("bundle.zip", archive),
|
|
2158
|
+
...bundle.files.map((file) => write(`files/${file.name}`, file.code)),
|
|
2159
|
+
...bundle.files.map((file) => file.map && write(`files/${file.name}.map`, file.map))
|
|
2160
|
+
]);
|
|
2161
|
+
return {
|
|
2162
|
+
size: formatByteSize(archive.byteLength)
|
|
2163
|
+
};
|
|
2164
|
+
});
|
|
2151
2165
|
});
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
})
|
|
2166
|
+
code = new aws2.s3.BucketObject(group, "code", {
|
|
2167
|
+
bucket: ctx.shared.get("function-bucket-name"),
|
|
2168
|
+
key: `/lambda/${name}.zip`,
|
|
2169
|
+
body: Asset.fromFile(getBuildPath("function", name, "bundle.zip"))
|
|
2170
|
+
});
|
|
2171
|
+
} else if (basename4(props.file) === "dockerfile") {
|
|
2172
|
+
ctx.registerBuild("function", name, async (build3) => {
|
|
2173
|
+
const version = Math.random().toString();
|
|
2174
|
+
return build3(version, async () => {
|
|
2175
|
+
const repoName = formatGlobalResourceName(ctx.appConfig.name, "function", "repository", "-");
|
|
2176
|
+
await exec(`docker build -t ${name} .`, {
|
|
2177
|
+
cwd: dirname6(props.file)
|
|
2178
|
+
});
|
|
2179
|
+
await exec(
|
|
2180
|
+
`docker tag ${name}:latest ${ctx.accountId}.dkr.ecr.${ctx.appConfig.region}.amazonaws.com/${repoName}:${name}`,
|
|
2181
|
+
{
|
|
2182
|
+
cwd: dirname6(props.file)
|
|
2183
|
+
}
|
|
2184
|
+
);
|
|
2185
|
+
});
|
|
2186
|
+
});
|
|
2187
|
+
const image = new aws2.ecr.Image(group, "image", {
|
|
2188
|
+
repository: ctx.shared.get("function-repository-name"),
|
|
2189
|
+
name,
|
|
2190
|
+
tag: name
|
|
2191
|
+
});
|
|
2192
|
+
code = {
|
|
2193
|
+
imageUri: image.uri
|
|
2194
|
+
};
|
|
2195
|
+
} else {
|
|
2196
|
+
throw new Error("Unknown Lambda Function type.");
|
|
2197
|
+
}
|
|
2158
2198
|
const role = new aws2.iam.Role(group, "role", {
|
|
2159
2199
|
name,
|
|
2160
2200
|
assumedBy: "lambda.amazonaws.com"
|
|
@@ -2175,8 +2215,8 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
2175
2215
|
const lambda = new aws2.lambda.Function(group, `function`, {
|
|
2176
2216
|
...props,
|
|
2177
2217
|
name,
|
|
2178
|
-
code,
|
|
2179
2218
|
role: role.arn,
|
|
2219
|
+
code,
|
|
2180
2220
|
// Remove conflicting props.
|
|
2181
2221
|
vpc: void 0,
|
|
2182
2222
|
log: props.log
|
|
@@ -2562,9 +2602,9 @@ var configFeature = defineFeature({
|
|
|
2562
2602
|
});
|
|
2563
2603
|
|
|
2564
2604
|
// src/feature/function/index.ts
|
|
2605
|
+
import { aws as aws5, Node as Node5 } from "@awsless/formation";
|
|
2565
2606
|
import { camelCase as camelCase3 } from "change-case";
|
|
2566
2607
|
import { relative } from "path";
|
|
2567
|
-
import { Node as Node5, aws as aws5 } from "@awsless/formation";
|
|
2568
2608
|
var typeGenCode2 = `
|
|
2569
2609
|
import { InvokeOptions, InvokeResponse } from '@awsless/lambda'
|
|
2570
2610
|
import type { PartialDeep } from 'type-fest'
|
|
@@ -2622,6 +2662,11 @@ var functionFeature = defineFeature({
|
|
|
2622
2662
|
forceDelete: true
|
|
2623
2663
|
});
|
|
2624
2664
|
ctx.shared.set("function-bucket-name", bucket.name);
|
|
2665
|
+
const repository = new aws5.ecr.Repository(group, "repository", {
|
|
2666
|
+
name: formatGlobalResourceName(ctx.appConfig.name, "function", "repository", "-")
|
|
2667
|
+
});
|
|
2668
|
+
ctx.shared.set("function-repository-name", repository.name);
|
|
2669
|
+
ctx.shared.set("function-repository-uri", repository.uri);
|
|
2625
2670
|
},
|
|
2626
2671
|
onStack(ctx) {
|
|
2627
2672
|
for (const [id, props] of Object.entries(ctx.stackConfig.functions || {})) {
|
|
@@ -2632,7 +2677,7 @@ var functionFeature = defineFeature({
|
|
|
2632
2677
|
});
|
|
2633
2678
|
|
|
2634
2679
|
// src/feature/graphql/index.ts
|
|
2635
|
-
import { paramCase as paramCase5 } from "change-case";
|
|
2680
|
+
import { constantCase as constantCase3, paramCase as paramCase5 } from "change-case";
|
|
2636
2681
|
import { mergeTypeDefs } from "@graphql-tools/merge";
|
|
2637
2682
|
import { generate } from "@awsless/graphql";
|
|
2638
2683
|
import { buildSchema, print } from "graphql";
|
|
@@ -2660,7 +2705,7 @@ var formatFullDomainName = (config2, id, subDomain) => {
|
|
|
2660
2705
|
// src/build/fingerprint.ts
|
|
2661
2706
|
import { createHash as createHash3 } from "crypto";
|
|
2662
2707
|
import { readFile as readFile4, readdir as readdir2, stat as stat4 } from "fs/promises";
|
|
2663
|
-
import { basename as
|
|
2708
|
+
import { basename as basename5, dirname as dirname7, extname as extname4, join as join7 } from "path";
|
|
2664
2709
|
import parseStaticImports2 from "parse-static-imports";
|
|
2665
2710
|
var extensions2 = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
|
|
2666
2711
|
var generateFileHashes2 = async (file, hashes) => {
|
|
@@ -2687,7 +2732,7 @@ var fingerprintFromDirectory = async (dir) => {
|
|
|
2687
2732
|
const hashes = /* @__PURE__ */ new Map();
|
|
2688
2733
|
const files = await readdir2(dir, { recursive: true });
|
|
2689
2734
|
for (const file of files) {
|
|
2690
|
-
if (extensions2.includes(
|
|
2735
|
+
if (extensions2.includes(extname4(file).substring(1)) && file.at(0) !== "_") {
|
|
2691
2736
|
await generateFileHashes2(join7(dir, file), hashes);
|
|
2692
2737
|
}
|
|
2693
2738
|
}
|
|
@@ -2698,7 +2743,7 @@ var readModuleFile2 = (file) => {
|
|
|
2698
2743
|
if (file.endsWith(".js")) {
|
|
2699
2744
|
return readFiles2([file, file.substring(0, file.length - 3) + ".ts"]);
|
|
2700
2745
|
}
|
|
2701
|
-
if (!
|
|
2746
|
+
if (!basename5(file).includes(".")) {
|
|
2702
2747
|
return readFiles2([
|
|
2703
2748
|
file,
|
|
2704
2749
|
...extensions2.map((exp) => `${file}.${exp}`),
|
|
@@ -2722,7 +2767,7 @@ var readFiles2 = async (files) => {
|
|
|
2722
2767
|
};
|
|
2723
2768
|
var findDependencies2 = async (file, code) => {
|
|
2724
2769
|
const imports = await parseStaticImports2(code);
|
|
2725
|
-
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join7(
|
|
2770
|
+
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join7(dirname7(file), value) : value);
|
|
2726
2771
|
};
|
|
2727
2772
|
|
|
2728
2773
|
// src/feature/graphql/build/typescript/resolver.ts
|
|
@@ -2731,7 +2776,7 @@ import { swc as swc2, minify as swcMinify2 } from "rollup-plugin-swc3";
|
|
|
2731
2776
|
import json2 from "@rollup/plugin-json";
|
|
2732
2777
|
import commonjs2 from "@rollup/plugin-commonjs";
|
|
2733
2778
|
import nodeResolve2 from "@rollup/plugin-node-resolve";
|
|
2734
|
-
import { dirname as
|
|
2779
|
+
import { dirname as dirname8 } from "path";
|
|
2735
2780
|
var buildTypeScriptResolver = async (input, { minify = true } = {}) => {
|
|
2736
2781
|
const bundle = await rollup2({
|
|
2737
2782
|
input,
|
|
@@ -2753,7 +2798,7 @@ var buildTypeScriptResolver = async (input, { minify = true } = {}) => {
|
|
|
2753
2798
|
// minify,
|
|
2754
2799
|
// module: true,
|
|
2755
2800
|
jsc: {
|
|
2756
|
-
baseUrl:
|
|
2801
|
+
baseUrl: dirname8(input),
|
|
2757
2802
|
minify: { sourceMap: true }
|
|
2758
2803
|
},
|
|
2759
2804
|
sourceMaps: true
|
|
@@ -2972,6 +3017,7 @@ var graphqlFeature = defineFeature({
|
|
|
2972
3017
|
evaluateTargetHealth: false
|
|
2973
3018
|
}
|
|
2974
3019
|
});
|
|
3020
|
+
ctx.bindEnv(`GRAPHQL_${constantCase3(id)}_ENDPOINT`, domainName);
|
|
2975
3021
|
}
|
|
2976
3022
|
}
|
|
2977
3023
|
},
|
|
@@ -3119,7 +3165,7 @@ var pubsubFeature = defineFeature({
|
|
|
3119
3165
|
});
|
|
3120
3166
|
|
|
3121
3167
|
// src/feature/queue/index.ts
|
|
3122
|
-
import { camelCase as camelCase4, constantCase as
|
|
3168
|
+
import { camelCase as camelCase4, constantCase as constantCase4 } from "change-case";
|
|
3123
3169
|
import { relative as relative2 } from "path";
|
|
3124
3170
|
import deepmerge2 from "deepmerge";
|
|
3125
3171
|
import { Node as Node9, aws as aws9 } from "@awsless/formation";
|
|
@@ -3195,14 +3241,14 @@ var queueFeature = defineFeature({
|
|
|
3195
3241
|
});
|
|
3196
3242
|
ctx.onFunction(({ lambda: lambda2, policy: policy2 }) => {
|
|
3197
3243
|
policy2.addStatement(queue2.permissions);
|
|
3198
|
-
lambda2.addEnvironment(`QUEUE_${
|
|
3244
|
+
lambda2.addEnvironment(`QUEUE_${constantCase4(ctx.stack.name)}_${constantCase4(id)}_URL`, queue2.url);
|
|
3199
3245
|
});
|
|
3200
3246
|
}
|
|
3201
3247
|
}
|
|
3202
3248
|
});
|
|
3203
3249
|
|
|
3204
3250
|
// src/feature/store/index.ts
|
|
3205
|
-
import {
|
|
3251
|
+
import { aws as aws10, Node as Node10 } from "@awsless/formation";
|
|
3206
3252
|
var typeGenCode4 = `
|
|
3207
3253
|
import { Body, PutObjectProps, BodyStream, createPresignedPost } from '@awsless/s3'
|
|
3208
3254
|
import { Size } from '@awsless/size'
|
|
@@ -3237,6 +3283,7 @@ var storeFeature = defineFeature({
|
|
|
3237
3283
|
onStack(ctx) {
|
|
3238
3284
|
for (const [id, props] of Object.entries(ctx.stackConfig.stores ?? {})) {
|
|
3239
3285
|
const group = new Node10(ctx.stack, "store", id);
|
|
3286
|
+
const bucketName = formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, "store", id);
|
|
3240
3287
|
const lambdaConfigs = [];
|
|
3241
3288
|
const eventMap = {
|
|
3242
3289
|
"created:*": "s3:ObjectCreated:*",
|
|
@@ -3249,17 +3296,23 @@ var storeFeature = defineFeature({
|
|
|
3249
3296
|
"removed:marker": "s3:ObjectRemoved:DeleteMarkerCreated"
|
|
3250
3297
|
};
|
|
3251
3298
|
for (const [event, funcProps] of Object.entries(props.events ?? {})) {
|
|
3252
|
-
const
|
|
3299
|
+
const eventGroup = new Node10(group, "event", event);
|
|
3300
|
+
const { lambda } = createAsyncLambdaFunction(eventGroup, ctx, `store`, id, funcProps);
|
|
3301
|
+
new aws10.lambda.Permission(eventGroup, "permission", {
|
|
3302
|
+
action: "lambda:InvokeFunction",
|
|
3303
|
+
principal: "s3.amazonaws.com",
|
|
3304
|
+
functionArn: lambda.arn,
|
|
3305
|
+
sourceArn: `arn:aws:s3:::${bucketName}`
|
|
3306
|
+
});
|
|
3253
3307
|
lambdaConfigs.push({
|
|
3254
3308
|
event: eventMap[event],
|
|
3255
3309
|
function: lambda.arn
|
|
3256
3310
|
});
|
|
3257
3311
|
}
|
|
3258
3312
|
const bucket = new aws10.s3.Bucket(group, "store", {
|
|
3259
|
-
name:
|
|
3313
|
+
name: bucketName,
|
|
3260
3314
|
versioning: props.versioning,
|
|
3261
3315
|
lambdaConfigs,
|
|
3262
|
-
// cors: props.cors,
|
|
3263
3316
|
cors: [
|
|
3264
3317
|
// ---------------------------------------------
|
|
3265
3318
|
// Support for presigned post requests
|
|
@@ -3483,7 +3536,7 @@ var vpcFeature = defineFeature({
|
|
|
3483
3536
|
});
|
|
3484
3537
|
|
|
3485
3538
|
// src/feature/auth/index.ts
|
|
3486
|
-
import { constantCase as
|
|
3539
|
+
import { constantCase as constantCase5 } from "change-case";
|
|
3487
3540
|
import { Node as Node14, aws as aws14 } from "@awsless/formation";
|
|
3488
3541
|
var authFeature = defineFeature({
|
|
3489
3542
|
name: "auth",
|
|
@@ -3536,8 +3589,8 @@ var authFeature = defineFeature({
|
|
|
3536
3589
|
functionArn: item.lambda.arn,
|
|
3537
3590
|
sourceArn: userPoolArn
|
|
3538
3591
|
});
|
|
3539
|
-
item.lambda.addEnvironment(`AUTH_${
|
|
3540
|
-
item.lambda.addEnvironment(`AUTH_${
|
|
3592
|
+
item.lambda.addEnvironment(`AUTH_${constantCase5(id)}_USER_POOL_ID`, userPoolId);
|
|
3593
|
+
item.lambda.addEnvironment(`AUTH_${constantCase5(id)}_CLIENT_ID`, clientId);
|
|
3541
3594
|
item.policy.addStatement({
|
|
3542
3595
|
actions: ["cognito:*"],
|
|
3543
3596
|
resources: [
|
|
@@ -3586,6 +3639,8 @@ var authFeature = defineFeature({
|
|
|
3586
3639
|
userSrp: true
|
|
3587
3640
|
}
|
|
3588
3641
|
});
|
|
3642
|
+
ctx.bindEnv(`AUTH_${constantCase5(id)}_USER_POOL_ID`, userPool.id);
|
|
3643
|
+
ctx.bindEnv(`AUTH_${constantCase5(id)}_CLIENT_ID`, client.id);
|
|
3589
3644
|
ctx.shared.set(`auth-${id}-user-pool-arn`, userPool.arn);
|
|
3590
3645
|
ctx.shared.set(`auth-${id}-user-pool-id`, userPool.id);
|
|
3591
3646
|
ctx.shared.set(`auth-${id}-client-id`, client.id);
|
|
@@ -3595,7 +3650,7 @@ var authFeature = defineFeature({
|
|
|
3595
3650
|
|
|
3596
3651
|
// src/feature/http/index.ts
|
|
3597
3652
|
import { Node as Node15, aws as aws15 } from "@awsless/formation";
|
|
3598
|
-
import { camelCase as camelCase5 } from "change-case";
|
|
3653
|
+
import { camelCase as camelCase5, constantCase as constantCase6 } from "change-case";
|
|
3599
3654
|
import { relative as relative3 } from "path";
|
|
3600
3655
|
var parseRoute = (route) => {
|
|
3601
3656
|
const [method, ...paths] = route.split(" ");
|
|
@@ -3705,6 +3760,7 @@ var httpFeature = defineFeature({
|
|
|
3705
3760
|
})
|
|
3706
3761
|
]
|
|
3707
3762
|
});
|
|
3763
|
+
ctx.shared.set(`http-${id}-listener-arn`, listener.arn);
|
|
3708
3764
|
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
3709
3765
|
new aws15.route53.RecordSet(group2, domainName, {
|
|
3710
3766
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
@@ -3716,7 +3772,7 @@ var httpFeature = defineFeature({
|
|
|
3716
3772
|
dnsName: loadBalancer.dnsName
|
|
3717
3773
|
}
|
|
3718
3774
|
});
|
|
3719
|
-
ctx.
|
|
3775
|
+
ctx.bindEnv(`HTTP_${constantCase6(id)}_ENDPOINT`, domainName);
|
|
3720
3776
|
}
|
|
3721
3777
|
},
|
|
3722
3778
|
onStack(ctx) {
|
|
@@ -3762,7 +3818,7 @@ var httpFeature = defineFeature({
|
|
|
3762
3818
|
|
|
3763
3819
|
// src/feature/search/index.ts
|
|
3764
3820
|
import { Node as Node16, aws as aws16 } from "@awsless/formation";
|
|
3765
|
-
import { constantCase as
|
|
3821
|
+
import { constantCase as constantCase7 } from "change-case";
|
|
3766
3822
|
var typeGenCode6 = `
|
|
3767
3823
|
import { AnyStruct, Table } from '@awsless/open-search'
|
|
3768
3824
|
|
|
@@ -3818,7 +3874,7 @@ var searchFeature = defineFeature({
|
|
|
3818
3874
|
}
|
|
3819
3875
|
ctx.onFunction(({ lambda, policy }) => {
|
|
3820
3876
|
lambda.addEnvironment(
|
|
3821
|
-
`SEARCH_${
|
|
3877
|
+
`SEARCH_${constantCase7(ctx.stack.name)}_${constantCase7(id)}_DOMAIN`,
|
|
3822
3878
|
openSearch.domainEndpoint
|
|
3823
3879
|
);
|
|
3824
3880
|
policy.addStatement({
|
|
@@ -3838,7 +3894,7 @@ import { join as join8 } from "path";
|
|
|
3838
3894
|
|
|
3839
3895
|
// src/feature/site/util.ts
|
|
3840
3896
|
import { lookup, contentType } from "mime-types";
|
|
3841
|
-
import { extname as
|
|
3897
|
+
import { extname as extname5 } from "path";
|
|
3842
3898
|
var getCacheControl = (file) => {
|
|
3843
3899
|
switch (lookup(file)) {
|
|
3844
3900
|
case false:
|
|
@@ -3853,7 +3909,7 @@ var getCacheControl = (file) => {
|
|
|
3853
3909
|
}
|
|
3854
3910
|
};
|
|
3855
3911
|
var getContentType = (file) => {
|
|
3856
|
-
return contentType(
|
|
3912
|
+
return contentType(extname5(file)) || "text/html; charset=utf-8";
|
|
3857
3913
|
};
|
|
3858
3914
|
|
|
3859
3915
|
// src/feature/site/index.ts
|
|
@@ -3870,6 +3926,7 @@ var siteFeature = defineFeature({
|
|
|
3870
3926
|
if (props.ssr) {
|
|
3871
3927
|
const { lambda, code } = createLambdaFunction(group, ctx, `site`, id, props.ssr);
|
|
3872
3928
|
versions.push(code.version);
|
|
3929
|
+
ctx.registerSiteFunction(lambda);
|
|
3873
3930
|
new aws17.lambda.Permission(group, "permission", {
|
|
3874
3931
|
principal: "*",
|
|
3875
3932
|
// principal: 'cloudfront.amazonaws.com',
|
|
@@ -4042,6 +4099,7 @@ var siteFeature = defineFeature({
|
|
|
4042
4099
|
|
|
4043
4100
|
// src/feature/rest/index.ts
|
|
4044
4101
|
import { Node as Node18, aws as aws18 } from "@awsless/formation";
|
|
4102
|
+
import { constantCase as constantCase8 } from "change-case";
|
|
4045
4103
|
var restFeature = defineFeature({
|
|
4046
4104
|
name: "rest",
|
|
4047
4105
|
onApp(ctx) {
|
|
@@ -4084,6 +4142,7 @@ var restFeature = defineFeature({
|
|
|
4084
4142
|
}
|
|
4085
4143
|
});
|
|
4086
4144
|
record.dependsOn(domain, mapping);
|
|
4145
|
+
ctx.bindEnv(`REST_${constantCase8(id)}_ENDPOINT`, domainName);
|
|
4087
4146
|
}
|
|
4088
4147
|
}
|
|
4089
4148
|
},
|
|
@@ -4243,6 +4302,8 @@ var createApp = (props, filters = []) => {
|
|
|
4243
4302
|
const app = new App(props.appConfig.name);
|
|
4244
4303
|
const base = new Stack(app, "base");
|
|
4245
4304
|
const shared = new SharedData();
|
|
4305
|
+
const binds = [];
|
|
4306
|
+
const siteFunctions = [];
|
|
4246
4307
|
const configs = /* @__PURE__ */ new Set();
|
|
4247
4308
|
const tests = [];
|
|
4248
4309
|
const builders = [];
|
|
@@ -4267,6 +4328,12 @@ var createApp = (props, filters = []) => {
|
|
|
4267
4328
|
},
|
|
4268
4329
|
registerBuild(type, name, builder) {
|
|
4269
4330
|
builders.push({ type, name, builder });
|
|
4331
|
+
},
|
|
4332
|
+
registerSiteFunction(lambda) {
|
|
4333
|
+
siteFunctions.push(lambda);
|
|
4334
|
+
},
|
|
4335
|
+
bindEnv(name, value) {
|
|
4336
|
+
binds.push({ name, value });
|
|
4270
4337
|
}
|
|
4271
4338
|
});
|
|
4272
4339
|
}
|
|
@@ -4304,6 +4371,12 @@ var createApp = (props, filters = []) => {
|
|
|
4304
4371
|
},
|
|
4305
4372
|
registerConfig(name) {
|
|
4306
4373
|
configs.add(name);
|
|
4374
|
+
},
|
|
4375
|
+
registerSiteFunction(lambda) {
|
|
4376
|
+
siteFunctions.push(lambda);
|
|
4377
|
+
},
|
|
4378
|
+
bindEnv(name, value) {
|
|
4379
|
+
binds.push({ name, value });
|
|
4307
4380
|
}
|
|
4308
4381
|
});
|
|
4309
4382
|
}
|
|
@@ -4318,6 +4391,11 @@ var createApp = (props, filters = []) => {
|
|
|
4318
4391
|
listener(fn);
|
|
4319
4392
|
}
|
|
4320
4393
|
}
|
|
4394
|
+
for (const lambda of siteFunctions) {
|
|
4395
|
+
for (const { name, value } of binds) {
|
|
4396
|
+
lambda.addEnvironment(name, value);
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4321
4399
|
for (const stackConfig of filterdStacks) {
|
|
4322
4400
|
const functions = allLocalFunctions[stackConfig.name];
|
|
4323
4401
|
for (const dependency of stackConfig.depends ?? []) {
|
|
@@ -4333,6 +4411,7 @@ var createApp = (props, filters = []) => {
|
|
|
4333
4411
|
app,
|
|
4334
4412
|
base,
|
|
4335
4413
|
tests,
|
|
4414
|
+
binds,
|
|
4336
4415
|
shared,
|
|
4337
4416
|
configs,
|
|
4338
4417
|
builders
|
|
@@ -4520,20 +4599,20 @@ var config = (program2) => {
|
|
|
4520
4599
|
import { confirm as confirm3 } from "@clack/prompts";
|
|
4521
4600
|
|
|
4522
4601
|
// src/util/workspace.ts
|
|
4523
|
-
import { WorkSpace, aws as aws19, local } from "@awsless/formation";
|
|
4524
4602
|
import { minutes as minutes4 } from "@awsless/duration";
|
|
4525
|
-
import {
|
|
4603
|
+
import { aws as aws20, local, WorkSpace } from "@awsless/formation";
|
|
4526
4604
|
import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4605
|
+
import { dirname as dirname9, join as join9 } from "path";
|
|
4527
4606
|
var createWorkSpace = (props) => {
|
|
4528
|
-
const lockProvider = new
|
|
4607
|
+
const lockProvider = new aws20.dynamodb.LockProvider({
|
|
4529
4608
|
...props,
|
|
4530
4609
|
tableName: "awsless-locks"
|
|
4531
4610
|
});
|
|
4532
|
-
const stateProvider = new
|
|
4611
|
+
const stateProvider = new aws20.s3.StateProvider({
|
|
4533
4612
|
...props,
|
|
4534
4613
|
bucket: "awsless-state"
|
|
4535
4614
|
});
|
|
4536
|
-
const cloudProviders =
|
|
4615
|
+
const cloudProviders = aws20.createCloudProviders({
|
|
4537
4616
|
...props,
|
|
4538
4617
|
timeout: minutes4(60)
|
|
4539
4618
|
});
|
|
@@ -4552,7 +4631,7 @@ var createWorkSpace = (props) => {
|
|
|
4552
4631
|
var pullRemoteState = async (app, stateProvider) => {
|
|
4553
4632
|
const file = join9(directories.state, `${app.urn}.json`);
|
|
4554
4633
|
const state2 = await stateProvider.get(app.urn);
|
|
4555
|
-
await mkdir2(
|
|
4634
|
+
await mkdir2(dirname9(file), { recursive: true });
|
|
4556
4635
|
if (typeof state2 === "undefined") {
|
|
4557
4636
|
await rm(file);
|
|
4558
4637
|
} else {
|
|
@@ -4591,6 +4670,7 @@ var del2 = (program2) => {
|
|
|
4591
4670
|
}
|
|
4592
4671
|
const { workspace, stateProvider } = createWorkSpace({
|
|
4593
4672
|
credentials,
|
|
4673
|
+
accountId,
|
|
4594
4674
|
region
|
|
4595
4675
|
});
|
|
4596
4676
|
await task("Deleting the stacks to AWS", async (update) => {
|
|
@@ -4690,10 +4770,10 @@ import { startVitest } from "vitest/node";
|
|
|
4690
4770
|
import commonjs3 from "@rollup/plugin-commonjs";
|
|
4691
4771
|
import nodeResolve3 from "@rollup/plugin-node-resolve";
|
|
4692
4772
|
import json3 from "@rollup/plugin-json";
|
|
4693
|
-
import { dirname as
|
|
4773
|
+
import { dirname as dirname10, join as join10 } from "path";
|
|
4694
4774
|
import { fileURLToPath } from "url";
|
|
4695
4775
|
var startTest = async (props) => {
|
|
4696
|
-
const __dirname =
|
|
4776
|
+
const __dirname = dirname10(fileURLToPath(import.meta.url));
|
|
4697
4777
|
const result = await startVitest(
|
|
4698
4778
|
"test",
|
|
4699
4779
|
props.filters,
|
|
@@ -4897,6 +4977,7 @@ var deploy = (program2) => {
|
|
|
4897
4977
|
await buildAssets(builders);
|
|
4898
4978
|
const { workspace, stateProvider } = createWorkSpace({
|
|
4899
4979
|
credentials,
|
|
4980
|
+
accountId,
|
|
4900
4981
|
region
|
|
4901
4982
|
});
|
|
4902
4983
|
await task("Deploying the stacks to AWS", async (update) => {
|
|
@@ -4910,7 +4991,7 @@ var deploy = (program2) => {
|
|
|
4910
4991
|
};
|
|
4911
4992
|
|
|
4912
4993
|
// src/cli/command/diff.ts
|
|
4913
|
-
import { WorkSpace as WorkSpace2, aws as
|
|
4994
|
+
import { WorkSpace as WorkSpace2, aws as aws21 } from "@awsless/formation";
|
|
4914
4995
|
import chalk7 from "chalk";
|
|
4915
4996
|
var diff = (program2) => {
|
|
4916
4997
|
program2.command("diff").description("Diff your app with AWS").action(async (filters) => {
|
|
@@ -4922,12 +5003,12 @@ var diff = (program2) => {
|
|
|
4922
5003
|
const { app, builders } = createApp({ appConfig, stackConfigs, accountId }, filters);
|
|
4923
5004
|
await buildAssets(builders);
|
|
4924
5005
|
const workspace = new WorkSpace2({
|
|
4925
|
-
stateProvider: new
|
|
5006
|
+
stateProvider: new aws21.dynamodb.DynamoDBStateProvider({
|
|
4926
5007
|
credentials,
|
|
4927
5008
|
region,
|
|
4928
5009
|
tableName: "awsless-state"
|
|
4929
5010
|
}),
|
|
4930
|
-
cloudProviders:
|
|
5011
|
+
cloudProviders: aws21.createCloudProviders({
|
|
4931
5012
|
credentials,
|
|
4932
5013
|
region: appConfig.region
|
|
4933
5014
|
})
|
|
@@ -4983,7 +5064,7 @@ import { log as log9 } from "@clack/prompts";
|
|
|
4983
5064
|
|
|
4984
5065
|
// src/type-gen/generate.ts
|
|
4985
5066
|
import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
4986
|
-
import { dirname as
|
|
5067
|
+
import { dirname as dirname11, join as join12, relative as relative5 } from "path";
|
|
4987
5068
|
var generateTypes = async (props) => {
|
|
4988
5069
|
const files = [];
|
|
4989
5070
|
await Promise.all(
|
|
@@ -4997,7 +5078,7 @@ var generateTypes = async (props) => {
|
|
|
4997
5078
|
if (include) {
|
|
4998
5079
|
files.push(relative5(directories.root, path));
|
|
4999
5080
|
}
|
|
5000
|
-
await mkdir4(
|
|
5081
|
+
await mkdir4(dirname11(path), { recursive: true });
|
|
5001
5082
|
await writeFile4(path, code);
|
|
5002
5083
|
}
|
|
5003
5084
|
}
|
|
@@ -5272,6 +5353,50 @@ var auth = (program2) => {
|
|
|
5272
5353
|
commands5.forEach((cb) => cb(command));
|
|
5273
5354
|
};
|
|
5274
5355
|
|
|
5356
|
+
// src/cli/command/bind.ts
|
|
5357
|
+
import { unwrap as unwrap2 } from "@awsless/formation";
|
|
5358
|
+
import { note as note3 } from "@clack/prompts";
|
|
5359
|
+
import { spawn } from "child_process";
|
|
5360
|
+
var bind = (program2) => {
|
|
5361
|
+
program2.command("bind").argument("<command...>", "The command to execute").description(`Bind your site environment variables to a command`).action(async (commands7) => {
|
|
5362
|
+
await layout("bind", async ({ appConfig, stackConfigs }) => {
|
|
5363
|
+
const region = appConfig.region;
|
|
5364
|
+
const credentials = getCredentials(appConfig.profile);
|
|
5365
|
+
const accountId = await getAccountId(credentials, region);
|
|
5366
|
+
const { app, binds } = createApp({ appConfig, stackConfigs, accountId });
|
|
5367
|
+
const { workspace } = createWorkSpace({
|
|
5368
|
+
credentials,
|
|
5369
|
+
accountId,
|
|
5370
|
+
region
|
|
5371
|
+
});
|
|
5372
|
+
await workspace.hydrate(app);
|
|
5373
|
+
const env = {};
|
|
5374
|
+
for (const { name, value } of binds) {
|
|
5375
|
+
env[name] = unwrap2(value);
|
|
5376
|
+
}
|
|
5377
|
+
note3(wrap(list(env)), "Bind Env");
|
|
5378
|
+
const command = commands7.join(" ");
|
|
5379
|
+
spawn(command, {
|
|
5380
|
+
env: {
|
|
5381
|
+
// Pass the process env vars
|
|
5382
|
+
...process.env,
|
|
5383
|
+
// Pass the site bind env vars
|
|
5384
|
+
...env,
|
|
5385
|
+
// Basic info
|
|
5386
|
+
AWS_REGION: appConfig.region,
|
|
5387
|
+
AWS_ACCOUNT_ID: accountId
|
|
5388
|
+
// Give AWS access
|
|
5389
|
+
// AWS_ACCESS_KEY_ID: credentials.accessKeyId,
|
|
5390
|
+
// AWS_SECRET_ACCESS_KEY: credentials.secretAccessKey,
|
|
5391
|
+
// AWS_SESSION_TOKEN: credentials.sessionToken,
|
|
5392
|
+
},
|
|
5393
|
+
stdio: "inherit",
|
|
5394
|
+
shell: true
|
|
5395
|
+
});
|
|
5396
|
+
});
|
|
5397
|
+
});
|
|
5398
|
+
};
|
|
5399
|
+
|
|
5275
5400
|
// src/cli/command/index.ts
|
|
5276
5401
|
var commands6 = [
|
|
5277
5402
|
bootstrap,
|
|
@@ -5281,7 +5406,7 @@ var commands6 = [
|
|
|
5281
5406
|
diff,
|
|
5282
5407
|
del2,
|
|
5283
5408
|
dev,
|
|
5284
|
-
|
|
5409
|
+
bind,
|
|
5285
5410
|
auth,
|
|
5286
5411
|
state,
|
|
5287
5412
|
resource,
|
|
@@ -807,6 +807,14 @@ var SitesSchema = z24.record(
|
|
|
807
807
|
z24.object({
|
|
808
808
|
domain: ResourceIdSchema.describe("The domain id to link your site with."),
|
|
809
809
|
subDomain: z24.string().optional(),
|
|
810
|
+
// bind: z
|
|
811
|
+
// .object({
|
|
812
|
+
// auth: z.array(ResourceIdSchema),
|
|
813
|
+
// graphql: z.array(ResourceIdSchema),
|
|
814
|
+
// // http: z.array(ResourceIdSchema),
|
|
815
|
+
// // rest: z.array(ResourceIdSchema),
|
|
816
|
+
// })
|
|
817
|
+
// .optional(),
|
|
810
818
|
static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
|
|
811
819
|
ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
|
|
812
820
|
// bind: z.object({
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/lib/resource/util.ts
|
|
2
|
+
import { paramCase } from "change-case";
|
|
3
|
+
var APP = process.env.APP ?? "app";
|
|
4
|
+
var STACK = process.env.STACK ?? "stack";
|
|
5
|
+
var bindLocalResourceName = (type) => {
|
|
6
|
+
return (name, stack = STACK) => {
|
|
7
|
+
return [APP, paramCase(stack), paramCase(type), paramCase(name)].join(
|
|
8
|
+
"--"
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
var bindGlobalResourceName = (type) => {
|
|
13
|
+
return (name) => {
|
|
14
|
+
return [APP, paramCase(type), paramCase(name)].join("--");
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var createProxy = /* @__NO_SIDE_EFFECTS__ */ (cb) => {
|
|
18
|
+
const cache = /* @__PURE__ */ new Map();
|
|
19
|
+
return new Proxy(
|
|
20
|
+
{},
|
|
21
|
+
{
|
|
22
|
+
get(_, name) {
|
|
23
|
+
if (!cache.has(name)) {
|
|
24
|
+
cache.set(name, cb(name));
|
|
25
|
+
}
|
|
26
|
+
return cache.get(name);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// src/lib/resource/auth.ts
|
|
33
|
+
import { constantCase } from "change-case";
|
|
34
|
+
var getAuthName = bindGlobalResourceName("auth");
|
|
35
|
+
var Auth = /* @__PURE__ */ createProxy((name) => {
|
|
36
|
+
return getAuthProps(name);
|
|
37
|
+
});
|
|
38
|
+
var getAuthProps = (name) => {
|
|
39
|
+
const env = process.env;
|
|
40
|
+
const id = constantCase(name);
|
|
41
|
+
return {
|
|
42
|
+
name: getAuthName(name),
|
|
43
|
+
// userPoolId: env[`AWSLESS_CLIENT_AUTH_${id}_USER_POOL_ID`]!,
|
|
44
|
+
// clientId: env[`AWSLESS_CLIENT_AUTH_${id}_CLIENT_ID`]!,
|
|
45
|
+
// clientSecret: env[`AWSLESS_CLIENT_AUTH_${id}_CLIENT_SECRET`]!,
|
|
46
|
+
userPoolId: env[`AUTH_${id}_USER_POOL_ID`],
|
|
47
|
+
clientId: env[`AUTH_${id}_CLIENT_ID`]
|
|
48
|
+
// clientSecret: env[`AUTH_${id}_CLIENT_SECRET`]!,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
APP,
|
|
54
|
+
STACK,
|
|
55
|
+
bindLocalResourceName,
|
|
56
|
+
bindGlobalResourceName,
|
|
57
|
+
createProxy,
|
|
58
|
+
getAuthName,
|
|
59
|
+
Auth,
|
|
60
|
+
getAuthProps
|
|
61
|
+
};
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Auth
|
|
3
|
+
} from "./chunk-RRXFYZJQ.js";
|
|
4
|
+
|
|
1
5
|
// src/lib/resource/http.ts
|
|
2
6
|
var createHttpFetcher = (host) => {
|
|
3
7
|
return async ({ method, path, headers, body, query }) => {
|
|
@@ -41,6 +45,7 @@ var createHttpClient = (fetcher) => {
|
|
|
41
45
|
};
|
|
42
46
|
};
|
|
43
47
|
export {
|
|
48
|
+
Auth,
|
|
44
49
|
createHttpClient,
|
|
45
50
|
createHttpFetcher
|
|
46
51
|
};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { A as Auth, b as AuthResources, g as getAuthName, a as getAuthProps } from './auth-b89f6013.js';
|
|
1
2
|
import * as _awsless_lambda from '@awsless/lambda';
|
|
2
3
|
import { Handler, Loggers } from '@awsless/lambda';
|
|
3
4
|
import { BaseSchema, SnsTopicSchema, SqsQueueSchema } from '@awsless/validate';
|
|
@@ -17,17 +18,6 @@ interface TaskResources {
|
|
|
17
18
|
}
|
|
18
19
|
declare const Task: TaskResources;
|
|
19
20
|
|
|
20
|
-
declare const getAuthName: <N extends string>(name: N) => `app--auth--${N}`;
|
|
21
|
-
interface AuthResources {
|
|
22
|
-
}
|
|
23
|
-
declare const Auth: AuthResources;
|
|
24
|
-
declare const getAuthProps: (name: string) => {
|
|
25
|
-
readonly name: `app--auth--${string}`;
|
|
26
|
-
readonly userPoolId: string;
|
|
27
|
-
readonly clientId: string;
|
|
28
|
-
readonly clientSecret: string;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
21
|
declare const getTableName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--table--${N}`;
|
|
32
22
|
interface TableResources {
|
|
33
23
|
}
|
|
@@ -129,4 +119,4 @@ interface TaskMockResponse {
|
|
|
129
119
|
}
|
|
130
120
|
declare const mockTask: (cb: (mock: TaskMock) => void) => TaskMockResponse;
|
|
131
121
|
|
|
132
|
-
export { APP,
|
|
122
|
+
export { APP, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionMock, FunctionMockResponse, FunctionProps, FunctionResources, Queue, QueueMock, QueueMockResponse, QueueProps, QueueResources, STACK, Search, SearchResources, Store, StoreResources, Table, TableResources, Task, TaskMock, TaskMockResponse, TaskResources, Topic, TopicMock, TopicMockResponse, TopicProps, TopicResources, cron, func, getCacheProps, getConfigName, getFunctionName, getQueueName, getSearchName, getStoreName, getTableName, getTaskName, getTopicName, mockFunction, mockQueue, mockTask, mockTopic, queue, topic };
|
package/dist/server.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var bindGlobalResourceName = (type) => {
|
|
13
|
-
return (name) => {
|
|
14
|
-
return [APP, paramCase(type), paramCase(name)].join("--");
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
var createProxy = /* @__NO_SIDE_EFFECTS__ */ (cb) => {
|
|
18
|
-
const cache2 = /* @__PURE__ */ new Map();
|
|
19
|
-
return new Proxy(
|
|
20
|
-
{},
|
|
21
|
-
{
|
|
22
|
-
get(_, name) {
|
|
23
|
-
if (!cache2.has(name)) {
|
|
24
|
-
cache2.set(name, cb(name));
|
|
25
|
-
}
|
|
26
|
-
return cache2.get(name);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
APP,
|
|
3
|
+
Auth,
|
|
4
|
+
STACK,
|
|
5
|
+
bindGlobalResourceName,
|
|
6
|
+
bindLocalResourceName,
|
|
7
|
+
createProxy,
|
|
8
|
+
getAuthName,
|
|
9
|
+
getAuthProps
|
|
10
|
+
} from "./chunk-RRXFYZJQ.js";
|
|
31
11
|
|
|
32
12
|
// src/lib/resource/function.ts
|
|
33
13
|
import { invoke } from "@awsless/lambda";
|
|
@@ -84,26 +64,6 @@ var Task = /* @__PURE__ */ createProxy((stackName) => {
|
|
|
84
64
|
});
|
|
85
65
|
});
|
|
86
66
|
|
|
87
|
-
// src/lib/resource/auth.ts
|
|
88
|
-
import { constantCase } from "change-case";
|
|
89
|
-
var getAuthName = bindGlobalResourceName("auth");
|
|
90
|
-
var Auth = /* @__PURE__ */ createProxy((name) => {
|
|
91
|
-
return getAuthProps(name);
|
|
92
|
-
});
|
|
93
|
-
var getAuthProps = (name) => {
|
|
94
|
-
const env = process.env;
|
|
95
|
-
const id = constantCase(name);
|
|
96
|
-
return {
|
|
97
|
-
name: getAuthName(name),
|
|
98
|
-
// userPoolId: env[`AWSLESS_CLIENT_AUTH_${id}_USER_POOL_ID`]!,
|
|
99
|
-
// clientId: env[`AWSLESS_CLIENT_AUTH_${id}_CLIENT_ID`]!,
|
|
100
|
-
// clientSecret: env[`AWSLESS_CLIENT_AUTH_${id}_CLIENT_SECRET`]!,
|
|
101
|
-
userPoolId: env[`AUTH_${id}_USER_POOL_ID`],
|
|
102
|
-
clientId: env[`AUTH_${id}_CLIENT_ID`],
|
|
103
|
-
clientSecret: env[`AUTH_${id}_CLIENT_SECRET`]
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
|
|
107
67
|
// src/lib/resource/table.ts
|
|
108
68
|
var getTableName = bindLocalResourceName("table");
|
|
109
69
|
var Table = /* @__PURE__ */ createProxy((stack) => {
|
|
@@ -135,10 +95,10 @@ import {
|
|
|
135
95
|
sendMessage,
|
|
136
96
|
sendMessageBatch
|
|
137
97
|
} from "@awsless/sqs";
|
|
138
|
-
import { constantCase
|
|
98
|
+
import { constantCase } from "change-case";
|
|
139
99
|
var getQueueName = bindLocalResourceName("queue");
|
|
140
100
|
var getQueueUrl = (name, stack = STACK) => {
|
|
141
|
-
return process.env[`QUEUE_${
|
|
101
|
+
return process.env[`QUEUE_${constantCase(stack)}_${constantCase(name)}_URL`];
|
|
142
102
|
};
|
|
143
103
|
var Queue = /* @__PURE__ */ createProxy((stack) => {
|
|
144
104
|
return createProxy((queue2) => {
|
|
@@ -167,10 +127,10 @@ var Queue = /* @__PURE__ */ createProxy((stack) => {
|
|
|
167
127
|
});
|
|
168
128
|
|
|
169
129
|
// src/lib/resource/cache.ts
|
|
170
|
-
import { constantCase as
|
|
130
|
+
import { constantCase as constantCase2 } from "change-case";
|
|
171
131
|
import { command } from "@awsless/redis";
|
|
172
132
|
var getCacheProps = (name, stack = STACK) => {
|
|
173
|
-
const prefix = `CACHE_${
|
|
133
|
+
const prefix = `CACHE_${constantCase2(stack)}_${constantCase2(name)}`;
|
|
174
134
|
return {
|
|
175
135
|
host: process.env[`${prefix}_HOST`],
|
|
176
136
|
port: parseInt(process.env[`${prefix}_PORT`], 10)
|
|
@@ -241,14 +201,14 @@ var Store = /* @__PURE__ */ createProxy((stack) => {
|
|
|
241
201
|
|
|
242
202
|
// src/lib/resource/config.ts
|
|
243
203
|
import { ssm } from "@awsless/ssm";
|
|
244
|
-
import { paramCase
|
|
204
|
+
import { paramCase } from "change-case";
|
|
245
205
|
var getConfigName = (name) => {
|
|
246
206
|
return `/.awsless/${APP}/${name}`;
|
|
247
207
|
};
|
|
248
|
-
var
|
|
208
|
+
var IS_TEST = process.env.NODE_ENV === "test";
|
|
249
209
|
var CONFIGS = process.env.CONFIG;
|
|
250
210
|
var loadConfigData = /* @__NO_SIDE_EFFECTS__ */ async () => {
|
|
251
|
-
if (!
|
|
211
|
+
if (!IS_TEST && CONFIGS) {
|
|
252
212
|
const keys = CONFIGS.split(",");
|
|
253
213
|
if (keys.length > 0) {
|
|
254
214
|
const paths = {};
|
|
@@ -265,17 +225,17 @@ var Config = /* @__PURE__ */ new Proxy(
|
|
|
265
225
|
{},
|
|
266
226
|
{
|
|
267
227
|
get(_, name) {
|
|
268
|
-
const key =
|
|
228
|
+
const key = paramCase(name);
|
|
269
229
|
const value = data[key];
|
|
270
230
|
if (typeof value === "undefined") {
|
|
271
231
|
throw new Error(
|
|
272
|
-
`The "${name}" config value hasn't been set yet. ${
|
|
232
|
+
`The "${name}" config value hasn't been set yet. ${IS_TEST ? `Use "Config.${name} = 'VAlUE'" to define your mock value.` : `Define access to the desired config value inside your awsless stack file.`}`
|
|
273
233
|
);
|
|
274
234
|
}
|
|
275
235
|
return value;
|
|
276
236
|
},
|
|
277
237
|
set(_, name, value) {
|
|
278
|
-
const key =
|
|
238
|
+
const key = paramCase(name);
|
|
279
239
|
data[key] = value;
|
|
280
240
|
return true;
|
|
281
241
|
}
|
|
@@ -283,12 +243,12 @@ var Config = /* @__PURE__ */ new Proxy(
|
|
|
283
243
|
);
|
|
284
244
|
|
|
285
245
|
// src/lib/resource/search.ts
|
|
286
|
-
import { constantCase as
|
|
246
|
+
import { constantCase as constantCase3 } from "change-case";
|
|
287
247
|
import { searchClient, define } from "@awsless/open-search";
|
|
288
248
|
var getSearchName = bindLocalResourceName("search");
|
|
289
249
|
var getSearchProps = (name, stack = STACK) => {
|
|
290
250
|
return {
|
|
291
|
-
domain: process.env[`CACHE_${
|
|
251
|
+
domain: process.env[`CACHE_${constantCase3(stack)}_${constantCase3(name)}_DOMAIN`]
|
|
292
252
|
};
|
|
293
253
|
};
|
|
294
254
|
var Search = /* @__PURE__ */ createProxy((stack) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.249",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
+
"@awsless/lambda": "^0.0.19",
|
|
31
32
|
"@awsless/open-search": "^0.0.12",
|
|
32
|
-
"@awsless/redis": "^0.0.12",
|
|
33
33
|
"@awsless/sns": "^0.0.7",
|
|
34
|
-
"@awsless/lambda": "^0.0.19",
|
|
35
|
-
"@awsless/sqs": "^0.0.7",
|
|
36
34
|
"@awsless/s3": "^0.0.10",
|
|
37
|
-
"@awsless/
|
|
35
|
+
"@awsless/sqs": "^0.0.7",
|
|
36
|
+
"@awsless/redis": "^0.0.12",
|
|
38
37
|
"@awsless/validate": "^0.0.14",
|
|
38
|
+
"@awsless/ssm": "^0.0.7",
|
|
39
39
|
"@awsless/weak-cache": "^0.0.1"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"parse-static-imports": "^1.1.0",
|
|
88
88
|
"pretty-hrtime": "^1.0.3",
|
|
89
89
|
"promise-dag": "^1.0.0",
|
|
90
|
+
"promisify-child-process": "^4.1.2",
|
|
90
91
|
"rollup": "^4.0.2",
|
|
91
92
|
"rollup-plugin-replace": "^2.2.0",
|
|
92
93
|
"rollup-plugin-swc3": "^0.10.2",
|
|
@@ -97,12 +98,12 @@
|
|
|
97
98
|
"wrap-ansi": "^8.1.0",
|
|
98
99
|
"zod": "^3.21.4",
|
|
99
100
|
"zod-to-json-schema": "^3.22.3",
|
|
101
|
+
"@awsless/code": "^0.0.10",
|
|
102
|
+
"@awsless/duration": "^0.0.1",
|
|
100
103
|
"@awsless/graphql": "^0.0.9",
|
|
101
|
-
"@awsless/validate": "^0.0.14",
|
|
102
|
-
"@awsless/formation": "^0.0.27",
|
|
103
104
|
"@awsless/size": "^0.0.1",
|
|
104
|
-
"@awsless/
|
|
105
|
-
"@awsless/
|
|
105
|
+
"@awsless/formation": "^0.0.27",
|
|
106
|
+
"@awsless/validate": "^0.0.14"
|
|
106
107
|
},
|
|
107
108
|
"scripts": {
|
|
108
109
|
"test": "pnpm code test",
|