@awsless/awsless 0.0.489 → 0.0.490

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.
@@ -615,7 +615,7 @@ var AppSchema = z21.object({
615
615
  });
616
616
 
617
617
  // src/config/stack.ts
618
- import { z as z35 } from "zod";
618
+ import { z as z36 } from "zod";
619
619
 
620
620
  // src/feature/cache/schema.ts
621
621
  import { gibibytes as gibibytes2 } from "@awsless/size";
@@ -1050,24 +1050,96 @@ var StoresSchema = z30.union([
1050
1050
  )
1051
1051
  ]).optional().describe("Define the stores in your stack.");
1052
1052
 
1053
- // src/feature/table/schema.ts
1054
- import { minutes as minutes4, seconds as seconds4 } from "@awsless/duration";
1053
+ // src/feature/images/schema.ts
1055
1054
  import { z as z31 } from "zod";
1056
- var KeySchema = z31.string().min(1).max(255);
1057
- var TablesSchema = z31.record(
1055
+ var transformationOptionsSchema = z31.object({
1056
+ // Resize options
1057
+ width: z31.number().int().positive().optional(),
1058
+ height: z31.number().int().positive().optional(),
1059
+ fit: z31.enum(["cover", "contain", "fill", "inside", "outside"]).optional(),
1060
+ position: z31.enum(["top", "right top", "right", "right bottom", "bottom", "left bottom", "left", "left top", "center"]).optional(),
1061
+ // Format options
1062
+ quality: z31.number().int().min(1).max(100).optional(),
1063
+ progressive: z31.boolean().optional(),
1064
+ // Processing options
1065
+ rotate: z31.number().optional(),
1066
+ flip: z31.boolean().optional(),
1067
+ flop: z31.boolean().optional(),
1068
+ blur: z31.number().min(0.3).max(1e3).optional(),
1069
+ sharpen: z31.boolean().optional(),
1070
+ grayscale: z31.boolean().optional(),
1071
+ normalize: z31.boolean().optional()
1072
+ });
1073
+ var extensionOptionsSchema = z31.object({
1074
+ // WebP specific
1075
+ effort: z31.number().int().min(0).max(6).optional(),
1076
+ lossless: z31.boolean().optional(),
1077
+ nearLossless: z31.boolean().optional(),
1078
+ // smartSubsample: z.boolean().optional(),
1079
+ // JPEG specific
1080
+ mozjpeg: z31.boolean().optional(),
1081
+ // trellisQuantisation: z.boolean().optional(),
1082
+ // overshootDeringing: z.boolean().optional(),
1083
+ // optimiseScans: z.boolean().optional(),
1084
+ // PNG specific
1085
+ compressionLevel: z31.number().int().min(0).max(9).optional(),
1086
+ adaptiveFiltering: z31.boolean().optional(),
1087
+ // palette: z.boolean().optional(),
1088
+ // AVIF specific
1089
+ speed: z31.number().int().min(0).max(9).optional()
1090
+ // chromaSubsampling: z.string().optional(),
1091
+ });
1092
+ var staticOriginSchema = LocalDirectorySchema.describe(
1093
+ "Specifies the path to a image directory that will be uploaded in S3."
1094
+ );
1095
+ var functionOriginSchema = FunctionSchema.describe(
1096
+ "Specifies the file that will be called when an image isn't found in the S3 bucket."
1097
+ );
1098
+ var ImagesSchema = z31.record(
1058
1099
  ResourceIdSchema,
1059
1100
  z31.object({
1101
+ domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
1102
+ subDomain: z31.string().optional(),
1103
+ presets: z31.record(z31.string(), transformationOptionsSchema).describe("Named presets for image transformations"),
1104
+ extensions: z31.record(z31.enum(["jpeg", "jpg", "png", "webp"]), extensionOptionsSchema).describe("Format-specific optimization options"),
1105
+ origin: z31.union([
1106
+ z31.object({
1107
+ static: staticOriginSchema,
1108
+ function: functionOriginSchema.optional()
1109
+ }),
1110
+ z31.object({
1111
+ static: staticOriginSchema.optional(),
1112
+ function: functionOriginSchema
1113
+ }),
1114
+ z31.object({
1115
+ static: staticOriginSchema,
1116
+ function: functionOriginSchema
1117
+ })
1118
+ ]).describe(
1119
+ "Image transformation will be applied from a base image. Base images orginates from a local directory that will be uploaded to S3 or from a lambda function."
1120
+ )
1121
+ // postprocess: FunctionSchema.optional()
1122
+ })
1123
+ ).optional().describe("Define image CDN & transformations in your stack.");
1124
+
1125
+ // src/feature/table/schema.ts
1126
+ import { minutes as minutes4, seconds as seconds4 } from "@awsless/duration";
1127
+ import { z as z32 } from "zod";
1128
+ var KeySchema = z32.string().min(1).max(255);
1129
+ var TablesSchema = z32.record(
1130
+ ResourceIdSchema,
1131
+ z32.object({
1060
1132
  hash: KeySchema.describe(
1061
1133
  "Specifies the name of the partition / hash key that makes up the primary key for the table."
1062
1134
  ),
1063
1135
  sort: KeySchema.optional().describe(
1064
1136
  "Specifies the name of the range / sort key that makes up the primary key for the table."
1065
1137
  ),
1066
- fields: z31.record(z31.string(), z31.enum(["string", "number", "binary"])).optional().describe(
1138
+ fields: z32.record(z32.string(), z32.enum(["string", "number", "binary"])).optional().describe(
1067
1139
  'A list of attributes that describe the key schema for the table and indexes. If no attribute field is defined we default to "string".'
1068
1140
  ),
1069
- class: z31.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1070
- pointInTimeRecovery: z31.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1141
+ class: z32.enum(["standard", "standard-infrequent-access"]).default("standard").describe("The table class of the table."),
1142
+ pointInTimeRecovery: z32.boolean().default(false).describe("Indicates whether point in time recovery is enabled on the table."),
1071
1143
  ttl: KeySchema.optional().describe(
1072
1144
  [
1073
1145
  "The name of the TTL attribute used to store the expiration time for items in the table.",
@@ -1075,8 +1147,8 @@ var TablesSchema = z31.record(
1075
1147
  ].join("\n")
1076
1148
  ),
1077
1149
  // deletionProtection: DeletionProtectionSchema.optional(),
1078
- stream: z31.object({
1079
- type: z31.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1150
+ stream: z32.object({
1151
+ type: z32.enum(["keys-only", "new-image", "old-image", "new-and-old-images"]).describe(
1080
1152
  [
1081
1153
  "When an item in the table is modified, you can determines what information is written to the stream for this table.",
1082
1154
  "Valid values are:",
@@ -1086,7 +1158,7 @@ var TablesSchema = z31.record(
1086
1158
  "- new-and-old-images - Both the new and the old item images of the item are written to the stream."
1087
1159
  ].join("\n")
1088
1160
  ),
1089
- batchSize: z31.number().min(1).max(1e4).default(1).describe(
1161
+ batchSize: z32.number().min(1).max(1e4).default(1).describe(
1090
1162
  [
1091
1163
  "The maximum number of records in each batch that Lambda pulls from your stream and sends to your function.",
1092
1164
  "Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).",
@@ -1116,7 +1188,7 @@ var TablesSchema = z31.record(
1116
1188
  // 'You can specify a number from -1 to 10000.',
1117
1189
  // ].join('\n')
1118
1190
  // ),
1119
- retryAttempts: z31.number().min(-1).max(1e4).default(-1).describe(
1191
+ retryAttempts: z32.number().min(-1).max(1e4).default(-1).describe(
1120
1192
  [
1121
1193
  "Discard records after the specified number of retries.",
1122
1194
  "The default value is -1, which sets the maximum number of retries to infinite.",
@@ -1124,7 +1196,7 @@ var TablesSchema = z31.record(
1124
1196
  "You can specify a number from -1 to 10000."
1125
1197
  ].join("\n")
1126
1198
  ),
1127
- concurrencyPerShard: z31.number().min(1).max(10).default(1).describe(
1199
+ concurrencyPerShard: z32.number().min(1).max(10).default(1).describe(
1128
1200
  [
1129
1201
  "The number of batches to process concurrently from each shard.",
1130
1202
  "You can specify a number from 1 to 10."
@@ -1134,16 +1206,16 @@ var TablesSchema = z31.record(
1134
1206
  }).optional().describe(
1135
1207
  "The settings for the DynamoDB table stream, which capture changes to items stored in the table."
1136
1208
  ),
1137
- indexes: z31.record(
1138
- z31.string(),
1139
- z31.object({
1209
+ indexes: z32.record(
1210
+ z32.string(),
1211
+ z32.object({
1140
1212
  hash: KeySchema.describe(
1141
1213
  "Specifies the name of the partition / hash key that makes up the primary key for the global secondary index."
1142
1214
  ),
1143
1215
  sort: KeySchema.optional().describe(
1144
1216
  "Specifies the name of the range / sort key that makes up the primary key for the global secondary index."
1145
1217
  ),
1146
- projection: z31.enum(["all", "keys-only"]).default("all").describe(
1218
+ projection: z32.enum(["all", "keys-only"]).default("all").describe(
1147
1219
  [
1148
1220
  "The set of attributes that are projected into the index:",
1149
1221
  "- all - All of the table attributes are projected into the index.",
@@ -1157,11 +1229,11 @@ var TablesSchema = z31.record(
1157
1229
  ).optional().describe("Define the tables in your stack.");
1158
1230
 
1159
1231
  // src/feature/task/schema.ts
1160
- import { z as z32 } from "zod";
1161
- var RetryAttemptsSchema2 = z32.number().int().min(0).max(2).describe(
1232
+ import { z as z33 } from "zod";
1233
+ var RetryAttemptsSchema2 = z33.number().int().min(0).max(2).describe(
1162
1234
  "The maximum number of times to retry when the function returns an error. You can specify a number from 0 to 2."
1163
1235
  );
1164
- var TaskSchema = z32.union([
1236
+ var TaskSchema = z33.union([
1165
1237
  LocalFileSchema.transform((file) => ({
1166
1238
  consumer: {
1167
1239
  code: {
@@ -1172,33 +1244,33 @@ var TaskSchema = z32.union([
1172
1244
  },
1173
1245
  retryAttempts: void 0
1174
1246
  })),
1175
- z32.object({
1247
+ z33.object({
1176
1248
  consumer: FunctionSchema,
1177
1249
  retryAttempts: RetryAttemptsSchema2.optional()
1178
1250
  })
1179
1251
  ]);
1180
- var TasksSchema = z32.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1252
+ var TasksSchema = z33.record(ResourceIdSchema, TaskSchema).optional().describe("Define the tasks in your stack.");
1181
1253
 
1182
1254
  // src/feature/test/schema.ts
1183
- import { z as z33 } from "zod";
1184
- var TestsSchema = z33.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1255
+ import { z as z34 } from "zod";
1256
+ var TestsSchema = z34.union([LocalDirectorySchema.transform((v) => [v]), LocalDirectorySchema.array()]).describe("Define the location of your tests for your stack.").optional();
1185
1257
 
1186
1258
  // src/feature/topic/schema.ts
1187
1259
  import { kebabCase as kebabCase3 } from "change-case";
1188
- import { z as z34 } from "zod";
1189
- var TopicNameSchema = z34.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
1190
- var TopicsSchema = z34.array(TopicNameSchema).refine((topics) => {
1260
+ import { z as z35 } from "zod";
1261
+ var TopicNameSchema = z35.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid topic name").transform((value) => kebabCase3(value)).describe("Define event topic name.");
1262
+ var TopicsSchema = z35.array(TopicNameSchema).refine((topics) => {
1191
1263
  return topics.length === new Set(topics).size;
1192
1264
  }, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
1193
- var SubscribersSchema = z34.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1265
+ var SubscribersSchema = z35.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1194
1266
 
1195
1267
  // src/config/stack.ts
1196
1268
  var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
1197
1269
  var NameSchema = ResourceIdSchema.refine((name) => !["base", "hostedzones"].includes(name), {
1198
1270
  message: `Stack name can't be a reserved name.`
1199
1271
  }).describe("Stack name.");
1200
- var StackSchema = z35.object({
1201
- $schema: z35.string().optional(),
1272
+ var StackSchema = z36.object({
1273
+ $schema: z36.string().optional(),
1202
1274
  name: NameSchema,
1203
1275
  depends: DependsSchema,
1204
1276
  commands: CommandsSchema,
@@ -1223,7 +1295,8 @@ var StackSchema = z35.object({
1223
1295
  pubsub: PubSubSchema,
1224
1296
  searchs: SearchsSchema,
1225
1297
  sites: SitesSchema,
1226
- tests: TestsSchema
1298
+ tests: TestsSchema,
1299
+ images: ImagesSchema
1227
1300
  });
1228
1301
 
1229
1302
  // cli/build-json-schema.ts
Binary file
@@ -0,0 +1 @@
1
+ 79683796c2bc3e9bae6c051ab9628fe6f37428a3
Binary file
Binary file
package/dist/prebuild.js CHANGED
@@ -148,11 +148,11 @@ var zipFiles = (files) => {
148
148
  };
149
149
 
150
150
  // src/feature/function/prebuild.ts
151
- var prebuild = async (file, output) => {
151
+ var prebuild = async (file, output, external = []) => {
152
152
  const bundle = await bundleTypeScript({
153
153
  file,
154
154
  minify: true,
155
- external: []
155
+ external
156
156
  });
157
157
  const archive = await zipFiles(bundle.files);
158
158
  await writeFile(join(output, "HASH"), bundle.hash);
@@ -162,10 +162,11 @@ var prebuild = async (file, output) => {
162
162
  // src/prebuild.ts
163
163
  var __dirname = dirname2(fileURLToPath(import.meta.url));
164
164
  var builds = {
165
- rpc: "../src/feature/rpc/server/handle.ts"
165
+ rpc: "../src/feature/rpc/server/handle.ts",
166
+ images: "../src/feature/images/server/handle.ts"
166
167
  };
167
168
  for (const [name, file] of Object.entries(builds)) {
168
169
  const output = join2(__dirname, "prebuild", name);
169
170
  await mkdir(output, { recursive: true });
170
- await prebuild(join2(__dirname, file), output);
171
+ await prebuild(join2(__dirname, file), output, ["sharp"]);
171
172
  }