@awsless/awsless 0.0.366 → 0.0.367
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/app.json +1 -1
- package/dist/bin.js +521 -229
- package/dist/build-json-schema.js +122 -107
- package/dist/prebuild/rpc/HASH +1 -0
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/prebuild.js +153 -0
- package/dist/server.d.ts +10 -1
- package/dist/stack.json +1 -1
- package/package.json +15 -13
package/dist/bin.js
CHANGED
|
@@ -596,9 +596,9 @@ var require_Alias = __commonJS({
|
|
|
596
596
|
var anchors = require_anchors();
|
|
597
597
|
var visit = require_visit();
|
|
598
598
|
var identity = require_identity();
|
|
599
|
-
var
|
|
599
|
+
var Node24 = require_Node();
|
|
600
600
|
var toJS = require_toJS();
|
|
601
|
-
var Alias = class extends
|
|
601
|
+
var Alias = class extends Node24.NodeBase {
|
|
602
602
|
constructor(source) {
|
|
603
603
|
super(identity.ALIAS);
|
|
604
604
|
this.source = source;
|
|
@@ -696,10 +696,10 @@ var require_Scalar = __commonJS({
|
|
|
696
696
|
"../../node_modules/.pnpm/yaml@2.5.0/node_modules/yaml/dist/nodes/Scalar.js"(exports) {
|
|
697
697
|
"use strict";
|
|
698
698
|
var identity = require_identity();
|
|
699
|
-
var
|
|
699
|
+
var Node24 = require_Node();
|
|
700
700
|
var toJS = require_toJS();
|
|
701
701
|
var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object";
|
|
702
|
-
var Scalar = class extends
|
|
702
|
+
var Scalar = class extends Node24.NodeBase {
|
|
703
703
|
constructor(value) {
|
|
704
704
|
super(identity.SCALAR);
|
|
705
705
|
this.value = value;
|
|
@@ -803,7 +803,7 @@ var require_Collection = __commonJS({
|
|
|
803
803
|
"use strict";
|
|
804
804
|
var createNode = require_createNode();
|
|
805
805
|
var identity = require_identity();
|
|
806
|
-
var
|
|
806
|
+
var Node24 = require_Node();
|
|
807
807
|
function collectionFromPath(schema, path, value) {
|
|
808
808
|
let v = value;
|
|
809
809
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
@@ -827,7 +827,7 @@ var require_Collection = __commonJS({
|
|
|
827
827
|
});
|
|
828
828
|
}
|
|
829
829
|
var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
|
|
830
|
-
var Collection = class extends
|
|
830
|
+
var Collection = class extends Node24.NodeBase {
|
|
831
831
|
constructor(type, schema) {
|
|
832
832
|
super(type);
|
|
833
833
|
Object.defineProperty(this, "schema", {
|
|
@@ -7560,7 +7560,7 @@ var debug = (...parts) => {
|
|
|
7560
7560
|
};
|
|
7561
7561
|
|
|
7562
7562
|
// src/config/app.ts
|
|
7563
|
-
import { z as
|
|
7563
|
+
import { z as z21 } from "zod";
|
|
7564
7564
|
|
|
7565
7565
|
// src/feature/auth/schema.ts
|
|
7566
7566
|
import { z as z7 } from "zod";
|
|
@@ -7678,7 +7678,7 @@ var LogRetentionSchema = DurationSchema.refine(
|
|
|
7678
7678
|
(duration) => {
|
|
7679
7679
|
return validLogRetentionDays.includes(toDays(duration));
|
|
7680
7680
|
},
|
|
7681
|
-
`Invalid log retention. Valid days are: ${validLogRetentionDays.map((
|
|
7681
|
+
`Invalid log retention. Valid days are: ${validLogRetentionDays.map((days7) => `${days7}`).join(", ")}`
|
|
7682
7682
|
).describe("The log retention duration.");
|
|
7683
7683
|
var LogSchema = z5.union([
|
|
7684
7684
|
z5.boolean().transform((enabled) => ({ retention: enabled ? days(7) : days(0) })),
|
|
@@ -7703,32 +7703,33 @@ var BuildSchema = z5.object({
|
|
|
7703
7703
|
minify: MinifySchema.default(true),
|
|
7704
7704
|
external: z5.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`)
|
|
7705
7705
|
}).describe(`Options for the function bundler`);
|
|
7706
|
+
var FnSchema = z5.object({
|
|
7707
|
+
file: FileSchema,
|
|
7708
|
+
// node
|
|
7709
|
+
handler: HandlerSchema.optional(),
|
|
7710
|
+
build: BuildSchema.optional(),
|
|
7711
|
+
// container
|
|
7712
|
+
// ...
|
|
7713
|
+
runtime: RuntimeSchema.optional(),
|
|
7714
|
+
description: DescriptionSchema.optional(),
|
|
7715
|
+
warm: WarmSchema.optional(),
|
|
7716
|
+
vpc: VPCSchema.optional(),
|
|
7717
|
+
log: LogSchema.optional(),
|
|
7718
|
+
timeout: TimeoutSchema.optional(),
|
|
7719
|
+
memorySize: MemorySizeSchema.optional(),
|
|
7720
|
+
architecture: ArchitectureSchema.optional(),
|
|
7721
|
+
ephemeralStorageSize: EphemeralStorageSizeSchema.optional(),
|
|
7722
|
+
retryAttempts: RetryAttemptsSchema.optional(),
|
|
7723
|
+
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
7724
|
+
layers: LayersSchema.optional(),
|
|
7725
|
+
environment: EnvironmentSchema.optional(),
|
|
7726
|
+
permissions: PermissionsSchema.optional()
|
|
7727
|
+
});
|
|
7706
7728
|
var FunctionSchema = z5.union([
|
|
7707
7729
|
LocalFileSchema.transform((file) => ({
|
|
7708
7730
|
file
|
|
7709
7731
|
})),
|
|
7710
|
-
|
|
7711
|
-
file: FileSchema,
|
|
7712
|
-
// node
|
|
7713
|
-
handler: HandlerSchema.optional(),
|
|
7714
|
-
build: BuildSchema.optional(),
|
|
7715
|
-
// container
|
|
7716
|
-
// ...
|
|
7717
|
-
runtime: RuntimeSchema.optional(),
|
|
7718
|
-
description: DescriptionSchema.optional(),
|
|
7719
|
-
warm: WarmSchema.optional(),
|
|
7720
|
-
vpc: VPCSchema.optional(),
|
|
7721
|
-
log: LogSchema.optional(),
|
|
7722
|
-
timeout: TimeoutSchema.optional(),
|
|
7723
|
-
memorySize: MemorySizeSchema.optional(),
|
|
7724
|
-
architecture: ArchitectureSchema.optional(),
|
|
7725
|
-
ephemeralStorageSize: EphemeralStorageSizeSchema.optional(),
|
|
7726
|
-
retryAttempts: RetryAttemptsSchema.optional(),
|
|
7727
|
-
reserved: ReservedConcurrentExecutionsSchema.optional(),
|
|
7728
|
-
layers: LayersSchema.optional(),
|
|
7729
|
-
environment: EnvironmentSchema.optional(),
|
|
7730
|
-
permissions: PermissionsSchema.optional()
|
|
7731
|
-
})
|
|
7732
|
+
FnSchema
|
|
7732
7733
|
]);
|
|
7733
7734
|
var FunctionsSchema = z5.record(ResourceIdSchema, FunctionSchema).optional().describe("Define the functions in your stack.");
|
|
7734
7735
|
var FunctionDefaultSchema = z5.object({
|
|
@@ -8105,27 +8106,39 @@ var RestDefaultSchema = z16.record(
|
|
|
8105
8106
|
).optional().describe("Define your global REST API's.");
|
|
8106
8107
|
var RestSchema = z16.record(ResourceIdSchema, z16.record(RouteSchema2, FunctionSchema)).optional().describe("Define routes in your stack for your global REST API.");
|
|
8107
8108
|
|
|
8108
|
-
// src/feature/
|
|
8109
|
+
// src/feature/rpc/schema.ts
|
|
8109
8110
|
import { z as z17 } from "zod";
|
|
8110
|
-
var
|
|
8111
|
-
|
|
8111
|
+
var RpcDefaultSchema = z17.record(
|
|
8112
|
+
ResourceIdSchema,
|
|
8113
|
+
z17.object({
|
|
8114
|
+
domain: ResourceIdSchema.describe("The domain id to link your RPC API with.").optional(),
|
|
8115
|
+
subDomain: z17.string().optional(),
|
|
8116
|
+
auth: FunctionSchema.optional()
|
|
8117
|
+
})
|
|
8118
|
+
).describe(`Define the global RPC API's.`).optional();
|
|
8119
|
+
var RpcSchema = z17.record(ResourceIdSchema, z17.record(z17.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
|
|
8120
|
+
|
|
8121
|
+
// src/feature/store/schema.ts
|
|
8122
|
+
import { z as z18 } from "zod";
|
|
8123
|
+
var DeletionProtectionSchema = z18.boolean().describe("Specifies if you want to protect the store from being deleted by awsless.");
|
|
8124
|
+
var StoreDefaultSchema = z18.object({
|
|
8112
8125
|
deletionProtection: DeletionProtectionSchema.optional()
|
|
8113
8126
|
}).optional();
|
|
8114
|
-
var StoresSchema =
|
|
8115
|
-
|
|
8127
|
+
var StoresSchema = z18.union([
|
|
8128
|
+
z18.array(ResourceIdSchema).transform((list4) => {
|
|
8116
8129
|
const stores = {};
|
|
8117
8130
|
for (const key of list4) {
|
|
8118
8131
|
stores[key] = {};
|
|
8119
8132
|
}
|
|
8120
8133
|
return stores;
|
|
8121
8134
|
}),
|
|
8122
|
-
|
|
8135
|
+
z18.record(
|
|
8123
8136
|
ResourceIdSchema,
|
|
8124
|
-
|
|
8137
|
+
z18.object({
|
|
8125
8138
|
// cors: CorsSchema,
|
|
8126
8139
|
deletionProtection: DeletionProtectionSchema.optional(),
|
|
8127
|
-
versioning:
|
|
8128
|
-
events:
|
|
8140
|
+
versioning: z18.boolean().default(false).describe("Enable versioning of your store."),
|
|
8141
|
+
events: z18.object({
|
|
8129
8142
|
// create
|
|
8130
8143
|
"created:*": FunctionSchema.optional().describe(
|
|
8131
8144
|
"Subscribe to notifications regardless of the API that was used to create an object."
|
|
@@ -8158,41 +8171,41 @@ var StoresSchema = z17.union([
|
|
|
8158
8171
|
]).optional().describe("Define the stores in your stack.");
|
|
8159
8172
|
|
|
8160
8173
|
// src/feature/table/schema.ts
|
|
8161
|
-
import { z as
|
|
8162
|
-
var KeySchema =
|
|
8163
|
-
var DeletionProtectionSchema2 =
|
|
8164
|
-
var TableDefaultSchema =
|
|
8174
|
+
import { z as z19 } from "zod";
|
|
8175
|
+
var KeySchema = z19.string().min(1).max(255);
|
|
8176
|
+
var DeletionProtectionSchema2 = z19.boolean().describe("Specifies if you want to protect the table from being deleted by awsless.");
|
|
8177
|
+
var TableDefaultSchema = z19.object({
|
|
8165
8178
|
deletionProtection: DeletionProtectionSchema2.optional()
|
|
8166
8179
|
}).optional();
|
|
8167
|
-
var TablesSchema =
|
|
8180
|
+
var TablesSchema = z19.record(
|
|
8168
8181
|
ResourceIdSchema,
|
|
8169
|
-
|
|
8182
|
+
z19.object({
|
|
8170
8183
|
hash: KeySchema.describe(
|
|
8171
8184
|
"Specifies the name of the partition / hash key that makes up the primary key for the table."
|
|
8172
8185
|
),
|
|
8173
8186
|
sort: KeySchema.optional().describe(
|
|
8174
8187
|
"Specifies the name of the range / sort key that makes up the primary key for the table."
|
|
8175
8188
|
),
|
|
8176
|
-
fields:
|
|
8189
|
+
fields: z19.record(z19.string(), z19.enum(["string", "number", "binary"])).optional().describe(
|
|
8177
8190
|
'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
|
|
8178
8191
|
),
|
|
8179
|
-
class:
|
|
8180
|
-
pointInTimeRecovery:
|
|
8192
|
+
class: z19.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
|
|
8193
|
+
pointInTimeRecovery: z19.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
|
|
8181
8194
|
timeToLiveAttribute: KeySchema.optional().describe(
|
|
8182
8195
|
"The name of the TTL attribute used to store the expiration time for items in the table. To update this property, you must first disable TTL and then enable TTL with the new attribute name."
|
|
8183
8196
|
),
|
|
8184
8197
|
deletionProtection: DeletionProtectionSchema2.optional(),
|
|
8185
|
-
stream:
|
|
8186
|
-
type:
|
|
8198
|
+
stream: z19.object({
|
|
8199
|
+
type: z19.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
|
|
8187
8200
|
"When an item in the table is modified, stream.type determines what information is written to the stream for this table. Valid values are:\n- keys-only - Only the key attributes of the modified item are written to the stream.\n- new-image - The entire item, as it appears after it was modified, is written to the stream.\n- old-image - The entire item, as it appeared before it was modified, is written to the stream.\n- new-and-old-images - Both the new and the old item images of the item are written to the stream."
|
|
8188
8201
|
),
|
|
8189
8202
|
consumer: FunctionSchema.describe("The consuming lambda function for the stream")
|
|
8190
8203
|
}).optional().describe(
|
|
8191
8204
|
"The settings for the DynamoDB table stream, which capture changes to items stored in the table."
|
|
8192
8205
|
),
|
|
8193
|
-
indexes:
|
|
8194
|
-
|
|
8195
|
-
|
|
8206
|
+
indexes: z19.record(
|
|
8207
|
+
z19.string(),
|
|
8208
|
+
z19.object({
|
|
8196
8209
|
/** Specifies the name of the partition / hash key that makes up the primary key for the global secondary index. */
|
|
8197
8210
|
hash: KeySchema,
|
|
8198
8211
|
/** Specifies the name of the range / sort key that makes up the primary key for the global secondary index. */
|
|
@@ -8202,14 +8215,14 @@ var TablesSchema = z18.record(
|
|
|
8202
8215
|
* - keys-only - Only the index and primary keys are projected into the index.
|
|
8203
8216
|
* @default 'all'
|
|
8204
8217
|
*/
|
|
8205
|
-
projection:
|
|
8218
|
+
projection: z19.enum(["all", "keys-only"]).default("all")
|
|
8206
8219
|
})
|
|
8207
8220
|
).optional().describe("Specifies the global secondary indexes to be created on the table.")
|
|
8208
8221
|
})
|
|
8209
8222
|
).optional().describe("Define the tables in your stack.");
|
|
8210
8223
|
|
|
8211
8224
|
// src/config/schema/region.ts
|
|
8212
|
-
import { z as
|
|
8225
|
+
import { z as z20 } from "zod";
|
|
8213
8226
|
var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
|
|
8214
8227
|
var AF = ["af-south-1"];
|
|
8215
8228
|
var AP = [
|
|
@@ -8238,20 +8251,20 @@ var EU = [
|
|
|
8238
8251
|
var ME = ["me-south-1", "me-central-1"];
|
|
8239
8252
|
var SA = ["sa-east-1"];
|
|
8240
8253
|
var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
|
|
8241
|
-
var RegionSchema =
|
|
8254
|
+
var RegionSchema = z20.enum(regions);
|
|
8242
8255
|
|
|
8243
8256
|
// src/config/app.ts
|
|
8244
|
-
var AppSchema =
|
|
8245
|
-
$schema:
|
|
8257
|
+
var AppSchema = z21.object({
|
|
8258
|
+
$schema: z21.string().optional(),
|
|
8246
8259
|
name: ResourceIdSchema.describe("App name."),
|
|
8247
8260
|
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
8248
|
-
profile:
|
|
8261
|
+
profile: z21.string().describe("The AWS profile to deploy to."),
|
|
8249
8262
|
// stage: z
|
|
8250
8263
|
// .string()
|
|
8251
8264
|
// .regex(/^[a-z]+$/)
|
|
8252
8265
|
// .default('prod')
|
|
8253
8266
|
// .describe('The deployment stage.'),
|
|
8254
|
-
defaults:
|
|
8267
|
+
defaults: z21.object({
|
|
8255
8268
|
auth: AuthDefaultSchema,
|
|
8256
8269
|
domains: DomainsDefaultSchema,
|
|
8257
8270
|
function: FunctionDefaultSchema,
|
|
@@ -8260,6 +8273,7 @@ var AppSchema = z20.object({
|
|
|
8260
8273
|
graphql: GraphQLDefaultSchema,
|
|
8261
8274
|
http: HttpDefaultSchema,
|
|
8262
8275
|
rest: RestDefaultSchema,
|
|
8276
|
+
rpc: RpcDefaultSchema,
|
|
8263
8277
|
pubsub: PubSubDefaultSchema,
|
|
8264
8278
|
table: TableDefaultSchema,
|
|
8265
8279
|
store: StoreDefaultSchema
|
|
@@ -8268,11 +8282,11 @@ var AppSchema = z20.object({
|
|
|
8268
8282
|
});
|
|
8269
8283
|
|
|
8270
8284
|
// src/config/stack.ts
|
|
8271
|
-
import { z as
|
|
8285
|
+
import { z as z33 } from "zod";
|
|
8272
8286
|
|
|
8273
8287
|
// src/feature/cache/schema.ts
|
|
8274
|
-
import { z as
|
|
8275
|
-
var TypeSchema2 =
|
|
8288
|
+
import { z as z22 } from "zod";
|
|
8289
|
+
var TypeSchema2 = z22.enum([
|
|
8276
8290
|
"t4g.small",
|
|
8277
8291
|
"t4g.medium",
|
|
8278
8292
|
"r6g.large",
|
|
@@ -8287,29 +8301,29 @@ var TypeSchema2 = z21.enum([
|
|
|
8287
8301
|
"r6gd.4xlarge",
|
|
8288
8302
|
"r6gd.8xlarge"
|
|
8289
8303
|
]);
|
|
8290
|
-
var PortSchema =
|
|
8291
|
-
var ShardsSchema =
|
|
8292
|
-
var ReplicasPerShardSchema =
|
|
8293
|
-
var EngineSchema =
|
|
8294
|
-
var CachesSchema =
|
|
8304
|
+
var PortSchema = z22.number().int().min(1).max(5e4);
|
|
8305
|
+
var ShardsSchema = z22.number().int().min(0).max(100);
|
|
8306
|
+
var ReplicasPerShardSchema = z22.number().int().min(0).max(5);
|
|
8307
|
+
var EngineSchema = z22.enum(["7.0", "6.2"]);
|
|
8308
|
+
var CachesSchema = z22.record(
|
|
8295
8309
|
ResourceIdSchema,
|
|
8296
|
-
|
|
8310
|
+
z22.object({
|
|
8297
8311
|
type: TypeSchema2.default("t4g.small"),
|
|
8298
8312
|
port: PortSchema.default(6379),
|
|
8299
8313
|
shards: ShardsSchema.default(1),
|
|
8300
8314
|
replicasPerShard: ReplicasPerShardSchema.default(1),
|
|
8301
8315
|
engine: EngineSchema.default("7.0"),
|
|
8302
|
-
dataTiering:
|
|
8316
|
+
dataTiering: z22.boolean().default(false)
|
|
8303
8317
|
})
|
|
8304
8318
|
).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
|
|
8305
8319
|
|
|
8306
8320
|
// src/feature/command/schema.ts
|
|
8307
|
-
import { z as
|
|
8308
|
-
var CommandSchema2 =
|
|
8309
|
-
|
|
8321
|
+
import { z as z23 } from "zod";
|
|
8322
|
+
var CommandSchema2 = z23.union([
|
|
8323
|
+
z23.object({
|
|
8310
8324
|
file: LocalFileSchema,
|
|
8311
|
-
handler:
|
|
8312
|
-
description:
|
|
8325
|
+
handler: z23.string().default("default").describe("The name of the handler that needs to run"),
|
|
8326
|
+
description: z23.string().optional().describe("A description of the command")
|
|
8313
8327
|
// options: z.record(ResourceIdSchema, OptionSchema).optional(),
|
|
8314
8328
|
// arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
|
|
8315
8329
|
}),
|
|
@@ -8319,22 +8333,22 @@ var CommandSchema2 = z22.union([
|
|
|
8319
8333
|
description: void 0
|
|
8320
8334
|
}))
|
|
8321
8335
|
]);
|
|
8322
|
-
var CommandsSchema =
|
|
8336
|
+
var CommandsSchema = z23.record(ResourceIdSchema, CommandSchema2).optional().describe("Define the custom commands for your stack.");
|
|
8323
8337
|
|
|
8324
8338
|
// src/feature/config/schema.ts
|
|
8325
|
-
import { z as
|
|
8326
|
-
var ConfigNameSchema =
|
|
8327
|
-
var ConfigsSchema =
|
|
8339
|
+
import { z as z24 } from "zod";
|
|
8340
|
+
var ConfigNameSchema = z24.string().regex(/[a-z0-9\-]/g, "Invalid config name");
|
|
8341
|
+
var ConfigsSchema = z24.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
|
|
8328
8342
|
|
|
8329
8343
|
// src/feature/cron/schema/index.ts
|
|
8330
|
-
import { z as
|
|
8344
|
+
import { z as z26 } from "zod";
|
|
8331
8345
|
|
|
8332
8346
|
// src/feature/cron/schema/schedule.ts
|
|
8333
|
-
import { z as
|
|
8347
|
+
import { z as z25 } from "zod";
|
|
8334
8348
|
import { awsCronExpressionValidator } from "aws-cron-expression-validator";
|
|
8335
|
-
var RateExpressionSchema =
|
|
8349
|
+
var RateExpressionSchema = z25.custom(
|
|
8336
8350
|
(value) => {
|
|
8337
|
-
return
|
|
8351
|
+
return z25.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
|
|
8338
8352
|
const [str] = rate.split(" ");
|
|
8339
8353
|
const number = parseInt(str);
|
|
8340
8354
|
return number > 0;
|
|
@@ -8350,9 +8364,9 @@ var RateExpressionSchema = z24.custom(
|
|
|
8350
8364
|
}
|
|
8351
8365
|
return `rate(${rate})`;
|
|
8352
8366
|
});
|
|
8353
|
-
var CronExpressionSchema =
|
|
8367
|
+
var CronExpressionSchema = z25.custom(
|
|
8354
8368
|
(value) => {
|
|
8355
|
-
return
|
|
8369
|
+
return z25.string().safeParse(value).success;
|
|
8356
8370
|
},
|
|
8357
8371
|
{ message: "Invalid cron expression" }
|
|
8358
8372
|
).superRefine((value, ctx) => {
|
|
@@ -8361,12 +8375,12 @@ var CronExpressionSchema = z24.custom(
|
|
|
8361
8375
|
} catch (error) {
|
|
8362
8376
|
if (error instanceof Error) {
|
|
8363
8377
|
ctx.addIssue({
|
|
8364
|
-
code:
|
|
8378
|
+
code: z25.ZodIssueCode.custom,
|
|
8365
8379
|
message: `Invalid cron expression: ${error.message}`
|
|
8366
8380
|
});
|
|
8367
8381
|
} else {
|
|
8368
8382
|
ctx.addIssue({
|
|
8369
|
-
code:
|
|
8383
|
+
code: z25.ZodIssueCode.custom,
|
|
8370
8384
|
message: "Invalid cron expression"
|
|
8371
8385
|
});
|
|
8372
8386
|
}
|
|
@@ -8377,15 +8391,15 @@ var CronExpressionSchema = z24.custom(
|
|
|
8377
8391
|
var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
|
|
8378
8392
|
|
|
8379
8393
|
// src/feature/cron/schema/index.ts
|
|
8380
|
-
var CronsSchema =
|
|
8394
|
+
var CronsSchema = z26.record(
|
|
8381
8395
|
ResourceIdSchema,
|
|
8382
|
-
|
|
8383
|
-
enabled:
|
|
8396
|
+
z26.object({
|
|
8397
|
+
enabled: z26.boolean().default(true).describe("If the cron is enabled."),
|
|
8384
8398
|
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
8385
8399
|
schedule: ScheduleExpressionSchema.describe(
|
|
8386
8400
|
'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
|
|
8387
8401
|
),
|
|
8388
|
-
payload:
|
|
8402
|
+
payload: z26.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
8389
8403
|
})
|
|
8390
8404
|
).optional().describe(`Define the cron jobs in your stack.`);
|
|
8391
8405
|
|
|
@@ -8396,9 +8410,9 @@ var OnFailureSchema = FunctionSchema.optional().describe(
|
|
|
8396
8410
|
|
|
8397
8411
|
// src/feature/search/schema.ts
|
|
8398
8412
|
import { gibibytes as gibibytes2 } from "@awsless/size";
|
|
8399
|
-
import { z as
|
|
8400
|
-
var VersionSchema =
|
|
8401
|
-
var TypeSchema3 =
|
|
8413
|
+
import { z as z27 } from "zod";
|
|
8414
|
+
var VersionSchema = z27.enum(["2.13", "2.11", "2.9", "2.7", "2.5", "2.3", "1.3"]);
|
|
8415
|
+
var TypeSchema3 = z27.enum([
|
|
8402
8416
|
"t3.small",
|
|
8403
8417
|
"t3.medium",
|
|
8404
8418
|
"m3.medium",
|
|
@@ -8473,41 +8487,41 @@ var TypeSchema3 = z26.enum([
|
|
|
8473
8487
|
"r6gd.16xlarge"
|
|
8474
8488
|
]);
|
|
8475
8489
|
var StorageSizeSchema = SizeSchema.refine(sizeMin(gibibytes2(10)), "Minimum storage size is 10 GB").refine(sizeMax(gibibytes2(100)), "Maximum storage size is 100 GB").describe("The size of the function's /tmp directory. You can specify a size value from 512 MB to 10 GiB.");
|
|
8476
|
-
var SearchsSchema =
|
|
8490
|
+
var SearchsSchema = z27.record(
|
|
8477
8491
|
ResourceIdSchema,
|
|
8478
|
-
|
|
8492
|
+
z27.object({
|
|
8479
8493
|
type: TypeSchema3.default("t3.small"),
|
|
8480
|
-
count:
|
|
8494
|
+
count: z27.number().int().min(1).default(1),
|
|
8481
8495
|
version: VersionSchema.default("2.13"),
|
|
8482
8496
|
storage: StorageSizeSchema.default("10 GB"),
|
|
8483
|
-
vpc:
|
|
8497
|
+
vpc: z27.boolean().default(false)
|
|
8484
8498
|
})
|
|
8485
8499
|
).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
|
|
8486
8500
|
|
|
8487
8501
|
// src/feature/site/schema.ts
|
|
8488
|
-
import { z as
|
|
8489
|
-
var ErrorResponsePathSchema =
|
|
8502
|
+
import { z as z28 } from "zod";
|
|
8503
|
+
var ErrorResponsePathSchema = z28.string().describe(
|
|
8490
8504
|
"The path to the custom error page that you want to return to the viewer when your origin returns the HTTP status code specified.\n - We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable."
|
|
8491
8505
|
);
|
|
8492
|
-
var StatusCodeSchema =
|
|
8506
|
+
var StatusCodeSchema = z28.number().int().positive().optional().describe(
|
|
8493
8507
|
"The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:\n- Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute 200, the response typically won't be intercepted.\n- If you don't care about distinguishing among different client errors or server errors, you can specify 400 or 500 as the ResponseCode for all 4xx or 5xx errors.\n- You might want to return a 200 status code (OK) and static website so your customers don't know that your website is down."
|
|
8494
8508
|
);
|
|
8495
8509
|
var MinTTLSchema = DurationSchema.describe(
|
|
8496
8510
|
"The minimum amount of time, that you want to cache the error response. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available."
|
|
8497
8511
|
);
|
|
8498
|
-
var ErrorResponseSchema =
|
|
8512
|
+
var ErrorResponseSchema = z28.union([
|
|
8499
8513
|
ErrorResponsePathSchema,
|
|
8500
|
-
|
|
8514
|
+
z28.object({
|
|
8501
8515
|
path: ErrorResponsePathSchema,
|
|
8502
8516
|
statusCode: StatusCodeSchema.optional(),
|
|
8503
8517
|
minTTL: MinTTLSchema.optional()
|
|
8504
8518
|
})
|
|
8505
8519
|
]).optional();
|
|
8506
|
-
var SitesSchema =
|
|
8520
|
+
var SitesSchema = z28.record(
|
|
8507
8521
|
ResourceIdSchema,
|
|
8508
|
-
|
|
8522
|
+
z28.object({
|
|
8509
8523
|
domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
|
|
8510
|
-
subDomain:
|
|
8524
|
+
subDomain: z28.string().optional(),
|
|
8511
8525
|
// bind: z
|
|
8512
8526
|
// .object({
|
|
8513
8527
|
// auth: z.array(ResourceIdSchema),
|
|
@@ -8530,7 +8544,7 @@ var SitesSchema = z27.record(
|
|
|
8530
8544
|
// build: z.string().optional(),
|
|
8531
8545
|
// }),
|
|
8532
8546
|
// ]),
|
|
8533
|
-
errors:
|
|
8547
|
+
errors: z28.object({
|
|
8534
8548
|
400: ErrorResponseSchema.describe("Customize a `400 Bad Request` response."),
|
|
8535
8549
|
403: ErrorResponseSchema.describe("Customize a `403 Forbidden` response."),
|
|
8536
8550
|
404: ErrorResponseSchema.describe("Customize a `404 Not Found` response."),
|
|
@@ -8543,16 +8557,16 @@ var SitesSchema = z27.record(
|
|
|
8543
8557
|
503: ErrorResponseSchema.describe("Customize a `503 Service Unavailable` response."),
|
|
8544
8558
|
504: ErrorResponseSchema.describe("Customize a `504 Gateway Timeout` response.")
|
|
8545
8559
|
}).optional().describe("Customize the error responses for specific HTTP status codes."),
|
|
8546
|
-
cors:
|
|
8547
|
-
override:
|
|
8560
|
+
cors: z28.object({
|
|
8561
|
+
override: z28.boolean().default(false),
|
|
8548
8562
|
maxAge: DurationSchema.default("365 days"),
|
|
8549
|
-
exposeHeaders:
|
|
8550
|
-
credentials:
|
|
8551
|
-
headers:
|
|
8552
|
-
origins:
|
|
8553
|
-
methods:
|
|
8563
|
+
exposeHeaders: z28.string().array().optional(),
|
|
8564
|
+
credentials: z28.boolean().default(false),
|
|
8565
|
+
headers: z28.string().array().default(["*"]),
|
|
8566
|
+
origins: z28.string().array().default(["*"]),
|
|
8567
|
+
methods: z28.enum(["GET", "DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "ALL"]).array().default(["ALL"])
|
|
8554
8568
|
}).optional().describe("Define the cors headers."),
|
|
8555
|
-
security:
|
|
8569
|
+
security: z28.object({
|
|
8556
8570
|
// contentSecurityPolicy: z.object({
|
|
8557
8571
|
// override: z.boolean().default(false),
|
|
8558
8572
|
// policy: z.string(),
|
|
@@ -8594,10 +8608,10 @@ var SitesSchema = z27.record(
|
|
|
8594
8608
|
// reportUri?: string
|
|
8595
8609
|
// }
|
|
8596
8610
|
}).optional().describe("Define the security policy."),
|
|
8597
|
-
cache:
|
|
8598
|
-
cookies:
|
|
8599
|
-
headers:
|
|
8600
|
-
queries:
|
|
8611
|
+
cache: z28.object({
|
|
8612
|
+
cookies: z28.string().array().optional().describe("Specifies the cookies that CloudFront includes in the cache key."),
|
|
8613
|
+
headers: z28.string().array().optional().describe("Specifies the headers that CloudFront includes in the cache key."),
|
|
8614
|
+
queries: z28.string().array().optional().describe("Specifies the query values that CloudFront includes in the cache key.")
|
|
8601
8615
|
}).optional().describe(
|
|
8602
8616
|
"Specifies the cookies, headers, and query values that CloudFront includes in the cache key."
|
|
8603
8617
|
)
|
|
@@ -8605,22 +8619,22 @@ var SitesSchema = z27.record(
|
|
|
8605
8619
|
).optional().describe("Define the sites in your stack.");
|
|
8606
8620
|
|
|
8607
8621
|
// src/feature/stream/schema.ts
|
|
8608
|
-
import { z as
|
|
8609
|
-
var LatencyModeSchema =
|
|
8622
|
+
import { z as z29 } from "zod";
|
|
8623
|
+
var LatencyModeSchema = z29.enum(["low", "normal"]).describe(
|
|
8610
8624
|
`Channel latency mode. Valid values:
|
|
8611
8625
|
- normal: Use "normal" to broadcast and deliver live video up to Full HD.
|
|
8612
8626
|
- low: Use "low" for near real-time interactions with viewers.`
|
|
8613
8627
|
);
|
|
8614
|
-
var TypeSchema4 =
|
|
8628
|
+
var TypeSchema4 = z29.enum(["standard", "basic", "advanced-sd", "advanced-hd"]).describe(`The channel type, which determines the allowable resolution and bitrate.
|
|
8615
8629
|
If you exceed the allowable resolution or bitrate, the stream probably will disconnect immediately. Valid values:
|
|
8616
8630
|
- standard: Video is transcoded: multiple qualities are generated from the original input to automatically give viewers the best experience for their devices and network conditions. Transcoding allows higher playback quality across a range of download speeds. Resolution can be up to 1080p and bitrate can be up to 8.5 Mbps. Audio is transcoded only for renditions 360p and below; above that, audio is passed through.
|
|
8617
8631
|
- basic: Video is transmuxed: Amazon IVS delivers the original input to viewers. The viewer's video-quality choice is limited to the original input. Resolution can be up to 1080p and bitrate can be up to 1.5 Mbps for 480p and up to 3.5 Mbps for resolutions between 480p and 1080p.
|
|
8618
8632
|
- advanced-sd: Video is transcoded; multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions. Input resolution can be up to 1080p and bitrate can be up to 8.5 Mbps; output is capped at SD quality (480p). You can select an optional transcode preset (see below). Audio for all renditions is transcoded, and an audio-only rendition is available.
|
|
8619
8633
|
- advanced-hd: Video is transcoded; multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions. Input resolution can be up to 1080p and bitrate can be up to 8.5 Mbps; output is capped at HD quality (720p). You can select an optional transcode preset (see below). Audio for all renditions is transcoded, and an audio-only rendition is available.
|
|
8620
8634
|
`);
|
|
8621
|
-
var StreamsSchema =
|
|
8635
|
+
var StreamsSchema = z29.record(
|
|
8622
8636
|
ResourceIdSchema,
|
|
8623
|
-
|
|
8637
|
+
z29.object({
|
|
8624
8638
|
type: TypeSchema4.default("standard"),
|
|
8625
8639
|
// preset: PresetSchema.optional(),
|
|
8626
8640
|
latencyMode: LatencyModeSchema.default("low")
|
|
@@ -8628,42 +8642,42 @@ var StreamsSchema = z28.record(
|
|
|
8628
8642
|
).optional().describe("Define the streams in your stack.");
|
|
8629
8643
|
|
|
8630
8644
|
// src/feature/task/schema.ts
|
|
8631
|
-
import { z as
|
|
8632
|
-
var RetryAttemptsSchema2 =
|
|
8645
|
+
import { z as z30 } from "zod";
|
|
8646
|
+
var RetryAttemptsSchema2 = z30.number().int().min(0).max(2).describe(
|
|
8633
8647
|
"The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
|
|
8634
8648
|
);
|
|
8635
|
-
var TaskSchema =
|
|
8649
|
+
var TaskSchema = z30.union([
|
|
8636
8650
|
LocalFileSchema.transform((file) => ({
|
|
8637
8651
|
consumer: { file },
|
|
8638
8652
|
retryAttempts: void 0
|
|
8639
8653
|
})),
|
|
8640
|
-
|
|
8654
|
+
z30.object({
|
|
8641
8655
|
consumer: FunctionSchema,
|
|
8642
8656
|
retryAttempts: RetryAttemptsSchema2.optional()
|
|
8643
8657
|
})
|
|
8644
8658
|
]);
|
|
8645
|
-
var TasksSchema =
|
|
8659
|
+
var TasksSchema = z30.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
|
|
8646
8660
|
|
|
8647
8661
|
// src/feature/test/schema.ts
|
|
8648
|
-
import { z as
|
|
8649
|
-
var TestsSchema =
|
|
8662
|
+
import { z as z31 } from "zod";
|
|
8663
|
+
var TestsSchema = z31.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
|
|
8650
8664
|
|
|
8651
8665
|
// src/feature/topic/schema.ts
|
|
8652
8666
|
import { paramCase as paramCase2 } from "change-case";
|
|
8653
|
-
import { z as
|
|
8654
|
-
var TopicNameSchema =
|
|
8655
|
-
var TopicsSchema =
|
|
8667
|
+
import { z as z32 } from "zod";
|
|
8668
|
+
var TopicNameSchema = z32.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => paramCase2(value)).describe("Define event topic name.");
|
|
8669
|
+
var TopicsSchema = z32.array(TopicNameSchema).refine((topics) => {
|
|
8656
8670
|
return topics.length === new Set(topics).size;
|
|
8657
8671
|
}, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
|
|
8658
|
-
var SubscribersSchema =
|
|
8672
|
+
var SubscribersSchema = z32.record(TopicNameSchema, z32.union([EmailSchema, FunctionSchema])).optional().describe("Define the event topics to subscribe too in your stack.");
|
|
8659
8673
|
|
|
8660
8674
|
// src/config/stack.ts
|
|
8661
8675
|
var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
|
|
8662
8676
|
var NameSchema = ResourceIdSchema.refine((name) => !["base"].includes(name), {
|
|
8663
8677
|
message: `Stack name can't be a reserved name.`
|
|
8664
8678
|
}).describe("Stack name.");
|
|
8665
|
-
var StackSchema =
|
|
8666
|
-
$schema:
|
|
8679
|
+
var StackSchema = z33.object({
|
|
8680
|
+
$schema: z33.string().optional(),
|
|
8667
8681
|
name: NameSchema,
|
|
8668
8682
|
depends: DependsSchema,
|
|
8669
8683
|
commands: CommandsSchema,
|
|
@@ -8672,6 +8686,7 @@ var StackSchema = z32.object({
|
|
|
8672
8686
|
graphql: GraphQLSchema,
|
|
8673
8687
|
http: HttpSchema,
|
|
8674
8688
|
rest: RestSchema,
|
|
8689
|
+
rpc: RpcSchema,
|
|
8675
8690
|
configs: ConfigsSchema,
|
|
8676
8691
|
crons: CronsSchema,
|
|
8677
8692
|
caches: CachesSchema,
|
|
@@ -8729,13 +8744,13 @@ var readConfigWithStage = async (file, stage) => {
|
|
|
8729
8744
|
};
|
|
8730
8745
|
|
|
8731
8746
|
// src/config/load/validate.ts
|
|
8732
|
-
import { z as
|
|
8747
|
+
import { z as z34 } from "zod";
|
|
8733
8748
|
var validateConfig = async (schema, file, data) => {
|
|
8734
8749
|
try {
|
|
8735
8750
|
const result = await schema.parseAsync(data);
|
|
8736
8751
|
return result;
|
|
8737
8752
|
} catch (error) {
|
|
8738
|
-
if (error instanceof
|
|
8753
|
+
if (error instanceof z34.ZodError) {
|
|
8739
8754
|
throw new ConfigError(file, error, data);
|
|
8740
8755
|
}
|
|
8741
8756
|
throw error;
|
|
@@ -10672,7 +10687,7 @@ import nodeResolve from "@rollup/plugin-node-resolve";
|
|
|
10672
10687
|
import { createHash as createHash2 } from "crypto";
|
|
10673
10688
|
import { dirname as dirname6 } from "path";
|
|
10674
10689
|
import { rollup } from "rollup";
|
|
10675
|
-
import { minify as swcMinify
|
|
10690
|
+
import { swc, minify as swcMinify } from "rollup-plugin-swc3";
|
|
10676
10691
|
var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file, external }) => {
|
|
10677
10692
|
const bundle = await rollup({
|
|
10678
10693
|
input: file,
|
|
@@ -10802,7 +10817,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
10802
10817
|
let code;
|
|
10803
10818
|
if (props.runtime === "container") {
|
|
10804
10819
|
ctx.registerBuild("function", name, async (build3) => {
|
|
10805
|
-
const cwd = dirname7(
|
|
10820
|
+
const cwd = dirname7(local2.file);
|
|
10806
10821
|
const version = await hashElement(cwd, {
|
|
10807
10822
|
files: {
|
|
10808
10823
|
exclude: ["stack.json"]
|
|
@@ -10831,10 +10846,10 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
10831
10846
|
};
|
|
10832
10847
|
} else {
|
|
10833
10848
|
ctx.registerBuild("function", name, async (build3, { workspace }) => {
|
|
10834
|
-
const version = await generateFileHash(workspace,
|
|
10849
|
+
const version = await generateFileHash(workspace, local2.file);
|
|
10835
10850
|
return build3(version, async (write) => {
|
|
10836
10851
|
const bundle = await bundleTypeScript({
|
|
10837
|
-
file:
|
|
10852
|
+
file: local2.file,
|
|
10838
10853
|
external: props.build.external,
|
|
10839
10854
|
minify: props.build.minify
|
|
10840
10855
|
});
|
|
@@ -10972,6 +10987,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
|
10972
10987
|
lambda.dependsOn(vpcPolicy);
|
|
10973
10988
|
}
|
|
10974
10989
|
return {
|
|
10990
|
+
name,
|
|
10975
10991
|
lambda,
|
|
10976
10992
|
policy,
|
|
10977
10993
|
code
|
|
@@ -12607,9 +12623,284 @@ var restFeature = defineFeature({
|
|
|
12607
12623
|
}
|
|
12608
12624
|
});
|
|
12609
12625
|
|
|
12626
|
+
// src/feature/rpc/index.ts
|
|
12627
|
+
import { camelCase as camelCase6, constantCase as constantCase9, paramCase as paramCase6 } from "change-case";
|
|
12628
|
+
import { aws as aws16, Node as Node15, Output as Output3 } from "@awsless/formation";
|
|
12629
|
+
import { mebibytes as mebibytes2 } from "@awsless/size";
|
|
12630
|
+
import { dirname as dirname10, join as join8, relative as relative5 } from "path";
|
|
12631
|
+
import { fileURLToPath } from "node:url";
|
|
12632
|
+
|
|
12633
|
+
// src/feature/function/prebuild.ts
|
|
12634
|
+
import { Asset as Asset4, aws as aws15 } from "@awsless/formation";
|
|
12635
|
+
var createPrebuildLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
12636
|
+
let name;
|
|
12637
|
+
if ("stack" in ctx) {
|
|
12638
|
+
name = formatLocalResourceName({
|
|
12639
|
+
appName: ctx.app.name,
|
|
12640
|
+
stackName: ctx.stack.name,
|
|
12641
|
+
resourceType: ns,
|
|
12642
|
+
resourceName: id
|
|
12643
|
+
});
|
|
12644
|
+
} else {
|
|
12645
|
+
name = formatGlobalResourceName({
|
|
12646
|
+
appName: ctx.appConfig.name,
|
|
12647
|
+
resourceType: ns,
|
|
12648
|
+
resourceName: id
|
|
12649
|
+
});
|
|
12650
|
+
}
|
|
12651
|
+
const props = {
|
|
12652
|
+
architecture: "arm64",
|
|
12653
|
+
runtime: "nodejs20.x",
|
|
12654
|
+
...local2
|
|
12655
|
+
};
|
|
12656
|
+
const code = new aws15.s3.BucketObject(group, "code", {
|
|
12657
|
+
bucket: ctx.shared.get("function-bucket-name"),
|
|
12658
|
+
key: `/lambda/${name}.zip`,
|
|
12659
|
+
body: Asset4.fromFile(props.bundleFile)
|
|
12660
|
+
});
|
|
12661
|
+
const role = new aws15.iam.Role(group, "role", {
|
|
12662
|
+
name,
|
|
12663
|
+
assumedBy: "lambda.amazonaws.com"
|
|
12664
|
+
});
|
|
12665
|
+
const policy = new aws15.iam.RolePolicy(group, "policy", {
|
|
12666
|
+
role: role.name,
|
|
12667
|
+
name: "lambda-policy",
|
|
12668
|
+
version: "2012-10-17"
|
|
12669
|
+
});
|
|
12670
|
+
const lambda = new aws15.lambda.Function(group, `function`, {
|
|
12671
|
+
...props,
|
|
12672
|
+
name,
|
|
12673
|
+
role: role.arn,
|
|
12674
|
+
code,
|
|
12675
|
+
runtime: props.runtime === "container" ? void 0 : props.runtime,
|
|
12676
|
+
// Remove conflicting props.
|
|
12677
|
+
vpc: void 0,
|
|
12678
|
+
log: props.log
|
|
12679
|
+
});
|
|
12680
|
+
new aws15.lambda.SourceCodeUpdate(group, "update", {
|
|
12681
|
+
functionName: lambda.name,
|
|
12682
|
+
version: Asset4.fromFile(props.bundleHash),
|
|
12683
|
+
architecture: props.architecture,
|
|
12684
|
+
code
|
|
12685
|
+
});
|
|
12686
|
+
ctx.onEnv((name2, value) => {
|
|
12687
|
+
lambda.addEnvironment(name2, value);
|
|
12688
|
+
});
|
|
12689
|
+
ctx.registerPolicy(policy);
|
|
12690
|
+
lambda.addEnvironment("APP", ctx.appConfig.name);
|
|
12691
|
+
lambda.addEnvironment("APP_ID", ctx.appId);
|
|
12692
|
+
if ("stackConfig" in ctx) {
|
|
12693
|
+
lambda.addEnvironment("STACK", ctx.stackConfig.name);
|
|
12694
|
+
}
|
|
12695
|
+
if (props.log?.retention && props.log?.retention?.value > 0n) {
|
|
12696
|
+
const logGroup = new aws15.cloudWatch.LogGroup(group, "log", {
|
|
12697
|
+
name: lambda.name.apply((name2) => `/aws/lambda/${name2}`),
|
|
12698
|
+
retention: props.log.retention
|
|
12699
|
+
});
|
|
12700
|
+
policy.addStatement(
|
|
12701
|
+
{
|
|
12702
|
+
actions: ["logs:CreateLogStream"],
|
|
12703
|
+
resources: [logGroup.arn]
|
|
12704
|
+
},
|
|
12705
|
+
{
|
|
12706
|
+
actions: ["logs:PutLogEvents"],
|
|
12707
|
+
resources: [logGroup.arn.apply((arn) => `${arn}:*`)]
|
|
12708
|
+
}
|
|
12709
|
+
);
|
|
12710
|
+
}
|
|
12711
|
+
if ("permissions" in local2 && local2.permissions) {
|
|
12712
|
+
policy.addStatement(...local2.permissions);
|
|
12713
|
+
}
|
|
12714
|
+
if (props.warm) {
|
|
12715
|
+
const rule = new aws15.events.Rule(group, "warm", {
|
|
12716
|
+
name: `${name}--warm`,
|
|
12717
|
+
schedule: "rate(5 minutes)",
|
|
12718
|
+
enabled: true,
|
|
12719
|
+
targets: [
|
|
12720
|
+
{
|
|
12721
|
+
id: "warmer",
|
|
12722
|
+
arn: lambda.arn,
|
|
12723
|
+
input: {
|
|
12724
|
+
warmer: true,
|
|
12725
|
+
concurrency: props.warm
|
|
12726
|
+
}
|
|
12727
|
+
}
|
|
12728
|
+
]
|
|
12729
|
+
});
|
|
12730
|
+
new aws15.lambda.Permission(group, `warm`, {
|
|
12731
|
+
action: "lambda:InvokeFunction",
|
|
12732
|
+
principal: "events.amazonaws.com",
|
|
12733
|
+
functionArn: lambda.arn,
|
|
12734
|
+
sourceArn: rule.arn
|
|
12735
|
+
});
|
|
12736
|
+
}
|
|
12737
|
+
if (props.vpc) {
|
|
12738
|
+
lambda.setVpc({
|
|
12739
|
+
securityGroupIds: [ctx.shared.get(`vpc-security-group-id`)],
|
|
12740
|
+
subnetIds: [
|
|
12741
|
+
ctx.shared.get(`vpc-public-subnet-id-1`),
|
|
12742
|
+
ctx.shared.get(`vpc-public-subnet-id-2`)
|
|
12743
|
+
]
|
|
12744
|
+
});
|
|
12745
|
+
const vpcPolicy = new aws15.iam.RolePolicy(group, "vpc-policy", {
|
|
12746
|
+
role: role.name,
|
|
12747
|
+
name: "lambda-vpc-policy",
|
|
12748
|
+
version: "2012-10-17",
|
|
12749
|
+
statements: [
|
|
12750
|
+
{
|
|
12751
|
+
actions: [
|
|
12752
|
+
"ec2:CreateNetworkInterface",
|
|
12753
|
+
"ec2:DescribeNetworkInterfaces",
|
|
12754
|
+
"ec2:DeleteNetworkInterface",
|
|
12755
|
+
"ec2:AssignPrivateIpAddresses",
|
|
12756
|
+
"ec2:UnassignPrivateIpAddresses"
|
|
12757
|
+
],
|
|
12758
|
+
resources: ["*"]
|
|
12759
|
+
}
|
|
12760
|
+
]
|
|
12761
|
+
});
|
|
12762
|
+
lambda.dependsOn(vpcPolicy);
|
|
12763
|
+
}
|
|
12764
|
+
return {
|
|
12765
|
+
name,
|
|
12766
|
+
lambda,
|
|
12767
|
+
policy,
|
|
12768
|
+
code
|
|
12769
|
+
};
|
|
12770
|
+
};
|
|
12771
|
+
|
|
12772
|
+
// src/feature/rpc/index.ts
|
|
12773
|
+
import { days as days5, seconds as seconds3 } from "@awsless/duration";
|
|
12774
|
+
var __dirname = dirname10(fileURLToPath(import.meta.url));
|
|
12775
|
+
var rpcFeature = defineFeature({
|
|
12776
|
+
name: "rpc",
|
|
12777
|
+
async onTypeGen(ctx) {
|
|
12778
|
+
const types2 = new TypeFile("@awsless/awsless/client");
|
|
12779
|
+
const schemas = new TypeObject(1);
|
|
12780
|
+
for (const id of Object.keys(ctx.appConfig.defaults.rpc ?? {})) {
|
|
12781
|
+
const schema = new TypeObject(2);
|
|
12782
|
+
for (const stack of ctx.stackConfigs) {
|
|
12783
|
+
for (const [name, props] of Object.entries(stack.rpc?.[id] ?? {})) {
|
|
12784
|
+
const relFile = relative5(directories.types, props.file);
|
|
12785
|
+
const varName = camelCase6(`${stack.name}-${name}`);
|
|
12786
|
+
types2.addImport(varName, relFile);
|
|
12787
|
+
schema.addType(name, `Infer<typeof ${varName}>`);
|
|
12788
|
+
}
|
|
12789
|
+
}
|
|
12790
|
+
schemas.addType(id, schema);
|
|
12791
|
+
}
|
|
12792
|
+
types2.addInterface("RpcSchema", schemas);
|
|
12793
|
+
await ctx.write("rpc.d.ts", types2, true);
|
|
12794
|
+
},
|
|
12795
|
+
onApp(ctx) {
|
|
12796
|
+
for (const [id, props] of Object.entries(ctx.appConfig.defaults.rpc ?? {})) {
|
|
12797
|
+
const group = new Node15(ctx.base, "rpc", id);
|
|
12798
|
+
const name = formatGlobalResourceName({
|
|
12799
|
+
appName: ctx.app.name,
|
|
12800
|
+
resourceType: "rpc",
|
|
12801
|
+
resourceName: id
|
|
12802
|
+
});
|
|
12803
|
+
const { lambda } = createPrebuildLambdaFunction(group, ctx, "rpc", id, {
|
|
12804
|
+
bundleFile: join8(__dirname, "/prebuild/rpc/bundle.zip"),
|
|
12805
|
+
bundleHash: join8(__dirname, "/prebuild/rpc/HASH"),
|
|
12806
|
+
memorySize: mebibytes2(256)
|
|
12807
|
+
});
|
|
12808
|
+
const schema = {};
|
|
12809
|
+
lambda.addEnvironment(
|
|
12810
|
+
"SCHEMA",
|
|
12811
|
+
new Output3([], (resolve2) => {
|
|
12812
|
+
ctx.onReady(() => {
|
|
12813
|
+
resolve2(JSON.stringify(schema));
|
|
12814
|
+
});
|
|
12815
|
+
})
|
|
12816
|
+
);
|
|
12817
|
+
ctx.shared.set(`rpc-${id}-schema`, schema);
|
|
12818
|
+
if (props.auth) {
|
|
12819
|
+
const authGroup = new Node15(group, "auth", "authorizer");
|
|
12820
|
+
const auth2 = createLambdaFunction(authGroup, ctx, "rpc", `${id}-auth`, props.auth);
|
|
12821
|
+
lambda.addEnvironment("AUTH", auth2.lambda.name);
|
|
12822
|
+
}
|
|
12823
|
+
const permission = new aws16.lambda.Permission(group, "permission", {
|
|
12824
|
+
principal: "*",
|
|
12825
|
+
action: "lambda:InvokeFunctionUrl",
|
|
12826
|
+
functionArn: lambda.arn,
|
|
12827
|
+
urlAuthType: "none"
|
|
12828
|
+
});
|
|
12829
|
+
const url = new aws16.lambda.Url(group, "url", {
|
|
12830
|
+
targetArn: lambda.arn,
|
|
12831
|
+
authType: "none"
|
|
12832
|
+
}).dependsOn(permission);
|
|
12833
|
+
const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
|
|
12834
|
+
const certificateArn = props.domain ? ctx.shared.get(`global-certificate-${props.domain}-arn`) : void 0;
|
|
12835
|
+
const cache = new aws16.cloudFront.CachePolicy(group, "cache", {
|
|
12836
|
+
name,
|
|
12837
|
+
minTtl: seconds3(1),
|
|
12838
|
+
maxTtl: days5(365),
|
|
12839
|
+
defaultTtl: days5(1)
|
|
12840
|
+
});
|
|
12841
|
+
const originRequest = new aws16.cloudFront.OriginRequestPolicy(group, "request", {
|
|
12842
|
+
name,
|
|
12843
|
+
header: {
|
|
12844
|
+
behavior: "all-except",
|
|
12845
|
+
values: ["host", "authentication"]
|
|
12846
|
+
}
|
|
12847
|
+
});
|
|
12848
|
+
const cdn = new aws16.cloudFront.Distribution(group, "cdn", {
|
|
12849
|
+
name,
|
|
12850
|
+
compress: true,
|
|
12851
|
+
certificateArn,
|
|
12852
|
+
viewerProtocol: "https-only",
|
|
12853
|
+
aliases: domainName ? [domainName] : void 0,
|
|
12854
|
+
origins: [
|
|
12855
|
+
{
|
|
12856
|
+
id: "default",
|
|
12857
|
+
domainName: url.url.apply((url2) => url2.split("/")[2]),
|
|
12858
|
+
protocol: "https-only"
|
|
12859
|
+
}
|
|
12860
|
+
],
|
|
12861
|
+
targetOriginId: "default",
|
|
12862
|
+
cachePolicyId: cache.id,
|
|
12863
|
+
originRequestPolicyId: originRequest.id
|
|
12864
|
+
// responseHeadersPolicyId: responseHeaders.id,
|
|
12865
|
+
});
|
|
12866
|
+
if (props.domain) {
|
|
12867
|
+
const fullDomainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
12868
|
+
new aws16.route53.RecordSet(group, "record", {
|
|
12869
|
+
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
12870
|
+
type: "A",
|
|
12871
|
+
name: fullDomainName,
|
|
12872
|
+
alias: cdn.aliasTarget
|
|
12873
|
+
});
|
|
12874
|
+
ctx.bind(`RPC_${constantCase9(id)}_ENDPOINT`, fullDomainName);
|
|
12875
|
+
} else {
|
|
12876
|
+
ctx.bind(`RPC_${constantCase9(id)}_ENDPOINT`, cdn.aliasTarget.dnsName);
|
|
12877
|
+
}
|
|
12878
|
+
}
|
|
12879
|
+
},
|
|
12880
|
+
onStack(ctx) {
|
|
12881
|
+
for (const [id, queries] of Object.entries(ctx.stackConfig.rpc ?? {})) {
|
|
12882
|
+
const defaultProps = ctx.appConfig.defaults.rpc?.[id];
|
|
12883
|
+
if (!defaultProps) {
|
|
12884
|
+
throw new FileError(ctx.stackConfig.file, `RPC definition is not defined on app level for "${id}"`);
|
|
12885
|
+
}
|
|
12886
|
+
const schema = ctx.shared.get(`rpc-${id}-schema`);
|
|
12887
|
+
const group = new Node15(ctx.stack, "rpc", id);
|
|
12888
|
+
for (const [name, props] of Object.entries(queries ?? {})) {
|
|
12889
|
+
const queryGroup = new Node15(group, "query", name);
|
|
12890
|
+
const entryId = paramCase6(`${id}-${shortId(name)}`);
|
|
12891
|
+
const lambda = createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
|
|
12892
|
+
...props,
|
|
12893
|
+
description: `${id} ${name}`
|
|
12894
|
+
});
|
|
12895
|
+
schema[name] = lambda.name;
|
|
12896
|
+
}
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
});
|
|
12900
|
+
|
|
12610
12901
|
// src/feature/search/index.ts
|
|
12611
|
-
import { aws as
|
|
12612
|
-
import { constantCase as
|
|
12902
|
+
import { aws as aws17, Node as Node16 } from "@awsless/formation";
|
|
12903
|
+
import { constantCase as constantCase10 } from "change-case";
|
|
12613
12904
|
var typeGenCode4 = `
|
|
12614
12905
|
import { AnyStruct, Table } from '@awsless/open-search'
|
|
12615
12906
|
|
|
@@ -12636,9 +12927,9 @@ var searchFeature = defineFeature({
|
|
|
12636
12927
|
},
|
|
12637
12928
|
onStack(ctx) {
|
|
12638
12929
|
for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
|
|
12639
|
-
const group = new
|
|
12930
|
+
const group = new Node16(ctx.stack, "search", id);
|
|
12640
12931
|
const name = `${id}-${shortId([ctx.app.name, ctx.stack.name, this.name, id].join("--"))}`;
|
|
12641
|
-
const openSearch = new
|
|
12932
|
+
const openSearch = new aws17.openSearch.Domain(group, "domain", {
|
|
12642
12933
|
name,
|
|
12643
12934
|
version: props.version,
|
|
12644
12935
|
storageSize: props.storage,
|
|
@@ -12665,7 +12956,7 @@ var searchFeature = defineFeature({
|
|
|
12665
12956
|
]
|
|
12666
12957
|
});
|
|
12667
12958
|
}
|
|
12668
|
-
ctx.addEnv(`SEARCH_${
|
|
12959
|
+
ctx.addEnv(`SEARCH_${constantCase10(ctx.stack.name)}_${constantCase10(id)}_DOMAIN`, openSearch.domainEndpoint);
|
|
12669
12960
|
ctx.onPolicy((policy) => {
|
|
12670
12961
|
policy.addStatement({
|
|
12671
12962
|
actions: ["es:ESHttp*"],
|
|
@@ -12677,10 +12968,10 @@ var searchFeature = defineFeature({
|
|
|
12677
12968
|
});
|
|
12678
12969
|
|
|
12679
12970
|
// src/feature/site/index.ts
|
|
12680
|
-
import { days as
|
|
12681
|
-
import { Asset as
|
|
12971
|
+
import { days as days6, seconds as seconds4 } from "@awsless/duration";
|
|
12972
|
+
import { Asset as Asset5, aws as aws18, Node as Node17 } from "@awsless/formation";
|
|
12682
12973
|
import { glob as glob2 } from "glob";
|
|
12683
|
-
import { join as
|
|
12974
|
+
import { join as join9 } from "path";
|
|
12684
12975
|
|
|
12685
12976
|
// src/feature/site/util.ts
|
|
12686
12977
|
import { lookup, contentType } from "mime-types";
|
|
@@ -12703,12 +12994,12 @@ var getContentType = (file) => {
|
|
|
12703
12994
|
};
|
|
12704
12995
|
|
|
12705
12996
|
// src/feature/site/index.ts
|
|
12706
|
-
import { constantCase as
|
|
12997
|
+
import { constantCase as constantCase11 } from "change-case";
|
|
12707
12998
|
var siteFeature = defineFeature({
|
|
12708
12999
|
name: "site",
|
|
12709
13000
|
onStack(ctx) {
|
|
12710
13001
|
for (const [id, props] of Object.entries(ctx.stackConfig.sites ?? {})) {
|
|
12711
|
-
const group = new
|
|
13002
|
+
const group = new Node17(ctx.stack, "site", id);
|
|
12712
13003
|
const name = formatLocalResourceName({
|
|
12713
13004
|
appName: ctx.app.name,
|
|
12714
13005
|
stackName: ctx.stack.name,
|
|
@@ -12727,7 +13018,7 @@ var siteFeature = defineFeature({
|
|
|
12727
13018
|
ctx.onBind((name2, value) => {
|
|
12728
13019
|
lambda.addEnvironment(name2, value);
|
|
12729
13020
|
});
|
|
12730
|
-
new
|
|
13021
|
+
new aws18.lambda.Permission(group, "permission", {
|
|
12731
13022
|
principal: "*",
|
|
12732
13023
|
// principal: 'cloudfront.amazonaws.com',
|
|
12733
13024
|
action: "lambda:InvokeFunctionUrl",
|
|
@@ -12736,7 +13027,7 @@ var siteFeature = defineFeature({
|
|
|
12736
13027
|
// urlAuthType: 'aws-iam',
|
|
12737
13028
|
// sourceArn: distribution.arn,
|
|
12738
13029
|
});
|
|
12739
|
-
const url = new
|
|
13030
|
+
const url = new aws18.lambda.Url(group, "url", {
|
|
12740
13031
|
targetArn: lambda.arn,
|
|
12741
13032
|
authType: "none"
|
|
12742
13033
|
// authType: 'aws-iam',
|
|
@@ -12748,7 +13039,7 @@ var siteFeature = defineFeature({
|
|
|
12748
13039
|
});
|
|
12749
13040
|
}
|
|
12750
13041
|
if (props.static) {
|
|
12751
|
-
bucket = new
|
|
13042
|
+
bucket = new aws18.s3.Bucket(group, "bucket", {
|
|
12752
13043
|
name: formatLocalResourceName({
|
|
12753
13044
|
appName: ctx.app.name,
|
|
12754
13045
|
stackName: ctx.stack.name,
|
|
@@ -12774,7 +13065,7 @@ var siteFeature = defineFeature({
|
|
|
12774
13065
|
policy.addStatement(bucket.permissions);
|
|
12775
13066
|
});
|
|
12776
13067
|
bucket.deletionPolicy = "after-deployment";
|
|
12777
|
-
const accessControl = new
|
|
13068
|
+
const accessControl = new aws18.cloudFront.OriginAccessControl(group, `access`, {
|
|
12778
13069
|
name,
|
|
12779
13070
|
type: "s3",
|
|
12780
13071
|
behavior: "always",
|
|
@@ -12786,10 +13077,10 @@ var siteFeature = defineFeature({
|
|
|
12786
13077
|
nodir: true
|
|
12787
13078
|
});
|
|
12788
13079
|
for (const file of files) {
|
|
12789
|
-
const object = new
|
|
13080
|
+
const object = new aws18.s3.BucketObject(group, file, {
|
|
12790
13081
|
bucket: bucket.name,
|
|
12791
13082
|
key: file,
|
|
12792
|
-
body:
|
|
13083
|
+
body: Asset5.fromFile(join9(props.static, file)),
|
|
12793
13084
|
cacheControl: getCacheControl(file),
|
|
12794
13085
|
contentType: getContentType(file)
|
|
12795
13086
|
});
|
|
@@ -12809,21 +13100,21 @@ var siteFeature = defineFeature({
|
|
|
12809
13100
|
statusCodes: [403, 404]
|
|
12810
13101
|
});
|
|
12811
13102
|
}
|
|
12812
|
-
const cache = new
|
|
13103
|
+
const cache = new aws18.cloudFront.CachePolicy(group, "cache", {
|
|
12813
13104
|
name,
|
|
12814
|
-
minTtl:
|
|
12815
|
-
maxTtl:
|
|
12816
|
-
defaultTtl:
|
|
13105
|
+
minTtl: seconds4(1),
|
|
13106
|
+
maxTtl: days6(365),
|
|
13107
|
+
defaultTtl: days6(1),
|
|
12817
13108
|
...props.cache
|
|
12818
13109
|
});
|
|
12819
|
-
const originRequest = new
|
|
13110
|
+
const originRequest = new aws18.cloudFront.OriginRequestPolicy(group, "request", {
|
|
12820
13111
|
name,
|
|
12821
13112
|
header: {
|
|
12822
13113
|
behavior: "all-except",
|
|
12823
13114
|
values: ["host", "authorization"]
|
|
12824
13115
|
}
|
|
12825
13116
|
});
|
|
12826
|
-
const responseHeaders = new
|
|
13117
|
+
const responseHeaders = new aws18.cloudFront.ResponseHeadersPolicy(group, "response", {
|
|
12827
13118
|
name,
|
|
12828
13119
|
cors: props.cors,
|
|
12829
13120
|
remove: ["server"]
|
|
@@ -12833,7 +13124,7 @@ var siteFeature = defineFeature({
|
|
|
12833
13124
|
});
|
|
12834
13125
|
const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
|
|
12835
13126
|
const certificateArn = props.domain ? ctx.shared.get(`global-certificate-${props.domain}-arn`) : void 0;
|
|
12836
|
-
const distribution = new
|
|
13127
|
+
const distribution = new aws18.cloudFront.Distribution(group, "distribution", {
|
|
12837
13128
|
name,
|
|
12838
13129
|
compress: true,
|
|
12839
13130
|
certificateArn,
|
|
@@ -12861,13 +13152,13 @@ var siteFeature = defineFeature({
|
|
|
12861
13152
|
};
|
|
12862
13153
|
})
|
|
12863
13154
|
});
|
|
12864
|
-
new
|
|
13155
|
+
new aws18.cloudFront.InvalidateCache(group, "invalidate", {
|
|
12865
13156
|
distributionId: distribution.id,
|
|
12866
13157
|
paths: ["/*"],
|
|
12867
13158
|
versions
|
|
12868
13159
|
});
|
|
12869
13160
|
if (props.static) {
|
|
12870
|
-
new
|
|
13161
|
+
new aws18.s3.BucketPolicy(group, `policy`, {
|
|
12871
13162
|
bucketName: bucket.name,
|
|
12872
13163
|
statements: [
|
|
12873
13164
|
{
|
|
@@ -12894,7 +13185,7 @@ var siteFeature = defineFeature({
|
|
|
12894
13185
|
});
|
|
12895
13186
|
}
|
|
12896
13187
|
if (domainName) {
|
|
12897
|
-
new
|
|
13188
|
+
new aws18.route53.RecordSet(group, `record`, {
|
|
12898
13189
|
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
12899
13190
|
type: "A",
|
|
12900
13191
|
name: domainName,
|
|
@@ -12902,7 +13193,7 @@ var siteFeature = defineFeature({
|
|
|
12902
13193
|
});
|
|
12903
13194
|
}
|
|
12904
13195
|
ctx.bind(
|
|
12905
|
-
`SITE_${
|
|
13196
|
+
`SITE_${constantCase11(ctx.stack.name)}_${constantCase11(id)}_ENDPOINT`,
|
|
12906
13197
|
domainName ? domainName : distribution.domainName
|
|
12907
13198
|
);
|
|
12908
13199
|
}
|
|
@@ -12910,8 +13201,8 @@ var siteFeature = defineFeature({
|
|
|
12910
13201
|
});
|
|
12911
13202
|
|
|
12912
13203
|
// src/feature/store/index.ts
|
|
12913
|
-
import { aws as
|
|
12914
|
-
import { paramCase as
|
|
13204
|
+
import { aws as aws19, Node as Node18 } from "@awsless/formation";
|
|
13205
|
+
import { paramCase as paramCase7 } from "change-case";
|
|
12915
13206
|
var typeGenCode5 = `
|
|
12916
13207
|
import { Body, PutObjectProps, BodyStream } from '@awsless/s3'
|
|
12917
13208
|
|
|
@@ -12947,7 +13238,7 @@ var storeFeature = defineFeature({
|
|
|
12947
13238
|
},
|
|
12948
13239
|
onStack(ctx) {
|
|
12949
13240
|
for (const [id, props] of Object.entries(ctx.stackConfig.stores ?? {})) {
|
|
12950
|
-
const group = new
|
|
13241
|
+
const group = new Node18(ctx.stack, "store", id);
|
|
12951
13242
|
const name = formatLocalResourceName({
|
|
12952
13243
|
appName: ctx.app.name,
|
|
12953
13244
|
stackName: ctx.stack.name,
|
|
@@ -12967,13 +13258,13 @@ var storeFeature = defineFeature({
|
|
|
12967
13258
|
"removed:marker": "s3:ObjectRemoved:DeleteMarkerCreated"
|
|
12968
13259
|
};
|
|
12969
13260
|
for (const [event, funcProps] of Object.entries(props.events ?? {})) {
|
|
12970
|
-
const eventGroup = new
|
|
12971
|
-
const eventId =
|
|
13261
|
+
const eventGroup = new Node18(group, "event", event);
|
|
13262
|
+
const eventId = paramCase7(`${id}-${shortId(event)}`);
|
|
12972
13263
|
const { lambda } = createAsyncLambdaFunction(eventGroup, ctx, `store`, eventId, {
|
|
12973
13264
|
...funcProps,
|
|
12974
13265
|
description: `${id} event "${event}"`
|
|
12975
13266
|
});
|
|
12976
|
-
new
|
|
13267
|
+
new aws19.lambda.Permission(eventGroup, "permission", {
|
|
12977
13268
|
action: "lambda:InvokeFunction",
|
|
12978
13269
|
principal: "s3.amazonaws.com",
|
|
12979
13270
|
functionArn: lambda.arn,
|
|
@@ -12984,7 +13275,7 @@ var storeFeature = defineFeature({
|
|
|
12984
13275
|
function: lambda.arn
|
|
12985
13276
|
});
|
|
12986
13277
|
}
|
|
12987
|
-
const bucket = new
|
|
13278
|
+
const bucket = new aws19.s3.Bucket(group, "store", {
|
|
12988
13279
|
name,
|
|
12989
13280
|
versioning: props.versioning,
|
|
12990
13281
|
forceDelete: true,
|
|
@@ -13012,27 +13303,27 @@ var storeFeature = defineFeature({
|
|
|
13012
13303
|
});
|
|
13013
13304
|
|
|
13014
13305
|
// src/feature/stream/index.ts
|
|
13015
|
-
import { aws as
|
|
13016
|
-
import { constantCase as
|
|
13306
|
+
import { aws as aws20, Node as Node19 } from "@awsless/formation";
|
|
13307
|
+
import { constantCase as constantCase12 } from "change-case";
|
|
13017
13308
|
var streamFeature = defineFeature({
|
|
13018
13309
|
name: "stream",
|
|
13019
13310
|
onStack(ctx) {
|
|
13020
13311
|
for (const [id, props] of Object.entries(ctx.stackConfig.streams ?? {})) {
|
|
13021
|
-
const group = new
|
|
13312
|
+
const group = new Node19(ctx.stack, "stream", id);
|
|
13022
13313
|
const name = formatLocalResourceName({
|
|
13023
13314
|
appName: ctx.app.name,
|
|
13024
13315
|
stackName: ctx.stack.name,
|
|
13025
13316
|
resourceType: "stream",
|
|
13026
13317
|
resourceName: id
|
|
13027
13318
|
});
|
|
13028
|
-
const channel = new
|
|
13319
|
+
const channel = new aws20.ivs.Channel(group, "channel", {
|
|
13029
13320
|
name,
|
|
13030
13321
|
...props
|
|
13031
13322
|
});
|
|
13032
|
-
const streamKey = new
|
|
13323
|
+
const streamKey = new aws20.ivs.StreamKey(group, "key", {
|
|
13033
13324
|
channel: channel.arn
|
|
13034
13325
|
});
|
|
13035
|
-
const prefix = `STREAM_${
|
|
13326
|
+
const prefix = `STREAM_${constantCase12(ctx.stack.name)}_${constantCase12(id)}`;
|
|
13036
13327
|
ctx.bind(`${prefix}_ENDPOINT`, channel.playbackUrl);
|
|
13037
13328
|
ctx.addEnv(`${prefix}_INGEST_ENDPOINT`, channel.ingestEndpoint);
|
|
13038
13329
|
ctx.addEnv(`${prefix}_STREAM_KEY`, streamKey.value);
|
|
@@ -13041,7 +13332,7 @@ var streamFeature = defineFeature({
|
|
|
13041
13332
|
});
|
|
13042
13333
|
|
|
13043
13334
|
// src/feature/table/index.ts
|
|
13044
|
-
import { aws as
|
|
13335
|
+
import { aws as aws21, Node as Node20 } from "@awsless/formation";
|
|
13045
13336
|
var tableFeature = defineFeature({
|
|
13046
13337
|
name: "table",
|
|
13047
13338
|
async onTypeGen(ctx) {
|
|
@@ -13065,7 +13356,7 @@ var tableFeature = defineFeature({
|
|
|
13065
13356
|
},
|
|
13066
13357
|
onStack(ctx) {
|
|
13067
13358
|
for (const [id, props] of Object.entries(ctx.stackConfig.tables ?? {})) {
|
|
13068
|
-
const group = new
|
|
13359
|
+
const group = new Node20(ctx.stack, "table", id);
|
|
13069
13360
|
const name = formatLocalResourceName({
|
|
13070
13361
|
appName: ctx.app.name,
|
|
13071
13362
|
stackName: ctx.stack.name,
|
|
@@ -13073,7 +13364,7 @@ var tableFeature = defineFeature({
|
|
|
13073
13364
|
resourceName: id
|
|
13074
13365
|
});
|
|
13075
13366
|
const deletionProtection = props.deletionProtection ?? ctx.appConfig.defaults.table?.deletionProtection;
|
|
13076
|
-
const table2 = new
|
|
13367
|
+
const table2 = new aws21.dynamodb.Table(group, "table", {
|
|
13077
13368
|
...props,
|
|
13078
13369
|
name,
|
|
13079
13370
|
stream: props.stream?.type,
|
|
@@ -13086,7 +13377,7 @@ var tableFeature = defineFeature({
|
|
|
13086
13377
|
const { lambda, policy } = createLambdaFunction(group, ctx, "table", id, props.stream.consumer);
|
|
13087
13378
|
lambda.addEnvironment("LOG_VIEWABLE_ERROR", "1");
|
|
13088
13379
|
const onFailure = getGlobalOnFailure(ctx);
|
|
13089
|
-
const source = new
|
|
13380
|
+
const source = new aws21.lambda.EventSourceMapping(group, id, {
|
|
13090
13381
|
functionArn: lambda.arn,
|
|
13091
13382
|
sourceArn: table2.streamArn,
|
|
13092
13383
|
batchSize: 100,
|
|
@@ -13113,9 +13404,9 @@ var tableFeature = defineFeature({
|
|
|
13113
13404
|
});
|
|
13114
13405
|
|
|
13115
13406
|
// src/feature/task/index.ts
|
|
13116
|
-
import { Node as
|
|
13117
|
-
import { camelCase as
|
|
13118
|
-
import { relative as
|
|
13407
|
+
import { Node as Node21 } from "@awsless/formation";
|
|
13408
|
+
import { camelCase as camelCase7 } from "change-case";
|
|
13409
|
+
import { relative as relative6 } from "path";
|
|
13119
13410
|
var typeGenCode6 = `
|
|
13120
13411
|
import { InvokeOptions } from '@awsless/lambda'
|
|
13121
13412
|
import type { Mock } from 'vitest'
|
|
@@ -13150,14 +13441,14 @@ var taskFeature = defineFeature({
|
|
|
13150
13441
|
const mock = new TypeObject(2);
|
|
13151
13442
|
const mockResponse = new TypeObject(2);
|
|
13152
13443
|
for (const [name, props] of Object.entries(stack.tasks || {})) {
|
|
13153
|
-
const varName =
|
|
13444
|
+
const varName = camelCase7(`${stack.name}-${name}`);
|
|
13154
13445
|
const funcName = formatLocalResourceName({
|
|
13155
13446
|
appName: ctx.appConfig.name,
|
|
13156
13447
|
stackName: stack.name,
|
|
13157
13448
|
resourceType: "task",
|
|
13158
13449
|
resourceName: name
|
|
13159
13450
|
});
|
|
13160
|
-
const relFile =
|
|
13451
|
+
const relFile = relative6(directories.types, props.consumer.file);
|
|
13161
13452
|
types2.addImport(varName, relFile);
|
|
13162
13453
|
resource2.addType(name, `Invoke<'${funcName}', typeof ${varName}>`);
|
|
13163
13454
|
mock.addType(name, `MockBuilder<typeof ${varName}>`);
|
|
@@ -13175,7 +13466,7 @@ var taskFeature = defineFeature({
|
|
|
13175
13466
|
},
|
|
13176
13467
|
onStack(ctx) {
|
|
13177
13468
|
for (const [id, props] of Object.entries(ctx.stackConfig.tasks ?? {})) {
|
|
13178
|
-
const group = new
|
|
13469
|
+
const group = new Node21(ctx.stack, "task", id);
|
|
13179
13470
|
createAsyncLambdaFunction(group, ctx, "task", id, props.consumer);
|
|
13180
13471
|
}
|
|
13181
13472
|
}
|
|
@@ -13192,7 +13483,7 @@ var testFeature = defineFeature({
|
|
|
13192
13483
|
});
|
|
13193
13484
|
|
|
13194
13485
|
// src/feature/topic/index.ts
|
|
13195
|
-
import { aws as
|
|
13486
|
+
import { aws as aws22, Node as Node22 } from "@awsless/formation";
|
|
13196
13487
|
var typeGenCode7 = `
|
|
13197
13488
|
import type { PublishOptions } from '@awsless/sns'
|
|
13198
13489
|
import type { Mock } from 'vitest'
|
|
@@ -13233,13 +13524,13 @@ var topicFeature = defineFeature({
|
|
|
13233
13524
|
onApp(ctx) {
|
|
13234
13525
|
for (const stack of ctx.stackConfigs) {
|
|
13235
13526
|
for (const id of stack.topics ?? []) {
|
|
13236
|
-
const group = new
|
|
13527
|
+
const group = new Node22(ctx.base, "topic", id);
|
|
13237
13528
|
const name = formatGlobalResourceName({
|
|
13238
13529
|
appName: ctx.appConfig.name,
|
|
13239
13530
|
resourceType: "topic",
|
|
13240
13531
|
resourceName: id
|
|
13241
13532
|
});
|
|
13242
|
-
const topic = new
|
|
13533
|
+
const topic = new aws22.sns.Topic(group, "topic", {
|
|
13243
13534
|
name
|
|
13244
13535
|
});
|
|
13245
13536
|
ctx.shared.set(`topic-${id}-arn`, topic.arn);
|
|
@@ -13256,22 +13547,22 @@ var topicFeature = defineFeature({
|
|
|
13256
13547
|
});
|
|
13257
13548
|
}
|
|
13258
13549
|
for (const [id, props] of Object.entries(ctx.stackConfig.subscribers ?? {})) {
|
|
13259
|
-
const group = new
|
|
13550
|
+
const group = new Node22(ctx.stack, "topic", id);
|
|
13260
13551
|
const topicArn = ctx.shared.get(`topic-${id}-arn`);
|
|
13261
13552
|
if (typeof props === "string" && isEmail(props)) {
|
|
13262
|
-
new
|
|
13553
|
+
new aws22.sns.Subscription(group, id, {
|
|
13263
13554
|
topicArn,
|
|
13264
13555
|
protocol: "email",
|
|
13265
13556
|
endpoint: props
|
|
13266
13557
|
});
|
|
13267
13558
|
} else if (typeof props === "object") {
|
|
13268
13559
|
const { lambda } = createAsyncLambdaFunction(group, ctx, `topic`, id, props);
|
|
13269
|
-
new
|
|
13560
|
+
new aws22.sns.Subscription(group, id, {
|
|
13270
13561
|
topicArn,
|
|
13271
13562
|
protocol: "lambda",
|
|
13272
13563
|
endpoint: lambda.arn
|
|
13273
13564
|
});
|
|
13274
|
-
new
|
|
13565
|
+
new aws22.lambda.Permission(group, id, {
|
|
13275
13566
|
action: "lambda:InvokeFunction",
|
|
13276
13567
|
principal: "sns.amazonaws.com",
|
|
13277
13568
|
functionArn: lambda.arn,
|
|
@@ -13283,36 +13574,36 @@ var topicFeature = defineFeature({
|
|
|
13283
13574
|
});
|
|
13284
13575
|
|
|
13285
13576
|
// src/feature/vpc/index.ts
|
|
13286
|
-
import { aws as
|
|
13577
|
+
import { aws as aws23, combine as combine2, Node as Node23 } from "@awsless/formation";
|
|
13287
13578
|
var vpcFeature = defineFeature({
|
|
13288
13579
|
name: "vpc",
|
|
13289
13580
|
onApp(ctx) {
|
|
13290
|
-
const group = new
|
|
13291
|
-
const vpc = new
|
|
13581
|
+
const group = new Node23(ctx.base, "vpc", "main");
|
|
13582
|
+
const vpc = new aws23.ec2.Vpc(group, "vpc", {
|
|
13292
13583
|
name: ctx.app.name,
|
|
13293
|
-
cidrBlock:
|
|
13584
|
+
cidrBlock: aws23.ec2.Peer.ipv4("10.0.0.0/16")
|
|
13294
13585
|
// cidrBlock: aws.ec2.Peer.ipv6('fd00:10:20::/48'),
|
|
13295
13586
|
// cidrBlock: aws.ec2.Peer.ipv6('2a05:d018:c69:6600::/56'),
|
|
13296
13587
|
// enableDnsSupport: true,
|
|
13297
13588
|
// enableDnsHostnames: true,
|
|
13298
13589
|
});
|
|
13299
|
-
const privateRouteTable = new
|
|
13590
|
+
const privateRouteTable = new aws23.ec2.RouteTable(group, "private", {
|
|
13300
13591
|
vpcId: vpc.id,
|
|
13301
13592
|
name: "private"
|
|
13302
13593
|
});
|
|
13303
|
-
const publicRouteTable = new
|
|
13594
|
+
const publicRouteTable = new aws23.ec2.RouteTable(group, "public", {
|
|
13304
13595
|
vpcId: vpc.id,
|
|
13305
13596
|
name: "public"
|
|
13306
13597
|
});
|
|
13307
|
-
const gateway = new
|
|
13308
|
-
const attachment = new
|
|
13598
|
+
const gateway = new aws23.ec2.InternetGateway(group, "gateway");
|
|
13599
|
+
const attachment = new aws23.ec2.VPCGatewayAttachment(group, "attachment", {
|
|
13309
13600
|
vpcId: vpc.id,
|
|
13310
13601
|
internetGatewayId: gateway.id
|
|
13311
13602
|
});
|
|
13312
|
-
new
|
|
13603
|
+
new aws23.ec2.Route(group, "route", {
|
|
13313
13604
|
gatewayId: gateway.id,
|
|
13314
13605
|
routeTableId: publicRouteTable.id,
|
|
13315
|
-
destination:
|
|
13606
|
+
destination: aws23.ec2.Peer.anyIpv4()
|
|
13316
13607
|
// destination: aws.ec2.Peer.anyIpv6(),
|
|
13317
13608
|
});
|
|
13318
13609
|
ctx.shared.set(
|
|
@@ -13328,10 +13619,10 @@ var vpcFeature = defineFeature({
|
|
|
13328
13619
|
for (const i in zones) {
|
|
13329
13620
|
const index = Number(i) + 1;
|
|
13330
13621
|
const id = `${table2.identifier}-${index}`;
|
|
13331
|
-
const subnet = new
|
|
13622
|
+
const subnet = new aws23.ec2.Subnet(group, id, {
|
|
13332
13623
|
name: `${ctx.app.name}--${table2.identifier}-${index}`,
|
|
13333
13624
|
vpcId: vpc.id,
|
|
13334
|
-
cidrBlock:
|
|
13625
|
+
cidrBlock: aws23.ec2.Peer.ipv4(`10.0.${block++}.0/24`),
|
|
13335
13626
|
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`fd00:10:20:${++block}::/64`),
|
|
13336
13627
|
// ipv6CidrBlock: aws.ec2.Peer.ipv6(`2a05:d018:c69:660${++block}::/64`),
|
|
13337
13628
|
// ipv6CidrBlock: ipv6CidrBlock.ipv6CidrBlock.apply(ip => ),
|
|
@@ -13341,7 +13632,7 @@ var vpcFeature = defineFeature({
|
|
|
13341
13632
|
mapPublicIpOnLaunch: table2.identifier === "public",
|
|
13342
13633
|
availabilityZone: ctx.appConfig.region + zones[i]
|
|
13343
13634
|
});
|
|
13344
|
-
new
|
|
13635
|
+
new aws23.ec2.SubnetRouteTableAssociation(group, id, {
|
|
13345
13636
|
routeTableId: table2.id,
|
|
13346
13637
|
subnetId: subnet.id
|
|
13347
13638
|
});
|
|
@@ -13378,7 +13669,8 @@ var features = [
|
|
|
13378
13669
|
cronFeature,
|
|
13379
13670
|
httpFeature,
|
|
13380
13671
|
restFeature,
|
|
13381
|
-
siteFeature
|
|
13672
|
+
siteFeature,
|
|
13673
|
+
rpcFeature
|
|
13382
13674
|
];
|
|
13383
13675
|
|
|
13384
13676
|
// src/shared.ts
|
|
@@ -13853,12 +14145,12 @@ import { confirm as confirm4, isCancel as isCancel5 } from "@clack/prompts";
|
|
|
13853
14145
|
import { log as log8 } from "@clack/prompts";
|
|
13854
14146
|
import chalk6 from "chalk";
|
|
13855
14147
|
import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile3 } from "fs/promises";
|
|
13856
|
-
import { join as
|
|
14148
|
+
import { join as join12 } from "path";
|
|
13857
14149
|
|
|
13858
14150
|
// src/build/__fingerprint.ts
|
|
13859
14151
|
import { createHash as createHash5 } from "crypto";
|
|
13860
14152
|
import { readdir, readFile as readFile6, stat as stat4 } from "fs/promises";
|
|
13861
|
-
import { basename as basename4, dirname as
|
|
14153
|
+
import { basename as basename4, dirname as dirname11, extname as extname3, join as join10 } from "path";
|
|
13862
14154
|
import parseStaticImports from "parse-static-imports";
|
|
13863
14155
|
var extensions = ["js", "mjs", "jsx", "ts", "mts", "tsx"];
|
|
13864
14156
|
var generateFileHashes = async (file, hashes) => {
|
|
@@ -13880,7 +14172,7 @@ var fingerprintFromDirectory = async (dir) => {
|
|
|
13880
14172
|
const files = await readdir(dir, { recursive: true });
|
|
13881
14173
|
for (const file of files) {
|
|
13882
14174
|
if (extensions.includes(extname3(file).substring(1)) && file.at(0) !== "_") {
|
|
13883
|
-
await generateFileHashes(
|
|
14175
|
+
await generateFileHashes(join10(dir, file), hashes);
|
|
13884
14176
|
}
|
|
13885
14177
|
}
|
|
13886
14178
|
const merge2 = Buffer.concat(Array.from(hashes.values()).sort());
|
|
@@ -13894,7 +14186,7 @@ var readModuleFile = (file) => {
|
|
|
13894
14186
|
return readFiles([
|
|
13895
14187
|
file,
|
|
13896
14188
|
...extensions.map((exp) => `${file}.${exp}`),
|
|
13897
|
-
...extensions.map((exp) =>
|
|
14189
|
+
...extensions.map((exp) => join10(file, `/index.${exp}`))
|
|
13898
14190
|
]);
|
|
13899
14191
|
}
|
|
13900
14192
|
return readFile6(file, "utf8");
|
|
@@ -13914,7 +14206,7 @@ var readFiles = async (files) => {
|
|
|
13914
14206
|
};
|
|
13915
14207
|
var findDependencies = async (file, code) => {
|
|
13916
14208
|
const imports = await parseStaticImports(code);
|
|
13917
|
-
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ?
|
|
14209
|
+
return imports.map((entry) => entry.moduleName).filter(Boolean).map((value) => value?.startsWith(".") ? join10(dirname11(file), value) : value);
|
|
13918
14210
|
};
|
|
13919
14211
|
|
|
13920
14212
|
// src/test/reporter.ts
|
|
@@ -13997,10 +14289,10 @@ import { startVitest } from "vitest/node";
|
|
|
13997
14289
|
import commonjs3 from "@rollup/plugin-commonjs";
|
|
13998
14290
|
import nodeResolve3 from "@rollup/plugin-node-resolve";
|
|
13999
14291
|
import json3 from "@rollup/plugin-json";
|
|
14000
|
-
import { dirname as
|
|
14001
|
-
import { fileURLToPath } from "url";
|
|
14292
|
+
import { dirname as dirname12, join as join11 } from "path";
|
|
14293
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
14002
14294
|
var startTest = async (props) => {
|
|
14003
|
-
const
|
|
14295
|
+
const __dirname2 = dirname12(fileURLToPath2(import.meta.url));
|
|
14004
14296
|
const result = await startVitest(
|
|
14005
14297
|
"test",
|
|
14006
14298
|
props.filters,
|
|
@@ -14014,7 +14306,7 @@ var startTest = async (props) => {
|
|
|
14014
14306
|
exclude: ["**/_*", "**/_*/**", ...configDefaults.exclude],
|
|
14015
14307
|
globals: true,
|
|
14016
14308
|
reporters: props.reporter,
|
|
14017
|
-
globalSetup:
|
|
14309
|
+
globalSetup: join11(__dirname2, "test-global-setup.js")
|
|
14018
14310
|
// env: {
|
|
14019
14311
|
// TZ: 'UTC',
|
|
14020
14312
|
// },
|
|
@@ -14108,7 +14400,7 @@ var logTestErrors = (event) => {
|
|
|
14108
14400
|
var runTest = async (stack, dir, filters) => {
|
|
14109
14401
|
await mkdir4(directories.test, { recursive: true });
|
|
14110
14402
|
const fingerprint = await fingerprintFromDirectory(dir);
|
|
14111
|
-
const file =
|
|
14403
|
+
const file = join12(directories.test, `${stack}.json`);
|
|
14112
14404
|
const exists = await fileExist(file);
|
|
14113
14405
|
if (exists && !process.env.NO_CACHE) {
|
|
14114
14406
|
const raw = await readFile7(file, { encoding: "utf8" });
|
|
@@ -14418,7 +14710,7 @@ import { log as log10 } from "@clack/prompts";
|
|
|
14418
14710
|
|
|
14419
14711
|
// src/type-gen/generate.ts
|
|
14420
14712
|
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
14421
|
-
import { dirname as
|
|
14713
|
+
import { dirname as dirname13, join as join13, relative as relative7 } from "path";
|
|
14422
14714
|
var generateTypes = async (props) => {
|
|
14423
14715
|
const files = [];
|
|
14424
14716
|
await Promise.all(
|
|
@@ -14427,12 +14719,12 @@ var generateTypes = async (props) => {
|
|
|
14427
14719
|
...props,
|
|
14428
14720
|
async write(file, data, include = false) {
|
|
14429
14721
|
const code = data?.toString("utf8");
|
|
14430
|
-
const path =
|
|
14722
|
+
const path = join13(directories.types, file);
|
|
14431
14723
|
if (code) {
|
|
14432
14724
|
if (include) {
|
|
14433
|
-
files.push(
|
|
14725
|
+
files.push(relative7(directories.root, path));
|
|
14434
14726
|
}
|
|
14435
|
-
await mkdir5(
|
|
14727
|
+
await mkdir5(dirname13(path), { recursive: true });
|
|
14436
14728
|
await writeFile4(path, code);
|
|
14437
14729
|
}
|
|
14438
14730
|
}
|
|
@@ -14441,7 +14733,7 @@ var generateTypes = async (props) => {
|
|
|
14441
14733
|
);
|
|
14442
14734
|
if (files.length) {
|
|
14443
14735
|
const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
|
|
14444
|
-
await writeFile4(
|
|
14736
|
+
await writeFile4(join13(directories.root, `awsless.d.ts`), code);
|
|
14445
14737
|
}
|
|
14446
14738
|
};
|
|
14447
14739
|
|