@xpert-ai/contracts 3.15.5 → 3.15.7

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.cjs.js CHANGED
@@ -3856,7 +3856,7 @@ var MCP_APP_RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
3856
3856
 
3857
3857
  /**
3858
3858
  * Build a hierarchical tree structure from a flat list of DocumentInterface objects,
3859
- * and
3859
+ * preserving explicit chunkIndex order whenever it is available.
3860
3860
  *
3861
3861
  * @template Metadata - Type of metadata, defaults to IDocChunkMetadata
3862
3862
  * @param documents - A flat array of DocumentInterface objects
@@ -3912,18 +3912,33 @@ function buildChunkTree(documents) {
3912
3912
  if (!documents || documents.length === 0) return [];
3913
3913
  // Step 1. Build a lookup map for quick access by chunkId
3914
3914
  var map = new Map();
3915
+ // Keep the original retrieval/insertion order as a deterministic fallback.
3916
+ var inputOrder = new Map();
3917
+ documents.forEach(function(doc, index) {
3918
+ var chunkId = getChunkNodeId(doc);
3919
+ if (chunkId) {
3920
+ map.set(chunkId, _object_spread_props$2(_object_spread$2({}, doc), {
3921
+ metadata: _object_spread_props$2(_object_spread$2({}, doc.metadata), {
3922
+ chunkId: chunkId,
3923
+ children: []
3924
+ })
3925
+ }));
3926
+ inputOrder.set(chunkId, index);
3927
+ }
3928
+ });
3929
+ // Step 2. Organize nodes into tree
3930
+ var roots = [];
3915
3931
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3916
3932
  try {
3917
- for(var _iterator = documents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3933
+ for(var _iterator = map.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3918
3934
  var doc = _step.value;
3919
- var chunkId = getChunkNodeId(doc);
3920
- if (chunkId) {
3921
- map.set(chunkId, _object_spread_props$2(_object_spread$2({}, doc), {
3922
- metadata: _object_spread_props$2(_object_spread$2({}, doc.metadata), {
3923
- chunkId: chunkId,
3924
- children: []
3925
- })
3926
- }));
3935
+ var parentId = doc.metadata.parentId;
3936
+ if (parentId && map.has(parentId)) {
3937
+ var parent = map.get(parentId);
3938
+ parent.metadata.children = parent.metadata.children || [];
3939
+ parent.metadata.children.push(doc);
3940
+ } else {
3941
+ roots.push(doc);
3927
3942
  }
3928
3943
  }
3929
3944
  } catch (err) {
@@ -3940,46 +3955,66 @@ function buildChunkTree(documents) {
3940
3955
  }
3941
3956
  }
3942
3957
  }
3943
- // Step 2. Organize nodes into tree
3944
- var roots = [];
3945
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
3958
+ sortChunkNodes(roots, inputOrder);
3959
+ return roots;
3960
+ }
3961
+ function getChunkNodeId(document) {
3962
+ var _document_metadata;
3963
+ if ((_document_metadata = document.metadata) === null || _document_metadata === void 0 ? void 0 : _document_metadata.chunkId) {
3964
+ return document.metadata.chunkId;
3965
+ }
3966
+ if ("id" in document && typeof document.id === "string" && document.id) {
3967
+ return document.id;
3968
+ }
3969
+ return undefined;
3970
+ }
3971
+ function sortChunkNodes(nodes, inputOrder) {
3972
+ // Sort every sibling group, including nested children, so the rendered tree matches document flow.
3973
+ nodes.sort(function(left, right) {
3974
+ return compareChunkNodes(left, right, inputOrder);
3975
+ });
3976
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3946
3977
  try {
3947
- for(var _iterator1 = map.values()[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
3948
- var doc1 = _step1.value;
3949
- var parentId = doc1.metadata.parentId;
3950
- if (parentId && map.has(parentId)) {
3951
- var parent = map.get(parentId);
3952
- parent.metadata.children = parent.metadata.children || [];
3953
- parent.metadata.children.push(doc1);
3954
- } else {
3955
- roots.push(doc1);
3978
+ for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3979
+ var node = _step.value;
3980
+ var _node_metadata_children;
3981
+ if ((_node_metadata_children = node.metadata.children) === null || _node_metadata_children === void 0 ? void 0 : _node_metadata_children.length) {
3982
+ sortChunkNodes(node.metadata.children, inputOrder);
3956
3983
  }
3957
3984
  }
3958
3985
  } catch (err) {
3959
- _didIteratorError1 = true;
3960
- _iteratorError1 = err;
3986
+ _didIteratorError = true;
3987
+ _iteratorError = err;
3961
3988
  } finally{
3962
3989
  try {
3963
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
3964
- _iterator1.return();
3990
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3991
+ _iterator.return();
3965
3992
  }
3966
3993
  } finally{
3967
- if (_didIteratorError1) {
3968
- throw _iteratorError1;
3994
+ if (_didIteratorError) {
3995
+ throw _iteratorError;
3969
3996
  }
3970
3997
  }
3971
3998
  }
3972
- return roots;
3973
3999
  }
3974
- function getChunkNodeId(document) {
3975
- var _document_metadata;
3976
- if ((_document_metadata = document.metadata) === null || _document_metadata === void 0 ? void 0 : _document_metadata.chunkId) {
3977
- return document.metadata.chunkId;
4000
+ function compareChunkNodes(left, right, inputOrder) {
4001
+ // chunkIndex is the canonical document-order signal; input order is only a fallback.
4002
+ var leftIndex = getFiniteNumber(left.metadata.chunkIndex);
4003
+ var rightIndex = getFiniteNumber(right.metadata.chunkIndex);
4004
+ if (leftIndex !== undefined && rightIndex !== undefined && leftIndex !== rightIndex) {
4005
+ return leftIndex - rightIndex;
3978
4006
  }
3979
- if ("id" in document && typeof document.id === "string" && document.id) {
3980
- return document.id;
4007
+ if (leftIndex !== undefined || rightIndex !== undefined) {
4008
+ return leftIndex !== undefined ? -1 : 1;
3981
4009
  }
3982
- return undefined;
4010
+ var _inputOrder_get;
4011
+ var leftOrder = (_inputOrder_get = inputOrder.get(left.metadata.chunkId)) !== null && _inputOrder_get !== void 0 ? _inputOrder_get : 0;
4012
+ var _inputOrder_get1;
4013
+ var rightOrder = (_inputOrder_get1 = inputOrder.get(right.metadata.chunkId)) !== null && _inputOrder_get1 !== void 0 ? _inputOrder_get1 : 0;
4014
+ return leftOrder - rightOrder;
4015
+ }
4016
+ function getFiniteNumber(value) {
4017
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
3983
4018
  }
3984
4019
  /**
3985
4020
  * Find all leaf nodes (nodes without children).
package/index.esm.js CHANGED
@@ -3854,7 +3854,7 @@ var MCP_APP_RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
3854
3854
 
3855
3855
  /**
3856
3856
  * Build a hierarchical tree structure from a flat list of DocumentInterface objects,
3857
- * and
3857
+ * preserving explicit chunkIndex order whenever it is available.
3858
3858
  *
3859
3859
  * @template Metadata - Type of metadata, defaults to IDocChunkMetadata
3860
3860
  * @param documents - A flat array of DocumentInterface objects
@@ -3910,18 +3910,33 @@ function buildChunkTree(documents) {
3910
3910
  if (!documents || documents.length === 0) return [];
3911
3911
  // Step 1. Build a lookup map for quick access by chunkId
3912
3912
  var map = new Map();
3913
+ // Keep the original retrieval/insertion order as a deterministic fallback.
3914
+ var inputOrder = new Map();
3915
+ documents.forEach(function(doc, index) {
3916
+ var chunkId = getChunkNodeId(doc);
3917
+ if (chunkId) {
3918
+ map.set(chunkId, _object_spread_props$2(_object_spread$2({}, doc), {
3919
+ metadata: _object_spread_props$2(_object_spread$2({}, doc.metadata), {
3920
+ chunkId: chunkId,
3921
+ children: []
3922
+ })
3923
+ }));
3924
+ inputOrder.set(chunkId, index);
3925
+ }
3926
+ });
3927
+ // Step 2. Organize nodes into tree
3928
+ var roots = [];
3913
3929
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3914
3930
  try {
3915
- for(var _iterator = documents[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3931
+ for(var _iterator = map.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3916
3932
  var doc = _step.value;
3917
- var chunkId = getChunkNodeId(doc);
3918
- if (chunkId) {
3919
- map.set(chunkId, _object_spread_props$2(_object_spread$2({}, doc), {
3920
- metadata: _object_spread_props$2(_object_spread$2({}, doc.metadata), {
3921
- chunkId: chunkId,
3922
- children: []
3923
- })
3924
- }));
3933
+ var parentId = doc.metadata.parentId;
3934
+ if (parentId && map.has(parentId)) {
3935
+ var parent = map.get(parentId);
3936
+ parent.metadata.children = parent.metadata.children || [];
3937
+ parent.metadata.children.push(doc);
3938
+ } else {
3939
+ roots.push(doc);
3925
3940
  }
3926
3941
  }
3927
3942
  } catch (err) {
@@ -3938,46 +3953,66 @@ function buildChunkTree(documents) {
3938
3953
  }
3939
3954
  }
3940
3955
  }
3941
- // Step 2. Organize nodes into tree
3942
- var roots = [];
3943
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
3956
+ sortChunkNodes(roots, inputOrder);
3957
+ return roots;
3958
+ }
3959
+ function getChunkNodeId(document) {
3960
+ var _document_metadata;
3961
+ if ((_document_metadata = document.metadata) === null || _document_metadata === void 0 ? void 0 : _document_metadata.chunkId) {
3962
+ return document.metadata.chunkId;
3963
+ }
3964
+ if ("id" in document && typeof document.id === "string" && document.id) {
3965
+ return document.id;
3966
+ }
3967
+ return undefined;
3968
+ }
3969
+ function sortChunkNodes(nodes, inputOrder) {
3970
+ // Sort every sibling group, including nested children, so the rendered tree matches document flow.
3971
+ nodes.sort(function(left, right) {
3972
+ return compareChunkNodes(left, right, inputOrder);
3973
+ });
3974
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3944
3975
  try {
3945
- for(var _iterator1 = map.values()[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
3946
- var doc1 = _step1.value;
3947
- var parentId = doc1.metadata.parentId;
3948
- if (parentId && map.has(parentId)) {
3949
- var parent = map.get(parentId);
3950
- parent.metadata.children = parent.metadata.children || [];
3951
- parent.metadata.children.push(doc1);
3952
- } else {
3953
- roots.push(doc1);
3976
+ for(var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3977
+ var node = _step.value;
3978
+ var _node_metadata_children;
3979
+ if ((_node_metadata_children = node.metadata.children) === null || _node_metadata_children === void 0 ? void 0 : _node_metadata_children.length) {
3980
+ sortChunkNodes(node.metadata.children, inputOrder);
3954
3981
  }
3955
3982
  }
3956
3983
  } catch (err) {
3957
- _didIteratorError1 = true;
3958
- _iteratorError1 = err;
3984
+ _didIteratorError = true;
3985
+ _iteratorError = err;
3959
3986
  } finally{
3960
3987
  try {
3961
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
3962
- _iterator1.return();
3988
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3989
+ _iterator.return();
3963
3990
  }
3964
3991
  } finally{
3965
- if (_didIteratorError1) {
3966
- throw _iteratorError1;
3992
+ if (_didIteratorError) {
3993
+ throw _iteratorError;
3967
3994
  }
3968
3995
  }
3969
3996
  }
3970
- return roots;
3971
3997
  }
3972
- function getChunkNodeId(document) {
3973
- var _document_metadata;
3974
- if ((_document_metadata = document.metadata) === null || _document_metadata === void 0 ? void 0 : _document_metadata.chunkId) {
3975
- return document.metadata.chunkId;
3998
+ function compareChunkNodes(left, right, inputOrder) {
3999
+ // chunkIndex is the canonical document-order signal; input order is only a fallback.
4000
+ var leftIndex = getFiniteNumber(left.metadata.chunkIndex);
4001
+ var rightIndex = getFiniteNumber(right.metadata.chunkIndex);
4002
+ if (leftIndex !== undefined && rightIndex !== undefined && leftIndex !== rightIndex) {
4003
+ return leftIndex - rightIndex;
3976
4004
  }
3977
- if ("id" in document && typeof document.id === "string" && document.id) {
3978
- return document.id;
4005
+ if (leftIndex !== undefined || rightIndex !== undefined) {
4006
+ return leftIndex !== undefined ? -1 : 1;
3979
4007
  }
3980
- return undefined;
4008
+ var _inputOrder_get;
4009
+ var leftOrder = (_inputOrder_get = inputOrder.get(left.metadata.chunkId)) !== null && _inputOrder_get !== void 0 ? _inputOrder_get : 0;
4010
+ var _inputOrder_get1;
4011
+ var rightOrder = (_inputOrder_get1 = inputOrder.get(right.metadata.chunkId)) !== null && _inputOrder_get1 !== void 0 ? _inputOrder_get1 : 0;
4012
+ return leftOrder - rightOrder;
4013
+ }
4014
+ function getFiniteNumber(value) {
4015
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
3981
4016
  }
3982
4017
  /**
3983
4018
  * Find all leaf nodes (nodes without children).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/contracts",
3
- "version": "3.15.5",
3
+ "version": "3.15.7",
4
4
  "license": "AGPL-3.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,10 @@
19
19
  "module": "./index.esm.js",
20
20
  "main": "./index.cjs.js",
21
21
  "dependencies": {
22
- "@xpert-ai/chatkit-types": "~0.4.5"
22
+ "@octokit/types": "13.10.0",
23
+ "@types/json-schema": "^7.0.15",
24
+ "@xpert-ai/chatkit-types": "~0.4.5",
25
+ "zod-to-json-schema": "^3.25.2"
23
26
  },
24
27
  "types": "./index.d.ts"
25
28
  }
@@ -6,6 +6,10 @@ export type TDocumentAsset = {
6
6
  type: 'image' | 'video' | 'audio' | 'file';
7
7
  url: string;
8
8
  filePath: string;
9
+ sourceType?: 'pdf_page' | 'docx_embedded_image' | 'image_file';
10
+ page?: number;
11
+ order?: number;
12
+ altText?: string;
9
13
  };
10
14
  export interface IDocChunkMetadata {
11
15
  chunkId: string;
@@ -47,7 +51,7 @@ export interface IKnowledgeDocumentChunk<Metadata extends IDocChunkMetadata = an
47
51
  }
48
52
  /**
49
53
  * Build a hierarchical tree structure from a flat list of DocumentInterface objects,
50
- * and
54
+ * preserving explicit chunkIndex order whenever it is available.
51
55
  *
52
56
  * @template Metadata - Type of metadata, defaults to IDocChunkMetadata
53
57
  * @param documents - A flat array of DocumentInterface objects
@@ -1,4 +1,4 @@
1
- import { IBasePerTenantEntityModel } from '../base-entity.model';
1
+ import { IBasePerTenantAndOrganizationEntityModel, IBasePerTenantEntityModel } from '../base-entity.model';
2
2
  import { IUser } from '../user.model';
3
3
  export declare enum MembershipPlanStatusEnum {
4
4
  Active = "active",
@@ -31,21 +31,21 @@ export interface IMembershipRateLimit {
31
31
  period: TMembershipRateLimitPeriod;
32
32
  pointLimit: number;
33
33
  }
34
- export interface IMembershipPlan extends IBasePerTenantEntityModel {
34
+ export interface IMembershipPlan extends IBasePerTenantAndOrganizationEntityModel {
35
35
  code: string;
36
36
  name: string;
37
37
  description?: string | null;
38
38
  status: MembershipPlanStatusEnum;
39
39
  isDefault?: boolean;
40
40
  period: MembershipPeriodEnum;
41
- includedPoints: number;
41
+ includedPoints: number | null;
42
42
  tokensPerPoint: number;
43
43
  priceAmount?: number | null;
44
44
  priceCurrency?: string | null;
45
45
  modelMultipliers?: IMembershipModelMultiplier[];
46
46
  rateLimits?: IMembershipRateLimit[];
47
47
  }
48
- export interface IUserMembership extends IBasePerTenantEntityModel {
48
+ export interface IUserMembership extends IBasePerTenantAndOrganizationEntityModel {
49
49
  userId: string;
50
50
  user?: IUser;
51
51
  planId: string;
@@ -53,7 +53,7 @@ export interface IUserMembership extends IBasePerTenantEntityModel {
53
53
  status: MembershipStatusEnum;
54
54
  currentPeriodStart: Date;
55
55
  currentPeriodEnd: Date;
56
- pointsGranted: number;
56
+ pointsGranted: number | null;
57
57
  pointsUsed: number;
58
58
  pointsTotalUsed: number;
59
59
  assignedById?: string | null;
@@ -82,13 +82,26 @@ export interface IMembershipPointLedger extends IBasePerTenantEntityModel {
82
82
  export interface IMembershipMe {
83
83
  membership: IUserMembership;
84
84
  plan: IMembershipPlan;
85
- pointsGranted: number;
85
+ pointsGranted: number | null;
86
86
  pointsUsed: number;
87
- pointsRemaining: number;
87
+ pointsRemaining: number | null;
88
88
  pointsTotalUsed: number;
89
89
  currentPeriodStart: Date;
90
90
  currentPeriodEnd: Date;
91
91
  }
92
+ export interface IMembershipScopeStatus {
93
+ tenantId: string;
94
+ organizationId?: string | null;
95
+ scope: 'tenant' | 'organization';
96
+ planCount: number;
97
+ activePlanCount: number;
98
+ defaultPlan?: IMembershipPlan | null;
99
+ initialized: boolean;
100
+ needsRepair: boolean;
101
+ activeMemberCount?: number | null;
102
+ assignedMemberCount?: number | null;
103
+ localCopilotCount?: number | null;
104
+ }
92
105
  export interface IMembershipUsageBucket {
93
106
  date: string;
94
107
  pointsUsed: number;
@@ -29,6 +29,7 @@ export type TXpertWorkspaceSettings = {
29
29
  };
30
30
  export type TXpertWorkspaceStatus = 'active' | 'deprecated' | 'archived';
31
31
  export type TXpertWorkspaceVisibility = 'private' | 'tenant-shared';
32
+ export type TXpertWorkspaceAccessPurpose = 'runtime' | 'authoring';
32
33
  export type TXpertWorkspaceCapabilities = {
33
34
  canRead: boolean;
34
35
  canRun: boolean;
package/src/plugin.d.ts CHANGED
@@ -131,6 +131,11 @@ export interface XpertPluginMcpServerPolicy {
131
131
  export interface XpertPluginBundleManifest {
132
132
  name: string;
133
133
  version?: string;
134
+ /**
135
+ * Stable namespace claimed by bundle artifacts before install.
136
+ * Marketplace indexing uses this value to display and review artifact ownership.
137
+ */
138
+ artifactNamespace?: string;
134
139
  description?: string;
