@sitevision/api 2025.5.1 → 2025.7.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/index.d.ts CHANGED
@@ -134,6 +134,7 @@ import './server/WebResourceFactory';
134
134
  import './server/XSLTUtil';
135
135
  import './server/XmlParserUtil';
136
136
  import './server/ai';
137
+ import './server/aiAssistant';
137
138
  import './server/appData';
138
139
  import './server/appInfo';
139
140
  import './server/appResource';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitevision/api",
3
- "version": "2025.5.1",
3
+ "version": "2025.7.1",
4
4
  "author": "Sitevision AB",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,5 +30,5 @@
30
30
  "access": "public",
31
31
  "directory": "dist"
32
32
  },
33
- "gitHead": "28570281cd01424c7ed0772fb5a5f004c92712b1"
33
+ "gitHead": "771eb380b026a8b6df85ac5c55a83dfa55b9a179"
34
34
  }
@@ -152,6 +152,7 @@ import type { String } from "../../types/java/lang/String";
152
152
  * </ul>
153
153
  * @author Magnus Lövgren
154
154
  * @since Sitevision 2.6.1_08
155
+ * @deprecated
155
156
  */
156
157
  export interface FileIconRenderer {
157
158
  /**
@@ -9,6 +9,7 @@ import type { Node } from "../../types/javax/jcr/Node";
9
9
  * See {@link senselogic.sitevision.api.Utils} for how to obtain an instance of the <code>Utils</code> interface.
10
10
  * </p>
11
11
  * @author Magnus Lövgren
12
+ * @deprecated
12
13
  */
13
14
  export interface IconUtil {
14
15
  /**
@@ -734,6 +734,18 @@ export interface NodeTypeUtil extends NodeTypeUtilConstants {
734
734
  */
735
735
  SEMANTIC_INDEX_REPOSITORY_TYPE: "sv:semanticIndexRepository";
736
736
 
737
+ /**
738
+ * The primary node type name for the ai assistant type.
739
+ * @since Sitevision 2025.07.1
740
+ */
741
+ AI_ASSISTANT_TYPE: "sv:aiAssistant";
742
+
743
+ /**
744
+ * The primary node type name for the ai assistant repository type.
745
+ * @since Sitevision 2025.07.1
746
+ */
747
+ AI_ASSISTANT_REPOSITORY_TYPE: "sv:aiAssistantRepository";
748
+
737
749
  /**
738
750
  * The primary node type name for the simple user type.
739
751
  * @see #isSimpleUser(Node)
@@ -1242,6 +1254,12 @@ export interface NodeTypeUtil extends NodeTypeUtilConstants {
1242
1254
  */
1243
1255
  TARGET_AUDIENCE_TYPE: "sv:targetAudience";
1244
1256
 
1257
+ /**
1258
+ * The primary node type name for the target audience group repository type.
1259
+ * @since SiteVision 2025.07.1
1260
+ */
1261
+ TARGET_AUDIENCE_GROUP_REPOSITORY_TYPE: "sv:targetAudienceGroupRepository";
1262
+
1245
1263
  /**
1246
1264
  * The primary node type name for the target audience group type.
1247
1265
  * @since Sitevision 2024.09.2
@@ -495,6 +495,20 @@ export interface ResourceLocatorUtil {
495
495
  * @since Sitevision 2025.03.1
496
496
  */
497
497
  getSemanticIndexRepository(): Node;
498
+
499
+ /**
500
+ * Gets the target audience group repository (sv:targetAudienceGroupRepository) for the site of current node.
501
+ * @return the target audience group repository, or null if indeterminable.
502
+ * @since Sitevision 2025.07.1
503
+ */
504
+ getTargetAudienceGroupRepository(): Node;
505
+
506
+ /**
507
+ * Gets the ai assistant repository (sv:aiAssistantRepository) for the site of current node.
508
+ * @return the ai assistant repository, or null if indeterminable.
509
+ * @since Sitevision 2025.07.1
510
+ */
511
+ getAiAssistantRepository(): Node;
498
512
  }
499
513
 
500
514
  declare namespace ResourceLocatorUtil {}
@@ -52,5 +52,7 @@ var _default = exports["default"] = {
52
52
  getCssRuleRepository: function getCssRuleRepository() {},
53
53
  getLlmConfigurationRepository: function getLlmConfigurationRepository() {},
54
54
  getTargetAudienceRepository: function getTargetAudienceRepository() {},
55
- getSemanticIndexRepository: function getSemanticIndexRepository() {}
55
+ getSemanticIndexRepository: function getSemanticIndexRepository() {},
56
+ getTargetAudienceGroupRepository: function getTargetAudienceGroupRepository() {},
57
+ getAiAssistantRepository: function getAiAssistantRepository() {}
56
58
  };
@@ -29,8 +29,8 @@ export interface GenerateTextOptions {
29
29
 
30
30
  /**
31
31
  * Maximum duration (in milliseconds) before timing out.
32
- * The default value and valid range are environment-dependent and can be
33
- * configured via a system property. If not explicitly set, the system
32
+ * The default value and valid range are environment-dependent and can be
33
+ * configured via a system property. If not explicitly set, the system
34
34
  * determines an appropriate timeout value.
35
35
  */
36
36
  timeout?: number;
@@ -99,8 +99,8 @@ export interface StreamTextOptions {
99
99
 
100
100
  /**
101
101
  * Maximum duration (in milliseconds) before timing out.
102
- * The default value and valid range are environment-dependent and can be
103
- * configured via a system property. If not explicitly set, the system
102
+ * The default value and valid range are environment-dependent and can be
103
+ * configured via a system property. If not explicitly set, the system
104
104
  * determines an appropriate timeout value.
105
105
  */
106
106
  timeout?: number;
@@ -139,6 +139,15 @@ export interface StreamTextOptions {
139
139
  onFinish: (result: StreamFinishResult) => void;
140
140
  }
141
141
 
142
+ /**
143
+ * Contains token usage information for the request. Note that usage may vary and may not be supported by some models.
144
+ */
145
+ export type UsageInfo = {
146
+ promptTokens: number;
147
+ completionTokens: number;
148
+ totalTokens: number;
149
+ };
150
+
142
151
  /**
143
152
  * Final result object for a streaming text operation.
144
153
  */
@@ -164,13 +173,9 @@ export interface StreamFinishResult {
164
173
  finishReason: string;
165
174
 
166
175
  /**
167
- * (Optional) Token usage statistics for this request.
176
+ * Token usage statistics for this request.
168
177
  */
169
- usage?: {
170
- promptTokens: number;
171
- completionTokens: number;
172
- totalTokens: number;
173
- };
178
+ usage: UsageInfo;
174
179
  }
175
180
 
176
181
  /**
@@ -0,0 +1,197 @@
1
+ import aiAssistant from '.';
2
+ import type { Node } from '../../types/javax/jcr/Node';
3
+ import type { Message, StreamFinishResult, UsageInfo } from '../ai';
4
+
5
+ export type SemanticQueryOptions = {
6
+ /**
7
+ * The query, typically the user message to be used in a conversation
8
+ */
9
+ query: string;
10
+
11
+ /**
12
+ * Max number of chunks. Valid numbers are between 1 and 20 and the default is 5.
13
+ */
14
+ maxHits?: number;
15
+ };
16
+
17
+ export type AskAssistantOptions = {
18
+ /**
19
+ * The user message in the conversation
20
+ */
21
+ message: string;
22
+
23
+ /**
24
+ * The key that identifies the conversation for current user
25
+ */
26
+ conversationIdentifier: string;
27
+
28
+ /**
29
+ * The potential knowledge needed to answer the user question/message (optional).
30
+ * A provided knowledge value will be included in the system message/prompt of this conversation. The value will replace potentially previous knowledge.
31
+ *
32
+ * Hints. This value is typically extracted via the querySemanticIndex method. And potential existing knowledge in the conversation can be retrieved via the getConversationKnowledge method.
33
+ */
34
+ knowledge?: string | string[];
35
+
36
+ /**
37
+ * Callback function that is triggered for each received token.
38
+ * The function receives the token as a string.
39
+ *
40
+ * @param token The streamed token received from the AI model.
41
+ */
42
+ onChunk: (token: string) => void;
43
+
44
+ /**
45
+ * Callback function triggered when the streaming operation completes.
46
+ *
47
+ * @param result The final result of the stream operation.
48
+ */
49
+ onFinish: (result: StreamFinishResult) => void;
50
+ /**
51
+ * Maximum duration (in milliseconds) before timing out.
52
+ * The default value and valid range are environment-dependent and can be
53
+ * configured via a system property. If not explicitly set, the system
54
+ * determines an appropriate timeout value.
55
+ */
56
+ timeout?: number;
57
+
58
+ /**
59
+ * The maximum number of tokens (words/word fragments) the model can generate.
60
+ */
61
+ maxTokens?: number;
62
+
63
+ /**
64
+ * Controls response randomness:
65
+ * - Lower values (e.g., 0) make responses deterministic.
66
+ * - Higher values (e.g., 1) increase variability.
67
+ */
68
+ temperature?: number;
69
+
70
+ /**
71
+ * Reduces repeated token usage in generated text.
72
+ * Higher values promote more diverse output.
73
+ */
74
+ frequencyPenalty?: number;
75
+ };
76
+
77
+ export type AskLLMOptions = {
78
+ /**
79
+ * Messages that represent a conversation
80
+ */
81
+ messages: Message[];
82
+
83
+ /**
84
+ * The maximum amount of time, in milliseconds, that Sitevision will wait for a response before the connection times out.
85
+ * Default 30000 (30s)
86
+ */
87
+ timeout?: number;
88
+
89
+ /**
90
+ * Specifies the maximum number of tokens (words or word fragments) that the model can generate in the response. This includes both the prompt and the completion.
91
+ */
92
+ maxTokens?: number;
93
+
94
+ /**
95
+ * Controls the randomness or creativity of the model's output. Lower values make the output more deterministic and focused, while higher values introduce more variability and creativity.
96
+ */
97
+ temperature?: number;
98
+
99
+ /**
100
+ * Penalizes the model for using the same tokens repeatedly. A higher value reduces the likelihood of repeating the same phrases, promoting more diverse language usage.
101
+ */
102
+ frequencyPenalty?: number;
103
+ };
104
+
105
+ export type KnowledgeEntry = {
106
+ /**
107
+ * The unique identifier for the source of the knowledge.
108
+ */
109
+ id: string;
110
+
111
+ /**
112
+ * The knowledge text, typically a string.
113
+ */
114
+ text: string;
115
+ };
116
+
117
+ export type LLMResponse = {
118
+ text: string;
119
+
120
+ error: string;
121
+
122
+ finishReason: string;
123
+
124
+ usage: UsageInfo;
125
+ };
126
+
127
+ /**
128
+ * AI SDK for interacting with Large Language Models (LLMs).
129
+ */
130
+ export interface AIAssistant {
131
+ /**
132
+ * Returns a new, unique conversationIdentifier string - the key needed to identify a conversation for current user.
133
+ * @param aiAssistant The AI Assistant instance.
134
+ * @returns A unique conversation identifier string.
135
+ */
136
+ createConversation(aiAssistant: Node): string;
137
+
138
+ /**
139
+ * Retrieves the memory (context) of a specific conversation. Will not include any system messages.
140
+ *
141
+ * @param aiAssistant The AI Assistant instance.
142
+ * @param conversationIdentifier The unique identifier of the conversation.
143
+ * @returns An array of messages representing the conversation memory.
144
+ */
145
+ getConversationMemory(
146
+ aiAssistant: Node,
147
+ conversationIdentifier: string
148
+ ): Message[];
149
+
150
+ /**
151
+ * Retrieves the knowledge string used in the conversation.
152
+ *
153
+ * @param aiAssistant The AI Assistant instance.
154
+ * @param conversationIdentifier The unique identifier of the conversation.
155
+ * @returns A string representing the conversation knowledge.
156
+ */
157
+ getConversationKnowledge(
158
+ aiAssistant: Node,
159
+ conversationIdentifier: string
160
+ ): string;
161
+
162
+ /**
163
+ * Queries a semantic index for knowledge entries based on the provided options.
164
+ *
165
+ * @param aiAssistant The AI Assistant instance.
166
+ * @param options Options for the semantic query.
167
+ * @returns An array of knowledge entries matching the query.
168
+ */
169
+ querySemanticIndex(
170
+ aiAssistant: Node,
171
+ options: SemanticQueryOptions
172
+ ): KnowledgeEntry[];
173
+
174
+ /**
175
+ * Asks the AI Assistant a question and will receive a streamed response.
176
+ *
177
+ * @param aiAssistant The AI Assistant instance.
178
+ * @param options Options for the assistant query.
179
+ */
180
+ askAssistant(aiAssistant: Node, options: AskAssistantOptions);
181
+
182
+ /**
183
+ * Method to generate text using the LLM of an AI Assistant configuration. Useful for non-interactive use cases such as summarization,
184
+ * @param aiAssistant The AI Assistant instance.
185
+ * @param options Options for the LLM query.
186
+ */
187
+ askLLM(aiAssistant: Node, options: AskLLMOptions): LLMResponse;
188
+ }
189
+
190
+ declare namespace AIAssistant {}
191
+
192
+ /**
193
+ * The AI Assistant SDK instance.
194
+ */
195
+ declare var aiAssistant: AIAssistant;
196
+
197
+ export default aiAssistant;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _default = exports["default"] = {
8
+ createConversation: function createConversation() {},
9
+ getConversationMemory: function getConversationMemory() {},
10
+ getConversationKnowledge: function getConversationKnowledge() {},
11
+ querySemanticIndex: function querySemanticIndex() {},
12
+ askAssistant: function askAssistant() {},
13
+ askLLM: function askLLM() {}
14
+ };
@@ -20,6 +20,10 @@ import type { String } from "../../../../../java/lang/String";
20
20
  * This renderer provides the ability to render <em>"plain" HTML</em> output for a Text module
21
21
  * <em>(typically what you want when the HTML of the Text module should be used outside of Sitevision, i.e. headless)</em>.
22
22
  * </li>
23
+ * <li>
24
+ * This renderer also supports rendering output as <em>Markdown</em>,
25
+ * which is particularly useful for large language model (LLM) applications and other modern content workflows.
26
+ * </li>
23
27
  * </ul>
24
28
  *
25
29
  * <p>
@@ -43,14 +47,15 @@ import type { String } from "../../../../../java/lang/String";
43
47
  *
44
48
  * <p>
45
49
  * <strong>Example of how this renderer could be used:</strong><br>
46
- * E.g. You want to get all output types (html, plain html, text) from two Text modules on a specific page.
50
+ * E.g. You want to get all output types (html, plain html, text, markdown) from two Text modules on a specific page.
47
51
  * </p>
48
52
  * <pre><code> var textRendererBuilder = require('TextModuleRendererBuilder'),
49
53
  * textRenderer,
50
54
  * page,
51
55
  * htmlData = { "type": "HTML" },
52
56
  * plainHtmlData = { "type": "Plain HTML" },
53
- * textData = { "type": "Text" };
57
+ * textData = { "type": "Text" },
58
+ * markdownData = { "type": "Markdown" };
54
59
  *
55
60
  * <em>// Get the page where the Text modules are located...</em>
56
61
  * page = ...
@@ -64,6 +69,7 @@ import type { String } from "../../../../../java/lang/String";
64
69
  * htmlData.heading = textRenderer.renderHtml();
65
70
  * plainHtmlData.heading = textRenderer.renderPlainHtml();
66
71
  * textData.heading = textRenderer.renderText();
72
+ * markdownData.heading = textRenderer.renderMarkdown();
67
73
  * }
68
74
  *
69
75
  * <em>// Update the TextModuleRenderer with another Text module and render (if possible)</em>
@@ -72,6 +78,7 @@ import type { String } from "../../../../../java/lang/String";
72
78
  * htmlData.content = textRenderer.renderHtml();
73
79
  * plainHtmlData.content = textRenderer.renderPlainHtml();
74
80
  * textData.content = textRenderer.renderText();
81
+ * markdownData.content = textRenderer.renderMarkdown();
75
82
  * }</code></pre>
