@awsless/awsless 0.0.581 → 0.0.583

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -994,36 +994,38 @@ var OnLogDefaultSchema = z17.union([
994
994
  })
995
995
  ]).optional().describe("Define a subscription on all Lambda functions logs.");
996
996
 
997
- // src/feature/pubsub/appsync/schema.ts
997
+ // src/feature/pubsub/schema.ts
998
998
  import { z as z18 } from "zod";
999
999
  var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
1000
1000
  var PubSubDefaultSchema = z18.record(
1001
1001
  ResourceIdSchema,
1002
1002
  z18.object({
1003
- auth: FunctionSchema.describe("The authentication function for the pubsub API."),
1003
+ auth: FunctionSchema,
1004
1004
  domain: DomainSchema.optional(),
1005
- subDomain: z18.string().optional(),
1006
- namespaces: z18.array(z18.string()).optional().describe('The namespaces for the PubSub API. If not set, a single "default" namespace is created.'),
1007
- logLevel: z18.enum(["none", "info", "error", "debug", "all"]).optional().describe("The logging level for AppSync API. When set, logging is enabled.")
1005
+ subDomain: z18.string().optional()
1006
+ // auth: z.union([
1007
+ // ResourceIdSchema,
1008
+ // z.object({
1009
+ // authorizer: FunctionSchema,
1010
+ // // ttl: AuthorizerTtl.default('1 hour'),
1011
+ // }),
1012
+ // ]),
1013
+ // policy: z
1014
+ // .object({
1015
+ // publish: z.array(z.string()).optional(),
1016
+ // subscribe: z.array(z.string()).optional(),
1017
+ // })
1018
+ // .optional(),
1008
1019
  })
1009
- ).optional().describe("Define the pubsub API configuration in your stack.");
1020
+ ).optional().describe("Define the pubsub subscriber in your stack.");
1010
1021
  var PubSubSchema = z18.record(
1011
1022
  ResourceIdSchema,
1012
1023
  z18.object({
1013
- channels: z18.array(z18.string()).describe("The event channels this subscriber listens to."),
1014
- filter: z18.object({
1015
- eventType: z18.string().optional().describe("Filter events by event type.")
1016
- // Add more filter options as needed
1017
- // userId: z.string().optional(),
1018
- // custom: z.record(z.string(), z.any()).optional(),
1019
- }).optional().describe("Event filtering options."),
1020
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
1021
- batchSize: z18.number().int().min(1).max(100).default(1).describe("Number of events to batch before invoking the consumer function."),
1022
- retryPolicy: z18.object({
1023
- maxRetries: z18.number().int().min(0).max(3).default(2).describe("Maximum number of retry attempts.")
1024
- }).optional().describe("Retry policy for failed event processing.")
1024
+ sql: z18.string().describe("The SQL statement used to query the IOT topic."),
1025
+ sqlVersion: z18.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
1026
+ consumer: FunctionSchema.describe("The consuming lambda function properties.")
1025
1027
  })
1026
- ).optional().describe("Define the pubsub event subscribers in your stack.");
1028
+ ).optional().describe("Define the pubsub subscriber in your stack.");
1027
1029
 
1028
1030
  // src/feature/queue/schema.ts
1029
1031
  import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
@@ -1153,7 +1155,24 @@ var RpcDefaultSchema = z22.record(
1153
1155
  geoRestrictions: z22.array(z22.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
1154
1156
  })
1155
1157
  ).describe(`Define the global RPC API's.`).optional();
