@voyantjs/cloud-sdk 0.4.0 → 0.5.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/README.md +48 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/search.d.ts +66 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +72 -0
- package/package.json +12 -3
package/README.md
CHANGED
|
@@ -14,6 +14,8 @@ Public TypeScript client for Voyant Cloud APIs.
|
|
|
14
14
|
long-running crawls and keep-alive Puppeteer sessions)
|
|
15
15
|
- video (manage uploads, playback, captions, watermarks, signed playback
|
|
16
16
|
tokens; create videos from a public URL)
|
|
17
|
+
- search (`createSearchClientConfig` returns a Typesense client config pointed
|
|
18
|
+
at the Voyant search proxy)
|
|
17
19
|
|
|
18
20
|
## Install
|
|
19
21
|
|
|
@@ -44,6 +46,7 @@ Root groups:
|
|
|
44
46
|
- `email`
|
|
45
47
|
- `browser`
|
|
46
48
|
- `video`
|
|
49
|
+
- `search` (standalone `createSearchClientConfig` export, not on the client)
|
|
47
50
|
|
|
48
51
|
The `vault` group covers list-vaults, list-secrets, and get-secret routes.
|
|
49
52
|
|
|
@@ -83,6 +86,49 @@ await client.browser.sessions.runCommands(session.id, {
|
|
|
83
86
|
await client.browser.sessions.close(session.id);
|
|
84
87
|
```
|
|
85
88
|
|
|
89
|
+
The `search` surface is a config helper, not a wrapped client. Voyant's
|
|
90
|
+
search proxy speaks the Typesense HTTP protocol, so `createSearchClientConfig`
|
|
91
|
+
hands back a config you pass straight to the official `typesense` package:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { Client } from "typesense";
|
|
95
|
+
import { createSearchClientConfig } from "@voyantjs/cloud-sdk";
|
|
96
|
+
|
|
97
|
+
const search = new Client(
|
|
98
|
+
createSearchClientConfig({
|
|
99
|
+
apiKey: process.env.VOYANT_API_KEY!,
|
|
100
|
+
organizationSlug: "acme",
|
|
101
|
+
projectName: "catalog",
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
await search.collections().create({
|
|
106
|
+
name: "products",
|
|
107
|
+
fields: [
|
|
108
|
+
{ name: "name", type: "string" },
|
|
109
|
+
{ name: "tags", type: "string[]", facet: true },
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
await search
|
|
114
|
+
.collections("products")
|
|
115
|
+
.documents()
|
|
116
|
+
.import([{ id: "1", name: "Sneakers", tags: ["shoes"] }], {
|
|
117
|
+
action: "upsert",
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const hits = await search
|
|
121
|
+
.collections("products")
|
|
122
|
+
.documents()
|
|
123
|
+
.search({ q: "sneak", query_by: "name,tags" });
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`apiKey` is your Voyant API token (`search:read` for queries,
|
|
127
|
+
`search:write` for writes). The proxy auths with `Authorization: Bearer ...`,
|
|
128
|
+
substitutes the project's scoped Typesense key downstream, and rewrites
|
|
129
|
+
collection names so isolation prefixes never leak into your code. `typesense`
|
|
130
|
+
is a peer requirement — install it alongside the SDK if you use search.
|
|
131
|
+
|
|
86
132
|
The `video` group covers the Voyant video service: `videos.{list, get,
|
|
87
133
|
createUpload, createFromUrl, update, delete, enableDownload, mintToken}`,
|
|
88
134
|
captions under `videos.captions.{list, upload, generate, delete}`, and
|
|
@@ -127,6 +173,7 @@ Useful exported types include:
|
|
|
127
173
|
`GenerateVideoCaptionInput`, `CreateVideoWatermarkInput`,
|
|
128
174
|
`VideoStatus`, `VideoCaptionStatus`, `VideoDownloadStatus`,
|
|
129
175
|
`VideoWatermarkPosition`
|
|
176
|
+
- `SearchClientConfig`, `SearchClientConfigOptions`
|
|
130
177
|
- `PhoneNumberStatus`, `SmsMessageStatus`, `VerificationChannel`,
|
|
131
178
|
`VerificationAttemptStatus`, `EmailMessageStatus`,
|
|
132
179
|
`BrowserSessionStatus`, `BrowserJobStatus`
|
|
@@ -141,7 +188,7 @@ Useful exported types include:
|
|
|
141
188
|
`verification:read`, `emails:read`, `emails:send`, `browser:render`,
|
|
142
189
|
`browser:scrape`, `browser:extract`, `browser:crawl`, `browser:sessions`,
|
|
143
190
|
`video:read`, `video:upload`, `video:delete`, `video:captions:write`,
|
|
144
|
-
`video:watermarks:write`);
|
|
191
|
+
`video:watermarks:write`, `search:read`, `search:write`);
|
|
145
192
|
requests fail with `403` if the token does not include the required scope
|
|
146
193
|
|
|
147
194
|
For repo-level context, see [../../docs/cloud.md](../../docs/cloud.md).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { createVoyantCloudClient, VoyantCloudClient } from "./client.js";
|
|
2
|
+
export { createSearchClientConfig } from "./search.js";
|
|
3
|
+
export type { SearchClientConfig, SearchClientConfigOptions, } from "./search.js";
|
|
2
4
|
export type { BrowserCommand, BrowserCommandResult, BrowserCookie, BrowserCrawlSummary, BrowserGoToOptions, BrowserJobKind, BrowserJobStatus, BrowserJsonInput, BrowserLink, BrowserPdfInput, BrowserPdfOptions, BrowserRenderInput, BrowserSameSite, BrowserScrapeElement, BrowserScrapeInput, BrowserScrapeResult, BrowserScreenshotInput, BrowserScreenshotOptions, BrowserSessionStatus, BrowserSessionSummary, BrowserSnapshotResult, BrowserViewport, BrowserWaitForSelector, BrowserWaitUntil, CheckVerificationInput, CreateVideoFromUrlInput, CreateVideoUploadInput, CreateVideoWatermarkInput, EmailMessageStatus, EmailMessageSummary, GenerateVideoCaptionInput, MintVideoSignedTokenInput, OpenBrowserSessionInput, PhoneNumberCapabilities, PhoneNumberStatus, PhoneNumberSummary, RunBrowserCommandsInput, RunBrowserCommandsResult, SendEmailAttachment, SendEmailInput, SendSmsInput, SmsMessageStatus, SmsMessageSummary, StartBrowserCrawlInput, StartBrowserCrawlResult, StartVerificationInput, UpdateVideoInput, UploadVideoCaptionInput, VaultSecretSummary, VaultSecretValue, VaultSummary, VerificationAttemptStatus, VerificationAttemptSummary, VerificationChannel, VerificationCheckResult, VideoCaptionStatus, VideoCaptionSummary, VideoDownloadStatus, VideoSignedToken, VideoStatus, VideoSummary, VideoUploadTicket, VideoWatermarkPosition, VideoWatermarkProfileSummary, VoyantCloudClientOptions, } from "./types.js";
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzE,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration helper for the Voyant search surface.
|
|
3
|
+
*
|
|
4
|
+
* Voyant's search-api is a thin proxy in front of Typesense. It auths
|
|
5
|
+
* incoming requests against a Voyant API token, picks the right scoped
|
|
6
|
+
* Typesense key (read or write) server-side, and rewrites collection
|
|
7
|
+
* names so customers never see our internal isolation prefix.
|
|
8
|
+
*
|
|
9
|
+
* The wire protocol is pure Typesense, so we don't ship a hand-rolled
|
|
10
|
+
* SDK surface for it. Instead, this helper produces a config object
|
|
11
|
+
* that you pass directly to the official `typesense` client:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Client } from "typesense";
|
|
15
|
+
* import { createSearchClientConfig } from "@voyantjs/cloud-sdk";
|
|
16
|
+
*
|
|
17
|
+
* const search = new Client(createSearchClientConfig({
|
|
18
|
+
* apiKey: process.env.VOYANT_API_TOKEN!,
|
|
19
|
+
* organizationSlug: "acme",
|
|
20
|
+
* projectName: "catalog",
|
|
21
|
+
* }));
|
|
22
|
+
*
|
|
23
|
+
* await search.collections().create({
|
|
24
|
+
* name: "products",
|
|
25
|
+
* fields: [{ name: "name", type: "string" }],
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* `apiKey` here is your Voyant API token — it is sent as
|
|
30
|
+
* `Authorization: Bearer ...`. The proxy strips Typesense's own
|
|
31
|
+
* `X-TYPESENSE-API-KEY` header from inbound requests and injects the
|
|
32
|
+
* project's scoped key downstream.
|
|
33
|
+
*/
|
|
34
|
+
export interface SearchClientConfigOptions {
|
|
35
|
+
/** Voyant API token with `search:read` (queries) or `search:write` (writes) scope. */
|
|
36
|
+
apiKey: string;
|
|
37
|
+
/** Organization slug — the first path segment in the search URL. */
|
|
38
|
+
organizationSlug: string;
|
|
39
|
+
/** Search project name — the second path segment in the search URL. */
|
|
40
|
+
projectName: string;
|
|
41
|
+
/** Override the default `search.voyantjs.com` host (e.g. for local dev). */
|
|
42
|
+
host?: string;
|
|
43
|
+
/** Override the default port. */
|
|
44
|
+
port?: number;
|
|
45
|
+
/** Override the default `https` protocol. */
|
|
46
|
+
protocol?: string;
|
|
47
|
+
/** Additional headers to merge with `Authorization`. */
|
|
48
|
+
additionalHeaders?: Record<string, string>;
|
|
49
|
+
}
|
|
50
|
+
export interface SearchClientConfig {
|
|
51
|
+
apiKey: string;
|
|
52
|
+
nodes: Array<{
|
|
53
|
+
host: string;
|
|
54
|
+
port: number;
|
|
55
|
+
protocol: string;
|
|
56
|
+
path: string;
|
|
57
|
+
}>;
|
|
58
|
+
additionalHeaders: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a Typesense client configuration that targets the Voyant
|
|
62
|
+
* search proxy. Pass the returned object straight to
|
|
63
|
+
* `new Typesense.Client(...)`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function createSearchClientConfig(options: SearchClientConfigOptions): SearchClientConfig;
|
|
66
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,MAAM,WAAW,yBAAyB;IACxC,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,gBAAgB,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,kBAAkB,CA0CpB"}
|
package/dist/search.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration helper for the Voyant search surface.
|
|
3
|
+
*
|
|
4
|
+
* Voyant's search-api is a thin proxy in front of Typesense. It auths
|
|
5
|
+
* incoming requests against a Voyant API token, picks the right scoped
|
|
6
|
+
* Typesense key (read or write) server-side, and rewrites collection
|
|
7
|
+
* names so customers never see our internal isolation prefix.
|
|
8
|
+
*
|
|
9
|
+
* The wire protocol is pure Typesense, so we don't ship a hand-rolled
|
|
10
|
+
* SDK surface for it. Instead, this helper produces a config object
|
|
11
|
+
* that you pass directly to the official `typesense` client:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { Client } from "typesense";
|
|
15
|
+
* import { createSearchClientConfig } from "@voyantjs/cloud-sdk";
|
|
16
|
+
*
|
|
17
|
+
* const search = new Client(createSearchClientConfig({
|
|
18
|
+
* apiKey: process.env.VOYANT_API_TOKEN!,
|
|
19
|
+
* organizationSlug: "acme",
|
|
20
|
+
* projectName: "catalog",
|
|
21
|
+
* }));
|
|
22
|
+
*
|
|
23
|
+
* await search.collections().create({
|
|
24
|
+
* name: "products",
|
|
25
|
+
* fields: [{ name: "name", type: "string" }],
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* `apiKey` here is your Voyant API token — it is sent as
|
|
30
|
+
* `Authorization: Bearer ...`. The proxy strips Typesense's own
|
|
31
|
+
* `X-TYPESENSE-API-KEY` header from inbound requests and injects the
|
|
32
|
+
* project's scoped key downstream.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_SEARCH_HOST = "search.voyantjs.com";
|
|
35
|
+
const DEFAULT_SEARCH_PORT = 443;
|
|
36
|
+
const DEFAULT_SEARCH_PROTOCOL = "https";
|
|
37
|
+
/**
|
|
38
|
+
* Build a Typesense client configuration that targets the Voyant
|
|
39
|
+
* search proxy. Pass the returned object straight to
|
|
40
|
+
* `new Typesense.Client(...)`.
|
|
41
|
+
*/
|
|
42
|
+
export function createSearchClientConfig(options) {
|
|
43
|
+
const { apiKey, organizationSlug, projectName, host = DEFAULT_SEARCH_HOST, port = DEFAULT_SEARCH_PORT, protocol = DEFAULT_SEARCH_PROTOCOL, additionalHeaders, } = options;
|
|
44
|
+
if (!apiKey) {
|
|
45
|
+
throw new Error("createSearchClientConfig: `apiKey` is required.");
|
|
46
|
+
}
|
|
47
|
+
if (!organizationSlug) {
|
|
48
|
+
throw new Error("createSearchClientConfig: `organizationSlug` is required.");
|
|
49
|
+
}
|
|
50
|
+
if (!projectName) {
|
|
51
|
+
throw new Error("createSearchClientConfig: `projectName` is required.");
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
// typesense-js requires `apiKey`. The proxy strips the
|
|
55
|
+
// X-TYPESENSE-API-KEY header it adds and uses our bearer token
|
|
56
|
+
// instead, so this value is ignored downstream — but it must be
|
|
57
|
+
// a non-empty string for the client to construct.
|
|
58
|
+
apiKey: "voyant-bearer",
|
|
59
|
+
nodes: [
|
|
60
|
+
{
|
|
61
|
+
host,
|
|
62
|
+
port,
|
|
63
|
+
protocol,
|
|
64
|
+
path: `/${organizationSlug}/${projectName}`,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
additionalHeaders: {
|
|
68
|
+
...additionalHeaders,
|
|
69
|
+
Authorization: `Bearer ${apiKey}`,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/cloud-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Public TypeScript SDK for Voyant Cloud APIs.",
|
|
5
5
|
"license": "FSL-1.1-Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -37,11 +37,20 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@voyant-sdk/sdk-core": "0.2.0"
|
|
39
39
|
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"typesense": "^2.0.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"typesense": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
40
48
|
"devDependencies": {
|
|
41
49
|
"eslint": "^9.39.1",
|
|
42
50
|
"typescript": "5.9.2",
|
|
43
|
-
"
|
|
44
|
-
"@voyant-sdk/typescript-config": "0.0.0"
|
|
51
|
+
"typesense": "^2.0.0",
|
|
52
|
+
"@voyant-sdk/typescript-config": "0.0.0",
|
|
53
|
+
"@voyant-sdk/eslint-config": "0.0.0"
|
|
45
54
|
},
|
|
46
55
|
"publishConfig": {
|
|
47
56
|
"access": "public"
|