sst 2.8.5 → 2.8.7
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/cli/commands/plugins/kysely.js +20 -37
- package/cli/commands/plugins/pothos.js +1 -0
- package/constructs/Api.d.ts +7 -0
- package/constructs/Api.js +2 -0
- package/constructs/SsrSite.js +3 -2
- package/package.json +3 -3
- package/pothos.d.ts +2 -3
- package/pothos.js +3 -0
- package/runtime/handlers/dotnet.js +3 -2
- package/runtime/handlers.d.ts +1 -0
- package/runtime/workers.js +1 -0
- package/sst.mjs +27 -39
- package/support/rds-migrator/index.mjs +15 -15
|
@@ -2,7 +2,7 @@ import { Kysely } from "kysely";
|
|
|
2
2
|
import { DataApiDialect } from "kysely-data-api";
|
|
3
3
|
import { RDSData } from "@aws-sdk/client-rds-data";
|
|
4
4
|
import * as fs from "fs/promises";
|
|
5
|
-
import {
|
|
5
|
+
import { PostgresDialect, MysqlDialect, Serializer, Transformer, } from "kysely-codegen";
|
|
6
6
|
import { Context } from "../../../context/context.js";
|
|
7
7
|
import { useBus } from "../../../bus.js";
|
|
8
8
|
import { Logger } from "../../../logger.js";
|
|
@@ -15,48 +15,31 @@ export const useKyselyTypeGenerator = Context.memo(async () => {
|
|
|
15
15
|
if (!db.types)
|
|
16
16
|
return;
|
|
17
17
|
logger("generating types for", db.migratorID);
|
|
18
|
+
const dataApi = new DataApiDialect({
|
|
19
|
+
mode: db.engine.includes("postgres") ? "postgres" : "mysql",
|
|
20
|
+
driver: {
|
|
21
|
+
secretArn: db.secretArn,
|
|
22
|
+
resourceArn: db.clusterArn,
|
|
23
|
+
database: db.defaultDatabaseName,
|
|
24
|
+
client: useAWSClient(RDSData),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
18
27
|
const k = new Kysely({
|
|
19
|
-
dialect:
|
|
20
|
-
mode: db.engine.includes("postgres") ? "postgres" : "mysql",
|
|
21
|
-
driver: {
|
|
22
|
-
secretArn: db.secretArn,
|
|
23
|
-
resourceArn: db.clusterArn,
|
|
24
|
-
database: db.defaultDatabaseName,
|
|
25
|
-
client: useAWSClient(RDSData),
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
+
dialect: dataApi,
|
|
28
29
|
});
|
|
29
|
-
const
|
|
30
|
-
logger("introspected tables");
|
|
31
|
-
const metadata = db.engine.includes("postgres")
|
|
32
|
-
? tables.map((table) => ({
|
|
33
|
-
...table,
|
|
34
|
-
columns: table.columns.map((column) => {
|
|
35
|
-
const isArray = column.dataType.startsWith("_");
|
|
36
|
-
return {
|
|
37
|
-
...column,
|
|
38
|
-
dataType: isArray ? column.dataType.slice(1) : column.dataType,
|
|
39
|
-
enumValues: null,
|
|
40
|
-
isArray,
|
|
41
|
-
};
|
|
42
|
-
}),
|
|
43
|
-
}))
|
|
44
|
-
: tables.map((table) => ({
|
|
45
|
-
...table,
|
|
46
|
-
columns: table.columns.map((column) => ({
|
|
47
|
-
...column,
|
|
48
|
-
enumValues: null,
|
|
49
|
-
})),
|
|
50
|
-
}));
|
|
51
|
-
logger("generated metadata", metadata.length);
|
|
52
|
-
const transformer = new Transformer();
|
|
53
|
-
const Dialect = db.engine.includes("postgres")
|
|
30
|
+
const dialect = db.engine.includes("postgres")
|
|
54
31
|
? new PostgresDialect()
|
|
55
32
|
: new MysqlDialect();
|
|
33
|
+
const instrospection = await dialect.introspector.introspect({
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
db: k,
|
|
36
|
+
});
|
|
37
|
+
logger("introspected tables");
|
|
38
|
+
const transformer = new Transformer();
|
|
56
39
|
const nodes = transformer.transform({
|
|
57
|
-
dialect:
|
|
40
|
+
dialect: dialect,
|
|
58
41
|
camelCase: db.types.camelCase === true,
|
|
59
|
-
metadata:
|
|
42
|
+
metadata: instrospection,
|
|
60
43
|
});
|
|
61
44
|
logger("transformed nodes", nodes.length);
|
|
62
45
|
const lastIndex = nodes.length - 1;
|
|
@@ -14,6 +14,7 @@ export const usePothosBuilder = Context.memo(() => {
|
|
|
14
14
|
try {
|
|
15
15
|
const schema = await Pothos.generate({
|
|
16
16
|
schema: route.schema,
|
|
17
|
+
internalPackages: route.internalPackages,
|
|
17
18
|
});
|
|
18
19
|
await fs.writeFile(route.output, schema);
|
|
19
20
|
// bus.publish("pothos.extracted", { file: route.output });
|
package/constructs/Api.d.ts
CHANGED
|
@@ -586,6 +586,10 @@ export interface ApiGraphQLRouteProps<AuthorizerKeys> extends ApiBaseRouteProps<
|
|
|
586
586
|
* Commands to run after generating schema. Useful for code generation steps
|
|
587
587
|
*/
|
|
588
588
|
commands?: string[];
|
|
589
|
+
/**
|
|
590
|
+
* List of packages that should be considered internal during schema generation
|
|
591
|
+
*/
|
|
592
|
+
internalPackages?: string[];
|
|
589
593
|
};
|
|
590
594
|
}
|
|
591
595
|
/**
|
|
@@ -753,6 +757,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
|
|
|
753
757
|
stack: string;
|
|
754
758
|
} | undefined;
|
|
755
759
|
schema?: undefined;
|
|
760
|
+
internalPackages?: undefined;
|
|
756
761
|
output?: undefined;
|
|
757
762
|
commands?: undefined;
|
|
758
763
|
} | {
|
|
@@ -763,6 +768,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
|
|
|
763
768
|
stack: string;
|
|
764
769
|
} | undefined;
|
|
765
770
|
schema: string | undefined;
|
|
771
|
+
internalPackages: string[] | undefined;
|
|
766
772
|
output: string | undefined;
|
|
767
773
|
commands: string[] | undefined;
|
|
768
774
|
} | {
|
|
@@ -770,6 +776,7 @@ export declare class Api<Authorizers extends Record<string, ApiAuthorizer> = Rec
|
|
|
770
776
|
route: string;
|
|
771
777
|
fn?: undefined;
|
|
772
778
|
schema?: undefined;
|
|
779
|
+
internalPackages?: undefined;
|
|
773
780
|
output?: undefined;
|
|
774
781
|
commands?: undefined;
|
|
775
782
|
})[];
|
package/constructs/Api.js
CHANGED
|
@@ -231,6 +231,7 @@ export class Api extends Construct {
|
|
|
231
231
|
route: key,
|
|
232
232
|
fn: getFunctionRef(data.function),
|
|
233
233
|
schema: data.schema,
|
|
234
|
+
internalPackages: data.internalPackages,
|
|
234
235
|
output: data.output,
|
|
235
236
|
commands: data.commands,
|
|
236
237
|
};
|
|
@@ -591,6 +592,7 @@ export class Api extends Construct {
|
|
|
591
592
|
output: routeProps.pothos?.output,
|
|
592
593
|
schema: routeProps.pothos?.schema,
|
|
593
594
|
commands: routeProps.pothos?.commands,
|
|
595
|
+
internalPackages: routeProps.pothos?.internalPackages,
|
|
594
596
|
};
|
|
595
597
|
}
|
|
596
598
|
return result;
|
package/constructs/SsrSite.js
CHANGED
|
@@ -8,7 +8,7 @@ import { execSync } from "child_process";
|
|
|
8
8
|
import { Construct } from "constructs";
|
|
9
9
|
import { Fn, Token, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
|
|
10
10
|
import { BlockPublicAccess, Bucket, } from "aws-cdk-lib/aws-s3";
|
|
11
|
-
import { Role, Effect, Policy, PolicyStatement,
|
|
11
|
+
import { Role, Effect, Policy, PolicyStatement, AccountPrincipal, } from "aws-cdk-lib/aws-iam";
|
|
12
12
|
import { Function as CdkFunction, Code, Runtime, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
|
|
13
13
|
import { HostedZone, ARecord, AaaaRecord, RecordTarget, } from "aws-cdk-lib/aws-route53";
|
|
14
14
|
import { Asset } from "aws-cdk-lib/aws-s3-assets";
|
|
@@ -430,8 +430,9 @@ export class SsrSite extends Construct {
|
|
|
430
430
|
}
|
|
431
431
|
createFunctionForDev() {
|
|
432
432
|
const { runtime, timeout, memorySize, permissions, environment, bind } = this.props;
|
|
433
|
+
const app = this.node.root;
|
|
433
434
|
const role = new Role(this, "ServerFunctionRole", {
|
|
434
|
-
assumedBy: new
|
|
435
|
+
assumedBy: new AccountPrincipal(app.account),
|
|
435
436
|
maxSessionDuration: CdkDuration.hours(12),
|
|
436
437
|
});
|
|
437
438
|
const ssrFn = new SsrFunction(this, `ServerFunction`, {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.8.
|
|
4
|
+
"version": "2.8.7",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"immer": "9",
|
|
73
73
|
"ink": "^4.0.0",
|
|
74
74
|
"ink-spinner": "^5.0.0",
|
|
75
|
-
"kysely": "^0.23.
|
|
76
|
-
"kysely-codegen": "^0.
|
|
75
|
+
"kysely": "^0.23.5",
|
|
76
|
+
"kysely-codegen": "^0.10.0",
|
|
77
77
|
"kysely-data-api": "^0.2.0",
|
|
78
78
|
"minimatch": "^6.1.6",
|
|
79
79
|
"openid-client": "^5.1.8",
|
package/pothos.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * as Pothos from "./pothos.js";
|
|
2
2
|
interface GenerateOpts {
|
|
3
3
|
schema: string;
|
|
4
|
+
internalPackages?: string[];
|
|
4
5
|
}
|
|
5
6
|
export declare function generate(opts: GenerateOpts): Promise<string>;
|
|
6
|
-
export declare function extractSchema(opts:
|
|
7
|
-
schema: string;
|
|
8
|
-
}): Promise<any>;
|
|
7
|
+
export declare function extractSchema(opts: GenerateOpts): Promise<any>;
|
package/pothos.js
CHANGED
|
@@ -32,6 +32,9 @@ export async function extractSchema(opts) {
|
|
|
32
32
|
setup(build) {
|
|
33
33
|
const filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/; // Must not start with "/" or "./" or "../"
|
|
34
34
|
build.onResolve({ filter }, (args) => {
|
|
35
|
+
const packageName = args.path.match(/^(@[^\/]+\/[^\/]+|[^@/]+)/);
|
|
36
|
+
if (packageName && opts.internalPackages?.includes(packageName[0]))
|
|
37
|
+
return;
|
|
35
38
|
return {
|
|
36
39
|
path: args.path,
|
|
37
40
|
external: true,
|
|
@@ -42,7 +42,7 @@ export const useDotnetHandler = Context.memo(async () => {
|
|
|
42
42
|
const name = input.handler.split(":")[0];
|
|
43
43
|
const proc = spawn(`dotnet`, [
|
|
44
44
|
`exec`,
|
|
45
|
-
url.fileURLToPath(new URL(`../../support/${BOOTSTRAP_MAP[
|
|
45
|
+
url.fileURLToPath(new URL(`../../support/${BOOTSTRAP_MAP[input.runtime]}/release/dotnet-bootstrap.dll`, import.meta.url)),
|
|
46
46
|
name + ".dll",
|
|
47
47
|
input.handler,
|
|
48
48
|
], {
|
|
@@ -81,7 +81,7 @@ export const useDotnetHandler = Context.memo(async () => {
|
|
|
81
81
|
"dotnet",
|
|
82
82
|
"publish",
|
|
83
83
|
"--output",
|
|
84
|
-
input.out,
|
|
84
|
+
'"' + input.out + '"',
|
|
85
85
|
"--configuration",
|
|
86
86
|
"Release",
|
|
87
87
|
"--framework",
|
|
@@ -104,6 +104,7 @@ export const useDotnetHandler = Context.memo(async () => {
|
|
|
104
104
|
return {
|
|
105
105
|
type: "success",
|
|
106
106
|
handler: input.props.handler,
|
|
107
|
+
runtime: input.props.runtime,
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
catch (ex) {
|
package/runtime/handlers.d.ts
CHANGED
package/runtime/workers.js
CHANGED
|
@@ -45,6 +45,7 @@ export const useRuntimeWorkers = Context.memo(async () => {
|
|
|
45
45
|
workerID: evt.properties.workerID,
|
|
46
46
|
environment: evt.properties.env,
|
|
47
47
|
url: `${server.url}/${evt.properties.workerID}/${server.API_VERSION}`,
|
|
48
|
+
runtime: props.runtime,
|
|
48
49
|
});
|
|
49
50
|
workers.set(evt.properties.workerID, {
|
|
50
51
|
workerID: evt.properties.workerID,
|
package/sst.mjs
CHANGED
|
@@ -3960,7 +3960,8 @@ var init_workers = __esm({
|
|
|
3960
3960
|
...build2,
|
|
3961
3961
|
workerID: evt.properties.workerID,
|
|
3962
3962
|
environment: evt.properties.env,
|
|
3963
|
-
url: `${server.url}/${evt.properties.workerID}/${server.API_VERSION}
|
|
3963
|
+
url: `${server.url}/${evt.properties.workerID}/${server.API_VERSION}`,
|
|
3964
|
+
runtime: props.runtime
|
|
3964
3965
|
});
|
|
3965
3966
|
workers.set(evt.properties.workerID, {
|
|
3966
3967
|
workerID: evt.properties.workerID,
|
|
@@ -4069,7 +4070,7 @@ var init_dotnet = __esm({
|
|
|
4069
4070
|
`exec`,
|
|
4070
4071
|
url3.fileURLToPath(
|
|
4071
4072
|
new URL(
|
|
4072
|
-
`../../support/${BOOTSTRAP_MAP[
|
|
4073
|
+
`../../support/${BOOTSTRAP_MAP[input.runtime]}/release/dotnet-bootstrap.dll`,
|
|
4073
4074
|
import.meta.url
|
|
4074
4075
|
)
|
|
4075
4076
|
),
|
|
@@ -4114,7 +4115,7 @@ var init_dotnet = __esm({
|
|
|
4114
4115
|
"dotnet",
|
|
4115
4116
|
"publish",
|
|
4116
4117
|
"--output",
|
|
4117
|
-
input.out,
|
|
4118
|
+
'"' + input.out + '"',
|
|
4118
4119
|
"--configuration",
|
|
4119
4120
|
"Release",
|
|
4120
4121
|
"--framework",
|
|
@@ -4131,7 +4132,8 @@ var init_dotnet = __esm({
|
|
|
4131
4132
|
);
|
|
4132
4133
|
return {
|
|
4133
4134
|
type: "success",
|
|
4134
|
-
handler: input.props.handler
|
|
4135
|
+
handler: input.props.handler,
|
|
4136
|
+
runtime: input.props.runtime
|
|
4135
4137
|
};
|
|
4136
4138
|
} catch (ex) {
|
|
4137
4139
|
return {
|
|
@@ -6172,6 +6174,9 @@ async function extractSchema(opts) {
|
|
|
6172
6174
|
setup(build2) {
|
|
6173
6175
|
const filter = /^[^.\/]|^\.[^.\/]|^\.\.[^\/]/;
|
|
6174
6176
|
build2.onResolve({ filter }, (args) => {
|
|
6177
|
+
const packageName = args.path.match(/^(@[^\/]+\/[^\/]+|[^@/]+)/);
|
|
6178
|
+
if (packageName && opts.internalPackages?.includes(packageName[0]))
|
|
6179
|
+
return;
|
|
6175
6180
|
return {
|
|
6176
6181
|
path: args.path,
|
|
6177
6182
|
external: true
|
|
@@ -6320,7 +6325,8 @@ var init_pothos2 = __esm({
|
|
|
6320
6325
|
async function build2(route) {
|
|
6321
6326
|
try {
|
|
6322
6327
|
const schema = await pothos_exports.generate({
|
|
6323
|
-
schema: route.schema
|
|
6328
|
+
schema: route.schema,
|
|
6329
|
+
internalPackages: route.internalPackages
|
|
6324
6330
|
});
|
|
6325
6331
|
await fs15.writeFile(route.output, schema);
|
|
6326
6332
|
if (Array.isArray(route.commands) && route.commands.length > 0) {
|
|
@@ -6368,8 +6374,6 @@ import { DataApiDialect } from "kysely-data-api";
|
|
|
6368
6374
|
import { RDSData } from "@aws-sdk/client-rds-data";
|
|
6369
6375
|
import * as fs16 from "fs/promises";
|
|
6370
6376
|
import {
|
|
6371
|
-
DatabaseMetadata,
|
|
6372
|
-
EnumCollection,
|
|
6373
6377
|
PostgresDialect,
|
|
6374
6378
|
MysqlDialect,
|
|
6375
6379
|
Serializer,
|
|
@@ -6391,44 +6395,28 @@ var init_kysely = __esm({
|
|
|
6391
6395
|
if (!db.types)
|
|
6392
6396
|
return;
|
|
6393
6397
|
logger("generating types for", db.migratorID);
|
|
6398
|
+
const dataApi = new DataApiDialect({
|
|
6399
|
+
mode: db.engine.includes("postgres") ? "postgres" : "mysql",
|
|
6400
|
+
driver: {
|
|
6401
|
+
secretArn: db.secretArn,
|
|
6402
|
+
resourceArn: db.clusterArn,
|
|
6403
|
+
database: db.defaultDatabaseName,
|
|
6404
|
+
client: useAWSClient(RDSData)
|
|
6405
|
+
}
|
|
6406
|
+
});
|
|
6394
6407
|
const k = new Kysely({
|
|
6395
|
-
dialect:
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
database: db.defaultDatabaseName,
|
|
6401
|
-
client: useAWSClient(RDSData)
|
|
6402
|
-
}
|
|
6403
|
-
})
|
|
6408
|
+
dialect: dataApi
|
|
6409
|
+
});
|
|
6410
|
+
const dialect = db.engine.includes("postgres") ? new PostgresDialect() : new MysqlDialect();
|
|
6411
|
+
const instrospection = await dialect.introspector.introspect({
|
|
6412
|
+
db: k
|
|
6404
6413
|
});
|
|
6405
|
-
const tables = await k.introspection.getTables();
|
|
6406
6414
|
logger("introspected tables");
|
|
6407
|
-
const metadata3 = db.engine.includes("postgres") ? tables.map((table) => ({
|
|
6408
|
-
...table,
|
|
6409
|
-
columns: table.columns.map((column) => {
|
|
6410
|
-
const isArray = column.dataType.startsWith("_");
|
|
6411
|
-
return {
|
|
6412
|
-
...column,
|
|
6413
|
-
dataType: isArray ? column.dataType.slice(1) : column.dataType,
|
|
6414
|
-
enumValues: null,
|
|
6415
|
-
isArray
|
|
6416
|
-
};
|
|
6417
|
-
})
|
|
6418
|
-
})) : tables.map((table) => ({
|
|
6419
|
-
...table,
|
|
6420
|
-
columns: table.columns.map((column) => ({
|
|
6421
|
-
...column,
|
|
6422
|
-
enumValues: null
|
|
6423
|
-
}))
|
|
6424
|
-
}));
|
|
6425
|
-
logger("generated metadata", metadata3.length);
|
|
6426
6415
|
const transformer = new Transformer();
|
|
6427
|
-
const Dialect = db.engine.includes("postgres") ? new PostgresDialect() : new MysqlDialect();
|
|
6428
6416
|
const nodes = transformer.transform({
|
|
6429
|
-
dialect
|
|
6417
|
+
dialect,
|
|
6430
6418
|
camelCase: db.types.camelCase === true,
|
|
6431
|
-
metadata:
|
|
6419
|
+
metadata: instrospection
|
|
6432
6420
|
});
|
|
6433
6421
|
logger("transformed nodes", nodes.length);
|
|
6434
6422
|
const lastIndex = nodes.length - 1;
|