@terreno/ai 0.28.0 → 0.30.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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.test.ts +102 -0
package/package.json CHANGED
@@ -18,14 +18,14 @@
18
18
  "description": "AI service layer for Terreno apps - GPT chat, request logging, and admin tools.",
19
19
  "devDependencies": {
20
20
  "@biomejs/biome": "^2.3.6",
21
- "@terreno/test": "0.28.0",
21
+ "@terreno/test": "0.30.0",
22
22
  "@types/bun": "^1.3.8",
23
23
  "@types/express": "^5.0.6",
24
24
  "@types/luxon": "^3.7.1",
25
25
  "@types/multer": "^1.4.12",
26
26
  "@types/passport-local-mongoose": "^6.1.5",
27
27
  "@types/supertest": "^7.2.0",
28
- "@terreno/api": "0.28.0",
28
+ "@terreno/api": "0.30.0",
29
29
  "mongoose": "8.23.0",
30
30
  "passport-local-mongoose": "^9.0.1",
31
31
  "supertest": "^7.2.2",
@@ -72,7 +72,7 @@
72
72
  "access": "public"
73
73
  },
74
74
  "peerDependencies": {
75
- "@terreno/api": "0.28.0",
75
+ "@terreno/api": "0.30.0",
76
76
  "mongoose": "^8.0.0"
77
77
  },
78
78
  "repository": {
@@ -91,5 +91,5 @@
91
91
  "test:coverage": "bun run ../scripts/check-coverage.ts"
92
92
  },
93
93
  "types": "dist/index.d.ts",
94
- "version": "0.28.0"
94
+ "version": "0.30.0"
95
95
  }
@@ -0,0 +1,102 @@
1
+ import {describe, expect, it} from "bun:test";
2
+
3
+ import * as terrenoAi from "./index";
4
+
5
+ const exported: Record<string, unknown> = terrenoAi;
6
+
7
+ /**
8
+ * Guards the public entrypoint of @terreno/ai: a missing or renamed export here is a
9
+ * breaking change for consumers, and the barrel itself is never exercised by the
10
+ * per-module tests.
11
+ */
12
+ describe("@terreno/ai public exports", () => {
13
+ const expectedFunctions = [
14
+ "addAiRequestsExplorerRoutes",
15
+ "addFileRoutes",
16
+ "addGptHistoryRoutes",
17
+ "addGptRoutes",
18
+ "addMcpRoutes",
19
+ "addProjectRoutes",
20
+ "assertVertexModelsEnabled",
21
+ "compilePrompt",
22
+ "createPrompt",
23
+ "createTelemetryConfig",
24
+ "createVertexProvider",
25
+ "getCached",
26
+ "getLangfuseClient",
27
+ "getPrompt",
28
+ "initLangfuseClient",
29
+ "initTracing",
30
+ "invalidateCache",
31
+ "invalidatePromptCache",
32
+ "isLangfuseInitialized",
33
+ "isVertexModelAllowed",
34
+ "jsonSchema",
35
+ "listEnabledVertexModels",
36
+ "listGeminiApiModels",
37
+ "normalizeGeminiModelId",
38
+ "normalizeLlmJsonTextForStructuredOutput",
39
+ "normalizeVertexModelId",
40
+ "parseAiJson",
41
+ "preparePromptForAI",
42
+ "setCached",
43
+ "shutdownLangfuseClient",
44
+ "shutdownTracing",
45
+ "verifyVertexModelsEnabled",
46
+ ] as const;
47
+
48
+ const expectedClasses = [
49
+ "AIRequest",
50
+ "AIService",
51
+ "AiApp",
52
+ "FileAttachment",
53
+ "FileStorageService",
54
+ "GptHistory",
55
+ "LangfuseApp",
56
+ "LangfuseCache",
57
+ "MCPService",
58
+ "Project",
59
+ ] as const;
60
+
61
+ const expectedConstants = [
62
+ "CONTENT_SUMMARY_PROMPT",
63
+ "DEFAULT_GPT_MEMORY",
64
+ "DEFAULT_VERTEX_LOCATION",
65
+ "GEMINI_API_BASE_URL",
66
+ "JSON_VALUE_SYSTEM_PROMPT",
67
+ "Output",
68
+ "REMIX_PROMPT",
69
+ "TITLE_GENERATION_PROMPT",
70
+ "TRANSLATION_PROMPT",
71
+ "TemperaturePresets",
72
+ ] as const;
73
+
74
+ it.each(expectedFunctions)("exports %s as a function", (name) => {
75
+ expect(typeof exported[name]).toBe("function");
76
+ });
77
+
78
+ it.each(expectedClasses)("exports %s as a constructable value", (name) => {
79
+ expect(typeof exported[name]).toBe("function");
80
+ });
81
+
82
+ it.each(expectedConstants)("exports the %s constant", (name) => {
83
+ expect(exported[name]).toBeDefined();
84
+ });
85
+
86
+ it("re-exports the default AI request types", () => {
87
+ expect(terrenoAi.DEFAULT_AI_REQUEST_TYPES).toContain("general");
88
+ expect(terrenoAi.DEFAULT_AI_REQUEST_TYPES).toContain("translation");
89
+
90
+ // The tuple is frozen at the type level via `as const`; keep the runtime list stable
91
+ // because request types are persisted on AIRequest documents.
92
+ expect([...terrenoAi.DEFAULT_AI_REQUEST_TYPES]).toEqual([
93
+ "general",
94
+ "json_array",
95
+ "json_object",
96
+ "json_value",
97
+ "remix",
98
+ "summarization",
99
+ "translation",
100
+ ]);
101
+ });
102
+ });