effect-browserbase 0.1.0-beta.102 → 0.2.0-beta.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 +61 -231
- package/dist/Account.d.mts +4 -6
- package/dist/Account.mjs +4 -9
- package/dist/Account.mjs.map +1 -1
- package/dist/{Acquisition-WBafHwXH.mjs → Acquisition-D8o4jtCg.mjs} +22 -68
- package/dist/Acquisition-D8o4jtCg.mjs.map +1 -0
- package/dist/Agents.d.mts +4 -6
- package/dist/Agents.mjs +3 -19
- package/dist/Agents.mjs.map +1 -1
- package/dist/Allocation.d.mts +9 -11
- package/dist/Allocation.mjs +2 -4
- package/dist/Allocation.mjs.map +1 -1
- package/dist/Browser.d.mts +25 -140
- package/dist/Browser.mjs +266 -1
- package/dist/Browser.mjs.map +1 -0
- package/dist/BrowserBinding.d.mts +7 -34
- package/dist/BrowserBinding.mjs +30 -1
- package/dist/BrowserBinding.mjs.map +1 -0
- package/dist/Certificates.d.mts +3 -5
- package/dist/Certificates.mjs +2 -7
- package/dist/Certificates.mjs.map +1 -1
- package/dist/{Cleanup-G2YpTCuU.d.mts → Cleanup-DMTDBir8.d.mts} +5 -6
- package/dist/Cleanup.d.mts +3 -2
- package/dist/Cleanup.mjs +1 -6
- package/dist/Cleanup.mjs.map +1 -1
- package/dist/{Client-D1_xYM9o.mjs → Client-BQteUePT.mjs} +2 -4
- package/dist/{Client-D1_xYM9o.mjs.map → Client-BQteUePT.mjs.map} +1 -1
- package/dist/Client.d.mts +51 -2
- package/dist/Client.mjs +1 -1
- package/dist/Connection-DcvJZEdc.mjs +65 -0
- package/dist/Connection-DcvJZEdc.mjs.map +1 -0
- package/dist/ContextCoordination.d.mts +5 -6
- package/dist/ContextCoordination.mjs +1 -8
- package/dist/ContextCoordination.mjs.map +1 -1
- package/dist/Contexts.d.mts +4 -6
- package/dist/Contexts.mjs +2 -8
- package/dist/Contexts.mjs.map +1 -1
- package/dist/Downloads.d.mts +6 -8
- package/dist/Downloads.mjs +3 -8
- package/dist/Downloads.mjs.map +1 -1
- package/dist/Errors.d.mts +3 -26
- package/dist/Errors.mjs +1 -137
- package/dist/Errors.mjs.map +1 -1
- package/dist/{Extensions-ClZbYb1H.mjs → Extensions-nMNMPGCc.mjs} +3 -9
- package/dist/{Extensions-ClZbYb1H.mjs.map → Extensions-nMNMPGCc.mjs.map} +1 -1
- package/dist/Extensions.d.mts +4 -6
- package/dist/Extensions.mjs +1 -1
- package/dist/Functions.d.mts +4 -6
- package/dist/Functions.mjs +3 -17
- package/dist/Functions.mjs.map +1 -1
- package/dist/{Launch-BHcAEq05.mjs → Launch-m0fxzJ49.mjs} +5 -5
- package/dist/Launch-m0fxzJ49.mjs.map +1 -0
- package/dist/Launch.d.mts +130 -2
- package/dist/Launch.mjs +4 -11
- package/dist/Launch.mjs.map +1 -1
- package/dist/PageFetch.d.mts +3 -5
- package/dist/PageFetch.mjs +2 -8
- package/dist/PageFetch.mjs.map +1 -1
- package/dist/Projects.d.mts +3 -5
- package/dist/Projects.mjs +2 -8
- package/dist/Projects.mjs.map +1 -1
- package/dist/Recordings.d.mts +6 -8
- package/dist/Recordings.mjs +3 -5
- package/dist/Recordings.mjs.map +1 -1
- package/dist/{References-URDAtapt.d.mts → References-DOH3Wu44.d.mts} +5 -6
- package/dist/References.d.mts +3 -2
- package/dist/References.mjs +10 -18
- package/dist/References.mjs.map +1 -1
- package/dist/Replays.d.mts +6 -8
- package/dist/Replays.mjs +3 -5
- package/dist/Replays.mjs.map +1 -1
- package/dist/Search.d.mts +3 -5
- package/dist/Search.mjs +2 -9
- package/dist/Search.mjs.map +1 -1
- package/dist/{SessionData-DRKcKCqw.d.mts → SessionData-5xYZDshJ.d.mts} +5 -6
- package/dist/SessionData.d.mts +3 -2
- package/dist/SessionData.mjs +1 -8
- package/dist/SessionData.mjs.map +1 -1
- package/dist/{Sessions-CtbseWEh.mjs → Sessions-DoQGg9nB.mjs} +34 -18
- package/dist/Sessions-DoQGg9nB.mjs.map +1 -0
- package/dist/{Sessions-B8E4kMxo.d.mts → Sessions-tFJYaXFq.d.mts} +8 -8
- package/dist/Sessions.d.mts +4 -3
- package/dist/Sessions.mjs +1 -1
- package/dist/{Transfers-Czv5IZzJ.d.mts → Transfers-GVqzrDWl.d.mts} +22 -9
- package/dist/Transfers.d.mts +3 -2
- package/dist/Transfers.mjs +12 -28
- package/dist/Transfers.mjs.map +1 -1
- package/dist/Uploads.d.mts +6 -8
- package/dist/Uploads.mjs +3 -5
- package/dist/Uploads.mjs.map +1 -1
- package/dist/Webhooks.d.mts +3 -5
- package/dist/Webhooks.mjs +2 -11
- package/dist/Webhooks.mjs.map +1 -1
- package/dist/{WriterFacts-osvYAsIx.d.mts → WriterFacts-5CPBGG1P.d.mts} +4 -3
- package/dist/index.d.mts +27 -30
- package/dist/index.mjs +26 -30
- package/package.json +3 -24
- package/dist/Acquisition-WBafHwXH.mjs.map +0 -1
- package/dist/Association-CEps4hYP.mjs +0 -10
- package/dist/Association-CEps4hYP.mjs.map +0 -1
- package/dist/Bootstrap-BXuzZojd.mjs +0 -194
- package/dist/Bootstrap-BXuzZojd.mjs.map +0 -1
- package/dist/Bootstrap-m7lHgj0D.d.mts +0 -177
- package/dist/Bootstrap.d.mts +0 -2
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser-joE4Zgys.mjs +0 -1557
- package/dist/Browser-joE4Zgys.mjs.map +0 -1
- package/dist/BrowserBinding-qbQA6JhH.mjs +0 -2452
- package/dist/BrowserBinding-qbQA6JhH.mjs.map +0 -1
- package/dist/BrowserData-LpcAuAub.d.mts +0 -369
- package/dist/BrowserData.d.mts +0 -2
- package/dist/BrowserData.mjs +0 -442
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/Capture-CZJPuD7b.mjs +0 -532
- package/dist/Capture-CZJPuD7b.mjs.map +0 -1
- package/dist/Capture-Dr5MkIJb.d.mts +0 -125
- package/dist/Capture.d.mts +0 -2
- package/dist/Capture.mjs +0 -2
- package/dist/Client-Ca0zSg1n.d.mts +0 -53
- package/dist/Images-DgscEfSf.mjs +0 -127
- package/dist/Images-DgscEfSf.mjs.map +0 -1
- package/dist/Launch-BHcAEq05.mjs.map +0 -1
- package/dist/Launch-C8CfaYxb.d.mts +0 -132
- package/dist/PageControl.d.mts +0 -16
- package/dist/PageControl.mjs +0 -36
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
- package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
- package/dist/Sessions-CtbseWEh.mjs.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
|
@@ -1,9 +1,37 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { Identifier, SessionReference } from "./References.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
2
|
+
import { ClientError, SessionError } from "./Errors.mjs";
|
|
3
|
+
import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
|
|
5
4
|
import { ProviderSession, SessionMetadata, SessionStatus, isTerminalSessionStatus } from "./SessionData.mjs";
|
|
6
5
|
import { Clock, Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
6
|
+
import { BrowserError, Reasons } from "effect-browser/errors";
|
|
7
|
+
//#region src/internal/browser/RequestFailure.ts
|
|
8
|
+
/** Only control-plane reads reach this bridge, before a modeled browser action dispatches. */
|
|
9
|
+
const browserRequestFailure = (operation, error) => {
|
|
10
|
+
const reason = () => {
|
|
11
|
+
switch (error.reason) {
|
|
12
|
+
case "configuration": return Reasons.Configuration.make({});
|
|
13
|
+
case "authorization": return Reasons.Authorization.make({});
|
|
14
|
+
case "rate-limited": return Reasons.RateLimited.make(error.retryAfterMillis === void 0 ? {} : { retryAfterMillis: error.retryAfterMillis });
|
|
15
|
+
case "not-found": return Reasons.NotFound.make({});
|
|
16
|
+
case "active": return Reasons.Active.make({});
|
|
17
|
+
case "disabled": return Reasons.Disabled.make({});
|
|
18
|
+
case "expired": return Reasons.Expired.make({});
|
|
19
|
+
case "transport": return Reasons.Transport.make(error.status === void 0 ? {} : { status: error.status });
|
|
20
|
+
case "timeout": return Reasons.Timeout.make({});
|
|
21
|
+
case "malformed": return Reasons.Malformed.make({});
|
|
22
|
+
case "unsafe-url": return Reasons.UnsafeUrl.make({});
|
|
23
|
+
case "content-type": return Reasons.ContentType.make({});
|
|
24
|
+
case "limit":
|
|
25
|
+
case "provider": return Reasons.Provider.make(error.status === void 0 ? {} : { status: error.status });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return BrowserError.make({
|
|
29
|
+
operation,
|
|
30
|
+
reason: reason(),
|
|
31
|
+
outcome: error.outcome ?? "undispatched"
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
7
35
|
//#region src/internal/browser/LiveView.ts
|
|
8
36
|
const LiveUrl = Schema.String.check(Schema.isMaxLength(16384), Schema.makeFilter((value) => {
|
|
9
37
|
try {
|
|
@@ -49,21 +77,9 @@ const issueLiveUrls = Effect.fnUntraced(function* (client, reference, expiresInS
|
|
|
49
77
|
requestedTtlSeconds: expiresInSeconds
|
|
50
78
|
};
|
|
51
79
|
});
|
|
52
|
-
const issueLiveView = (client, reference, expiresInSeconds) => issueLiveUrls(client, reference, expiresInSeconds).pipe(Effect.mapError((error) =>
|
|
53
|
-
operation: "live-view",
|
|
54
|
-
reason: error.reason
|
|
55
|
-
})));
|
|
80
|
+
const issueLiveView = (client, reference, expiresInSeconds) => issueLiveUrls(client, reference, expiresInSeconds).pipe(Effect.mapError((error) => browserRequestFailure("live-view", error)));
|
|
56
81
|
//#endregion
|
|
57
82
|
//#region src/Sessions.ts
|
|
58
|
-
var Sessions_exports = /* @__PURE__ */ __exportAll({
|
|
59
|
-
BrowserbaseSessions: () => BrowserbaseSessions,
|
|
60
|
-
SessionListQuery: () => SessionListQuery,
|
|
61
|
-
SessionLogEntry: () => SessionLogEntry,
|
|
62
|
-
SessionMetadata: () => SessionMetadata,
|
|
63
|
-
SessionStatus: () => SessionStatus,
|
|
64
|
-
SessionWaitOptions: () => SessionWaitOptions,
|
|
65
|
-
isTerminalSessionStatus: () => isTerminalSessionStatus
|
|
66
|
-
});
|
|
67
83
|
const SessionListQuery = Schema.Struct({
|
|
68
84
|
status: Schema.optionalKey(SessionStatus),
|
|
69
85
|
q: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(2048)))
|
|
@@ -239,6 +255,6 @@ var BrowserbaseSessions = class BrowserbaseSessions extends Context.Service()("e
|
|
|
239
255
|
}));
|
|
240
256
|
};
|
|
241
257
|
//#endregion
|
|
242
|
-
export {
|
|
258
|
+
export { issueLiveView as a, SessionWaitOptions as i, SessionListQuery as n, browserRequestFailure as o, SessionLogEntry as r, BrowserbaseSessions as t };
|
|
243
259
|
|
|
244
|
-
//# sourceMappingURL=Sessions-
|
|
260
|
+
//# sourceMappingURL=Sessions-DoQGg9nB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sessions-DoQGg9nB.mjs","names":[],"sources":["../src/internal/browser/RequestFailure.ts","../src/internal/browser/LiveView.ts","../src/Sessions.ts"],"sourcesContent":["import { BrowserError, Reasons, type BrowserReason } from \"effect-browser/errors\";\n\nimport type { ClientError } from \"../../Errors.ts\";\n\ntype RequestFailure = Pick<ClientError, \"reason\" | \"outcome\" | \"status\" | \"retryAfterMillis\">;\n\n/** Only control-plane reads reach this bridge, before a modeled browser action dispatches. */\nexport const browserRequestFailure = (\n operation: \"connect\" | \"reconnect\" | \"live-view\",\n error: RequestFailure,\n): BrowserError => {\n const reason = (): BrowserReason => {\n switch (error.reason) {\n case \"configuration\":\n return Reasons.Configuration.make({});\n case \"authorization\":\n return Reasons.Authorization.make({});\n case \"rate-limited\":\n return Reasons.RateLimited.make(\n error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis },\n );\n case \"not-found\":\n return Reasons.NotFound.make({});\n case \"active\":\n return Reasons.Active.make({});\n case \"disabled\":\n return Reasons.Disabled.make({});\n case \"expired\":\n return Reasons.Expired.make({});\n case \"transport\":\n return Reasons.Transport.make(error.status === undefined ? {} : { status: error.status });\n case \"timeout\":\n return Reasons.Timeout.make({});\n case \"malformed\":\n return Reasons.Malformed.make({});\n case \"unsafe-url\":\n return Reasons.UnsafeUrl.make({});\n case \"content-type\":\n return Reasons.ContentType.make({});\n // A control-plane limit carries no measured bound. Do not invent native Limit facts.\n case \"limit\":\n case \"provider\":\n return Reasons.Provider.make(error.status === undefined ? {} : { status: error.status });\n }\n };\n\n return BrowserError.make({\n operation,\n reason: reason(),\n outcome: error.outcome ?? \"undispatched\",\n });\n};\n","import { Effect, Redacted, Schema } from \"effect\";\n\nimport type { BrowserbaseClient } from \"../../Client.ts\";\nimport { ClientError } from \"../../Errors.ts\";\nimport { Identifier, type SessionReference } from \"../../References.ts\";\nimport { browserRequestFailure } from \"./RequestFailure.ts\";\n\nconst LiveUrl = Schema.String.check(\n Schema.isMaxLength(16384),\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return (\n url.protocol === \"https:\" &&\n !url.username &&\n !url.password &&\n (url.hostname === \"browserbase.com\" || url.hostname.endsWith(\".browserbase.com\"))\n );\n } catch {\n return false;\n }\n }),\n);\n\nconst Live = Schema.Struct({\n debuggerFullscreenUrl: LiveUrl,\n pages: Schema.Array(Schema.Struct({ id: Identifier, debuggerFullscreenUrl: LiveUrl })).check(\n Schema.isMaxLength(64),\n ),\n});\n\nexport interface LiveView {\n readonly session: Redacted.Redacted<string>;\n readonly pages: ReadonlyArray<{\n readonly liveViewPageId: string;\n readonly url: Redacted.Redacted<string>;\n }>;\n readonly requestedTtlSeconds: number;\n}\n\n/**\n * Issuing a debugger URL is an authorization step, not proof that an operator took control.\n * The URL is redacted here so it cannot be logged or returned as an ordinary model value.\n */\nexport const issueLiveUrls = Effect.fnUntraced(function* (\n client: BrowserbaseClient[\"Service\"],\n reference: SessionReference,\n expiresInSeconds: number,\n) {\n if (!Number.isSafeInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > 21600)\n return yield* ClientError.make({\n operation: \"provider-read\",\n reason: \"configuration\",\n outcome: \"undispatched\",\n });\n if (reference.projectId !== client.projectId)\n return yield* ClientError.make({\n operation: \"provider-read\",\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n const raw = yield* client.json(\n \"GET\",\n `/v1/sessions/${encodeURIComponent(reference.sessionId)}/debug?expiresIn=${expiresInSeconds}`,\n );\n\n const value = yield* Schema.decodeUnknownEffect(Live)(raw).pipe(\n Effect.mapError(() => ClientError.make({ operation: \"provider-read\", reason: \"malformed\" })),\n );\n\n return {\n session: Redacted.make(value.debuggerFullscreenUrl),\n pages: value.pages.map((page) => ({\n liveViewPageId: page.id,\n url: Redacted.make(page.debuggerFullscreenUrl),\n })),\n requestedTtlSeconds: expiresInSeconds,\n } satisfies LiveView;\n});\n\nexport const issueLiveView = (\n client: BrowserbaseClient[\"Service\"],\n reference: SessionReference,\n expiresInSeconds: number,\n) =>\n issueLiveUrls(client, reference, expiresInSeconds).pipe(\n Effect.mapError((error) => browserRequestFailure(\"live-view\", error)),\n );\n","import { Clock, Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport type { ClientError } from \"./Errors.ts\";\nimport { SessionError } from \"./Errors.ts\";\nimport { issueLiveUrls, type LiveView } from \"./internal/browser/LiveView.ts\";\nexport type { LiveView } from \"./internal/browser/LiveView.ts\";\nimport { SessionReference } from \"./References.ts\";\nimport {\n ProviderSession,\n SessionMetadata,\n SessionStatus,\n isTerminalSessionStatus,\n} from \"./SessionData.ts\";\nexport { SessionMetadata, SessionStatus, isTerminalSessionStatus } from \"./SessionData.ts\";\n\nexport const SessionListQuery = Schema.Struct({\n status: Schema.optionalKey(SessionStatus),\n q: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(2048))),\n});\n\nexport type SessionListQuery = typeof SessionListQuery.Type;\n\nexport const SessionWaitOptions = Schema.Struct({\n timeoutMillis: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 600000 })),\n pollIntervalMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 25, maximum: 5000 })),\n ),\n});\n\nexport type SessionWaitOptions = typeof SessionWaitOptions.Type;\n\nconst Millis = Schema.Finite;\n\n/**\n * One CDP-level log entry. Protocol payloads are present only when requested: they carry\n * page content, cookies and typed input, so they are host evidence, never model input.\n */\nexport class SessionLogEntry extends Schema.Class<SessionLogEntry>(\"BrowserbaseSessionLogEntry\")({\n method: Schema.String.check(Schema.isMaxLength(256)),\n pageId: Schema.Int,\n frameId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),\n loaderId: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(256))),\n timestamp: Schema.optionalKey(Millis),\n requestTimestamp: Schema.optionalKey(Millis),\n responseTimestamp: Schema.optionalKey(Millis),\n params: Schema.optionalKey(Schema.Json),\n result: Schema.optionalKey(Schema.Json),\n}) {}\n\nconst ProviderLog = Schema.Struct({\n method: SessionLogEntry.fields.method,\n pageId: Schema.Int,\n sessionId: Schema.String,\n frameId: SessionLogEntry.fields.frameId,\n loaderId: SessionLogEntry.fields.loaderId,\n timestamp: Schema.optionalKey(Millis),\n request: Schema.optionalKey(\n Schema.Struct({\n params: Schema.optionalKey(Schema.Json),\n timestamp: Schema.optionalKey(Millis),\n }),\n ),\n response: Schema.optionalKey(\n Schema.Struct({\n result: Schema.optionalKey(Schema.Json),\n timestamp: Schema.optionalKey(Millis),\n }),\n ),\n});\n\nexport interface SessionLogOptions {\n /** Include CDP `params`/`result` payloads. Off by default; see `SessionLogEntry`. */\n readonly includePayloads?: boolean;\n}\n\nconst now = Clock.monotonicTimeNanos.pipe(Effect.map((value) => Number(value) / 1000000));\n\nconst fromClient = (operation: SessionError[\"operation\"], error: ClientError): SessionError =>\n SessionError.make({\n operation,\n reason: error.reason,\n ...(error.outcome === undefined ? {} : { outcome: error.outcome }),\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis }),\n });\n\nconst malformed = (operation: SessionError[\"operation\"], mutation = false) =>\n SessionError.make({\n operation,\n reason: \"malformed\",\n ...(mutation ? { outcome: \"unknown\" as const } : {}),\n });\n\nconst configuration = (operation: SessionError[\"operation\"]) =>\n SessionError.make({ operation, reason: \"configuration\", outcome: \"undispatched\" });\n\n/** Passive inspection never releases a remote session. Release is a separate explicit mutation. */\nexport class BrowserbaseSessions extends Context.Service<\n BrowserbaseSessions,\n {\n readonly retrieve: (\n reference: SessionReference,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n readonly list: (\n query?: SessionListQuery,\n ) => Effect.Effect<ReadonlyArray<SessionMetadata>, SessionError>;\n readonly requestRelease: (\n reference: SessionReference,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n readonly waitForTerminal: (\n reference: SessionReference,\n options: SessionWaitOptions,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n readonly waitUntilRunning: (\n reference: SessionReference,\n options: SessionWaitOptions,\n ) => Effect.Effect<SessionMetadata, SessionError>;\n /** Session logs, bounded by the 1 MiB control-plane reply limit (`reason: \"limit\"`). */\n readonly logs: (\n reference: SessionReference,\n options?: SessionLogOptions,\n ) => Effect.Effect<ReadonlyArray<SessionLogEntry>, SessionError>;\n /**\n * Redacted Live View URLs for any session in the project, owned or not. Issuing a URL\n * grants view and input access to whoever holds it; it does not pause automation.\n */\n readonly liveUrls: (\n reference: SessionReference,\n expiresInSeconds?: number,\n ) => Effect.Effect<LiveView, SessionError>;\n }\n>()(\"effect-browserbase/Sessions\") {\n static readonly layer: Layer.Layer<BrowserbaseSessions, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseSessions,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const validate = Effect.fnUntraced(function* (\n reference: SessionReference,\n operation: SessionError[\"operation\"],\n ) {\n const ref = yield* Schema.decodeEffect(SessionReference)(reference, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(operation)));\n\n if (ref.projectId !== client.projectId)\n return yield* SessionError.make({\n operation,\n reason: \"authorization\",\n outcome: \"undispatched\",\n });\n\n return ref;\n });\n\n const decode = Effect.fnUntraced(function* (\n raw: unknown,\n operation: SessionError[\"operation\"],\n expected?: SessionReference,\n mutation = false,\n ) {\n const value = yield* Schema.decodeUnknownEffect(ProviderSession)(raw).pipe(\n Effect.mapError(() => malformed(operation, mutation)),\n );\n\n if (\n value.projectId !== client.projectId ||\n (expected !== undefined &&\n (value.id !== expected.sessionId || value.projectId !== expected.projectId))\n )\n return yield* malformed(operation, mutation);\n const { id, projectId, ...metadata } = value;\n\n return SessionMetadata.make({\n reference: SessionReference.make({ provider: \"browserbase\", projectId, sessionId: id }),\n ...metadata,\n });\n });\n\n const read = Effect.fnUntraced(function* (reference: SessionReference, deadline?: number) {\n const ref = yield* validate(reference, \"session-retrieve\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, undefined, deadline)\n .pipe(Effect.mapError((error) => fromClient(\"session-retrieve\", error)));\n\n return yield* decode(raw, \"session-retrieve\", ref);\n });\n\n const retrieve = Effect.fn(\"BrowserbaseSessions.retrieve\")(function* (\n reference: SessionReference,\n ) {\n return yield* read(reference);\n });\n\n const list = Effect.fn(\"BrowserbaseSessions.list\")(function* (query: SessionListQuery = {}) {\n const checked = yield* Schema.decodeEffect(SessionListQuery)(query, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(\"session-list\")));\n\n const search = new URLSearchParams();\n\n if (checked.status !== undefined) search.set(\"status\", checked.status);\n if (checked.q !== undefined) search.set(\"q\", checked.q);\n\n const raw = yield* client\n .json(\"GET\", `/v1/sessions${search.size === 0 ? \"\" : `?${search}`}`)\n .pipe(Effect.mapError((error) => fromClient(\"session-list\", error)));\n\n const rows = yield* Schema.decodeUnknownEffect(\n Schema.Array(ProviderSession).check(Schema.isMaxLength(1024)),\n )(raw).pipe(Effect.mapError(() => malformed(\"session-list\")));\n\n if (new Set(rows.map((row) => row.id)).size !== rows.length)\n return yield* malformed(\"session-list\");\n const output: SessionMetadata[] = [];\n\n for (const row of rows) output.push(yield* decode(row, \"session-list\"));\n\n return output;\n });\n\n const requestRelease = Effect.fn(\"BrowserbaseSessions.requestRelease\")(function* (\n reference: SessionReference,\n ) {\n const ref = yield* validate(reference, \"session-release\");\n\n const raw = yield* client\n .json(\"POST\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}`, {\n projectId: ref.projectId,\n status: \"REQUEST_RELEASE\",\n })\n .pipe(Effect.mapError((error) => fromClient(\"session-release\", error)));\n\n return yield* decode(raw, \"session-release\", ref, true);\n });\n\n const wait = Effect.fnUntraced(function* (\n reference: SessionReference,\n options: SessionWaitOptions,\n untilRunning: boolean,\n ) {\n const bounds = yield* Schema.decodeEffect(SessionWaitOptions)(options, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => configuration(\"session-wait\")));\n\n const deadline = (yield* now) + bounds.timeoutMillis;\n\n for (;;) {\n const remaining = deadline - (yield* now);\n\n if (remaining <= 0)\n return yield* SessionError.make({ operation: \"session-wait\", reason: \"timeout\" });\n\n // The deadline bounds the provider read too, not just sleeps between reads.\n const metadata = yield* read(reference, deadline).pipe(\n Effect.timeoutOrElse({\n duration: remaining,\n orElse: () =>\n Effect.fail(SessionError.make({ operation: \"session-wait\", reason: \"timeout\" })),\n }),\n );\n\n if (\n untilRunning ? metadata.status === \"RUNNING\" : isTerminalSessionStatus(metadata.status)\n )\n return metadata;\n if (untilRunning && isTerminalSessionStatus(metadata.status))\n return yield* SessionError.make({ operation: \"session-wait\", reason: \"expired\" });\n yield* Effect.sleep(\n Math.max(0, Math.min(bounds.pollIntervalMillis ?? 250, deadline - (yield* now))),\n );\n }\n });\n\n const logs = Effect.fn(\"BrowserbaseSessions.logs\")(function* (\n reference: SessionReference,\n options: SessionLogOptions = {},\n ) {\n const ref = yield* validate(reference, \"session-logs\");\n\n const raw = yield* client\n .json(\"GET\", `/v1/sessions/${encodeURIComponent(ref.sessionId)}/logs`)\n .pipe(Effect.mapError((error) => fromClient(\"session-logs\", error)));\n\n const rows = yield* Schema.decodeUnknownEffect(\n Schema.Array(ProviderLog).check(Schema.isMaxLength(100_000)),\n )(raw).pipe(Effect.mapError(() => malformed(\"session-logs\")));\n\n if (rows.some((row) => row.sessionId !== ref.sessionId))\n return yield* malformed(\"session-logs\");\n\n return rows.map((row) =>\n SessionLogEntry.make({\n method: row.method,\n pageId: row.pageId,\n ...(row.frameId === undefined ? {} : { frameId: row.frameId }),\n ...(row.loaderId === undefined ? {} : { loaderId: row.loaderId }),\n ...(row.timestamp === undefined ? {} : { timestamp: row.timestamp }),\n ...(row.request?.timestamp === undefined\n ? {}\n : { requestTimestamp: row.request.timestamp }),\n ...(row.response?.timestamp === undefined\n ? {}\n : { responseTimestamp: row.response.timestamp }),\n ...(options.includePayloads === true && row.request?.params !== undefined\n ? { params: row.request.params }\n : {}),\n ...(options.includePayloads === true && row.response?.result !== undefined\n ? { result: row.response.result }\n : {}),\n }),\n );\n });\n\n const liveUrls = Effect.fn(\"BrowserbaseSessions.liveUrls\")(function* (\n reference: SessionReference,\n expiresInSeconds = 300,\n ) {\n const ref = yield* validate(reference, \"session-live-view\");\n\n return yield* issueLiveUrls(client, ref, expiresInSeconds).pipe(\n Effect.mapError((error) => fromClient(\"session-live-view\", error)),\n );\n });\n\n return BrowserbaseSessions.of({\n logs,\n liveUrls,\n retrieve,\n list,\n requestRelease,\n waitForTerminal: (ref, options) => wait(ref, options, false),\n waitUntilRunning: (ref, options) => wait(ref, options, true),\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;AAOA,MAAa,yBACX,WACA,UACiB;CACjB,MAAM,eAA8B;EAClC,QAAQ,MAAM,QAAd;GACE,KAAK,iB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AW,IAAI,UAAU;IAClE,GAAI,IAAI,SAAS,cAAc,KAAA,IAC3B,CAAC,IACD,EAAE,kBAAkB,IAAI,QAAQ,UAAU;IAC9C,GAAI,IAAI,UAAU,cAAc,KAAA,IAC5B,CAAC,IACD,EAAE,mBAAmB,IAAI,SAAS,UAAU;IAChD,GAAI,QAAQ,oBAAoB,QAAQ,IAAI,SAAS,WAAW,KAAA,IAC5D,EAAE,QAAQ,IAAI,QAAQ,OAAO,IAC7B,CAAC;IACL,GAAI,QAAQ,oBAAoB,QAAQ,IAAI,UAAU,WAAW,KAAA,IAC7D,EAAE,QAAQ,IAAI,SAAS,OAAO,IAC9B,CAAC;GACP,CAAC,CACH;EACF,CAAC;EAED,MAAM,WAAW,OAAO,GAAG,8BAA8B,CAAC,CAAC,WACzD,WACA,mBAAmB,KACnB;GACA,MAAM,MAAM,OAAO,SAAS,WAAW,mBAAmB;GAE1D,OAAO,OAAO,cAAc,QAAQ,KAAK,gBAAgB,CAAC,CAAC,KACzD,OAAO,UAAU,UAAU,WAAW,qBAAqB,KAAK,CAAC,CACnE;EACF,CAAC;EAED,OAAO,oBAAoB,GAAG;GAC5B;GACA;GACA;GACA;GACA;GACA,kBAAkB,KAAK,YAAY,KAAK,KAAK,SAAS,KAAK;GAC3D,mBAAmB,KAAK,YAAY,KAAK,KAAK,SAAS,IAAI;EAC7D,CAAC;CACH,CAAC,CACH;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SessionReference } from "./References-DOH3Wu44.mjs";
|
|
2
2
|
import { SessionError } from "./Errors.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { BrowserbaseClient } from "./Client.mjs";
|
|
4
|
+
import { n as SessionMetadata } from "./SessionData-5xYZDshJ.mjs";
|
|
5
5
|
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
6
6
|
//#region src/internal/browser/LiveView.d.ts
|
|
7
7
|
interface LiveView {
|
|
@@ -12,9 +12,8 @@ interface LiveView {
|
|
|
12
12
|
}>;
|
|
13
13
|
readonly requestedTtlSeconds: number;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/Sessions.d.ts
|
|
18
17
|
declare const SessionListQuery: Schema.Struct<{
|
|
19
18
|
readonly status: Schema.optionalKey<Schema.Literals<readonly ["PENDING", "RUNNING", "ERROR", "TIMED_OUT", "COMPLETED"]>>;
|
|
20
19
|
readonly q: Schema.optionalKey<Schema.NonEmptyString>;
|
|
@@ -64,5 +63,6 @@ declare class BrowserbaseSessions extends BrowserbaseSessions_base {
|
|
|
64
63
|
static readonly layer: Layer.Layer<BrowserbaseSessions, never, BrowserbaseClient>;
|
|
65
64
|
}
|
|
66
65
|
//#endregion
|
|
67
|
-
export { SessionWaitOptions as a, SessionLogOptions as i, SessionListQuery as n,
|
|
68
|
-
|
|
66
|
+
export { SessionWaitOptions as a, SessionLogOptions as i, SessionListQuery as n, LiveView as o, SessionLogEntry as r, BrowserbaseSessions as t };
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=Sessions-tFJYaXFq.d.mts.map
|
package/dist/Sessions.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { a as SessionWaitOptions, i as SessionLogOptions, n as SessionListQuery,
|
|
2
|
-
import {
|
|
3
|
-
export { BrowserbaseSessions, type LiveView, SessionListQuery, SessionLogEntry, SessionLogOptions, SessionMetadata, SessionStatus, SessionWaitOptions, isTerminalSessionStatus };
|
|
1
|
+
import { a as SessionWaitOptions, i as SessionLogOptions, n as SessionListQuery, o as LiveView, r as SessionLogEntry, t as BrowserbaseSessions } from "./Sessions-tFJYaXFq.mjs";
|
|
2
|
+
import { i as isTerminalSessionStatus, n as SessionMetadata, r as SessionStatus } from "./SessionData-5xYZDshJ.mjs";
|
|
3
|
+
export { BrowserbaseSessions, type LiveView, SessionListQuery, SessionLogEntry, SessionLogOptions, SessionMetadata, SessionStatus, SessionWaitOptions, isTerminalSessionStatus };
|
|
4
|
+
export {};
|
package/dist/Sessions.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SessionMetadata, SessionStatus, isTerminalSessionStatus } from "./SessionData.mjs";
|
|
2
|
-
import { i as SessionWaitOptions, n as SessionListQuery, r as SessionLogEntry, t as BrowserbaseSessions } from "./Sessions-
|
|
2
|
+
import { i as SessionWaitOptions, n as SessionListQuery, r as SessionLogEntry, t as BrowserbaseSessions } from "./Sessions-DoQGg9nB.mjs";
|
|
3
3
|
export { BrowserbaseSessions, SessionListQuery, SessionLogEntry, SessionMetadata, SessionStatus, SessionWaitOptions, isTerminalSessionStatus };
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SessionReference } from "./References-DOH3Wu44.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const PositiveInt: Schema.Int;
|
|
3
|
+
import { InlineFile, PositiveInt, SafeFilename as SafeFilename$1 } from "effect-browser/browser-data";
|
|
4
|
+
//#region src/Transfers.d.ts
|
|
7
5
|
/** Shared caller-owned transfer bounds. Omitted timeout retains the 60-second default. */
|
|
8
6
|
declare const ArtifactTransferPolicy: Schema.Struct<{
|
|
9
7
|
readonly maxBytes: Schema.Int;
|
|
10
8
|
readonly timeoutMillis: Schema.optionalKey<Schema.Int>;
|
|
11
9
|
}>;
|
|
12
10
|
type ArtifactTransferPolicy = typeof ArtifactTransferPolicy.Type;
|
|
13
|
-
/** Portable basename only; never a local or remote filesystem path. */
|
|
14
|
-
declare const SafeFilename: Schema.NonEmptyString;
|
|
15
11
|
/**
|
|
16
12
|
* A path the provider reported for a file it already holds. It is only ever decoded from a
|
|
17
13
|
* provider response: no caller, and certainly no model, names a remote filesystem path.
|
|
@@ -71,6 +67,23 @@ declare const ReplayPage_base: Schema.Class<ReplayPage, Schema.Struct<{
|
|
|
71
67
|
readonly endTimeMs: Schema.Finite;
|
|
72
68
|
}>, {}>;
|
|
73
69
|
declare class ReplayPage extends ReplayPage_base {}
|
|
70
|
+
/**
|
|
71
|
+
* The uploaded branch carries receipts, not paths. Attachment authority is the identity of a
|
|
72
|
+
* receipt this package issued for this exact session, so decoding one back into a new value
|
|
73
|
+
* would discard the very evidence being checked.
|
|
74
|
+
*/
|
|
75
|
+
type FileSelection = {
|
|
76
|
+
readonly _tag: "Inline";
|
|
77
|
+
readonly files: ReadonlyArray<InlineFile>;
|
|
78
|
+
} | {
|
|
79
|
+
readonly _tag: "Uploaded";
|
|
80
|
+
readonly uploads: ReadonlyArray<UploadReceipt>;
|
|
81
|
+
};
|
|
82
|
+
interface SelectFilesRequest {
|
|
83
|
+
readonly selector: string;
|
|
84
|
+
readonly selection: FileSelection;
|
|
85
|
+
}
|
|
74
86
|
//#endregion
|
|
75
|
-
export {
|
|
76
|
-
|
|
87
|
+
export { PositiveInt as a, RecordingPageReference as c, SafeFilename$1 as d, SelectFilesRequest as f, FileSelection as i, RemoteFilePath as l, DownloadMetadata as n, RecordingBatch as o, UploadReceipt as p, DownloadObservation as r, RecordingPage as s, ArtifactTransferPolicy as t, ReplayPage as u };
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=Transfers-GVqzrDWl.d.mts.map
|
package/dist/Transfers.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, UploadReceipt };
|
|
1
|
+
import { a as PositiveInt, c as RecordingPageReference, d as SafeFilename, f as SelectFilesRequest, i as FileSelection, l as RemoteFilePath, n as DownloadMetadata, o as RecordingBatch, p as UploadReceipt, r as DownloadObservation, s as RecordingPage, t as ArtifactTransferPolicy, u as ReplayPage } from "./Transfers-GVqzrDWl.mjs";
|
|
2
|
+
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, FileSelection, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, SelectFilesRequest, UploadReceipt };
|
|
3
|
+
export {};
|
package/dist/Transfers.mjs
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Identifier, SessionReference } from "./References.mjs";
|
|
1
|
+
import { Identifier as Identifier$1, SessionReference } from "./References.mjs";
|
|
3
2
|
import { Schema } from "effect";
|
|
3
|
+
import { PositiveInt, SafeFilename, SafeFilename as SafeFilename$1 } from "effect-browser/browser-data";
|
|
4
4
|
//#region src/Transfers.ts
|
|
5
|
-
var Transfers_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
-
ArtifactTransferPolicy: () => ArtifactTransferPolicy,
|
|
7
|
-
DownloadMetadata: () => DownloadMetadata,
|
|
8
|
-
DownloadObservation: () => DownloadObservation,
|
|
9
|
-
PositiveInt: () => PositiveInt,
|
|
10
|
-
RecordingBatch: () => RecordingBatch,
|
|
11
|
-
RecordingPage: () => RecordingPage,
|
|
12
|
-
RecordingPageReference: () => RecordingPageReference,
|
|
13
|
-
RemoteFilePath: () => RemoteFilePath,
|
|
14
|
-
ReplayPage: () => ReplayPage,
|
|
15
|
-
SafeFilename: () => SafeFilename,
|
|
16
|
-
UploadReceipt: () => UploadReceipt
|
|
17
|
-
});
|
|
18
|
-
const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));
|
|
19
5
|
/** Shared caller-owned transfer bounds. Omitted timeout retains the 60-second default. */
|
|
20
6
|
const ArtifactTransferPolicy = Schema.Struct({
|
|
21
7
|
maxBytes: Schema.Int.check(Schema.isBetween({
|
|
@@ -27,8 +13,6 @@ const ArtifactTransferPolicy = Schema.Struct({
|
|
|
27
13
|
maximum: 6e5
|
|
28
14
|
})))
|
|
29
15
|
});
|
|
30
|
-
/** Portable basename only; never a local or remote filesystem path. */
|
|
31
|
-
const SafeFilename = Schema.NonEmptyString.check(Schema.isMaxLength(240), Schema.makeFilter((value) => value !== "." && value !== ".." && !/[\x00-\x1f\x7f/\\:]/.test(value) && !/[. ]$/.test(value) && !/^\s/.test(value) && !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(value), { title: "a portable, non-path download filename" }));
|
|
32
16
|
/**
|
|
33
17
|
* A path the provider reported for a file it already holds. It is only ever decoded from a
|
|
34
18
|
* provider response: no caller, and certainly no model, names a remote filesystem path.
|
|
@@ -40,15 +24,15 @@ const RemoteFilePath = Schema.NonEmptyString.check(Schema.isMaxLength(4096), Sch
|
|
|
40
24
|
*/
|
|
41
25
|
var UploadReceipt = class extends Schema.Class("BrowserbaseUploadReceipt")({
|
|
42
26
|
reference: SessionReference,
|
|
43
|
-
filename: SafeFilename,
|
|
27
|
+
filename: SafeFilename$1,
|
|
44
28
|
bytes: Schema.Natural,
|
|
45
29
|
remotePath: Schema.optionalKey(RemoteFilePath),
|
|
46
30
|
acknowledgement: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024)))
|
|
47
31
|
}) {};
|
|
48
32
|
var DownloadMetadata = class extends Schema.Class("BrowserbaseDownloadMetadata")({
|
|
49
|
-
id: Identifier,
|
|
50
|
-
sessionId: Identifier,
|
|
51
|
-
filename: SafeFilename,
|
|
33
|
+
id: Identifier$1,
|
|
34
|
+
sessionId: Identifier$1,
|
|
35
|
+
filename: SafeFilename$1,
|
|
52
36
|
mimeType: Schema.NonEmptyString.check(Schema.isMaxLength(128)),
|
|
53
37
|
size: Schema.Natural,
|
|
54
38
|
checksum: Schema.String.check(Schema.isPattern(/^[a-fA-F0-9]{64}$/)),
|
|
@@ -57,8 +41,8 @@ var DownloadMetadata = class extends Schema.Class("BrowserbaseDownloadMetadata")
|
|
|
57
41
|
/** A native event identity is not a provider download ID. Associate provider metadata explicitly. */
|
|
58
42
|
var DownloadObservation = class extends Schema.Class("BrowserbaseDownloadObservation")({
|
|
59
43
|
reference: SessionReference,
|
|
60
|
-
downloadId: Identifier,
|
|
61
|
-
filename: SafeFilename,
|
|
44
|
+
downloadId: Identifier$1,
|
|
45
|
+
filename: SafeFilename$1,
|
|
62
46
|
state: Schema.Literals([
|
|
63
47
|
"started",
|
|
64
48
|
"completed",
|
|
@@ -68,10 +52,10 @@ var DownloadObservation = class extends Schema.Class("BrowserbaseDownloadObserva
|
|
|
68
52
|
}) {};
|
|
69
53
|
var RecordingPageReference = class extends Schema.Class("BrowserbaseRecordingPageReference")({
|
|
70
54
|
session: SessionReference,
|
|
71
|
-
pageId: Identifier
|
|
55
|
+
pageId: Identifier$1
|
|
72
56
|
}) {};
|
|
73
57
|
var RecordingPage = class extends Schema.Class("BrowserbaseRecordingPage")({
|
|
74
|
-
pageId: Identifier,
|
|
58
|
+
pageId: Identifier$1,
|
|
75
59
|
status: Schema.Literals([
|
|
76
60
|
"NOT_REQUESTED",
|
|
77
61
|
"PENDING",
|
|
@@ -91,11 +75,11 @@ var RecordingBatch = class extends Schema.Class("BrowserbaseRecordingBatch")({
|
|
|
91
75
|
timedOut: Schema.Boolean
|
|
92
76
|
}) {};
|
|
93
77
|
var ReplayPage = class extends Schema.Class("BrowserbaseReplayPage")({
|
|
94
|
-
pageId: Identifier,
|
|
78
|
+
pageId: Identifier$1,
|
|
95
79
|
startTimeMs: Schema.Finite,
|
|
96
80
|
endTimeMs: Schema.Finite
|
|
97
81
|
}) {};
|
|
98
82
|
//#endregion
|
|
99
|
-
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, UploadReceipt
|
|
83
|
+
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, UploadReceipt };
|
|
100
84
|
|
|
101
85
|
//# sourceMappingURL=Transfers.mjs.map
|
package/dist/Transfers.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transfers.mjs","names":[],"sources":["../src/Transfers.ts"],"sourcesContent":["import { Schema } from \"effect\";\
|
|
1
|
+
{"version":3,"file":"Transfers.mjs","names":["SafeFilename","Identifier"],"sources":["../src/Transfers.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { type InlineFile, SafeFilename } from \"effect-browser/browser-data\";\n\nexport { PositiveInt, SafeFilename } from \"effect-browser/browser-data\";\n\nimport { Identifier, SessionReference } from \"./References.ts\";\n\n/** Shared caller-owned transfer bounds. Omitted timeout retains the 60-second default. */\nexport const ArtifactTransferPolicy = Schema.Struct({\n maxBytes: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 2 ** 31 - 1 })),\n timeoutMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 600_000 })),\n ),\n});\n\nexport type ArtifactTransferPolicy = typeof ArtifactTransferPolicy.Type;\n\n/**\n * A path the provider reported for a file it already holds. It is only ever decoded from a\n * provider response: no caller, and certainly no model, names a remote filesystem path.\n */\nexport const RemoteFilePath = Schema.NonEmptyString.check(\n Schema.isMaxLength(4096),\n Schema.makeFilter(\n (value) =>\n value.startsWith(\"/\") &&\n !value.includes(\"\\\\\") &&\n !value.includes(\"//\") &&\n ![...value].some((character) => character < \" \" || character === \"\\x7f\") &&\n value.split(\"/\").every((segment) => segment !== \".\" && segment !== \"..\"),\n { title: \"an absolute, traversal-free remote path\" },\n ),\n);\n\n/**\n * Evidence of one accepted upload. `remotePath` exists only when the provider returned one;\n * its absence is reported rather than guessed, and attachment is refused without it.\n */\nexport class UploadReceipt extends Schema.Class<UploadReceipt>(\"BrowserbaseUploadReceipt\")({\n reference: SessionReference,\n filename: SafeFilename,\n bytes: Schema.Natural,\n remotePath: Schema.optionalKey(RemoteFilePath),\n acknowledgement: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n}) {}\n\nexport class DownloadMetadata extends Schema.Class<DownloadMetadata>(\"BrowserbaseDownloadMetadata\")(\n {\n id: Identifier,\n sessionId: Identifier,\n filename: SafeFilename,\n mimeType: Schema.NonEmptyString.check(Schema.isMaxLength(128)),\n size: Schema.Natural,\n checksum: Schema.String.check(Schema.isPattern(/^[a-fA-F0-9]{64}$/)),\n createdAt: Schema.NonEmptyString.check(Schema.isMaxLength(64)),\n },\n) {}\n\n/** A native event identity is not a provider download ID. Associate provider metadata explicitly. */\nexport class DownloadObservation extends Schema.Class<DownloadObservation>(\n \"BrowserbaseDownloadObservation\",\n)({\n reference: SessionReference,\n downloadId: Identifier,\n filename: SafeFilename,\n state: Schema.Literals([\"started\", \"completed\", \"failed\", \"unknown\"]),\n}) {}\n\nexport class RecordingPageReference extends Schema.Class<RecordingPageReference>(\n \"BrowserbaseRecordingPageReference\",\n)({\n session: SessionReference,\n pageId: Identifier,\n}) {}\n\nexport class RecordingPage extends Schema.Class<RecordingPage>(\"BrowserbaseRecordingPage\")({\n pageId: Identifier,\n status: Schema.Literals([\"NOT_REQUESTED\", \"PENDING\", \"COMPLETED\", \"FAILED\"]),\n delivery: Schema.Literals([\"not-ready\", \"download\", \"external-storage\"]),\n completedAt: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(64))),\n}) {}\n\nexport class RecordingBatch extends Schema.Class<RecordingBatch>(\"BrowserbaseRecordingBatch\")({\n reference: SessionReference,\n pages: Schema.Array(RecordingPage).check(Schema.isMaxLength(256)),\n timedOut: Schema.Boolean,\n}) {}\n\nexport class ReplayPage extends Schema.Class<ReplayPage>(\"BrowserbaseReplayPage\")({\n pageId: Identifier,\n startTimeMs: Schema.Finite,\n endTimeMs: Schema.Finite,\n}) {}\n\n/**\n * The uploaded branch carries receipts, not paths. Attachment authority is the identity of a\n * receipt this package issued for this exact session, so decoding one back into a new value\n * would discard the very evidence being checked.\n */\nexport type FileSelection =\n | { readonly _tag: \"Inline\"; readonly files: ReadonlyArray<InlineFile> }\n | { readonly _tag: \"Uploaded\"; readonly uploads: ReadonlyArray<UploadReceipt> };\n\nexport interface SelectFilesRequest {\n readonly selector: string;\n readonly selection: FileSelection;\n}\n"],"mappings":";;;;;AAQA,MAAa,yBAAyB,OAAO,OAAO;CAClD,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS,KAAK,KAAK;CAAE,CAAC,CAAC;CACjF,eAAe,OAAO,YACpB,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAQ,CAAC,CAAC,CACrE;AACF,CAAC;;;;;AAQD,MAAa,iBAAiB,OAAO,eAAe,MAClD,OAAO,YAAY,IAAI,GACvB,OAAO,YACJ,UACC,MAAM,WAAW,GAAG,KACpB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,cAAc,YAAY,OAAO,cAAc,GAAM,KACvE,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,YAAY,YAAY,OAAO,YAAY,IAAI,GACzE,EAAE,OAAO,0CAA0C,CACrD,CACF;;;;;AAMA,IAAa,gBAAb,cAAmC,OAAO,MAAqB,0BAA0B,CAAC,CAAC;CACzF,WAAW;CACX,UAAUA;CACV,OAAO,OAAO;CACd,YAAY,OAAO,YAAY,cAAc;CAC7C,iBAAiB,OAAO,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,IAAI,CAAC,CAAC;AACnF,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,mBAAb,cAAsC,OAAO,MAAwB,6BAA6B,CAAC,CACjG;CACE,IAAIC;CACJ,WAAWA;CACX,UAAUD;CACV,UAAU,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;CAC7D,MAAM,OAAO;CACb,UAAU,OAAO,OAAO,MAAM,OAAO,UAAU,mBAAmB,CAAC;CACnE,WAAW,OAAO,eAAe,MAAM,OAAO,YAAY,EAAE,CAAC;AAC/D,CACF,CAAC,CAAC,CAAC;;AAGH,IAAa,sBAAb,cAAyC,OAAO,MAC9C,gCACF,CAAC,CAAC;CACA,WAAW;CACX,YAAYC;CACZ,UAAUD;CACV,OAAO,OAAO,SAAS;EAAC;EAAW;EAAa;EAAU;CAAS,CAAC;AACtE,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,yBAAb,cAA4C,OAAO,MACjD,mCACF,CAAC,CAAC;CACA,SAAS;CACT,QAAQC;AACV,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,gBAAb,cAAmC,OAAO,MAAqB,0BAA0B,CAAC,CAAC;CACzF,QAAQA;CACR,QAAQ,OAAO,SAAS;EAAC;EAAiB;EAAW;EAAa;CAAQ,CAAC;CAC3E,UAAU,OAAO,SAAS;EAAC;EAAa;EAAY;CAAkB,CAAC;CACvE,aAAa,OAAO,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,iBAAb,cAAoC,OAAO,MAAsB,2BAA2B,CAAC,CAAC;CAC5F,WAAW;CACX,OAAO,OAAO,MAAM,aAAa,CAAC,CAAC,MAAM,OAAO,YAAY,GAAG,CAAC;CAChE,UAAU,OAAO;AACnB,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,aAAb,cAAgC,OAAO,MAAkB,uBAAuB,CAAC,CAAC;CAChF,QAAQA;CACR,aAAa,OAAO;CACpB,WAAW,OAAO;AACpB,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/Uploads.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as SessionReference } from "./References-DOH3Wu44.mjs";
|
|
2
2
|
import { FileError } from "./Errors.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as BrowserbaseSessions } from "./Sessions-
|
|
5
|
-
import {
|
|
3
|
+
import { BrowserbaseClient } from "./Client.mjs";
|
|
4
|
+
import { t as BrowserbaseSessions } from "./Sessions-tFJYaXFq.mjs";
|
|
5
|
+
import { p as UploadReceipt } from "./Transfers-GVqzrDWl.mjs";
|
|
6
6
|
import { Context, Effect, Layer } from "effect";
|
|
7
|
-
|
|
8
|
-
export { BrowserbaseUploads, UploadFile };
|
|
9
|
-
}
|
|
7
|
+
//#region src/Uploads.d.ts
|
|
10
8
|
export interface UploadFile {
|
|
11
9
|
readonly filename: string;
|
|
12
10
|
readonly mediaType: string;
|
|
@@ -25,5 +23,5 @@ export declare class BrowserbaseUploads extends BrowserbaseUploads_base {
|
|
|
25
23
|
static readonly layer: Layer.Layer<BrowserbaseUploads, never, BrowserbaseClient | BrowserbaseSessions>;
|
|
26
24
|
}
|
|
27
25
|
//#endregion
|
|
28
|
-
export {
|
|
26
|
+
export {};
|
|
29
27
|
//# sourceMappingURL=Uploads.d.mts.map
|
package/dist/Uploads.mjs
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { FileError } from "./Errors.mjs";
|
|
3
2
|
import { RemoteFilePath, SafeFilename, UploadReceipt } from "./Transfers.mjs";
|
|
4
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
5
|
-
import { t as BrowserbaseSessions } from "./Sessions-
|
|
3
|
+
import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
|
|
4
|
+
import { t as BrowserbaseSessions } from "./Sessions-DoQGg9nB.mjs";
|
|
6
5
|
import { n as recordIssuedUpload } from "./Issued-DejqoMYL.mjs";
|
|
7
6
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
8
7
|
//#region src/Uploads.ts
|
|
9
|
-
var Uploads_exports = /* @__PURE__ */ __exportAll({ BrowserbaseUploads: () => BrowserbaseUploads });
|
|
10
8
|
/** The provider's documented per-file ceiling for a session upload. */
|
|
11
9
|
const MAX_UPLOAD_BYTES = 536870912;
|
|
12
10
|
const MediaType = Schema.NonEmptyString.check(Schema.isMaxLength(128), Schema.isPattern(/^[a-z0-9][a-z0-9!#$&^_+.-]*\/[a-z0-9][a-z0-9!#$&^_+.-]*$/));
|
|
@@ -102,6 +100,6 @@ var BrowserbaseUploads = class BrowserbaseUploads extends Context.Service()("eff
|
|
|
102
100
|
}));
|
|
103
101
|
};
|
|
104
102
|
//#endregion
|
|
105
|
-
export { BrowserbaseUploads
|
|
103
|
+
export { BrowserbaseUploads };
|
|
106
104
|
|
|
107
105
|
//# sourceMappingURL=Uploads.mjs.map
|
package/dist/Uploads.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Uploads.mjs","names":[],"sources":["../src/Uploads.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { type ClientError, FileError } from \"./Errors.ts\";\nimport { recordIssuedUpload } from \"./internal/upload/Issued.ts\";\nimport type { SessionReference } from \"./References.ts\";\nimport { BrowserbaseSessions } from \"./Sessions.ts\";\nimport { RemoteFilePath, SafeFilename, UploadReceipt } from \"./Transfers.ts\";\n\n/** The provider's documented per-file ceiling for a session upload. */\nconst MAX_UPLOAD_BYTES = 512 * 1024 * 1024;\n\nconst MediaType = Schema.NonEmptyString.check(\n Schema.isMaxLength(128),\n Schema.isPattern(/^[a-z0-9][a-z0-9!#$&^_+.-]*\\/[a-z0-9][a-z0-9!#$&^_+.-]*$/),\n);\n\nconst UploadOptions = Schema.Struct({\n filename: SafeFilename,\n mediaType: MediaType,\n maxBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: MAX_UPLOAD_BYTES })),\n ),\n timeoutMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 600_000 })),\n ),\n});\n\n/**\n * Only fields this package can validate are carried forward. `path` is the provider's own\n * remote location for the stored file; when the response omits it, the receipt says so\n * instead of inventing one, and attachment by path is refused rather than guessed.\n */\n/**\n * Where the provider places session uploads inside the remote browser. Observed against the\n * provider on 21 September 2026 and documented at\n * https://docs.browserbase.com/platform/browser/files/uploads.md; the create reply does not\n * return it.\n */\nconst UPLOAD_DIRECTORY = \"/tmp/.uploads\";\n\nconst ProviderUpload = Schema.Struct({\n message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n path: Schema.optionalKey(RemoteFilePath),\n});\n\nexport interface UploadFile {\n readonly filename: string;\n readonly mediaType: string;\n readonly bytes: Uint8Array;\n readonly maxBytes?: number;\n readonly timeoutMillis?: number;\n}\n\nconst failure = (operation: FileError[\"operation\"], reason: FileError[\"reason\"]) =>\n FileError.make({ operation, reason, outcome: \"undispatched\" });\n\nconst fromClient = (operation: FileError[\"operation\"]) => (error: ClientError) =>\n FileError.make({\n operation,\n reason: error.reason,\n ...(error.outcome === undefined ? {} : { outcome: error.outcome }),\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis }),\n });\n\n/**\n * A session upload places bytes where the remote browser can already reach them. It is the\n * large-file half of file selection; small in-memory selection needs no provisioning at all.\n */\nexport class BrowserbaseUploads extends Context.Service<\n BrowserbaseUploads,\n {\n readonly create: (\n reference: SessionReference,\n file: UploadFile,\n ) => Effect.Effect<UploadReceipt, FileError>;\n }\n>()(\"effect-browserbase/Uploads\") {\n static readonly layer: Layer.Layer<\n BrowserbaseUploads,\n never,\n BrowserbaseClient | BrowserbaseSessions\n > = Layer.effect(\n BrowserbaseUploads,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n\n const create = Effect.fn(\"BrowserbaseUploads.create\")(function* (\n reference: SessionReference,\n file: UploadFile,\n ) {\n const { bytes, ...rest } = file;\n\n const value = yield* Schema.decodeEffect(UploadOptions)(rest, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => failure(\"upload\", \"configuration\")));\n\n if (!(bytes instanceof Uint8Array)) return yield* failure(\"upload\", \"configuration\");\n const maxBytes = value.maxBytes ?? MAX_UPLOAD_BYTES;\n\n if (bytes.byteLength < 1 || bytes.byteLength > maxBytes)\n return yield* failure(\"upload\", \"limit\");\n\n // The exact owning session admits the upload; a terminal session cannot receive files.\n const state = yield* sessions\n .retrieve(reference)\n .pipe(\n Effect.mapError((error) =>\n FileError.make({ operation: \"upload\", reason: error.reason }),\n ),\n );\n\n if (state.status !== \"RUNNING\") return yield* failure(\"upload\", \"expired\");\n\n // Send the same immutable bytes that were measured a moment ago.\n const owned = new Uint8Array(bytes);\n\n const raw = yield* client\n .upload(\n `/v1/sessions/${encodeURIComponent(state.reference.sessionId)}/uploads`,\n {\n field: \"file\",\n filename: value.filename,\n mediaType: value.mediaType,\n bytes: owned,\n },\n {\n maxBytes,\n ...(value.timeoutMillis === undefined ? {} : { timeoutMillis: value.timeoutMillis }),\n },\n )\n .pipe(Effect.mapError(fromClient(\"upload\")));\n\n const acknowledged = yield* Schema.decodeUnknownEffect(ProviderUpload)(raw).pipe(\n Effect.mapError(() =>\n FileError.make({ operation: \"upload\", reason: \"malformed\", outcome: \"unknown\" }),\n ),\n );\n\n // The provider's reply carries only a message; its documented upload location is a\n // fixed directory keyed by the part's filename, which was validated above. A path the\n // provider does return still wins, and was checked for traversal when decoded.\n const remotePath = acknowledged.path ?? `${UPLOAD_DIRECTORY}/${value.filename}`;\n\n const receipt = UploadReceipt.make({\n reference: state.reference,\n filename: value.filename,\n bytes: owned.byteLength,\n remotePath,\n ...(acknowledged.message === undefined ? {} : { acknowledgement: acknowledged.message }),\n });\n\n recordIssuedUpload(receipt, { reference: state.reference, remotePath });\n\n return receipt;\n });\n\n return BrowserbaseUploads.of({ create });\n }),\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Uploads.mjs","names":[],"sources":["../src/Uploads.ts"],"sourcesContent":["import { Context, Effect, Layer, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { type ClientError, FileError } from \"./Errors.ts\";\nimport { recordIssuedUpload } from \"./internal/upload/Issued.ts\";\nimport type { SessionReference } from \"./References.ts\";\nimport { BrowserbaseSessions } from \"./Sessions.ts\";\nimport { RemoteFilePath, SafeFilename, UploadReceipt } from \"./Transfers.ts\";\n\n/** The provider's documented per-file ceiling for a session upload. */\nconst MAX_UPLOAD_BYTES = 512 * 1024 * 1024;\n\nconst MediaType = Schema.NonEmptyString.check(\n Schema.isMaxLength(128),\n Schema.isPattern(/^[a-z0-9][a-z0-9!#$&^_+.-]*\\/[a-z0-9][a-z0-9!#$&^_+.-]*$/),\n);\n\nconst UploadOptions = Schema.Struct({\n filename: SafeFilename,\n mediaType: MediaType,\n maxBytes: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: MAX_UPLOAD_BYTES })),\n ),\n timeoutMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 600_000 })),\n ),\n});\n\n/**\n * Only fields this package can validate are carried forward. `path` is the provider's own\n * remote location for the stored file; when the response omits it, the receipt says so\n * instead of inventing one, and attachment by path is refused rather than guessed.\n */\n/**\n * Where the provider places session uploads inside the remote browser. Observed against the\n * provider on 21 September 2026 and documented at\n * https://docs.browserbase.com/platform/browser/files/uploads.md; the create reply does not\n * return it.\n */\nconst UPLOAD_DIRECTORY = \"/tmp/.uploads\";\n\nconst ProviderUpload = Schema.Struct({\n message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),\n path: Schema.optionalKey(RemoteFilePath),\n});\n\nexport interface UploadFile {\n readonly filename: string;\n readonly mediaType: string;\n readonly bytes: Uint8Array;\n readonly maxBytes?: number;\n readonly timeoutMillis?: number;\n}\n\nconst failure = (operation: FileError[\"operation\"], reason: FileError[\"reason\"]) =>\n FileError.make({ operation, reason, outcome: \"undispatched\" });\n\nconst fromClient = (operation: FileError[\"operation\"]) => (error: ClientError) =>\n FileError.make({\n operation,\n reason: error.reason,\n ...(error.outcome === undefined ? {} : { outcome: error.outcome }),\n ...(error.status === undefined ? {} : { status: error.status }),\n ...(error.retryAfterMillis === undefined ? {} : { retryAfterMillis: error.retryAfterMillis }),\n });\n\n/**\n * A session upload places bytes where the remote browser can already reach them. It is the\n * large-file half of file selection; small in-memory selection needs no provisioning at all.\n */\nexport class BrowserbaseUploads extends Context.Service<\n BrowserbaseUploads,\n {\n readonly create: (\n reference: SessionReference,\n file: UploadFile,\n ) => Effect.Effect<UploadReceipt, FileError>;\n }\n>()(\"effect-browserbase/Uploads\") {\n static readonly layer: Layer.Layer<\n BrowserbaseUploads,\n never,\n BrowserbaseClient | BrowserbaseSessions\n > = Layer.effect(\n BrowserbaseUploads,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n const sessions = yield* BrowserbaseSessions;\n\n const create = Effect.fn(\"BrowserbaseUploads.create\")(function* (\n reference: SessionReference,\n file: UploadFile,\n ) {\n const { bytes, ...rest } = file;\n\n const value = yield* Schema.decodeEffect(UploadOptions)(rest, {\n onExcessProperty: \"error\",\n }).pipe(Effect.mapError(() => failure(\"upload\", \"configuration\")));\n\n if (!(bytes instanceof Uint8Array)) return yield* failure(\"upload\", \"configuration\");\n const maxBytes = value.maxBytes ?? MAX_UPLOAD_BYTES;\n\n if (bytes.byteLength < 1 || bytes.byteLength > maxBytes)\n return yield* failure(\"upload\", \"limit\");\n\n // The exact owning session admits the upload; a terminal session cannot receive files.\n const state = yield* sessions\n .retrieve(reference)\n .pipe(\n Effect.mapError((error) =>\n FileError.make({ operation: \"upload\", reason: error.reason }),\n ),\n );\n\n if (state.status !== \"RUNNING\") return yield* failure(\"upload\", \"expired\");\n\n // Send the same immutable bytes that were measured a moment ago.\n const owned = new Uint8Array(bytes);\n\n const raw = yield* client\n .upload(\n `/v1/sessions/${encodeURIComponent(state.reference.sessionId)}/uploads`,\n {\n field: \"file\",\n filename: value.filename,\n mediaType: value.mediaType,\n bytes: owned,\n },\n {\n maxBytes,\n ...(value.timeoutMillis === undefined ? {} : { timeoutMillis: value.timeoutMillis }),\n },\n )\n .pipe(Effect.mapError(fromClient(\"upload\")));\n\n const acknowledged = yield* Schema.decodeUnknownEffect(ProviderUpload)(raw).pipe(\n Effect.mapError(() =>\n FileError.make({ operation: \"upload\", reason: \"malformed\", outcome: \"unknown\" }),\n ),\n );\n\n // The provider's reply carries only a message; its documented upload location is a\n // fixed directory keyed by the part's filename, which was validated above. A path the\n // provider does return still wins, and was checked for traversal when decoded.\n const remotePath = acknowledged.path ?? `${UPLOAD_DIRECTORY}/${value.filename}`;\n\n const receipt = UploadReceipt.make({\n reference: state.reference,\n filename: value.filename,\n bytes: owned.byteLength,\n remotePath,\n ...(acknowledged.message === undefined ? {} : { acknowledgement: acknowledged.message }),\n });\n\n recordIssuedUpload(receipt, { reference: state.reference, remotePath });\n\n return receipt;\n });\n\n return BrowserbaseUploads.of({ create });\n }),\n );\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,mBAAmB;AAEzB,MAAM,YAAY,OAAO,eAAe,MACtC,OAAO,YAAY,GAAG,GACtB,OAAO,UAAU,0DAA0D,CAC7E;AAEA,MAAM,gBAAgB,OAAO,OAAO;CAClC,UAAU;CACV,WAAW;CACX,UAAU,OAAO,YACf,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAiB,CAAC,CAAC,CAC9E;CACA,eAAe,OAAO,YACpB,OAAO,IAAI,MAAM,OAAO,UAAU;EAAE,SAAS;EAAG,SAAS;CAAQ,CAAC,CAAC,CACrE;AACF,CAAC;;;;;;;;;;;;AAaD,MAAM,mBAAmB;AAEzB,MAAM,iBAAiB,OAAO,OAAO;CACnC,SAAS,OAAO,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,IAAI,CAAC,CAAC;CACzE,MAAM,OAAO,YAAY,cAAc;AACzC,CAAC;AAUD,MAAM,WAAW,WAAmC,WAClD,UAAU,KAAK;CAAE;CAAW;CAAQ,SAAS;AAAe,CAAC;AAE/D,MAAM,cAAc,eAAuC,UACzD,UAAU,KAAK;CACb;CACA,QAAQ,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,MAAM;IACjB,OAAO;GACT,GACA;IACE;IACA,GAAI,MAAM,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,eAAe,MAAM,cAAc;GACpF,CACF,CAAC,CACA,KAAK,OAAO,SAAS,WAAW,QAAQ,CAAC,CAAC;GAE7C,MAAM,eAAe,OAAO,OAAO,oBAAoB,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,KAC1E,OAAO,eACL,UAAU,KAAK;IAAE,WAAW;IAAU,QAAQ;IAAa,SAAS;GAAU,CAAC,CACjF,CACF;GAKA,MAAM,aAAa,aAAa,QAAQ,GAAG,iBAAiB,GAAG,MAAM;GAErE,MAAM,UAAU,cAAc,KAAK;IACjC,WAAW,MAAM;IACjB,UAAU,MAAM;IAChB,OAAO,MAAM;IACb;IACA,GAAI,aAAa,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB,aAAa,QAAQ;GACxF,CAAC;GAED,mBAAmB,SAAS;IAAE,WAAW,MAAM;IAAW;GAAW,CAAC;GAEtE,OAAO;EACT,CAAC;EAED,OAAO,mBAAmB,GAAG,EAAE,OAAO,CAAC;CACzC,CAAC,CACH;AACF"}
|
package/dist/Webhooks.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { PlatformError } from "./Errors.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { BrowserbaseClient } from "./Client.mjs";
|
|
3
3
|
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
4
|
-
|
|
5
|
-
export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookPage, WebhookRegistration, WebhookSettings, WebhookUpdate };
|
|
6
|
-
}
|
|
4
|
+
//#region src/Webhooks.d.ts
|
|
7
5
|
/** Provider event names. Browserbase currently emits Functions events only. */
|
|
8
6
|
export declare const WebhookEventType: Schema.Literals<readonly ["functions.builds.running", "functions.builds.completed", "functions.builds.failed", "functions.invocations.pending", "functions.invocations.running", "functions.invocations.completed", "functions.invocations.failed"]>;
|
|
9
7
|
export type WebhookEventType = typeof WebhookEventType.Type;
|
|
@@ -56,5 +54,5 @@ export declare class BrowserbaseWebhooks extends BrowserbaseWebhooks_base {
|
|
|
56
54
|
static readonly layer: Layer.Layer<BrowserbaseWebhooks, never, BrowserbaseClient>;
|
|
57
55
|
}
|
|
58
56
|
//#endregion
|
|
59
|
-
export {
|
|
57
|
+
export {};
|
|
60
58
|
//# sourceMappingURL=Webhooks.d.mts.map
|
package/dist/Webhooks.mjs
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
1
|
import { Identifier } from "./References.mjs";
|
|
3
2
|
import { PlatformError } from "./Errors.mjs";
|
|
4
|
-
import { t as BrowserbaseClient } from "./Client-
|
|
3
|
+
import { t as BrowserbaseClient } from "./Client-BQteUePT.mjs";
|
|
5
4
|
import { t as resource } from "./Resource-DBksC4zB.mjs";
|
|
6
5
|
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
7
6
|
//#region src/Webhooks.ts
|
|
8
|
-
var Webhooks_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
BrowserbaseWebhooks: () => BrowserbaseWebhooks,
|
|
10
|
-
WebhookEventType: () => WebhookEventType,
|
|
11
|
-
WebhookListQuery: () => WebhookListQuery,
|
|
12
|
-
WebhookMetadata: () => WebhookMetadata,
|
|
13
|
-
WebhookSettings: () => WebhookSettings,
|
|
14
|
-
WebhookUpdate: () => WebhookUpdate
|
|
15
|
-
});
|
|
16
7
|
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
17
8
|
/** Provider event names. Browserbase currently emits Functions events only. */
|
|
18
9
|
const WebhookEventType = Schema.Literals([
|
|
@@ -138,6 +129,6 @@ var BrowserbaseWebhooks = class BrowserbaseWebhooks extends Context.Service()("e
|
|
|
138
129
|
}));
|
|
139
130
|
};
|
|
140
131
|
//#endregion
|
|
141
|
-
export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookSettings, WebhookUpdate
|
|
132
|
+
export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookSettings, WebhookUpdate };
|
|
142
133
|
|
|
143
134
|
//# sourceMappingURL=Webhooks.mjs.map
|
package/dist/Webhooks.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Webhooks.mjs","names":[],"sources":["../src/Webhooks.ts"],"sourcesContent":["import { Context, Effect, Layer, Redacted, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { PlatformError } from \"./Errors.ts\";\nimport { resource } from \"./internal/http/Resource.ts\";\nimport { Identifier } from \"./References.ts\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\n/** Provider event names. Browserbase currently emits Functions events only. */\nexport const WebhookEventType = Schema.Literals([\n \"functions.builds.running\",\n \"functions.builds.completed\",\n \"functions.builds.failed\",\n \"functions.invocations.pending\",\n \"functions.invocations.running\",\n \"functions.invocations.completed\",\n \"functions.invocations.failed\",\n]);\n\nexport type WebhookEventType = typeof WebhookEventType.Type;\n\nconst Endpoint = Schema.NonEmptyString.check(\n Schema.isMaxLength(2048),\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return url.protocol === \"https:\" && !url.username && !url.password;\n } catch {\n return false;\n }\n }),\n);\n\nconst EventTypes = Schema.Array(WebhookEventType).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(7),\n Schema.isUnique(),\n);\n\nexport const WebhookSettings = Schema.Struct({ endpoint: Endpoint, eventTypes: EventTypes });\nexport type WebhookSettings = typeof WebhookSettings.Type;\n\nexport const WebhookUpdate = Schema.Struct({\n endpoint: Schema.optionalKey(Endpoint),\n eventTypes: Schema.optionalKey(EventTypes),\n});\n\nexport type WebhookUpdate = typeof WebhookUpdate.Type;\n\nexport class WebhookMetadata extends Schema.Class<WebhookMetadata>(\"BrowserbaseWebhookMetadata\")({\n webhookId: Identifier,\n projectId: Identifier,\n endpoint: Schema.String.check(Schema.isMaxLength(2048)),\n eventTypes: Schema.Array(Schema.String.check(Schema.isMaxLength(128))).check(\n Schema.isMaxLength(64),\n ),\n createdAt: Timestamp,\n updatedAt: Timestamp,\n}) {}\n\n/** A signing secret is returned once, redacted so it cannot be logged by accident. */\nexport interface WebhookRegistration {\n readonly webhook: WebhookMetadata;\n readonly secret: Redacted.Redacted<string>;\n}\n\nexport interface WebhookPage {\n readonly webhooks: ReadonlyArray<WebhookMetadata>;\n readonly nextCursor: string | undefined;\n}\n\nconst ProviderWebhook = Schema.Struct({\n id: Identifier,\n projectId: Identifier,\n endpoint: WebhookMetadata.fields.endpoint,\n eventTypes: WebhookMetadata.fields.eventTypes,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n});\n\nconst Secret = Schema.NonEmptyString.check(Schema.isMaxLength(1024));\n\nconst Page = Schema.Struct({\n data: Schema.Array(ProviderWebhook).check(Schema.isMaxLength(100)),\n nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096)))),\n});\n\nexport const WebhookListQuery = Schema.Struct({\n cursor: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(4096))),\n limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 }))),\n});\n\nexport type WebhookListQuery = typeof WebhookListQuery.Type;\n\n/** Webhook administration for the Client's project. Mutations are never retried. */\nexport class BrowserbaseWebhooks extends Context.Service<\n BrowserbaseWebhooks,\n {\n readonly create: (\n settings: WebhookSettings,\n ) => Effect.Effect<WebhookRegistration, PlatformError>;\n readonly list: (query?: WebhookListQuery) => Effect.Effect<WebhookPage, PlatformError>;\n readonly retrieve: (webhookId: string) => Effect.Effect<WebhookMetadata, PlatformError>;\n readonly update: (\n webhookId: string,\n update: WebhookUpdate,\n ) => Effect.Effect<WebhookMetadata, PlatformError>;\n readonly delete: (webhookId: string) => Effect.Effect<void, PlatformError>;\n /** Issues a new secret; the old one keeps working unless `revokeImmediately`. */\n readonly rotateSecret: (\n webhookId: string,\n options?: { readonly revokeImmediately?: boolean },\n ) => Effect.Effect<Redacted.Redacted<string>, PlatformError>;\n }\n>()(\"effect-browserbase/Webhooks\") {\n static readonly layer: Layer.Layer<BrowserbaseWebhooks, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseWebhooks,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const api = resource<PlatformError>(client, (failure) =>\n PlatformError.make({ ...failure, service: \"webhooks\" }),\n );\n\n const decode = (\n operation: PlatformError[\"operation\"],\n mutation: boolean,\n expected?: string,\n ) =>\n Effect.fnUntraced(function* (value: typeof ProviderWebhook.Type) {\n if (\n value.projectId !== client.projectId ||\n (expected !== undefined && value.id !== expected)\n )\n return yield* api.malformed(operation, mutation);\n\n const { id, ...rest } = value;\n\n return WebhookMetadata.make({ webhookId: id, ...rest });\n });\n\n const path = (id: string) => `/v1/webhooks/${api.segment(id)}`;\n\n const create = Effect.fn(\"BrowserbaseWebhooks.create\")(function* (settings: WebhookSettings) {\n const value = yield* api.input(WebhookSettings, settings, \"webhook-create\");\n\n const created = yield* api.request(\n \"POST\",\n \"/v1/webhooks\",\n Schema.Struct({ ...ProviderWebhook.fields, secret: Secret }),\n \"webhook-create\",\n value,\n );\n\n const { secret, ...webhook } = created;\n\n return {\n webhook: yield* decode(\"webhook-create\", true)(webhook),\n secret: Redacted.make(secret),\n };\n });\n\n const list = Effect.fn(\"BrowserbaseWebhooks.list\")(function* (query: WebhookListQuery = {}) {\n const value = yield* api.input(WebhookListQuery, query, \"webhook-list\");\n\n const page = yield* api.request(\n \"GET\",\n `/v1/webhooks${api.query(value)}`,\n Page,\n \"webhook-list\",\n );\n\n return {\n webhooks: yield* Effect.forEach(page.data, decode(\"webhook-list\", false)),\n nextCursor: page.nextCursor ?? undefined,\n };\n });\n\n const retrieve = Effect.fn(\"BrowserbaseWebhooks.retrieve\")(function* (webhookId: string) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-retrieve\");\n const value = yield* api.request(\"GET\", path(id), ProviderWebhook, \"webhook-retrieve\");\n\n return yield* decode(\"webhook-retrieve\", false, id)(value);\n });\n\n const update = Effect.fn(\"BrowserbaseWebhooks.update\")(function* (\n webhookId: string,\n changes: WebhookUpdate,\n ) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-update\");\n const value = yield* api.input(WebhookUpdate, changes, \"webhook-update\");\n\n if (value.endpoint === undefined && value.eventTypes === undefined)\n return yield* api.configuration(\"webhook-update\");\n\n const updated = yield* api.request(\n \"PATCH\",\n path(id),\n ProviderWebhook,\n \"webhook-update\",\n value,\n );\n\n return yield* decode(\"webhook-update\", true, id)(updated);\n });\n\n const remove = Effect.fn(\"BrowserbaseWebhooks.delete\")(function* (webhookId: string) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-delete\");\n\n yield* api.remove(path(id), \"webhook-delete\");\n });\n\n const rotateSecret = Effect.fn(\"BrowserbaseWebhooks.rotateSecret\")(function* (\n webhookId: string,\n options: { readonly revokeImmediately?: boolean } = {},\n ) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-rotate-secret\");\n\n const value = yield* api.input(\n Schema.Struct({ revokeImmediately: Schema.optionalKey(Schema.Boolean) }),\n options,\n \"webhook-rotate-secret\",\n );\n\n const rotated = yield* api.request(\n \"POST\",\n `${path(id)}/secret`,\n Schema.Struct({ secret: Secret }),\n \"webhook-rotate-secret\",\n value,\n );\n\n return Redacted.make(rotated.secret);\n });\n\n return BrowserbaseWebhooks.of({\n create,\n list,\n retrieve,\n update,\n delete: remove,\n rotateSecret,\n });\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAOA,MAAM,YAAY,OAAO,OAAO,MAAM,OAAO,YAAY,EAAE,CAAC;;AAG5D,MAAa,mBAAmB,OAAO,SAAS;CAC9C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAID,MAAM,WAAW,OAAO,eAAe,MACrC,OAA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AAC,GACrD;GACA,MAAM,KAAK,OAAO,IAAI,MAAM,YAAY,WAAW,uBAAuB;GAE1E,MAAM,QAAQ,OAAO,IAAI,MACvB,OAAO,OAAO,EAAE,mBAAmB,OAAO,YAAY,OAAO,OAAO,EAAE,CAAC,GACvE,SACA,uBACF;GAEA,MAAM,UAAU,OAAO,IAAI,QACzB,QACA,GAAG,KAAK,EAAE,EAAE,UACZ,OAAO,OAAO,EAAE,QAAQ,OAAO,CAAC,GAChC,yBACA,KACF;GAEA,OAAO,SAAS,KAAK,QAAQ,MAAM;EACrC,CAAC;EAED,OAAO,oBAAoB,GAAG;GAC5B;GACA;GACA;GACA;GACA,QAAQ;GACR;EACF,CAAC;CACH,CAAC,CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"Webhooks.mjs","names":[],"sources":["../src/Webhooks.ts"],"sourcesContent":["import { Context, Effect, Layer, Redacted, Schema } from \"effect\";\n\nimport { BrowserbaseClient } from \"./Client.ts\";\nimport { PlatformError } from \"./Errors.ts\";\nimport { resource } from \"./internal/http/Resource.ts\";\nimport { Identifier } from \"./References.ts\";\n\nconst Timestamp = Schema.String.check(Schema.isMaxLength(64));\n\n/** Provider event names. Browserbase currently emits Functions events only. */\nexport const WebhookEventType = Schema.Literals([\n \"functions.builds.running\",\n \"functions.builds.completed\",\n \"functions.builds.failed\",\n \"functions.invocations.pending\",\n \"functions.invocations.running\",\n \"functions.invocations.completed\",\n \"functions.invocations.failed\",\n]);\n\nexport type WebhookEventType = typeof WebhookEventType.Type;\n\nconst Endpoint = Schema.NonEmptyString.check(\n Schema.isMaxLength(2048),\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return url.protocol === \"https:\" && !url.username && !url.password;\n } catch {\n return false;\n }\n }),\n);\n\nconst EventTypes = Schema.Array(WebhookEventType).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(7),\n Schema.isUnique(),\n);\n\nexport const WebhookSettings = Schema.Struct({ endpoint: Endpoint, eventTypes: EventTypes });\nexport type WebhookSettings = typeof WebhookSettings.Type;\n\nexport const WebhookUpdate = Schema.Struct({\n endpoint: Schema.optionalKey(Endpoint),\n eventTypes: Schema.optionalKey(EventTypes),\n});\n\nexport type WebhookUpdate = typeof WebhookUpdate.Type;\n\nexport class WebhookMetadata extends Schema.Class<WebhookMetadata>(\"BrowserbaseWebhookMetadata\")({\n webhookId: Identifier,\n projectId: Identifier,\n endpoint: Schema.String.check(Schema.isMaxLength(2048)),\n eventTypes: Schema.Array(Schema.String.check(Schema.isMaxLength(128))).check(\n Schema.isMaxLength(64),\n ),\n createdAt: Timestamp,\n updatedAt: Timestamp,\n}) {}\n\n/** A signing secret is returned once, redacted so it cannot be logged by accident. */\nexport interface WebhookRegistration {\n readonly webhook: WebhookMetadata;\n readonly secret: Redacted.Redacted<string>;\n}\n\nexport interface WebhookPage {\n readonly webhooks: ReadonlyArray<WebhookMetadata>;\n readonly nextCursor: string | undefined;\n}\n\nconst ProviderWebhook = Schema.Struct({\n id: Identifier,\n projectId: Identifier,\n endpoint: WebhookMetadata.fields.endpoint,\n eventTypes: WebhookMetadata.fields.eventTypes,\n createdAt: Timestamp,\n updatedAt: Timestamp,\n});\n\nconst Secret = Schema.NonEmptyString.check(Schema.isMaxLength(1024));\n\nconst Page = Schema.Struct({\n data: Schema.Array(ProviderWebhook).check(Schema.isMaxLength(100)),\n nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096)))),\n});\n\nexport const WebhookListQuery = Schema.Struct({\n cursor: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(4096))),\n limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 }))),\n});\n\nexport type WebhookListQuery = typeof WebhookListQuery.Type;\n\n/** Webhook administration for the Client's project. Mutations are never retried. */\nexport class BrowserbaseWebhooks extends Context.Service<\n BrowserbaseWebhooks,\n {\n readonly create: (\n settings: WebhookSettings,\n ) => Effect.Effect<WebhookRegistration, PlatformError>;\n readonly list: (query?: WebhookListQuery) => Effect.Effect<WebhookPage, PlatformError>;\n readonly retrieve: (webhookId: string) => Effect.Effect<WebhookMetadata, PlatformError>;\n readonly update: (\n webhookId: string,\n update: WebhookUpdate,\n ) => Effect.Effect<WebhookMetadata, PlatformError>;\n readonly delete: (webhookId: string) => Effect.Effect<void, PlatformError>;\n /** Issues a new secret; the old one keeps working unless `revokeImmediately`. */\n readonly rotateSecret: (\n webhookId: string,\n options?: { readonly revokeImmediately?: boolean },\n ) => Effect.Effect<Redacted.Redacted<string>, PlatformError>;\n }\n>()(\"effect-browserbase/Webhooks\") {\n static readonly layer: Layer.Layer<BrowserbaseWebhooks, never, BrowserbaseClient> = Layer.effect(\n BrowserbaseWebhooks,\n Effect.gen(function* () {\n const client = yield* BrowserbaseClient;\n\n const api = resource<PlatformError>(client, (failure) =>\n PlatformError.make({ ...failure, service: \"webhooks\" }),\n );\n\n const decode = (\n operation: PlatformError[\"operation\"],\n mutation: boolean,\n expected?: string,\n ) =>\n Effect.fnUntraced(function* (value: typeof ProviderWebhook.Type) {\n if (\n value.projectId !== client.projectId ||\n (expected !== undefined && value.id !== expected)\n )\n return yield* api.malformed(operation, mutation);\n\n const { id, ...rest } = value;\n\n return WebhookMetadata.make({ webhookId: id, ...rest });\n });\n\n const path = (id: string) => `/v1/webhooks/${api.segment(id)}`;\n\n const create = Effect.fn(\"BrowserbaseWebhooks.create\")(function* (settings: WebhookSettings) {\n const value = yield* api.input(WebhookSettings, settings, \"webhook-create\");\n\n const created = yield* api.request(\n \"POST\",\n \"/v1/webhooks\",\n Schema.Struct({ ...ProviderWebhook.fields, secret: Secret }),\n \"webhook-create\",\n value,\n );\n\n const { secret, ...webhook } = created;\n\n return {\n webhook: yield* decode(\"webhook-create\", true)(webhook),\n secret: Redacted.make(secret),\n };\n });\n\n const list = Effect.fn(\"BrowserbaseWebhooks.list\")(function* (query: WebhookListQuery = {}) {\n const value = yield* api.input(WebhookListQuery, query, \"webhook-list\");\n\n const page = yield* api.request(\n \"GET\",\n `/v1/webhooks${api.query(value)}`,\n Page,\n \"webhook-list\",\n );\n\n return {\n webhooks: yield* Effect.forEach(page.data, decode(\"webhook-list\", false)),\n nextCursor: page.nextCursor ?? undefined,\n };\n });\n\n const retrieve = Effect.fn(\"BrowserbaseWebhooks.retrieve\")(function* (webhookId: string) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-retrieve\");\n const value = yield* api.request(\"GET\", path(id), ProviderWebhook, \"webhook-retrieve\");\n\n return yield* decode(\"webhook-retrieve\", false, id)(value);\n });\n\n const update = Effect.fn(\"BrowserbaseWebhooks.update\")(function* (\n webhookId: string,\n changes: WebhookUpdate,\n ) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-update\");\n const value = yield* api.input(WebhookUpdate, changes, \"webhook-update\");\n\n if (value.endpoint === undefined && value.eventTypes === undefined)\n return yield* api.configuration(\"webhook-update\");\n\n const updated = yield* api.request(\n \"PATCH\",\n path(id),\n ProviderWebhook,\n \"webhook-update\",\n value,\n );\n\n return yield* decode(\"webhook-update\", true, id)(updated);\n });\n\n const remove = Effect.fn(\"BrowserbaseWebhooks.delete\")(function* (webhookId: string) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-delete\");\n\n yield* api.remove(path(id), \"webhook-delete\");\n });\n\n const rotateSecret = Effect.fn(\"BrowserbaseWebhooks.rotateSecret\")(function* (\n webhookId: string,\n options: { readonly revokeImmediately?: boolean } = {},\n ) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-rotate-secret\");\n\n const value = yield* api.input(\n Schema.Struct({ revokeImmediately: Schema.optionalKey(Schema.Boolean) }),\n options,\n \"webhook-rotate-secret\",\n );\n\n const rotated = yield* api.request(\n \"POST\",\n `${path(id)}/secret`,\n Schema.Struct({ secret: Secret }),\n \"webhook-rotate-secret\",\n value,\n );\n\n return Redacted.make(rotated.secret);\n });\n\n return BrowserbaseWebhooks.of({\n create,\n list,\n retrieve,\n update,\n delete: remove,\n rotateSecret,\n });\n }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AC,WAAW,WAAmB;GACnF,MAAM,KAAK,OAAO,IAAI,MAAM,YAAY,WAAW,gBAAgB;GAEnE,OAAO,IAAI,OAAO,KAAK,EAAE,GAAG,gBAAgB;EAC9C,CAAC;EAED,MAAM,eAAe,OAAO,GAAG,kCAAkC,CAAC,CAAC,WACjE,WACA,UAAoD,CAAC,GACrD;GACA,MAAM,KAAK,OAAO,IAAI,MAAM,YAAY,WAAW,uBAAuB;GAE1E,MAAM,QAAQ,OAAO,IAAI,MACvB,OAAO,OAAO,EAAE,mBAAmB,OAAO,YAAY,OAAO,OAAO,EAAE,CAAC,GACvE,SACA,uBACF;GAEA,MAAM,UAAU,OAAO,IAAI,QACzB,QACA,GAAG,KAAK,EAAE,EAAE,UACZ,OAAO,OAAO,EAAE,QAAQ,OAAO,CAAC,GAChC,yBACA,KACF;GAEA,OAAO,SAAS,KAAK,QAAQ,MAAM;EACrC,CAAC;EAED,OAAO,oBAAoB,GAAG;GAC5B;GACA;GACA;GACA;GACA,QAAQ;GACR;EACF,CAAC;CACH,CAAC,CACH;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as CleanupResult } from "./Cleanup-
|
|
1
|
+
import { a as SessionReference, n as ContextReference, t as AllocationAttempt } from "./References-DOH3Wu44.mjs";
|
|
2
|
+
import { n as CleanupResult } from "./Cleanup-DMTDBir8.mjs";
|
|
3
3
|
import { Effect, Schema } from "effect";
|
|
4
4
|
//#region src/internal/session/WriterFacts.d.ts
|
|
5
5
|
/**
|
|
@@ -58,4 +58,5 @@ interface WriterOptions<A, VerifyE, VerifyR> {
|
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
60
|
export { WriterLease as a, WriterAttemptFacts as i, ContextWriterPermit as n, WriterOptions as o, PersistenceEvidence as r, WriterSettlementFacts as s, ContextWriterBackend as t };
|
|
61
|
-
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=WriterFacts-5CPBGG1P.d.mts.map
|