1156
- var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1158
+ var PermissionsSchema2 = z22.union([
1159
+ //
1160
+ z22.string().transform((v) => [v]),
1161
+ z22.string().array()
1162
+ ]).default([]).describe(
1163
+ "Specifies a list of permissions that can be used inside your custom authorizer function to determine if the user has access to this specific RPC function."
1164
+ );
1165
+ var EntrySchema = z22.union([
1166
+ FunctionSchema.transform((props) => ({
1167
+ function: props,
1168
+ permissions: []
1169
+ })),
1170
+ z22.object({
1171
+ function: FunctionSchema,
1172
+ permissions: PermissionsSchema2
1173
+ })
1174
+ ]);
1175
+ var RpcSchema = z22.record(ResourceIdSchema, z22.record(z22.string(), EntrySchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
1157
1176
 
1158
1177
  // src/feature/instance/schema.ts
1159
1178
  import { days as days3, toDays as toDays2 } from "@awsless/duration";
@@ -1225,7 +1244,7 @@ var PermissionSchema2 = z23.object({
1225
1244
  actions: ActionsSchema2,
1226
1245
  resources: ResourcesSchema2
1227
1246
  });
1228
- var PermissionsSchema2 = z23.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
1247
+ var PermissionsSchema3 = z23.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
1229
1248
  var DescriptionSchema2 = z23.string().describe("A description of the instance.");
1230
1249
  var ImageSchema = z23.string().optional().describe("The URL of the container image to use.");
1231
1250
  var validLogRetentionDays2 = [
@@ -1267,7 +1286,7 @@ var ISchema = z23.object({
1267
1286
  memorySize: MemorySizeSchema2.optional(),
1268
1287
  architecture: ArchitectureSchema3.optional(),
1269
1288
  environment: EnvironmentSchema2.optional(),
1270
- permissions: PermissionsSchema2.optional(),
1289
+ permissions: PermissionsSchema3.optional(),
1271
1290
  healthCheck: HealthCheckSchema.optional()
1272
1291
  // restartPolicy: RestartPolicySchema.optional(),
1273
1292
  });
@@ -1284,7 +1303,7 @@ var InstanceDefaultSchema = z23.object({
1284
1303
  memorySize: MemorySizeSchema2.default("512 MB"),
1285
1304
  architecture: ArchitectureSchema3.default("arm64"),
1286
1305
  environment: EnvironmentSchema2.optional(),
1287
- permissions: PermissionsSchema2.optional(),
1306
+ permissions: PermissionsSchema3.optional(),
1288
1307
  healthCheck: HealthCheckSchema.optional(),
1289
1308
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
1290
1309
  log: LogSchema2.default(true).transform((log26) => ({
@@ -2490,7 +2509,6 @@ var authFeature = defineFeature({
2490
2509
  resourceType: "auth",
2491
2510
  resourceName: id
2492
2511
  });
2493
- props.username;
2494
2512
  const userPool = new $.aws.cognito.UserPool(
2495
2513
  group,
2496
2514
  "user-pool",
@@ -3029,6 +3047,7 @@ var bundleTypeScript = async ({
3029
3047
  }
3030
3048
  const code = Buffer.from(item.code, "utf8");
3031
3049
  const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
3050
+ item.map?.version;
3032
3051
  hash.update(code);
3033
3052
  files.push({
3034
3053
  name: item.fileName,
@@ -4528,8 +4547,8 @@ var rpcFeature = defineFeature({
4528
4547
  const schema = new TypeObject(2);
4529
4548
  for (const stack of ctx.stackConfigs) {
4530
4549
  for (const [name, props] of Object.entries(stack.rpc?.[id] ?? {})) {
4531
- if ("file" in props.code) {
4532
- const relFile = relative5(directories.types, props.code.file);
4550
+ if ("file" in props.function.code) {
4551
+ const relFile = relative5(directories.types, props.function.code.file);
4533
4552
  const varName = camelCase5(`${stack.name}-${name}`);
4534
4553
  types2.addImport(varName, relFile);
4535
4554
  schema.addType(name, `Handle<typeof ${varName}>`);
@@ -4558,7 +4577,7 @@ var rpcFeature = defineFeature({
4558
4577
  } else {
4559
4578
  list3.add(name);
4560
4579
  }
4561
- const timeout = toSeconds5(props.timeout ?? ctx.appConfig.defaults.function.timeout);
4580
+ const timeout = toSeconds5(props.function.timeout ?? ctx.appConfig.defaults.function.timeout);
4562
4581
  const maxTimeout = toSeconds5(ctx.appConfig.defaults.rpc[id].timeout) * 0.8;
4563
4582
  if (timeout > maxTimeout) {
4564
4583
  throw new FileError(
@@ -4784,7 +4803,7 @@ var rpcFeature = defineFeature({
4784
4803
  const queryGroup = new Group13(group, "query", name);
4785
4804
  const entryId = kebabCase6(`${id}-${shortId(name)}`);
4786
4805
  createLambdaFunction(queryGroup, ctx, `rpc`, entryId, {
4787
- ...props,
4806
+ ...props.function,
4788
4807
  description: `${id} ${name}`
4789
4808
  });
4790
4809
  new $13.aws.dynamodb.TableItem(queryGroup, "query", {
@@ -4800,6 +4819,11 @@ var rpcFeature = defineFeature({
4800
4819
  resourceType: "rpc",
4801
4820
  resourceName: entryId
4802
4821
  })
4822
+ },
4823
+ permissions: {
4824
+ L: props.permissions.map((permission) => ({
4825
+ S: permission
4826
+ }))
4803
4827
  }
4804
4828
  })
4805
4829
  });
@@ -389,36 +389,38 @@ var OnLogDefaultSchema = z14.union([
389
389
  })
390
390
  ]).optional().describe("Define a subscription on all Lambda functions logs.");
391
391
 
392
- // src/feature/pubsub/appsync/schema.ts
392
+ // src/feature/pubsub/schema.ts
393
393
  import { z as z15 } from "zod";
394
394
  var DomainSchema = ResourceIdSchema.describe("The domain id to link your Pubsub API with.");
395
395
  var PubSubDefaultSchema = z15.record(
396
396
  ResourceIdSchema,
397
397
  z15.object({
398
- auth: FunctionSchema.describe("The authentication function for the pubsub API."),
398
+ auth: FunctionSchema,
399
399
  domain: DomainSchema.optional(),
400
- subDomain: z15.string().optional(),
401
- namespaces: z15.array(z15.string()).optional().describe('The namespaces for the PubSub API. If not set, a single "default" namespace is created.'),
402
- logLevel: z15.enum(["none", "info", "error", "debug", "all"]).optional().describe("The logging level for AppSync API. When set, logging is enabled.")
400
+ subDomain: z15.string().optional()
401
+ // auth: z.union([
402
+ // ResourceIdSchema,
403
+ // z.object({
404
+ // authorizer: FunctionSchema,
405
+ // // ttl: AuthorizerTtl.default('1 hour'),
406
+ // }),
407
+ // ]),
408
+ // policy: z
409
+ // .object({
410
+ // publish: z.array(z.string()).optional(),
411
+ // subscribe: z.array(z.string()).optional(),
412
+ // })
413
+ // .optional(),
403
414
  })
404
- ).optional().describe("Define the pubsub API configuration in your stack.");
415
+ ).optional().describe("Define the pubsub subscriber in your stack.");
405
416
  var PubSubSchema = z15.record(
406
417
  ResourceIdSchema,
407
418
  z15.object({
408
- channels: z15.array(z15.string()).describe("The event channels this subscriber listens to."),
409
- filter: z15.object({
410
- eventType: z15.string().optional().describe("Filter events by event type.")
411
- // Add more filter options as needed
412
- // userId: z.string().optional(),
413
- // custom: z.record(z.string(), z.any()).optional(),
414
- }).optional().describe("Event filtering options."),
415
- consumer: FunctionSchema.describe("The consuming lambda function properties."),
416
- batchSize: z15.number().int().min(1).max(100).default(1).describe("Number of events to batch before invoking the consumer function."),
417
- retryPolicy: z15.object({
418
- maxRetries: z15.number().int().min(0).max(3).default(2).describe("Maximum number of retry attempts.")
419
- }).optional().describe("Retry policy for failed event processing.")
419
+ sql: z15.string().describe("The SQL statement used to query the IOT topic."),
420
+ sqlVersion: z15.enum(["2015-10-08", "2016-03-23", "beta"]).default("2016-03-23").describe("The version of the SQL rules engine to use when evaluating the rule."),
421
+ consumer: FunctionSchema.describe("The consuming lambda function properties.")
420
422
  })
421
- ).optional().describe("Define the pubsub event subscribers in your stack.");
423
+ ).optional().describe("Define the pubsub subscriber in your stack.");
422
424
 
423
425
  // src/feature/queue/schema.ts
424
426
  import { days as days2, hours, minutes as minutes2, seconds as seconds2 } from "@awsless/duration";
@@ -548,7 +550,24 @@ var RpcDefaultSchema = z19.record(
548
550
  geoRestrictions: z19.array(z19.string().length(2).toUpperCase()).default([]).describe("Specifies a blacklist of countries that should be blocked.")
549
551
  })
550
552
  ).describe(`Define the global RPC API's.`).optional();
551
- var RpcSchema = z19.record(ResourceIdSchema, z19.record(z19.string(), FunctionSchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
553
+ var PermissionsSchema2 = z19.union([
554
+ //
555
+ z19.string().transform((v) => [v]),
556
+ z19.string().array()
557
+ ]).default([]).describe(
558
+ "Specifies a list of permissions that can be used inside your custom authorizer function to determine if the user has access to this specific RPC function."
559
+ );
560
+ var EntrySchema = z19.union([
561
+ FunctionSchema.transform((props) => ({
562
+ function: props,
563
+ permissions: []
564
+ })),
565
+ z19.object({
566
+ function: FunctionSchema,
567
+ permissions: PermissionsSchema2
568
+ })
569
+ ]);
570
+ var RpcSchema = z19.record(ResourceIdSchema, z19.record(z19.string(), EntrySchema).describe("The queries for your global RPC API.")).describe("Define the schema in your stack for your global RPC API.").optional();
552
571
 
553
572
  // src/feature/instance/schema.ts
554
573
  import { days as days3, toDays as toDays2 } from "@awsless/duration";
@@ -620,7 +639,7 @@ var PermissionSchema2 = z20.object({
620
639
  actions: ActionsSchema2,
621
640
  resources: ResourcesSchema2
622
641
  });
623
- var PermissionsSchema2 = z20.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
642
+ var PermissionsSchema3 = z20.union([PermissionSchema2.transform((v) => [v]), PermissionSchema2.array()]).describe("Add IAM permissions to your instance.");
624
643
  var DescriptionSchema2 = z20.string().describe("A description of the instance.");
625
644
  var ImageSchema = z20.string().optional().describe("The URL of the container image to use.");
626
645
  var validLogRetentionDays2 = [
@@ -662,7 +681,7 @@ var ISchema = z20.object({
662
681
  memorySize: MemorySizeSchema2.optional(),
663
682
  architecture: ArchitectureSchema3.optional(),
664
683
  environment: EnvironmentSchema2.optional(),
665
- permissions: PermissionsSchema2.optional(),
684
+ permissions: PermissionsSchema3.optional(),
666
685
  healthCheck: HealthCheckSchema.optional()
667
686
  // restartPolicy: RestartPolicySchema.optional(),
668
687
  });
@@ -679,7 +698,7 @@ var InstanceDefaultSchema = z20.object({
679
698
  memorySize: MemorySizeSchema2.default("512 MB"),
680
699
  architecture: ArchitectureSchema3.default("arm64"),
681
700
  environment: EnvironmentSchema2.optional(),
682
- permissions: PermissionsSchema2.optional(),
701
+ permissions: PermissionsSchema3.optional(),
683
702
  healthCheck: HealthCheckSchema.optional(),
684
703
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
685
704
  log: LogSchema2.default(true).transform((log) => ({
Binary file
Binary file
@@ -1 +1 @@
1
- 809ac79b62f213f5ced66b7a051b247cda10444b
1
+ f25c05904c0f9349537dd7cb51577a1befa4c1af
Binary file
package/dist/prebuild.js CHANGED
@@ -118,6 +118,7 @@ var bundleTypeScript = async ({
118
118
  }
119
119
  const code = Buffer.from(item.code, "utf8");
120
120
  const map = item.map ? Buffer.from(item.map.toString(), "utf8") : void 0;
121
+ item.map?.version;
121
122
  hash.update(code);
122
123
  files.push({
123
124
  name: item.fileName,
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
2
2
  import * as vitest from 'vitest';
3
- import { Duration, DurationFormat } from '@awsless/duration';
3
+ import { Duration } from '@awsless/duration';
4
4
  import { QoS } from '@awsless/iot';
5
5
  export { QoS } from '@awsless/iot';
6
6
  import { IoTCustomAuthorizerResult } from 'aws-lambda';
@@ -131,7 +131,8 @@ type RpcAuthorizerResponse = {
131
131
  authorized: true;
132
132
  context?: unknown;
133
133
  lockKey?: string;
134
- ttl: DurationFormat;
134
+ permissions?: string[];
135
+ ttl: Duration;
135
136
  };
136
137
 
137
138
  declare const getSearchName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--search--${N}`;
@@ -142,9 +143,9 @@ interface SearchResources {
142
143
  }
143
144
  declare const Search: SearchResources;
144
145
 
145
- declare const getSiteBucketName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--site--${N}--${string}`;
146
+ declare const getSiteBucketName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--site--${N}--app-id`;
146
147
 
147
- declare const getStoreName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--store--${N}--${string}`;
148
+ declare const getStoreName: <N extends string, S extends string = "stack">(resourceName: N, stackName?: S) => `app--${S}--store--${N}--app-id`;
148
149
  interface StoreResources {
149
150
  }
150
151
  declare const Store: StoreResources;
package/dist/server.js CHANGED
@@ -12,6 +12,7 @@ import { publish } from "@awsless/sns";
12
12
  // src/lib/server/util.ts
13
13
  import { kebabCase } from "change-case";
14
14
  var APP = process.env.APP ?? "app";
15
+ var APP_ID = process.env.APP_ID ?? "app-id";
15
16
  var STACK = process.env.STACK ?? "stack";
16
17
  var IS_TEST = process.env.NODE_ENV === "test";
17
18
  var build = (opt) => {
@@ -617,11 +618,11 @@ var Search = /* @__PURE__ */ createProxy((stack) => {
617
618
  });
618
619
 
619
620
  // src/lib/server/site.ts
620
- var getSiteBucketName = bindPostfixedLocalResourceName("site", process.env.APP_ID);
621
+ var getSiteBucketName = bindPostfixedLocalResourceName("site", APP_ID);
621
622
 
622
623
  // src/lib/server/store.ts
623
624
  import { deleteObject, getObject, headObject, putObject } from "@awsless/s3";
624
- var getStoreName = bindPostfixedLocalResourceName("store", process.env.APP_ID);
625
+ var getStoreName = bindPostfixedLocalResourceName("store", APP_ID);
625
626
  var Store = /* @__PURE__ */ createProxy((stack) => {
626
627
  return createProxy((name) => {
627
628
  const bucket = getStoreName(name, stack);