@terreno/api 57.4.0 → 57.6.1
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 +5 -5
- package/bunfig.toml +1 -1
- package/dist/actions.js +197 -368
- package/dist/adminModelRouter.js +88 -173
- package/dist/api.js +617 -852
- package/dist/audit/auditApp.js +48 -89
- package/dist/audit/auditEventModel.js +15 -16
- package/dist/audit/cloudTasksEnqueue.js +56 -149
- package/dist/audit/diff.js +70 -160
- package/dist/audit/processQueue.js +25 -70
- package/dist/audit/rbacSink.js +25 -66
- package/dist/audit/record.js +129 -251
- package/dist/auth.js +432 -681
- package/dist/authRecovery.js +155 -269
- package/dist/authTokens.js +43 -118
- package/dist/betterAuthApp.js +25 -26
- package/dist/betterAuthSetup.js +258 -413
- package/dist/browserLogsRoute.d.ts +6 -0
- package/dist/browserLogsRoute.js +97 -0
- package/dist/collectionRegistry.js +32 -47
- package/dist/config.js +53 -122
- package/dist/configurationApp.js +180 -361
- package/dist/configurationPlugin.js +130 -302
- package/dist/consentApp.js +276 -421
- package/dist/docLoader.js +78 -126
- package/dist/envConfigurationPlugin.js +25 -147
- package/dist/errors.js +151 -247
- package/dist/example.js +28 -34
- package/dist/expressServer.d.ts +10 -0
- package/dist/expressServer.js +109 -255
- package/dist/frameworkModelNames.d.ts +24 -0
- package/dist/frameworkModelNames.js +31 -0
- package/dist/githubAuth.js +152 -216
- package/dist/httpClient.js +176 -264
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -2
- package/dist/logger.js +145 -278
- package/dist/mcp/auth.js +76 -128
- package/dist/mcp/createMCPRequest.js +4 -5
- package/dist/mcp/handlers.js +268 -480
- package/dist/mcp/query.js +56 -150
- package/dist/mcp/registry.js +17 -30
- package/dist/mcp/schemaGenerator.js +95 -181
- package/dist/mcp/server.js +28 -100
- package/dist/mcp/serviceTokens.js +102 -191
- package/dist/mcp/toolGenerator.js +78 -191
- package/dist/middleware.js +15 -27
- package/dist/migrations/fixtures/all-down/20260910120000-one.js +2 -42
- package/dist/migrations/fixtures/all-down/20260910120001-two.js +2 -42
- package/dist/migrations/fixtures/bad-id/20260910120000-mismatch.js +1 -39
- package/dist/migrations/fixtures/bad-name/not-a-migration.js +1 -39
- package/dist/migrations/fixtures/valid/20260910120000-alpha.js +1 -39
- package/dist/migrations/fixtures/valid/20260910120001-beta.js +2 -42
- package/dist/migrations/generate.js +107 -229
- package/dist/migrations/load.js +75 -201
- package/dist/migrations/lock.js +54 -126
- package/dist/migrations/runner.js +192 -446
- package/dist/migrations/schemaCatalog.js +122 -263
- package/dist/models/consentForm.js +6 -6
- package/dist/models/consentResponse.js +5 -5
- package/dist/models/mcpServiceToken.js +66 -156
- package/dist/models/notification.js +6 -6
- package/dist/models/notificationPreference.js +6 -6
- package/dist/models/versionConfig.js +5 -5
- package/dist/notifications/notificationService.js +133 -273
- package/dist/notifications/notificationsApp.js +85 -179
- package/dist/notifications/notificationsBeforeSend.js +19 -64
- package/dist/notifiers/googleChatNotifier.js +36 -117
- package/dist/notifiers/slackNotifier.d.ts +31 -2
- package/dist/notifiers/slackNotifier.js +170 -119
- package/dist/notifiers/zoomNotifier.js +60 -111
- package/dist/openApi.js +107 -122
- package/dist/openApiBuilder.js +117 -159
- package/dist/openApiCompat.js +81 -148
- package/dist/openApiEtag.js +7 -7
- package/dist/openApiValidator.js +177 -286
- package/dist/orgs/orgContext.js +87 -157
- package/dist/orgs/orgPermissions.js +29 -68
- package/dist/orgs/orgPlugin.js +9 -27
- package/dist/orgs/organizationModel.js +65 -166
- package/dist/orgs/organizationSettings.js +29 -36
- package/dist/orgs/orgsApp.js +346 -608
- package/dist/permissions.js +88 -181
- package/dist/plugins.js +125 -218
- package/dist/populate.js +130 -240
- package/dist/rateLimit/applyTrustProxy.js +1 -1
- package/dist/rateLimit/createStore.js +7 -8
- package/dist/rateLimit/memoryStore.js +22 -100
- package/dist/rateLimit/middleware.js +48 -99
- package/dist/rateLimit/mongoStore.js +54 -112
- package/dist/rateLimit/policies.js +41 -75
- package/dist/rateLimit/redisStore.js +39 -133
- package/dist/rbac/access.js +119 -267
- package/dist/rbac/assertAllowed.js +95 -171
- package/dist/rbac/auditModel.js +14 -58
- package/dist/rbac/backfillAdmins.js +24 -130
- package/dist/rbac/fieldViews.js +46 -141
- package/dist/rbac/membershipOrgAdminSource.js +28 -99
- package/dist/rbac/middleware.js +30 -96
- package/dist/rbac/modelRouterAccess.js +130 -307
- package/dist/rbac/permissionUtils.js +40 -179
- package/dist/rbac/realtimeAccess.js +81 -147
- package/dist/rbac/resolve.d.ts +1 -1
- package/dist/rbac/resolve.js +148 -342
- package/dist/rbac/roleManager.js +318 -700
- package/dist/rbac/roleModel.js +44 -171
- package/dist/rbac/routes.js +93 -196
- package/dist/rbac/scopes.js +39 -133
- package/dist/rbac/statements.js +23 -91
- package/dist/rbac/userPlugin.js +3 -29
- package/dist/realtime/changeStreamWatcher.js +489 -800
- package/dist/realtime/deprecation.js +8 -10
- package/dist/realtime/queryMatcher.js +110 -191
- package/dist/realtime/queryStore.js +35 -118
- package/dist/realtime/realtimeApp.js +247 -401
- package/dist/realtime/registry.js +19 -30
- package/dist/realtime/sessionRevalidation.js +132 -358
- package/dist/realtime/socketAuth.js +89 -208
- package/dist/realtime/socketUser.js +10 -56
- package/dist/requestContext.js +93 -139
- package/dist/schemaMetadata.js +179 -274
- package/dist/scriptRunner.js +96 -266
- package/dist/scrubAdminFields.js +36 -108
- package/dist/secretProviders.js +130 -299
- package/dist/seedRunner.js +221 -514
- package/dist/sync/adminBroadcastScope.js +58 -170
- package/dist/sync/adminWindowAccess.js +15 -86
- package/dist/sync/adminWindowMutation.js +110 -181
- package/dist/sync/executors.js +425 -629
- package/dist/sync/loadHarness.js +392 -689
- package/dist/sync/models.js +181 -341
- package/dist/sync/mutationHandler.js +533 -801
- package/dist/sync/registrationSideEffects.js +41 -95
- package/dist/sync/registry.js +29 -49
- package/dist/sync/routes.js +484 -817
- package/dist/sync/scripts/compactTombstones.js +83 -228
- package/dist/sync/serialize.js +18 -58
- package/dist/sync/socketHandlers.js +253 -478
- package/dist/sync/streams.js +49 -117
- package/dist/sync/syncApp.js +12 -15
- package/dist/sync/syncBatch.js +63 -168
- package/dist/sync/syncSeqPlugin.js +430 -702
- package/dist/syncConsents.js +113 -253
- package/dist/terrenoApp.js +166 -276
- package/dist/tests/createTestData.js +146 -256
- package/dist/tests/models.js +14 -54
- package/dist/tests/mongoTestSetup.js +42 -103
- package/dist/tests/testHelper.js +31 -93
- package/dist/tests.js +12 -51
- package/dist/transformers.js +61 -164
- package/dist/utils.js +31 -93
- package/dist/vendor/wesleytodd-openapi/index.js +37 -51
- package/dist/vendor/wesleytodd-openapi/lib/generate-doc.js +32 -40
- package/dist/vendor/wesleytodd-openapi/lib/layer-schema.js +3 -3
- package/dist/vendor/wesleytodd-openapi/lib/ui.js +50 -19
- package/dist/vendor/wesleytodd-openapi/lib/validate.js +19 -47
- package/dist/versionCheckPlugin.js +52 -100
- package/dist/webhooks/headerValue.js +2 -2
- package/dist/webhooks/idempotency/memoryStore.js +16 -59
- package/dist/webhooks/idempotency/mongoStore.js +55 -130
- package/dist/webhooks/idempotency/webhookReceipt.js +9 -9
- package/dist/webhooks/rawBody.js +1 -1
- package/dist/webhooks/timingSafeEqual.js +4 -5
- package/dist/webhooks/verifiers/hmac.js +17 -18
- package/dist/webhooks/verifiers/sendgrid.js +20 -22
- package/dist/webhooks/verifiers/stripe.js +31 -65
- package/dist/webhooks/verifiers/twilio.js +23 -73
- package/dist/webhooks/webhooksApp.js +78 -177
- package/dist/zodOpenApi.js +2 -2
- package/package.json +6 -6
- package/src/__tests__/browserLogsRoute.test.ts +165 -0
- package/src/api.arrayOperations.test.ts +44 -0
- package/src/api.ts +64 -39
- package/src/audit/auditApp.test.ts +5 -5
- package/src/audit/auditEventModel.ts +7 -3
- package/src/audit/auditRouter.test.ts +5 -5
- package/src/audit/rbacSink.test.ts +2 -2
- package/src/audit/record.test.ts +2 -2
- package/src/audit/record.ts +3 -2
- package/src/auth.ts +1 -1
- package/src/authRecovery.test.ts +43 -0
- package/src/authRecovery.ts +16 -10
- package/src/authTokens.ts +6 -2
- package/src/authVerification.test.ts +22 -0
- package/src/browserLogsRoute.ts +110 -0
- package/src/configurationPlugin.test.ts +1 -11
- package/src/expressServer.ts +10 -0
- package/src/frameworkModelNames.test.ts +62 -0
- package/src/frameworkModelNames.ts +33 -0
- package/src/index.ts +7 -0
- package/src/isolated/migrateCliConnect.isolated.ts +51 -0
- package/src/mcp/auth.test.ts +34 -1
- package/src/migrations/cli.test.ts +0 -23
- package/src/models/mcpServiceToken.ts +4 -3
- package/src/models/notification.ts +3 -2
- package/src/models/notificationPreference.ts +1 -1
- package/src/notifications/notificationsApp.test.ts +24 -1
- package/src/notifiers/slackNotifier.test.ts +186 -1
- package/src/notifiers/slackNotifier.ts +167 -8
- package/src/orgs/orgPlugin.ts +1 -1
- package/src/orgs/organizationModel.ts +11 -6
- package/src/plugins.test.ts +5 -0
- package/src/plugins.ts +3 -0
- package/src/realtime/realtimeApp.ts +1 -1
- package/src/sync/integration.test.ts +2 -2
- package/src/terrenoApp.ts +3 -0
- package/src/types.d.ts +1 -0
- package/src/webhooks/idempotency/webhookReceipt.ts +4 -3
- package/tsconfig.json +13 -54
- package/tsconfig.typedoc.json +2 -0
package/dist/mcp/query.js
CHANGED
|
@@ -1,58 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __values = (this && this.__values) || function(o) {
|
|
14
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
15
|
-
if (m) return m.call(o);
|
|
16
|
-
if (o && typeof o.length === "number") return {
|
|
17
|
-
next: function () {
|
|
18
|
-
if (o && i >= o.length) o = void 0;
|
|
19
|
-
return { value: o && o[i++], done: !o };
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
23
|
-
};
|
|
24
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
-
if (!m) return o;
|
|
27
|
-
var i = m.call(o), r, ar = [], e;
|
|
28
|
-
try {
|
|
29
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
-
}
|
|
31
|
-
catch (error) { e = { error: error }; }
|
|
32
|
-
finally {
|
|
33
|
-
try {
|
|
34
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
-
}
|
|
36
|
-
finally { if (e) throw e.error; }
|
|
37
|
-
}
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
3
|
exports.buildListQuery = void 0;
|
|
42
|
-
|
|
4
|
+
const schemaGenerator_1 = require("./schemaGenerator");
|
|
43
5
|
/** Args consumed by pagination/population, never treated as filters. */
|
|
44
|
-
|
|
6
|
+
const RESERVED_LIST_ARGS = new Set(["limit", "page", "populate", "sort"]);
|
|
45
7
|
/**
|
|
46
8
|
* Top-level logical operators an MCP client may send. Mirrors the REST list endpoint,
|
|
47
9
|
* which allows `$and` / `$or` and validates every nested key against `queryFields`.
|
|
48
10
|
*/
|
|
49
|
-
|
|
11
|
+
const ALLOWED_LOGICAL_OPERATORS = new Set(["$and", "$or"]);
|
|
50
12
|
/**
|
|
51
13
|
* Comparison operators allowed inside a field's value, e.g. `{completed: {$ne: true}}`.
|
|
52
14
|
* Deliberately excludes evaluation operators that can run arbitrary code or ignore
|
|
53
15
|
* indexes ($where, $expr, $function, $accumulator, $jsonSchema, $text).
|
|
54
16
|
*/
|
|
55
|
-
|
|
17
|
+
const ALLOWED_FIELD_OPERATORS = new Set([
|
|
56
18
|
"$all",
|
|
57
19
|
"$eq",
|
|
58
20
|
"$exists",
|
|
@@ -67,7 +29,7 @@ var ALLOWED_FIELD_OPERATORS = new Set([
|
|
|
67
29
|
"$regex",
|
|
68
30
|
"$size",
|
|
69
31
|
]);
|
|
70
|
-
|
|
32
|
+
const isPlainObject = (value) => {
|
|
71
33
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
72
34
|
};
|
|
73
35
|
/**
|
|
@@ -76,48 +38,27 @@ var isPlainObject = function (value) {
|
|
|
76
38
|
*
|
|
77
39
|
* @returns The offending operator name, or undefined when the value is safe.
|
|
78
40
|
*/
|
|
79
|
-
|
|
80
|
-
var e_1, _a, e_2, _b;
|
|
41
|
+
const findDisallowedOperator = (value) => {
|
|
81
42
|
if (Array.isArray(value)) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (found) {
|
|
87
|
-
return found;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
92
|
-
finally {
|
|
93
|
-
try {
|
|
94
|
-
if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
|
|
43
|
+
for (const item of value) {
|
|
44
|
+
const found = findDisallowedOperator(item);
|
|
45
|
+
if (found) {
|
|
46
|
+
return found;
|
|
95
47
|
}
|
|
96
|
-
finally { if (e_1) throw e_1.error; }
|
|
97
48
|
}
|
|
98
49
|
return undefined;
|
|
99
50
|
}
|
|
100
51
|
if (!isPlainObject(value)) {
|
|
101
52
|
return undefined;
|
|
102
53
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (key.startsWith("$") && !ALLOWED_FIELD_OPERATORS.has(key)) {
|
|
107
|
-
return key;
|
|
108
|
-
}
|
|
109
|
-
var found = findDisallowedOperator(nested);
|
|
110
|
-
if (found) {
|
|
111
|
-
return found;
|
|
112
|
-
}
|
|
54
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
55
|
+
if (key.startsWith("$") && !ALLOWED_FIELD_OPERATORS.has(key)) {
|
|
56
|
+
return key;
|
|
113
57
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
58
|
+
const found = findDisallowedOperator(nested);
|
|
59
|
+
if (found) {
|
|
60
|
+
return found;
|
|
119
61
|
}
|
|
120
|
-
finally { if (e_2) throw e_2.error; }
|
|
121
62
|
}
|
|
122
63
|
return undefined;
|
|
123
64
|
};
|
|
@@ -125,60 +66,38 @@ var findDisallowedOperator = function (value) {
|
|
|
125
66
|
* Validate one branch of a `$and` / `$or` clause. Every key must either be another
|
|
126
67
|
* logical operator or a field listed in `queryFields`, matching REST's behavior.
|
|
127
68
|
*/
|
|
128
|
-
|
|
129
|
-
var e_3, _a;
|
|
69
|
+
const validateLogicalBranch = (branch, allowedQueryFields) => {
|
|
130
70
|
if (!isPlainObject(branch)) {
|
|
131
71
|
return "Logical operators ($and/$or) take an array of filter objects";
|
|
132
72
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
if (error) {
|
|
139
|
-
return error;
|
|
140
|
-
}
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
if (!allowedQueryFields.has(key)) {
|
|
144
|
-
return "".concat(key, " is not allowed as a filter field");
|
|
145
|
-
}
|
|
146
|
-
var disallowed = findDisallowedOperator(value);
|
|
147
|
-
if (disallowed) {
|
|
148
|
-
return "".concat(disallowed, " is not an allowed query operator");
|
|
73
|
+
for (const [key, value] of Object.entries(branch)) {
|
|
74
|
+
if (ALLOWED_LOGICAL_OPERATORS.has(key)) {
|
|
75
|
+
const error = validateLogicalClause(key, value, allowedQueryFields);
|
|
76
|
+
if (error) {
|
|
77
|
+
return error;
|
|
149
78
|
}
|
|
79
|
+
continue;
|
|
150
80
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
81
|
+
if (!allowedQueryFields.has(key)) {
|
|
82
|
+
return `${key} is not allowed as a filter field`;
|
|
83
|
+
}
|
|
84
|
+
const disallowed = findDisallowedOperator(value);
|
|
85
|
+
if (disallowed) {
|
|
86
|
+
return `${disallowed} is not an allowed query operator`;
|
|
156
87
|
}
|
|
157
|
-
finally { if (e_3) throw e_3.error; }
|
|
158
88
|
}
|
|
159
89
|
return undefined;
|
|
160
90
|
};
|
|
161
|
-
|
|
162
|
-
var e_4, _a;
|
|
91
|
+
const validateLogicalClause = (operator, value, allowedQueryFields) => {
|
|
163
92
|
if (!Array.isArray(value) || value.length === 0) {
|
|
164
|
-
return
|
|
93
|
+
return `${operator} takes a non-empty array of filter objects`;
|
|
165
94
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (error) {
|
|
171
|
-
return error;
|
|
172
|
-
}
|
|
95
|
+
for (const branch of value) {
|
|
96
|
+
const error = validateLogicalBranch(branch, allowedQueryFields);
|
|
97
|
+
if (error) {
|
|
98
|
+
return error;
|
|
173
99
|
}
|
|
174
100
|
}
|
|
175
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
176
|
-
finally {
|
|
177
|
-
try {
|
|
178
|
-
if (value_2_1 && !value_2_1.done && (_a = value_2.return)) _a.call(value_2);
|
|
179
|
-
}
|
|
180
|
-
finally { if (e_4) throw e_4.error; }
|
|
181
|
-
}
|
|
182
101
|
return undefined;
|
|
183
102
|
};
|
|
184
103
|
/**
|
|
@@ -189,44 +108,31 @@ var validateLogicalClause = function (operator, value, allowedQueryFields) {
|
|
|
189
108
|
* Anything else is rejected rather than silently dropped so the calling LLM can correct
|
|
190
109
|
* itself instead of receiving results for a query it did not ask for.
|
|
191
110
|
*/
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
if (ALLOWED_LOGICAL_OPERATORS.has(key)) {
|
|
206
|
-
var error = validateLogicalClause(key, value, allowedQueryFields);
|
|
207
|
-
if (error) {
|
|
208
|
-
return { error: error };
|
|
209
|
-
}
|
|
210
|
-
query[key] = value;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
if (!allowedQueryFields.has(key)) {
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
var disallowed = findDisallowedOperator(value);
|
|
217
|
-
if (disallowed) {
|
|
218
|
-
return { error: "".concat(disallowed, " is not an allowed query operator") };
|
|
111
|
+
const buildListQuery = ({ args, config, options, }) => {
|
|
112
|
+
const query = { ...(options.defaultQueryParams ?? {}) };
|
|
113
|
+
const excludeFields = config.excludeFields ?? [];
|
|
114
|
+
const allowedQueryFields = new Set((options.queryFields ?? []).filter((field) => !(0, schemaGenerator_1.isFieldExcluded)(field, excludeFields)));
|
|
115
|
+
for (const [key, value] of Object.entries(args)) {
|
|
116
|
+
if (RESERVED_LIST_ARGS.has(key) || value === undefined) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (ALLOWED_LOGICAL_OPERATORS.has(key)) {
|
|
120
|
+
const error = validateLogicalClause(key, value, allowedQueryFields);
|
|
121
|
+
if (error) {
|
|
122
|
+
return { error };
|
|
219
123
|
}
|
|
220
124
|
query[key] = value;
|
|
125
|
+
continue;
|
|
221
126
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
127
|
+
if (!allowedQueryFields.has(key)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const disallowed = findDisallowedOperator(value);
|
|
131
|
+
if (disallowed) {
|
|
132
|
+
return { error: `${disallowed} is not an allowed query operator` };
|
|
227
133
|
}
|
|
228
|
-
|
|
134
|
+
query[key] = value;
|
|
229
135
|
}
|
|
230
|
-
return { query
|
|
136
|
+
return { query };
|
|
231
137
|
};
|
|
232
138
|
exports.buildListQuery = buildListQuery;
|
package/dist/mcp/registry.js
CHANGED
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.clearMCPRegistry = exports.getMCPCustomTools = exports.getMCPRegistry = exports.registerMCPTool = exports.updateMCPRegistryOptions = exports.registerMCPModel = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var mcpRoutePathForModel = function (model) { var _a, _b; return (_b = (_a = findCollectionByModelName(model.modelName)) === null || _a === void 0 ? void 0 : _a.routePath) !== null && _b !== void 0 ? _b : "/_mcp/".concat(model.modelName); };
|
|
21
|
-
var registerMCPModel = function (model, config, options) {
|
|
4
|
+
const collectionRegistry_1 = require("../collectionRegistry");
|
|
5
|
+
const mcpCustomTools = [];
|
|
6
|
+
const findCollectionByModelName = (modelName) => (0, collectionRegistry_1.listCollections)().find((record) => record.model.modelName === modelName);
|
|
7
|
+
const mcpRoutePathForModel = (model) => findCollectionByModelName(model.modelName)?.routePath ?? `/_mcp/${model.modelName}`;
|
|
8
|
+
const registerMCPModel = (model, config, options) => {
|
|
22
9
|
(0, collectionRegistry_1.registerCollection)({
|
|
23
|
-
model
|
|
24
|
-
options:
|
|
10
|
+
model,
|
|
11
|
+
options: { ...options, mcp: config },
|
|
25
12
|
routePath: mcpRoutePathForModel(model),
|
|
26
13
|
});
|
|
27
14
|
};
|
|
28
15
|
exports.registerMCPModel = registerMCPModel;
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
const updateMCPRegistryOptions = (modelName, options) => {
|
|
17
|
+
const existing = findCollectionByModelName(modelName);
|
|
31
18
|
if (!existing) {
|
|
32
19
|
return;
|
|
33
20
|
}
|
|
34
21
|
(0, collectionRegistry_1.replaceCollectionOptions)(existing.routePath, options);
|
|
35
22
|
};
|
|
36
23
|
exports.updateMCPRegistryOptions = updateMCPRegistryOptions;
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const registerMCPTool = (tool) => {
|
|
25
|
+
const existingIndex = mcpCustomTools.findIndex((registered) => registered.name === tool.name);
|
|
39
26
|
if (existingIndex >= 0) {
|
|
40
27
|
mcpCustomTools[existingIndex] = tool;
|
|
41
28
|
return;
|
|
@@ -43,22 +30,22 @@ var registerMCPTool = function (tool) {
|
|
|
43
30
|
mcpCustomTools.push(tool);
|
|
44
31
|
};
|
|
45
32
|
exports.registerMCPTool = registerMCPTool;
|
|
46
|
-
|
|
33
|
+
const getMCPRegistry = () => {
|
|
47
34
|
return (0, collectionRegistry_1.listCollections)()
|
|
48
|
-
.filter(
|
|
49
|
-
.map(
|
|
35
|
+
.filter((record) => record.surfaces.mcp)
|
|
36
|
+
.map((record) => ({
|
|
50
37
|
config: record.options.mcp,
|
|
51
38
|
model: record.model,
|
|
52
39
|
modelName: record.model.modelName,
|
|
53
40
|
options: record.options,
|
|
54
|
-
})
|
|
41
|
+
}));
|
|
55
42
|
};
|
|
56
43
|
exports.getMCPRegistry = getMCPRegistry;
|
|
57
|
-
|
|
44
|
+
const getMCPCustomTools = () => {
|
|
58
45
|
return mcpCustomTools;
|
|
59
46
|
};
|
|
60
47
|
exports.getMCPCustomTools = getMCPCustomTools;
|
|
61
|
-
|
|
48
|
+
const clearMCPRegistry = () => {
|
|
62
49
|
(0, collectionRegistry_1.clearCollectionRegistry)();
|
|
63
50
|
mcpCustomTools.length = 0;
|
|
64
51
|
};
|