76
83
  * <p>
77
84
  * The JSON result of the Javascript objects in the example script above could be something like this:
@@ -95,6 +102,13 @@ import type { String } from "../../../../../java/lang/String";
95
102
  * "type": "Text",
96
103
  * "heading": "Heading",
97
104
  * "content": "Some content"
105
+ * }
106
+ *
107
+ * <strong>// markdownData</strong>
108
+ * {
109
+ * "type": "Markdown",
110
+ * "heading": "# Heading",
111
+ * "content": "Some content"
98
112
  * }</code></pre>
99
113
  *
100
114
  * <p>
@@ -231,4 +245,16 @@ export type TextModuleRenderer = {
231
245
  * @see #renderHtml()
232
246
  */
233
247
  renderPlainHtml(): string;
248
+
249
+ /**
250
+ * Renders Markdown for the loaded Text module.
251
+ *
252
+ * <p>
253
+ * <strong>Note!</strong> The returned value will always be empty string if the {@link #isLoaded()} state is <code>false</code>
254
+ * when invoking this render method <em>(i.e. you would typically always check the loaded state before calling this method).</em>
255
+ * </p>
256
+ * @return the Markdown representation of the loaded Text module, or empty String if rendering fails or no Text module is loaded
257
+ * @since Sitevision 2025.07.1
258
+ */
259
+ renderMarkdown(): string;
234
260
  };
