@awsless/awsless 0.0.311 → 0.0.313
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.d.ts +1 -0
- package/dist/bin.js +28 -17
- package/dist/build-json-schema.js +2 -2
- package/dist/client.d.ts +54 -0
- package/dist/server.d.ts +121 -0
- package/dist/server.js +4 -0
- package/dist/stack.json +1 -1
- package/package.json +7 -7
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/bin.js
CHANGED
|
@@ -1068,7 +1068,7 @@ var CronsSchema = z23.record(
|
|
|
1068
1068
|
),
|
|
1069
1069
|
payload: z23.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
1070
1070
|
})
|
|
1071
|
-
).optional();
|
|
1071
|
+
).optional().describe(`Define the cron jobs in your stack.`);
|
|
1072
1072
|
|
|
1073
1073
|
// src/feature/on-failure/schema.ts
|
|
1074
1074
|
var OnFailureSchema = FunctionSchema.optional().describe(
|
|
@@ -1187,7 +1187,7 @@ var ErrorResponseSchema = z25.union([
|
|
|
1187
1187
|
var SitesSchema = z25.record(
|
|
1188
1188
|
ResourceIdSchema,
|
|
1189
1189
|
z25.object({
|
|
1190
|
-
domain: ResourceIdSchema.describe("The domain id to link your site with."),
|
|
1190
|
+
domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
|
|
1191
1191
|
subDomain: z25.string().optional(),
|
|
1192
1192
|
// bind: z
|
|
1193
1193
|
// .object({
|
|
@@ -3954,6 +3954,7 @@ var getContentType = (file) => {
|
|
|
3954
3954
|
};
|
|
3955
3955
|
|
|
3956
3956
|
// src/feature/site/index.ts
|
|
3957
|
+
import { constantCase as constantCase10 } from "change-case";
|
|
3957
3958
|
var siteFeature = defineFeature({
|
|
3958
3959
|
name: "site",
|
|
3959
3960
|
onStack(ctx) {
|
|
@@ -4009,6 +4010,9 @@ var siteFeature = defineFeature({
|
|
|
4009
4010
|
}
|
|
4010
4011
|
]
|
|
4011
4012
|
});
|
|
4013
|
+
ctx.onPolicy((policy) => {
|
|
4014
|
+
policy.addStatement(bucket.permissions);
|
|
4015
|
+
});
|
|
4012
4016
|
bucket.deletionPolicy = "after-deployment";
|
|
4013
4017
|
const accessControl = new aws16.cloudFront.OriginAccessControl(group, `access`, {
|
|
4014
4018
|
name,
|
|
@@ -4059,7 +4063,6 @@ var siteFeature = defineFeature({
|
|
|
4059
4063
|
values: ["host", "authorization"]
|
|
4060
4064
|
}
|
|
4061
4065
|
});
|
|
4062
|
-
const domainName = formatFullDomainName(ctx.appConfig, props.domain, props.subDomain);
|
|
4063
4066
|
const responseHeaders = new aws16.cloudFront.ResponseHeadersPolicy(group, "response", {
|
|
4064
4067
|
name,
|
|
4065
4068
|
cors: props.cors,
|
|
@@ -4068,11 +4071,13 @@ var siteFeature = defineFeature({
|
|
|
4068
4071
|
// override: true,
|
|
4069
4072
|
// },
|
|
4070
4073
|
});
|
|
4074
|
+
const domainName = props.domain ? formatFullDomainName(ctx.appConfig, props.domain, props.subDomain) : void 0;
|
|
4075
|
+
const certificateArn = props.domain ? ctx.shared.get(`global-certificate-${props.domain}-arn`) : void 0;
|
|
4071
4076
|
const distribution = new aws16.cloudFront.Distribution(group, "distribution", {
|
|
4072
4077
|
name,
|
|
4073
|
-
certificateArn: ctx.shared.get(`global-certificate-${props.domain}-arn`),
|
|
4074
4078
|
compress: true,
|
|
4075
|
-
|
|
4079
|
+
certificateArn,
|
|
4080
|
+
aliases: domainName ? [domainName] : [],
|
|
4076
4081
|
origins,
|
|
4077
4082
|
originGroups,
|
|
4078
4083
|
// defaultRootObject: 'index.html',
|
|
@@ -4128,16 +4133,22 @@ var siteFeature = defineFeature({
|
|
|
4128
4133
|
]
|
|
4129
4134
|
});
|
|
4130
4135
|
}
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4136
|
+
if (domainName) {
|
|
4137
|
+
new aws16.route53.RecordSet(group, `record`, {
|
|
4138
|
+
hostedZoneId: ctx.shared.get(`hosted-zone-${props.domain}-id`),
|
|
4139
|
+
type: "A",
|
|
4140
|
+
name: domainName,
|
|
4141
|
+
alias: {
|
|
4142
|
+
dnsName: distribution.domainName,
|
|
4143
|
+
hostedZoneId: distribution.hostedZoneId,
|
|
4144
|
+
evaluateTargetHealth: false
|
|
4145
|
+
}
|
|
4146
|
+
});
|
|
4147
|
+
}
|
|
4148
|
+
ctx.bind(
|
|
4149
|
+
`SITE_${constantCase10(ctx.stack.name)}_${constantCase10(id)}_ENDPOINT`,
|
|
4150
|
+
domainName ? domainName : distribution.domainName
|
|
4151
|
+
);
|
|
4141
4152
|
}
|
|
4142
4153
|
}
|
|
4143
4154
|
});
|
|
@@ -4228,7 +4239,7 @@ var storeFeature = defineFeature({
|
|
|
4228
4239
|
|
|
4229
4240
|
// src/feature/stream/index.ts
|
|
4230
4241
|
import { aws as aws18, Node as Node17 } from "@awsless/formation";
|
|
4231
|
-
import { constantCase as
|
|
4242
|
+
import { constantCase as constantCase11 } from "change-case";
|
|
4232
4243
|
var streamFeature = defineFeature({
|
|
4233
4244
|
name: "stream",
|
|
4234
4245
|
onStack(ctx) {
|
|
@@ -4242,7 +4253,7 @@ var streamFeature = defineFeature({
|
|
|
4242
4253
|
const streamKey = new aws18.ivs.StreamKey(group, "key", {
|
|
4243
4254
|
channel: channel.arn
|
|
4244
4255
|
});
|
|
4245
|
-
const prefix = `STREAM_${
|
|
4256
|
+
const prefix = `STREAM_${constantCase11(ctx.stack.name)}_${constantCase11(id)}`;
|
|
4246
4257
|
ctx.bind(`${prefix}_ENDPOINT`, channel.playbackUrl);
|
|
4247
4258
|
ctx.addEnv(`${prefix}_INGEST_ENDPOINT`, channel.ingestEndpoint);
|
|
4248
4259
|
ctx.addEnv(`${prefix}_STREAM_KEY`, streamKey.value);
|
|
@@ -384,7 +384,7 @@ var CronsSchema = z12.record(
|
|
|
384
384
|
),
|
|
385
385
|
payload: z12.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
386
386
|
})
|
|
387
|
-
).optional();
|
|
387
|
+
).optional().describe(`Define the cron jobs in your stack.`);
|
|
388
388
|
|
|
389
389
|
// src/feature/graphql/schema.ts
|
|
390
390
|
import { z as z13 } from "zod";
|
|
@@ -758,7 +758,7 @@ var ErrorResponseSchema = z22.union([
|
|
|
758
758
|
var SitesSchema = z22.record(
|
|
759
759
|
ResourceIdSchema,
|
|
760
760
|
z22.object({
|
|
761
|
-
domain: ResourceIdSchema.describe("The domain id to link your site with."),
|
|
761
|
+
domain: ResourceIdSchema.describe("The domain id to link your site with.").optional(),
|
|
762
762
|
subDomain: z22.string().optional(),
|
|
763
763
|
// bind: z
|
|
764
764
|
// .object({
|
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,121 @@
|
|
|
1
|
+
import { AwsCredentialIdentityProvider } from '@aws-sdk/types';
|
|
2
|
+
import { Mock } from 'vitest';
|
|
3
|
+
import { QoS } from '@awsless/iot';
|
|
4
|
+
export { QoS } from '@awsless/iot';
|
|
5
|
+
|
|
6
|
+
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"];
|
|
7
|
+
type Region = (typeof regions)[number];
|
|
8
|
+
|
|
9
|
+
type Credentials = AwsCredentialIdentityProvider;
|
|
10
|
+
|
|
11
|
+
type CommandContext = {
|
|
12
|
+
region: Region;
|
|
13
|
+
credentials: Credentials;
|
|
14
|
+
accountId: string;
|
|
15
|
+
update: (msg: string) => void;
|
|
16
|
+
};
|
|
17
|
+
type CommandHandler = (options: CommandOptions, context: CommandContext) => Promise<string | undefined | void>;
|
|
18
|
+
declare class CommandOptions {
|
|
19
|
+
private opts;
|
|
20
|
+
constructor(args: string[]);
|
|
21
|
+
get(name: string): any;
|
|
22
|
+
private getAssertType;
|
|
23
|
+
number(name: string): number;
|
|
24
|
+
string(name: string): string;
|
|
25
|
+
boolean(name: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface FunctionMock {
|
|
29
|
+
}
|
|
30
|
+
interface FunctionMockResponse {
|
|
31
|
+
}
|
|
32
|
+
declare const mockFunction: (cb: (mock: FunctionMock) => void) => FunctionMockResponse;
|
|
33
|
+
|
|
34
|
+
declare const mockPubSub: () => Mock;
|
|
35
|
+
|
|
36
|
+
interface QueueMock {
|
|
37
|
+
}
|
|
38
|
+
interface QueueMockResponse {
|
|
39
|
+
}
|
|
40
|
+
declare const mockQueue: (cb: (mock: QueueMock) => void) => QueueMockResponse;
|
|
41
|
+
|
|
42
|
+
interface TaskMock {
|
|
43
|
+
}
|
|
44
|
+
interface TaskMockResponse {
|
|
45
|
+
}
|
|
46
|
+
declare const mockTask: (cb: (mock: TaskMock) => void) => TaskMockResponse;
|
|
47
|
+
|
|
48
|
+
interface TopicMock {
|
|
49
|
+
}
|
|
50
|
+
interface TopicMockResponse {
|
|
51
|
+
}
|
|
52
|
+
declare const mockTopic: (cb: (mock: TopicMock) => void) => TopicMockResponse;
|
|
53
|
+
|
|
54
|
+
declare const getCacheProps: (name: string, stack?: string) => {
|
|
55
|
+
readonly host: string;
|
|
56
|
+
readonly port: number;
|
|
57
|
+
};
|
|
58
|
+
interface CacheResources {
|
|
59
|
+
}
|
|
60
|
+
declare const Cache: CacheResources;
|
|
61
|
+
|
|
62
|
+
declare const getConfigName: (name: string) => string;
|
|
63
|
+
interface ConfigResources {
|
|
64
|
+
}
|
|
65
|
+
declare const Config: ConfigResources;
|
|
66
|
+
|
|
67
|
+
declare const getFunctionName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--function--${N}`;
|
|
68
|
+
interface FunctionResources {
|
|
69
|
+
}
|
|
70
|
+
declare const Function: FunctionResources;
|
|
71
|
+
declare const Fn: FunctionResources;
|
|
72
|
+
|
|
73
|
+
declare const getPubSubTopic: <N extends string>(name: N) => `app/pubsub/${N}`;
|
|
74
|
+
|
|
75
|
+
type PublishOptions = {
|
|
76
|
+
qos?: QoS;
|
|
77
|
+
};
|
|
78
|
+
declare const PubSub: {
|
|
79
|
+
publish(topic: string, event: string, payload: unknown, opts?: PublishOptions): Promise<void>;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare const getQueueName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--queue--${N}`;
|
|
83
|
+
declare const getQueueUrl: (name: string, stack?: string) => string | undefined;
|
|
84
|
+
interface QueueResources {
|
|
85
|
+
}
|
|
86
|
+
declare const Queue: QueueResources;
|
|
87
|
+
|
|
88
|
+
declare const getSearchName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--search--${N}`;
|
|
89
|
+
declare const getSearchProps: (name: string, stack?: string) => {
|
|
90
|
+
readonly domain: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
interface SearchResources {
|
|
93
|
+
}
|
|
94
|
+
declare const Search: SearchResources;
|
|
95
|
+
|
|
96
|
+
declare const getSiteBucketName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--site--${N}`;
|
|
97
|
+
|
|
98
|
+
declare const getStoreName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--store--${N}`;
|
|
99
|
+
interface StoreResources {
|
|
100
|
+
}
|
|
101
|
+
declare const Store: StoreResources;
|
|
102
|
+
|
|
103
|
+
declare const getTableName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--table--${N}`;
|
|
104
|
+
interface TableResources {
|
|
105
|
+
}
|
|
106
|
+
declare const Table: TableResources;
|
|
107
|
+
|
|
108
|
+
declare const getTaskName: <N extends string, S extends string = "stack">(name: N, stack?: S) => `app--${S}--task--${N}`;
|
|
109
|
+
interface TaskResources {
|
|
110
|
+
}
|
|
111
|
+
declare const Task: TaskResources;
|
|
112
|
+
|
|
113
|
+
declare const getTopicName: <N extends string>(name: N) => `app--topic--${N}`;
|
|
114
|
+
interface TopicResources {
|
|
115
|
+
}
|
|
116
|
+
declare const Topic: TopicResources;
|
|
117
|
+
|
|
118
|
+
declare const APP: "app";
|
|
119
|
+
declare const STACK: "stack";
|
|
120
|
+
|
|
121
|
+
export { APP, Cache, CacheResources, CommandContext, CommandHandler, CommandOptions, Config, ConfigResources, Fn, Function, FunctionMock, FunctionMockResponse, FunctionResources, PubSub, PublishOptions, Queue, QueueMock, QueueMockResponse, QueueResources, STACK, Search, SearchResources, Store, StoreResources, Table, TableResources, Task, TaskMock, TaskMockResponse, TaskResources, Topic, TopicMock, TopicMockResponse, TopicResources, getCacheProps, getConfigName, getFunctionName, getPubSubTopic, getQueueName, getQueueUrl, getSearchName, getSearchProps, getSiteBucketName, getStoreName, getTableName, getTaskName, getTopicName, mockFunction, mockPubSub, mockQueue, mockTask, mockTopic };
|
package/dist/server.js
CHANGED
|
@@ -339,6 +339,9 @@ var Search = /* @__PURE__ */ createProxy((stack) => {
|
|
|
339
339
|
});
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
+
// src/lib/server/site.ts
|
|
343
|
+
var getSiteBucketName = bindLocalResourceName("site");
|
|
344
|
+
|
|
342
345
|
// src/lib/server/store.ts
|
|
343
346
|
import { deleteObject, getObject, headObject, putObject } from "@awsless/s3";
|
|
344
347
|
var getStoreName = bindLocalResourceName("store");
|
|
@@ -404,6 +407,7 @@ export {
|
|
|
404
407
|
getQueueUrl,
|
|
405
408
|
getSearchName,
|
|
406
409
|
getSearchProps,
|
|
410
|
+
getSiteBucketName,
|
|
407
411
|
getStoreName,
|
|
408
412
|
getTableName,
|
|
409
413
|
getTaskName,
|