Skip to content

Commit 185f914

Browse files
jordanhunt22Convex, Inc.
authored andcommitted
[Node Migration] Add system udf to query lambda version (#40555)
GitOrigin-RevId: c4d48519cc38ee2a4aef5ef006e609de755adfe0
1 parent fd5b65a commit 185f914

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

npm-packages/system-udfs/convex/_generated/api.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import type * as _system_frontend_listDeploymentEventsFromTime from "../_system/
5050
import type * as _system_frontend_listEnvironmentVariables from "../_system/frontend/listEnvironmentVariables.js";
5151
import type * as _system_frontend_listTableScan from "../_system/frontend/listTableScan.js";
5252
import type * as _system_frontend_modules from "../_system/frontend/modules.js";
53+
import type * as _system_frontend_node from "../_system/frontend/node.js";
5354
import type * as _system_frontend_paginatedDeploymentEvents from "../_system/frontend/paginatedDeploymentEvents.js";
5455
import type * as _system_frontend_paginatedScheduledJobs from "../_system/frontend/paginatedScheduledJobs.js";
5556
import type * as _system_frontend_paginatedTableDocuments from "../_system/frontend/paginatedTableDocuments.js";
@@ -62,6 +63,7 @@ import type * as _system_paginationLimits from "../_system/paginationLimits.js";
6263
import type * as _system_repl_wrappers from "../_system/repl/wrappers.js";
6364
import type * as _system_secretSystemTables from "../_system/secretSystemTables.js";
6465
import type * as _system_server from "../_system/server.js";
66+
import type * as tableDefs_awsLambdaVersions from "../tableDefs/awsLambdaVersions.js";
6567
import type * as tableDefs_deploymentAuditLogTable from "../tableDefs/deploymentAuditLogTable.js";
6668
import type * as tableDefs_snapshotImport from "../tableDefs/snapshotImport.js";
6769

@@ -111,6 +113,7 @@ declare const fullApi: ApiFromModules<{
111113
"_system/frontend/listEnvironmentVariables": typeof _system_frontend_listEnvironmentVariables;
112114
"_system/frontend/listTableScan": typeof _system_frontend_listTableScan;
113115
"_system/frontend/modules": typeof _system_frontend_modules;
116+
"_system/frontend/node": typeof _system_frontend_node;
114117
"_system/frontend/paginatedDeploymentEvents": typeof _system_frontend_paginatedDeploymentEvents;
115118
"_system/frontend/paginatedScheduledJobs": typeof _system_frontend_paginatedScheduledJobs;
116119
"_system/frontend/paginatedTableDocuments": typeof _system_frontend_paginatedTableDocuments;
@@ -123,6 +126,7 @@ declare const fullApi: ApiFromModules<{
123126
"_system/repl/wrappers": typeof _system_repl_wrappers;
124127
"_system/secretSystemTables": typeof _system_secretSystemTables;
125128
"_system/server": typeof _system_server;
129+
"tableDefs/awsLambdaVersions": typeof tableDefs_awsLambdaVersions;
126130
"tableDefs/deploymentAuditLogTable": typeof tableDefs_deploymentAuditLogTable;
127131
"tableDefs/snapshotImport": typeof tableDefs_snapshotImport;
128132
}>;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { queryPrivateSystem } from "../secretSystemTables";
2+
3+
export const version = queryPrivateSystem({
4+
args: {},
5+
handler: async function ({ db }) {
6+
const version = await db
7+
.query("_aws_lambda_versions")
8+
.order("desc")
9+
.filter((q) => q.eq(q.field("typeConfig.type"), "static"))
10+
.first();
11+
12+
if (!version) {
13+
return null;
14+
}
15+
16+
return version.lambdaConfig.runtime;
17+
},
18+
});

npm-packages/system-udfs/convex/schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import deploymentAuditLogTable, {
44
deploymentState,
55
} from "./tableDefs/deploymentAuditLogTable";
66
import { snapshotImportsTable } from "./tableDefs/snapshotImport";
7+
import { awsLambdaVersionsTable } from "./tableDefs/awsLambdaVersions";
78

89
// This file isn't autogenerated, it must be manually synced with system tables.
910

@@ -438,4 +439,5 @@ export default defineSchema({
438439
_log_sinks: logSinksTable,
439440
_backend_state: backendStateTable,
440441
_snapshot_imports: snapshotImportsTable,
442+
_aws_lambda_versions: awsLambdaVersionsTable,
441443
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineTable } from "convex/server";
2+
import { v } from "convex/values";
3+
4+
export const awsLambdaVersionsTable = defineTable({
5+
lambdaName: v.string(),
6+
lambdaVersion: v.string(),
7+
lambdaConfig: v.object({
8+
runtime: v.string(),
9+
}),
10+
typeConfig: v.object({
11+
type: v.string(),
12+
}),
13+
});

0 commit comments

Comments
 (0)