@@ -11,5 +11,6 @@ var _default = exports["default"] = {
11
11
  isLoaded: function isLoaded() {},
12
12
  renderHtml: function renderHtml() {},
13
13
  renderText: function renderText() {},
14
- renderPlainHtml: function renderPlainHtml() {}
14
+ renderPlainHtml: function renderPlainHtml() {},
15
+ renderMarkdown: function renderMarkdown() {}
15
16
  };
@@ -1367,6 +1367,13 @@ export type NodeTypeUtilConstants = {
1367
1367
  */
1368
1368
  getTARGET_AUDIENCE_TYPE(): string;
1369
1369
 
1370
+ /**
1371
+ * Get accessor for {@link senselogic.sitevision.api.node.NodeTypeUtil#TARGET_AUDIENCE_GROUP_REPOSITORY_TYPE}.
1372
+ * @return {@link senselogic.sitevision.api.node.NodeTypeUtil#TARGET_AUDIENCE_GROUP_REPOSITORY_TYPE}
1373
+ * @since Sitevision 2025.07.1
1374
+ */
1375
+ getTARGET_AUDIENCE_GROUP_REPOSITORY_TYPE(): string;
1376
+
1370
1377
  /**
1371
1378
  * Get accessor for {@link senselogic.sitevision.api.node.NodeTypeUtil#TARGET_AUDIENCE_GROUP_TYPE}.
1372
1379
  * @return {@link senselogic.sitevision.api.node.NodeTypeUtil#TARGET_AUDIENCE_GROUP_TYPE}
@@ -1422,4 +1429,18 @@ export type NodeTypeUtilConstants = {
1422
1429
  * @since Sitevision 2025.03.1
1423
1430
  */
1424
1431
  getSEMANTIC_INDEX_REPOSITORY_TYPE(): string;
1432
+
1433
+ /**
1434
+ * Get accessor for {@link senselogic.sitevision.api.node.NodeTypeUtil#AI_ASSISTANT_TYPE}.
1435
+ * @return {@link senselogic.sitevision.api.node.NodeTypeUtil#AI_ASSISTANT_TYPE}
1436
+ * @since Sitevision 2025.07.1
1437
+ */
1438
+ getAI_ASSISTANT_TYPE(): string;
1439
+
1440
+ /**
1441
+ * Get accessor for {@link senselogic.sitevision.api.node.NodeTypeUtil#AI_ASSISTANT_REPOSITORY_TYPE}.
1442
+ * @return {@link senselogic.sitevision.api.node.NodeTypeUtil#AI_ASSISTANT_REPOSITORY_TYPE}
1443
+ * @since Sitevision 2025.07.1
1444
+ */
1445
+ getAI_ASSISTANT_REPOSITORY_TYPE(): string;
1425
1446
  };
