@awsless/awsless 0.0.92 → 0.0.94
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 +182 -92
- package/dist/features/cognito-client-secret/bundle.zip +0 -0
- package/dist/features/delete-bucket/bundle.zip +0 -0
- package/dist/features/delete-hosted-zone/bundle.zip +0 -0
- package/dist/features/global-exports/bundle.zip +0 -0
- package/dist/features/invalidate-cache/bundle.zip +0 -0
- package/dist/features/upload-bucket-asset/bundle.zip +0 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +62 -0
- package/package.json +4 -4
package/dist/bin.js
CHANGED
|
@@ -1244,10 +1244,7 @@ import { mkdir, writeFile } from "fs/promises";
|
|
|
1244
1244
|
import { join as join3, relative } from "path";
|
|
1245
1245
|
import { camelCase, constantCase as constantCase3 } from "change-case";
|
|
1246
1246
|
var generateResourceTypes = async (config) => {
|
|
1247
|
-
const plugins = [
|
|
1248
|
-
...defaultPlugins,
|
|
1249
|
-
...config.plugins || []
|
|
1250
|
-
];
|
|
1247
|
+
const plugins = [...defaultPlugins, ...config.plugins || []];
|
|
1251
1248
|
const files = [];
|
|
1252
1249
|
for (const plugin of plugins) {
|
|
1253
1250
|
const code = plugin.onTypeGen?.({ config });
|
|
@@ -1264,13 +1261,11 @@ var generateResourceTypes = async (config) => {
|
|
|
1264
1261
|
}
|
|
1265
1262
|
};
|
|
1266
1263
|
var TypeGen = class {
|
|
1267
|
-
constructor(module
|
|
1264
|
+
constructor(module) {
|
|
1268
1265
|
this.module = module;
|
|
1269
|
-
this.interfaceName = interfaceName;
|
|
1270
|
-
this.readonly = readonly;
|
|
1271
1266
|
}
|
|
1272
1267
|
codes = /* @__PURE__ */ new Set();
|
|
1273
|
-
|
|
1268
|
+
interfaces = /* @__PURE__ */ new Map();
|
|
1274
1269
|
imports = /* @__PURE__ */ new Map();
|
|
1275
1270
|
addImport(varName, path) {
|
|
1276
1271
|
this.imports.set(varName, path);
|
|
@@ -1280,48 +1275,49 @@ var TypeGen = class {
|
|
|
1280
1275
|
this.codes.add(code);
|
|
1281
1276
|
return this;
|
|
1282
1277
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
return this;
|
|
1288
|
-
}
|
|
1289
|
-
addConst(name, type) {
|
|
1290
|
-
if (type) {
|
|
1291
|
-
this.types.set(constantCase3(name), type);
|
|
1278
|
+
addInterface(name, type) {
|
|
1279
|
+
const value = type.toString();
|
|
1280
|
+
if (value) {
|
|
1281
|
+
this.interfaces.set(name, value);
|
|
1292
1282
|
}
|
|
1293
1283
|
return this;
|
|
1294
1284
|
}
|
|
1285
|
+
// addConst(name: string, type: string) {
|
|
1286
|
+
// if (type) {
|
|
1287
|
+
// this.types.set(constantCase(name), type)
|
|
1288
|
+
// }
|
|
1289
|
+
// return this
|
|
1290
|
+
// }
|
|
1295
1291
|
toString() {
|
|
1296
|
-
if (this.
|
|
1292
|
+
if (this.interfaces.size === 0) {
|
|
1297
1293
|
return;
|
|
1298
1294
|
}
|
|
1299
1295
|
const lines = [];
|
|
1300
1296
|
if (this.imports.size > 0) {
|
|
1301
|
-
lines.push(
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1297
|
+
lines.push(
|
|
1298
|
+
...[
|
|
1299
|
+
"// Imports",
|
|
1300
|
+
...Array.from(this.imports.entries()).map(([varName, path]) => {
|
|
1301
|
+
return `import ${camelCase(varName)} from '${path}'`;
|
|
1302
|
+
}),
|
|
1303
|
+
""
|
|
1304
|
+
]
|
|
1305
|
+
);
|
|
1308
1306
|
}
|
|
1309
1307
|
if (this.codes.size > 0) {
|
|
1310
|
-
lines.push(...[
|
|
1311
|
-
"// Types",
|
|
1312
|
-
...Array.from(this.codes).map((v) => v.trim()),
|
|
1313
|
-
""
|
|
1314
|
-
]);
|
|
1308
|
+
lines.push(...["// Types", ...Array.from(this.codes).map((v) => v.trim()), ""]);
|
|
1315
1309
|
}
|
|
1316
1310
|
return [
|
|
1317
1311
|
...lines,
|
|
1318
1312
|
"// Extend module",
|
|
1319
1313
|
`declare module '${this.module}' {`,
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
`
|
|
1314
|
+
Array.from(this.interfaces).map(([name, type]) => {
|
|
1315
|
+
return ` interface ${name} ${type}`;
|
|
1316
|
+
}).join("\n\n"),
|
|
1317
|
+
// ...Array.from(this.types.entries()).map(([propName, type]) => { // `\tinterface ${this.interfaceName} {`,
|
|
1318
|
+
// return `\t\t${this.readonly ? 'readonly ' : ''}${propName}: ${type}`
|
|
1319
|
+
// }),
|
|
1320
|
+
// `\t}`,
|
|
1325
1321
|
`}`,
|
|
1326
1322
|
"",
|
|
1327
1323
|
"// Export fix",
|
|
@@ -1330,10 +1326,15 @@ var TypeGen = class {
|
|
|
1330
1326
|
}
|
|
1331
1327
|
};
|
|
1332
1328
|
var TypeObject = class {
|
|
1329
|
+
constructor(level, readonly = true) {
|
|
1330
|
+
this.level = level;
|
|
1331
|
+
this.readonly = readonly;
|
|
1332
|
+
}
|
|
1333
1333
|
types = /* @__PURE__ */ new Map();
|
|
1334
1334
|
addType(name, type) {
|
|
1335
|
-
|
|
1336
|
-
|
|
1335
|
+
const value = type.toString();
|
|
1336
|
+
if (value) {
|
|
1337
|
+
this.types.set(camelCase(name), value);
|
|
1337
1338
|
}
|
|
1338
1339
|
return this;
|
|
1339
1340
|
}
|
|
@@ -1350,9 +1351,16 @@ var TypeObject = class {
|
|
|
1350
1351
|
return [
|
|
1351
1352
|
"{",
|
|
1352
1353
|
...Array.from(this.types.entries()).map(([propName, type]) => {
|
|
1353
|
-
return
|
|
1354
|
+
return [
|
|
1355
|
+
" ".repeat(this.level + 1),
|
|
1356
|
+
this.readonly ? "readonly" : "",
|
|
1357
|
+
" ",
|
|
1358
|
+
propName,
|
|
1359
|
+
": ",
|
|
1360
|
+
type
|
|
1361
|
+
].join("");
|
|
1354
1362
|
}),
|
|
1355
|
-
"
|
|
1363
|
+
`${" ".repeat(this.level)}}`
|
|
1356
1364
|
].join("\n");
|
|
1357
1365
|
}
|
|
1358
1366
|
};
|
|
@@ -1564,30 +1572,51 @@ var schema = z6.object({
|
|
|
1564
1572
|
});
|
|
1565
1573
|
var typeGenCode = `
|
|
1566
1574
|
import { InvokeOptions, InvokeResponse } from '@awsless/lambda'
|
|
1575
|
+
import type { Mock } from 'vitest'
|
|
1576
|
+
|
|
1577
|
+
type Func = (...args: any[]) => any
|
|
1567
1578
|
|
|
1568
|
-
type Invoke<Name extends string,
|
|
1579
|
+
type Invoke<Name extends string, F extends Func> = {
|
|
1569
1580
|
readonly name: Name
|
|
1570
|
-
readonly async: (payload: Parameters<
|
|
1571
|
-
(payload: Parameters<
|
|
1572
|
-
}
|
|
1581
|
+
readonly async: (payload: Parameters<F>[0], options?: Omit<InvokeOptions, 'name' | 'payload' | 'type'>) => InvokeResponse<F>
|
|
1582
|
+
(payload: Parameters<F>[0], options?: Omit<InvokeOptions, 'name' | 'payload'>): InvokeResponse<F>
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
type Response<F extends Func> = Partial<Awaited<InvokeResponse<F>>>
|
|
1586
|
+
type MockHandle<F extends Func> = (payload: Parameters<F>[0]) => Response<F> | void
|
|
1587
|
+
type MockHandleOrResponse<F extends Func> = MockHandle<F> | Response<F>
|
|
1588
|
+
type MockBuilder<F extends Func> = (handleOrResponse?: MockHandleOrResponse<F>) => void
|
|
1589
|
+
`;
|
|
1573
1590
|
var functionPlugin = definePlugin({
|
|
1574
1591
|
name: "function",
|
|
1575
1592
|
schema,
|
|
1576
1593
|
onTypeGen({ config }) {
|
|
1577
|
-
const types2 = new TypeGen("@awsless/awsless"
|
|
1578
|
-
|
|
1594
|
+
const types2 = new TypeGen("@awsless/awsless");
|
|
1595
|
+
const resources = new TypeObject(1);
|
|
1596
|
+
const mocks = new TypeObject(1);
|
|
1597
|
+
const mockResponses = new TypeObject(1);
|
|
1579
1598
|
for (const stack of config.stacks) {
|
|
1580
|
-
const
|
|
1599
|
+
const resource = new TypeObject(2);
|
|
1600
|
+
const mock = new TypeObject(2);
|
|
1601
|
+
const mockResponse = new TypeObject(2);
|
|
1581
1602
|
for (const [name, fileOrProps] of Object.entries(stack.functions || {})) {
|
|
1582
1603
|
const varName = camelCase2(`${stack.name}-${name}`);
|
|
1583
1604
|
const funcName = formatName(`${config.name}-${stack.name}-${name}`);
|
|
1584
1605
|
const file = typeof fileOrProps === "string" ? fileOrProps : fileOrProps.file;
|
|
1585
1606
|
const relFile = relative2(directories.types, file);
|
|
1586
1607
|
types2.addImport(varName, relFile);
|
|
1587
|
-
|
|
1608
|
+
resource.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
|
|
1609
|
+
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
1610
|
+
mockResponse.addType(name, `Mock`);
|
|
1588
1611
|
}
|
|
1589
|
-
|
|
1612
|
+
mocks.addType(stack.name, mock);
|
|
1613
|
+
resources.addType(stack.name, resource);
|
|
1614
|
+
mockResponses.addType(stack.name, mockResponse);
|
|
1590
1615
|
}
|
|
1616
|
+
types2.addCode(typeGenCode);
|
|
1617
|
+
types2.addInterface("FunctionResources", resources);
|
|
1618
|
+
types2.addInterface("FunctionMock", mocks);
|
|
1619
|
+
types2.addInterface("FunctionMockResponse", mockResponses);
|
|
1591
1620
|
return types2.toString();
|
|
1592
1621
|
},
|
|
1593
1622
|
onStack(ctx) {
|
|
@@ -1830,24 +1859,48 @@ var SqsEventSource = class extends Group {
|
|
|
1830
1859
|
// src/plugins/queue.ts
|
|
1831
1860
|
import { camelCase as camelCase3, constantCase as constantCase5 } from "change-case";
|
|
1832
1861
|
import { relative as relative3 } from "path";
|
|
1833
|
-
var RetentionPeriodSchema = DurationSchema.refine(
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
var
|
|
1862
|
+
var RetentionPeriodSchema = DurationSchema.refine(
|
|
1863
|
+
durationMin(Duration.minutes(1)),
|
|
1864
|
+
"Minimum retention period is 1 minute"
|
|
1865
|
+
).refine(durationMax(Duration.days(14)), "Maximum retention period is 14 days");
|
|
1866
|
+
var VisibilityTimeoutSchema = DurationSchema.refine(
|
|
1867
|
+
durationMax(Duration.hours(12)),
|
|
1868
|
+
"Maximum visibility timeout is 12 hours"
|
|
1869
|
+
);
|
|
1870
|
+
var DeliveryDelaySchema = DurationSchema.refine(
|
|
1871
|
+
durationMax(Duration.minutes(15)),
|
|
1872
|
+
"Maximum delivery delay is 15 minutes"
|
|
1873
|
+
);
|
|
1874
|
+
var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
|
|
1875
|
+
durationMin(Duration.seconds(1)),
|
|
1876
|
+
"Minimum receive message wait time is 1 second"
|
|
1877
|
+
).refine(durationMax(Duration.seconds(20)), "Maximum receive message wait time is 20 seconds");
|
|
1878
|
+
var MaxMessageSizeSchema = SizeSchema.refine(
|
|
1879
|
+
sizeMin(Size.kiloBytes(1)),
|
|
1880
|
+
"Minimum max message size is 1 KB"
|
|
1881
|
+
).refine(sizeMax(Size.kiloBytes(256)), "Maximum max message size is 256 KB");
|
|
1838
1882
|
var BatchSizeSchema = z8.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000");
|
|
1839
1883
|
var MaxConcurrencySchema = z8.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000");
|
|
1840
|
-
var MaxBatchingWindow = DurationSchema.refine(
|
|
1884
|
+
var MaxBatchingWindow = DurationSchema.refine(
|
|
1885
|
+
durationMax(Duration.minutes(5)),
|
|
1886
|
+
"Maximum max batching window is 5 minutes"
|
|
1887
|
+
);
|
|
1841
1888
|
var typeGenCode2 = `
|
|
1842
1889
|
import { SendMessageOptions, SendMessageBatchOptions, BatchItem } from '@awsless/sqs'
|
|
1890
|
+
import type { Mock } from 'vitest'
|
|
1843
1891
|
|
|
1844
|
-
type
|
|
1892
|
+
type Func = (...args: any[]) => any
|
|
1893
|
+
type Payload<F extends Func> = Parameters<F>[0]['Records'][number]['body']
|
|
1845
1894
|
|
|
1846
|
-
type Send<Name extends string,
|
|
1895
|
+
type Send<Name extends string, F extends Func> = {
|
|
1847
1896
|
readonly name: Name
|
|
1848
|
-
readonly batch(items:BatchItem<Payload<
|
|
1849
|
-
(payload: Payload<
|
|
1850
|
-
}
|
|
1897
|
+
readonly batch(items:BatchItem<Payload<F>>[], options?:Omit<SendMessageBatchOptions, 'queue' | 'items'>): Promise<void>
|
|
1898
|
+
(payload: Payload<F>, options?: Omit<SendMessageOptions, 'queue' | 'payload'>): Promise<void>
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
type MockHandle<F extends Func> = (payload: Parameters<F>[0]) => void
|
|
1902
|
+
type MockBuilder<F extends Func> = (handle?: MockHandle<F>) => void
|
|
1903
|
+
`;
|
|
1851
1904
|
var queuePlugin = definePlugin({
|
|
1852
1905
|
name: "queue",
|
|
1853
1906
|
schema: z8.object({
|
|
@@ -1948,21 +2001,33 @@ var queuePlugin = definePlugin({
|
|
|
1948
2001
|
}).array()
|
|
1949
2002
|
}),
|
|
1950
2003
|
onTypeGen({ config }) {
|
|
1951
|
-
const
|
|
1952
|
-
|
|
2004
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
2005
|
+
const resources = new TypeObject(1);
|
|
2006
|
+
const mocks = new TypeObject(1);
|
|
2007
|
+
const mockResponses = new TypeObject(1);
|
|
1953
2008
|
for (const stack of config.stacks) {
|
|
1954
|
-
const
|
|
2009
|
+
const resource = new TypeObject(2);
|
|
2010
|
+
const mock = new TypeObject(2);
|
|
2011
|
+
const mockResponse = new TypeObject(2);
|
|
1955
2012
|
for (const [name, fileOrProps] of Object.entries(stack.queues || {})) {
|
|
1956
2013
|
const varName = camelCase3(`${stack.name}-${name}`);
|
|
1957
2014
|
const queueName = formatName(`${config.name}-${stack.name}-${name}`);
|
|
1958
2015
|
const file = typeof fileOrProps === "string" ? fileOrProps : typeof fileOrProps.consumer === "string" ? fileOrProps.consumer : fileOrProps.consumer.file;
|
|
1959
2016
|
const relFile = relative3(directories.types, file);
|
|
1960
|
-
|
|
1961
|
-
|
|
2017
|
+
gen.addImport(varName, relFile);
|
|
2018
|
+
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
2019
|
+
resource.addType(name, `Send<'${queueName}', typeof ${varName}>`);
|
|
2020
|
+
mockResponse.addType(name, `Mock`);
|
|
1962
2021
|
}
|
|
1963
|
-
|
|
2022
|
+
mocks.addType(stack.name, mock);
|
|
2023
|
+
resources.addType(stack.name, resource);
|
|
2024
|
+
mockResponses.addType(stack.name, mockResponse);
|
|
1964
2025
|
}
|
|
1965
|
-
|
|
2026
|
+
gen.addCode(typeGenCode2);
|
|
2027
|
+
gen.addInterface("QueueResources", resources);
|
|
2028
|
+
gen.addInterface("QueueMock", mocks);
|
|
2029
|
+
gen.addInterface("QueueMockResponse", mockResponses);
|
|
2030
|
+
return gen.toString();
|
|
1966
2031
|
},
|
|
1967
2032
|
onStack(ctx) {
|
|
1968
2033
|
const { stack, config, stackConfig, bind } = ctx;
|
|
@@ -2236,16 +2301,18 @@ var tablePlugin = definePlugin({
|
|
|
2236
2301
|
}).array()
|
|
2237
2302
|
}),
|
|
2238
2303
|
onTypeGen({ config }) {
|
|
2239
|
-
const
|
|
2304
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
2305
|
+
const resources = new TypeObject(1);
|
|
2240
2306
|
for (const stack of config.stacks) {
|
|
2241
|
-
const list3 = new TypeObject();
|
|
2307
|
+
const list3 = new TypeObject(2);
|
|
2242
2308
|
for (const name of Object.keys(stack.tables || {})) {
|
|
2243
2309
|
const tableName = formatName(`${config.name}-${stack.name}-${name}`);
|
|
2244
2310
|
list3.addType(name, `'${tableName}'`);
|
|
2245
2311
|
}
|
|
2246
|
-
|
|
2312
|
+
resources.addType(stack.name, list3);
|
|
2247
2313
|
}
|
|
2248
|
-
|
|
2314
|
+
gen.addInterface("TableResources", resources);
|
|
2315
|
+
return gen.toString();
|
|
2249
2316
|
},
|
|
2250
2317
|
onStack(ctx) {
|
|
2251
2318
|
const { config, stack, stackConfig, bind } = ctx;
|
|
@@ -2368,16 +2435,18 @@ var storePlugin = definePlugin({
|
|
|
2368
2435
|
}).array()
|
|
2369
2436
|
}),
|
|
2370
2437
|
onTypeGen({ config }) {
|
|
2371
|
-
const
|
|
2438
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
2439
|
+
const resources = new TypeObject(1);
|
|
2372
2440
|
for (const stack of config.stacks) {
|
|
2373
|
-
const list3 = new TypeObject();
|
|
2441
|
+
const list3 = new TypeObject(2);
|
|
2374
2442
|
for (const name of stack.stores || []) {
|
|
2375
2443
|
const storeName = formatName(`${config.name}-${stack.name}-${name}`);
|
|
2376
2444
|
list3.addType(name, `{ readonly name: '${storeName}' }`);
|
|
2377
2445
|
}
|
|
2378
|
-
|
|
2446
|
+
resources.addType(stack.name, list3);
|
|
2379
2447
|
}
|
|
2380
|
-
|
|
2448
|
+
gen.addInterface("StoreResources", resources);
|
|
2449
|
+
return gen.toString();
|
|
2381
2450
|
},
|
|
2382
2451
|
onStack({ config, stack, stackConfig, bootstrap: bootstrap2, bind }) {
|
|
2383
2452
|
for (const id of stackConfig.stores || []) {
|
|
@@ -2480,12 +2549,17 @@ var isEmail = (value) => {
|
|
|
2480
2549
|
import { paramCase as paramCase4 } from "change-case";
|
|
2481
2550
|
var TopicNameSchema = z12.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => paramCase4(value));
|
|
2482
2551
|
var typeGenCode3 = `
|
|
2483
|
-
import { PublishOptions } from '@awsless/sns'
|
|
2552
|
+
import type { PublishOptions } from '@awsless/sns'
|
|
2553
|
+
import type { Mock } from 'vitest'
|
|
2484
2554
|
|
|
2485
2555
|
type Publish<Name extends string> = {
|
|
2486
2556
|
readonly name: Name
|
|
2487
2557
|
(payload: unknown, options?: Omit<PublishOptions, 'topic' | 'payload'>): Promise<void>
|
|
2488
|
-
}
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
type MockHandle = (payload: unknown) => void
|
|
2561
|
+
type MockBuilder = (handle?: MockHandle) => void
|
|
2562
|
+
`;
|
|
2489
2563
|
var topicPlugin = definePlugin({
|
|
2490
2564
|
name: "topic",
|
|
2491
2565
|
schema: z12.object({
|
|
@@ -2532,14 +2606,22 @@ var topicPlugin = definePlugin({
|
|
|
2532
2606
|
})
|
|
2533
2607
|
}),
|
|
2534
2608
|
onTypeGen({ config }) {
|
|
2535
|
-
const gen = new TypeGen("@awsless/awsless"
|
|
2536
|
-
|
|
2609
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
2610
|
+
const resources = new TypeObject(1);
|
|
2611
|
+
const mocks = new TypeObject(1);
|
|
2612
|
+
const mockResponses = new TypeObject(1);
|
|
2537
2613
|
for (const stack of config.stacks) {
|
|
2538
2614
|
for (const topic of stack.topics || []) {
|
|
2539
2615
|
const name = formatName(`${config.name}-${topic}`);
|
|
2540
|
-
|
|
2616
|
+
mockResponses.addType(topic, "Mock");
|
|
2617
|
+
resources.addType(topic, `Publish<'${name}'>`);
|
|
2618
|
+
mocks.addType(topic, `MockBuilder`);
|
|
2541
2619
|
}
|
|
2542
2620
|
}
|
|
2621
|
+
gen.addCode(typeGenCode3);
|
|
2622
|
+
gen.addInterface("TopicResources", resources);
|
|
2623
|
+
gen.addInterface("TopicMock", mocks);
|
|
2624
|
+
gen.addInterface("TopicMockResponse", mockResponses);
|
|
2543
2625
|
return gen.toString();
|
|
2544
2626
|
},
|
|
2545
2627
|
onApp({ config, bootstrap: bootstrap2 }) {
|
|
@@ -4421,15 +4503,17 @@ var searchPlugin = definePlugin({
|
|
|
4421
4503
|
}).array()
|
|
4422
4504
|
}),
|
|
4423
4505
|
onTypeGen({ config }) {
|
|
4424
|
-
const gen = new TypeGen("@awsless/awsless"
|
|
4506
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
4507
|
+
const resources = new TypeObject(1);
|
|
4425
4508
|
for (const stack of config.stacks) {
|
|
4426
|
-
const list3 = new TypeObject();
|
|
4509
|
+
const list3 = new TypeObject(2);
|
|
4427
4510
|
for (const id of stack.searchs || []) {
|
|
4428
4511
|
const name = formatName(`${config.name}-${stack.name}-${id}`);
|
|
4429
4512
|
list3.addType(name, `{ readonly name: '${name}' }`);
|
|
4430
4513
|
}
|
|
4431
|
-
|
|
4514
|
+
resources.addType(stack.name, list3);
|
|
4432
4515
|
}
|
|
4516
|
+
gen.addInterface("SearchResources", resources);
|
|
4433
4517
|
return gen.toString();
|
|
4434
4518
|
},
|
|
4435
4519
|
onStack({ config, stack, stackConfig, bind }) {
|
|
@@ -4573,15 +4657,17 @@ var cachePlugin = definePlugin({
|
|
|
4573
4657
|
}).array()
|
|
4574
4658
|
}),
|
|
4575
4659
|
onTypeGen({ config }) {
|
|
4576
|
-
const gen = new TypeGen("@awsless/awsless"
|
|
4577
|
-
|
|
4660
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
4661
|
+
const resources = new TypeObject(1);
|
|
4578
4662
|
for (const stack of config.stacks) {
|
|
4579
|
-
const
|
|
4663
|
+
const resource = new TypeObject(2);
|
|
4580
4664
|
for (const name of Object.keys(stack.caches || {})) {
|
|
4581
|
-
|
|
4665
|
+
resource.addType(name, `Command`);
|
|
4582
4666
|
}
|
|
4583
|
-
|
|
4667
|
+
resources.addType(stack.name, resource);
|
|
4584
4668
|
}
|
|
4669
|
+
gen.addCode(typeGenCode4);
|
|
4670
|
+
gen.addInterface("CacheResources", resources);
|
|
4585
4671
|
return gen.toString();
|
|
4586
4672
|
},
|
|
4587
4673
|
onStack({ config, stack, stackConfig, bootstrap: bootstrap2, bind }) {
|
|
@@ -4995,13 +5081,15 @@ var configPlugin = definePlugin({
|
|
|
4995
5081
|
}).array()
|
|
4996
5082
|
}),
|
|
4997
5083
|
onTypeGen({ config }) {
|
|
4998
|
-
const
|
|
5084
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
5085
|
+
const resources = new TypeObject(0, false);
|
|
4999
5086
|
for (const stack of config.stacks) {
|
|
5000
5087
|
for (const name of stack.configs || []) {
|
|
5001
|
-
|
|
5088
|
+
resources.addConst(name, "string");
|
|
5002
5089
|
}
|
|
5003
5090
|
}
|
|
5004
|
-
|
|
5091
|
+
gen.addInterface("ConfigResources", resources.toString());
|
|
5092
|
+
return gen.toString();
|
|
5005
5093
|
},
|
|
5006
5094
|
onStack({ bind, config, stackConfig }) {
|
|
5007
5095
|
const configs = stackConfig.configs;
|
|
@@ -6186,14 +6274,16 @@ var authPlugin = definePlugin({
|
|
|
6186
6274
|
}).array()
|
|
6187
6275
|
}),
|
|
6188
6276
|
onTypeGen({ config }) {
|
|
6189
|
-
const gen = new TypeGen("@awsless/awsless"
|
|
6277
|
+
const gen = new TypeGen("@awsless/awsless");
|
|
6278
|
+
const resources = new TypeObject(1);
|
|
6190
6279
|
for (const name of Object.keys(config.defaults.auth)) {
|
|
6191
6280
|
const authName = formatName(`${config.name}-${name}`);
|
|
6192
|
-
|
|
6281
|
+
resources.addType(
|
|
6193
6282
|
name,
|
|
6194
6283
|
`{ readonly name: '${authName}', readonly userPoolId: string, readonly clientId: string }`
|
|
6195
6284
|
);
|
|
6196
6285
|
}
|
|
6286
|
+
gen.addInterface("AuthResources", resources);
|
|
6197
6287
|
return gen.toString();
|
|
6198
6288
|
},
|
|
6199
6289
|
onStack({ bootstrap: bootstrap2, stackConfig, bind }) {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -11270,6 +11270,24 @@ type CronProps<H extends Handler<S>, S extends BaseSchema> = {
|
|
|
11270
11270
|
};
|
|
11271
11271
|
declare const cron: <H extends Handler<S>, S extends BaseSchema<any, any>>(props: CronProps<H, S>) => (event: _awsless_lambda.Input<S>, context?: _awsless_lambda.LambdaContext | undefined) => Promise<ReturnType<H>>;
|
|
11272
11272
|
|
|
11273
|
+
interface FunctionMock {
|
|
11274
|
+
}
|
|
11275
|
+
interface FunctionMockResponse {
|
|
11276
|
+
}
|
|
11277
|
+
declare const mockFunction: (cb: (mock: FunctionMock) => void) => FunctionMockResponse;
|
|
11278
|
+
|
|
11279
|
+
interface TopicMock {
|
|
11280
|
+
}
|
|
11281
|
+
interface TopicMockResponse {
|
|
11282
|
+
}
|
|
11283
|
+
declare const mockTopic: (cb: (mock: TopicMock) => void) => TopicMockResponse;
|
|
11284
|
+
|
|
11285
|
+
interface QueueMock {
|
|
11286
|
+
}
|
|
11287
|
+
interface QueueMockResponse {
|
|
11288
|
+
}
|
|
11289
|
+
declare const mockQueue: (cb: (mock: QueueMock) => void) => QueueMockResponse;
|
|
11290
|
+
|
|
11273
11291
|
type AppConfig = CombinedDefaultPluginsConfigInput;
|
|
11274
11292
|
type StackConfig = CombinedDefaultPluginsConfigInput['stacks'][number];
|
|
11275
11293
|
declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (StackConfig$1 & {
|
|
@@ -12071,4 +12089,4 @@ declare const defineStackConfig: (config: StackConfig) => StackConfig$1 | (Stack
|
|
|
12071
12089
|
});
|
|
12072
12090
|
declare const defineAppConfig: (config: AppConfig | AppConfigFactory<AppConfig>) => CombinedDefaultPluginsConfigInput | AppConfigFactory<CombinedDefaultPluginsConfigInput>;
|
|
12073
12091
|
|
|
12074
|
-
export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionProps, FunctionResources, Plugin, Queue, QueueProps, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicProps, TopicResources, cron, defineAppConfig, definePlugin, defineStackConfig, func, getAuthName, getAuthProps, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName, queue, topic };
|
|
12092
|
+
export { APP, AppConfig, Auth, AuthResources, Cache, CacheResources, Config, ConfigResources, CronProps, Fn, Function, FunctionMock, FunctionMockResponse, FunctionProps, FunctionResources, Plugin, Queue, QueueMock, QueueMockResponse, QueueProps, QueueResources, STACK, Search, SearchResources, StackConfig, Store, StoreResources, Table, TableResources, Topic, TopicMock, TopicMockResponse, TopicProps, TopicResources, cron, defineAppConfig, definePlugin, defineStackConfig, func, getAuthName, getAuthProps, getCacheProps, getConfigName, getFunctionName, getGlobalResourceName, getLocalResourceName, getQueueName, getSearchName, getStoreName, getTableName, getTopicName, mockFunction, mockQueue, mockTopic, queue, topic };
|
package/dist/index.js
CHANGED
|
@@ -275,6 +275,65 @@ var cron = (props) => {
|
|
|
275
275
|
});
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
+
// src/node/mock/function.ts
|
|
279
|
+
import { mockLambda } from "@awsless/lambda";
|
|
280
|
+
var mockFunction = (cb) => {
|
|
281
|
+
const list = {};
|
|
282
|
+
const mock = createProxy((stack) => {
|
|
283
|
+
return createProxy((name) => {
|
|
284
|
+
return (handleOrResponse) => {
|
|
285
|
+
const handle = typeof handleOrResponse === "function" ? handleOrResponse : () => handleOrResponse;
|
|
286
|
+
list[getFunctionName(stack, name)] = handle;
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
cb(mock);
|
|
291
|
+
const result = mockLambda(list);
|
|
292
|
+
return createProxy((stack) => {
|
|
293
|
+
return createProxy((name) => {
|
|
294
|
+
return result[getFunctionName(stack, name)];
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// src/node/mock/topic.ts
|
|
300
|
+
import { mockSQS } from "@awsless/sqs";
|
|
301
|
+
var mockTopic = (cb) => {
|
|
302
|
+
const list = {};
|
|
303
|
+
const mock = createProxy((name) => {
|
|
304
|
+
return (handle) => {
|
|
305
|
+
list[getTopicName(name)] = handle ?? (() => {
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
});
|
|
309
|
+
cb(mock);
|
|
310
|
+
const result = mockSQS(list);
|
|
311
|
+
return createProxy((name) => {
|
|
312
|
+
return result[getTopicName(name)];
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// src/node/mock/queue.ts
|
|
317
|
+
import { mockSQS as mockSQS2 } from "@awsless/sqs";
|
|
318
|
+
var mockQueue = (cb) => {
|
|
319
|
+
const list = {};
|
|
320
|
+
const mock = createProxy((stack) => {
|
|
321
|
+
return createProxy((name) => {
|
|
322
|
+
return (handle) => {
|
|
323
|
+
list[getQueueName(stack, name)] = handle ?? (() => {
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
cb(mock);
|
|
329
|
+
const result = mockSQS2(list);
|
|
330
|
+
return createProxy((stack) => {
|
|
331
|
+
return createProxy((name) => {
|
|
332
|
+
return result[getQueueName(stack, name)];
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
|
|
278
337
|
// src/index.ts
|
|
279
338
|
var defineStackConfig = (config) => config;
|
|
280
339
|
var defineAppConfig = (config) => config;
|
|
@@ -308,6 +367,9 @@ export {
|
|
|
308
367
|
getStoreName,
|
|
309
368
|
getTableName,
|
|
310
369
|
getTopicName,
|
|
370
|
+
mockFunction,
|
|
371
|
+
mockQueue,
|
|
372
|
+
mockTopic,
|
|
311
373
|
queue,
|
|
312
374
|
topic
|
|
313
375
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.94",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@awsless/validate": "^0.0.6",
|
|
28
27
|
"@awsless/redis": "^0.0.8",
|
|
29
|
-
"@awsless/lambda": "^0.0.13",
|
|
30
28
|
"@awsless/sns": "^0.0.7",
|
|
29
|
+
"@awsless/lambda": "^0.0.13",
|
|
30
|
+
"@awsless/ssm": "^0.0.7",
|
|
31
31
|
"@awsless/sqs": "^0.0.7",
|
|
32
|
-
"@awsless/
|
|
32
|
+
"@awsless/validate": "^0.0.6"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@aws-appsync/utils": "^1.5.0",
|