@terreno/api 57.21.0 → 58.0.0-beta.2

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +1 -1
  3. package/dist/api.d.ts +0 -13
  4. package/dist/api.js +0 -9
  5. package/dist/auth.d.ts +3 -2
  6. package/dist/auth.js +95 -5
  7. package/dist/authRecovery.d.ts +2 -1
  8. package/dist/authRecovery.js +35 -17
  9. package/dist/collectionRegistry.d.ts +3 -4
  10. package/dist/collectionRegistry.js +0 -1
  11. package/dist/consentApp.d.ts +1 -1
  12. package/dist/consentApp.js +58 -2
  13. package/dist/index.d.ts +4 -5
  14. package/dist/index.js +8 -20
  15. package/dist/mcp/adminTracking.js +1 -1
  16. package/dist/mcp/serviceTokens.d.ts +21 -1
  17. package/dist/mcp/serviceTokens.js +159 -183
  18. package/dist/migrations/builtin/mcpServiceTokenStringIds.d.ts +18 -0
  19. package/dist/migrations/builtin/mcpServiceTokenStringIds.js +67 -0
  20. package/dist/models/mcpRequestLog.js +1 -1
  21. package/dist/models/mcpServiceToken.js +36 -4
  22. package/dist/openApiBuilder.d.ts +4 -0
  23. package/dist/openApiBuilder.js +2 -0
  24. package/dist/rbac/realtimeAccess.d.ts +5 -4
  25. package/dist/rbac/realtimeAccess.js +17 -64
  26. package/dist/realtime/changeStreamWatcher.d.ts +8 -63
  27. package/dist/realtime/changeStreamWatcher.js +32 -391
  28. package/dist/realtime/realtimeApp.d.ts +14 -27
  29. package/dist/realtime/realtimeApp.js +14 -220
  30. package/dist/realtime/types.d.ts +0 -64
  31. package/dist/sync/entityIds.d.ts +14 -0
  32. package/dist/sync/entityIds.js +17 -0
  33. package/dist/sync/executors.js +14 -2
  34. package/dist/sync/models.d.ts +1 -0
  35. package/dist/sync/models.js +4 -0
  36. package/dist/sync/mutationHandler.js +51 -2
  37. package/dist/sync/routes.js +12 -17
  38. package/dist/sync/socketHandlers.d.ts +1 -1
  39. package/dist/sync/socketHandlers.js +1 -1
  40. package/dist/sync/types.d.ts +8 -0
  41. package/dist/terrenoApp.d.ts +7 -5
  42. package/dist/terrenoApp.js +18 -14
  43. package/dist/tests/openApiResponseSchema.d.ts +39 -0
  44. package/dist/tests/openApiResponseSchema.js +56 -0
  45. package/dist/tests.d.ts +1 -0
  46. package/dist/tests.js +4 -1
  47. package/dist/types/mcpAdmin.d.ts +1 -1
  48. package/dist/types/mcpServiceToken.d.ts +7 -4
  49. package/dist/versionCheckPlugin.d.ts +1 -1
  50. package/dist/versionCheckPlugin.js +25 -2
  51. package/package.json +17 -6
  52. package/src/__snapshots__/openApi.test.ts.snap +4986 -2478
  53. package/src/__snapshots__/openApiBuilder.test.ts.snap +836 -0
  54. package/src/__tests__/openApiResponseSchema.test.ts +148 -0
  55. package/src/__tests__/versionCheckPlugin.test.ts +72 -0
  56. package/src/api.test.ts +9 -7
  57. package/src/api.ts +0 -24
  58. package/src/auth.ts +116 -5
  59. package/src/authOpenApi.test.ts +316 -0
  60. package/src/authRecovery.ts +47 -19
  61. package/src/betterAuthOAuthHandoff.test.ts +13 -5
  62. package/src/collectionRegistry.ts +3 -5
  63. package/src/consentApp.test.ts +98 -0
  64. package/src/consentApp.ts +67 -2
  65. package/src/index.ts +6 -28
  66. package/src/mcp/actionTools.test.ts +2 -2
  67. package/src/mcp/adminTracking.ts +1 -1
  68. package/src/mcp/auth.test.ts +7 -3
  69. package/src/mcp/oauth.test.ts +12 -12
  70. package/src/mcp/serviceTokens.sync.test.ts +230 -0
  71. package/src/mcp/serviceTokens.test.ts +112 -61
  72. package/src/mcp/serviceTokens.ts +193 -212
  73. package/src/migrations/builtin/mcpServiceTokenStringIds.test.ts +194 -0
  74. package/src/migrations/builtin/mcpServiceTokenStringIds.ts +121 -0
  75. package/src/models/mcpRequestLog.ts +1 -1
  76. package/src/models/mcpServiceToken.test.ts +52 -5
  77. package/src/models/mcpServiceToken.ts +51 -14
  78. package/src/openApiBuilder.test.ts +34 -1
  79. package/src/openApiBuilder.ts +5 -0
  80. package/src/rateLimit/rateLimit.test.ts +25 -10
  81. package/src/rbac/realtimeAccess.test.ts +20 -172
  82. package/src/rbac/realtimeAccess.ts +17 -82
  83. package/src/realtime/changeStreamWatcher.ts +43 -506
  84. package/src/realtime/realtime.test.ts +205 -2545
  85. package/src/realtime/realtimeApp.ts +16 -295
  86. package/src/realtime/types.ts +0 -72
  87. package/src/sync/entityIds.ts +18 -0
  88. package/src/sync/executors.test.ts +28 -0
  89. package/src/sync/executors.ts +23 -2
  90. package/src/sync/models.ts +6 -0
  91. package/src/sync/mutationHandler.test.ts +84 -0
  92. package/src/sync/mutationHandler.ts +57 -2
  93. package/src/sync/routes.ts +12 -17
  94. package/src/sync/socketHandlers.ts +1 -1
  95. package/src/sync/syncRoutes.test.ts +8 -4
  96. package/src/sync/syncSocket.test.ts +77 -113
  97. package/src/sync/types.ts +9 -0
  98. package/src/terrenoApp.mcpServiceTokens.test.ts +14 -6
  99. package/src/terrenoApp.ts +24 -18
  100. package/src/tests/openApiResponseSchema.ts +104 -0
  101. package/src/tests.ts +7 -0
  102. package/src/types/mcpAdmin.ts +1 -1
  103. package/src/types/mcpServiceToken.ts +7 -4
  104. package/src/versionCheckPlugin.ts +41 -2
  105. package/biome.jsonc +0 -22
  106. package/bunfig.toml +0 -10
  107. package/bunfig.unit.toml +0 -3
  108. package/dist/realtime/deprecation.d.ts +0 -13
  109. package/dist/realtime/deprecation.js +0 -31
  110. package/dist/realtime/queryStore.d.ts +0 -37
  111. package/dist/realtime/queryStore.js +0 -103
  112. package/dist/realtime/registry.d.ts +0 -15
  113. package/dist/realtime/registry.js +0 -52
  114. package/e2e/smoke.ts +0 -193
  115. package/src/realtime/deprecation.test.ts +0 -60
  116. package/src/realtime/deprecation.ts +0 -33
  117. package/src/realtime/queryStore.ts +0 -122
  118. package/src/realtime/registry.ts +0 -84
  119. package/tsconfig.json +0 -19
  120. package/tsconfig.typecheck.json +0 -14
  121. package/tsconfig.typedoc.json +0 -13
