@enhance-eng/sdk 0.1.0-dev.sha-3f7dd0acb078 → 0.1.0-dev.sha-d9190c779d58
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 +34 -8
- package/dist/capture-client.client-DsMSGK3h.d.mts +34 -0
- package/dist/{index-PIb9iIwo.d.mts → capture-files.lib-BpwdV8DQ.d.mts} +10 -1
- package/dist/client.d.mts +2 -0
- package/dist/client.mjs +2 -0
- package/dist/environment.config-CA-3pMfN.d.mts +12 -0
- package/dist/{environment.config-BgNT6S_H.mjs → environment.config-D898JKZB.mjs} +1 -5
- package/dist/environment.config-DW6wFq6z.mjs +34 -0
- package/dist/index.d.mts +4 -35
- package/dist/index.mjs +1 -1
- package/dist/package-CLHe5Seu.mjs +4 -0
- package/dist/playwright/index.d.mts +1 -1
- package/dist/playwright/index.mjs +2 -4
- package/dist/playwright/reporter.d.mts +3 -4
- package/dist/playwright/reporter.mjs +4 -7
- package/package.json +5 -1
- package/dist/capture-files.lib-CvX7Ca8M.d.mts +0 -11
package/README.md
CHANGED
|
@@ -9,9 +9,38 @@ npm install --save-dev @enhance-eng/sdk
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Development prereleases use the same package: `npm install --save-dev @enhance-eng/sdk@next`.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Development versions (`-dev.sha-…`) default to the Enhance development API. Stable versions
|
|
13
|
+
default to production. Both distributions are public and use the same code.
|
|
14
|
+
|
|
15
|
+
Set `ENHANCE_ENVIRONMENT` to choose explicitly; the Node client and every reporter share these settings:
|
|
16
|
+
|
|
17
|
+
| Environment | API | Credentials |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `local` | `http://localhost:3000` | A token and canvas from your local API |
|
|
20
|
+
| `development` | `https://api.enhance3.karunalabs.ai` | A development token and canvas |
|
|
21
|
+
| `production` | `https://api.enhancelabs.ai` | A production token and canvas |
|
|
22
|
+
|
|
23
|
+
Use `ENHANCE_API_URL` for a different local port or a custom API. A named environment rejects
|
|
24
|
+
an endpoint from another environment before sending credentials. Omit `ENHANCE_ENVIRONMENT`
|
|
25
|
+
when targeting a custom server. `NODE_ENV`, the URL of the page being captured, and the CI
|
|
26
|
+
runner do not select the destination: tests often run a local page while publishing to a cloud canvas.
|
|
27
|
+
|
|
28
|
+
For local runs, load an ignored environment file before running tests:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
set -a
|
|
32
|
+
source .env.sdk.local
|
|
33
|
+
set +a
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Its values are `ENHANCE_ENVIRONMENT=local`, `ENHANCE_API_URL=http://localhost:3000` (or the
|
|
37
|
+
worktree API port), and `ENHANCE_TOKEN` from that local instance. In CI, set the environment
|
|
38
|
+
name and its token as job configuration and a secret respectively. Tokens are never inferred
|
|
39
|
+
from another environment or read from CLI credential storage by the SDK.
|
|
40
|
+
|
|
41
|
+
Integrations that already own destination and credential selection, such as the Enhance CLI,
|
|
42
|
+
import `createEnhance` from `@enhance-eng/sdk/client` and pass both `apiUrl` and `token`.
|
|
43
|
+
That entry uses the same publisher without loading SDK environment defaults or ambient credentials.
|
|
15
44
|
|
|
16
45
|
Configure the reporter in `playwright.config.ts`:
|
|
17
46
|
|
|
@@ -29,7 +58,7 @@ export default defineConfig({
|
|
|
29
58
|
});
|
|
30
59
|
```
|
|
31
60
|
|
|
32
|
-
Create an agent token in **Settings → Agent tokens** and store it as the `ENHANCE_TOKEN` secret in your CI runner (or environment variable locally). Its owner must be able to edit the destination canvas. Use the canvas UUID from its `/c/<uuid>` URL.
|
|
61
|
+
Create an agent token in **Settings → Agent tokens** in the destination environment and store it as the `ENHANCE_TOKEN` secret in your CI runner (or environment variable locally). Its owner must be able to edit the destination canvas. Use the canvas UUID from its `/c/<uuid>` URL. Credentials stay in the Node process, outside captured pages and artifacts. Reporter options `environment`, `apiUrl`, and `token` override their corresponding environment variables.
|
|
33
62
|
|
|
34
63
|
```ts
|
|
35
64
|
import { test } from '@playwright/test';
|
|
@@ -86,10 +115,7 @@ The core Node entry point publishes the same manifest; it has no Playwright depe
|
|
|
86
115
|
```ts
|
|
87
116
|
import { createEnhance } from '@enhance-eng/sdk';
|
|
88
117
|
|
|
89
|
-
const enhance = createEnhance(
|
|
90
|
-
apiUrl: process.env.ENHANCE_API_URL ?? 'https://api.enhancelabs.ai',
|
|
91
|
-
token: process.env.ENHANCE_TOKEN ?? '',
|
|
92
|
-
});
|
|
118
|
+
const enhance = createEnhance(); // Same environment and token settings as the reporter.
|
|
93
119
|
const receipt = await enhance.captures.publishManifest('./saved-capture/manifest.json');
|
|
94
120
|
console.log(receipt.canvasUrl);
|
|
95
121
|
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { a as CaptureReceipt, l as getCaptureRunOutputSchema, o as CaptureRunDescriptor, t as CapturePayload } from "./capture-files.lib-BpwdV8DQ.mjs";
|
|
2
|
+
//#region src/node/capture-transport.client.d.ts
|
|
3
|
+
interface CaptureClientOptions {
|
|
4
|
+
readonly apiUrl: string;
|
|
5
|
+
readonly token: string;
|
|
6
|
+
readonly timeoutMs?: number;
|
|
7
|
+
readonly publicationTimeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/node/capture-client.client.d.ts
|
|
11
|
+
interface BeginCaptureRun {
|
|
12
|
+
readonly canvas: string;
|
|
13
|
+
readonly source?: string;
|
|
14
|
+
readonly runKey: string;
|
|
15
|
+
readonly participants?: readonly string[];
|
|
16
|
+
readonly directory?: string;
|
|
17
|
+
}
|
|
18
|
+
interface CaptureRun {
|
|
19
|
+
readonly descriptor: CaptureRunDescriptor;
|
|
20
|
+
readonly directory: string;
|
|
21
|
+
readonly add: (payload: CapturePayload) => Promise<void>;
|
|
22
|
+
readonly publish: () => Promise<CaptureReceipt>;
|
|
23
|
+
readonly cancel: () => Promise<CaptureReceipt | null>;
|
|
24
|
+
}
|
|
25
|
+
interface EnhanceClient {
|
|
26
|
+
readonly captures: {
|
|
27
|
+
readonly begin: (input: BeginCaptureRun) => Promise<CaptureRun>;
|
|
28
|
+
readonly publishManifest: (path: string) => Promise<CaptureReceipt>;
|
|
29
|
+
readonly get: (runId: string) => Promise<ReturnType<typeof getCaptureRunOutputSchema.parse>>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
declare const createEnhance: (options: CaptureClientOptions) => EnhanceClient;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CaptureClientOptions as a, createEnhance as i, CaptureRun as n, EnhanceClient as r, BeginCaptureRun as t };
|
|
@@ -254,4 +254,13 @@ declare const getCaptureRunOutputSchema: z.ZodObject<{
|
|
|
254
254
|
/** All publishers select whole terminal attempts with the same completeness rules. */
|
|
255
255
|
declare const selectedCaptures: (input: CaptureManifest) => readonly CaptureArtifact[] | string;
|
|
256
256
|
//#endregion
|
|
257
|
-
|
|
257
|
+
//#region src/node/capture-files.lib.d.ts
|
|
258
|
+
interface CapturePayload {
|
|
259
|
+
readonly artifact: CaptureArtifact;
|
|
260
|
+
readonly blobs: readonly {
|
|
261
|
+
readonly description: CaptureBlob;
|
|
262
|
+
readonly bytes: Uint8Array;
|
|
263
|
+
}[];
|
|
264
|
+
}
|
|
265
|
+
//#endregion
|
|
266
|
+
export { CaptureReceipt as a, captureManifestSchema as c, CaptureManifest as i, getCaptureRunOutputSchema as l, selectedCaptures as n, CaptureRunDescriptor as o, CaptureArtifact as r, captureArtifactSchema as s, CapturePayload as t };
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a as CaptureClientOptions$1, r as EnhanceClient } from "./capture-client.client-DsMSGK3h.mjs";
|
|
2
|
+
//#region src/node/environment.config.d.ts
|
|
3
|
+
type CaptureEnvironment = 'local' | 'development' | 'production';
|
|
4
|
+
interface CaptureConnectionOptions {
|
|
5
|
+
readonly environment?: CaptureEnvironment;
|
|
6
|
+
readonly apiUrl?: string;
|
|
7
|
+
readonly token?: string;
|
|
8
|
+
}
|
|
9
|
+
interface CaptureClientOptions extends CaptureConnectionOptions, Pick<CaptureClientOptions$1, 'timeoutMs' | 'publicationTimeoutMs'> {}
|
|
10
|
+
declare const createEnhance: (options?: CaptureClientOptions) => EnhanceClient;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { createEnhance as i, CaptureConnectionOptions as n, CaptureEnvironment as r, CaptureClientOptions as t };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { s as captureError } from "./capture-files.lib-BA_KBz9W.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
//#region src/playwright/environment.config.ts
|
|
4
|
-
const captureEnvironment = () => ({
|
|
5
|
-
apiUrl: process.env["ENHANCE_API_URL"] ?? "https://api.enhancelabs.ai",
|
|
6
|
-
token: process.env["ENHANCE_TOKEN"] ?? "",
|
|
7
|
-
directory: process.env["ENHANCE_CAPTURE_DIRECTORY"] ?? ""
|
|
8
|
-
});
|
|
4
|
+
const captureEnvironment = () => ({ directory: process.env["ENHANCE_CAPTURE_DIRECTORY"] ?? "" });
|
|
9
5
|
const setCaptureDirectory = (directory) => {
|
|
10
6
|
if (directory === "") throw captureError("configuration", "Capture output directory must not be empty.");
|
|
11
7
|
process.env["ENHANCE_CAPTURE_DIRECTORY"] = directory;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { s as captureError } from "./capture-files.lib-BA_KBz9W.mjs";
|
|
2
|
+
import { t as version } from "./package-CLHe5Seu.mjs";
|
|
3
|
+
import { t as createEnhance$1 } from "./capture-client.client-BDphetFj.mjs";
|
|
4
|
+
import process from "node:process";
|
|
5
|
+
//#region src/node/environment.config.ts
|
|
6
|
+
const endpoints = {
|
|
7
|
+
local: "http://localhost:3000",
|
|
8
|
+
development: "https://api.enhance3.karunalabs.ai",
|
|
9
|
+
production: "https://api.enhancelabs.ai"
|
|
10
|
+
};
|
|
11
|
+
const captureConnection = (options) => {
|
|
12
|
+
const selected = options.environment ?? process.env["ENHANCE_ENVIRONMENT"];
|
|
13
|
+
if (selected !== void 0 && selected !== "local" && selected !== "development" && selected !== "production") throw captureError("configuration", "ENHANCE_ENVIRONMENT must be local, development, or production.");
|
|
14
|
+
const environment = selected ?? (version.includes("-dev.") ? "development" : "production");
|
|
15
|
+
const apiUrl = options.apiUrl ?? process.env["ENHANCE_API_URL"] ?? endpoints[environment];
|
|
16
|
+
if (selected !== void 0) {
|
|
17
|
+
const url = URL.parse(apiUrl);
|
|
18
|
+
if (!(url !== null && (environment === "local" ? [
|
|
19
|
+
"localhost",
|
|
20
|
+
"127.0.0.1",
|
|
21
|
+
"[::1]"
|
|
22
|
+
].includes(url.hostname) : url.origin === endpoints[environment]))) throw captureError("configuration", `The API URL does not match the ${environment} environment. Set its matching endpoint or remove the explicit environment to use a custom API.`);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
apiUrl,
|
|
26
|
+
token: options.token ?? process.env["ENHANCE_TOKEN"] ?? ""
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const createEnhance = (options = {}) => createEnhance$1({
|
|
30
|
+
...options,
|
|
31
|
+
...captureConnection(options)
|
|
32
|
+
});
|
|
33
|
+
//#endregion
|
|
34
|
+
export { createEnhance as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { a as CaptureReceipt, c as captureManifestSchema, i as CaptureManifest,
|
|
2
|
-
import { t as
|
|
1
|
+
import { a as CaptureReceipt, c as captureManifestSchema, i as CaptureManifest, n as selectedCaptures, o as CaptureRunDescriptor, r as CaptureArtifact, s as captureArtifactSchema, t as CapturePayload } from "./capture-files.lib-BpwdV8DQ.mjs";
|
|
2
|
+
import { n as CaptureRun, r as EnhanceClient, t as BeginCaptureRun } from "./capture-client.client-DsMSGK3h.mjs";
|
|
3
|
+
import { i as createEnhance, r as CaptureEnvironment, t as CaptureClientOptions } from "./environment.config-CA-3pMfN.mjs";
|
|
3
4
|
//#region src/core/capture-error.error.d.ts
|
|
4
5
|
type CaptureErrorCode = 'configuration' | 'capture' | 'artifact' | 'authorization' | 'conversion' | 'conflict' | 'transport';
|
|
5
6
|
interface CaptureError extends Error {
|
|
@@ -7,36 +8,4 @@ interface CaptureError extends Error {
|
|
|
7
8
|
readonly runId?: string;
|
|
8
9
|
}
|
|
9
10
|
//#endregion
|
|
10
|
-
|
|
11
|
-
interface CaptureClientOptions {
|
|
12
|
-
readonly apiUrl: string;
|
|
13
|
-
readonly token: string;
|
|
14
|
-
readonly timeoutMs?: number;
|
|
15
|
-
readonly publicationTimeoutMs?: number;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/node/capture-client.client.d.ts
|
|
19
|
-
interface BeginCaptureRun {
|
|
20
|
-
readonly canvas: string;
|
|
21
|
-
readonly source?: string;
|
|
22
|
-
readonly runKey: string;
|
|
23
|
-
readonly participants?: readonly string[];
|
|
24
|
-
readonly directory?: string;
|
|
25
|
-
}
|
|
26
|
-
interface CaptureRun {
|
|
27
|
-
readonly descriptor: CaptureRunDescriptor;
|
|
28
|
-
readonly directory: string;
|
|
29
|
-
readonly add: (payload: CapturePayload) => Promise<void>;
|
|
30
|
-
readonly publish: () => Promise<CaptureReceipt>;
|
|
31
|
-
readonly cancel: () => Promise<CaptureReceipt | null>;
|
|
32
|
-
}
|
|
33
|
-
interface EnhanceClient {
|
|
34
|
-
readonly captures: {
|
|
35
|
-
readonly begin: (input: BeginCaptureRun) => Promise<CaptureRun>;
|
|
36
|
-
readonly publishManifest: (path: string) => Promise<CaptureReceipt>;
|
|
37
|
-
readonly get: (runId: string) => Promise<ReturnType<typeof getCaptureRunOutputSchema.parse>>;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
declare const createEnhance: (options: CaptureClientOptions) => EnhanceClient;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { type BeginCaptureRun, type CaptureArtifact, type CaptureClientOptions, type CaptureError, type CaptureErrorCode, type CaptureManifest, type CapturePayload, type CaptureReceipt, type CaptureRun, type CaptureRunDescriptor, type EnhanceClient, captureArtifactSchema, captureManifestSchema, createEnhance, selectedCaptures };
|
|
11
|
+
export { type BeginCaptureRun, type CaptureArtifact, type CaptureClientOptions, type CaptureEnvironment, type CaptureError, type CaptureErrorCode, type CaptureManifest, type CapturePayload, type CaptureReceipt, type CaptureRun, type CaptureRunDescriptor, type EnhanceClient, captureArtifactSchema, captureManifestSchema, createEnhance, selectedCaptures };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { m as captureManifestSchema, p as captureArtifactSchema, u as selectedCaptures } from "./capture-files.lib-BA_KBz9W.mjs";
|
|
2
|
-
import { t as createEnhance } from "./
|
|
2
|
+
import { t as createEnhance } from "./environment.config-DW6wFq6z.mjs";
|
|
3
3
|
export { captureArtifactSchema, captureManifestSchema, createEnhance, selectedCaptures };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a as captureBlobDigest, c as canonicalCaptureJson, h as captureRunDescriptorSchema, i as writeCapturePayload, p as captureArtifactSchema, s as captureError } from "../capture-files.lib-BA_KBz9W.mjs";
|
|
2
|
-
import { t as
|
|
2
|
+
import { t as version } from "../package-CLHe5Seu.mjs";
|
|
3
|
+
import { t as captureEnvironment } from "../environment.config-D898JKZB.mjs";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { readFile } from "node:fs/promises";
|
|
5
6
|
import nodePath from "node:path";
|
|
@@ -6288,9 +6289,6 @@ const mirrorAssetCopySession = (deps) => {
|
|
|
6288
6289
|
};
|
|
6289
6290
|
};
|
|
6290
6291
|
//#endregion
|
|
6291
|
-
//#region package.json
|
|
6292
|
-
var version = "0.1.0-dev.sha-3f7dd0acb078";
|
|
6293
|
-
//#endregion
|
|
6294
6292
|
//#region src/playwright/capture-page.lib.ts
|
|
6295
6293
|
const CAPTURE_STABILITY_MS = 5e3;
|
|
6296
6294
|
const RETENTION_DEADLINE_MS = 15e3;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { o as CaptureRunDescriptor } from "../
|
|
1
|
+
import { o as CaptureRunDescriptor } from "../capture-files.lib-BpwdV8DQ.mjs";
|
|
2
|
+
import { n as CaptureConnectionOptions } from "../environment.config-CA-3pMfN.mjs";
|
|
2
3
|
import { Reporter } from "@playwright/test/reporter";
|
|
3
4
|
//#region src/playwright/capture-reporter.lib.d.ts
|
|
4
|
-
interface EnhanceReporterOptions {
|
|
5
|
+
interface EnhanceReporterOptions extends CaptureConnectionOptions {
|
|
5
6
|
readonly canvas: string;
|
|
6
7
|
readonly source?: string;
|
|
7
|
-
readonly apiUrl?: string;
|
|
8
|
-
readonly token?: string;
|
|
9
8
|
readonly runKey?: string;
|
|
10
9
|
readonly directory?: string;
|
|
11
10
|
readonly run?: CaptureRunDescriptor;
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { p as captureArtifactSchema, r as writeCaptureJson } from "../capture-files.lib-BA_KBz9W.mjs";
|
|
2
|
-
import { t as createEnhance } from "../
|
|
3
|
-
import { n as setCaptureDirectory
|
|
2
|
+
import { t as createEnhance } from "../environment.config-DW6wFq6z.mjs";
|
|
3
|
+
import { n as setCaptureDirectory } from "../environment.config-D898JKZB.mjs";
|
|
4
|
+
import process from "node:process";
|
|
4
5
|
import { mkdir, readFile } from "node:fs/promises";
|
|
5
6
|
import nodePath from "node:path";
|
|
6
|
-
import process from "node:process";
|
|
7
7
|
//#region src/playwright/capture-reporter.lib.ts
|
|
8
8
|
const errorOf = (error) => error instanceof Error ? error : /* @__PURE__ */ new Error("Enhance reporter could not complete the capture run.");
|
|
9
9
|
const initialize = async (session) => {
|
|
10
10
|
const current = session;
|
|
11
11
|
await mkdir(session.directory, { recursive: true });
|
|
12
12
|
try {
|
|
13
|
-
current.client = createEnhance(
|
|
14
|
-
apiUrl: session.options.apiUrl ?? captureEnvironment().apiUrl,
|
|
15
|
-
token: session.options.token ?? captureEnvironment().token
|
|
16
|
-
});
|
|
13
|
+
current.client = createEnhance(session.options);
|
|
17
14
|
if (session.options.run === void 0) current.run = (await current.client.captures.begin({
|
|
18
15
|
canvas: session.options.canvas,
|
|
19
16
|
...session.options.source !== void 0 && { source: session.options.source },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enhance-eng/sdk",
|
|
3
|
-
"version": "0.1.0-dev.sha-
|
|
3
|
+
"version": "0.1.0-dev.sha-d9190c779d58",
|
|
4
4
|
"description": "Capture editable customer journeys in Enhance from your tests.",
|
|
5
5
|
"homepage": "https://enhancelabs.ai",
|
|
6
6
|
"repository": {
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
"types": "./dist/playwright/index.d.mts",
|
|
24
24
|
"import": "./dist/playwright/index.mjs"
|
|
25
25
|
},
|
|
26
|
+
"./client": {
|
|
27
|
+
"types": "./dist/client.d.mts",
|
|
28
|
+
"import": "./dist/client.mjs"
|
|
29
|
+
},
|
|
26
30
|
"./playwright/reporter": {
|
|
27
31
|
"types": "./dist/playwright/reporter.d.mts",
|
|
28
32
|
"import": "./dist/playwright/reporter.mjs",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { n as CaptureArtifact, r as CaptureBlob } from "./index-PIb9iIwo.mjs";
|
|
2
|
-
//#region src/node/capture-files.lib.d.ts
|
|
3
|
-
interface CapturePayload {
|
|
4
|
-
readonly artifact: CaptureArtifact;
|
|
5
|
-
readonly blobs: readonly {
|
|
6
|
-
readonly description: CaptureBlob;
|
|
7
|
-
readonly bytes: Uint8Array;
|
|
8
|
-
}[];
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
export { CapturePayload as t };
|