@awsless/awsless 0.0.411 → 0.0.413

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.
@@ -786,8 +786,8 @@ var SearchsSchema = z22.record(
786
786
  type: TypeSchema3.default("t3.small"),
787
787
  count: z22.number().int().min(1).default(1),
788
788
  version: VersionSchema.default("2.13"),
789
- storage: StorageSizeSchema.default("10 GB"),
790
- vpc: z22.boolean().default(false)
789
+ storage: StorageSizeSchema.default("10 GB")
790
+ // vpc: z.boolean().default(false),
791
791
  })
792
792
  ).optional().describe("Define the search instances in your stack. Backed by OpenSearch.");
793
793
 
@@ -823,8 +823,11 @@ var SitesSchema = z23.record(
823
823
  // // rest: z.array(ResourceIdSchema),
824
824
  // })
825
825
  // .optional(),
826
- static: LocalDirectorySchema.optional().describe("Specifies the path to the static files directory."),
826
+ static: z23.union([LocalDirectorySchema, z23.boolean()]).optional().describe(
827
+ "Specifies the path to the static files directory. Additionally you can also pass `true` when you don't have local static files, but still want to make an S3 bucket."
828
+ ),
827
829
  ssr: FunctionSchema.optional().describe("Specifies the ssr file."),
830
+ origin: z23.enum(["ssr-first", "static-first"]).default("static-first").describe("Specifies the origin fallback ordering."),
828
831
  // bind: z.object({
829
832
  // auth:
830
833
  // h
@@ -1065,7 +1068,7 @@ var TopicNameSchema = z29.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Inva
1065
1068
  var TopicsSchema = z29.array(TopicNameSchema).refine((topics) => {
1066
1069
  return topics.length === new Set(topics).size;
1067
1070
  }, "Must be a list of unique topic names").optional().describe("Define the event topics to publish too in your stack.");
1068
- var SubscribersSchema = z29.record(TopicNameSchema, z29.union([EmailSchema, FunctionSchema])).optional().describe("Define the event topics to subscribe too in your stack.");
1071
+ var SubscribersSchema = z29.record(TopicNameSchema, FunctionSchema).optional().describe("Define the event topics to subscribe too in your stack.");
1069
1072
 
1070
1073
  // src/config/stack.ts
1071
1074
  var DependsSchema = ResourceIdSchema.array().optional().describe("Define the stacks that this stack is depended on.");
@@ -1102,21 +1105,34 @@ var StackSchema = z30.object({
1102
1105
  });
1103
1106
 
1104
1107
  // src/config/app.ts
1105
- import { z as z34 } from "zod";
1108
+ import { z as z35 } from "zod";
1106
1109
 
1107
- // src/feature/domain/schema.ts
1110
+ // src/feature/alert/schema.ts
1111
+ import { paramCase as paramCase3 } from "change-case";
1108
1112
  import { z as z31 } from "zod";
1109
- var DomainNameSchema = z31.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
1113
+ var AlertNameSchema = z31.string().min(3).max(256).regex(/^[a-z0-9\-]+$/i, "Invalid alert name").transform((value) => paramCase3(value)).describe("Define event topic name.");
1114
+ var AlertsDefaultSchema = z31.record(
1115
+ AlertNameSchema,
1116
+ z31.union([
1117
+ //
1118
+ EmailSchema.transform((v) => [v]),
1119
+ EmailSchema.array()
1120
+ ])
1121
+ ).optional().describe("Define the alerts in your app. Alerts are a way to send messages to one or more email addresses.");
1122
+
1123
+ // src/feature/domain/schema.ts
1124
+ import { z as z32 } from "zod";
1125
+ var DomainNameSchema = z32.string().regex(/[a-z\-\_\.]/g, "Invalid domain name").describe(
1110
1126
  "Enter a fully qualified domain name, for example, www.example.com. You can optionally include a trailing dot. If you omit the trailing dot, Amazon Route 53 assumes that the domain name that you specify is fully qualified. This means that Route 53 treats www.example.com (without a trailing dot) and www.example.com. (with a trailing dot) as identical."
1111
1127
  );
1112
- var DNSTypeSchema = z31.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
1128
+ var DNSTypeSchema = z32.enum(["A", "AAAA", "CAA", "CNAME", "DS", "MX", "NAPTR", "NS", "PTR", "SOA", "SPF", "SRV", "TXT"]).describe("The DNS record type.");
1113
1129
  var TTLSchema = DurationSchema.describe("The resource record cache time to live (TTL).");
1114
- var RecordsSchema = z31.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
1115
- var DomainsDefaultSchema = z31.record(
1130
+ var RecordsSchema = z32.string().array().describe("One or more values that correspond with the value that you specified for the Type property.");
1131
+ var DomainsDefaultSchema = z32.record(
1116
1132
  ResourceIdSchema,
1117
- z31.object({
1133
+ z32.object({
1118
1134
  domain: DomainNameSchema.describe("Define the domain name"),
1119
- dns: z31.object({
1135
+ dns: z32.object({
1120
1136
  name: DomainNameSchema.optional(),
1121
1137
  type: DNSTypeSchema,
1122
1138
  ttl: TTLSchema,
@@ -1131,21 +1147,21 @@ var OnFailureDefaultSchema = FunctionSchema.optional().describe(
1131
1147
  );
1132
1148
 
1133
1149
  // src/feature/on-log/schema.ts
1134
- import { z as z32 } from "zod";
1135
- var FilterSchema = z32.enum(["trace", "debug", "info", "warn", "error", "fatal"]).array().describe("The log level that will gets delivered to the consumer.");
1136
- var OnLogDefaultSchema = z32.union([
1150
+ import { z as z33 } from "zod";
1151
+ var FilterSchema = z33.enum(["trace", "debug", "info", "warn", "error", "fatal"]).array().describe("The log level that will gets delivered to the consumer.");
1152
+ var OnLogDefaultSchema = z33.union([
1137
1153
  FunctionSchema.transform((consumer) => ({
1138
1154
  consumer,
1139
1155
  filter: ["error", "fatal"]
1140
1156
  })),
1141
- z32.object({
1157
+ z33.object({
1142
1158
  consumer: FunctionSchema,
1143
1159
  filter: FilterSchema
1144
1160
  })
1145
1161
  ]).optional().describe("Define a subscription on all Lambda functions logs.");
1146
1162
 
1147
1163
  // src/config/schema/region.ts
1148
- import { z as z33 } from "zod";
1164
+ import { z as z34 } from "zod";
1149
1165
  var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
1150
1166
  var AF = ["af-south-1"];
1151
1167
  var AP = [
@@ -1174,21 +1190,21 @@ var EU = [
1174
1190
  var ME = ["me-south-1", "me-central-1"];
1175
1191
  var SA = ["sa-east-1"];
1176
1192
  var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
1177
- var RegionSchema = z33.enum(regions);
1193
+ var RegionSchema = z34.enum(regions);
1178
1194
 
1179
1195
  // src/config/app.ts
1180
- var AppSchema = z34.object({
1181
- $schema: z34.string().optional(),
1196
+ var AppSchema = z35.object({
1197
+ $schema: z35.string().optional(),
1182
1198
  name: ResourceIdSchema.describe("App name."),
1183
1199
  region: RegionSchema.describe("The AWS region to deploy to."),
1184
- profile: z34.string().describe("The AWS profile to deploy to."),
1200
+ profile: z35.string().describe("The AWS profile to deploy to."),
1185
1201
  // stage: z
1186
1202
  // .string()
1187
1203
  // .regex(/^[a-z]+$/)
1188
1204
  // .default('prod')
1189
1205
  // .describe('The deployment stage.'),
1190
1206
  // onFailure: OnFailureSchema,
1191
- defaults: z34.object({
1207
+ defaults: z35.object({
1192
1208
  onFailure: OnFailureDefaultSchema,
1193
1209
  onLog: OnLogDefaultSchema,
1194
1210
  auth: AuthDefaultSchema,
@@ -1202,7 +1218,8 @@ var AppSchema = z34.object({
1202
1218
  rpc: RpcDefaultSchema,
1203
1219
  pubsub: PubSubDefaultSchema,
1204
1220
  table: TableDefaultSchema,
1205
- store: StoreDefaultSchema
1221
+ store: StoreDefaultSchema,
1222
+ alerts: AlertsDefaultSchema
1206
1223
  // dataRetention: z.boolean().describe('Configure how your resources are handled on delete.').default(false),
1207
1224
  }).default({}).describe("Default properties")
1208
1225
  });
Binary file
package/dist/server.d.ts CHANGED
@@ -53,6 +53,11 @@ interface TopicMockResponse {
53
53
  }
54
54
  declare const mockTopic: (cb: (mock: TopicMock) => void) => TopicMockResponse;
55
55
 
56
+ declare const getAlertName: <N extends string>(resourceName: N) => `app--alert--${N}`;
57
+ interface AlertResources {
58
+ }
59
+ declare const Alert: AlertResources;
60
+
56
61
  declare const getAuthProps: (name: string) => {
57
62
  readonly userPoolId: string | undefined;
58
63
  readonly clientId: string | undefined;
@@ -155,4 +160,4 @@ declare const Topic: TopicResources;
155
160
  declare const APP: "app";
156
161
  declare const STACK: "stack";
157
162
 
158
- export { APP, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, CommandOptions, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, PubSub, type PublishOptions, Queue, type QueueMock, type QueueMockResponse, type QueueResources, type RpcAuthorizerResponse, STACK, Search, type SearchResources, Store, type StoreResources, Table, type TableResources, Task, type TaskMock, type TaskMockResponse, type TaskResources, Topic, type TopicMock, type TopicMockResponse, type TopicResources, getAuthProps, getCacheProps, getConfigName, getConfigValue, getFunctionName, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
163
+ export { APP, Alert, type AlertResources, Auth, type AuthResources, Cache, type CacheResources, type CommandContext, type CommandHandler, CommandOptions, Config, type ConfigResources, Fn, Function, type FunctionMock, type FunctionMockResponse, type FunctionResources, PubSub, type PublishOptions, Queue, type QueueMock, type QueueMockResponse, type QueueResources, type RpcAuthorizerResponse, STACK, Search, type SearchResources, Store, type StoreResources, Table, type TableResources, Task, type TaskMock, type TaskMockResponse, type TaskResources, Topic, type TopicMock, type TopicMockResponse, type TopicResources, getAlertName, getAuthProps, getCacheProps, getConfigName, getConfigValue, getFunctionName, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic, pubsubAuthorizerHandle, pubsubAuthorizerResponse, setConfigValue };
package/dist/server.js CHANGED
@@ -217,6 +217,7 @@ var mockTask = (cb) => {
217
217
  import { mockSNS } from "@awsless/sns";
218
218
 
219
219
  // src/lib/server/topic.ts
220
+ import { stringify } from "@awsless/json";
220
221
  import { publish } from "@awsless/sns";
221
222
  var getTopicName = bindGlobalResourceName("topic");
222
223
  var Topic = /* @__PURE__ */ createProxy((name) => {
@@ -226,7 +227,7 @@ var Topic = /* @__PURE__ */ createProxy((name) => {
226
227
  await publish({
227
228
  ...options,
228
229
  topic,
229
- payload
230
+ payload: stringify(payload)
230
231
  });
231
232
  }
232
233
  };
@@ -250,6 +251,25 @@ var mockTopic = (cb) => {
250
251
  });
251
252
  };
252
253
 
254
+ // src/lib/server/alert.ts
255
+ import { publish as publish2 } from "@awsless/sns";
256
+ var getAlertName = bindGlobalResourceName("alert");
257
+ var Alert = /* @__PURE__ */ createProxy((name) => {
258
+ const topic = getAlertName(name);
259
+ const ctx = {
260
+ [topic]: async (subject, payload, options = {}) => {
261
+ await publish2({
262
+ ...options,
263
+ topic,
264
+ subject,
265
+ payload
266
+ });
267
+ }
268
+ };
269
+ const call = ctx[topic];
270
+ return call;
271
+ });
272
+
253
273
  // src/lib/server/auth.ts
254
274
  import { constantCase as constantCase2 } from "change-case";
255
275
  var getAuthProps = (name) => {
@@ -364,16 +384,16 @@ var Config = /* @__PURE__ */ new Proxy(
364
384
 
365
385
  // src/lib/server/pubsub.ts
366
386
  import { hours, toSeconds } from "@awsless/duration";
367
- import { publish as publish2, QoS } from "@awsless/iot";
368
- import { stringify } from "@awsless/json";
387
+ import { publish as publish3, QoS } from "@awsless/iot";
388
+ import { stringify as stringify2 } from "@awsless/json";
369
389
  var getPubSubTopic = (name) => {
370
390
  return `${APP}/pubsub/${name}`;
371
391
  };
372
392
  var PubSub = {
373
393
  async publish(topic, event, payload, opts = {}) {
374
- await publish2({
394
+ await publish3({
375
395
  topic: getPubSubTopic(topic),
376
- payload: Buffer.from(stringify([event, payload])),
396
+ payload: Buffer.from(stringify2([event, payload])),
377
397
  ...opts
378
398
  });
379
399
  }
@@ -467,7 +487,7 @@ var Search = /* @__PURE__ */ createProxy((stack) => {
467
487
  domain,
468
488
  defineTable(tableName, schema) {
469
489
  return define(tableName, schema, () => {
470
- if (!client) client = searchClient({ node: domain }, "es");
490
+ if (!client) client = searchClient({ node: `https://${domain}` }, "es");
471
491
  return client;
472
492
  });
473
493
  }
@@ -521,6 +541,7 @@ var Table = /* @__PURE__ */ createProxy((stack) => {
521
541
  });
522
542
  export {
523
543
  APP,
544
+ Alert,
524
545
  Auth,
525
546
  Cache,
526
547
  CommandOptions,
@@ -536,6 +557,7 @@ export {
536
557
  Table,
537
558
  Task,
538
559
  Topic,
560
+ getAlertName,
539
561
  getAuthProps,
540
562
  getCacheProps,
541
563
  getConfigName,