@utaba/deep-memory-storage-sqlserver 0.16.0 → 0.17.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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _utaba_deep_memory_types from '@utaba/deep-memory/types';
2
2
  import { UsageSink, StorageRepositoryConfig, StoredRepository, RepositoryFilter, PaginatedResult, StoredRepositorySummary, RepositoryUpdate, RepositoryStats, MemoryVocabulary, PaginationOptions, VocabularyChangeRecord, StoredEntity, StoredEntityUpdate, StorageFindQuery, StoredRelationship, RelationshipQueryOptions, StorageExploreOptions, StorageNeighborhood, StoragePathOptions, StoragePathResult, StorageTimelineOptions, StorageTimelineResult, ExportChunk, ImportChunk, BulkImportResult, SearchOptions, SearchHit } from '@utaba/deep-memory/types';
3
3
  import sql from 'mssql';
4
- import { StorageProvider, EnsureSchemaResult, SearchProvider, SearchableEntity } from '@utaba/deep-memory/providers';
4
+ import { StorageProvider, EnsureSchemaResult, EntityReadOptions, SearchProvider, SearchableEntity } from '@utaba/deep-memory/providers';
5
5
 
6
6
  /** Configuration for SqlServerStorageProvider */
7
7
  interface SqlServerStorageProviderConfig {
@@ -49,9 +49,9 @@ declare class SqlServerStorageProvider implements StorageProvider {
49
49
  saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
50
50
  getVocabularyChangeLog(repositoryId: string, options?: PaginationOptions): Promise<PaginatedResult<VocabularyChangeRecord>>;
51
51
  createEntity(repositoryId: string, entity: StoredEntity): Promise<StoredEntity>;
52
- getEntity(repositoryId: string, entityId: string): Promise<StoredEntity | null>;
53
- getEntityBySlug(repositoryId: string, slug: string): Promise<StoredEntity | null>;
54
- getEntities(repositoryId: string, entityIds: string[]): Promise<Map<string, StoredEntity>>;
52
+ getEntity(repositoryId: string, entityId: string, options?: EntityReadOptions): Promise<StoredEntity | null>;
53
+ getEntityBySlug(repositoryId: string, slug: string, options?: EntityReadOptions): Promise<StoredEntity | null>;
54
+ getEntities(repositoryId: string, entityIds: string[], options?: EntityReadOptions): Promise<Map<string, StoredEntity>>;
55
55
  updateEntity(repositoryId: string, entityId: string, updates: StoredEntityUpdate): Promise<StoredEntity>;
56
56
  deleteEntity(repositoryId: string, entityId: string): Promise<void>;
57
57
  deleteEntities(repositoryId: string, ids: string[]): Promise<{
@@ -62,7 +62,7 @@ declare class SqlServerStorageProvider implements StorageProvider {
62
62
  deletedEntities: number;
63
63
  deletedRelationships: number;
64
64
  }>;
65
- findEntities(repositoryId: string, query: StorageFindQuery): Promise<PaginatedResult<StoredEntity>>;
65
+ findEntities(repositoryId: string, query: StorageFindQuery, options?: EntityReadOptions): Promise<PaginatedResult<StoredEntity>>;
66
66
  createRelationship(repositoryId: string, relationship: StoredRelationship): Promise<StoredRelationship>;
67
67
  getRelationship(repositoryId: string, relationshipId: string): Promise<StoredRelationship | null>;
68
68
  getEntityRelationships(repositoryId: string, entityId: string, options?: RelationshipQueryOptions): Promise<PaginatedResult<StoredRelationship>>;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _utaba_deep_memory_types from '@utaba/deep-memory/types';
2
2
  import { UsageSink, StorageRepositoryConfig, StoredRepository, RepositoryFilter, PaginatedResult, StoredRepositorySummary, RepositoryUpdate, RepositoryStats, MemoryVocabulary, PaginationOptions, VocabularyChangeRecord, StoredEntity, StoredEntityUpdate, StorageFindQuery, StoredRelationship, RelationshipQueryOptions, StorageExploreOptions, StorageNeighborhood, StoragePathOptions, StoragePathResult, StorageTimelineOptions, StorageTimelineResult, ExportChunk, ImportChunk, BulkImportResult, SearchOptions, SearchHit } from '@utaba/deep-memory/types';
3
3
  import sql from 'mssql';
4
- import { StorageProvider, EnsureSchemaResult, SearchProvider, SearchableEntity } from '@utaba/deep-memory/providers';
4
+ import { StorageProvider, EnsureSchemaResult, EntityReadOptions, SearchProvider, SearchableEntity } from '@utaba/deep-memory/providers';
5
5
 
6
6
  /** Configuration for SqlServerStorageProvider */
7
7
  interface SqlServerStorageProviderConfig {
@@ -49,9 +49,9 @@ declare class SqlServerStorageProvider implements StorageProvider {
49
49
  saveVocabulary(repositoryId: string, vocabulary: MemoryVocabulary): Promise<void>;
50
50
  getVocabularyChangeLog(repositoryId: string, options?: PaginationOptions): Promise<PaginatedResult<VocabularyChangeRecord>>;
51
51
  createEntity(repositoryId: string, entity: StoredEntity): Promise<StoredEntity>;
52
- getEntity(repositoryId: string, entityId: string): Promise<StoredEntity | null>;
53
- getEntityBySlug(repositoryId: string, slug: string): Promise<StoredEntity | null>;
54
- getEntities(repositoryId: string, entityIds: string[]): Promise<Map<string, StoredEntity>>;
52
+ getEntity(repositoryId: string, entityId: string, options?: EntityReadOptions): Promise<StoredEntity | null>;
53
+ getEntityBySlug(repositoryId: string, slug: string, options?: EntityReadOptions): Promise<StoredEntity | null>;
54
+ getEntities(repositoryId: string, entityIds: string[], options?: EntityReadOptions): Promise<Map<string, StoredEntity>>;
55
55
  updateEntity(repositoryId: string, entityId: string, updates: StoredEntityUpdate): Promise<StoredEntity>;
56
56
  deleteEntity(repositoryId: string, entityId: string): Promise<void>;
57
57
  deleteEntities(repositoryId: string, ids: string[]): Promise<{
@@ -62,7 +62,7 @@ declare class SqlServerStorageProvider implements StorageProvider {
62
62
  deletedEntities: number;
63
63
  deletedRelationships: number;
64
64
  }>;
65
- findEntities(repositoryId: string, query: StorageFindQuery): Promise<PaginatedResult<StoredEntity>>;
65
+ findEntities(repositoryId: string, query: StorageFindQuery, options?: EntityReadOptions): Promise<PaginatedResult<StoredEntity>>;
66
66
  createRelationship(repositoryId: string, relationship: StoredRelationship): Promise<StoredRelationship>;
67
67
  getRelationship(repositoryId: string, relationshipId: string): Promise<StoredRelationship | null>;
68
68
  getEntityRelationships(repositoryId: string, entityId: string, options?: RelationshipQueryOptions): Promise<PaginatedResult<StoredRelationship>>;
package/dist/index.js CHANGED
@@ -887,33 +887,36 @@ var SqlServerStorageProvider = class {
887
887
  `);
888
888
  return entity;
889
889
  }
890
- async getEntity(repositoryId, entityId) {
890
+ async getEntity(repositoryId, entityId, options) {
891
891
  const pool = this.getPool();
892
+ const cols = options?.loadEmbeddings ? ENTITY_COLS_FULL : ENTITY_COLS_LIGHT;
892
893
  const result = await pool.request().input("repoId", sql.UniqueIdentifier, repositoryId).input("entityId", sql.NVarChar, entityId).query(
893
- `SELECT ${ENTITY_COLS_LIGHT} FROM ${this.t("dm_entities")}
894
+ `SELECT ${cols} FROM ${this.t("dm_entities")}
894
895
  WHERE [repository_id] = @repoId AND [entity_id] = @entityId`
895
896
  );
896
897
  const row = result.recordset[0];
897
898
  if (!row) return null;
898
899
  return entityFromRow(row);
899
900
  }
900
- async getEntityBySlug(repositoryId, slug) {
901
+ async getEntityBySlug(repositoryId, slug, options) {
901
902
  const pool = this.getPool();
903
+ const cols = options?.loadEmbeddings ? ENTITY_COLS_FULL : ENTITY_COLS_LIGHT;
902
904
  const result = await pool.request().input("repoId", sql.UniqueIdentifier, repositoryId).input("slug", sql.NVarChar, slug).query(
903
- `SELECT ${ENTITY_COLS_LIGHT} FROM ${this.t("dm_entities")}
905
+ `SELECT ${cols} FROM ${this.t("dm_entities")}
904
906
  WHERE [repository_id] = @repoId AND [slug] = @slug`
905
907
  );
906
908
  const row = result.recordset[0];
907
909
  if (!row) return null;
908
910
  return entityFromRow(row);
909
911
  }
910
- async getEntities(repositoryId, entityIds) {
912
+ async getEntities(repositoryId, entityIds, options) {
911
913
  const pool = this.getPool();
912
914
  const result = /* @__PURE__ */ new Map();
913
915
  if (entityIds.length === 0) return result;
916
+ const cols = options?.loadEmbeddings ? ENTITY_COLS_FULL : ENTITY_COLS_LIGHT;
914
917
  const tvp = this.createIdListTvp(entityIds);
915
918
  const rows = await pool.request().input("repoId", sql.UniqueIdentifier, repositoryId).input("entityIds", tvp).query(
916
- `SELECT ${ENTITY_COLS_LIGHT} FROM ${this.t("dm_entities")}
919
+ `SELECT ${cols} FROM ${this.t("dm_entities")}
917
920
  WHERE [repository_id] = @repoId
918
921
  AND [entity_id] IN (SELECT [id] FROM @entityIds)`
919
922
  );
@@ -1025,7 +1028,7 @@ var SqlServerStorageProvider = class {
1025
1028
  const deletedEntities = entResult.rowsAffected[0] ?? 0;
1026
1029
  return { deletedEntities, deletedRelationships };
1027
1030
  }
1028
- async findEntities(repositoryId, query) {
1031
+ async findEntities(repositoryId, query, options) {
1029
1032
  const pool = this.getPool();
1030
1033
  const req = pool.request().input("repoId", sql.UniqueIdentifier, repositoryId);
1031
1034
  const conditions = ["[repository_id] = @repoId"];
@@ -1085,8 +1088,9 @@ var SqlServerStorageProvider = class {
1085
1088
  const total = totalResult.recordset[0]?.cnt ?? 0;
1086
1089
  req.input("limit", sql.Int, query.limit);
1087
1090
  req.input("offset", sql.Int, query.offset);
1091
+ const cols = options?.loadEmbeddings ? ENTITY_COLS_FULL : ENTITY_COLS_LIGHT;
1088
1092
  const result = await req.query(
1089
- `SELECT ${ENTITY_COLS_LIGHT} FROM ${this.t("dm_entities")}
1093
+ `SELECT ${cols} FROM ${this.t("dm_entities")}
1090
1094
  WHERE ${where}
1091
1095
  ORDER BY [entity_id]
1092
1096
  OFFSET @offset ROWS FETCH NEXT @limit ROWS ONLY`