@neon/tools 2.15.0 → 2.16.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 +117 -4
- package/dist/descriptions.gen.js +2 -2
- package/dist/generated/zod.gen.d.ts +3 -3
- package/dist/index.d.ts +17 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -9
- package/dist/lib/custom/auth-config.d.ts +0 -1
- package/dist/lib/custom/auth-config.d.ts.map +1 -1
- package/dist/lib/custom/auth-config.js +13 -6
- package/dist/lib/custom/docs.d.ts.map +1 -1
- package/dist/lib/custom/docs.js +2 -0
- package/dist/lib/custom/feedback.d.ts.map +1 -1
- package/dist/lib/custom/feedback.js +1 -0
- package/dist/lib/custom/fetch.d.ts.map +1 -1
- package/dist/lib/custom/fetch.js +1 -0
- package/dist/lib/custom/organizations.d.ts.map +1 -1
- package/dist/lib/custom/organizations.js +1 -0
- package/dist/lib/custom/resources.d.ts.map +1 -1
- package/dist/lib/custom/resources.js +1 -0
- package/dist/lib/custom/sql/connection.d.ts +6 -7
- package/dist/lib/custom/sql/connection.d.ts.map +1 -1
- package/dist/lib/custom/sql/connection.js +9 -11
- package/dist/lib/custom/sql/describe-branch.js +2 -2
- package/dist/lib/custom/sql/inspect/inspect.js +2 -2
- package/dist/lib/custom/sql/migrations.d.ts.map +1 -1
- package/dist/lib/custom/sql/migrations.js +3 -5
- package/dist/lib/custom/sql/query-tuning.d.ts.map +1 -1
- package/dist/lib/custom/sql/query-tuning.js +3 -5
- package/dist/lib/custom/sql/run.d.ts.map +1 -1
- package/dist/lib/custom/sql/run.js +4 -5
- package/dist/lib/custom/sql/schema.js +3 -3
- package/dist/lib/custom/sql/slow-queries.js +2 -2
- package/dist/lib/customize.d.ts +1 -1
- package/dist/lib/customize.d.ts.map +1 -1
- package/dist/lib/customize.js +8 -4
- package/dist/lib/ergonomic/bind.d.ts +10 -6
- package/dist/lib/ergonomic/bind.d.ts.map +1 -1
- package/dist/lib/ergonomic/bind.js +11 -2
- package/dist/lib/ergonomic/catalog.d.ts +2 -8
- package/dist/lib/ergonomic/catalog.d.ts.map +1 -1
- package/dist/lib/ergonomic/catalog.js +100 -22
- package/dist/lib/ergonomic/composed.d.ts.map +1 -1
- package/dist/lib/ergonomic/composed.js +29 -0
- package/dist/lib/operation.d.ts +50 -4
- package/dist/lib/operation.d.ts.map +1 -1
- package/dist/lib/operation.js +6 -1
- package/dist/lib/policy.d.ts +24 -0
- package/dist/lib/policy.d.ts.map +1 -0
- package/dist/lib/policy.js +49 -0
- package/dist/lib/redact.d.ts +8 -0
- package/dist/lib/redact.d.ts.map +1 -0
- package/dist/lib/redact.js +40 -0
- package/dist/mastra.d.ts +2 -1
- package/dist/mastra.d.ts.map +1 -1
- package/dist/operations.gen.d.ts +388 -388
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { decodeBase64 } from "../binary.js";
|
|
2
2
|
import { toToolResult } from "../result.js";
|
|
3
|
+
import { toolMetadata } from "../operation.js";
|
|
3
4
|
import { bindTool, collectObjectList, collectPages, fromGenerated, publishedId } from "./bind.js";
|
|
4
5
|
import { describeTableTool, listTablesTool } from "../custom/sql/schema.js";
|
|
5
6
|
import { inspectDatabaseTool } from "../custom/sql/inspect/inspect.js";
|
|
@@ -25,18 +26,6 @@ const logReadAnnotations = {
|
|
|
25
26
|
idempotentHint: true,
|
|
26
27
|
openWorldHint: false
|
|
27
28
|
};
|
|
28
|
-
const withoutSmtpPassword = (config) => config.type === "standard" ? {
|
|
29
|
-
...config,
|
|
30
|
-
password: ""
|
|
31
|
-
} : config;
|
|
32
|
-
const withoutPluginSecrets = (plugins) => ({
|
|
33
|
-
...plugins,
|
|
34
|
-
...plugins.email_provider && { email_provider: withoutSmtpPassword(plugins.email_provider) },
|
|
35
|
-
...plugins.oauth_providers && { oauth_providers: plugins.oauth_providers.map((provider) => provider.client_secret === void 0 ? provider : {
|
|
36
|
-
...provider,
|
|
37
|
-
client_secret: ""
|
|
38
|
-
}) }
|
|
39
|
-
});
|
|
40
29
|
const listIncidentsInputSchema = z.strictObject({});
|
|
41
30
|
const listIncidentsOutputSchema = z.looseObject({
|
|
42
31
|
status: z.string().describe("Overall status: operational, degraded, or outage."),
|
|
@@ -85,13 +74,14 @@ const listIncidentsTool = (options) => ({
|
|
|
85
74
|
openWorldHint: true
|
|
86
75
|
},
|
|
87
76
|
requiresApproval: false,
|
|
88
|
-
metadata: {
|
|
77
|
+
metadata: toolMetadata({
|
|
89
78
|
method: "GET",
|
|
79
|
+
readOnlySafe: true,
|
|
90
80
|
path: NEON_STATUS_API_URL,
|
|
91
81
|
stability: "stable",
|
|
92
82
|
deprecated: false,
|
|
93
83
|
tags: ["Status"]
|
|
94
|
-
},
|
|
84
|
+
}),
|
|
95
85
|
async execute(input, context) {
|
|
96
86
|
await listIncidentsInputSchema.parseAsync(input);
|
|
97
87
|
return toToolResult(await listNeonIncidents({
|
|
@@ -403,6 +393,10 @@ const toolFactories = {
|
|
|
403
393
|
id: "postgres.roles.list",
|
|
404
394
|
generated: "listProjectBranchRoles",
|
|
405
395
|
output: RolesResponse.shape.roles,
|
|
396
|
+
secretOutputFields: [{
|
|
397
|
+
path: "$[*].password",
|
|
398
|
+
kind: "setup"
|
|
399
|
+
}],
|
|
406
400
|
run: (neon, input, signal) => neon.postgres.roles.list({
|
|
407
401
|
projectId: input.project_id,
|
|
408
402
|
branchId: input.branch_id
|
|
@@ -412,6 +406,10 @@ const toolFactories = {
|
|
|
412
406
|
id: "postgres.roles.get",
|
|
413
407
|
generated: "getProjectBranchRole",
|
|
414
408
|
output: Role,
|
|
409
|
+
secretOutputFields: [{
|
|
410
|
+
path: "$.password",
|
|
411
|
+
kind: "setup"
|
|
412
|
+
}],
|
|
415
413
|
run: (neon, input, signal) => neon.postgres.roles.get({
|
|
416
414
|
projectId: input.project_id,
|
|
417
415
|
branchId: input.branch_id,
|
|
@@ -433,6 +431,11 @@ const toolFactories = {
|
|
|
433
431
|
id: "postgres.roles.resetPassword",
|
|
434
432
|
generated: "resetProjectBranchRolePassword",
|
|
435
433
|
output: Role,
|
|
434
|
+
secretOutputFields: [{
|
|
435
|
+
path: "$.password",
|
|
436
|
+
kind: "setup"
|
|
437
|
+
}],
|
|
438
|
+
returnsOnlySecrets: true,
|
|
436
439
|
run: (neon, input, signal) => neon.postgres.roles.resetPassword({
|
|
437
440
|
projectId: input.project_id,
|
|
438
441
|
branchId: input.branch_id,
|
|
@@ -639,6 +642,11 @@ const toolFactories = {
|
|
|
639
642
|
id: "storage.objects.presign",
|
|
640
643
|
generated: "presignProjectBranchBucketObject",
|
|
641
644
|
output: PresignResponse,
|
|
645
|
+
secretOutputFields: [{
|
|
646
|
+
path: "$.url",
|
|
647
|
+
kind: "setup"
|
|
648
|
+
}],
|
|
649
|
+
returnsOnlySecrets: true,
|
|
642
650
|
run: (neon, input, signal) => neon.storage.objects.presign({
|
|
643
651
|
projectId: input.project_id,
|
|
644
652
|
branchId: input.branch_id,
|
|
@@ -802,6 +810,13 @@ const toolFactories = {
|
|
|
802
810
|
id: "credentials.create",
|
|
803
811
|
generated: "createCredential",
|
|
804
812
|
output: CreateCredentialResponse,
|
|
813
|
+
secretOutputFields: [{
|
|
814
|
+
path: "$.api_token",
|
|
815
|
+
kind: "setup"
|
|
816
|
+
}, {
|
|
817
|
+
path: "$.s3_secret_access_key",
|
|
818
|
+
kind: "setup"
|
|
819
|
+
}],
|
|
805
820
|
run: (neon, input, signal) => neon.credentials.create({
|
|
806
821
|
projectId: input.project_id,
|
|
807
822
|
branchId: input.branch_id,
|
|
@@ -824,6 +839,14 @@ const toolFactories = {
|
|
|
824
839
|
id: "credentials.rotate",
|
|
825
840
|
generated: "rotateCredential",
|
|
826
841
|
output: RotateCredentialResponse,
|
|
842
|
+
secretOutputFields: [{
|
|
843
|
+
path: "$.api_token",
|
|
844
|
+
kind: "setup"
|
|
845
|
+
}, {
|
|
846
|
+
path: "$.s3_secret_access_key",
|
|
847
|
+
kind: "setup"
|
|
848
|
+
}],
|
|
849
|
+
returnsOnlySecrets: true,
|
|
827
850
|
annotations: {
|
|
828
851
|
readOnlyHint: false,
|
|
829
852
|
destructiveHint: true,
|
|
@@ -877,6 +900,11 @@ const toolFactories = {
|
|
|
877
900
|
id: "realtime.secret",
|
|
878
901
|
generated: "getProjectBranchRealtimeSecret",
|
|
879
902
|
output: RealtimeSecret,
|
|
903
|
+
secretOutputFields: [{
|
|
904
|
+
path: "$.secret",
|
|
905
|
+
kind: "setup"
|
|
906
|
+
}],
|
|
907
|
+
returnsOnlySecrets: true,
|
|
880
908
|
requiresApproval: true,
|
|
881
909
|
run: (neon, input, signal) => neon.realtime.secret({
|
|
882
910
|
projectId: input.project_id,
|
|
@@ -906,6 +934,7 @@ const toolFactories = {
|
|
|
906
934
|
list: true,
|
|
907
935
|
annotations: logReadAnnotations,
|
|
908
936
|
requiresApproval: false,
|
|
937
|
+
readOnlySafe: true,
|
|
909
938
|
run: (neon, input, signal) => collectPages(neon.logs.query({
|
|
910
939
|
projectId: input.project_id,
|
|
911
940
|
branchId: input.branch_id,
|
|
@@ -1029,6 +1058,10 @@ const toolFactories = {
|
|
|
1029
1058
|
id: "auth.create",
|
|
1030
1059
|
generated: "createNeonAuth",
|
|
1031
1060
|
output: NeonAuthCreateIntegrationResponse,
|
|
1061
|
+
secretOutputFields: [{
|
|
1062
|
+
path: "$.secret_server_key",
|
|
1063
|
+
kind: "setup"
|
|
1064
|
+
}],
|
|
1032
1065
|
run: (neon, input, signal) => neon.auth.create({
|
|
1033
1066
|
projectId: input.project_id,
|
|
1034
1067
|
branchId: input.branch_id,
|
|
@@ -1060,6 +1093,10 @@ const toolFactories = {
|
|
|
1060
1093
|
id: "auth.oauthProviders.list",
|
|
1061
1094
|
generated: "listBranchNeonAuthOauthProviders",
|
|
1062
1095
|
output: ListNeonAuthOauthProvidersResponse.shape.providers,
|
|
1096
|
+
secretOutputFields: [{
|
|
1097
|
+
path: "$[*].client_secret",
|
|
1098
|
+
kind: "stored"
|
|
1099
|
+
}],
|
|
1063
1100
|
run: (neon, input, signal) => neon.auth.oauthProviders.list({
|
|
1064
1101
|
projectId: input.project_id,
|
|
1065
1102
|
branchId: input.branch_id
|
|
@@ -1069,6 +1106,10 @@ const toolFactories = {
|
|
|
1069
1106
|
id: "auth.oauthProviders.add",
|
|
1070
1107
|
generated: "addBranchNeonAuthOauthProvider",
|
|
1071
1108
|
output: NeonAuthOauthProvider,
|
|
1109
|
+
secretOutputFields: [{
|
|
1110
|
+
path: "$.client_secret",
|
|
1111
|
+
kind: "stored"
|
|
1112
|
+
}],
|
|
1072
1113
|
run: (neon, input, signal) => neon.auth.oauthProviders.add({
|
|
1073
1114
|
projectId: input.project_id,
|
|
1074
1115
|
branchId: input.branch_id,
|
|
@@ -1084,6 +1125,10 @@ const toolFactories = {
|
|
|
1084
1125
|
id: "auth.oauthProviders.update",
|
|
1085
1126
|
generated: "updateBranchNeonAuthOauthProvider",
|
|
1086
1127
|
output: NeonAuthOauthProvider,
|
|
1128
|
+
secretOutputFields: [{
|
|
1129
|
+
path: "$.client_secret",
|
|
1130
|
+
kind: "stored"
|
|
1131
|
+
}],
|
|
1087
1132
|
run: (neon, input, signal) => neon.auth.oauthProviders.update({
|
|
1088
1133
|
projectId: input.project_id,
|
|
1089
1134
|
branchId: input.branch_id,
|
|
@@ -1151,6 +1196,10 @@ const toolFactories = {
|
|
|
1151
1196
|
id: "auth.oauthClients.create",
|
|
1152
1197
|
generated: "createNeonAuthOAuthClient",
|
|
1153
1198
|
output: NeonAuthOAuthClientCreated,
|
|
1199
|
+
secretOutputFields: [{
|
|
1200
|
+
path: "$.client_secret",
|
|
1201
|
+
kind: "setup"
|
|
1202
|
+
}],
|
|
1154
1203
|
run: (neon, input, signal) => neon.auth.oauthClients.create({
|
|
1155
1204
|
projectId: input.project_id,
|
|
1156
1205
|
branchId: input.branch_id,
|
|
@@ -1190,6 +1239,11 @@ const toolFactories = {
|
|
|
1190
1239
|
id: "auth.oauthClients.rotateSecret",
|
|
1191
1240
|
generated: "rotateNeonAuthOAuthClientSecret",
|
|
1192
1241
|
output: NeonAuthOAuthClientSecret,
|
|
1242
|
+
secretOutputFields: [{
|
|
1243
|
+
path: "$.client_secret",
|
|
1244
|
+
kind: "setup"
|
|
1245
|
+
}],
|
|
1246
|
+
returnsOnlySecrets: true,
|
|
1193
1247
|
run: (neon, input, signal) => neon.auth.oauthClients.rotateSecret({
|
|
1194
1248
|
projectId: input.project_id,
|
|
1195
1249
|
branchId: input.branch_id,
|
|
@@ -1308,21 +1362,29 @@ const toolFactories = {
|
|
|
1308
1362
|
id: "auth.emailProvider.get",
|
|
1309
1363
|
generated: "getNeonAuthEmailProvider",
|
|
1310
1364
|
output: NeonAuthEmailServerConfigResponse,
|
|
1311
|
-
|
|
1312
|
-
|
|
1365
|
+
secretOutputFields: [{
|
|
1366
|
+
path: "$.password",
|
|
1367
|
+
kind: "stored"
|
|
1368
|
+
}],
|
|
1369
|
+
readOnlySafe: true,
|
|
1370
|
+
run: (neon, input, signal) => neon.auth.emailProvider.get({
|
|
1313
1371
|
projectId: input.project_id,
|
|
1314
1372
|
branchId: input.branch_id
|
|
1315
|
-
}, { signal })
|
|
1373
|
+
}, { signal })
|
|
1316
1374
|
}),
|
|
1317
1375
|
"auth.emailProvider.update": (options) => fromGenerated(options, {
|
|
1318
1376
|
id: "auth.emailProvider.update",
|
|
1319
1377
|
generated: "updateNeonAuthEmailProvider",
|
|
1320
1378
|
output: NeonAuthEmailServerConfigResponse,
|
|
1321
|
-
|
|
1379
|
+
secretOutputFields: [{
|
|
1380
|
+
path: "$.password",
|
|
1381
|
+
kind: "stored"
|
|
1382
|
+
}],
|
|
1383
|
+
run: (neon, input, signal) => neon.auth.emailProvider.update({
|
|
1322
1384
|
projectId: input.project_id,
|
|
1323
1385
|
branchId: input.branch_id,
|
|
1324
1386
|
...input.body
|
|
1325
|
-
}, { signal })
|
|
1387
|
+
}, { signal })
|
|
1326
1388
|
}),
|
|
1327
1389
|
"auth.emailProvider.sendTest": (options) => fromGenerated(options, {
|
|
1328
1390
|
id: "auth.emailProvider.sendTest",
|
|
@@ -1338,11 +1400,18 @@ const toolFactories = {
|
|
|
1338
1400
|
id: "auth.plugins.get",
|
|
1339
1401
|
generated: "getNeonAuthPluginConfigs",
|
|
1340
1402
|
output: NeonAuthPluginConfigs,
|
|
1341
|
-
|
|
1342
|
-
|
|
1403
|
+
secretOutputFields: [{
|
|
1404
|
+
path: "$.email_provider.password",
|
|
1405
|
+
kind: "stored"
|
|
1406
|
+
}, {
|
|
1407
|
+
path: "$.oauth_providers[*].client_secret",
|
|
1408
|
+
kind: "stored"
|
|
1409
|
+
}],
|
|
1410
|
+
readOnlySafe: true,
|
|
1411
|
+
run: (neon, input, signal) => neon.auth.plugins.get({
|
|
1343
1412
|
projectId: input.project_id,
|
|
1344
1413
|
branchId: input.branch_id
|
|
1345
|
-
}, { signal })
|
|
1414
|
+
}, { signal })
|
|
1346
1415
|
}),
|
|
1347
1416
|
"auth.plugins.magicLink.update": (options) => fromGenerated(options, {
|
|
1348
1417
|
id: "auth.plugins.magicLink.update",
|
|
@@ -1482,6 +1551,10 @@ const toolFactories = {
|
|
|
1482
1551
|
id: "apiKeys.create",
|
|
1483
1552
|
generated: "createApiKey",
|
|
1484
1553
|
output: ApiKeyCreateResponse,
|
|
1554
|
+
secretOutputFields: [{
|
|
1555
|
+
path: "$.key",
|
|
1556
|
+
kind: "setup"
|
|
1557
|
+
}],
|
|
1485
1558
|
run: (neon, input, signal) => neon.apiKeys.create({ keyName: input.key_name }, { signal })
|
|
1486
1559
|
}),
|
|
1487
1560
|
"apiKeys.revoke": (options) => fromGenerated(options, {
|
|
@@ -1583,6 +1656,10 @@ const toolFactories = {
|
|
|
1583
1656
|
id: "organizations.apiKeys.create",
|
|
1584
1657
|
generated: "createOrgApiKey",
|
|
1585
1658
|
output: OrgApiKeyCreateResponse,
|
|
1659
|
+
secretOutputFields: [{
|
|
1660
|
+
path: "$.key",
|
|
1661
|
+
kind: "setup"
|
|
1662
|
+
}],
|
|
1586
1663
|
run: (neon, input, signal) => neon.organizations.apiKeys.create({
|
|
1587
1664
|
orgId: input.org_id,
|
|
1588
1665
|
keyName: input.key_name,
|
|
@@ -1612,6 +1689,7 @@ const toolFactories = {
|
|
|
1612
1689
|
requiresApproval: false,
|
|
1613
1690
|
metadata: {
|
|
1614
1691
|
method: "GET",
|
|
1692
|
+
readOnlySafe: true,
|
|
1615
1693
|
path: "/regions",
|
|
1616
1694
|
stability: "stable",
|
|
1617
1695
|
deprecated: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composed.d.ts","sourceRoot":"","sources":["../../../src/lib/ergonomic/composed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAUzB,OAAO,EAAyB,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAwD1E,eAAO,MAAM,uBAAuB;;;;;;;;;;kBAuBjC,CAAC;AAEJ,eAAO,MAAM,iCAAiC;;;;;;;;;;kBAQ5C,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAEnC,CAAC;AAEH,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAG7C,CAAC;AAEH,eAAO,MAAM,qBAAqB;;kBAIhC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;kBAWrC,CAAC;AAIH,eAAO,MAAM,wBAAwB;;;;;;;;;kBAiBnC,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;kBAuCpC,CAAC;AAoBH,eAAO,MAAM,kBAAkB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"composed.d.ts","sourceRoot":"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BvD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC5D,CAAC;AAEH,eAAO,MAAM,iBAAiB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;CA4C1D,CAAC;AAMH,eAAO,MAAM,oBAAoB,GAAI,SAAS,iBAAiB;;;;;;;;;CAoC7D,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDvD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiC5D,CAAC;AAEH,eAAO,MAAM,eAAe,GAAI,SAAS,iBAAiB;;;;;;;;;;;;;;;;CA8BxD,CAAC"}
|
|
@@ -108,6 +108,7 @@ const lokiQueryRangeTool = (options) => bindTool(options, {
|
|
|
108
108
|
requiresApproval: false,
|
|
109
109
|
metadata: {
|
|
110
110
|
method: "GET",
|
|
111
|
+
readOnlySafe: true,
|
|
111
112
|
path: "/telemetry/v1/projects/{project_id}/branches/{branch_id}/loki/api/v1/query_range",
|
|
112
113
|
stability: "beta",
|
|
113
114
|
deprecated: false,
|
|
@@ -183,6 +184,7 @@ const createBranchTool = (options) => bindTool(options, {
|
|
|
183
184
|
requiresApproval: true,
|
|
184
185
|
metadata: {
|
|
185
186
|
method: "POST",
|
|
187
|
+
readOnlySafe: false,
|
|
186
188
|
path: "/projects/{project_id}/branches",
|
|
187
189
|
stability: "stable",
|
|
188
190
|
deprecated: false,
|
|
@@ -218,6 +220,11 @@ const createBranchAndConnectTool = (options) => bindTool(options, {
|
|
|
218
220
|
requiresApproval: true,
|
|
219
221
|
metadata: {
|
|
220
222
|
method: "POST",
|
|
223
|
+
readOnlySafe: false,
|
|
224
|
+
secretOutputFields: [{
|
|
225
|
+
path: "$.connectionString",
|
|
226
|
+
kind: "setup"
|
|
227
|
+
}],
|
|
221
228
|
path: "/projects/{project_id}/branches",
|
|
222
229
|
stability: "stable",
|
|
223
230
|
deprecated: false,
|
|
@@ -241,6 +248,7 @@ const createProjectTool = (options) => bindTool(options, {
|
|
|
241
248
|
requiresApproval: true,
|
|
242
249
|
metadata: {
|
|
243
250
|
method: "POST",
|
|
251
|
+
readOnlySafe: false,
|
|
244
252
|
path: "/projects",
|
|
245
253
|
stability: "stable",
|
|
246
254
|
deprecated: false,
|
|
@@ -262,6 +270,11 @@ const createProjectAndConnectTool = (options) => bindTool(options, {
|
|
|
262
270
|
requiresApproval: true,
|
|
263
271
|
metadata: {
|
|
264
272
|
method: "POST",
|
|
273
|
+
readOnlySafe: false,
|
|
274
|
+
secretOutputFields: [{
|
|
275
|
+
path: "$.connectionString",
|
|
276
|
+
kind: "setup"
|
|
277
|
+
}],
|
|
265
278
|
path: "/projects",
|
|
266
279
|
stability: "stable",
|
|
267
280
|
deprecated: false,
|
|
@@ -279,6 +292,7 @@ const getDefaultTool = (options) => bindTool(options, {
|
|
|
279
292
|
requiresApproval: false,
|
|
280
293
|
metadata: {
|
|
281
294
|
method: "GET",
|
|
295
|
+
readOnlySafe: true,
|
|
282
296
|
path: "/projects/{project_id}/branches",
|
|
283
297
|
stability: "stable",
|
|
284
298
|
deprecated: false,
|
|
@@ -296,6 +310,7 @@ const resetFromParentTool = (options) => bindTool(options, {
|
|
|
296
310
|
requiresApproval: true,
|
|
297
311
|
metadata: {
|
|
298
312
|
method: "POST",
|
|
313
|
+
readOnlySafe: false,
|
|
299
314
|
path: "/projects/{project_id}/branches/{branch_id}/restore",
|
|
300
315
|
stability: "stable",
|
|
301
316
|
deprecated: false,
|
|
@@ -317,6 +332,7 @@ const compareSchemaTool = (options) => bindTool(options, {
|
|
|
317
332
|
requiresApproval: false,
|
|
318
333
|
metadata: {
|
|
319
334
|
method: "GET",
|
|
335
|
+
readOnlySafe: true,
|
|
320
336
|
path: "/projects/{project_id}/branches/{branch_id}/compare_schema",
|
|
321
337
|
stability: "stable",
|
|
322
338
|
deprecated: false,
|
|
@@ -344,6 +360,12 @@ const connectionStringTool = (options) => bindTool(options, {
|
|
|
344
360
|
requiresApproval: true,
|
|
345
361
|
metadata: {
|
|
346
362
|
method: "GET",
|
|
363
|
+
readOnlySafe: false,
|
|
364
|
+
secretOutputFields: [{
|
|
365
|
+
path: "$",
|
|
366
|
+
kind: "setup"
|
|
367
|
+
}],
|
|
368
|
+
returnsOnlySecrets: true,
|
|
347
369
|
path: "/projects/{project_id}/connection_uri",
|
|
348
370
|
stability: "stable",
|
|
349
371
|
deprecated: false,
|
|
@@ -367,6 +389,11 @@ const createRoleTool = (options) => bindTool(options, {
|
|
|
367
389
|
requiresApproval: true,
|
|
368
390
|
metadata: {
|
|
369
391
|
method: "POST",
|
|
392
|
+
readOnlySafe: false,
|
|
393
|
+
secretOutputFields: [{
|
|
394
|
+
path: "$.password",
|
|
395
|
+
kind: "setup"
|
|
396
|
+
}],
|
|
370
397
|
path: "/projects/{project_id}/branches/{branch_id}/roles",
|
|
371
398
|
stability: "stable",
|
|
372
399
|
deprecated: false,
|
|
@@ -398,6 +425,7 @@ const restoreSnapshotTool = (options) => bindTool(options, {
|
|
|
398
425
|
requiresApproval: true,
|
|
399
426
|
metadata: {
|
|
400
427
|
method: "POST",
|
|
428
|
+
readOnlySafe: false,
|
|
401
429
|
path: "/projects/{project_id}/snapshots/{snapshot_id}/restore",
|
|
402
430
|
stability: "stable",
|
|
403
431
|
deprecated: false,
|
|
@@ -421,6 +449,7 @@ const setScheduleTool = (options) => bindTool(options, {
|
|
|
421
449
|
requiresApproval: true,
|
|
422
450
|
metadata: {
|
|
423
451
|
method: "PUT",
|
|
452
|
+
readOnlySafe: false,
|
|
424
453
|
path: "/projects/{project_id}/branches/{branch_id}/backup_schedule",
|
|
425
454
|
stability: "stable",
|
|
426
455
|
deprecated: false,
|
package/dist/lib/operation.d.ts
CHANGED
|
@@ -15,20 +15,62 @@ export interface NeonToolCaller {
|
|
|
15
15
|
export interface NeonToolExecutionContext {
|
|
16
16
|
signal?: AbortSignal;
|
|
17
17
|
apiKey?: NeonBearerCredential;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Refuses every tool whose `metadata.readOnlySafe` is false. SQL tools run
|
|
20
|
+
* caller SQL in a `READ ONLY` transaction or refuse to run.
|
|
21
|
+
*/
|
|
19
22
|
readOnly?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Which secrets results keep. A hidden secret reads `"***redacted***"`, and
|
|
25
|
+
* a tool whose `metadata.returnsOnlySecrets` result would be hidden refuses.
|
|
26
|
+
*/
|
|
27
|
+
secrets?: NeonSecretsMode;
|
|
20
28
|
/** Every SQL connection logs in as this Postgres role. */
|
|
21
29
|
postgresRole?: string;
|
|
22
30
|
/** Attribution sent with `docs.search` requests. */
|
|
23
31
|
caller?: NeonToolCaller;
|
|
24
32
|
}
|
|
25
|
-
|
|
33
|
+
/**
|
|
34
|
+
* `setup`: a credential Neon issues for an app, CI job, or agent to use, such as
|
|
35
|
+
* a connection string, role password, or credential token.
|
|
36
|
+
* `stored`: a secret you gave Neon to call another service, such as an SMTP
|
|
37
|
+
* password or an OAuth provider's client secret.
|
|
38
|
+
*/
|
|
39
|
+
export type NeonSecretKind = "setup" | "stored";
|
|
40
|
+
/** `all` keeps every secret, `setup` keeps only `setup` secrets, `none` keeps none. */
|
|
41
|
+
export type NeonSecretsMode = "all" | "setup" | "none";
|
|
42
|
+
export interface NeonSecretField {
|
|
43
|
+
/**
|
|
44
|
+
* `$` for the whole value, `.key` for a field, `[*]` for every array item,
|
|
45
|
+
* as in `$.oauth_providers[*].client_secret`.
|
|
46
|
+
*/
|
|
47
|
+
path: string;
|
|
48
|
+
kind: NeonSecretKind;
|
|
49
|
+
}
|
|
50
|
+
export interface NeonOperationMetadata {
|
|
26
51
|
method: string;
|
|
27
52
|
path: string;
|
|
28
53
|
stability: string;
|
|
29
54
|
deprecated: boolean;
|
|
30
55
|
tags: readonly string[];
|
|
31
56
|
}
|
|
57
|
+
export interface NeonToolMetadata extends NeonOperationMetadata {
|
|
58
|
+
/**
|
|
59
|
+
* Changes no Neon resource and returns no connection string or role
|
|
60
|
+
* password. A tool that is not refuses to run when `readOnly` is true.
|
|
61
|
+
*/
|
|
62
|
+
readOnlySafe: boolean;
|
|
63
|
+
/** Where the result carries a secret, and what kind it is. */
|
|
64
|
+
secretOutputFields: readonly NeonSecretField[];
|
|
65
|
+
/**
|
|
66
|
+
* The result is the secret itself: a read of an existing secret, or a
|
|
67
|
+
* rotation that returns the replacement. Refused when `secrets` hides it.
|
|
68
|
+
*/
|
|
69
|
+
returnsOnlySecrets: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** Literal tool metadata; the secret fields default to none. */
|
|
72
|
+
export type NeonToolMetadataInput = Omit<NeonToolMetadata, "secretOutputFields" | "returnsOnlySecrets"> & Partial<Pick<NeonToolMetadata, "secretOutputFields" | "returnsOnlySecrets">>;
|
|
73
|
+
export declare const toolMetadata: (metadata: NeonToolMetadataInput) => NeonToolMetadata;
|
|
32
74
|
export interface JsonSafeBlob {
|
|
33
75
|
base64: string;
|
|
34
76
|
contentType: string;
|
|
@@ -64,9 +106,13 @@ export interface NeonOperation<InputSchema extends z.ZodType, Id extends string
|
|
|
64
106
|
inputSchema: InputSchema;
|
|
65
107
|
annotations: NeonToolAnnotations;
|
|
66
108
|
requiresApproval: boolean;
|
|
67
|
-
metadata:
|
|
109
|
+
metadata: NeonOperationMetadata;
|
|
68
110
|
invoke(client: Client, input: z.output<InputSchema>, signal?: AbortSignal): Promise<Output>;
|
|
69
111
|
}
|
|
70
112
|
export declare const defineOperation: <const InputSchema extends z.ZodType, const Id extends string, Output>(operation: NeonOperation<InputSchema, Id, Output>) => NeonOperation<InputSchema, Id, Output>;
|
|
71
|
-
|
|
113
|
+
/** A generated operation bound to a client. `fromGenerated` adds the tool policy. */
|
|
114
|
+
export type NeonOperationTool<InputSchema extends z.ZodType = z.ZodType, Id extends string = string, Output = unknown> = Omit<NeonTool<InputSchema, Id, Output>, "metadata"> & {
|
|
115
|
+
metadata: NeonOperationMetadata;
|
|
116
|
+
};
|
|
117
|
+
export declare const bindOperation: <const InputSchema extends z.ZodType, const Id extends string, Output>(operation: NeonOperation<InputSchema, Id, Output>, client: Client) => NeonOperationTool<InputSchema, Id, JsonSafe<Awaited<Output>>>;
|
|
72
118
|
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../src/lib/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,KAAK,oBAAoB,EAA2B,MAAM,WAAW,CAAC;AAG/E,MAAM,WAAW,mBAAmB;IACnC,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACx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W,GAClB,OAAO,CAAC,MAAM,CAAC,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,GAC3B,KAAK,CAAC,WAAW,SAAS,CAAC,CAAC,OAAO,EACnC,KAAK,CAAC,EAAE,SAAS,MAAM,EACvB,MAAM,EAEN,WAAW,aAAa,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,2CACpC,CAAC;AAEf,qFAAqF;AACrF,MAAM,MAAM,iBAAiB,CAC5B,WAAW,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,EACzC,EAAE,SAAS,MAAM,GAAG,MAAM,EAC1B,MAAM,GAAG,OAAO,IACb,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IACzD,QAAQ,EAAE,qBAAqB,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,aAAa,GACzB,KAAK,CAAC,WAAW,SAAS,CAAC,CAAC,OAAO,EACnC,KAAK,CAAC,EAAE,SAAS,MAAM,EACvB,MAAM,EAEN,WAAW,aAAa,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,CAAC,EACjD,QAAQ,MAAM,KACZ,iBAAiB,CAAC,WAAW,EAAE,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAsB7D,CAAC"}
|
package/dist/lib/operation.js
CHANGED
|
@@ -2,6 +2,11 @@ import { requireBearerCredential } from "./auth.js";
|
|
|
2
2
|
import { toToolResult } from "./result.js";
|
|
3
3
|
import { createClient } from "@neon/sdk/raw";
|
|
4
4
|
// src/lib/operation.ts
|
|
5
|
+
const toolMetadata = (metadata) => ({
|
|
6
|
+
...metadata,
|
|
7
|
+
secretOutputFields: metadata.secretOutputFields ?? [],
|
|
8
|
+
returnsOnlySecrets: metadata.returnsOnlySecrets ?? false
|
|
9
|
+
});
|
|
5
10
|
const defineOperation = (operation) => operation;
|
|
6
11
|
const bindOperation = (operation, client) => ({
|
|
7
12
|
operationId: operation.operationId,
|
|
@@ -26,4 +31,4 @@ const clientWithCredential = (client, apiKey) => {
|
|
|
26
31
|
auth: requireBearerCredential(apiKey)
|
|
27
32
|
});
|
|
28
33
|
};
|
|
29
|
-
export { bindOperation, defineOperation };
|
|
34
|
+
export { bindOperation, defineOperation, toolMetadata };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { NeonSecretField, NeonSecretsMode, NeonTool, NeonToolExecutionContext, NeonToolMetadata } from "./operation.js";
|
|
2
|
+
export interface NeonToolPolicyOptions {
|
|
3
|
+
/** The default for `readOnly` in every execution context. */
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
/** The default for `secrets` in every execution context; `"all"` when unset. */
|
|
6
|
+
secrets?: NeonSecretsMode;
|
|
7
|
+
}
|
|
8
|
+
/** What a `tools` predicate sees: a tool without its `execute`. */
|
|
9
|
+
export type NeonToolDescriptor = Pick<NeonTool, "operationId" | "id" | "title" | "description" | "annotations" | "requiresApproval" | "metadata">;
|
|
10
|
+
export type NeonToolPredicate = (tool: NeonToolDescriptor) => boolean;
|
|
11
|
+
export declare const toolDescriptor: (tool: NeonTool) => NeonToolDescriptor;
|
|
12
|
+
export type NeonToolCallGuard = (context?: NeonToolExecutionContext) => void;
|
|
13
|
+
/** The secret fields `mode` replaces with `REDACTED_SECRET`. */
|
|
14
|
+
export declare const hiddenSecretFields: (metadata: Pick<NeonToolMetadata, "secretOutputFields">, mode: NeonSecretsMode) => NeonSecretField[];
|
|
15
|
+
/** The tool refuses under `mode` because its whole result would be hidden. */
|
|
16
|
+
export declare const withheldUnderSecrets: (metadata: Pick<NeonToolMetadata, "secretOutputFields" | "returnsOnlySecrets">, mode: NeonSecretsMode) => boolean;
|
|
17
|
+
/** Throws for a call the effective policy forbids. */
|
|
18
|
+
export declare const toolCallGuard: (tool: NeonTool, options: NeonToolPolicyOptions, publishedId: string) => NeonToolCallGuard;
|
|
19
|
+
/**
|
|
20
|
+
* SQL tools read the effective `readOnly` to open a `READ ONLY` transaction.
|
|
21
|
+
* Redaction runs inside `onExecute`, so a tracking hook sees the redacted result.
|
|
22
|
+
*/
|
|
23
|
+
export declare const applyToolPolicy: <Tool extends NeonTool>(tool: Tool, options: NeonToolPolicyOptions, guard: NeonToolCallGuard) => Tool;
|
|
24
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/lib/policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,eAAe,EACf,eAAe,EACf,QAAQ,EACR,wBAAwB,EACxB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,qBAAqB;IACrC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,OAAO,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACpC,QAAQ,EACN,aAAa,GACb,IAAI,GACJ,OAAO,GACP,aAAa,GACb,aAAa,GACb,kBAAkB,GAClB,UAAU,CACZ,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,kBAAkB,KAAK,OAAO,CAAC;AAEtE,eAAO,MAAM,cAAc,GAAI,MAAM,QAAQ,KAAG,kBAQ9C,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAU7E,gEAAgE;AAChE,eAAO,MAAM,kBAAkB,GAC9B,UAAU,IAAI,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,EACtD,MAAM,eAAe,KACnB,eAAe,EACgD,CAAC;AAEnE,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,GAChC,UAAU,IAAI,CACb,gBAAgB,EAChB,oBAAoB,GAAG,oBAAoB,CAC3C,EACD,MAAM,eAAe,KACnB,OAE2C,CAAC;AAE/C,sDAAsD;AACtD,eAAO,MAAM,aAAa,GAExB,MAAM,QAAQ,EACd,SAAS,qBAAqB,EAC9B,aAAa,MAAM,KACjB,iBAcF,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,IAAI,SAAS,QAAQ,EACpD,MAAM,IAAI,EACV,SAAS,qBAAqB,EAC9B,OAAO,iBAAiB,KACtB,IA2BF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { redactSecretFields } from "./redact.js";
|
|
2
|
+
import { NeonClientError } from "@neon/sdk";
|
|
3
|
+
// src/lib/policy.ts
|
|
4
|
+
const toolDescriptor = (tool) => ({
|
|
5
|
+
operationId: tool.operationId,
|
|
6
|
+
id: tool.id,
|
|
7
|
+
title: tool.title,
|
|
8
|
+
description: tool.description,
|
|
9
|
+
annotations: tool.annotations,
|
|
10
|
+
requiresApproval: tool.requiresApproval,
|
|
11
|
+
metadata: tool.metadata
|
|
12
|
+
});
|
|
13
|
+
const secretsMode = (options, context) => context?.secrets ?? options.secrets ?? "all";
|
|
14
|
+
const hides = (mode, field) => mode === "none" || mode === "setup" && field.kind !== "setup";
|
|
15
|
+
/** The secret fields `mode` replaces with `REDACTED_SECRET`. */
|
|
16
|
+
const hiddenSecretFields = (metadata, mode) => metadata.secretOutputFields.filter((field) => hides(mode, field));
|
|
17
|
+
/** The tool refuses under `mode` because its whole result would be hidden. */
|
|
18
|
+
const withheldUnderSecrets = (metadata, mode) => metadata.returnsOnlySecrets && hiddenSecretFields(metadata, mode).length > 0;
|
|
19
|
+
/** Throws for a call the effective policy forbids. */
|
|
20
|
+
const toolCallGuard = (tool, options, publishedId) => (context) => {
|
|
21
|
+
if ((context?.readOnly ?? options.readOnly) === true && !tool.metadata.readOnlySafe) throw new NeonClientError(`${publishedId} is unavailable in read-only mode because it can change Neon resources or returns a connection string or role password.`);
|
|
22
|
+
const secrets = secretsMode(options, context);
|
|
23
|
+
if (withheldUnderSecrets(tool.metadata, secrets)) throw new NeonClientError(`${publishedId} is unavailable with secrets: "${secrets}" because its result is a secret.`);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* SQL tools read the effective `readOnly` to open a `READ ONLY` transaction.
|
|
27
|
+
* Redaction runs inside `onExecute`, so a tracking hook sees the redacted result.
|
|
28
|
+
*/
|
|
29
|
+
const applyToolPolicy = (tool, options, guard) => {
|
|
30
|
+
const execute = tool.execute.bind(tool);
|
|
31
|
+
return {
|
|
32
|
+
...tool,
|
|
33
|
+
execute: async (input, context) => {
|
|
34
|
+
guard(context);
|
|
35
|
+
const readOnly = context?.readOnly ?? options.readOnly;
|
|
36
|
+
const result = await execute(input, readOnly === void 0 ? context : {
|
|
37
|
+
...context,
|
|
38
|
+
readOnly
|
|
39
|
+
});
|
|
40
|
+
const hidden = hiddenSecretFields(tool.metadata, secretsMode(options, context));
|
|
41
|
+
if (hidden.length === 0) return result;
|
|
42
|
+
return {
|
|
43
|
+
...result,
|
|
44
|
+
data: redactSecretFields(result.data, hidden.map((field) => field.path))
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export { applyToolPolicy, hiddenSecretFields, toolCallGuard, toolDescriptor, withheldUnderSecrets };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const REDACTED_SECRET = "***redacted***";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces every non-empty string at `paths` with `REDACTED_SECRET`. An absent,
|
|
4
|
+
* null, or empty value is left as is, so "no secret" stays distinguishable
|
|
5
|
+
* from "redacted". A path that meets a different shape throws.
|
|
6
|
+
*/
|
|
7
|
+
export declare const redactSecretFields: (data: unknown, paths: readonly string[]) => unknown;
|
|
8
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/lib/redact.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAwDhD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC9B,MAAM,OAAO,EACb,OAAO,SAAS,MAAM,EAAE,KACtB,OAID,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/lib/redact.ts
|
|
2
|
+
const REDACTED_SECRET = "***redacted***";
|
|
3
|
+
const parsePath = (path) => {
|
|
4
|
+
if (!path.startsWith("$")) throw new TypeError(`Secret path must start with $: ${path}`);
|
|
5
|
+
const segments = [];
|
|
6
|
+
const pattern = /\.([a-zA-Z_][a-zA-Z0-9_]*)|\[\*\]/gy;
|
|
7
|
+
pattern.lastIndex = 1;
|
|
8
|
+
while (pattern.lastIndex < path.length) {
|
|
9
|
+
const match = pattern.exec(path);
|
|
10
|
+
if (match === null) throw new TypeError(`Unsupported secret path: ${path}`);
|
|
11
|
+
segments.push(match[1] === void 0 ? { each: true } : { key: match[1] });
|
|
12
|
+
}
|
|
13
|
+
return segments;
|
|
14
|
+
};
|
|
15
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
+
const redactAt = (value, segments, path) => {
|
|
17
|
+
if (value === void 0 || value === null) return value;
|
|
18
|
+
const [head, ...rest] = segments;
|
|
19
|
+
if (head === void 0) {
|
|
20
|
+
if (typeof value !== "string") throw new TypeError(`Secret at ${path} is not a string`);
|
|
21
|
+
return value === "" ? value : REDACTED_SECRET;
|
|
22
|
+
}
|
|
23
|
+
if ("each" in head) {
|
|
24
|
+
if (!Array.isArray(value)) throw new TypeError(`Secret path ${path} expects an array`);
|
|
25
|
+
return value.map((item) => redactAt(item, rest, path));
|
|
26
|
+
}
|
|
27
|
+
if (!isRecord(value)) throw new TypeError(`Secret path ${path} expects an object`);
|
|
28
|
+
if (!(head.key in value)) return value;
|
|
29
|
+
return {
|
|
30
|
+
...value,
|
|
31
|
+
[head.key]: redactAt(value[head.key], rest, path)
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Replaces every non-empty string at `paths` with `REDACTED_SECRET`. An absent,
|
|
36
|
+
* null, or empty value is left as is, so "no secret" stays distinguishable
|
|
37
|
+
* from "redacted". A path that meets a different shape throws.
|
|
38
|
+
*/
|
|
39
|
+
const redactSecretFields = (data, paths) => paths.reduce((current, path) => redactAt(current, parsePath(path), path), data);
|
|
40
|
+
export { REDACTED_SECRET, redactSecretFields };
|