@@ -203,6 +203,7 @@ var _default = exports["default"] = {
203
203
  getCSS_RULE_TYPE: function getCSS_RULE_TYPE() {},
204
204
  getTARGET_AUDIENCE_REPOSITORY_TYPE: function getTARGET_AUDIENCE_REPOSITORY_TYPE() {},
205
205
  getTARGET_AUDIENCE_TYPE: function getTARGET_AUDIENCE_TYPE() {},
206
+ getTARGET_AUDIENCE_GROUP_REPOSITORY_TYPE: function getTARGET_AUDIENCE_GROUP_REPOSITORY_TYPE() {},
206
207
  getTARGET_AUDIENCE_GROUP_TYPE: function getTARGET_AUDIENCE_GROUP_TYPE() {},
207
208
  getMETADATA_SINGLE_TARGET_AUDIENCE_DEFINITION_TYPE: function getMETADATA_SINGLE_TARGET_AUDIENCE_DEFINITION_TYPE() {},
208
209
  getMETADATA_MULTIPLE_TARGET_AUDIENCE_DEFINITION_TYPE: function getMETADATA_MULTIPLE_TARGET_AUDIENCE_DEFINITION_TYPE() {},
@@ -210,5 +211,7 @@ var _default = exports["default"] = {
210
211
  getMETADATA_GEOLOCATION_DEFINITION_TYPE: function getMETADATA_GEOLOCATION_DEFINITION_TYPE() {},
211
212
  getMETADATA_MODULE_DEFINITION_TYPE: function getMETADATA_MODULE_DEFINITION_TYPE() {},
212
213
  getSEMANTIC_INDEX_TYPE: function getSEMANTIC_INDEX_TYPE() {},
213
- getSEMANTIC_INDEX_REPOSITORY_TYPE: function getSEMANTIC_INDEX_REPOSITORY_TYPE() {}
214
+ getSEMANTIC_INDEX_REPOSITORY_TYPE: function getSEMANTIC_INDEX_REPOSITORY_TYPE() {},
215
+ getAI_ASSISTANT_TYPE: function getAI_ASSISTANT_TYPE() {},
216
+ getAI_ASSISTANT_REPOSITORY_TYPE: function getAI_ASSISTANT_REPOSITORY_TYPE() {}
214
217
  };