@@ -74,11 +74,13 @@ export interface TerrenoAppOptions {
74
74
  */
75
75
  configureApp?: AddRoutes;
76
76
  /**
77
- * Optional HTTP rate limiting. Omitted or `undefined` leaves the limiter off
78
- * (Terreno 58 will default it on). Pass `{}` or `{store, limits, trustProxy}`
79
- * to enable. See [Rate limiting](../how-to/rate-limiting.md).
77
+ * HTTP rate limiting. On by default: omitted or `undefined` mounts the limiter with the
78
+ * memory store and default limits (auth 20 / 15 min, api 600 / 15 min). Pass
79
+ * `{store, limits, trustProxy, skip}` to configure it (`{}` is the same as omitting it).
80
+ * Pass `false` to turn it off. On Cloud Run pass `trustProxy: 1` so unauthenticated
81
+ * traffic keys by client IP. See [Rate limiting](../how-to/rate-limiting.md).
80
82
  */
81
- rateLimit?: RateLimitOptions;
83
+ rateLimit?: RateLimitOptions | false;
82
84
  /**
83
85
  * Opt-in personal MCP service tokens. `true` is `{enabled: true}`. When enabled,
84
86
  * mounts `/mcp/service-tokens` and accepts `Authorization: Bearer mcp_…` on `/mcp`.
@@ -272,7 +274,7 @@ export declare class TerrenoApp {
272
274
  * Build the Express application without starting the server.
273
275
  *
274
276
  * Configures the complete middleware stack including:
275
- * - CORS, JSON parsing, JWT decode, optional HTTP rate limiting, auth routes
277
+ * - CORS, JSON parsing, JWT decode, HTTP rate limiting (unless `rateLimit: false`), auth routes
276
278
  * - Better Auth session (when BetterAuthApp is registered) before the limiter
277
279
  * - Logging, Sentry, OpenAPI, model routers and plugins
278
280
  * - Error handling middleware
@@ -261,7 +261,7 @@ class TerrenoApp {
261
261
  * Build the Express application without starting the server.
262
262
  *
263
263
  * Configures the complete middleware stack including:
264
- * - CORS, JSON parsing, JWT decode, optional HTTP rate limiting, auth routes
264
+ * - CORS, JSON parsing, JWT decode, HTTP rate limiting (unless `rateLimit: false`), auth routes
265
265
  * - Better Auth session (when BetterAuthApp is registered) before the limiter
266
266
  * - Logging, Sentry, OpenAPI, model routers and plugins
267
267
  * - Error handling middleware
@@ -324,10 +324,12 @@ class TerrenoApp {
324
324
  app.use((0, betterAuthSetup_1.createBetterAuthSessionMiddleware)(auth, options.userModel));
325
325
  betterAuthForLimiter.markSessionMiddlewareMounted?.();
326
326
  }
327
- if (options.rateLimit) {
328
- const betterAuthBasePath = options.rateLimit.betterAuthBasePath ?? betterAuthForLimiter?.getBetterAuthBasePath?.();
327
+ // Rate limiting is on unless the app passes `rateLimit: false`.
328
+ const rateLimitOptions = options.rateLimit === false ? undefined : (options.rateLimit ?? {});
329
+ if (rateLimitOptions) {
330
+ const betterAuthBasePath = rateLimitOptions.betterAuthBasePath ?? betterAuthForLimiter?.getBetterAuthBasePath?.();
329
331
  const rateLimit = {
330
- ...options.rateLimit,
332
+ ...rateLimitOptions,
331
333
  ...(betterAuthBasePath ? { betterAuthBasePath } : {}),
332
334
  };
333
335
  (0, applyTrustProxy_1.applyRateLimitTrustProxy)(app, rateLimit);
@@ -339,7 +341,17 @@ class TerrenoApp {
339
341
  options.authOptions = {};
340
342
  }
341
343
  const authOptions = options.authOptions;
342
- (0, auth_1.addAuthRoutes)(app, options.userModel, authOptions);
344
+ // The OpenAPI generator walks the router stack on each /openapi.json request, so the
345
+ // instance can exist before it is mounted below. Auth routes need it to document themselves.
346
+ const oapi = (0, index_1.default)({
347
+ info: {
348
+ description: "Generated docs from an Express api",
349
+ title: "Express Application",
350
+ version: "1.0.0",
351
+ },
352
+ openapi: "3.0.0",
353
+ });
354
+ (0, auth_1.addAuthRoutes)(app, options.userModel, authOptions, oapi);
343
355
  if (options.logRequests !== false && options.loggingOptions?.logRequests !== false) {
344
356
  app.use(expressServer_1.logRequests);
345
357
  }
@@ -371,14 +383,6 @@ class TerrenoApp {
371
383
  app.use(openApiCompat_1.openApiCompatMiddleware);
372
384
  app.use(openApiEtag_1.openApiEtagMiddleware);
373
385
  app.use(middleware_1.jsonResponseRequestIdMiddleware);
374
- const oapi = (0, index_1.default)({
375
- info: {
376
- description: "Generated docs from an Express api",
377
- title: "Express Application",
378
- version: "1.0.0",
379
- },
380
- openapi: "3.0.0",
381
- });
382
386
  app.use(oapi);
383
387
  if (process.env.ENABLE_SWAGGER === "true") {
384
388
  app.use("/swagger", oapi.swaggerui());
@@ -440,7 +444,7 @@ class TerrenoApp {
440
444
  }
441
445
  // /auth/me must be registered after plugins so that session middleware
442
446
  // (e.g. Better Auth) has a chance to populate req.user first.
443
- (0, auth_1.addMeRoutes)(app, options.userModel, options.authOptions, options.accessControl);
447
+ (0, auth_1.addMeRoutes)(app, options.userModel, options.authOptions, options.accessControl, oapi);
444
448
  Sentry.setupExpressErrorHandler(app);
445
449
  // Error middleware
446
450
  app.use(errors_1.apiUnauthorizedMiddleware);
@@ -0,0 +1,39 @@
1
+ /** The subset of an OpenAPI document needed to look up and validate a response schema. */
2
+ export interface OpenApiResponseSpec {
3
+ components?: Record<string, unknown>;
4
+ paths?: Record<string, Record<string, OpenApiResponseOperation | undefined> | undefined>;
5
+ }
6
+ interface OpenApiResponseOperation {
7
+ responses?: Record<string, {
8
+ content?: Record<string, {
9
+ schema?: unknown;
10
+ }>;
11
+ } | undefined>;
12
+ }
13
+ export interface DocumentedResponseOptions {
14
+ /** The `/openapi.json` document the app serves. */
15
+ spec: OpenApiResponseSpec;
16
+ /** The OpenAPI path template, e.g. `/announcements/{id}/click`. */
17
+ path: string;
18
+ /** HTTP method, any case. */
19
+ method: string;
20
+ /** The real response: its status picks the documented response, its body is validated. */
21
+ response: {
22
+ status: number;
23
+ body: unknown;
24
+ };
25
+ /** Response media type to validate against. Defaults to `application/json`. */
26
+ contentType?: string;
27
+ }
28
+ export interface DocumentedResponseResult {
29
+ valid: boolean;
30
+ errors: string[];
31
+ }
32
+ /**
33
+ * Validates a real response body against the response schema `/openapi.json` documents for it,
34
+ * resolving `#/components/...` references against the same spec.
35
+ */
36
+ export declare const validateDocumentedResponse: ({ contentType, method, path, response, spec, }: DocumentedResponseOptions) => DocumentedResponseResult;
37
+ /** Throws with every schema violation when a response body does not match its documentation. */
38
+ export declare const expectDocumentedResponse: (options: DocumentedResponseOptions) => void;
39
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.expectDocumentedResponse = exports.validateDocumentedResponse = void 0;
7
+ const ajv_1 = __importDefault(require("ajv"));
8
+ const ajv_formats_1 = __importDefault(require("ajv-formats"));
9
+ /** Raised when a route or response is undocumented, or a body breaks its documented schema. */
10
+ class DocumentedResponseError extends Error {
11
+ name = "DocumentedResponseError";
12
+ }
13
+ const findResponseSchema = ({ contentType, method, path, spec, status, }) => {
14
+ const label = `${method.toUpperCase()} ${path}`;
15
+ const operation = spec.paths?.[path]?.[method.toLowerCase()];
16
+ if (!operation) {
17
+ throw new DocumentedResponseError(`${label} is not documented in the OpenAPI spec`);
18
+ }
19
+ const documented = operation.responses?.[String(status)];
20
+ if (!documented) {
21
+ const statuses = Object.keys(operation.responses ?? {}).join(", ") || "none";
22
+ throw new DocumentedResponseError(`${label} has no documented ${status} response (documented: ${statuses})`);
23
+ }
24
+ const schema = documented.content?.[contentType]?.schema;
25
+ if (!schema) {
26
+ throw new DocumentedResponseError(`${label} ${status} response has no ${contentType} schema`);
27
+ }
28
+ return schema;
29
+ };
30
+ /**
31
+ * Validates a real response body against the response schema `/openapi.json` documents for it,
32
+ * resolving `#/components/...` references against the same spec.
33
+ */
34
+ const validateDocumentedResponse = ({ contentType = "application/json", method, path, response, spec, }) => {
35
+ const schema = findResponseSchema({ contentType, method, path, spec, status: response.status });
36
+ const ajv = new ajv_1.default({ allErrors: true, strict: false });
37
+ (0, ajv_formats_1.default)(ajv);
38
+ // Wrapping keeps `#/components/...` refs resolvable from the root of the compiled schema.
39
+ const validate = ajv.compile({ allOf: [schema], components: spec.components ?? {} });
40
+ if (validate(response.body)) {
41
+ return { errors: [], valid: true };
42
+ }
43
+ const errors = (validate.errors ?? []).map((error) => `${error.instancePath || "(root)"} ${error.message ?? "is invalid"}`);
44
+ return { errors, valid: false };
45
+ };
46
+ exports.validateDocumentedResponse = validateDocumentedResponse;
47
+ /** Throws with every schema violation when a response body does not match its documentation. */
48
+ const expectDocumentedResponse = (options) => {
49
+ const { errors, valid } = (0, exports.validateDocumentedResponse)(options);
50
+ if (valid) {
51
+ return;
52
+ }
53
+ const label = `${options.method.toUpperCase()} ${options.path} ${options.response.status}`;
54
+ throw new DocumentedResponseError(`${label} response does not match its OpenAPI schema:\n- ${errors.join("\n- ")}\nBody: ${JSON.stringify(options.response.body)}`);
55
+ };
56
+ exports.expectDocumentedResponse = expectDocumentedResponse;
package/dist/tests.d.ts CHANGED
@@ -12,3 +12,4 @@ export { createTestData, FoodModel, loadTestDataFromCache, RequiredModel, StaffU
12
12
  export declare const getBaseServer: () => Express;
13
13
  export declare const authAsUser: (app: express.Application, type: "admin" | "notAdmin") => Promise<TestAgent>;
14
14
  export { loadTestData } from "./tests/mongoTestSetup";
15
+ export { type DocumentedResponseOptions, type DocumentedResponseResult, expectDocumentedResponse, type OpenApiResponseSpec, validateDocumentedResponse, } from "./tests/openApiResponseSchema";
package/dist/tests.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadTestData = exports.authAsUser = exports.getBaseServer = exports.UserModel = exports.setupTestData = exports.setupTestCache = exports.setupDb = exports.SuperUserModel = exports.StaffUserModel = exports.RequiredModel = exports.loadTestDataFromCache = exports.FoodModel = exports.createTestData = exports.authUserModel = void 0;
3
+ exports.validateDocumentedResponse = exports.expectDocumentedResponse = exports.loadTestData = exports.authAsUser = exports.getBaseServer = exports.UserModel = exports.setupTestData = exports.setupTestCache = exports.setupDb = exports.SuperUserModel = exports.StaffUserModel = exports.RequiredModel = exports.loadTestDataFromCache = exports.FoodModel = exports.createTestData = exports.authUserModel = void 0;
4
4
  const test_1 = require("@terreno/test");
5
5
  const openApiCompat_1 = require("./openApiCompat");
6
6
  const createTestData_1 = require("./tests/createTestData");
@@ -33,3 +33,6 @@ const authAsUser = async (app, type) => {
33
33
  exports.authAsUser = authAsUser;
34
34
  var mongoTestSetup_2 = require("./tests/mongoTestSetup");
35
35
  Object.defineProperty(exports, "loadTestData", { enumerable: true, get: function () { return mongoTestSetup_2.loadTestData; } });
36
+ var openApiResponseSchema_1 = require("./tests/openApiResponseSchema");
37
+ Object.defineProperty(exports, "expectDocumentedResponse", { enumerable: true, get: function () { return openApiResponseSchema_1.expectDocumentedResponse; } });
38
+ Object.defineProperty(exports, "validateDocumentedResponse", { enumerable: true, get: function () { return openApiResponseSchema_1.validateDocumentedResponse; } });
@@ -18,7 +18,7 @@ export interface McpRequestLogDocument extends mongoose.Document {
18
18
  oauthClientId?: string;
19
19
  oauthFamilyId?: string;
20
20
  outcome: McpRequestLogOutcome;
21
- serviceTokenId?: mongoose.Types.ObjectId;
21
+ serviceTokenId?: string;
22
22
  toolName: string;
23
23
  updated: Date;
24
24
  userId?: mongoose.Types.ObjectId;
@@ -8,7 +8,7 @@ interface McpServiceTokenMethods {
8
8
  deleteOne: (this: McpServiceTokenDocument) => Promise<McpServiceTokenDocument>;
9
9
  }
10
10
  export interface McpServiceTokenStatics extends FindExactlyOnePlugin<McpServiceTokenDocument>, FindOneOrNonePlugin<McpServiceTokenDocument> {
11
- countActiveForUser: (this: McpServiceTokenModel, userId: mongoose.Types.ObjectId) => Promise<number>;
11
+ countActiveForUser: (this: McpServiceTokenModel, userId: mongoose.Types.ObjectId | string) => Promise<number>;
12
12
  issueFor: (this: McpServiceTokenModel, user: {
13
13
  _id: {
14
14
  toString(): string;
@@ -30,14 +30,17 @@ export interface McpServiceTokenStatics extends FindExactlyOnePlugin<McpServiceT
30
30
  _id: {
31
31
  toString(): string;
32
32
  };
33
- }, tokenId: mongoose.Types.ObjectId) => Promise<McpServiceTokenDocument | null>;
33
+ }, tokenId: string) => Promise<McpServiceTokenDocument | null>;
34
34
  verify: (this: McpServiceTokenModel, token: string) => Promise<McpServiceTokenDocument | null>;
35
35
  }
36
36
  export interface McpServiceTokenModel extends mongoose.Model<McpServiceTokenDocument, object, McpServiceTokenMethods>, McpServiceTokenStatics {
37
37
  }
38
- export interface McpServiceTokenDocument extends mongoose.Document {
39
- _id: mongoose.Types.ObjectId;
38
+ export interface McpServiceTokenDocument extends mongoose.Document<string> {
39
+ /** UUID for new rows; ObjectId hex for rows migrated by mcp-service-token-string-ids. */
40
+ _id: string;
40
41
  created: Date;
42
+ /** Always false: a delete revokes the token instead of tombstoning it. */
43
+ deleted: boolean;
41
44
  expiresAt?: Date;
42
45
  lastUsedAt?: Date;
43
46
  name: string;
@@ -15,5 +15,5 @@ export interface VersionCheckResponse {
15
15
  * Compares client build number against admin-configured thresholds per platform.
16
16
  */
17
17
  export declare class VersionCheckPlugin implements TerrenoPlugin {
18
- register(app: express.Application): void;
18
+ register(app: express.Application, openApi?: unknown): void;
19
19
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VersionCheckPlugin = void 0;
4
4
  const api_1 = require("./api");
5
5
  const versionConfig_1 = require("./models/versionConfig");
6
+ const openApiBuilder_1 = require("./openApiBuilder");
6
7
  const DEFAULT_WARNING_MESSAGE = "A new version is available. Please update for the best experience.";
7
8
  const DEFAULT_REQUIRED_MESSAGE = "This version is no longer supported. Please update to continue.";
8
9
  const DEFAULT_POLLING_INTERVAL_MINUTES = 1440;
@@ -11,8 +12,30 @@ const DEFAULT_POLLING_INTERVAL_MINUTES = 1440;
11
12
  * Compares client build number against admin-configured thresholds per platform.
12
13
  */
13
14
  class VersionCheckPlugin {
14
- register(app) {
15
- app.get("/version-check", (0, api_1.asyncHandler)(async (req, res) => {
15
+ register(app, openApi) {
16
+ // Documentation only: request validation stays off so unparseable versions still get "ok".
17
+ const versionCheckOpenApi = (0, openApiBuilder_1.createOpenApiBuilder)(openApi ? { openApi: openApi } : {})
18
+ .withTags(["version"])
19
+ .withSummary("Check whether the client build must or should update")
20
+ .withQueryParameter("platform", { enum: ["web", "mobile"], type: "string" }, { description: "Client platform. Any other value is treated as web." })
21
+ .withQueryParameter("version", { type: "integer" }, { description: "Client build number. When missing or not a number, the status is ok." })
22
+ .withResponse(200, {
23
+ message: {
24
+ description: "Message to show when status is warning or required",
25
+ type: "string",
26
+ },
27
+ pollingIntervalMs: {
28
+ description: "How often the client should poll for updates, in milliseconds",
29
+ type: "number",
30
+ },
31
+ requiredVersion: { description: "Minimum supported build number", type: "number" },
32
+ status: { enum: ["ok", "warning", "required"], type: "string" },
33
+ updateUrl: { description: "Where the user can get the update", type: "string" },
34
+ warningVersion: { description: "Builds below this number get a warning", type: "number" },
35
+ }, { required: ["status"] })
36
+ .withValidation({ enabled: false })
37
+ .build();
38
+ app.get("/version-check", versionCheckOpenApi, (0, api_1.asyncHandler)(async (req, res) => {
16
39
  const versionParam = req.query.version;
17
40
  const platform = req.query.platform;
18
41
  let version;
package/package.json CHANGED
@@ -7,13 +7,13 @@
7
7
  "url": "https://github.com/TerrenoLabs/terreno/issues"
8
8
  },
9
9
  "dependencies": {
10
- "@asteasolutions/zod-to-openapi": "^8.5.0",
10
+ "@asteasolutions/zod-to-openapi": "^9.1.0",
11
11
  "@better-auth/expo": "^1.6.25",
12
12
  "@better-auth/passkey": "1.7.4",
13
13
  "@modelcontextprotocol/node": "^2.0.0",
14
14
  "@modelcontextprotocol/server": "^2.0.0",
15
- "@sentry/bun": "^10.39.0",
16
- "@terreno/test": "57.21.0",
15
+ "@sentry/bun": "^11.0.0",
16
+ "@terreno/test": "58.0.0-beta.2",
17
17
  "@thream/socketio-jwt": "^3.1.4",
18
18
  "@types/qs": "^6.14.0",
19
19
  "ajv": "8.20.0",
@@ -43,7 +43,7 @@
43
43
  "serve-static": "^2.2.1",
44
44
  "socket.io": "^4.8.1",
45
45
  "swagger-parser": "^10.0.3",
46
- "swagger-ui-dist": "^5.11.8",
46
+ "swagger-ui-dist": "^5.33.0",
47
47
  "winston": "^3.18.3",
48
48
  "yaml": "^2.4.0"
49
49
  },
@@ -51,7 +51,7 @@
51
51
  "devDependencies": {
52
52
  "@biomejs/biome": "^2.3.6",
53
53
  "@modelcontextprotocol/client": "^2.0.0",
54
- "@terreno/syncdb": "57.21.0",
54
+ "@terreno/syncdb": "58.0.0-beta.2",
55
55
  "@types/bun": "^1.4.0",
56
56
  "@types/cors": "^2.8.17",
57
57
  "@types/express": "^5.0.6",
@@ -80,8 +80,19 @@
80
80
  "./testing": {
81
81
  "default": "./dist/tests.js",
82
82
  "types": "./dist/tests.d.ts"
83
+ },
84
+ "./testing/openApi": {
85
+ "default": "./dist/tests/openApiResponseSchema.js",
86
+ "types": "./dist/tests/openApiResponseSchema.d.ts"
83
87
  }
84
88
  },
89
+ "files": [
90
+ "LICENSE",
91
+ "CHANGELOG.md",
92
+ "dist/**/*",
93
+ "src/**/*",
94
+ ".ai/**/*"
95
+ ],
85
96
  "homepage": "https://github.com/TerrenoLabs/terreno#readme",
86
97
  "keywords": [
87
98
  "rest",
@@ -137,5 +148,5 @@
137
148
  "updateSnapshot": "bun test --update-snapshots"
138
149
  },
139
150
  "types": "dist/index.d.ts",
140
- "version": "57.21.0"
151
+ "version": "58.0.0-beta.2"
141
152
  }