@sapiom/tools 0.7.0 → 0.8.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/CHANGELOG.md +29 -0
- package/README.md +10 -9
- package/dist/cjs/client.d.ts +28 -2
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +12 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/content-generation/index.d.ts +64 -1
- package/dist/cjs/content-generation/index.d.ts.map +1 -1
- package/dist/cjs/content-generation/index.js +129 -5
- package/dist/cjs/content-generation/index.js.map +1 -1
- package/dist/cjs/database/errors.d.ts +16 -0
- package/dist/cjs/database/errors.d.ts.map +1 -0
- package/dist/cjs/database/errors.js +36 -0
- package/dist/cjs/database/errors.js.map +1 -0
- package/dist/cjs/database/index.d.ts +101 -0
- package/dist/cjs/database/index.d.ts.map +1 -0
- package/dist/cjs/database/index.js +118 -0
- package/dist/cjs/database/index.js.map +1 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +12 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/search/index.d.ts +132 -3
- package/dist/cjs/search/index.d.ts.map +1 -1
- package/dist/cjs/search/index.js +160 -3
- package/dist/cjs/search/index.js.map +1 -1
- package/dist/cjs/stub/index.d.ts.map +1 -1
- package/dist/cjs/stub/index.js +112 -2
- package/dist/cjs/stub/index.js.map +1 -1
- package/dist/esm/client.d.ts +28 -2
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +13 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/content-generation/index.d.ts +64 -1
- package/dist/esm/content-generation/index.d.ts.map +1 -1
- package/dist/esm/content-generation/index.js +126 -4
- package/dist/esm/content-generation/index.js.map +1 -1
- package/dist/esm/database/errors.d.ts +16 -0
- package/dist/esm/database/errors.d.ts.map +1 -0
- package/dist/esm/database/errors.js +31 -0
- package/dist/esm/database/errors.js.map +1 -0
- package/dist/esm/database/index.d.ts +101 -0
- package/dist/esm/database/index.d.ts.map +1 -0
- package/dist/esm/database/index.js +113 -0
- package/dist/esm/database/index.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/index.d.ts +132 -3
- package/dist/esm/search/index.d.ts.map +1 -1
- package/dist/esm/search/index.js +157 -3
- package/dist/esm/search/index.js.map +1 -1
- package/dist/esm/stub/index.d.ts.map +1 -1
- package/dist/esm/stub/index.js +112 -2
- package/dist/esm/stub/index.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +6 -1
- package/src/content-generation/README.md +67 -0
- package/src/database/README.md +62 -0
- package/src/search/README.md +130 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `database` capability — provision an on-demand Postgres database, retrieve it,
|
|
3
|
+
* and delete it. You get back direct connection credentials, so you can connect
|
|
4
|
+
* with any standard Postgres client or driver.
|
|
5
|
+
*
|
|
6
|
+
* import { database } from "@sapiom/tools"; // ambient auth
|
|
7
|
+
* const db = await database.create({ duration: "1h", handle: "analytics" });
|
|
8
|
+
* db.connection?.connectionString; // a ready-to-use Postgres URI
|
|
9
|
+
*
|
|
10
|
+
* const again = await database.get(db.id); // or get("analytics") by handle
|
|
11
|
+
* await database.delete(db.id); // or delete("analytics")
|
|
12
|
+
*
|
|
13
|
+
* Or via an explicit client: `createClient({ apiKey }).database.create(...)`.
|
|
14
|
+
*
|
|
15
|
+
* This is a provisioning surface, not a query layer: it hands you connection
|
|
16
|
+
* credentials and you run your own SQL with the client of your choice.
|
|
17
|
+
*/
|
|
18
|
+
import { Transport } from "../_client/index.js";
|
|
19
|
+
import { DatabaseHttpError } from "./errors.js";
|
|
20
|
+
export { DatabaseHttpError };
|
|
21
|
+
/** How long the database lives before it is automatically removed. */
|
|
22
|
+
export type DatabaseDuration = "15m" | "1h" | "4h" | "24h" | "7d";
|
|
23
|
+
/** Lifecycle state of a database. */
|
|
24
|
+
export type DatabaseStatus = "provisioning" | "active" | "expired" | "deleting" | "deleted";
|
|
25
|
+
export interface CreateDatabaseInput {
|
|
26
|
+
/** How long the database lives before it is automatically removed (required). */
|
|
27
|
+
duration: DatabaseDuration;
|
|
28
|
+
/**
|
|
29
|
+
* Optional stable, human-friendly key you can use to look the database up later
|
|
30
|
+
* (`get(handle)` / `delete(handle)`). 3–63 chars, `^[a-z0-9][a-z0-9-]*[a-z0-9]$`.
|
|
31
|
+
* Unique within your tenant.
|
|
32
|
+
*/
|
|
33
|
+
handle?: string;
|
|
34
|
+
/** Optional display name. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** Optional description (up to 500 chars). */
|
|
37
|
+
description?: string;
|
|
38
|
+
/** Optional region to provision in. Defaults to a US region. */
|
|
39
|
+
region?: string;
|
|
40
|
+
/** Optional Postgres major version. Defaults to the latest supported. */
|
|
41
|
+
pgVersion?: 15 | 16 | 17;
|
|
42
|
+
}
|
|
43
|
+
export interface DatabaseConnection {
|
|
44
|
+
/**
|
|
45
|
+
* The full Postgres connection URI — pass this to any Postgres client. This is
|
|
46
|
+
* the canonical value and is always present; the component fields below are
|
|
47
|
+
* parsed from it on a best-effort basis and may be absent if it can't be parsed.
|
|
48
|
+
*/
|
|
49
|
+
connectionString: string;
|
|
50
|
+
/** Database host. */
|
|
51
|
+
host?: string;
|
|
52
|
+
/** Database port. */
|
|
53
|
+
port?: number;
|
|
54
|
+
/** Database user. */
|
|
55
|
+
username?: string;
|
|
56
|
+
/** Database password. */
|
|
57
|
+
password?: string;
|
|
58
|
+
/** Name of the database to connect to. */
|
|
59
|
+
databaseName?: string;
|
|
60
|
+
/** SSL mode from the connection URI, when present (e.g. "require"). */
|
|
61
|
+
sslmode?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface Database {
|
|
64
|
+
/** Unique database identifier. */
|
|
65
|
+
id: string;
|
|
66
|
+
/** The handle you set at creation, or `null` if none was given. */
|
|
67
|
+
handle: string | null;
|
|
68
|
+
/** Display name, or `null`. */
|
|
69
|
+
name: string | null;
|
|
70
|
+
/** Description, or `null`. */
|
|
71
|
+
description: string | null;
|
|
72
|
+
/** Lifecycle state. */
|
|
73
|
+
status: DatabaseStatus;
|
|
74
|
+
/** Region the database is provisioned in. */
|
|
75
|
+
region: string;
|
|
76
|
+
/** Postgres major version. */
|
|
77
|
+
pgVersion: number;
|
|
78
|
+
/** The lifetime the database was created with. */
|
|
79
|
+
duration: DatabaseDuration | string;
|
|
80
|
+
/** Connection credentials — `null` while the database is still being provisioned. */
|
|
81
|
+
connection: DatabaseConnection | null;
|
|
82
|
+
/** ISO-8601 timestamp when the database expires, or `null`. */
|
|
83
|
+
expiresAt: string | null;
|
|
84
|
+
/** ISO-8601 timestamp when the database was created. */
|
|
85
|
+
createdAt: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Provision a new Postgres database. `duration` is required. Returns the database
|
|
89
|
+
* with connection credentials in `connection`. Failed requests throw
|
|
90
|
+
* {@link DatabaseHttpError}.
|
|
91
|
+
*/
|
|
92
|
+
export declare function create(input: CreateDatabaseInput, transport?: Transport, baseUrl?: string): Promise<Database>;
|
|
93
|
+
/** Retrieve a database by its id or handle. */
|
|
94
|
+
export declare function get(idOrHandle: string, transport?: Transport, baseUrl?: string): Promise<Database>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete a database by its id or handle. Exported as `delete`:
|
|
97
|
+
* `import { database } from "@sapiom/tools"; await database.delete(id)`.
|
|
98
|
+
*/
|
|
99
|
+
declare function deleteDatabase(idOrHandle: string, transport?: Transport, baseUrl?: string): Promise<void>;
|
|
100
|
+
export { deleteDatabase as delete };
|
|
101
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","s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AAC;IACX,mEAAmE;IACnE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uBAAuB;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAAC;IACpC,qFAAqF;IACrF,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACtC,+DAA+D;IAC/D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;CACnB;AAoED;;;;GAIG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,mBAAmB,EAC1B,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,QAAQ,CAAC,CAuBnB;AAED,+CAA+C;AAC/C,wBAAsB,GAAG,CACvB,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,QAAQ,CAAC,CAQnB;AAED;;;GAGG;AACH,iBAAe,cAAc,CAC3B,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseHttpError = void 0;
|
|
4
|
+
exports.create = create;
|
|
5
|
+
exports.get = get;
|
|
6
|
+
exports.delete = deleteDatabase;
|
|
7
|
+
/**
|
|
8
|
+
* `database` capability — provision an on-demand Postgres database, retrieve it,
|
|
9
|
+
* and delete it. You get back direct connection credentials, so you can connect
|
|
10
|
+
* with any standard Postgres client or driver.
|
|
11
|
+
*
|
|
12
|
+
* import { database } from "@sapiom/tools"; // ambient auth
|
|
13
|
+
* const db = await database.create({ duration: "1h", handle: "analytics" });
|
|
14
|
+
* db.connection?.connectionString; // a ready-to-use Postgres URI
|
|
15
|
+
*
|
|
16
|
+
* const again = await database.get(db.id); // or get("analytics") by handle
|
|
17
|
+
* await database.delete(db.id); // or delete("analytics")
|
|
18
|
+
*
|
|
19
|
+
* Or via an explicit client: `createClient({ apiKey }).database.create(...)`.
|
|
20
|
+
*
|
|
21
|
+
* This is a provisioning surface, not a query layer: it hands you connection
|
|
22
|
+
* credentials and you run your own SQL with the client of your choice.
|
|
23
|
+
*/
|
|
24
|
+
const index_js_1 = require("../_client/index.js");
|
|
25
|
+
const errors_js_1 = require("./errors.js");
|
|
26
|
+
Object.defineProperty(exports, "DatabaseHttpError", { enumerable: true, get: function () { return errors_js_1.DatabaseHttpError; } });
|
|
27
|
+
const DEFAULT_BASE_URL = process.env.SAPIOM_DATABASE_URL || "https://neon.services.sapiom.ai";
|
|
28
|
+
/**
|
|
29
|
+
* Break a Postgres connection URI into its parts. `connectionString` is always
|
|
30
|
+
* preserved (it is the value you pass to a client); the parsed components are a
|
|
31
|
+
* convenience. If the URI can't be parsed, only `connectionString` is returned.
|
|
32
|
+
*/
|
|
33
|
+
function parseConnectionUri(uri) {
|
|
34
|
+
try {
|
|
35
|
+
const u = new URL(uri);
|
|
36
|
+
return {
|
|
37
|
+
connectionString: uri,
|
|
38
|
+
host: u.hostname,
|
|
39
|
+
port: u.port ? Number(u.port) : 5432,
|
|
40
|
+
username: decodeURIComponent(u.username),
|
|
41
|
+
password: decodeURIComponent(u.password),
|
|
42
|
+
databaseName: u.pathname.replace(/^\//, ""),
|
|
43
|
+
sslmode: u.searchParams.get("sslmode") ?? undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { connectionString: uri };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function mapDatabase(raw) {
|
|
51
|
+
return {
|
|
52
|
+
id: raw.id,
|
|
53
|
+
handle: raw.handle,
|
|
54
|
+
name: raw.name,
|
|
55
|
+
description: raw.description,
|
|
56
|
+
status: raw.status,
|
|
57
|
+
region: raw.region,
|
|
58
|
+
pgVersion: raw.pgVersion,
|
|
59
|
+
duration: raw.duration,
|
|
60
|
+
connection: raw.connectionUri == null ? null : parseConnectionUri(raw.connectionUri),
|
|
61
|
+
expiresAt: raw.expiresAt,
|
|
62
|
+
createdAt: raw.createdAt,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// ----- Capability operations -----
|
|
66
|
+
/**
|
|
67
|
+
* Provision a new Postgres database. `duration` is required. Returns the database
|
|
68
|
+
* with connection credentials in `connection`. Failed requests throw
|
|
69
|
+
* {@link DatabaseHttpError}.
|
|
70
|
+
*/
|
|
71
|
+
async function create(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
|
|
72
|
+
if (!input.duration) {
|
|
73
|
+
throw new errors_js_1.DatabaseHttpError("duration is required", 400, {
|
|
74
|
+
message: "duration is required",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const body = { duration: input.duration };
|
|
78
|
+
if (input.handle !== undefined)
|
|
79
|
+
body.handle = input.handle;
|
|
80
|
+
if (input.name !== undefined)
|
|
81
|
+
body.name = input.name;
|
|
82
|
+
if (input.description !== undefined)
|
|
83
|
+
body.description = input.description;
|
|
84
|
+
if (input.region !== undefined)
|
|
85
|
+
body.region = input.region;
|
|
86
|
+
if (input.pgVersion !== undefined)
|
|
87
|
+
body.pgVersion = input.pgVersion;
|
|
88
|
+
const res = await (0, errors_js_1.ensureOk)(await transport.fetch(`${baseUrl}/v1/databases`, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: { "content-type": "application/json" },
|
|
91
|
+
body: JSON.stringify(body),
|
|
92
|
+
}), "Failed to create database");
|
|
93
|
+
return mapDatabase((await res.json()));
|
|
94
|
+
}
|
|
95
|
+
/** Retrieve a database by its id or handle. */
|
|
96
|
+
async function get(idOrHandle, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
|
|
97
|
+
const res = await (0, errors_js_1.ensureOk)(await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`), `Failed to get database '${idOrHandle}'`);
|
|
98
|
+
return mapDatabase((await res.json()));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Delete a database by its id or handle. Exported as `delete`:
|
|
102
|
+
* `import { database } from "@sapiom/tools"; await database.delete(id)`.
|
|
103
|
+
*/
|
|
104
|
+
async function deleteDatabase(idOrHandle, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_BASE_URL) {
|
|
105
|
+
const res = await transport.fetch(`${baseUrl}/v1/databases/${encodeURIComponent(idOrHandle)}`, { method: "DELETE" });
|
|
106
|
+
if (!res.ok) {
|
|
107
|
+
const text = await res.text().catch(() => "");
|
|
108
|
+
let parsed;
|
|
109
|
+
try {
|
|
110
|
+
parsed = JSON.parse(text);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
parsed = text;
|
|
114
|
+
}
|
|
115
|
+
throw new errors_js_1.DatabaseHttpError(`Failed to delete database '${idOrHandle}': ${res.status} ${text}`, res.status, parsed);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/database/index.ts"],"names":[],"mappings":";;;AA8KA,wBA2BC;AAGD,kBAYC;AA+B0B,gCAAM;AAvPjC;;;;;;;;;;;;;;;;GAgBG;AACH,kDAAkE;AAClE,2CAA0D;AAEjD,kGAFU,6BAAiB,OAEV;AAE1B,MAAM,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ist/cjs/index.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export * as fileStorage from "./file-storage/index.js";
|
|
|
31
31
|
export { FileStorageHttpError } from "./file-storage/index.js";
|
|
32
32
|
export * as contentGeneration from "./content-generation/index.js";
|
|
33
33
|
export { ContentGenerationHttpError } from "./content-generation/index.js";
|
|
34
|
+
export { VIDEO_RESULT_SIGNAL } from "./content-generation/index.js";
|
|
35
|
+
export type { VideoResultPayload } from "./content-generation/index.js";
|
|
36
|
+
export { toVideoResumePayload } from "./content-generation/index.js";
|
|
34
37
|
export * as search from "./search/index.js";
|
|
35
38
|
export { SearchHttpError } from "./search/index.js";
|
|
39
|
+
export * as database from "./database/index.js";
|
|
40
|
+
export { DatabaseHttpError } from "./database/index.js";
|
|
36
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,YAAY,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;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D,YAAY,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,eAAe,EACf,oCAAoC,GACrC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,cAAc,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAGzE,YAAY,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.SearchHttpError = exports.search = exports.ContentGenerationHttpError = exports.contentGeneration = exports.FileStorageHttpError = exports.fileStorage = exports.OrchestrationResultSchemaError = exports.orchestrationResultSchema = exports.ORCHESTRATIONS_RESULT_SIGNAL = exports.orchestrations = exports.EXECUTION_ENVIRONMENT_BLAXEL_SANDBOX = exports.toResumePayload = exports.CodingResultSchemaError = exports.codingResultSchema = exports.CODING_RESULT_SIGNAL = exports.agent = exports.Repository = exports.repositories = exports.Sandbox = exports.sandboxes = exports.createClientFromEnv = exports.createClient = void 0;
|
|
36
|
+
exports.DatabaseHttpError = exports.database = exports.SearchHttpError = exports.search = exports.toVideoResumePayload = exports.VIDEO_RESULT_SIGNAL = exports.ContentGenerationHttpError = exports.contentGeneration = exports.FileStorageHttpError = exports.fileStorage = exports.OrchestrationResultSchemaError = exports.orchestrationResultSchema = exports.ORCHESTRATIONS_RESULT_SIGNAL = exports.orchestrations = exports.EXECUTION_ENVIRONMENT_BLAXEL_SANDBOX = exports.toResumePayload = exports.CodingResultSchemaError = exports.codingResultSchema = exports.CODING_RESULT_SIGNAL = exports.agent = exports.Repository = exports.repositories = exports.Sandbox = exports.sandboxes = exports.createClientFromEnv = exports.createClient = void 0;
|
|
37
37
|
/**
|
|
38
38
|
* `@sapiom/tools` — the typed Sapiom capability client.
|
|
39
39
|
*
|
|
@@ -81,7 +81,16 @@ Object.defineProperty(exports, "FileStorageHttpError", { enumerable: true, get:
|
|
|
81
81
|
exports.contentGeneration = __importStar(require("./content-generation/index.js"));
|
|
82
82
|
var index_js_8 = require("./content-generation/index.js");
|
|
83
83
|
Object.defineProperty(exports, "ContentGenerationHttpError", { enumerable: true, get: function () { return index_js_8.ContentGenerationHttpError; } });
|
|
84
|
+
// Surfaced top-level for the static `pause: { signal }` decl on a workflow step.
|
|
85
|
+
var index_js_9 = require("./content-generation/index.js");
|
|
86
|
+
Object.defineProperty(exports, "VIDEO_RESULT_SIGNAL", { enumerable: true, get: function () { return index_js_9.VIDEO_RESULT_SIGNAL; } });
|
|
87
|
+
// Map a live VideoGenerationResult to the wire shape the resumed step receives.
|
|
88
|
+
var index_js_10 = require("./content-generation/index.js");
|
|
89
|
+
Object.defineProperty(exports, "toVideoResumePayload", { enumerable: true, get: function () { return index_js_10.toVideoResumePayload; } });
|
|
84
90
|
exports.search = __importStar(require("./search/index.js"));
|
|
85
|
-
var
|
|
86
|
-
Object.defineProperty(exports, "SearchHttpError", { enumerable: true, get: function () { return
|
|
91
|
+
var index_js_11 = require("./search/index.js");
|
|
92
|
+
Object.defineProperty(exports, "SearchHttpError", { enumerable: true, get: function () { return index_js_11.SearchHttpError; } });
|
|
93
|
+
exports.database = __importStar(require("./database/index.js"));
|
|
94
|
+
var index_js_12 = require("./database/index.js");
|
|
95
|
+
Object.defineProperty(exports, "DatabaseHttpError", { enumerable: true, get: function () { return index_js_12.DatabaseHttpError; } });
|
|
87
96
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,yCAAgE;AAAvD,yGAAA,YAAY,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAQ1C,kEAAkD;AAClD,iDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAEhB,wEAAwD;AACxD,oDAAqD;AAA5C,sGAAA,UAAU,OAAA;AAEnB,0DAA0C;AAC1C,iFAAiF;AACjF,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA;AAO7B,+EAA+E;AAC/E,2CAA2C;AAC3C,6CAK0B;AAJxB,8GAAA,kBAAkB,OAAA;AAClB,mHAAA,uBAAuB,OAAA;AACvB,2GAAA,eAAe,OAAA;AACf,gIAAA,oCAAoC,OAAA;AAGtC,4EAA4D;AAC5D,iFAAiF;AACjF,sDAAyE;AAAhE,wHAAA,4BAA4B,OAAA;AAIrC,oEAAoE;AACpE,sDAGmC;AAFjC,qHAAA,yBAAyB,OAAA;AACzB,0HAAA,8BAA8B,OAAA;AAGhC,uEAAuD;AACvD,oDAA+D;AAAtD,gHAAA,oBAAoB,OAAA;AAE7B,mFAAmE;AACnE,0DAA2E;AAAlE,sHAAA,0BAA0B,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;GAYG;AACH,yCAAgE;AAAvD,yGAAA,YAAY,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAQ1C,kEAAkD;AAClD,iDAA+C;AAAtC,mGAAA,OAAO,OAAA;AAEhB,wEAAwD;AACxD,oDAAqD;AAA5C,sGAAA,UAAU,OAAA;AAEnB,0DAA0C;AAC1C,iFAAiF;AACjF,6CAAwD;AAA/C,gHAAA,oBAAoB,OAAA;AAO7B,+EAA+E;AAC/E,2CAA2C;AAC3C,6CAK0B;AAJxB,8GAAA,kBAAkB,OAAA;AAClB,mHAAA,uBAAuB,OAAA;AACvB,2GAAA,eAAe,OAAA;AACf,gIAAA,oCAAoC,OAAA;AAGtC,4EAA4D;AAC5D,iFAAiF;AACjF,sDAAyE;AAAhE,wHAAA,4BAA4B,OAAA;AAIrC,oEAAoE;AACpE,sDAGmC;AAFjC,qHAAA,yBAAyB,OAAA;AACzB,0HAAA,8BAA8B,OAAA;AAGhC,uEAAuD;AACvD,oDAA+D;AAAtD,gHAAA,oBAAoB,OAAA;AAE7B,mFAAmE;AACnE,0DAA2E;AAAlE,sHAAA,0BAA0B,OAAA;AACnC,iFAAiF;AACjF,0DAAoE;AAA3D,+GAAA,mBAAmB,OAAA;AAI5B,gFAAgF;AAChF,2DAAqE;AAA5D,iHAAA,oBAAoB,OAAA;AAE7B,4DAA4C;AAC5C,+CAAoD;AAA3C,4GAAA,eAAe,OAAA;AAExB,gEAAgD;AAChD,iDAAwD;AAA/C,8GAAA,iBAAiB,OAAA"}
|
|
@@ -2,15 +2,19 @@
|
|
|
2
2
|
* `search` capability — find information across the web and beyond.
|
|
3
3
|
*
|
|
4
4
|
* This is the home for Sapiom's search primitives: searching the web, reading the
|
|
5
|
-
* contents of a page, and looking up professional email addresses.
|
|
6
|
-
*
|
|
7
|
-
* follow.
|
|
5
|
+
* contents of a page, and looking up professional email addresses. It offers
|
|
6
|
+
* `webSearch` (search the web), `scrape` (read a page), and `emailSearch` (find,
|
|
7
|
+
* verify, and discover professional email addresses); more operations follow.
|
|
8
8
|
*
|
|
9
9
|
* import { search } from "@sapiom/tools"; // ambient auth
|
|
10
10
|
* const hits = await search.webSearch({ query: "what is an LLM agent?" });
|
|
11
11
|
* hits.answer; // a synthesized answer
|
|
12
12
|
* const page = await search.scrape({ url: "https://example.com" });
|
|
13
13
|
* page.markdown; // the page content as markdown
|
|
14
|
+
* const found = await search.emailSearch.findEmail({
|
|
15
|
+
* domain: "example.com", fullName: "Ada Lovelace",
|
|
16
|
+
* });
|
|
17
|
+
* found.email; // the discovered email, or null when not found
|
|
14
18
|
*
|
|
15
19
|
* Or via an explicit client: `createClient({ apiKey }).search.webSearch(...)`.
|
|
16
20
|
*
|
|
@@ -102,4 +106,129 @@ export interface WebSearchResponse {
|
|
|
102
106
|
* Failed requests throw {@link SearchHttpError}.
|
|
103
107
|
*/
|
|
104
108
|
export declare function webSearch(input: WebSearchInput, transport?: Transport, baseUrl?: string): Promise<WebSearchResponse>;
|
|
109
|
+
export interface FindEmailInput {
|
|
110
|
+
/** Company domain to search at, e.g. `"example.com"`. Provide this or `company`. */
|
|
111
|
+
domain?: string;
|
|
112
|
+
/** Company name, as an alternative to `domain`. Provide this or `domain`. */
|
|
113
|
+
company?: string;
|
|
114
|
+
/** Person's first name. Provide with `lastName`, or use `fullName`. */
|
|
115
|
+
firstName?: string;
|
|
116
|
+
/** Person's last name. Provide with `firstName`, or use `fullName`. */
|
|
117
|
+
lastName?: string;
|
|
118
|
+
/** Person's full name, as an alternative to `firstName` + `lastName`. */
|
|
119
|
+
fullName?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface FindEmailResult {
|
|
122
|
+
/** The discovered email address, or `null` when none was found. */
|
|
123
|
+
email: string | null;
|
|
124
|
+
/** Confidence score (0–100) that the email is correct. */
|
|
125
|
+
score?: number;
|
|
126
|
+
/** First name associated with the result. */
|
|
127
|
+
firstName?: string;
|
|
128
|
+
/** Last name associated with the result. */
|
|
129
|
+
lastName?: string;
|
|
130
|
+
/** Job title / position associated with the result. */
|
|
131
|
+
position?: string;
|
|
132
|
+
/** Company associated with the result. */
|
|
133
|
+
company?: string;
|
|
134
|
+
/** LinkedIn profile URL associated with the result. */
|
|
135
|
+
linkedinUrl?: string;
|
|
136
|
+
/** Deliverability verification for the discovered email, when available. */
|
|
137
|
+
verification?: {
|
|
138
|
+
status?: string;
|
|
139
|
+
date?: string;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Find a person's professional email address.
|
|
144
|
+
*
|
|
145
|
+
* You must provide enough to identify both the person and where they work:
|
|
146
|
+
* a `domain` OR `company`, AND either a `fullName` OR both `firstName` and
|
|
147
|
+
* `lastName`. Calling without a valid combination throws {@link SearchHttpError}
|
|
148
|
+
* before any request is made.
|
|
149
|
+
*
|
|
150
|
+
* Returns the best match, with `email` set to `null` when none was found. Failed
|
|
151
|
+
* requests throw {@link SearchHttpError}.
|
|
152
|
+
*/
|
|
153
|
+
export declare function findEmail(input: FindEmailInput, transport?: Transport, baseUrl?: string): Promise<FindEmailResult>;
|
|
154
|
+
export interface VerifyEmailInput {
|
|
155
|
+
/** The email address to verify. */
|
|
156
|
+
email: string;
|
|
157
|
+
}
|
|
158
|
+
export interface VerifyEmailResult {
|
|
159
|
+
/** The email address that was verified (echoes the input). */
|
|
160
|
+
email: string;
|
|
161
|
+
/** Overall deliverability status. */
|
|
162
|
+
status?: string;
|
|
163
|
+
/** Verification result classification. */
|
|
164
|
+
result?: string;
|
|
165
|
+
/** Confidence score (0–100) in the verification. */
|
|
166
|
+
score?: number;
|
|
167
|
+
/** Whether the mail server accepted the address at the SMTP level. */
|
|
168
|
+
smtpCheck?: boolean;
|
|
169
|
+
/** Whether the domain accepts mail for any address (so a positive is weak). */
|
|
170
|
+
acceptAll?: boolean;
|
|
171
|
+
/** Whether the address belongs to a disposable email provider. */
|
|
172
|
+
disposable?: boolean;
|
|
173
|
+
/** Whether the address belongs to a public webmail provider. */
|
|
174
|
+
webmail?: boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Verify that an email address is deliverable — returns a status, confidence
|
|
178
|
+
* score, SMTP/accept-all checks, and disposable/webmail flags. Use it before
|
|
179
|
+
* sending to avoid bounces.
|
|
180
|
+
*
|
|
181
|
+
* Failed requests throw {@link SearchHttpError}.
|
|
182
|
+
*/
|
|
183
|
+
export declare function verifyEmail(input: VerifyEmailInput, transport?: Transport, baseUrl?: string): Promise<VerifyEmailResult>;
|
|
184
|
+
export interface DomainSearchInput {
|
|
185
|
+
/** Company domain to search, e.g. `"example.com"`. */
|
|
186
|
+
domain: string;
|
|
187
|
+
/** Maximum number of emails to return (max 100, default 10). */
|
|
188
|
+
limit?: number;
|
|
189
|
+
/** Filter by email type. */
|
|
190
|
+
type?: "personal" | "generic";
|
|
191
|
+
/** Filter to one or more seniority levels. */
|
|
192
|
+
seniority?: ("junior" | "senior" | "executive")[];
|
|
193
|
+
/** Filter to one or more departments (e.g. `"engineering"`, `"sales"`). */
|
|
194
|
+
department?: string[];
|
|
195
|
+
}
|
|
196
|
+
export interface DomainEmail {
|
|
197
|
+
/** The email address. */
|
|
198
|
+
email: string;
|
|
199
|
+
/** Email type (e.g. `"personal"` or `"generic"`). */
|
|
200
|
+
type?: string;
|
|
201
|
+
/** Confidence score (0–100) that the address is valid. */
|
|
202
|
+
confidence?: number;
|
|
203
|
+
/** First name associated with the address. */
|
|
204
|
+
firstName?: string;
|
|
205
|
+
/** Last name associated with the address. */
|
|
206
|
+
lastName?: string;
|
|
207
|
+
/** Job title / position associated with the address. */
|
|
208
|
+
position?: string;
|
|
209
|
+
/** Department associated with the address. */
|
|
210
|
+
department?: string;
|
|
211
|
+
/** Seniority level associated with the address. */
|
|
212
|
+
seniority?: string;
|
|
213
|
+
}
|
|
214
|
+
export interface DomainSearchResult {
|
|
215
|
+
/** The domain that was searched (echoes the input). */
|
|
216
|
+
domain: string;
|
|
217
|
+
/** The organization name for the domain, when known. */
|
|
218
|
+
organization?: string;
|
|
219
|
+
/** The detected email pattern for the domain (e.g. `"{first}.{last}"`). */
|
|
220
|
+
pattern?: string;
|
|
221
|
+
/** Whether the domain accepts mail for any address. */
|
|
222
|
+
acceptAll?: boolean;
|
|
223
|
+
/** The emails discovered at the domain. */
|
|
224
|
+
emails: DomainEmail[];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Discover the professional emails published at a company domain. Filter the
|
|
228
|
+
* results by `type`, `seniority`, and `department` to home in on the people you
|
|
229
|
+
* care about.
|
|
230
|
+
*
|
|
231
|
+
* Failed requests throw {@link SearchHttpError}.
|
|
232
|
+
*/
|
|
233
|
+
export declare function domainSearch(input: DomainSearchInput, transport?: Transport, baseUrl?: string): Promise<DomainSearchResult>;
|
|
105
234
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/search/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/search/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,CAAC;AAa3B,sEAAsE;AACtE,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,MAAM,GACN,SAAS,GACT,YAAY,GACZ,OAAO,CAAC;AAEZ,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,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DAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2CAA2C;IAC3C,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAmDD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,iBAAiB,EACxB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAgC,GACtC,OAAO,CAAC,kBAAkB,CAAC,CAyB7B"}
|
package/dist/cjs/search/index.js
CHANGED
|
@@ -3,19 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SearchHttpError = void 0;
|
|
4
4
|
exports.scrape = scrape;
|
|
5
5
|
exports.webSearch = webSearch;
|
|
6
|
+
exports.findEmail = findEmail;
|
|
7
|
+
exports.verifyEmail = verifyEmail;
|
|
8
|
+
exports.domainSearch = domainSearch;
|
|
6
9
|
/**
|
|
7
10
|
* `search` capability — find information across the web and beyond.
|
|
8
11
|
*
|
|
9
12
|
* This is the home for Sapiom's search primitives: searching the web, reading the
|
|
10
|
-
* contents of a page, and looking up professional email addresses.
|
|
11
|
-
*
|
|
12
|
-
* follow.
|
|
13
|
+
* contents of a page, and looking up professional email addresses. It offers
|
|
14
|
+
* `webSearch` (search the web), `scrape` (read a page), and `emailSearch` (find,
|
|
15
|
+
* verify, and discover professional email addresses); more operations follow.
|
|
13
16
|
*
|
|
14
17
|
* import { search } from "@sapiom/tools"; // ambient auth
|
|
15
18
|
* const hits = await search.webSearch({ query: "what is an LLM agent?" });
|
|
16
19
|
* hits.answer; // a synthesized answer
|
|
17
20
|
* const page = await search.scrape({ url: "https://example.com" });
|
|
18
21
|
* page.markdown; // the page content as markdown
|
|
22
|
+
* const found = await search.emailSearch.findEmail({
|
|
23
|
+
* domain: "example.com", fullName: "Ada Lovelace",
|
|
24
|
+
* });
|
|
25
|
+
* found.email; // the discovered email, or null when not found
|
|
19
26
|
*
|
|
20
27
|
* Or via an explicit client: `createClient({ apiKey }).search.webSearch(...)`.
|
|
21
28
|
*
|
|
@@ -26,6 +33,7 @@ const errors_js_1 = require("./errors.js");
|
|
|
26
33
|
Object.defineProperty(exports, "SearchHttpError", { enumerable: true, get: function () { return errors_js_1.SearchHttpError; } });
|
|
27
34
|
const DEFAULT_BASE_URL = process.env.SAPIOM_SCRAPE_URL || "https://firecrawl.services.sapiom.ai";
|
|
28
35
|
const DEFAULT_WEB_SEARCH_BASE_URL = process.env.SAPIOM_SEARCH_URL || "https://api.sapiom.ai";
|
|
36
|
+
const DEFAULT_EMAIL_SEARCH_BASE_URL = process.env.SAPIOM_EMAIL_SEARCH_URL || "https://hunter.services.sapiom.ai";
|
|
29
37
|
/** Collapse a field that may be a single value or an array down to one value. */
|
|
30
38
|
function firstOf(value) {
|
|
31
39
|
return Array.isArray(value) ? value[0] : value;
|
|
@@ -126,4 +134,153 @@ async function webSearch(input, transport = (0, index_js_1.defaultTransport)(),
|
|
|
126
134
|
}, { authHeader: "x-api-key" }), "Failed to search the web");
|
|
127
135
|
return mapWebSearch(input.query, (await res.json()));
|
|
128
136
|
}
|
|
137
|
+
// ----- search.emailSearch -----
|
|
138
|
+
//
|
|
139
|
+
// Three operations for working with professional email addresses: find an email
|
|
140
|
+
// for a known person, verify an address is deliverable, and discover the emails
|
|
141
|
+
// published at a company domain.
|
|
142
|
+
// ----- Shared request/response helpers -----
|
|
143
|
+
/**
|
|
144
|
+
* Build a query string from a set of params. Skips any value that is null or
|
|
145
|
+
* undefined (so a JS caller passing an optional as `null` doesn't put `null` on
|
|
146
|
+
* the wire), and stringifies everything else.
|
|
147
|
+
*/
|
|
148
|
+
function toQuery(params) {
|
|
149
|
+
const search = new URLSearchParams();
|
|
150
|
+
for (const [key, value] of Object.entries(params)) {
|
|
151
|
+
if (value != null)
|
|
152
|
+
search.set(key, String(value));
|
|
153
|
+
}
|
|
154
|
+
const qs = search.toString();
|
|
155
|
+
return qs ? `?${qs}` : "";
|
|
156
|
+
}
|
|
157
|
+
async function getEnvelope(transport, url, errorPrefix) {
|
|
158
|
+
const res = await (0, errors_js_1.ensureOk)(await transport.fetch(url, { method: "GET" }), errorPrefix);
|
|
159
|
+
const body = (await res.json());
|
|
160
|
+
return body.data;
|
|
161
|
+
}
|
|
162
|
+
function mapFindEmail(raw) {
|
|
163
|
+
const d = raw ?? {};
|
|
164
|
+
// `!= null` so fields that come back null (a miss) are treated as absent rather
|
|
165
|
+
// than surfaced as `field: null`.
|
|
166
|
+
return {
|
|
167
|
+
email: d.email != null ? d.email : null,
|
|
168
|
+
...(d.score != null && { score: d.score }),
|
|
169
|
+
...(d.first_name != null && { firstName: d.first_name }),
|
|
170
|
+
...(d.last_name != null && { lastName: d.last_name }),
|
|
171
|
+
...(d.position != null && { position: d.position }),
|
|
172
|
+
...(d.company != null && { company: d.company }),
|
|
173
|
+
...(d.linkedin_url != null && { linkedinUrl: d.linkedin_url }),
|
|
174
|
+
...(d.verification != null && { verification: d.verification }),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Find a person's professional email address.
|
|
179
|
+
*
|
|
180
|
+
* You must provide enough to identify both the person and where they work:
|
|
181
|
+
* a `domain` OR `company`, AND either a `fullName` OR both `firstName` and
|
|
182
|
+
* `lastName`. Calling without a valid combination throws {@link SearchHttpError}
|
|
183
|
+
* before any request is made.
|
|
184
|
+
*
|
|
185
|
+
* Returns the best match, with `email` set to `null` when none was found. Failed
|
|
186
|
+
* requests throw {@link SearchHttpError}.
|
|
187
|
+
*/
|
|
188
|
+
async function findEmail(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_EMAIL_SEARCH_BASE_URL) {
|
|
189
|
+
// Guard the required combination client-side so an under-specified lookup fails
|
|
190
|
+
// fast and clearly, never as a confusing network round-trip. `!= null` plus a
|
|
191
|
+
// truthiness check rejects null/undefined/empty-string for JS callers.
|
|
192
|
+
const hasOrg = Boolean(input.domain) || Boolean(input.company);
|
|
193
|
+
const hasPerson = Boolean(input.fullName) ||
|
|
194
|
+
(Boolean(input.firstName) && Boolean(input.lastName));
|
|
195
|
+
if (!hasOrg || !hasPerson) {
|
|
196
|
+
throw new errors_js_1.SearchHttpError("findEmail requires (domain or company) and (fullName or firstName + lastName)", 400, undefined);
|
|
197
|
+
}
|
|
198
|
+
const query = toQuery({
|
|
199
|
+
domain: input.domain,
|
|
200
|
+
company: input.company,
|
|
201
|
+
first_name: input.firstName,
|
|
202
|
+
last_name: input.lastName,
|
|
203
|
+
full_name: input.fullName,
|
|
204
|
+
});
|
|
205
|
+
const data = await getEnvelope(transport, `${baseUrl}/v2/email-finder${query}`, "Failed to find email");
|
|
206
|
+
return mapFindEmail(data);
|
|
207
|
+
}
|
|
208
|
+
function mapVerifyEmail(email, raw) {
|
|
209
|
+
const d = raw ?? {};
|
|
210
|
+
return {
|
|
211
|
+
email: d.email ?? email,
|
|
212
|
+
...(d.status != null && { status: d.status }),
|
|
213
|
+
...(d.result != null && { result: d.result }),
|
|
214
|
+
...(d.score != null && { score: d.score }),
|
|
215
|
+
...(d.smtp_check != null && { smtpCheck: d.smtp_check }),
|
|
216
|
+
...(d.accept_all != null && { acceptAll: d.accept_all }),
|
|
217
|
+
...(d.disposable != null && { disposable: d.disposable }),
|
|
218
|
+
...(d.webmail != null && { webmail: d.webmail }),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Verify that an email address is deliverable — returns a status, confidence
|
|
223
|
+
* score, SMTP/accept-all checks, and disposable/webmail flags. Use it before
|
|
224
|
+
* sending to avoid bounces.
|
|
225
|
+
*
|
|
226
|
+
* Failed requests throw {@link SearchHttpError}.
|
|
227
|
+
*/
|
|
228
|
+
async function verifyEmail(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_EMAIL_SEARCH_BASE_URL) {
|
|
229
|
+
if (!input.email) {
|
|
230
|
+
throw new errors_js_1.SearchHttpError("verifyEmail requires an email", 400, undefined);
|
|
231
|
+
}
|
|
232
|
+
const query = toQuery({ email: input.email });
|
|
233
|
+
const data = await getEnvelope(transport, `${baseUrl}/v2/email-verifier${query}`, "Failed to verify email");
|
|
234
|
+
return mapVerifyEmail(input.email, data);
|
|
235
|
+
}
|
|
236
|
+
function mapDomainEmail(raw) {
|
|
237
|
+
return {
|
|
238
|
+
email: raw.value ?? "",
|
|
239
|
+
...(raw.type != null && { type: raw.type }),
|
|
240
|
+
...(raw.confidence != null && { confidence: raw.confidence }),
|
|
241
|
+
...(raw.first_name != null && { firstName: raw.first_name }),
|
|
242
|
+
...(raw.last_name != null && { lastName: raw.last_name }),
|
|
243
|
+
...(raw.position != null && { position: raw.position }),
|
|
244
|
+
...(raw.department != null && { department: raw.department }),
|
|
245
|
+
...(raw.seniority != null && { seniority: raw.seniority }),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function mapDomainSearch(domain, raw) {
|
|
249
|
+
const d = raw ?? {};
|
|
250
|
+
const emails = Array.isArray(d.emails) ? d.emails.map(mapDomainEmail) : [];
|
|
251
|
+
return {
|
|
252
|
+
domain: d.domain ?? domain,
|
|
253
|
+
...(d.organization != null && { organization: d.organization }),
|
|
254
|
+
...(d.pattern != null && { pattern: d.pattern }),
|
|
255
|
+
...(d.accept_all != null && { acceptAll: d.accept_all }),
|
|
256
|
+
emails,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Discover the professional emails published at a company domain. Filter the
|
|
261
|
+
* results by `type`, `seniority`, and `department` to home in on the people you
|
|
262
|
+
* care about.
|
|
263
|
+
*
|
|
264
|
+
* Failed requests throw {@link SearchHttpError}.
|
|
265
|
+
*/
|
|
266
|
+
async function domainSearch(input, transport = (0, index_js_1.defaultTransport)(), baseUrl = DEFAULT_EMAIL_SEARCH_BASE_URL) {
|
|
267
|
+
if (!input.domain) {
|
|
268
|
+
throw new errors_js_1.SearchHttpError("domainSearch requires a domain", 400, undefined);
|
|
269
|
+
}
|
|
270
|
+
// Array filters travel as comma-separated values; an empty array becomes
|
|
271
|
+
// nothing on the wire (filtered by `toQuery`).
|
|
272
|
+
const query = toQuery({
|
|
273
|
+
domain: input.domain,
|
|
274
|
+
limit: input.limit,
|
|
275
|
+
type: input.type,
|
|
276
|
+
seniority: input.seniority != null && input.seniority.length > 0
|
|
277
|
+
? input.seniority.join(",")
|
|
278
|
+
: undefined,
|
|
279
|
+
department: input.department != null && input.department.length > 0
|
|
280
|
+
? input.department.join(",")
|
|
281
|
+
: undefined,
|
|
282
|
+
});
|
|
283
|
+
const data = await getEnvelope(transport, `${baseUrl}/v2/domain-search${query}`, "Failed to search domain");
|
|
284
|
+
return mapDomainSearch(input.domain, data);
|
|
285
|
+
}
|
|
129
286
|
//# sourceMappingURL=index.js.map
|