@geekmidas/cloud 10.0.0-alpha.98 → 10.0.0
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/README.md +6 -14
- package/dist/index-ByEJy40r.d.cts +56 -0
- package/dist/index-ByEJy40r.d.cts.map +1 -0
- package/dist/index-DZ0QrJQr.d.mts +56 -0
- package/dist/index-DZ0QrJQr.d.mts.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -2
- package/dist/utils/index.cjs +5 -106
- package/dist/utils/index.d.cts +2 -62
- package/dist/utils/index.d.mts +2 -62
- package/dist/utils/index.mjs +2 -78
- package/dist/utils-BdKG20_m.mjs +83 -0
- package/dist/utils-BdKG20_m.mjs.map +1 -0
- package/dist/utils-CtMjuIMR.cjs +129 -0
- package/dist/utils-CtMjuIMR.cjs.map +1 -0
- package/package.json +9 -47
- package/src/sst/{aws/Api.ts → Api.ts} +47 -19
- package/src/sst/{aws/Cron.ts → Cron.ts} +46 -6
- package/src/sst/{aws/Function.ts → Function.ts} +41 -12
- package/src/sst/Queue.ts +46 -0
- package/src/sst/{aws/Storage.ts → Storage.ts} +3 -3
- package/src/sst/Topic.ts +37 -0
- package/src/sst/__tests__/LinkedEnvironment.spec.ts +1 -4
- package/src/sst/__type-tests__/authorizers.type-test.ts +2 -2
- package/src/sst/__type-tests__/manifest.type-test.ts +77 -0
- package/src/sst/__type-tests__/messaging.type-test.ts +3 -3
- package/src/sst/__type-tests__/storage.type-test.ts +2 -2
- package/src/sst/index.ts +7 -67
- package/src/sst/naming.ts +16 -37
- package/src/sst/tsconfig.json +2 -2
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.d.cts.map +0 -1
- package/dist/utils/index.d.mts.map +0 -1
- package/dist/utils/index.mjs.map +0 -1
- package/src/dokploy/Application.ts +0 -306
- package/src/dokploy/__tests__/Application.provider.spec.ts +0 -206
- package/src/dokploy/__tests__/Application.spec.ts +0 -69
- package/src/dokploy/index.ts +0 -18
- package/src/sst/__tests__/api.spec.ts +0 -185
- package/src/sst/__tests__/backends.spec.ts +0 -249
- package/src/sst/__tests__/bootstrap.spec.ts +0 -140
- package/src/sst/__tests__/database.spec.ts +0 -119
- package/src/sst/__tests__/encryption.spec.ts +0 -90
- package/src/sst/__tests__/fromManifest.integration.spec.ts +0 -427
- package/src/sst/__tests__/fromManifest.spec.ts +0 -567
- package/src/sst/__tests__/function.spec.ts +0 -121
- package/src/sst/__tests__/links.spec.ts +0 -209
- package/src/sst/__tests__/provides.spec.ts +0 -107
- package/src/sst/__tests__/ses.spec.ts +0 -93
- package/src/sst/__tests__/surfaces.spec.ts +0 -149
- package/src/sst/__type-tests__/overrides.type-test.ts +0 -152
- package/src/sst/aws/Cache.ts +0 -259
- package/src/sst/aws/Credential.ts +0 -61
- package/src/sst/aws/Database.ts +0 -204
- package/src/sst/aws/DatabaseBootstrap.ts +0 -312
- package/src/sst/aws/DerivedDatabase.ts +0 -117
- package/src/sst/aws/Email.ts +0 -181
- package/src/sst/aws/Encryption.ts +0 -91
- package/src/sst/aws/ExternalApi.ts +0 -58
- package/src/sst/aws/FileServer.ts +0 -82
- package/src/sst/aws/ObjectStorage.ts +0 -76
- package/src/sst/aws/Queue.ts +0 -149
- package/src/sst/aws/RestApiSurface.ts +0 -114
- package/src/sst/aws/Secret.ts +0 -76
- package/src/sst/aws/StaticSite.ts +0 -92
- package/src/sst/aws/Topic.ts +0 -68
- package/src/sst/aws/bootstrap/handler.ts +0 -119
- package/src/sst/aws/ses.ts +0 -132
- package/src/sst/errors.ts +0 -65
- package/src/sst/fromManifest.ts +0 -1116
- package/src/sst/overrides.ts +0 -133
- package/src/sst/upstash.d.ts +0 -38
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { externalApiUrl } from '@geekmidas/manifest';
|
|
2
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
3
|
-
import type { StackType } from '../Stack';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `ExternalApi` — the infra half of the `external-api` kind.
|
|
7
|
-
*
|
|
8
|
-
* Nothing is provisioned: the API is somebody else's. What this holds is the
|
|
9
|
-
* two facts a function needs to call it on this stage — the URL the
|
|
10
|
-
* declaration names for it, and the credentials the provider issued, kept as
|
|
11
|
-
* an SST secret and set out of band:
|
|
12
|
-
*
|
|
13
|
-
* ```
|
|
14
|
-
* sst secret set PolarCredentials '{"clientId":"…","clientSecret":"…"}' --stage prod
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class ExternalApi<
|
|
18
|
-
TStage extends string = string,
|
|
19
|
-
TDomain extends string = string,
|
|
20
|
-
> implements GkmLinkable
|
|
21
|
-
{
|
|
22
|
-
readonly _id: string;
|
|
23
|
-
|
|
24
|
-
private readonly url: string;
|
|
25
|
-
|
|
26
|
-
private readonly credentials: sst.Secret;
|
|
27
|
-
|
|
28
|
-
get _type() {
|
|
29
|
-
return ResourceType.ExternalApi;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
constructor(
|
|
33
|
-
stack: StackType<TStage, TDomain>,
|
|
34
|
-
name: string,
|
|
35
|
-
props: ExternalApiProps,
|
|
36
|
-
) {
|
|
37
|
-
this._id = name;
|
|
38
|
-
// Read at synth, so a stage the declaration has no URL for fails the
|
|
39
|
-
// deploy — with the stage named — rather than the first request.
|
|
40
|
-
this.url = externalApiUrl({ id: name, url: props.url }, stack.stage);
|
|
41
|
-
this.credentials = new sst.Secret(`${name}Credentials`, props.placeholder);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
provides(): Record<string, $util.Input<string>> {
|
|
45
|
-
return { url: this.url, credentials: this.credentials.value };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getSSTLink() {
|
|
49
|
-
return { properties: { ...this.provides() } };
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface ExternalApiProps {
|
|
54
|
-
/** The declaration's `url` — one for every stage, or one per stage name. */
|
|
55
|
-
url: string | Readonly<Record<string, string>>;
|
|
56
|
-
/** A value for the credentials secret until one is set, for a preview stage. */
|
|
57
|
-
placeholder?: string;
|
|
58
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
2
|
-
import type { StackType } from '../Stack';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `FileServer` — a CloudFront distribution over a bucket, and the infra half of
|
|
6
|
-
* the `file-server` kind.
|
|
7
|
-
*
|
|
8
|
-
* It owns the certificate and the DNS record, which is the whole reason the
|
|
9
|
-
* construct is its own rather than a flag on the bucket: a domain lifecycle has
|
|
10
|
-
* no business living inside an `objects` provisioner. It is also the same
|
|
11
|
-
* infrastructure a static site is — a distribution over an origin — with live
|
|
12
|
-
* bucket contents in place of a build output.
|
|
13
|
-
*
|
|
14
|
-
* The origin bucket must permit CloudFront to read it, which is set on the
|
|
15
|
-
* *bucket* rather than here: `fromManifest` gives a bucket `access:
|
|
16
|
-
* 'cloudfront'` when anything in the manifest serves it. That lookup is the cost
|
|
17
|
-
* this design named — the bucket alone no longer says whether it is served, so
|
|
18
|
-
* you find whoever points at it — paid once, in one place.
|
|
19
|
-
*
|
|
20
|
-
* What it does **not** do is signing. A CloudFront signed URL or signed cookie
|
|
21
|
-
* needs a key group and a private key, which is key material nothing declares
|
|
22
|
-
* yet; the construct's `signedUrl` is an S3 presign at the bucket instead. So
|
|
23
|
-
* open paths are served here, and a signed read goes to the bucket's own host.
|
|
24
|
-
* That is a real difference in hostname, and it is documented rather than hidden
|
|
25
|
-
* because a presign and a CloudFront signature share only the word "signed".
|
|
26
|
-
*/
|
|
27
|
-
export class FileServer<
|
|
28
|
-
TStage extends string = string,
|
|
29
|
-
TDomain extends string = string,
|
|
30
|
-
>
|
|
31
|
-
extends sst.aws.Router
|
|
32
|
-
implements GkmLinkable
|
|
33
|
-
{
|
|
34
|
-
readonly _id!: string;
|
|
35
|
-
|
|
36
|
-
get _type() {
|
|
37
|
-
return ResourceType.FileServer;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
_stack: StackType<TStage, TDomain>,
|
|
42
|
-
name: string,
|
|
43
|
-
props: FileServerProps,
|
|
44
|
-
) {
|
|
45
|
-
const { origin, ...args } = props;
|
|
46
|
-
|
|
47
|
-
super(name, args);
|
|
48
|
-
this._id = name;
|
|
49
|
-
|
|
50
|
-
// Everything at the root, so a served path *is* a bucket key and the
|
|
51
|
-
// client's `url(key)` and `getUploadURL(key)` speak the same language.
|
|
52
|
-
// Several origins would cost exactly that, which is why multi-origin is
|
|
53
|
-
// deferred until something asks for it.
|
|
54
|
-
this.routeBucket('/*', origin);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The one value this server resolves: where its objects answer.
|
|
59
|
-
*
|
|
60
|
-
* A custom domain when one is configured and the distribution's assigned
|
|
61
|
-
* hostname otherwise — `Router.url` already prefers the former. The assigned
|
|
62
|
-
* hostname is a fallback rather than a destination: it changes if the
|
|
63
|
-
* distribution is replaced, which turns every URL anyone emailed or cached
|
|
64
|
-
* into a dead one.
|
|
65
|
-
*/
|
|
66
|
-
provides(): Record<string, $util.Input<string>> {
|
|
67
|
-
return { url: this.url };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
override getSSTLink() {
|
|
71
|
-
const link = super.getSSTLink();
|
|
72
|
-
return {
|
|
73
|
-
...link,
|
|
74
|
-
properties: { ...link.properties, ...this.provides() },
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface FileServerProps extends sst.aws.RouterArgs {
|
|
80
|
-
/** The bucket whose objects this serves. */
|
|
81
|
-
origin: sst.aws.Bucket;
|
|
82
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { s3Url } from '@geekmidas/storage/aws';
|
|
2
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
3
|
-
import type { StackType } from '../Stack';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* `ObjectStorage` — a linkable S3 bucket (wraps `sst.aws.Bucket`), and the
|
|
7
|
-
* infra half of the `objects` construct.
|
|
8
|
-
*
|
|
9
|
-
* Its whole contribution is the link. SST injects the linked resource's
|
|
10
|
-
* properties at runtime and `@geekmidas/envkit`'s resolvers turn them into the
|
|
11
|
-
* env a construct reads — so composing a URL here would produce a value nothing
|
|
12
|
-
* ever reads.
|
|
13
|
-
*
|
|
14
|
-
* Usable on its own. `Stack.fromManifest` translates a manifest into these, but
|
|
15
|
-
* the component takes ordinary props so it works in a hand-written
|
|
16
|
-
* `sst.config.ts` with no manifest anywhere.
|
|
17
|
-
*/
|
|
18
|
-
export class ObjectStorage<
|
|
19
|
-
TStage extends string = string,
|
|
20
|
-
TDomain extends string = string,
|
|
21
|
-
>
|
|
22
|
-
extends sst.aws.Bucket
|
|
23
|
-
implements GkmLinkable
|
|
24
|
-
{
|
|
25
|
-
readonly _id!: string;
|
|
26
|
-
|
|
27
|
-
get _type() {
|
|
28
|
-
return ResourceType.ObjectStorage;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
_stack: StackType<TStage, TDomain>,
|
|
33
|
-
name: string,
|
|
34
|
-
props: ObjectStorageProps = {},
|
|
35
|
-
) {
|
|
36
|
-
super(name, props);
|
|
37
|
-
this._id = name;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* The values this bucket resolves onto anything that depends on it, keyed by
|
|
42
|
-
* role. `provideKey` turns a role into the env key the app declared, so
|
|
43
|
-
* `url` here is `UPLOADS_URL` there.
|
|
44
|
-
*
|
|
45
|
-
* Composed *here* because only the resource knows its own shape: the name may
|
|
46
|
-
* be supplied through props or generated, and the region is the bucket's, not
|
|
47
|
-
* the reader's. It stays a method rather than being inlined below so the
|
|
48
|
-
* contract can be asserted — declared keys against supplied ones — without a
|
|
49
|
-
* deploy.
|
|
50
|
-
*/
|
|
51
|
-
provides(): Record<string, $util.Input<string>> {
|
|
52
|
-
return {
|
|
53
|
-
url: $util
|
|
54
|
-
.all([this.name, this.nodes.bucket.region])
|
|
55
|
-
.apply(([bucket, region]) => s3Url.build({ bucket, region })),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* The link carries those values, because the link is what reaches the running
|
|
61
|
-
* code: SST injects these properties and envkit's resolvers flatten them into
|
|
62
|
-
* env. Composing anywhere else produces a value nothing reads.
|
|
63
|
-
*
|
|
64
|
-
* The permissions `super` includes are untouched: what a link grants stays
|
|
65
|
-
* SST's business.
|
|
66
|
-
*/
|
|
67
|
-
override getSSTLink() {
|
|
68
|
-
const link = super.getSSTLink();
|
|
69
|
-
return {
|
|
70
|
-
...link,
|
|
71
|
-
properties: { ...link.properties, ...this.provides() },
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface ObjectStorageProps extends sst.aws.BucketArgs {}
|
package/src/sst/aws/Queue.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
// The codec alone, not the barrel: `@geekmidas/events/sqs` re-exports the
|
|
2
|
-
// publisher and its AWS SDK client, and a deploy config that only needs to
|
|
3
|
-
// *compose a URL* should not have to resolve a runtime it never calls.
|
|
4
|
-
import * as sqsUrl from '@geekmidas/events/sqs/url';
|
|
5
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
6
|
-
import { regionOfArn } from '../naming';
|
|
7
|
-
import type { StackType } from '../Stack';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* `Queue` — a linkable SQS queue (wraps `sst.aws.Queue`), the point-to-point
|
|
11
|
-
* work queue. Link it to a producer and the runtime resolves `<NAME>_URL`,
|
|
12
|
-
* `<NAME>_ARN`, and a `<NAME>_PUBLISHER_CONNECTION_STRING` (`sqs://?queueUrl=…`)
|
|
13
|
-
* that `@geekmidas/events`'s `Publisher.fromConnectionString` consumes. Its
|
|
14
|
-
* one consumer — the handler the queue was declared with — is subscribed by
|
|
15
|
-
* {@link Queue.consume}.
|
|
16
|
-
*
|
|
17
|
-
* SST's native `Queue` link exposes only `url`, so `getSSTLink` is overridden to
|
|
18
|
-
* also expose `arn` (what the resolver needs). `QueueProps` extends
|
|
19
|
-
* `sst.aws.QueueArgs`. Source-only (extends ambient `sst.aws.*`); see docs §2.
|
|
20
|
-
*/
|
|
21
|
-
export class Queue<
|
|
22
|
-
TStage extends string = string,
|
|
23
|
-
TDomain extends string = string,
|
|
24
|
-
>
|
|
25
|
-
extends sst.aws.Queue
|
|
26
|
-
implements GkmLinkable
|
|
27
|
-
{
|
|
28
|
-
readonly _id!: string;
|
|
29
|
-
|
|
30
|
-
get _type() {
|
|
31
|
-
return ResourceType.Queue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
35
|
-
_stack: StackType<TStage, TDomain>,
|
|
36
|
-
name: string,
|
|
37
|
-
props: QueueProps = {},
|
|
38
|
-
) {
|
|
39
|
-
const { queueName, ...args } = props;
|
|
40
|
-
|
|
41
|
-
super(name, {
|
|
42
|
-
...args,
|
|
43
|
-
// A supplied name has to satisfy SQS's rule; an auto-generated one is
|
|
44
|
-
// Pulumi's problem and it already handles it.
|
|
45
|
-
...(queueName
|
|
46
|
-
? {
|
|
47
|
-
transform: {
|
|
48
|
-
...args.transform,
|
|
49
|
-
queue: { name: fifoName(queueName, args.fifo) },
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
: {}),
|
|
53
|
-
});
|
|
54
|
-
this._id = name;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The values this queue resolves onto anything that publishes to it, keyed
|
|
59
|
-
* by role. One key, the producer's: a worker is reached *through* the queue,
|
|
60
|
-
* so there is no second address and nothing can depend on the handler.
|
|
61
|
-
*
|
|
62
|
-
* The region is read out of the queue's own ARN rather than left for the SDK
|
|
63
|
-
* to infer. `AWS_REGION` inside a Lambda is the *function's* region, so a
|
|
64
|
-
* connection string that omits it works until the day the queue lives
|
|
65
|
-
* somewhere else and then fails at runtime with nothing to point at.
|
|
66
|
-
*/
|
|
67
|
-
provides(): Record<string, $util.Input<string>> {
|
|
68
|
-
return {
|
|
69
|
-
publisherConnectionString: $util
|
|
70
|
-
.all([this.url, this.arn])
|
|
71
|
-
.apply(([queueUrl, arn]) =>
|
|
72
|
-
sqsUrl.build({ queueUrl, region: regionOfArn(arn) }),
|
|
73
|
-
),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Subscribe the queue's one consumer: a Lambda running `handler`, linked to
|
|
79
|
-
* what the consumer depends on and to this queue itself.
|
|
80
|
-
*
|
|
81
|
-
* A queue has exactly one consumer, so this is called once per queue — by
|
|
82
|
-
* `fromManifest`, from the handler the build wrote for it.
|
|
83
|
-
*/
|
|
84
|
-
consume(consumer: QueueConsumer) {
|
|
85
|
-
return this.subscribe(
|
|
86
|
-
{
|
|
87
|
-
handler: consumer.handler,
|
|
88
|
-
link: [this, ...(consumer.link ?? [])],
|
|
89
|
-
runtime: 'nodejs24.x',
|
|
90
|
-
...(consumer.vpc ? { vpc: consumer.vpc } : {}),
|
|
91
|
-
...(consumer.timeout ? { timeout: consumer.timeout } : {}),
|
|
92
|
-
},
|
|
93
|
-
consumer.batchSize ? { batch: { size: consumer.batchSize } } : {},
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
override getSSTLink() {
|
|
98
|
-
const link = super.getSSTLink();
|
|
99
|
-
return {
|
|
100
|
-
...link,
|
|
101
|
-
properties: { ...link.properties, arn: this.arn, ...this.provides() },
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** The queue's one consumer, as {@link Queue.consume} subscribes it. */
|
|
107
|
-
export interface QueueConsumer {
|
|
108
|
-
/** The built handler — `apps/api/.gkm/aws/queues/emails.handler`. */
|
|
109
|
-
handler: string;
|
|
110
|
-
/** What the consumer depends on; the queue itself is always linked. */
|
|
111
|
-
link?: unknown[];
|
|
112
|
-
/** The database's network, when the consumer reaches one. */
|
|
113
|
-
vpc?: sst.aws.Vpc;
|
|
114
|
-
timeout?: `${number} seconds` | `${number} minutes`;
|
|
115
|
-
batchSize?: number;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface QueueProps extends sst.aws.QueueArgs {
|
|
119
|
-
/**
|
|
120
|
-
* The physical queue name, where the auto-generated one will not do.
|
|
121
|
-
*
|
|
122
|
-
* Normalised for SQS's FIFO rule — see {@link fifoName}. This is a separate
|
|
123
|
-
* prop rather than a `transform` because the rule is easy to not know and
|
|
124
|
-
* expensive to discover: the deploy fails at the API call, long after the
|
|
125
|
-
* plan looked fine.
|
|
126
|
-
*/
|
|
127
|
-
queueName?: string;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* A FIFO queue's name must end in `.fifo`, and a standard queue's must not.
|
|
132
|
-
*
|
|
133
|
-
* AWS rejects either mistake at the API call rather than at plan time, so the
|
|
134
|
-
* component fixes it where the fact lives instead of leaving it as something
|
|
135
|
-
* every caller has to remember. Appending is safe: `.fifo` counts toward the
|
|
136
|
-
* 80-character limit, so a name already carrying it must not get a second one.
|
|
137
|
-
*/
|
|
138
|
-
export function fifoName(
|
|
139
|
-
name: string,
|
|
140
|
-
fifo: sst.aws.QueueArgs['fifo'],
|
|
141
|
-
): string {
|
|
142
|
-
// `fifo` is an Input and may be an object (`{ contentBasedDeduplication }`),
|
|
143
|
-
// which is still FIFO — only `false` and `undefined` are not.
|
|
144
|
-
const isFifo = fifo !== undefined && fifo !== false;
|
|
145
|
-
|
|
146
|
-
if (!isFifo) return name.replace(/\.fifo$/, '');
|
|
147
|
-
|
|
148
|
-
return name.endsWith('.fifo') ? name : `${name}.fifo`;
|
|
149
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
2
|
-
import type { StackType } from '../Stack';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `RestApiSurface` — an HTTP API, and the infra half of the `rest-api` kind.
|
|
6
|
-
*
|
|
7
|
-
* Provisioned before its routes, because its *address* is what everything
|
|
8
|
-
* downstream needs: a site inlines it as `VITE_API_URL`, an auth server puts it
|
|
9
|
-
* on its trusted-origin list, and the cookie domain derives from it. The routes
|
|
10
|
-
* are mounted once everything they link to exists — see {@link mount}.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export interface RestApiSurfaceProps extends sst.aws.ApiGatewayV2Args {
|
|
14
|
-
/**
|
|
15
|
-
* Who may call this surface, resolved after everything is provisioned.
|
|
16
|
-
*
|
|
17
|
-
* A promise rather than a value, because the answer depends on constructs
|
|
18
|
-
* that do not exist yet when this one is built — see `provides()`.
|
|
19
|
-
*/
|
|
20
|
-
callers?: Promise<{ trustedOrigins: string; cookieDomain?: string }>;
|
|
21
|
-
}
|
|
22
|
-
export class RestApiSurface<
|
|
23
|
-
TStage extends string = string,
|
|
24
|
-
TDomain extends string = string,
|
|
25
|
-
>
|
|
26
|
-
extends sst.aws.ApiGatewayV2
|
|
27
|
-
implements GkmLinkable
|
|
28
|
-
{
|
|
29
|
-
readonly _id!: string;
|
|
30
|
-
|
|
31
|
-
get _type() {
|
|
32
|
-
return ResourceType.ApiGatewayV2;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private readonly callers: Promise<{
|
|
36
|
-
trustedOrigins: string;
|
|
37
|
-
cookieDomain?: string;
|
|
38
|
-
}>;
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
_stack: StackType<TStage, TDomain>,
|
|
42
|
-
name: string,
|
|
43
|
-
props: RestApiSurfaceProps = {},
|
|
44
|
-
) {
|
|
45
|
-
const { callers, ...args } = props;
|
|
46
|
-
|
|
47
|
-
super(name, args);
|
|
48
|
-
this._id = name;
|
|
49
|
-
this.callers = callers ?? Promise.resolve({ trustedOrigins: '' });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Where the surface answers, and who may call it.
|
|
54
|
-
*
|
|
55
|
-
* `trustedOrigins` and `cookieDomain` are declared by the construct and are
|
|
56
|
-
* *caller*-derived — read off the graph, not off this resource — so they are
|
|
57
|
-
* supplied through props rather than composed here. A surface knows its own
|
|
58
|
-
* address and nothing about who points at it.
|
|
59
|
-
*/
|
|
60
|
-
provides(): Record<string, $util.Input<string>> {
|
|
61
|
-
return {
|
|
62
|
-
url: this.url,
|
|
63
|
-
// Lazy, and it has to be. A surface's callers include the site, and
|
|
64
|
-
// the site's own build needs *this* surface's address — so the two
|
|
65
|
-
// values are circular even though the two resources are not. A
|
|
66
|
-
// promise resolved after everything is provisioned breaks it at the
|
|
67
|
-
// value level, which is the level the cycle is actually on.
|
|
68
|
-
trustedOrigins: $util.output(this.callers.then((c) => c.trustedOrigins)),
|
|
69
|
-
cookieDomain: $util.output(
|
|
70
|
-
this.callers.then((c) => c.cookieDomain ?? ''),
|
|
71
|
-
),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Mount one endpoint: a Lambda running the handler the build wrote for it,
|
|
77
|
-
* linked to exactly what that endpoint depends on.
|
|
78
|
-
*/
|
|
79
|
-
mount(endpoint: SurfaceRoute) {
|
|
80
|
-
return this.route(
|
|
81
|
-
`${endpoint.method} ${endpoint.path}`,
|
|
82
|
-
{
|
|
83
|
-
handler: endpoint.handler,
|
|
84
|
-
link: endpoint.link ?? [],
|
|
85
|
-
runtime: 'nodejs24.x',
|
|
86
|
-
...(endpoint.vpc ? { vpc: endpoint.vpc } : {}),
|
|
87
|
-
},
|
|
88
|
-
// `iam` is the one authorizer the gateway enforces itself; every other
|
|
89
|
-
// is the endpoint's own, checked in the handler.
|
|
90
|
-
endpoint.authorizer === 'iam' ? { auth: { iam: true } } : {},
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
override getSSTLink() {
|
|
95
|
-
const link = super.getSSTLink();
|
|
96
|
-
return {
|
|
97
|
-
...link,
|
|
98
|
-
properties: { ...link.properties, ...this.provides() },
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** One endpoint, as {@link RestApiSurface.mount} mounts it. */
|
|
104
|
-
export interface SurfaceRoute {
|
|
105
|
-
method: string;
|
|
106
|
-
path: string;
|
|
107
|
-
/** The built handler — `apps/api/.gkm/aws/routes/getUser.handler`. */
|
|
108
|
-
handler: string;
|
|
109
|
-
/** What the endpoint depends on, and nothing else. */
|
|
110
|
-
link?: unknown[];
|
|
111
|
-
/** The database's network, when the endpoint reaches one. */
|
|
112
|
-
vpc?: sst.aws.Vpc;
|
|
113
|
-
authorizer?: string;
|
|
114
|
-
}
|
package/src/sst/aws/Secret.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
2
|
-
import type { StackType } from '../Stack';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `Secret` — a linkable SST secret, and the infra half of the `secret` kind.
|
|
6
|
-
*
|
|
7
|
-
* The odd one among the kinds: it provisions no cloud resource of its own. An
|
|
8
|
-
* SST secret is a value held in the app's own encrypted state and set out of
|
|
9
|
-
* band (`sst secret set AuthSecret …`), which is why the component is thin and
|
|
10
|
-
* why the *deploy* fails rather than the *runtime* when nobody set one — SST
|
|
11
|
-
* raises `SecretMissingError` at synth, which is the earliest anything can.
|
|
12
|
-
*
|
|
13
|
-
* It provides a value rather than an address, which is the whole reason it is a
|
|
14
|
-
* node instead of a field on whatever needs it: the thing that generates a
|
|
15
|
-
* signing key, the thing that stores it, and the thing that reads it are three
|
|
16
|
-
* different systems deployed, and one derived string locally.
|
|
17
|
-
*
|
|
18
|
-
* Usable on its own. `Stack.fromManifest` translates a manifest into these, but
|
|
19
|
-
* the component takes an ordinary placeholder so it works in a hand-written
|
|
20
|
-
* `sst.config.ts` with no manifest anywhere.
|
|
21
|
-
*/
|
|
22
|
-
export class Secret<
|
|
23
|
-
TStage extends string = string,
|
|
24
|
-
TDomain extends string = string,
|
|
25
|
-
>
|
|
26
|
-
extends sst.Secret
|
|
27
|
-
implements GkmLinkable
|
|
28
|
-
{
|
|
29
|
-
readonly _id!: string;
|
|
30
|
-
|
|
31
|
-
get _type() {
|
|
32
|
-
return ResourceType.SSTSecret;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
_stack: StackType<TStage, TDomain>,
|
|
37
|
-
name: string,
|
|
38
|
-
props: SecretProps = {},
|
|
39
|
-
) {
|
|
40
|
-
super(name, props.placeholder);
|
|
41
|
-
this._id = name;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The one value this secret resolves onto anything that depends on it.
|
|
46
|
-
*
|
|
47
|
-
* `value` is the role, so `provideKey` turns it into the key the app
|
|
48
|
-
* declared. Note that a secret's key is its *name* rather than
|
|
49
|
-
* `<NAME>_VALUE` — `Auth` signs with `AUTH_SECRET`, which is also what
|
|
50
|
-
* better-auth's own tooling looks for — so the manifest declares that key
|
|
51
|
-
* directly and this contributes the value behind it.
|
|
52
|
-
*/
|
|
53
|
-
provides(): Record<string, $util.Input<string>> {
|
|
54
|
-
return { value: this.value };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
override getSSTLink() {
|
|
58
|
-
const link = super.getSSTLink();
|
|
59
|
-
return {
|
|
60
|
-
...link,
|
|
61
|
-
properties: { ...link.properties, ...this.provides() },
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface SecretProps {
|
|
67
|
-
/**
|
|
68
|
-
* A value to fall back to when none is set.
|
|
69
|
-
*
|
|
70
|
-
* Deliberately not a default for anything that signs: a placeholder signing
|
|
71
|
-
* key is one every deploy of every app shares, so leaving this unset — and
|
|
72
|
-
* letting the deploy fail — is the correct handling for a real secret. It
|
|
73
|
-
* exists for the values that are secrets by habit rather than by need.
|
|
74
|
-
*/
|
|
75
|
-
placeholder?: string;
|
|
76
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { type GkmLinkable, ResourceType } from '../Linkable';
|
|
2
|
-
import type { StackType } from '../Stack';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `StaticSite` — a built frontend on a distribution, and the infra half of the
|
|
6
|
-
* `site` kind.
|
|
7
|
-
*
|
|
8
|
-
* The same infrastructure a file server is, which is why they are neighbours
|
|
9
|
-
* here: a bucket, a distribution, a certificate and a domain. What differs is
|
|
10
|
-
* only what sits in the bucket — a build output rather than live contents.
|
|
11
|
-
*
|
|
12
|
-
* Its `environment` is the interesting part and is not composed here. The values
|
|
13
|
-
* a site inlines are derived from its *edges* by `publicEnvFor`, filtered by
|
|
14
|
-
* which provided values may be shipped to a browser, and renamed by the
|
|
15
|
-
* variant's prefix. That derivation is shared with the local target, so a site
|
|
16
|
-
* built by `gkm dev` and the same site built by a deploy inline the same names.
|
|
17
|
-
*/
|
|
18
|
-
export class StaticSite<
|
|
19
|
-
TStage extends string = string,
|
|
20
|
-
TDomain extends string = string,
|
|
21
|
-
>
|
|
22
|
-
extends sst.aws.StaticSite
|
|
23
|
-
implements GkmLinkable
|
|
24
|
-
{
|
|
25
|
-
readonly _id!: string;
|
|
26
|
-
|
|
27
|
-
get _type() {
|
|
28
|
-
return ResourceType.StaticSite;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
constructor(
|
|
32
|
-
_stack: StackType<TStage, TDomain>,
|
|
33
|
-
name: string,
|
|
34
|
-
props: StaticSiteProps = {},
|
|
35
|
-
) {
|
|
36
|
-
const { variant = 'static', ...args } = props;
|
|
37
|
-
|
|
38
|
-
super(name, {
|
|
39
|
-
// The variant's build, unless the caller supplied one. A site is
|
|
40
|
-
// source until something builds it — uploading `path` directly is what
|
|
41
|
-
// puts `src/` and `node_modules/` in a bucket — and *how* to build is
|
|
42
|
-
// exactly what the variant knows and the declaration deliberately does
|
|
43
|
-
// not.
|
|
44
|
-
build: BUILDS[variant],
|
|
45
|
-
...args,
|
|
46
|
-
});
|
|
47
|
-
this._id = name;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Where the site is served.
|
|
52
|
-
*
|
|
53
|
-
* Worth providing even though a browser gets there by typing it: an email
|
|
54
|
-
* templating a link back to the console needs this URL, and that is otherwise
|
|
55
|
-
* one more hand-maintained variable — the exact class of thing declaring a
|
|
56
|
-
* site was meant to remove.
|
|
57
|
-
*/
|
|
58
|
-
provides(): Record<string, $util.Input<string>> {
|
|
59
|
-
return { url: this.url };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
override getSSTLink() {
|
|
63
|
-
const link = super.getSSTLink();
|
|
64
|
-
return {
|
|
65
|
-
...link,
|
|
66
|
-
properties: { ...link.properties, ...this.provides() },
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface StaticSiteProps extends sst.aws.StaticSiteArgs {
|
|
72
|
-
/** Which framework builds it, for the default build command. */
|
|
73
|
-
variant?: 'static' | 'next' | 'tanstack';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* How each variant builds, and where it leaves the result.
|
|
78
|
-
*
|
|
79
|
-
* One neutral name from the construct, one build per framework — the same
|
|
80
|
-
* arrangement the `VITE_`/`NEXT_PUBLIC_` prefixes have, and for the same
|
|
81
|
-
* reason: the framework changes the code you write, so it changes this and
|
|
82
|
-
* nothing else.
|
|
83
|
-
*/
|
|
84
|
-
const BUILDS: Record<
|
|
85
|
-
NonNullable<StaticSiteProps['variant']>,
|
|
86
|
-
{ command: string; output: string }
|
|
87
|
-
> = {
|
|
88
|
-
static: { command: 'npm run build', output: 'dist' },
|
|
89
|
-
tanstack: { command: 'npm run build', output: 'dist' },
|
|
90
|
-
// Next's static export lands in `out`, not `dist`.
|
|
91
|
-
next: { command: 'npm run build', output: 'out' },
|
|
92
|
-
};
|