@awsless/awsless 0.0.298 → 0.0.300
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.d.ts +1 -0
- package/dist/bin.js +112 -74
- package/dist/build-json-schema.js +18 -1
- package/dist/client.d.ts +54 -0
- package/dist/server.d.ts +101 -0
- package/dist/server.js +9 -52
- package/package.json +13 -13
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/bin.js
CHANGED
|
@@ -372,7 +372,7 @@ var debug = (...parts) => {
|
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
// src/config/app.ts
|
|
375
|
-
import { z as
|
|
375
|
+
import { z as z18 } from "zod";
|
|
376
376
|
|
|
377
377
|
// src/feature/auth/schema.ts
|
|
378
378
|
import { z as z7 } from "zod";
|
|
@@ -770,8 +770,35 @@ var InstancesSchema = z12.record(
|
|
|
770
770
|
})
|
|
771
771
|
).optional().describe("Define the instances in your stack.");
|
|
772
772
|
|
|
773
|
-
// src/feature/
|
|
773
|
+
// src/feature/pubsub/schema.ts
|
|
774
774
|
import { z as z13 } from "zod";
|
|
775
|
+
var RealTimeDefaultSchema = z13.record(
|
|
776
|
+
ResourceIdSchema,
|
|
777
|
+
z13.object({
|
|
778
|
+
auth: z13.union([
|
|
779
|
+
ResourceIdSchema,
|
|
780
|
+
z13.object({
|
|
781
|
+
authorizer: FunctionSchema
|
|
782
|
+
// ttl: AuthorizerTtl.default('1 hour'),
|
|
783
|
+
})
|
|
784
|
+
]),
|
|
785
|
+
policy: z13.object({
|
|
786
|
+
publish: z13.array(z13.string()).optional(),
|
|
787
|
+
subscribe: z13.array(z13.string()).optional()
|
|
788
|
+
})
|
|
789
|
+
})
|
|
790
|
+
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
791
|
+
var PubSubSchema = z13.record(
|
|
792
|
+
ResourceIdSchema,
|
|
793
|
+
z13.object({
|
|
794
|
+
sql: z13.string().describe("The SQL statement used to query the IOT topic."),
|
|
795
|
+
sqlVersion: z13.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."),
|
|
796
|
+
consumer: FunctionSchema.describe("The consuming lambda function properties.")
|
|
797
|
+
})
|
|
798
|
+
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
799
|
+
|
|
800
|
+
// src/feature/queue/schema.ts
|
|
801
|
+
import { z as z14 } from "zod";
|
|
775
802
|
import { days as days2, hours, minutes as minutes3, seconds as seconds2 } from "@awsless/duration";
|
|
776
803
|
import { kibibytes } from "@awsless/size";
|
|
777
804
|
var RetentionPeriodSchema = DurationSchema.refine(
|
|
@@ -801,10 +828,10 @@ var ReceiveMessageWaitTimeSchema = DurationSchema.refine(
|
|
|
801
828
|
var MaxMessageSizeSchema = SizeSchema.refine(sizeMin(kibibytes(1)), "Minimum max message size is 1 KB").refine(sizeMax(kibibytes(256)), "Maximum max message size is 256 KB").describe(
|
|
802
829
|
"The limit of how many bytes that a message can contain before Amazon SQS rejects it. You can specify an size from 1 KB to 256 KB."
|
|
803
830
|
);
|
|
804
|
-
var BatchSizeSchema =
|
|
831
|
+
var BatchSizeSchema = z14.number().int().min(1, "Minimum batch size is 1").max(1e4, "Maximum batch size is 10000").describe(
|
|
805
832
|
"The maximum number of records in each batch that Lambda pulls from your queue and sends to your function. 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). You can specify an integer from 1 to 10000."
|
|
806
833
|
);
|
|
807
|
-
var MaxConcurrencySchema =
|
|
834
|
+
var MaxConcurrencySchema = z14.number().int().min(2, "Minimum max concurrency is 2").max(1e3, "Maximum max concurrency is 1000").describe(
|
|
808
835
|
"Limits the number of concurrent instances that the queue worker can invoke. You can specify an integer from 2 to 1000."
|
|
809
836
|
);
|
|
810
837
|
var MaxBatchingWindow = DurationSchema.refine(
|
|
@@ -813,7 +840,7 @@ var MaxBatchingWindow = DurationSchema.refine(
|
|
|
813
840
|
).describe(
|
|
814
841
|
"The maximum amount of time, that Lambda spends gathering records before invoking the function. You can specify an duration from 0 seconds to 5 minutes."
|
|
815
842
|
);
|
|
816
|
-
var QueueDefaultSchema =
|
|
843
|
+
var QueueDefaultSchema = z14.object({
|
|
817
844
|
retentionPeriod: RetentionPeriodSchema.default("7 days"),
|
|
818
845
|
visibilityTimeout: VisibilityTimeoutSchema.default("30 seconds"),
|
|
819
846
|
deliveryDelay: DeliveryDelaySchema.default("0 seconds"),
|
|
@@ -823,15 +850,15 @@ var QueueDefaultSchema = z13.object({
|
|
|
823
850
|
maxConcurrency: MaxConcurrencySchema.optional(),
|
|
824
851
|
maxBatchingWindow: MaxBatchingWindow.optional()
|
|
825
852
|
}).default({});
|
|
826
|
-
var QueuesSchema =
|
|
853
|
+
var QueuesSchema = z14.record(
|
|
827
854
|
ResourceIdSchema,
|
|
828
|
-
|
|
855
|
+
z14.union([
|
|
829
856
|
LocalFileSchema.transform((file) => ({
|
|
830
857
|
consumer: {
|
|
831
858
|
file
|
|
832
859
|
}
|
|
833
860
|
})),
|
|
834
|
-
|
|
861
|
+
z14.object({
|
|
835
862
|
consumer: FunctionSchema.describe("he consuming lambda function properties."),
|
|
836
863
|
retentionPeriod: RetentionPeriodSchema.optional(),
|
|
837
864
|
visibilityTimeout: VisibilityTimeoutSchema.optional(),
|
|
@@ -846,27 +873,27 @@ var QueuesSchema = z13.record(
|
|
|
846
873
|
).optional().describe("Define the queues in your stack.");
|
|
847
874
|
|
|
848
875
|
// src/feature/rest/schema.ts
|
|
849
|
-
import { z as
|
|
876
|
+
import { z as z16 } from "zod";
|
|
850
877
|
|
|
851
878
|
// src/config/schema/route.ts
|
|
852
|
-
import { z as
|
|
853
|
-
var RouteSchema2 =
|
|
854
|
-
|
|
855
|
-
|
|
879
|
+
import { z as z15 } from "zod";
|
|
880
|
+
var RouteSchema2 = z15.union([
|
|
881
|
+
z15.string().regex(/^(POST|GET|PUT|DELETE|HEAD|OPTIONS)(\s\/[a-z0-9\+\_\-\/\{\}]*)$/gi, "Invalid route"),
|
|
882
|
+
z15.literal("$default")
|
|
856
883
|
]);
|
|
857
884
|
|
|
858
885
|
// src/feature/rest/schema.ts
|
|
859
|
-
var RestDefaultSchema =
|
|
886
|
+
var RestDefaultSchema = z16.record(
|
|
860
887
|
ResourceIdSchema,
|
|
861
|
-
|
|
888
|
+
z16.object({
|
|
862
889
|
domain: ResourceIdSchema.describe("The domain id to link your API with.").optional(),
|
|
863
|
-
subDomain:
|
|
890
|
+
subDomain: z16.string().optional()
|
|
864
891
|
})
|
|
865
892
|
).optional().describe("Define your global REST API's.");
|
|
866
|
-
var RestSchema =
|
|
893
|
+
var RestSchema = z16.record(ResourceIdSchema, z16.record(RouteSchema2, FunctionSchema)).optional().describe("Define routes in your stack for your global REST API.");
|
|
867
894
|
|
|
868
895
|
// src/config/schema/region.ts
|
|
869
|
-
import { z as
|
|
896
|
+
import { z as z17 } from "zod";
|
|
870
897
|
var US = ["us-east-2", "us-east-1", "us-west-1", "us-west-2"];
|
|
871
898
|
var AF = ["af-south-1"];
|
|
872
899
|
var AP = [
|
|
@@ -895,20 +922,20 @@ var EU = [
|
|
|
895
922
|
var ME = ["me-south-1", "me-central-1"];
|
|
896
923
|
var SA = ["sa-east-1"];
|
|
897
924
|
var regions = [...US, ...AF, ...AP, ...CA, ...EU, ...ME, ...SA];
|
|
898
|
-
var RegionSchema =
|
|
925
|
+
var RegionSchema = z17.enum(regions);
|
|
899
926
|
|
|
900
927
|
// src/config/app.ts
|
|
901
|
-
var AppSchema =
|
|
902
|
-
$schema:
|
|
928
|
+
var AppSchema = z18.object({
|
|
929
|
+
$schema: z18.string().optional(),
|
|
903
930
|
name: ResourceIdSchema.describe("App name."),
|
|
904
931
|
region: RegionSchema.describe("The AWS region to deploy to."),
|
|
905
|
-
profile:
|
|
932
|
+
profile: z18.string().describe("The AWS profile to deploy to."),
|
|
906
933
|
// stage: z
|
|
907
934
|
// .string()
|
|
908
935
|
// .regex(/^[a-z]+$/)
|
|
909
936
|
// .default('prod')
|
|
910
937
|
// .describe('The deployment stage.'),
|
|
911
|
-
defaults:
|
|
938
|
+
defaults: z18.object({
|
|
912
939
|
auth: AuthDefaultSchema,
|
|
913
940
|
domains: DomainsDefaultSchema,
|
|
914
941
|
function: FunctionDefaultSchema,
|
|
@@ -916,7 +943,8 @@ var AppSchema = z17.object({
|
|
|
916
943
|
queue: QueueDefaultSchema,
|
|
917
944
|
graphql: GraphQLDefaultSchema,
|
|
918
945
|
http: HttpDefaultSchema,
|
|
919
|
-
rest: RestDefaultSchema
|
|
946
|
+
rest: RestDefaultSchema,
|
|
947
|
+
realtime: RealTimeDefaultSchema
|
|
920
948
|
}).default({}).describe("Default properties")
|
|
921
949
|
});
|
|
922
950
|
|
|
@@ -927,8 +955,8 @@ import { glob } from "glob";
|
|
|
927
955
|
import { z as z32 } from "zod";
|
|
928
956
|
|
|
929
957
|
// src/feature/cache/schema.ts
|
|
930
|
-
import { z as
|
|
931
|
-
var TypeSchema2 =
|
|
958
|
+
import { z as z19 } from "zod";
|
|
959
|
+
var TypeSchema2 = z19.enum([
|
|
932
960
|
"t4g.small",
|
|
933
961
|
"t4g.medium",
|
|
934
962
|
"r6g.large",
|
|
@@ -943,54 +971,54 @@ var TypeSchema2 = z18.enum([
|
|
|
943
971
|
"r6gd.4xlarge",
|
|
944
972
|
"r6gd.8xlarge"
|
|
945
973
|
]);
|
|
946
|
-
var PortSchema =
|
|
947
|
-
var ShardsSchema =
|
|
948
|
-
var ReplicasPerShardSchema =
|
|
949
|
-
var EngineSchema =
|
|
950
|
-
var CachesSchema =
|
|
974
|
+
var PortSchema = z19.number().int().min(1).max(5e4);
|
|
975
|
+
var ShardsSchema = z19.number().int().min(0).max(100);
|
|
976
|
+
var ReplicasPerShardSchema = z19.number().int().min(0).max(5);
|
|
977
|
+
var EngineSchema = z19.enum(["7.0", "6.2"]);
|
|
978
|
+
var CachesSchema = z19.record(
|
|
951
979
|
ResourceIdSchema,
|
|
952
|
-
|
|
980
|
+
z19.object({
|
|
953
981
|
type: TypeSchema2.default("t4g.small"),
|
|
954
982
|
port: PortSchema.default(6379),
|
|
955
983
|
shards: ShardsSchema.default(1),
|
|
956
984
|
replicasPerShard: ReplicasPerShardSchema.default(1),
|
|
957
985
|
engine: EngineSchema.default("7.0"),
|
|
958
|
-
dataTiering:
|
|
986
|
+
dataTiering: z19.boolean().default(false)
|
|
959
987
|
})
|
|
960
988
|
).optional().describe("Define the caches in your stack. For access to the cache put your functions inside the global VPC.");
|
|
961
989
|
|
|
962
990
|
// src/feature/command/schema.ts
|
|
963
|
-
import { z as
|
|
964
|
-
var CommandSchema2 =
|
|
965
|
-
|
|
991
|
+
import { z as z20 } from "zod";
|
|
992
|
+
var CommandSchema2 = z20.union([
|
|
993
|
+
z20.object({
|
|
966
994
|
file: LocalFileSchema,
|
|
967
|
-
handler:
|
|
968
|
-
description:
|
|
995
|
+
handler: z20.string().default("default").describe("The name of the handler that needs to run"),
|
|
996
|
+
description: z20.string().optional().describe("A description of the command")
|
|
969
997
|
// options: z.record(ResourceIdSchema, OptionSchema).optional(),
|
|
970
998
|
// arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
|
|
971
999
|
}),
|
|
972
|
-
|
|
1000
|
+
z20.string().transform((file) => ({
|
|
973
1001
|
file,
|
|
974
1002
|
handler: "default",
|
|
975
1003
|
description: void 0
|
|
976
1004
|
}))
|
|
977
1005
|
]);
|
|
978
|
-
var CommandsSchema =
|
|
1006
|
+
var CommandsSchema = z20.record(ResourceIdSchema, CommandSchema2).optional().describe("Define the custom commands for your stack.");
|
|
979
1007
|
|
|
980
1008
|
// src/feature/config/schema.ts
|
|
981
|
-
import { z as
|
|
982
|
-
var ConfigNameSchema =
|
|
983
|
-
var ConfigsSchema =
|
|
1009
|
+
import { z as z21 } from "zod";
|
|
1010
|
+
var ConfigNameSchema = z21.string().regex(/[a-z0-9\-]/g, "Invalid config name");
|
|
1011
|
+
var ConfigsSchema = z21.array(ConfigNameSchema).optional().describe("Define the config values for your stack.");
|
|
984
1012
|
|
|
985
1013
|
// src/feature/cron/schema/index.ts
|
|
986
|
-
import { z as
|
|
1014
|
+
import { z as z23 } from "zod";
|
|
987
1015
|
|
|
988
1016
|
// src/feature/cron/schema/schedule.ts
|
|
989
|
-
import { z as
|
|
1017
|
+
import { z as z22 } from "zod";
|
|
990
1018
|
import { awsCronExpressionValidator } from "aws-cron-expression-validator";
|
|
991
|
-
var RateExpressionSchema =
|
|
1019
|
+
var RateExpressionSchema = z22.custom(
|
|
992
1020
|
(value) => {
|
|
993
|
-
return
|
|
1021
|
+
return z22.string().regex(/^[0-9]+ (seconds?|minutes?|hours?|days?)$/).refine((rate) => {
|
|
994
1022
|
const [str] = rate.split(" ");
|
|
995
1023
|
const number = parseInt(str);
|
|
996
1024
|
return number > 0;
|
|
@@ -1006,9 +1034,9 @@ var RateExpressionSchema = z21.custom(
|
|
|
1006
1034
|
}
|
|
1007
1035
|
return `rate(${rate})`;
|
|
1008
1036
|
});
|
|
1009
|
-
var CronExpressionSchema =
|
|
1037
|
+
var CronExpressionSchema = z22.custom(
|
|
1010
1038
|
(value) => {
|
|
1011
|
-
return
|
|
1039
|
+
return z22.string().safeParse(value).success;
|
|
1012
1040
|
},
|
|
1013
1041
|
{ message: "Invalid cron expression" }
|
|
1014
1042
|
).superRefine((value, ctx) => {
|
|
@@ -1017,12 +1045,12 @@ var CronExpressionSchema = z21.custom(
|
|
|
1017
1045
|
} catch (error) {
|
|
1018
1046
|
if (error instanceof Error) {
|
|
1019
1047
|
ctx.addIssue({
|
|
1020
|
-
code:
|
|
1048
|
+
code: z22.ZodIssueCode.custom,
|
|
1021
1049
|
message: `Invalid cron expression: ${error.message}`
|
|
1022
1050
|
});
|
|
1023
1051
|
} else {
|
|
1024
1052
|
ctx.addIssue({
|
|
1025
|
-
code:
|
|
1053
|
+
code: z22.ZodIssueCode.custom,
|
|
1026
1054
|
message: "Invalid cron expression"
|
|
1027
1055
|
});
|
|
1028
1056
|
}
|
|
@@ -1033,15 +1061,15 @@ var CronExpressionSchema = z21.custom(
|
|
|
1033
1061
|
var ScheduleExpressionSchema = RateExpressionSchema.or(CronExpressionSchema);
|
|
1034
1062
|
|
|
1035
1063
|
// src/feature/cron/schema/index.ts
|
|
1036
|
-
var CronsSchema =
|
|
1064
|
+
var CronsSchema = z23.record(
|
|
1037
1065
|
ResourceIdSchema,
|
|
1038
|
-
|
|
1039
|
-
enabled:
|
|
1066
|
+
z23.object({
|
|
1067
|
+
enabled: z23.boolean().default(true).describe("If the cron is enabled."),
|
|
1040
1068
|
consumer: FunctionSchema.describe("The consuming lambda function properties."),
|
|
1041
1069
|
schedule: ScheduleExpressionSchema.describe(
|
|
1042
1070
|
'The scheduling expression.\n\nexample: "0 20 * * ? *"\nexample: "5 minutes"'
|
|
1043
1071
|
),
|
|
1044
|
-
payload:
|
|
1072
|
+
payload: z23.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
1045
1073
|
})
|
|
1046
1074
|
).optional();
|
|
1047
1075
|
|
|
@@ -1050,17 +1078,6 @@ var OnFailureSchema = FunctionSchema.optional().describe(
|
|
|
1050
1078
|
"Defining a onFailure handler will add a global onFailure handler for the following resources:\n- Async lambda functions\n- SQS queues\n- DynamoDB streams"
|
|
1051
1079
|
);
|
|
1052
1080
|
|
|
1053
|
-
// src/feature/pubsub/schema.ts
|
|
1054
|
-
import { z as z23 } from "zod";
|
|
1055
|
-
var PubSubSchema = z23.record(
|
|
1056
|
-
ResourceIdSchema,
|
|
1057
|
-
z23.object({
|
|
1058
|
-
sql: z23.string().describe("The SQL statement used to query the IOT topic."),
|
|
1059
|
-
sqlVersion: z23.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."),
|
|
1060
|
-
consumer: FunctionSchema.describe("The consuming lambda function properties.")
|
|
1061
|
-
})
|
|
1062
|
-
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
1063
|
-
|
|
1064
1081
|
// src/feature/search/schema.ts
|
|
1065
1082
|
import { gibibytes as gibibytes2 } from "@awsless/size";
|
|
1066
1083
|
import { z as z24 } from "zod";
|
|
@@ -2035,13 +2052,13 @@ var hasOnFailure = (stacks) => {
|
|
|
2035
2052
|
};
|
|
2036
2053
|
|
|
2037
2054
|
// src/feature/function/build/typescript/bundle.ts
|
|
2038
|
-
import { rollup } from "rollup";
|
|
2039
|
-
import { createHash } from "crypto";
|
|
2040
|
-
import { swc, minify as swcMinify } from "rollup-plugin-swc3";
|
|
2041
|
-
import json from "@rollup/plugin-json";
|
|
2042
2055
|
import commonjs from "@rollup/plugin-commonjs";
|
|
2056
|
+
import json from "@rollup/plugin-json";
|
|
2043
2057
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
2058
|
+
import { createHash } from "crypto";
|
|
2044
2059
|
import { dirname as dirname5 } from "path";
|
|
2060
|
+
import { rollup } from "rollup";
|
|
2061
|
+
import { minify as swcMinify, swc } from "rollup-plugin-swc3";
|
|
2045
2062
|
var bundleTypeScript = async ({ format: format2 = "esm", minify = true, file }) => {
|
|
2046
2063
|
const bundle = await rollup({
|
|
2047
2064
|
input: file,
|
|
@@ -3704,10 +3721,29 @@ import { aws as aws12, Node as Node11 } from "@awsless/formation";
|
|
|
3704
3721
|
var pubsubFeature = defineFeature({
|
|
3705
3722
|
name: "pubsub",
|
|
3706
3723
|
onApp(ctx) {
|
|
3724
|
+
for (const [id, props] of Object.entries(ctx.appConfig.defaults.realtime ?? {})) {
|
|
3725
|
+
const group = new Node11(ctx.base, "pubsub", id);
|
|
3726
|
+
const functionProps = typeof props.auth === "string" ? { file: "" } : props.auth.authorizer;
|
|
3727
|
+
const { lambda } = createLambdaFunction(group, ctx, "pubsub-auth", id, functionProps);
|
|
3728
|
+
lambda.addEnvironment("PUBSUB_POLICY", JSON.stringify(props.policy));
|
|
3729
|
+
lambda.addEnvironment("AWS_ACCOUNT_ID", ctx.accountId);
|
|
3730
|
+
const authorizer = new aws12.iot.Authorizer(group, "auth", {
|
|
3731
|
+
name: "test",
|
|
3732
|
+
functionArn: lambda.arn,
|
|
3733
|
+
enableSigning: false
|
|
3734
|
+
});
|
|
3735
|
+
const permission = new aws12.lambda.Permission(group, "permission", {
|
|
3736
|
+
functionArn: lambda.arn,
|
|
3737
|
+
principal: "iot.amazonaws.com",
|
|
3738
|
+
sourceArn: authorizer.arn,
|
|
3739
|
+
action: "lambda:InvokeFunction"
|
|
3740
|
+
});
|
|
3741
|
+
}
|
|
3707
3742
|
ctx.onPolicy((policy) => {
|
|
3708
3743
|
policy.addStatement({
|
|
3709
3744
|
actions: [`iot:Publish`],
|
|
3710
3745
|
resources: [`arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/*`]
|
|
3746
|
+
// resources: [`arn:aws:iot:${ctx.appConfig.region}:${ctx.accountId}:topic/${ctx.app.name}/*`],
|
|
3711
3747
|
});
|
|
3712
3748
|
});
|
|
3713
3749
|
},
|
|
@@ -3932,8 +3968,9 @@ var searchFeature = defineFeature({
|
|
|
3932
3968
|
onStack(ctx) {
|
|
3933
3969
|
for (const [id, props] of Object.entries(ctx.stackConfig.searchs ?? {})) {
|
|
3934
3970
|
const group = new Node14(ctx.stack, "search", id);
|
|
3971
|
+
const name = `${id}-${shortId([ctx.app.name, ctx.stack.name, this.name, id].join("--"))}`;
|
|
3935
3972
|
const openSearch = new aws15.openSearch.Domain(group, "domain", {
|
|
3936
|
-
name
|
|
3973
|
+
name,
|
|
3937
3974
|
version: props.version,
|
|
3938
3975
|
storageSize: props.storage,
|
|
3939
3976
|
instance: {
|
|
@@ -3943,8 +3980,9 @@ var searchFeature = defineFeature({
|
|
|
3943
3980
|
accessPolicy: {
|
|
3944
3981
|
statements: [
|
|
3945
3982
|
{
|
|
3946
|
-
principal: "
|
|
3947
|
-
|
|
3983
|
+
principal: { AWS: "*" },
|
|
3984
|
+
resources: [`arn:aws:es:${ctx.appConfig.region}:${ctx.accountId}:domain/${name}/*`],
|
|
3985
|
+
principalArn: `arn:aws:iam::${ctx.accountId}:role/${ctx.app.name}--${ctx.stack.name}--*`
|
|
3948
3986
|
}
|
|
3949
3987
|
]
|
|
3950
3988
|
}
|
|
@@ -3961,7 +3999,7 @@ var searchFeature = defineFeature({
|
|
|
3961
3999
|
ctx.addEnv(`SEARCH_${constantCase8(ctx.stack.name)}_${constantCase8(id)}_DOMAIN`, openSearch.domainEndpoint);
|
|
3962
4000
|
ctx.onPolicy((policy) => {
|
|
3963
4001
|
policy.addStatement({
|
|
3964
|
-
actions: ["es
|
|
4002
|
+
actions: ["es:ESHttp*"],
|
|
3965
4003
|
resources: [openSearch.arn]
|
|
3966
4004
|
});
|
|
3967
4005
|
});
|
|
@@ -529,6 +529,22 @@ var OnFailureSchema = FunctionSchema.optional().describe(
|
|
|
529
529
|
|
|
530
530
|
// src/feature/pubsub/schema.ts
|
|
531
531
|
import { z as z17 } from "zod";
|
|
532
|
+
var RealTimeDefaultSchema = z17.record(
|
|
533
|
+
ResourceIdSchema,
|
|
534
|
+
z17.object({
|
|
535
|
+
auth: z17.union([
|
|
536
|
+
ResourceIdSchema,
|
|
537
|
+
z17.object({
|
|
538
|
+
authorizer: FunctionSchema
|
|
539
|
+
// ttl: AuthorizerTtl.default('1 hour'),
|
|
540
|
+
})
|
|
541
|
+
]),
|
|
542
|
+
policy: z17.object({
|
|
543
|
+
publish: z17.array(z17.string()).optional(),
|
|
544
|
+
subscribe: z17.array(z17.string()).optional()
|
|
545
|
+
})
|
|
546
|
+
})
|
|
547
|
+
).optional().describe("Define the pubsub subscriber in your stack.");
|
|
532
548
|
var PubSubSchema = z17.record(
|
|
533
549
|
ResourceIdSchema,
|
|
534
550
|
z17.object({
|
|
@@ -1097,7 +1113,8 @@ var AppSchema = z32.object({
|
|
|
1097
1113
|
queue: QueueDefaultSchema,
|
|
1098
1114
|
graphql: GraphQLDefaultSchema,
|
|
1099
1115
|
http: HttpDefaultSchema,
|
|
1100
|
-
rest: RestDefaultSchema
|
|
1116
|
+
rest: RestDefaultSchema,
|
|
1117
|
+
realtime: RealTimeDefaultSchema
|
|
1101
1118
|
}).default({}).describe("Default properties")
|
|
1102
1119
|
});
|
|
1103
1120
|
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
interface AuthResources {
|
|
2
|
+
}
|
|
3
|
+
declare const Auth: AuthResources;
|
|
4
|
+
declare const getAuthProps: (name: string) => {
|
|
5
|
+
readonly userPoolId: string;
|
|
6
|
+
readonly clientId: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
interface GraphQLSchema {
|
|
10
|
+
}
|
|
11
|
+
interface GraphQLResources {
|
|
12
|
+
}
|
|
13
|
+
declare const GraphQL: GraphQLResources;
|
|
14
|
+
declare const getGraphQLProps: (name: string) => {
|
|
15
|
+
endpoint: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface HTTP {
|
|
19
|
+
}
|
|
20
|
+
type Method = 'GET' | 'POST';
|
|
21
|
+
type Path = string;
|
|
22
|
+
type Params = Record<string, string | number>;
|
|
23
|
+
type Query = Record<string, string>;
|
|
24
|
+
type Body = unknown;
|
|
25
|
+
type Route = {
|
|
26
|
+
param?: Params;
|
|
27
|
+
query?: Query;
|
|
28
|
+
body?: Body;
|
|
29
|
+
response: unknown;
|
|
30
|
+
};
|
|
31
|
+
type Routes = Record<Path, Route>;
|
|
32
|
+
type Schema = Partial<Record<Method, Routes>>;
|
|
33
|
+
type GetRoute<S extends Schema, M extends keyof S, P extends keyof S[M]> = S[M] extends Routes ? S[M][P] : never;
|
|
34
|
+
type Props<R extends Route> = {
|
|
35
|
+
headers?: Record<string, string>;
|
|
36
|
+
params?: R['param'] extends Params ? R['param'] : never;
|
|
37
|
+
query?: R['query'] extends Query ? R['query'] : never;
|
|
38
|
+
body?: R['body'] extends Body ? R['body'] : never;
|
|
39
|
+
};
|
|
40
|
+
type HttpFetcher = (props: {
|
|
41
|
+
method: Method;
|
|
42
|
+
path: Path;
|
|
43
|
+
headers: Headers;
|
|
44
|
+
query?: Query;
|
|
45
|
+
body?: Body;
|
|
46
|
+
}) => unknown;
|
|
47
|
+
declare const createHttpFetcher: (host: string) => HttpFetcher;
|
|
48
|
+
declare const createHttpClient: <S extends Partial<Record<Method, Routes>>>(fetcher: HttpFetcher) => {
|
|
49
|
+
fetch: <M extends keyof S, P extends keyof S[M]>(method: M, routeKey: Extract<P, string>, props?: Props<GetRoute<S, M, P>> | undefined) => Promise<GetRoute<S, M, P>["response"]>;
|
|
50
|
+
get<P_1 extends keyof S["GET"]>(routeKey: Extract<P_1, string>, props?: Props<GetRoute<S, "GET", P_1>> | undefined): Promise<GetRoute<S, "GET", P_1>["response"]>;
|
|
51
|
+
post<P_2 extends keyof S["POST"]>(routeKey: Extract<P_2, string>, props?: Props<GetRoute<S, "POST", P_2>> | undefined): Promise<GetRoute<S, "POST", P_2>["response"]>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { Auth, AuthResources, GraphQL, GraphQLResources, GraphQLSchema, HTTP, HttpFetcher, createHttpClient, createHttpFetcher, getAuthProps, getGraphQLProps };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
|
|
2
|
+
|
|
3
|
+
declare const regions: readonly ["us-east-2", "us-east-1", "us-west-1", "us-west-2", "af-south-1", "ap-east-1", "ap-south-2", "ap-southeast-3", "ap-southeast-4", "ap-south-1", "ap-northeast-3", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-south-1", "eu-west-3", "eu-south-2", "eu-north-1", "eu-central-2", "me-south-1", "me-central-1", "sa-east-1"];
|
|
4
|
+
type Region = (typeof regions)[number];
|
|
5
|
+
|
|
6
|
+
type Credentials = AwsCredentialIdentityProvider;
|
|
7
|
+
|
|
8
|
+
type CommandContext = {
|
|
9
|
+
region: Region;
|
|
10
|
+
credentials: Credentials;
|
|
11
|
+
accountId: string;
|
|
12
|
+
update: (msg: string) => void;
|
|
13
|
+
};
|
|
14
|
+
type CommandHandler = (options: CommandOptions, context: CommandContext) => Promise<string | undefined | void>;
|
|
15
|
+
declare class CommandOptions {
|
|
16
|
+
private opts;
|
|
17
|
+
constructor(args: string[]);
|
|
18
|
+
get(name: string): any;
|
|
19
|
+
private getAssertType;
|
|
20
|
+
number(name: string): number;
|
|
21
|
+
string(name: string): string;
|
|
22
|
+
boolean(name: string): boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface FunctionMock {
|
|
26
|
+
}
|
|
27
|
+
interface FunctionMockResponse {
|
|
28
|
+
}
|
|
29
|
+
declare const mockFunction: (cb: (mock: FunctionMock) => void) => FunctionMockResponse;
|
|
30
|
+
|
|
31
|
+
interface QueueMock {
|
|
32
|
+
}
|
|
33
|
+
interface QueueMockResponse {
|
|
34
|
+
}
|
|
35
|
+
declare const mockQueue: (cb: (mock: QueueMock) => void) => QueueMockResponse;
|
|
36
|
+
|
|
37
|
+
interface TaskMock {
|
|
38
|
+
}
|
|
39
|
+
interface TaskMockResponse {
|
|
40
|
+
}
|
|
41
|
+
declare const mockTask: (cb: (mock: TaskMock) => void) => TaskMockResponse;
|
|
42
|
+
|
|
43
|
+
interface TopicMock {
|
|
44
|
+
}
|
|
45
|
+
interface TopicMockResponse {
|
|
46
|
+
}
|
|
47
|
+
declare const mockTopic: (cb: (mock: TopicMock) => void) => TopicMockResponse;
|
|
48
|
+
|
|
49
|
+
declare const getCacheProps: (name: string, stack?: string) => {
|
|
50
|
+
readonly host: string;
|
|
51
|
+
readonly port: number;
|
|
52
|
+
};
|
|
53
|
+
interface CacheResources {
|
|
54
|
+
}
|
|
55
|
+
declare const Cache: CacheResources;
|
|
56
|
+
|
|
57
|
+
declare const getConfigName: (name: string) => string;
|
|
58
|
+
interface ConfigResources {
|
|
59
|
+
}
|
|
60
|
+
declare const Config: ConfigResources;
|
|
61
|
+
|
|
62
|
+
declare const getFunctionName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--function--${N}`;
|
|
63
|
+
interface FunctionResources {
|
|
64
|
+
}
|
|
65
|
+
declare const Function: FunctionResources;
|
|
66
|
+
declare const Fn: FunctionResources;
|
|
67
|
+
|
|
68
|
+
declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--queue--${N}`;
|
|
69
|
+
interface QueueResources {
|
|
70
|
+
}
|
|
71
|
+
declare const Queue: QueueResources;
|
|
72
|
+
|
|
73
|
+
declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--search--${N}`;
|
|
74
|
+
interface SearchResources {
|
|
75
|
+
}
|
|
76
|
+
declare const Search: SearchResources;
|
|
77
|
+
|
|
78
|
+
declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--store--${N}`;
|
|
79
|
+
interface StoreResources {
|
|
80
|
+
}
|
|
81
|
+
declare const Store: StoreResources;
|
|
82
|
+
|
|
83
|
+
declare const getTableName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--table--${N}`;
|
|
84
|
+
interface TableResources {
|
|
85
|
+
}
|
|
86
|
+
declare const Table: TableResources;
|
|
87
|
+
|
|
88
|
+
declare const getTaskName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--task--${N}`;
|
|
89
|
+
interface TaskResources {
|
|
90
|
+
}
|
|
91
|
+
declare const Task: TaskResources;
|
|
92
|
+
|
|
93
|
+
declare const getTopicName: <N extends string>(name: N) => `app--topic--${N}`;
|
|
94
|
+
interface TopicResources {
|
|
95
|
+
}
|
|
96
|
+
declare const Topic: TopicResources;
|
|
97
|
+
|
|
98
|
+
declare const APP: "app";
|
|
99
|
+
declare const STACK: "stack";
|
|
100
|
+
|
|
101
|
+
export { APP, Cache, CacheResources, CommandContext, CommandHandler, CommandOptions, Config, ConfigResources, Fn, Function, FunctionMock, FunctionMockResponse, FunctionResources, Queue, QueueMock, QueueMockResponse, QueueResources, STACK, Search, SearchResources, Store, StoreResources, Table, TableResources, Task, TaskMock, TaskMockResponse, TaskResources, Topic, TopicMock, TopicMockResponse, TopicResources, getCacheProps, getConfigName, getFunctionName, getQueueName, getSearchName, getStoreName, getTableName, getTaskName, getTopicName, mockFunction, mockQueue, mockTask, mockTopic };
|