@howells/stow-server 0.7.0 → 2.0.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/LICENSE +21 -0
- package/dist/index.d.mts +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.js +83 -85
- package/dist/index.mjs +83 -85
- package/package.json +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Stow
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
CHANGED
|
@@ -520,10 +520,12 @@ interface SearchResultItem {
|
|
|
520
520
|
name: string;
|
|
521
521
|
}>;
|
|
522
522
|
taxonomies?: Array<{
|
|
523
|
-
|
|
524
|
-
name: string;
|
|
523
|
+
externalUri: string | null;
|
|
525
524
|
group: string;
|
|
525
|
+
name: string;
|
|
526
526
|
similarity: number;
|
|
527
|
+
slug: string;
|
|
528
|
+
source: string;
|
|
527
529
|
}>;
|
|
528
530
|
width?: number | null;
|
|
529
531
|
}
|
|
@@ -938,19 +940,19 @@ declare class StowServer {
|
|
|
938
940
|
*/
|
|
939
941
|
get profiles(): {
|
|
940
942
|
create: (params?: ProfileCreateRequest) => Promise<ProfileResult>;
|
|
941
|
-
get: (id: string) => Promise<ProfileResult>;
|
|
942
|
-
delete: (id: string) => Promise<void>;
|
|
943
|
+
get: (id: string, bucket?: string) => Promise<ProfileResult>;
|
|
944
|
+
delete: (id: string, bucket?: string) => Promise<void>;
|
|
943
945
|
addFiles: (id: string, fileKeys: string[], bucket?: string) => Promise<ProfileFilesResult>;
|
|
944
946
|
removeFiles: (id: string, fileKeys: string[], bucket?: string) => Promise<ProfileFilesResult>;
|
|
945
947
|
signal: (id: string, signals: ProfileSignalInput[], bucket?: string) => Promise<ProfileSignalsResponse>;
|
|
946
|
-
deleteSignals: (id: string, signalIds: string[]) => Promise<DeleteProfileSignalsResult>;
|
|
947
|
-
clusters: (id: string) => Promise<{
|
|
948
|
+
deleteSignals: (id: string, signalIds: string[], bucket?: string) => Promise<DeleteProfileSignalsResult>;
|
|
949
|
+
clusters: (id: string, bucket?: string) => Promise<{
|
|
948
950
|
profileId: string;
|
|
949
951
|
signalCount: number;
|
|
950
952
|
clusters: ProfileClusterResult[];
|
|
951
953
|
}>;
|
|
952
|
-
recluster: (id: string, params?: ReclusterRequest) => Promise<ReclusterResult>;
|
|
953
|
-
renameCluster: (profileId: string, clusterId: string, params: RenameClusterRequest) => Promise<ProfileClusterResult>;
|
|
954
|
+
recluster: (id: string, params?: ReclusterRequest, bucket?: string) => Promise<ReclusterResult>;
|
|
955
|
+
renameCluster: (profileId: string, clusterId: string, params: RenameClusterRequest, bucket?: string) => Promise<ProfileClusterResult>;
|
|
954
956
|
};
|
|
955
957
|
private createProfile;
|
|
956
958
|
private getProfile;
|
package/dist/index.d.ts
CHANGED
|
@@ -520,10 +520,12 @@ interface SearchResultItem {
|
|
|
520
520
|
name: string;
|
|
521
521
|
}>;
|
|
522
522
|
taxonomies?: Array<{
|
|
523
|
-
|
|
524
|
-
name: string;
|
|
523
|
+
externalUri: string | null;
|
|
525
524
|
group: string;
|
|
525
|
+
name: string;
|
|
526
526
|
similarity: number;
|
|
527
|
+
slug: string;
|
|
528
|
+
source: string;
|
|
527
529
|
}>;
|
|
528
530
|
width?: number | null;
|
|
529
531
|
}
|
|
@@ -938,19 +940,19 @@ declare class StowServer {
|
|
|
938
940
|
*/
|
|
939
941
|
get profiles(): {
|
|
940
942
|
create: (params?: ProfileCreateRequest) => Promise<ProfileResult>;
|
|
941
|
-
get: (id: string) => Promise<ProfileResult>;
|
|
942
|
-
delete: (id: string) => Promise<void>;
|
|
943
|
+
get: (id: string, bucket?: string) => Promise<ProfileResult>;
|
|
944
|
+
delete: (id: string, bucket?: string) => Promise<void>;
|
|
943
945
|
addFiles: (id: string, fileKeys: string[], bucket?: string) => Promise<ProfileFilesResult>;
|
|
944
946
|
removeFiles: (id: string, fileKeys: string[], bucket?: string) => Promise<ProfileFilesResult>;
|
|
945
947
|
signal: (id: string, signals: ProfileSignalInput[], bucket?: string) => Promise<ProfileSignalsResponse>;
|
|
946
|
-
deleteSignals: (id: string, signalIds: string[]) => Promise<DeleteProfileSignalsResult>;
|
|
947
|
-
clusters: (id: string) => Promise<{
|
|
948
|
+
deleteSignals: (id: string, signalIds: string[], bucket?: string) => Promise<DeleteProfileSignalsResult>;
|
|
949
|
+
clusters: (id: string, bucket?: string) => Promise<{
|
|
948
950
|
profileId: string;
|
|
949
951
|
signalCount: number;
|
|
950
952
|
clusters: ProfileClusterResult[];
|
|
951
953
|
}>;
|
|
952
|
-
recluster: (id: string, params?: ReclusterRequest) => Promise<ReclusterResult>;
|
|
953
|
-
renameCluster: (profileId: string, clusterId: string, params: RenameClusterRequest) => Promise<ProfileClusterResult>;
|
|
954
|
+
recluster: (id: string, params?: ReclusterRequest, bucket?: string) => Promise<ReclusterResult>;
|
|
955
|
+
renameCluster: (profileId: string, clusterId: string, params: RenameClusterRequest, bucket?: string) => Promise<ProfileClusterResult>;
|
|
954
956
|
};
|
|
955
957
|
private createProfile;
|
|
956
958
|
private getProfile;
|
package/dist/index.js
CHANGED
|
@@ -294,12 +294,12 @@ var StowServer = class {
|
|
|
294
294
|
constructor(config) {
|
|
295
295
|
if (typeof config === "string") {
|
|
296
296
|
this.apiKey = config;
|
|
297
|
-
this.baseUrl = "https://
|
|
297
|
+
this.baseUrl = "https://api.stow.sh";
|
|
298
298
|
this.timeout = 3e4;
|
|
299
299
|
this.retries = 3;
|
|
300
300
|
} else {
|
|
301
301
|
this.apiKey = config.apiKey;
|
|
302
|
-
this.baseUrl = config.baseUrl || "https://
|
|
302
|
+
this.baseUrl = config.baseUrl || "https://api.stow.sh";
|
|
303
303
|
this.bucket = config.bucket;
|
|
304
304
|
this.timeout = config.timeout ?? 3e4;
|
|
305
305
|
this.retries = config.retries ?? 3;
|
|
@@ -315,20 +315,20 @@ var StowServer = class {
|
|
|
315
315
|
* Return account usage and API key info for the current credential.
|
|
316
316
|
*/
|
|
317
317
|
whoami() {
|
|
318
|
-
return this.request("/
|
|
318
|
+
return this.request("/whoami", { method: "GET" }, whoamiSchema);
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
321
|
* List all buckets available to the current organization.
|
|
322
322
|
*/
|
|
323
323
|
listBuckets() {
|
|
324
|
-
return this.request("/
|
|
324
|
+
return this.request("/buckets", { method: "GET" }, listBucketsSchema);
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
327
|
* Create a new bucket.
|
|
328
328
|
*/
|
|
329
329
|
async createBucket(request) {
|
|
330
330
|
const result = await this.request(
|
|
331
|
-
"/
|
|
331
|
+
"/buckets",
|
|
332
332
|
{
|
|
333
333
|
method: "POST",
|
|
334
334
|
headers: { "Content-Type": "application/json" },
|
|
@@ -343,7 +343,7 @@ var StowServer = class {
|
|
|
343
343
|
*/
|
|
344
344
|
async getBucket(id) {
|
|
345
345
|
const result = await this.request(
|
|
346
|
-
`/
|
|
346
|
+
`/buckets/${encodeURIComponent(id)}`,
|
|
347
347
|
{ method: "GET" },
|
|
348
348
|
bucketResponseSchema
|
|
349
349
|
);
|
|
@@ -354,7 +354,7 @@ var StowServer = class {
|
|
|
354
354
|
*/
|
|
355
355
|
async updateBucket(id, updates) {
|
|
356
356
|
const result = await this.request(
|
|
357
|
-
`/
|
|
357
|
+
`/buckets/${encodeURIComponent(id)}`,
|
|
358
358
|
{
|
|
359
359
|
method: "PATCH",
|
|
360
360
|
headers: { "Content-Type": "application/json" },
|
|
@@ -369,7 +369,7 @@ var StowServer = class {
|
|
|
369
369
|
*/
|
|
370
370
|
async updateBucketByName(name, updates) {
|
|
371
371
|
const result = await this.request(
|
|
372
|
-
`/
|
|
372
|
+
`/buckets/_?bucket=${encodeURIComponent(name)}`,
|
|
373
373
|
{
|
|
374
374
|
method: "PATCH",
|
|
375
375
|
headers: { "Content-Type": "application/json" },
|
|
@@ -389,7 +389,7 @@ var StowServer = class {
|
|
|
389
389
|
* Delete a bucket by id.
|
|
390
390
|
*/
|
|
391
391
|
async deleteBucket(id) {
|
|
392
|
-
await this.request(`/
|
|
392
|
+
await this.request(`/buckets/${encodeURIComponent(id)}`, {
|
|
393
393
|
method: "DELETE"
|
|
394
394
|
});
|
|
395
395
|
}
|
|
@@ -517,7 +517,7 @@ var StowServer = class {
|
|
|
517
517
|
}
|
|
518
518
|
return this.request(
|
|
519
519
|
this.withBucket(
|
|
520
|
-
presign.confirmUrl || "/
|
|
520
|
+
presign.confirmUrl || "/presign/confirm",
|
|
521
521
|
options?.bucket
|
|
522
522
|
),
|
|
523
523
|
{
|
|
@@ -543,7 +543,7 @@ var StowServer = class {
|
|
|
543
543
|
*/
|
|
544
544
|
async uploadFromUrl(url, filename, options) {
|
|
545
545
|
const result = await this.request(
|
|
546
|
-
this.withBucket("/
|
|
546
|
+
this.withBucket("/upload", options?.bucket),
|
|
547
547
|
{
|
|
548
548
|
method: "POST",
|
|
549
549
|
headers: { "Content-Type": "application/json" },
|
|
@@ -576,7 +576,7 @@ var StowServer = class {
|
|
|
576
576
|
*/
|
|
577
577
|
async queueUploadFromUrl(url, filename, options) {
|
|
578
578
|
return this.request(
|
|
579
|
-
this.withBucket("/
|
|
579
|
+
this.withBucket("/upload", options?.bucket),
|
|
580
580
|
{
|
|
581
581
|
method: "POST",
|
|
582
582
|
headers: { "Content-Type": "application/json" },
|
|
@@ -614,7 +614,7 @@ var StowServer = class {
|
|
|
614
614
|
contentHash
|
|
615
615
|
} = request;
|
|
616
616
|
return this.request(
|
|
617
|
-
this.withBucket("/
|
|
617
|
+
this.withBucket("/presign", bucket),
|
|
618
618
|
{
|
|
619
619
|
method: "POST",
|
|
620
620
|
headers: { "Content-Type": "application/json" },
|
|
@@ -648,7 +648,7 @@ var StowServer = class {
|
|
|
648
648
|
altText
|
|
649
649
|
} = request;
|
|
650
650
|
return this.request(
|
|
651
|
-
this.withBucket("/
|
|
651
|
+
this.withBucket("/presign/confirm", bucket),
|
|
652
652
|
{
|
|
653
653
|
method: "POST",
|
|
654
654
|
headers: { "Content-Type": "application/json" },
|
|
@@ -689,7 +689,7 @@ var StowServer = class {
|
|
|
689
689
|
if (options?.include?.length) {
|
|
690
690
|
params.set("include", options.include.join(","));
|
|
691
691
|
}
|
|
692
|
-
const path = `/
|
|
692
|
+
const path = `/files?${params}`;
|
|
693
693
|
return this.request(
|
|
694
694
|
this.withBucket(path, options?.bucket),
|
|
695
695
|
{ method: "GET" },
|
|
@@ -700,7 +700,7 @@ var StowServer = class {
|
|
|
700
700
|
* Delete a file by key
|
|
701
701
|
*/
|
|
702
702
|
async deleteFile(key, options) {
|
|
703
|
-
const path = `/
|
|
703
|
+
const path = `/files/${encodeURIComponent(key)}`;
|
|
704
704
|
await this.request(this.withBucket(path, options?.bucket), {
|
|
705
705
|
method: "DELETE"
|
|
706
706
|
});
|
|
@@ -709,7 +709,7 @@ var StowServer = class {
|
|
|
709
709
|
* Update metadata on an existing file
|
|
710
710
|
*/
|
|
711
711
|
updateFileMetadata(key, metadata, options) {
|
|
712
|
-
const path = `/
|
|
712
|
+
const path = `/files/${encodeURIComponent(key)}`;
|
|
713
713
|
return this.request(this.withBucket(path, options?.bucket), {
|
|
714
714
|
method: "PATCH",
|
|
715
715
|
headers: { "Content-Type": "application/json" },
|
|
@@ -727,7 +727,7 @@ var StowServer = class {
|
|
|
727
727
|
params.set("include", options.include.join(","));
|
|
728
728
|
}
|
|
729
729
|
const qs = params.toString();
|
|
730
|
-
const path = `/
|
|
730
|
+
const path = `/files/${encodeURIComponent(key)}${qs ? `?${qs}` : ""}`;
|
|
731
731
|
return this.request(
|
|
732
732
|
this.withBucket(path, options?.bucket),
|
|
733
733
|
{ method: "GET" },
|
|
@@ -739,7 +739,7 @@ var StowServer = class {
|
|
|
739
739
|
* Requires a searchable bucket.
|
|
740
740
|
*/
|
|
741
741
|
extractColors(key, options) {
|
|
742
|
-
const path = `/
|
|
742
|
+
const path = `/files/${encodeURIComponent(key)}/colors`;
|
|
743
743
|
return this.request(
|
|
744
744
|
this.withBucket(path, options?.bucket),
|
|
745
745
|
{ method: "POST" },
|
|
@@ -750,7 +750,7 @@ var StowServer = class {
|
|
|
750
750
|
* Extract dimensions (width/height) from an image or video file.
|
|
751
751
|
*/
|
|
752
752
|
extractDimensions(key, options) {
|
|
753
|
-
const path = `/
|
|
753
|
+
const path = `/files/${encodeURIComponent(key)}/dimensions`;
|
|
754
754
|
return this.request(
|
|
755
755
|
this.withBucket(path, options?.bucket),
|
|
756
756
|
{ method: "POST" },
|
|
@@ -762,7 +762,7 @@ var StowServer = class {
|
|
|
762
762
|
* Requires a searchable bucket.
|
|
763
763
|
*/
|
|
764
764
|
embed(key, options) {
|
|
765
|
-
const path = `/
|
|
765
|
+
const path = `/files/${encodeURIComponent(key)}/embedding`;
|
|
766
766
|
return this.request(
|
|
767
767
|
this.withBucket(path, options?.bucket),
|
|
768
768
|
{ method: "POST" },
|
|
@@ -774,7 +774,7 @@ var StowServer = class {
|
|
|
774
774
|
* Requires a searchable bucket.
|
|
775
775
|
*/
|
|
776
776
|
generateTitle(key, options) {
|
|
777
|
-
const path = `/
|
|
777
|
+
const path = `/files/${encodeURIComponent(key)}/title`;
|
|
778
778
|
return this.request(
|
|
779
779
|
this.withBucket(path, options?.bucket),
|
|
780
780
|
{ method: "POST" },
|
|
@@ -786,7 +786,7 @@ var StowServer = class {
|
|
|
786
786
|
* Requires a searchable bucket.
|
|
787
787
|
*/
|
|
788
788
|
generateDescription(key, options) {
|
|
789
|
-
const path = `/
|
|
789
|
+
const path = `/files/${encodeURIComponent(key)}/description`;
|
|
790
790
|
return this.request(
|
|
791
791
|
this.withBucket(path, options?.bucket),
|
|
792
792
|
{ method: "POST" },
|
|
@@ -798,7 +798,7 @@ var StowServer = class {
|
|
|
798
798
|
* Requires a searchable bucket.
|
|
799
799
|
*/
|
|
800
800
|
generateAltText(key, options) {
|
|
801
|
-
const path = `/
|
|
801
|
+
const path = `/files/${encodeURIComponent(key)}/alt-text`;
|
|
802
802
|
return this.request(
|
|
803
803
|
this.withBucket(path, options?.bucket),
|
|
804
804
|
{ method: "POST" },
|
|
@@ -813,7 +813,7 @@ var StowServer = class {
|
|
|
813
813
|
* tasks are re-dispatched as if the file were newly uploaded.
|
|
814
814
|
*/
|
|
815
815
|
replaceFile(key, url, options) {
|
|
816
|
-
const path = `/
|
|
816
|
+
const path = `/files/${encodeURIComponent(key)}/replace`;
|
|
817
817
|
return this.request(
|
|
818
818
|
this.withBucket(path, options?.bucket),
|
|
819
819
|
{
|
|
@@ -870,17 +870,17 @@ var StowServer = class {
|
|
|
870
870
|
};
|
|
871
871
|
}
|
|
872
872
|
listTags() {
|
|
873
|
-
return this.request("/
|
|
873
|
+
return this.request("/tags", { method: "GET" });
|
|
874
874
|
}
|
|
875
875
|
createTag(params) {
|
|
876
|
-
return this.request("/
|
|
876
|
+
return this.request("/tags", {
|
|
877
877
|
method: "POST",
|
|
878
878
|
headers: { "Content-Type": "application/json" },
|
|
879
879
|
body: JSON.stringify(params)
|
|
880
880
|
});
|
|
881
881
|
}
|
|
882
882
|
async deleteTag(id) {
|
|
883
|
-
await this.request(`/
|
|
883
|
+
await this.request(`/tags/${encodeURIComponent(id)}`, {
|
|
884
884
|
method: "DELETE"
|
|
885
885
|
});
|
|
886
886
|
}
|
|
@@ -891,7 +891,7 @@ var StowServer = class {
|
|
|
891
891
|
* Add tags to a file
|
|
892
892
|
*/
|
|
893
893
|
async addTags(key, tagIds, options) {
|
|
894
|
-
const path = `/
|
|
894
|
+
const path = `/files/${encodeURIComponent(key)}/tags`;
|
|
895
895
|
await this.request(this.withBucket(path, options?.bucket), {
|
|
896
896
|
method: "POST",
|
|
897
897
|
headers: { "Content-Type": "application/json" },
|
|
@@ -902,7 +902,7 @@ var StowServer = class {
|
|
|
902
902
|
* Remove a tag from a file
|
|
903
903
|
*/
|
|
904
904
|
async removeTag(key, tagId, options) {
|
|
905
|
-
const path = `/
|
|
905
|
+
const path = `/files/${encodeURIComponent(key)}/tags/${encodeURIComponent(tagId)}`;
|
|
906
906
|
await this.request(this.withBucket(path, options?.bucket), {
|
|
907
907
|
method: "DELETE"
|
|
908
908
|
});
|
|
@@ -927,7 +927,7 @@ var StowServer = class {
|
|
|
927
927
|
};
|
|
928
928
|
}
|
|
929
929
|
listTaxonomies() {
|
|
930
|
-
return this.request("/
|
|
930
|
+
return this.request("/taxonomies", { method: "GET" });
|
|
931
931
|
}
|
|
932
932
|
// ============================================================
|
|
933
933
|
// SEARCH - Vector similarity search
|
|
@@ -945,7 +945,7 @@ var StowServer = class {
|
|
|
945
945
|
}
|
|
946
946
|
searchSimilar(params) {
|
|
947
947
|
const bucket = this.resolveBucket(params.bucket);
|
|
948
|
-
return this.request("/
|
|
948
|
+
return this.request("/search/similar", {
|
|
949
949
|
method: "POST",
|
|
950
950
|
headers: { "Content-Type": "application/json" },
|
|
951
951
|
body: JSON.stringify({
|
|
@@ -964,7 +964,7 @@ var StowServer = class {
|
|
|
964
964
|
}
|
|
965
965
|
searchDiverse(params) {
|
|
966
966
|
const bucket = this.resolveBucket(params.bucket);
|
|
967
|
-
return this.request("/
|
|
967
|
+
return this.request("/search/diverse", {
|
|
968
968
|
method: "POST",
|
|
969
969
|
headers: { "Content-Type": "application/json" },
|
|
970
970
|
body: JSON.stringify({
|
|
@@ -984,7 +984,7 @@ var StowServer = class {
|
|
|
984
984
|
}
|
|
985
985
|
searchText(params) {
|
|
986
986
|
const bucket = this.resolveBucket(params.bucket);
|
|
987
|
-
return this.request("/
|
|
987
|
+
return this.request("/search/text", {
|
|
988
988
|
method: "POST",
|
|
989
989
|
headers: { "Content-Type": "application/json" },
|
|
990
990
|
body: JSON.stringify({
|
|
@@ -999,7 +999,7 @@ var StowServer = class {
|
|
|
999
999
|
}
|
|
1000
1000
|
searchColor(params) {
|
|
1001
1001
|
const bucket = this.resolveBucket(params.bucket);
|
|
1002
|
-
return this.request("/
|
|
1002
|
+
return this.request("/search/color", {
|
|
1003
1003
|
method: "POST",
|
|
1004
1004
|
headers: { "Content-Type": "application/json" },
|
|
1005
1005
|
body: JSON.stringify({
|
|
@@ -1032,7 +1032,7 @@ var StowServer = class {
|
|
|
1032
1032
|
const contentType = options?.contentType || "application/octet-stream";
|
|
1033
1033
|
const filename = options?.filename || "file";
|
|
1034
1034
|
const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await file.arrayBuffer());
|
|
1035
|
-
const presign = await this.request("/
|
|
1035
|
+
const presign = await this.request("/drops/presign", {
|
|
1036
1036
|
method: "POST",
|
|
1037
1037
|
headers: { "Content-Type": "application/json" },
|
|
1038
1038
|
body: JSON.stringify({
|
|
@@ -1050,7 +1050,7 @@ var StowServer = class {
|
|
|
1050
1050
|
throw new StowError("Failed to upload to storage", putRes.status);
|
|
1051
1051
|
}
|
|
1052
1052
|
return this.request(
|
|
1053
|
-
presign.confirmUrl || "/
|
|
1053
|
+
presign.confirmUrl || "/drops/presign/confirm",
|
|
1054
1054
|
{
|
|
1055
1055
|
method: "POST",
|
|
1056
1056
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1070,13 +1070,13 @@ var StowServer = class {
|
|
|
1070
1070
|
* List all drops for the authenticated user
|
|
1071
1071
|
*/
|
|
1072
1072
|
listDrops() {
|
|
1073
|
-
return this.request("/
|
|
1073
|
+
return this.request("/drops", { method: "GET" }, listDropsSchema);
|
|
1074
1074
|
}
|
|
1075
1075
|
/**
|
|
1076
1076
|
* Delete a drop by ID
|
|
1077
1077
|
*/
|
|
1078
1078
|
async deleteDrop(id) {
|
|
1079
|
-
await this.request(`/
|
|
1079
|
+
await this.request(`/drops/${encodeURIComponent(id)}`, {
|
|
1080
1080
|
method: "DELETE"
|
|
1081
1081
|
});
|
|
1082
1082
|
}
|
|
@@ -1089,89 +1089,80 @@ var StowServer = class {
|
|
|
1089
1089
|
get profiles() {
|
|
1090
1090
|
return {
|
|
1091
1091
|
create: (params) => this.createProfile(params),
|
|
1092
|
-
get: (id) => this.getProfile(id),
|
|
1093
|
-
delete: (id) => this.deleteProfile(id),
|
|
1092
|
+
get: (id, bucket) => this.getProfile(id, bucket),
|
|
1093
|
+
delete: (id, bucket) => this.deleteProfile(id, bucket),
|
|
1094
1094
|
addFiles: (id, fileKeys, bucket) => this.addProfileFiles(id, fileKeys, bucket),
|
|
1095
1095
|
removeFiles: (id, fileKeys, bucket) => this.removeProfileFiles(id, fileKeys, bucket),
|
|
1096
1096
|
signal: (id, signals, bucket) => this.signalProfile(id, signals, bucket),
|
|
1097
|
-
deleteSignals: (id, signalIds) => this.deleteProfileSignals(id, signalIds),
|
|
1098
|
-
clusters: (id) => this.getProfileClusters(id),
|
|
1099
|
-
recluster: (id, params) => this.reclusterProfile(id, params),
|
|
1100
|
-
renameCluster: (profileId, clusterId, params) => this.renameProfileCluster(profileId, clusterId, params)
|
|
1097
|
+
deleteSignals: (id, signalIds, bucket) => this.deleteProfileSignals(id, signalIds, bucket),
|
|
1098
|
+
clusters: (id, bucket) => this.getProfileClusters(id, bucket),
|
|
1099
|
+
recluster: (id, params, bucket) => this.reclusterProfile(id, params, bucket),
|
|
1100
|
+
renameCluster: (profileId, clusterId, params, bucket) => this.renameProfileCluster(profileId, clusterId, params, bucket)
|
|
1101
1101
|
};
|
|
1102
1102
|
}
|
|
1103
1103
|
createProfile(params) {
|
|
1104
1104
|
return this.request(
|
|
1105
|
-
"/
|
|
1105
|
+
this.withBucket("/profiles", params?.bucket),
|
|
1106
1106
|
{
|
|
1107
1107
|
method: "POST",
|
|
1108
1108
|
headers: { "Content-Type": "application/json" },
|
|
1109
1109
|
body: JSON.stringify({
|
|
1110
1110
|
...params?.name ? { name: params.name } : {},
|
|
1111
|
-
...params?.fileKeys ? { fileKeys: params.fileKeys } : {}
|
|
1112
|
-
...params?.bucket ? { bucket: params.bucket } : {}
|
|
1111
|
+
...params?.fileKeys ? { fileKeys: params.fileKeys } : {}
|
|
1113
1112
|
})
|
|
1114
1113
|
},
|
|
1115
1114
|
profileResultSchema
|
|
1116
1115
|
);
|
|
1117
1116
|
}
|
|
1118
|
-
getProfile(id) {
|
|
1117
|
+
getProfile(id, bucket) {
|
|
1119
1118
|
return this.request(
|
|
1120
|
-
`/
|
|
1119
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}`, bucket),
|
|
1121
1120
|
{ method: "GET" },
|
|
1122
1121
|
profileResultSchema
|
|
1123
1122
|
);
|
|
1124
1123
|
}
|
|
1125
|
-
async deleteProfile(id) {
|
|
1126
|
-
await this.request(
|
|
1127
|
-
|
|
1128
|
-
|
|
1124
|
+
async deleteProfile(id, bucket) {
|
|
1125
|
+
await this.request(
|
|
1126
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}`, bucket),
|
|
1127
|
+
{ method: "DELETE" }
|
|
1128
|
+
);
|
|
1129
1129
|
}
|
|
1130
1130
|
addProfileFiles(id, fileKeys, bucket) {
|
|
1131
1131
|
return this.request(
|
|
1132
|
-
`/
|
|
1132
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/files`, bucket),
|
|
1133
1133
|
{
|
|
1134
1134
|
method: "POST",
|
|
1135
1135
|
headers: { "Content-Type": "application/json" },
|
|
1136
|
-
body: JSON.stringify({
|
|
1137
|
-
fileKeys,
|
|
1138
|
-
...bucket ? { bucket } : {}
|
|
1139
|
-
})
|
|
1136
|
+
body: JSON.stringify({ fileKeys })
|
|
1140
1137
|
},
|
|
1141
1138
|
profileFilesResultSchema
|
|
1142
1139
|
);
|
|
1143
1140
|
}
|
|
1144
1141
|
removeProfileFiles(id, fileKeys, bucket) {
|
|
1145
1142
|
return this.request(
|
|
1146
|
-
`/
|
|
1143
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/files`, bucket),
|
|
1147
1144
|
{
|
|
1148
1145
|
method: "DELETE",
|
|
1149
1146
|
headers: { "Content-Type": "application/json" },
|
|
1150
|
-
body: JSON.stringify({
|
|
1151
|
-
fileKeys,
|
|
1152
|
-
...bucket ? { bucket } : {}
|
|
1153
|
-
})
|
|
1147
|
+
body: JSON.stringify({ fileKeys })
|
|
1154
1148
|
},
|
|
1155
1149
|
profileFilesResultSchema
|
|
1156
1150
|
);
|
|
1157
1151
|
}
|
|
1158
1152
|
signalProfile(id, signals, bucket) {
|
|
1159
1153
|
return this.request(
|
|
1160
|
-
`/
|
|
1154
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/signals`, bucket),
|
|
1161
1155
|
{
|
|
1162
1156
|
method: "POST",
|
|
1163
1157
|
headers: { "Content-Type": "application/json" },
|
|
1164
|
-
body: JSON.stringify({
|
|
1165
|
-
signals,
|
|
1166
|
-
...bucket ? { bucket } : {}
|
|
1167
|
-
})
|
|
1158
|
+
body: JSON.stringify({ signals })
|
|
1168
1159
|
},
|
|
1169
1160
|
profileSignalsResponseSchema
|
|
1170
1161
|
);
|
|
1171
1162
|
}
|
|
1172
|
-
deleteProfileSignals(id, signalIds) {
|
|
1163
|
+
deleteProfileSignals(id, signalIds, bucket) {
|
|
1173
1164
|
return this.request(
|
|
1174
|
-
`/
|
|
1165
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/signals`, bucket),
|
|
1175
1166
|
{
|
|
1176
1167
|
method: "DELETE",
|
|
1177
1168
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1180,23 +1171,30 @@ var StowServer = class {
|
|
|
1180
1171
|
deleteProfileSignalsResponseSchema
|
|
1181
1172
|
);
|
|
1182
1173
|
}
|
|
1183
|
-
getProfileClusters(id) {
|
|
1184
|
-
return this.request(
|
|
1185
|
-
|
|
1186
|
-
|
|
1174
|
+
getProfileClusters(id, bucket) {
|
|
1175
|
+
return this.request(
|
|
1176
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/clusters`, bucket),
|
|
1177
|
+
{ method: "GET" }
|
|
1178
|
+
);
|
|
1187
1179
|
}
|
|
1188
|
-
reclusterProfile(id, params) {
|
|
1189
|
-
return this.request(
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1180
|
+
reclusterProfile(id, params, bucket) {
|
|
1181
|
+
return this.request(
|
|
1182
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/clusters`, bucket),
|
|
1183
|
+
{
|
|
1184
|
+
method: "POST",
|
|
1185
|
+
headers: { "Content-Type": "application/json" },
|
|
1186
|
+
body: JSON.stringify({
|
|
1187
|
+
...params?.clusterCount !== void 0 ? { clusterCount: params.clusterCount } : {}
|
|
1188
|
+
})
|
|
1189
|
+
}
|
|
1190
|
+
);
|
|
1196
1191
|
}
|
|
1197
|
-
renameProfileCluster(profileId, clusterId, params) {
|
|
1192
|
+
renameProfileCluster(profileId, clusterId, params, bucket) {
|
|
1198
1193
|
return this.request(
|
|
1199
|
-
|
|
1194
|
+
this.withBucket(
|
|
1195
|
+
`/profiles/${encodeURIComponent(profileId)}/clusters/${encodeURIComponent(clusterId)}`,
|
|
1196
|
+
bucket
|
|
1197
|
+
),
|
|
1200
1198
|
{
|
|
1201
1199
|
method: "PUT",
|
|
1202
1200
|
headers: { "Content-Type": "application/json" },
|
package/dist/index.mjs
CHANGED
|
@@ -269,12 +269,12 @@ var StowServer = class {
|
|
|
269
269
|
constructor(config) {
|
|
270
270
|
if (typeof config === "string") {
|
|
271
271
|
this.apiKey = config;
|
|
272
|
-
this.baseUrl = "https://
|
|
272
|
+
this.baseUrl = "https://api.stow.sh";
|
|
273
273
|
this.timeout = 3e4;
|
|
274
274
|
this.retries = 3;
|
|
275
275
|
} else {
|
|
276
276
|
this.apiKey = config.apiKey;
|
|
277
|
-
this.baseUrl = config.baseUrl || "https://
|
|
277
|
+
this.baseUrl = config.baseUrl || "https://api.stow.sh";
|
|
278
278
|
this.bucket = config.bucket;
|
|
279
279
|
this.timeout = config.timeout ?? 3e4;
|
|
280
280
|
this.retries = config.retries ?? 3;
|
|
@@ -290,20 +290,20 @@ var StowServer = class {
|
|
|
290
290
|
* Return account usage and API key info for the current credential.
|
|
291
291
|
*/
|
|
292
292
|
whoami() {
|
|
293
|
-
return this.request("/
|
|
293
|
+
return this.request("/whoami", { method: "GET" }, whoamiSchema);
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* List all buckets available to the current organization.
|
|
297
297
|
*/
|
|
298
298
|
listBuckets() {
|
|
299
|
-
return this.request("/
|
|
299
|
+
return this.request("/buckets", { method: "GET" }, listBucketsSchema);
|
|
300
300
|
}
|
|
301
301
|
/**
|
|
302
302
|
* Create a new bucket.
|
|
303
303
|
*/
|
|
304
304
|
async createBucket(request) {
|
|
305
305
|
const result = await this.request(
|
|
306
|
-
"/
|
|
306
|
+
"/buckets",
|
|
307
307
|
{
|
|
308
308
|
method: "POST",
|
|
309
309
|
headers: { "Content-Type": "application/json" },
|
|
@@ -318,7 +318,7 @@ var StowServer = class {
|
|
|
318
318
|
*/
|
|
319
319
|
async getBucket(id) {
|
|
320
320
|
const result = await this.request(
|
|
321
|
-
`/
|
|
321
|
+
`/buckets/${encodeURIComponent(id)}`,
|
|
322
322
|
{ method: "GET" },
|
|
323
323
|
bucketResponseSchema
|
|
324
324
|
);
|
|
@@ -329,7 +329,7 @@ var StowServer = class {
|
|
|
329
329
|
*/
|
|
330
330
|
async updateBucket(id, updates) {
|
|
331
331
|
const result = await this.request(
|
|
332
|
-
`/
|
|
332
|
+
`/buckets/${encodeURIComponent(id)}`,
|
|
333
333
|
{
|
|
334
334
|
method: "PATCH",
|
|
335
335
|
headers: { "Content-Type": "application/json" },
|
|
@@ -344,7 +344,7 @@ var StowServer = class {
|
|
|
344
344
|
*/
|
|
345
345
|
async updateBucketByName(name, updates) {
|
|
346
346
|
const result = await this.request(
|
|
347
|
-
`/
|
|
347
|
+
`/buckets/_?bucket=${encodeURIComponent(name)}`,
|
|
348
348
|
{
|
|
349
349
|
method: "PATCH",
|
|
350
350
|
headers: { "Content-Type": "application/json" },
|
|
@@ -364,7 +364,7 @@ var StowServer = class {
|
|
|
364
364
|
* Delete a bucket by id.
|
|
365
365
|
*/
|
|
366
366
|
async deleteBucket(id) {
|
|
367
|
-
await this.request(`/
|
|
367
|
+
await this.request(`/buckets/${encodeURIComponent(id)}`, {
|
|
368
368
|
method: "DELETE"
|
|
369
369
|
});
|
|
370
370
|
}
|
|
@@ -492,7 +492,7 @@ var StowServer = class {
|
|
|
492
492
|
}
|
|
493
493
|
return this.request(
|
|
494
494
|
this.withBucket(
|
|
495
|
-
presign.confirmUrl || "/
|
|
495
|
+
presign.confirmUrl || "/presign/confirm",
|
|
496
496
|
options?.bucket
|
|
497
497
|
),
|
|
498
498
|
{
|
|
@@ -518,7 +518,7 @@ var StowServer = class {
|
|
|
518
518
|
*/
|
|
519
519
|
async uploadFromUrl(url, filename, options) {
|
|
520
520
|
const result = await this.request(
|
|
521
|
-
this.withBucket("/
|
|
521
|
+
this.withBucket("/upload", options?.bucket),
|
|
522
522
|
{
|
|
523
523
|
method: "POST",
|
|
524
524
|
headers: { "Content-Type": "application/json" },
|
|
@@ -551,7 +551,7 @@ var StowServer = class {
|
|
|
551
551
|
*/
|
|
552
552
|
async queueUploadFromUrl(url, filename, options) {
|
|
553
553
|
return this.request(
|
|
554
|
-
this.withBucket("/
|
|
554
|
+
this.withBucket("/upload", options?.bucket),
|
|
555
555
|
{
|
|
556
556
|
method: "POST",
|
|
557
557
|
headers: { "Content-Type": "application/json" },
|
|
@@ -589,7 +589,7 @@ var StowServer = class {
|
|
|
589
589
|
contentHash
|
|
590
590
|
} = request;
|
|
591
591
|
return this.request(
|
|
592
|
-
this.withBucket("/
|
|
592
|
+
this.withBucket("/presign", bucket),
|
|
593
593
|
{
|
|
594
594
|
method: "POST",
|
|
595
595
|
headers: { "Content-Type": "application/json" },
|
|
@@ -623,7 +623,7 @@ var StowServer = class {
|
|
|
623
623
|
altText
|
|
624
624
|
} = request;
|
|
625
625
|
return this.request(
|
|
626
|
-
this.withBucket("/
|
|
626
|
+
this.withBucket("/presign/confirm", bucket),
|
|
627
627
|
{
|
|
628
628
|
method: "POST",
|
|
629
629
|
headers: { "Content-Type": "application/json" },
|
|
@@ -664,7 +664,7 @@ var StowServer = class {
|
|
|
664
664
|
if (options?.include?.length) {
|
|
665
665
|
params.set("include", options.include.join(","));
|
|
666
666
|
}
|
|
667
|
-
const path = `/
|
|
667
|
+
const path = `/files?${params}`;
|
|
668
668
|
return this.request(
|
|
669
669
|
this.withBucket(path, options?.bucket),
|
|
670
670
|
{ method: "GET" },
|
|
@@ -675,7 +675,7 @@ var StowServer = class {
|
|
|
675
675
|
* Delete a file by key
|
|
676
676
|
*/
|
|
677
677
|
async deleteFile(key, options) {
|
|
678
|
-
const path = `/
|
|
678
|
+
const path = `/files/${encodeURIComponent(key)}`;
|
|
679
679
|
await this.request(this.withBucket(path, options?.bucket), {
|
|
680
680
|
method: "DELETE"
|
|
681
681
|
});
|
|
@@ -684,7 +684,7 @@ var StowServer = class {
|
|
|
684
684
|
* Update metadata on an existing file
|
|
685
685
|
*/
|
|
686
686
|
updateFileMetadata(key, metadata, options) {
|
|
687
|
-
const path = `/
|
|
687
|
+
const path = `/files/${encodeURIComponent(key)}`;
|
|
688
688
|
return this.request(this.withBucket(path, options?.bucket), {
|
|
689
689
|
method: "PATCH",
|
|
690
690
|
headers: { "Content-Type": "application/json" },
|
|
@@ -702,7 +702,7 @@ var StowServer = class {
|
|
|
702
702
|
params.set("include", options.include.join(","));
|
|
703
703
|
}
|
|
704
704
|
const qs = params.toString();
|
|
705
|
-
const path = `/
|
|
705
|
+
const path = `/files/${encodeURIComponent(key)}${qs ? `?${qs}` : ""}`;
|
|
706
706
|
return this.request(
|
|
707
707
|
this.withBucket(path, options?.bucket),
|
|
708
708
|
{ method: "GET" },
|
|
@@ -714,7 +714,7 @@ var StowServer = class {
|
|
|
714
714
|
* Requires a searchable bucket.
|
|
715
715
|
*/
|
|
716
716
|
extractColors(key, options) {
|
|
717
|
-
const path = `/
|
|
717
|
+
const path = `/files/${encodeURIComponent(key)}/colors`;
|
|
718
718
|
return this.request(
|
|
719
719
|
this.withBucket(path, options?.bucket),
|
|
720
720
|
{ method: "POST" },
|
|
@@ -725,7 +725,7 @@ var StowServer = class {
|
|
|
725
725
|
* Extract dimensions (width/height) from an image or video file.
|
|
726
726
|
*/
|
|
727
727
|
extractDimensions(key, options) {
|
|
728
|
-
const path = `/
|
|
728
|
+
const path = `/files/${encodeURIComponent(key)}/dimensions`;
|
|
729
729
|
return this.request(
|
|
730
730
|
this.withBucket(path, options?.bucket),
|
|
731
731
|
{ method: "POST" },
|
|
@@ -737,7 +737,7 @@ var StowServer = class {
|
|
|
737
737
|
* Requires a searchable bucket.
|
|
738
738
|
*/
|
|
739
739
|
embed(key, options) {
|
|
740
|
-
const path = `/
|
|
740
|
+
const path = `/files/${encodeURIComponent(key)}/embedding`;
|
|
741
741
|
return this.request(
|
|
742
742
|
this.withBucket(path, options?.bucket),
|
|
743
743
|
{ method: "POST" },
|
|
@@ -749,7 +749,7 @@ var StowServer = class {
|
|
|
749
749
|
* Requires a searchable bucket.
|
|
750
750
|
*/
|
|
751
751
|
generateTitle(key, options) {
|
|
752
|
-
const path = `/
|
|
752
|
+
const path = `/files/${encodeURIComponent(key)}/title`;
|
|
753
753
|
return this.request(
|
|
754
754
|
this.withBucket(path, options?.bucket),
|
|
755
755
|
{ method: "POST" },
|
|
@@ -761,7 +761,7 @@ var StowServer = class {
|
|
|
761
761
|
* Requires a searchable bucket.
|
|
762
762
|
*/
|
|
763
763
|
generateDescription(key, options) {
|
|
764
|
-
const path = `/
|
|
764
|
+
const path = `/files/${encodeURIComponent(key)}/description`;
|
|
765
765
|
return this.request(
|
|
766
766
|
this.withBucket(path, options?.bucket),
|
|
767
767
|
{ method: "POST" },
|
|
@@ -773,7 +773,7 @@ var StowServer = class {
|
|
|
773
773
|
* Requires a searchable bucket.
|
|
774
774
|
*/
|
|
775
775
|
generateAltText(key, options) {
|
|
776
|
-
const path = `/
|
|
776
|
+
const path = `/files/${encodeURIComponent(key)}/alt-text`;
|
|
777
777
|
return this.request(
|
|
778
778
|
this.withBucket(path, options?.bucket),
|
|
779
779
|
{ method: "POST" },
|
|
@@ -788,7 +788,7 @@ var StowServer = class {
|
|
|
788
788
|
* tasks are re-dispatched as if the file were newly uploaded.
|
|
789
789
|
*/
|
|
790
790
|
replaceFile(key, url, options) {
|
|
791
|
-
const path = `/
|
|
791
|
+
const path = `/files/${encodeURIComponent(key)}/replace`;
|
|
792
792
|
return this.request(
|
|
793
793
|
this.withBucket(path, options?.bucket),
|
|
794
794
|
{
|
|
@@ -845,17 +845,17 @@ var StowServer = class {
|
|
|
845
845
|
};
|
|
846
846
|
}
|
|
847
847
|
listTags() {
|
|
848
|
-
return this.request("/
|
|
848
|
+
return this.request("/tags", { method: "GET" });
|
|
849
849
|
}
|
|
850
850
|
createTag(params) {
|
|
851
|
-
return this.request("/
|
|
851
|
+
return this.request("/tags", {
|
|
852
852
|
method: "POST",
|
|
853
853
|
headers: { "Content-Type": "application/json" },
|
|
854
854
|
body: JSON.stringify(params)
|
|
855
855
|
});
|
|
856
856
|
}
|
|
857
857
|
async deleteTag(id) {
|
|
858
|
-
await this.request(`/
|
|
858
|
+
await this.request(`/tags/${encodeURIComponent(id)}`, {
|
|
859
859
|
method: "DELETE"
|
|
860
860
|
});
|
|
861
861
|
}
|
|
@@ -866,7 +866,7 @@ var StowServer = class {
|
|
|
866
866
|
* Add tags to a file
|
|
867
867
|
*/
|
|
868
868
|
async addTags(key, tagIds, options) {
|
|
869
|
-
const path = `/
|
|
869
|
+
const path = `/files/${encodeURIComponent(key)}/tags`;
|
|
870
870
|
await this.request(this.withBucket(path, options?.bucket), {
|
|
871
871
|
method: "POST",
|
|
872
872
|
headers: { "Content-Type": "application/json" },
|
|
@@ -877,7 +877,7 @@ var StowServer = class {
|
|
|
877
877
|
* Remove a tag from a file
|
|
878
878
|
*/
|
|
879
879
|
async removeTag(key, tagId, options) {
|
|
880
|
-
const path = `/
|
|
880
|
+
const path = `/files/${encodeURIComponent(key)}/tags/${encodeURIComponent(tagId)}`;
|
|
881
881
|
await this.request(this.withBucket(path, options?.bucket), {
|
|
882
882
|
method: "DELETE"
|
|
883
883
|
});
|
|
@@ -902,7 +902,7 @@ var StowServer = class {
|
|
|
902
902
|
};
|
|
903
903
|
}
|
|
904
904
|
listTaxonomies() {
|
|
905
|
-
return this.request("/
|
|
905
|
+
return this.request("/taxonomies", { method: "GET" });
|
|
906
906
|
}
|
|
907
907
|
// ============================================================
|
|
908
908
|
// SEARCH - Vector similarity search
|
|
@@ -920,7 +920,7 @@ var StowServer = class {
|
|
|
920
920
|
}
|
|
921
921
|
searchSimilar(params) {
|
|
922
922
|
const bucket = this.resolveBucket(params.bucket);
|
|
923
|
-
return this.request("/
|
|
923
|
+
return this.request("/search/similar", {
|
|
924
924
|
method: "POST",
|
|
925
925
|
headers: { "Content-Type": "application/json" },
|
|
926
926
|
body: JSON.stringify({
|
|
@@ -939,7 +939,7 @@ var StowServer = class {
|
|
|
939
939
|
}
|
|
940
940
|
searchDiverse(params) {
|
|
941
941
|
const bucket = this.resolveBucket(params.bucket);
|
|
942
|
-
return this.request("/
|
|
942
|
+
return this.request("/search/diverse", {
|
|
943
943
|
method: "POST",
|
|
944
944
|
headers: { "Content-Type": "application/json" },
|
|
945
945
|
body: JSON.stringify({
|
|
@@ -959,7 +959,7 @@ var StowServer = class {
|
|
|
959
959
|
}
|
|
960
960
|
searchText(params) {
|
|
961
961
|
const bucket = this.resolveBucket(params.bucket);
|
|
962
|
-
return this.request("/
|
|
962
|
+
return this.request("/search/text", {
|
|
963
963
|
method: "POST",
|
|
964
964
|
headers: { "Content-Type": "application/json" },
|
|
965
965
|
body: JSON.stringify({
|
|
@@ -974,7 +974,7 @@ var StowServer = class {
|
|
|
974
974
|
}
|
|
975
975
|
searchColor(params) {
|
|
976
976
|
const bucket = this.resolveBucket(params.bucket);
|
|
977
|
-
return this.request("/
|
|
977
|
+
return this.request("/search/color", {
|
|
978
978
|
method: "POST",
|
|
979
979
|
headers: { "Content-Type": "application/json" },
|
|
980
980
|
body: JSON.stringify({
|
|
@@ -1007,7 +1007,7 @@ var StowServer = class {
|
|
|
1007
1007
|
const contentType = options?.contentType || "application/octet-stream";
|
|
1008
1008
|
const filename = options?.filename || "file";
|
|
1009
1009
|
const buffer = Buffer.isBuffer(file) ? file : Buffer.from(await file.arrayBuffer());
|
|
1010
|
-
const presign = await this.request("/
|
|
1010
|
+
const presign = await this.request("/drops/presign", {
|
|
1011
1011
|
method: "POST",
|
|
1012
1012
|
headers: { "Content-Type": "application/json" },
|
|
1013
1013
|
body: JSON.stringify({
|
|
@@ -1025,7 +1025,7 @@ var StowServer = class {
|
|
|
1025
1025
|
throw new StowError("Failed to upload to storage", putRes.status);
|
|
1026
1026
|
}
|
|
1027
1027
|
return this.request(
|
|
1028
|
-
presign.confirmUrl || "/
|
|
1028
|
+
presign.confirmUrl || "/drops/presign/confirm",
|
|
1029
1029
|
{
|
|
1030
1030
|
method: "POST",
|
|
1031
1031
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1045,13 +1045,13 @@ var StowServer = class {
|
|
|
1045
1045
|
* List all drops for the authenticated user
|
|
1046
1046
|
*/
|
|
1047
1047
|
listDrops() {
|
|
1048
|
-
return this.request("/
|
|
1048
|
+
return this.request("/drops", { method: "GET" }, listDropsSchema);
|
|
1049
1049
|
}
|
|
1050
1050
|
/**
|
|
1051
1051
|
* Delete a drop by ID
|
|
1052
1052
|
*/
|
|
1053
1053
|
async deleteDrop(id) {
|
|
1054
|
-
await this.request(`/
|
|
1054
|
+
await this.request(`/drops/${encodeURIComponent(id)}`, {
|
|
1055
1055
|
method: "DELETE"
|
|
1056
1056
|
});
|
|
1057
1057
|
}
|
|
@@ -1064,89 +1064,80 @@ var StowServer = class {
|
|
|
1064
1064
|
get profiles() {
|
|
1065
1065
|
return {
|
|
1066
1066
|
create: (params) => this.createProfile(params),
|
|
1067
|
-
get: (id) => this.getProfile(id),
|
|
1068
|
-
delete: (id) => this.deleteProfile(id),
|
|
1067
|
+
get: (id, bucket) => this.getProfile(id, bucket),
|
|
1068
|
+
delete: (id, bucket) => this.deleteProfile(id, bucket),
|
|
1069
1069
|
addFiles: (id, fileKeys, bucket) => this.addProfileFiles(id, fileKeys, bucket),
|
|
1070
1070
|
removeFiles: (id, fileKeys, bucket) => this.removeProfileFiles(id, fileKeys, bucket),
|
|
1071
1071
|
signal: (id, signals, bucket) => this.signalProfile(id, signals, bucket),
|
|
1072
|
-
deleteSignals: (id, signalIds) => this.deleteProfileSignals(id, signalIds),
|
|
1073
|
-
clusters: (id) => this.getProfileClusters(id),
|
|
1074
|
-
recluster: (id, params) => this.reclusterProfile(id, params),
|
|
1075
|
-
renameCluster: (profileId, clusterId, params) => this.renameProfileCluster(profileId, clusterId, params)
|
|
1072
|
+
deleteSignals: (id, signalIds, bucket) => this.deleteProfileSignals(id, signalIds, bucket),
|
|
1073
|
+
clusters: (id, bucket) => this.getProfileClusters(id, bucket),
|
|
1074
|
+
recluster: (id, params, bucket) => this.reclusterProfile(id, params, bucket),
|
|
1075
|
+
renameCluster: (profileId, clusterId, params, bucket) => this.renameProfileCluster(profileId, clusterId, params, bucket)
|
|
1076
1076
|
};
|
|
1077
1077
|
}
|
|
1078
1078
|
createProfile(params) {
|
|
1079
1079
|
return this.request(
|
|
1080
|
-
"/
|
|
1080
|
+
this.withBucket("/profiles", params?.bucket),
|
|
1081
1081
|
{
|
|
1082
1082
|
method: "POST",
|
|
1083
1083
|
headers: { "Content-Type": "application/json" },
|
|
1084
1084
|
body: JSON.stringify({
|
|
1085
1085
|
...params?.name ? { name: params.name } : {},
|
|
1086
|
-
...params?.fileKeys ? { fileKeys: params.fileKeys } : {}
|
|
1087
|
-
...params?.bucket ? { bucket: params.bucket } : {}
|
|
1086
|
+
...params?.fileKeys ? { fileKeys: params.fileKeys } : {}
|
|
1088
1087
|
})
|
|
1089
1088
|
},
|
|
1090
1089
|
profileResultSchema
|
|
1091
1090
|
);
|
|
1092
1091
|
}
|
|
1093
|
-
getProfile(id) {
|
|
1092
|
+
getProfile(id, bucket) {
|
|
1094
1093
|
return this.request(
|
|
1095
|
-
`/
|
|
1094
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}`, bucket),
|
|
1096
1095
|
{ method: "GET" },
|
|
1097
1096
|
profileResultSchema
|
|
1098
1097
|
);
|
|
1099
1098
|
}
|
|
1100
|
-
async deleteProfile(id) {
|
|
1101
|
-
await this.request(
|
|
1102
|
-
|
|
1103
|
-
|
|
1099
|
+
async deleteProfile(id, bucket) {
|
|
1100
|
+
await this.request(
|
|
1101
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}`, bucket),
|
|
1102
|
+
{ method: "DELETE" }
|
|
1103
|
+
);
|
|
1104
1104
|
}
|
|
1105
1105
|
addProfileFiles(id, fileKeys, bucket) {
|
|
1106
1106
|
return this.request(
|
|
1107
|
-
`/
|
|
1107
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/files`, bucket),
|
|
1108
1108
|
{
|
|
1109
1109
|
method: "POST",
|
|
1110
1110
|
headers: { "Content-Type": "application/json" },
|
|
1111
|
-
body: JSON.stringify({
|
|
1112
|
-
fileKeys,
|
|
1113
|
-
...bucket ? { bucket } : {}
|
|
1114
|
-
})
|
|
1111
|
+
body: JSON.stringify({ fileKeys })
|
|
1115
1112
|
},
|
|
1116
1113
|
profileFilesResultSchema
|
|
1117
1114
|
);
|
|
1118
1115
|
}
|
|
1119
1116
|
removeProfileFiles(id, fileKeys, bucket) {
|
|
1120
1117
|
return this.request(
|
|
1121
|
-
`/
|
|
1118
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/files`, bucket),
|
|
1122
1119
|
{
|
|
1123
1120
|
method: "DELETE",
|
|
1124
1121
|
headers: { "Content-Type": "application/json" },
|
|
1125
|
-
body: JSON.stringify({
|
|
1126
|
-
fileKeys,
|
|
1127
|
-
...bucket ? { bucket } : {}
|
|
1128
|
-
})
|
|
1122
|
+
body: JSON.stringify({ fileKeys })
|
|
1129
1123
|
},
|
|
1130
1124
|
profileFilesResultSchema
|
|
1131
1125
|
);
|
|
1132
1126
|
}
|
|
1133
1127
|
signalProfile(id, signals, bucket) {
|
|
1134
1128
|
return this.request(
|
|
1135
|
-
`/
|
|
1129
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/signals`, bucket),
|
|
1136
1130
|
{
|
|
1137
1131
|
method: "POST",
|
|
1138
1132
|
headers: { "Content-Type": "application/json" },
|
|
1139
|
-
body: JSON.stringify({
|
|
1140
|
-
signals,
|
|
1141
|
-
...bucket ? { bucket } : {}
|
|
1142
|
-
})
|
|
1133
|
+
body: JSON.stringify({ signals })
|
|
1143
1134
|
},
|
|
1144
1135
|
profileSignalsResponseSchema
|
|
1145
1136
|
);
|
|
1146
1137
|
}
|
|
1147
|
-
deleteProfileSignals(id, signalIds) {
|
|
1138
|
+
deleteProfileSignals(id, signalIds, bucket) {
|
|
1148
1139
|
return this.request(
|
|
1149
|
-
`/
|
|
1140
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/signals`, bucket),
|
|
1150
1141
|
{
|
|
1151
1142
|
method: "DELETE",
|
|
1152
1143
|
headers: { "Content-Type": "application/json" },
|
|
@@ -1155,23 +1146,30 @@ var StowServer = class {
|
|
|
1155
1146
|
deleteProfileSignalsResponseSchema
|
|
1156
1147
|
);
|
|
1157
1148
|
}
|
|
1158
|
-
getProfileClusters(id) {
|
|
1159
|
-
return this.request(
|
|
1160
|
-
|
|
1161
|
-
|
|
1149
|
+
getProfileClusters(id, bucket) {
|
|
1150
|
+
return this.request(
|
|
1151
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/clusters`, bucket),
|
|
1152
|
+
{ method: "GET" }
|
|
1153
|
+
);
|
|
1162
1154
|
}
|
|
1163
|
-
reclusterProfile(id, params) {
|
|
1164
|
-
return this.request(
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1155
|
+
reclusterProfile(id, params, bucket) {
|
|
1156
|
+
return this.request(
|
|
1157
|
+
this.withBucket(`/profiles/${encodeURIComponent(id)}/clusters`, bucket),
|
|
1158
|
+
{
|
|
1159
|
+
method: "POST",
|
|
1160
|
+
headers: { "Content-Type": "application/json" },
|
|
1161
|
+
body: JSON.stringify({
|
|
1162
|
+
...params?.clusterCount !== void 0 ? { clusterCount: params.clusterCount } : {}
|
|
1163
|
+
})
|
|
1164
|
+
}
|
|
1165
|
+
);
|
|
1171
1166
|
}
|
|
1172
|
-
renameProfileCluster(profileId, clusterId, params) {
|
|
1167
|
+
renameProfileCluster(profileId, clusterId, params, bucket) {
|
|
1173
1168
|
return this.request(
|
|
1174
|
-
|
|
1169
|
+
this.withBucket(
|
|
1170
|
+
`/profiles/${encodeURIComponent(profileId)}/clusters/${encodeURIComponent(clusterId)}`,
|
|
1171
|
+
bucket
|
|
1172
|
+
),
|
|
1175
1173
|
{
|
|
1176
1174
|
method: "PUT",
|
|
1177
1175
|
headers: { "Content-Type": "application/json" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howells/stow-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Server-side SDK for Stow file storage",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,21 +29,21 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
34
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
35
|
-
"test": "vitest run",
|
|
36
|
-
"test:watch": "vitest"
|
|
37
|
-
},
|
|
38
32
|
"peerDependencies": {
|
|
39
33
|
"zod": "^3.0.0 || ^4.0.0"
|
|
40
34
|
},
|
|
41
35
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@types/node": "^25.3.0",
|
|
36
|
+
"@types/node": "^25.5.0",
|
|
44
37
|
"tsup": "^8.5.1",
|
|
45
38
|
"typescript": "^5.9.3",
|
|
46
|
-
"vitest": "^4.0
|
|
47
|
-
"zod": "^4.3.6"
|
|
39
|
+
"vitest": "^4.1.0",
|
|
40
|
+
"zod": "^4.3.6",
|
|
41
|
+
"@stow/typescript-config": "0.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
45
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|