@howells/stow-server 2.0.1 → 2.1.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.mts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +82 -3
- package/dist/index.mjs +82 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -453,6 +453,8 @@ interface ConfirmUploadRequest {
|
|
|
453
453
|
}
|
|
454
454
|
/** Input payload for similarity search. */
|
|
455
455
|
interface SimilarSearchRequest {
|
|
456
|
+
/** Use an anchor's embedding as the query vector */
|
|
457
|
+
anchorId?: string;
|
|
456
458
|
/** Bucket name or ID to scope search */
|
|
457
459
|
bucket?: string;
|
|
458
460
|
/** Use a specific cluster centroid instead of the profile master vector. Requires profileId. */
|
|
@@ -476,6 +478,8 @@ interface SimilarSearchRequest {
|
|
|
476
478
|
}
|
|
477
479
|
/** Input payload for diversity-aware search. */
|
|
478
480
|
interface DiverseSearchRequest {
|
|
481
|
+
/** Use an anchor's embedding as the query vector */
|
|
482
|
+
anchorId?: string;
|
|
479
483
|
/** Bucket name or ID to scope search */
|
|
480
484
|
bucket?: string;
|
|
481
485
|
/** Use a specific cluster centroid instead of the profile master vector. Requires profileId. */
|
|
@@ -529,6 +533,32 @@ interface SearchResultItem {
|
|
|
529
533
|
}>;
|
|
530
534
|
width?: number | null;
|
|
531
535
|
}
|
|
536
|
+
/** A text anchor — a named semantic reference point in a bucket's vector space. */
|
|
537
|
+
interface Anchor {
|
|
538
|
+
bucketId: string;
|
|
539
|
+
createdAt: string;
|
|
540
|
+
id: string;
|
|
541
|
+
label: string | null;
|
|
542
|
+
text: string;
|
|
543
|
+
updatedAt: string;
|
|
544
|
+
}
|
|
545
|
+
/** Input for creating an anchor. */
|
|
546
|
+
interface CreateAnchorRequest {
|
|
547
|
+
label?: string;
|
|
548
|
+
text: string;
|
|
549
|
+
}
|
|
550
|
+
/** Input for updating an anchor. */
|
|
551
|
+
interface UpdateAnchorRequest {
|
|
552
|
+
label?: string | null;
|
|
553
|
+
text?: string;
|
|
554
|
+
}
|
|
555
|
+
/** An anchor result returned in search responses. */
|
|
556
|
+
interface AnchorSearchResult {
|
|
557
|
+
id: string;
|
|
558
|
+
label: string | null;
|
|
559
|
+
similarity: number;
|
|
560
|
+
text: string;
|
|
561
|
+
}
|
|
532
562
|
/** Which filter categories were active in the request. */
|
|
533
563
|
interface AppliedFilters {
|
|
534
564
|
color?: string[];
|
|
@@ -547,6 +577,7 @@ interface FilteredMetadata {
|
|
|
547
577
|
}
|
|
548
578
|
/** Result payload returned by similarity/diversity search endpoints. */
|
|
549
579
|
interface SimilarSearchResult {
|
|
580
|
+
anchors?: AnchorSearchResult[];
|
|
550
581
|
filtered?: FilteredMetadata;
|
|
551
582
|
results: SearchResultItem[];
|
|
552
583
|
}
|
|
@@ -964,6 +995,35 @@ declare class StowServer {
|
|
|
964
995
|
private getProfileClusters;
|
|
965
996
|
private reclusterProfile;
|
|
966
997
|
private renameProfileCluster;
|
|
998
|
+
/**
|
|
999
|
+
* Anchors namespace for creating, listing, updating, and deleting text anchors.
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* const anchor = await stow.anchors.create({ text: "minimalist architecture", label: "minimal" });
|
|
1004
|
+
* const results = await stow.search.similar({ anchorId: anchor.id });
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
get anchors(): {
|
|
1008
|
+
create: (params: CreateAnchorRequest) => Promise<Anchor>;
|
|
1009
|
+
list: (options?: {
|
|
1010
|
+
bucket?: string;
|
|
1011
|
+
}) => Promise<{
|
|
1012
|
+
anchors: Anchor[];
|
|
1013
|
+
}>;
|
|
1014
|
+
get: (id: string, options?: {
|
|
1015
|
+
bucket?: string;
|
|
1016
|
+
}) => Promise<Anchor>;
|
|
1017
|
+
update: (id: string, params: UpdateAnchorRequest) => Promise<Anchor>;
|
|
1018
|
+
delete: (id: string, options?: {
|
|
1019
|
+
bucket?: string;
|
|
1020
|
+
}) => Promise<void>;
|
|
1021
|
+
};
|
|
1022
|
+
private createAnchor;
|
|
1023
|
+
private listAnchors;
|
|
1024
|
+
private getAnchor;
|
|
1025
|
+
private updateAnchor;
|
|
1026
|
+
private deleteAnchor;
|
|
967
1027
|
}
|
|
968
1028
|
|
|
969
|
-
export { type AppliedFilters, type BucketResult, type ColorSearchRequest, type ColorSearchResult, type ColorSearchResultItem, type ConfirmUploadRequest, type CreateBucketRequest, type DeleteProfileSignalsResult, type DiverseSearchRequest, type Drop, type DropResult, type FileColor, type FileColorProfile, type FileIncludeField, type FileResult, type FileTag, type FileTaxonomy, type FilteredMetadata, type ListBucketsResult, type ListDropsResult, type ListFilesItem, type ListFilesResult, type PresignDedupeResult, type PresignNewResult, type PresignRequest, type PresignResult, type ProfileClusterResult, type ProfileCreateRequest, type ProfileFilesResult, type ProfileResult, type ProfileSignalInput, type ProfileSignalResult, type ProfileSignalType, type ProfileSignalsResponse, type QueuedResult, type ReclusterRequest, type ReclusterResult, type RenameClusterRequest, type ReplaceResult, type SearchFilters, type SearchIncludeField, type SearchResultItem, type SimilarSearchRequest, type SimilarSearchResult, StowError, StowServer, type StowServerConfig, type TaskTriggerResult, type TaxonomyGroup, type TaxonomyListResult, type TaxonomyTerm, type TextSearchRequest, type TransformOptions, type UpdateBucketRequest, type UploadResult, type WhoamiResult };
|
|
1029
|
+
export { type Anchor, type AnchorSearchResult, type AppliedFilters, type BucketResult, type ColorSearchRequest, type ColorSearchResult, type ColorSearchResultItem, type ConfirmUploadRequest, type CreateAnchorRequest, type CreateBucketRequest, type DeleteProfileSignalsResult, type DiverseSearchRequest, type Drop, type DropResult, type FileColor, type FileColorProfile, type FileIncludeField, type FileResult, type FileTag, type FileTaxonomy, type FilteredMetadata, type ListBucketsResult, type ListDropsResult, type ListFilesItem, type ListFilesResult, type PresignDedupeResult, type PresignNewResult, type PresignRequest, type PresignResult, type ProfileClusterResult, type ProfileCreateRequest, type ProfileFilesResult, type ProfileResult, type ProfileSignalInput, type ProfileSignalResult, type ProfileSignalType, type ProfileSignalsResponse, type QueuedResult, type ReclusterRequest, type ReclusterResult, type RenameClusterRequest, type ReplaceResult, type SearchFilters, type SearchIncludeField, type SearchResultItem, type SimilarSearchRequest, type SimilarSearchResult, StowError, StowServer, type StowServerConfig, type TaskTriggerResult, type TaxonomyGroup, type TaxonomyListResult, type TaxonomyTerm, type TextSearchRequest, type TransformOptions, type UpdateAnchorRequest, type UpdateBucketRequest, type UploadResult, type WhoamiResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -453,6 +453,8 @@ interface ConfirmUploadRequest {
|
|
|
453
453
|
}
|
|
454
454
|
/** Input payload for similarity search. */
|
|
455
455
|
interface SimilarSearchRequest {
|
|
456
|
+
/** Use an anchor's embedding as the query vector */
|
|
457
|
+
anchorId?: string;
|
|
456
458
|
/** Bucket name or ID to scope search */
|
|
457
459
|
bucket?: string;
|
|
458
460
|
/** Use a specific cluster centroid instead of the profile master vector. Requires profileId. */
|
|
@@ -476,6 +478,8 @@ interface SimilarSearchRequest {
|
|
|
476
478
|
}
|
|
477
479
|
/** Input payload for diversity-aware search. */
|
|
478
480
|
interface DiverseSearchRequest {
|
|
481
|
+
/** Use an anchor's embedding as the query vector */
|
|
482
|
+
anchorId?: string;
|
|
479
483
|
/** Bucket name or ID to scope search */
|
|
480
484
|
bucket?: string;
|
|
481
485
|
/** Use a specific cluster centroid instead of the profile master vector. Requires profileId. */
|
|
@@ -529,6 +533,32 @@ interface SearchResultItem {
|
|
|
529
533
|
}>;
|
|
530
534
|
width?: number | null;
|
|
531
535
|
}
|
|
536
|
+
/** A text anchor — a named semantic reference point in a bucket's vector space. */
|
|
537
|
+
interface Anchor {
|
|
538
|
+
bucketId: string;
|
|
539
|
+
createdAt: string;
|
|
540
|
+
id: string;
|
|
541
|
+
label: string | null;
|
|
542
|
+
text: string;
|
|
543
|
+
updatedAt: string;
|
|
544
|
+
}
|
|
545
|
+
/** Input for creating an anchor. */
|
|
546
|
+
interface CreateAnchorRequest {
|
|
547
|
+
label?: string;
|
|
548
|
+
text: string;
|
|
549
|
+
}
|
|
550
|
+
/** Input for updating an anchor. */
|
|
551
|
+
interface UpdateAnchorRequest {
|
|
552
|
+
label?: string | null;
|
|
553
|
+
text?: string;
|
|
554
|
+
}
|
|
555
|
+
/** An anchor result returned in search responses. */
|
|
556
|
+
interface AnchorSearchResult {
|
|
557
|
+
id: string;
|
|
558
|
+
label: string | null;
|
|
559
|
+
similarity: number;
|
|
560
|
+
text: string;
|
|
561
|
+
}
|
|
532
562
|
/** Which filter categories were active in the request. */
|
|
533
563
|
interface AppliedFilters {
|
|
534
564
|
color?: string[];
|
|
@@ -547,6 +577,7 @@ interface FilteredMetadata {
|
|
|
547
577
|
}
|
|
548
578
|
/** Result payload returned by similarity/diversity search endpoints. */
|
|
549
579
|
interface SimilarSearchResult {
|
|
580
|
+
anchors?: AnchorSearchResult[];
|
|
550
581
|
filtered?: FilteredMetadata;
|
|
551
582
|
results: SearchResultItem[];
|
|
552
583
|
}
|
|
@@ -964,6 +995,35 @@ declare class StowServer {
|
|
|
964
995
|
private getProfileClusters;
|
|
965
996
|
private reclusterProfile;
|
|
966
997
|
private renameProfileCluster;
|
|
998
|
+
/**
|
|
999
|
+
* Anchors namespace for creating, listing, updating, and deleting text anchors.
|
|
1000
|
+
*
|
|
1001
|
+
* @example
|
|
1002
|
+
* ```typescript
|
|
1003
|
+
* const anchor = await stow.anchors.create({ text: "minimalist architecture", label: "minimal" });
|
|
1004
|
+
* const results = await stow.search.similar({ anchorId: anchor.id });
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
get anchors(): {
|
|
1008
|
+
create: (params: CreateAnchorRequest) => Promise<Anchor>;
|
|
1009
|
+
list: (options?: {
|
|
1010
|
+
bucket?: string;
|
|
1011
|
+
}) => Promise<{
|
|
1012
|
+
anchors: Anchor[];
|
|
1013
|
+
}>;
|
|
1014
|
+
get: (id: string, options?: {
|
|
1015
|
+
bucket?: string;
|
|
1016
|
+
}) => Promise<Anchor>;
|
|
1017
|
+
update: (id: string, params: UpdateAnchorRequest) => Promise<Anchor>;
|
|
1018
|
+
delete: (id: string, options?: {
|
|
1019
|
+
bucket?: string;
|
|
1020
|
+
}) => Promise<void>;
|
|
1021
|
+
};
|
|
1022
|
+
private createAnchor;
|
|
1023
|
+
private listAnchors;
|
|
1024
|
+
private getAnchor;
|
|
1025
|
+
private updateAnchor;
|
|
1026
|
+
private deleteAnchor;
|
|
967
1027
|
}
|
|
968
1028
|
|
|
969
|
-
export { type AppliedFilters, type BucketResult, type ColorSearchRequest, type ColorSearchResult, type ColorSearchResultItem, type ConfirmUploadRequest, type CreateBucketRequest, type DeleteProfileSignalsResult, type DiverseSearchRequest, type Drop, type DropResult, type FileColor, type FileColorProfile, type FileIncludeField, type FileResult, type FileTag, type FileTaxonomy, type FilteredMetadata, type ListBucketsResult, type ListDropsResult, type ListFilesItem, type ListFilesResult, type PresignDedupeResult, type PresignNewResult, type PresignRequest, type PresignResult, type ProfileClusterResult, type ProfileCreateRequest, type ProfileFilesResult, type ProfileResult, type ProfileSignalInput, type ProfileSignalResult, type ProfileSignalType, type ProfileSignalsResponse, type QueuedResult, type ReclusterRequest, type ReclusterResult, type RenameClusterRequest, type ReplaceResult, type SearchFilters, type SearchIncludeField, type SearchResultItem, type SimilarSearchRequest, type SimilarSearchResult, StowError, StowServer, type StowServerConfig, type TaskTriggerResult, type TaxonomyGroup, type TaxonomyListResult, type TaxonomyTerm, type TextSearchRequest, type TransformOptions, type UpdateBucketRequest, type UploadResult, type WhoamiResult };
|
|
1029
|
+
export { type Anchor, type AnchorSearchResult, type AppliedFilters, type BucketResult, type ColorSearchRequest, type ColorSearchResult, type ColorSearchResultItem, type ConfirmUploadRequest, type CreateAnchorRequest, type CreateBucketRequest, type DeleteProfileSignalsResult, type DiverseSearchRequest, type Drop, type DropResult, type FileColor, type FileColorProfile, type FileIncludeField, type FileResult, type FileTag, type FileTaxonomy, type FilteredMetadata, type ListBucketsResult, type ListDropsResult, type ListFilesItem, type ListFilesResult, type PresignDedupeResult, type PresignNewResult, type PresignRequest, type PresignResult, type ProfileClusterResult, type ProfileCreateRequest, type ProfileFilesResult, type ProfileResult, type ProfileSignalInput, type ProfileSignalResult, type ProfileSignalType, type ProfileSignalsResponse, type QueuedResult, type ReclusterRequest, type ReclusterResult, type RenameClusterRequest, type ReplaceResult, type SearchFilters, type SearchIncludeField, type SearchResultItem, type SimilarSearchRequest, type SimilarSearchResult, StowError, StowServer, type StowServerConfig, type TaskTriggerResult, type TaxonomyGroup, type TaxonomyListResult, type TaxonomyTerm, type TextSearchRequest, type TransformOptions, type UpdateAnchorRequest, type UpdateBucketRequest, type UploadResult, type WhoamiResult };
|
package/dist/index.js
CHANGED
|
@@ -285,6 +285,17 @@ var deleteProfileSignalsResponseSchema = import_zod.z.object({
|
|
|
285
285
|
totalSignals: import_zod.z.number(),
|
|
286
286
|
vectorUpdated: import_zod.z.boolean()
|
|
287
287
|
});
|
|
288
|
+
var anchorResponseSchema = import_zod.z.object({
|
|
289
|
+
id: import_zod.z.string(),
|
|
290
|
+
bucketId: import_zod.z.string(),
|
|
291
|
+
label: import_zod.z.string().nullable(),
|
|
292
|
+
text: import_zod.z.string(),
|
|
293
|
+
createdAt: import_zod.z.string(),
|
|
294
|
+
updatedAt: import_zod.z.string()
|
|
295
|
+
});
|
|
296
|
+
var anchorListResponseSchema = import_zod.z.object({
|
|
297
|
+
anchors: import_zod.z.array(anchorResponseSchema)
|
|
298
|
+
});
|
|
288
299
|
var StowServer = class {
|
|
289
300
|
apiKey;
|
|
290
301
|
baseUrl;
|
|
@@ -949,6 +960,7 @@ var StowServer = class {
|
|
|
949
960
|
method: "POST",
|
|
950
961
|
headers: { "Content-Type": "application/json" },
|
|
951
962
|
body: JSON.stringify({
|
|
963
|
+
...params.anchorId ? { anchorId: params.anchorId } : {},
|
|
952
964
|
...params.fileKey ? { fileKey: params.fileKey } : {},
|
|
953
965
|
...params.vector ? { vector: params.vector } : {},
|
|
954
966
|
...params.profileId ? { profileId: params.profileId } : {},
|
|
@@ -968,6 +980,7 @@ var StowServer = class {
|
|
|
968
980
|
method: "POST",
|
|
969
981
|
headers: { "Content-Type": "application/json" },
|
|
970
982
|
body: JSON.stringify({
|
|
983
|
+
...params.anchorId ? { anchorId: params.anchorId } : {},
|
|
971
984
|
...params.fileKey ? { fileKey: params.fileKey } : {},
|
|
972
985
|
...params.vector ? { vector: params.vector } : {},
|
|
973
986
|
...params.profileId ? { profileId: params.profileId } : {},
|
|
@@ -975,7 +988,7 @@ var StowServer = class {
|
|
|
975
988
|
...params.clusterIds?.length ? { clusterIds: params.clusterIds } : {},
|
|
976
989
|
...bucket ? { bucket } : {},
|
|
977
990
|
...params.limit ? { limit: params.limit } : {},
|
|
978
|
-
...params.lambda
|
|
991
|
+
...params.lambda === void 0 ? {} : { lambda: params.lambda },
|
|
979
992
|
...params.excludeKeys?.length ? { excludeKeys: params.excludeKeys } : {},
|
|
980
993
|
...params.filters ? { filters: params.filters } : {},
|
|
981
994
|
...params.include?.length ? { include: params.include } : {}
|
|
@@ -1008,7 +1021,7 @@ var StowServer = class {
|
|
|
1008
1021
|
...bucket ? { bucket } : {},
|
|
1009
1022
|
...params.limit ? { limit: params.limit } : {},
|
|
1010
1023
|
...params.excludeKeys?.length ? { excludeKeys: params.excludeKeys } : {},
|
|
1011
|
-
...params.minProportion
|
|
1024
|
+
...params.minProportion === void 0 ? {} : { minProportion: params.minProportion },
|
|
1012
1025
|
...params.dominantOnly ? { dominantOnly: params.dominantOnly } : {}
|
|
1013
1026
|
})
|
|
1014
1027
|
});
|
|
@@ -1184,7 +1197,7 @@ var StowServer = class {
|
|
|
1184
1197
|
method: "POST",
|
|
1185
1198
|
headers: { "Content-Type": "application/json" },
|
|
1186
1199
|
body: JSON.stringify({
|
|
1187
|
-
...params?.clusterCount
|
|
1200
|
+
...params?.clusterCount === void 0 ? {} : { clusterCount: params.clusterCount }
|
|
1188
1201
|
})
|
|
1189
1202
|
}
|
|
1190
1203
|
);
|
|
@@ -1202,6 +1215,72 @@ var StowServer = class {
|
|
|
1202
1215
|
}
|
|
1203
1216
|
);
|
|
1204
1217
|
}
|
|
1218
|
+
// ============================================================
|
|
1219
|
+
// ANCHORS - Named semantic reference points in vector space
|
|
1220
|
+
// ============================================================
|
|
1221
|
+
/**
|
|
1222
|
+
* Anchors namespace for creating, listing, updating, and deleting text anchors.
|
|
1223
|
+
*
|
|
1224
|
+
* @example
|
|
1225
|
+
* ```typescript
|
|
1226
|
+
* const anchor = await stow.anchors.create({ text: "minimalist architecture", label: "minimal" });
|
|
1227
|
+
* const results = await stow.search.similar({ anchorId: anchor.id });
|
|
1228
|
+
* ```
|
|
1229
|
+
*/
|
|
1230
|
+
get anchors() {
|
|
1231
|
+
return {
|
|
1232
|
+
create: (params) => this.createAnchor(params),
|
|
1233
|
+
list: (options) => this.listAnchors(options),
|
|
1234
|
+
get: (id, options) => this.getAnchor(id, options),
|
|
1235
|
+
update: (id, params) => this.updateAnchor(id, params),
|
|
1236
|
+
delete: (id, options) => this.deleteAnchor(id, options)
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
createAnchor(params) {
|
|
1240
|
+
return this.request(
|
|
1241
|
+
this.withBucket("/anchors"),
|
|
1242
|
+
{
|
|
1243
|
+
method: "POST",
|
|
1244
|
+
headers: { "Content-Type": "application/json" },
|
|
1245
|
+
body: JSON.stringify({
|
|
1246
|
+
text: params.text,
|
|
1247
|
+
...params.label ? { label: params.label } : {}
|
|
1248
|
+
})
|
|
1249
|
+
},
|
|
1250
|
+
anchorResponseSchema
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
listAnchors(options) {
|
|
1254
|
+
return this.request(
|
|
1255
|
+
this.withBucket("/anchors", options?.bucket),
|
|
1256
|
+
{ method: "GET" },
|
|
1257
|
+
anchorListResponseSchema
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
getAnchor(id, options) {
|
|
1261
|
+
return this.request(
|
|
1262
|
+
this.withBucket(`/anchors/${encodeURIComponent(id)}`, options?.bucket),
|
|
1263
|
+
{ method: "GET" },
|
|
1264
|
+
anchorResponseSchema
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
updateAnchor(id, params) {
|
|
1268
|
+
return this.request(
|
|
1269
|
+
this.withBucket(`/anchors/${encodeURIComponent(id)}`),
|
|
1270
|
+
{
|
|
1271
|
+
method: "PATCH",
|
|
1272
|
+
headers: { "Content-Type": "application/json" },
|
|
1273
|
+
body: JSON.stringify(params)
|
|
1274
|
+
},
|
|
1275
|
+
anchorResponseSchema
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
async deleteAnchor(id, options) {
|
|
1279
|
+
await this.request(
|
|
1280
|
+
this.withBucket(`/anchors/${encodeURIComponent(id)}`, options?.bucket),
|
|
1281
|
+
{ method: "DELETE" }
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1205
1284
|
};
|
|
1206
1285
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1207
1286
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -260,6 +260,17 @@ var deleteProfileSignalsResponseSchema = z.object({
|
|
|
260
260
|
totalSignals: z.number(),
|
|
261
261
|
vectorUpdated: z.boolean()
|
|
262
262
|
});
|
|
263
|
+
var anchorResponseSchema = z.object({
|
|
264
|
+
id: z.string(),
|
|
265
|
+
bucketId: z.string(),
|
|
266
|
+
label: z.string().nullable(),
|
|
267
|
+
text: z.string(),
|
|
268
|
+
createdAt: z.string(),
|
|
269
|
+
updatedAt: z.string()
|
|
270
|
+
});
|
|
271
|
+
var anchorListResponseSchema = z.object({
|
|
272
|
+
anchors: z.array(anchorResponseSchema)
|
|
273
|
+
});
|
|
263
274
|
var StowServer = class {
|
|
264
275
|
apiKey;
|
|
265
276
|
baseUrl;
|
|
@@ -924,6 +935,7 @@ var StowServer = class {
|
|
|
924
935
|
method: "POST",
|
|
925
936
|
headers: { "Content-Type": "application/json" },
|
|
926
937
|
body: JSON.stringify({
|
|
938
|
+
...params.anchorId ? { anchorId: params.anchorId } : {},
|
|
927
939
|
...params.fileKey ? { fileKey: params.fileKey } : {},
|
|
928
940
|
...params.vector ? { vector: params.vector } : {},
|
|
929
941
|
...params.profileId ? { profileId: params.profileId } : {},
|
|
@@ -943,6 +955,7 @@ var StowServer = class {
|
|
|
943
955
|
method: "POST",
|
|
944
956
|
headers: { "Content-Type": "application/json" },
|
|
945
957
|
body: JSON.stringify({
|
|
958
|
+
...params.anchorId ? { anchorId: params.anchorId } : {},
|
|
946
959
|
...params.fileKey ? { fileKey: params.fileKey } : {},
|
|
947
960
|
...params.vector ? { vector: params.vector } : {},
|
|
948
961
|
...params.profileId ? { profileId: params.profileId } : {},
|
|
@@ -950,7 +963,7 @@ var StowServer = class {
|
|
|
950
963
|
...params.clusterIds?.length ? { clusterIds: params.clusterIds } : {},
|
|
951
964
|
...bucket ? { bucket } : {},
|
|
952
965
|
...params.limit ? { limit: params.limit } : {},
|
|
953
|
-
...params.lambda
|
|
966
|
+
...params.lambda === void 0 ? {} : { lambda: params.lambda },
|
|
954
967
|
...params.excludeKeys?.length ? { excludeKeys: params.excludeKeys } : {},
|
|
955
968
|
...params.filters ? { filters: params.filters } : {},
|
|
956
969
|
...params.include?.length ? { include: params.include } : {}
|
|
@@ -983,7 +996,7 @@ var StowServer = class {
|
|
|
983
996
|
...bucket ? { bucket } : {},
|
|
984
997
|
...params.limit ? { limit: params.limit } : {},
|
|
985
998
|
...params.excludeKeys?.length ? { excludeKeys: params.excludeKeys } : {},
|
|
986
|
-
...params.minProportion
|
|
999
|
+
...params.minProportion === void 0 ? {} : { minProportion: params.minProportion },
|
|
987
1000
|
...params.dominantOnly ? { dominantOnly: params.dominantOnly } : {}
|
|
988
1001
|
})
|
|
989
1002
|
});
|
|
@@ -1159,7 +1172,7 @@ var StowServer = class {
|
|
|
1159
1172
|
method: "POST",
|
|
1160
1173
|
headers: { "Content-Type": "application/json" },
|
|
1161
1174
|
body: JSON.stringify({
|
|
1162
|
-
...params?.clusterCount
|
|
1175
|
+
...params?.clusterCount === void 0 ? {} : { clusterCount: params.clusterCount }
|
|
1163
1176
|
})
|
|
1164
1177
|
}
|
|
1165
1178
|
);
|
|
@@ -1177,6 +1190,72 @@ var StowServer = class {
|
|
|
1177
1190
|
}
|
|
1178
1191
|
);
|
|
1179
1192
|
}
|
|
1193
|
+
// ============================================================
|
|
1194
|
+
// ANCHORS - Named semantic reference points in vector space
|
|
1195
|
+
// ============================================================
|
|
1196
|
+
/**
|
|
1197
|
+
* Anchors namespace for creating, listing, updating, and deleting text anchors.
|
|
1198
|
+
*
|
|
1199
|
+
* @example
|
|
1200
|
+
* ```typescript
|
|
1201
|
+
* const anchor = await stow.anchors.create({ text: "minimalist architecture", label: "minimal" });
|
|
1202
|
+
* const results = await stow.search.similar({ anchorId: anchor.id });
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
get anchors() {
|
|
1206
|
+
return {
|
|
1207
|
+
create: (params) => this.createAnchor(params),
|
|
1208
|
+
list: (options) => this.listAnchors(options),
|
|
1209
|
+
get: (id, options) => this.getAnchor(id, options),
|
|
1210
|
+
update: (id, params) => this.updateAnchor(id, params),
|
|
1211
|
+
delete: (id, options) => this.deleteAnchor(id, options)
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
createAnchor(params) {
|
|
1215
|
+
return this.request(
|
|
1216
|
+
this.withBucket("/anchors"),
|
|
1217
|
+
{
|
|
1218
|
+
method: "POST",
|
|
1219
|
+
headers: { "Content-Type": "application/json" },
|
|
1220
|
+
body: JSON.stringify({
|
|
1221
|
+
text: params.text,
|
|
1222
|
+
...params.label ? { label: params.label } : {}
|
|
1223
|
+
})
|
|
1224
|
+
},
|
|
1225
|
+
anchorResponseSchema
|
|
1226
|
+
);
|
|
1227
|
+
}
|
|
1228
|
+
listAnchors(options) {
|
|
1229
|
+
return this.request(
|
|
1230
|
+
this.withBucket("/anchors", options?.bucket),
|
|
1231
|
+
{ method: "GET" },
|
|
1232
|
+
anchorListResponseSchema
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
getAnchor(id, options) {
|
|
1236
|
+
return this.request(
|
|
1237
|
+
this.withBucket(`/anchors/${encodeURIComponent(id)}`, options?.bucket),
|
|
1238
|
+
{ method: "GET" },
|
|
1239
|
+
anchorResponseSchema
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
updateAnchor(id, params) {
|
|
1243
|
+
return this.request(
|
|
1244
|
+
this.withBucket(`/anchors/${encodeURIComponent(id)}`),
|
|
1245
|
+
{
|
|
1246
|
+
method: "PATCH",
|
|
1247
|
+
headers: { "Content-Type": "application/json" },
|
|
1248
|
+
body: JSON.stringify(params)
|
|
1249
|
+
},
|
|
1250
|
+
anchorResponseSchema
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
async deleteAnchor(id, options) {
|
|
1254
|
+
await this.request(
|
|
1255
|
+
this.withBucket(`/anchors/${encodeURIComponent(id)}`, options?.bucket),
|
|
1256
|
+
{ method: "DELETE" }
|
|
1257
|
+
);
|
|
1258
|
+
}
|
|
1180
1259
|
};
|
|
1181
1260
|
export {
|
|
1182
1261
|
StowError,
|