135
140
  author?: string;
136
141
  homepage?: string;
@@ -257,6 +262,11 @@ export interface PluginSourceConfig extends PluginCodeSourceConfig {
257
262
  export interface PluginMeta {
258
263
  name: PluginName;
259
264
  version: string;
265
+ /**
266
+ * Stable namespace used for plugin-owned artifacts such as database tables.
267
+ * Table artifacts must use names like `plugin_<artifactNamespace>_<tableKey>`.
268
+ */
269
+ artifactNamespace?: string;
260
270
  /**
261
271
  * Declares the plugin's operational level used for visibility and install/uninstall guardrails.
262
272
  */
@@ -319,6 +329,11 @@ export interface PluginMarketplaceRegistryItem {
319
329
  id: string;
320
330
  packageName: string;
321
331
  version?: string | null;
332
+ /**
333
+ * Optional artifact namespace declared by the registry for plugins that are not installed yet.
334
+ * When omitted, marketplace views may derive a default from the package name.
335
+ */
336
+ artifactNamespace?: string | null;
322
337
  displayName: string;
323
338
  description: string;
324
339
  category: string;
@@ -343,6 +358,11 @@ export type PluginMarketplaceRegistryItemResponse = PluginMarketplaceRegistryIte
343
358
  export interface PluginMarketplaceRegistryItemInput {
344
359
  packageName?: string;
345
360
  version?: string | null;
361
+ /**
362
+ * Explicit artifact namespace used during manual marketplace registration or review.
363
+ * Keep it aligned with the plugin manifest/meta when the plugin declares one.
364
+ */
365
+ artifactNamespace?: string | null;
346
366
  displayName?: string;
347
367
  description?: string;
348
368
  category?: string;
@@ -388,6 +408,11 @@ export interface PluginMarketplaceItem {
388
408
  displayName?: I18nObject | string;
389
409
  description?: I18nObject | string;
390
410
  version?: string | null;
411
+ /**
412
+ * Namespace shown to users/reviewers for plugin-owned artifacts such as tables.
413
+ * This may come from registry data, bundle manifest, runtime meta, or package-name derivation.
414
+ */
415
+ artifactNamespace?: string | null;
391
416
  level?: PluginLevel;
392
417
  deprecated?: boolean;
393
418
  deprecationMessage?: I18nObject | string | null;