effect-browserbase 0.1.0-beta.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +441 -0
- package/dist/Account.d.mts +34 -0
- package/dist/Account.mjs +41 -0
- package/dist/Account.mjs.map +1 -0
- package/dist/Acquisition-WBafHwXH.mjs +280 -0
- package/dist/Acquisition-WBafHwXH.mjs.map +1 -0
- package/dist/Agents.d.mts +156 -0
- package/dist/Agents.mjs +307 -0
- package/dist/Agents.mjs.map +1 -0
- package/dist/Allocation.d.mts +99 -0
- package/dist/Allocation.mjs +29 -0
- package/dist/Allocation.mjs.map +1 -0
- package/dist/Association-CEps4hYP.mjs +10 -0
- package/dist/Association-CEps4hYP.mjs.map +1 -0
- package/dist/Authorization-Ll5f_XNM.mjs +12 -0
- package/dist/Authorization-Ll5f_XNM.mjs.map +1 -0
- package/dist/Bootstrap-BXuzZojd.mjs +194 -0
- package/dist/Bootstrap-BXuzZojd.mjs.map +1 -0
- package/dist/Bootstrap-m7lHgj0D.d.mts +177 -0
- package/dist/Bootstrap.d.mts +2 -0
- package/dist/Bootstrap.mjs +2 -0
- package/dist/Browser-joE4Zgys.mjs +1557 -0
- package/dist/Browser-joE4Zgys.mjs.map +1 -0
- package/dist/Browser.d.mts +195 -0
- package/dist/Browser.mjs +2 -0
- package/dist/BrowserBinding-qbQA6JhH.mjs +2452 -0
- package/dist/BrowserBinding-qbQA6JhH.mjs.map +1 -0
- package/dist/BrowserBinding.d.mts +40 -0
- package/dist/BrowserBinding.mjs +2 -0
- package/dist/BrowserData-LpcAuAub.d.mts +369 -0
- package/dist/BrowserData.d.mts +2 -0
- package/dist/BrowserData.mjs +442 -0
- package/dist/BrowserData.mjs.map +1 -0
- package/dist/Capture-CZJPuD7b.mjs +532 -0
- package/dist/Capture-CZJPuD7b.mjs.map +1 -0
- package/dist/Capture-Dr5MkIJb.d.mts +125 -0
- package/dist/Capture.d.mts +2 -0
- package/dist/Capture.mjs +2 -0
- package/dist/Certificates.d.mts +35 -0
- package/dist/Certificates.mjs +90 -0
- package/dist/Certificates.mjs.map +1 -0
- package/dist/Cleanup-G2YpTCuU.d.mts +24 -0
- package/dist/Cleanup.d.mts +2 -0
- package/dist/Cleanup.mjs +48 -0
- package/dist/Cleanup.mjs.map +1 -0
- package/dist/Client-Ca0zSg1n.d.mts +53 -0
- package/dist/Client-D1_xYM9o.mjs +424 -0
- package/dist/Client-D1_xYM9o.mjs.map +1 -0
- package/dist/Client.d.mts +2 -0
- package/dist/Client.mjs +2 -0
- package/dist/ContextCoordination.d.mts +16 -0
- package/dist/ContextCoordination.mjs +67 -0
- package/dist/ContextCoordination.mjs.map +1 -0
- package/dist/ContextWriter-BrQmoXRg.mjs +187 -0
- package/dist/ContextWriter-BrQmoXRg.mjs.map +1 -0
- package/dist/Contexts.d.mts +32 -0
- package/dist/Contexts.mjs +103 -0
- package/dist/Contexts.mjs.map +1 -0
- package/dist/Deadline-CrViaogr.mjs +13 -0
- package/dist/Deadline-CrViaogr.mjs.map +1 -0
- package/dist/Downloads.d.mts +44 -0
- package/dist/Downloads.mjs +142 -0
- package/dist/Downloads.mjs.map +1 -0
- package/dist/Errors.d.mts +123 -0
- package/dist/Errors.mjs +329 -0
- package/dist/Errors.mjs.map +1 -0
- package/dist/Extensions-ClZbYb1H.mjs +237 -0
- package/dist/Extensions-ClZbYb1H.mjs.map +1 -0
- package/dist/Extensions.d.mts +44 -0
- package/dist/Extensions.mjs +2 -0
- package/dist/Functions.d.mts +227 -0
- package/dist/Functions.mjs +332 -0
- package/dist/Functions.mjs.map +1 -0
- package/dist/Images-DgscEfSf.mjs +127 -0
- package/dist/Images-DgscEfSf.mjs.map +1 -0
- package/dist/Issued-DejqoMYL.mjs +15 -0
- package/dist/Issued-DejqoMYL.mjs.map +1 -0
- package/dist/Launch-BHcAEq05.mjs +111 -0
- package/dist/Launch-BHcAEq05.mjs.map +1 -0
- package/dist/Launch-C8CfaYxb.d.mts +132 -0
- package/dist/Launch.d.mts +2 -0
- package/dist/Launch.mjs +105 -0
- package/dist/Launch.mjs.map +1 -0
- package/dist/PageControl.d.mts +16 -0
- package/dist/PageControl.mjs +36 -0
- package/dist/PageControl.mjs.map +1 -0
- package/dist/PageControlAssociation-DabEg5AR.mjs +10 -0
- package/dist/PageControlAssociation-DabEg5AR.mjs.map +1 -0
- package/dist/PageFetch.d.mts +40 -0
- package/dist/PageFetch.mjs +64 -0
- package/dist/PageFetch.mjs.map +1 -0
- package/dist/Projects.d.mts +39 -0
- package/dist/Projects.mjs +71 -0
- package/dist/Projects.mjs.map +1 -0
- package/dist/Recordings.d.mts +28 -0
- package/dist/Recordings.mjs +131 -0
- package/dist/Recordings.mjs.map +1 -0
- package/dist/References-URDAtapt.d.mts +35 -0
- package/dist/References.d.mts +2 -0
- package/dist/References.mjs +41 -0
- package/dist/References.mjs.map +1 -0
- package/dist/Replays.d.mts +28 -0
- package/dist/Replays.mjs +109 -0
- package/dist/Replays.mjs.map +1 -0
- package/dist/Resource-DBksC4zB.mjs +50 -0
- package/dist/Resource-DBksC4zB.mjs.map +1 -0
- package/dist/Search.d.mts +38 -0
- package/dist/Search.mjs +53 -0
- package/dist/Search.mjs.map +1 -0
- package/dist/SessionData-DRKcKCqw.d.mts +39 -0
- package/dist/SessionData.d.mts +2 -0
- package/dist/SessionData.mjs +55 -0
- package/dist/SessionData.mjs.map +1 -0
- package/dist/Sessions-B8E4kMxo.d.mts +68 -0
- package/dist/Sessions-CtbseWEh.mjs +244 -0
- package/dist/Sessions-CtbseWEh.mjs.map +1 -0
- package/dist/Sessions.d.mts +3 -0
- package/dist/Sessions.mjs +3 -0
- package/dist/TransferPolicy-DQ06i7SZ.mjs +25 -0
- package/dist/TransferPolicy-DQ06i7SZ.mjs.map +1 -0
- package/dist/Transfers-Czv5IZzJ.d.mts +76 -0
- package/dist/Transfers.d.mts +2 -0
- package/dist/Transfers.mjs +101 -0
- package/dist/Transfers.mjs.map +1 -0
- package/dist/Uploads.d.mts +29 -0
- package/dist/Uploads.mjs +107 -0
- package/dist/Uploads.mjs.map +1 -0
- package/dist/Webhooks.d.mts +60 -0
- package/dist/Webhooks.mjs +143 -0
- package/dist/Webhooks.mjs.map +1 -0
- package/dist/WriterFacts-osvYAsIx.d.mts +61 -0
- package/dist/index.d.mts +30 -0
- package/dist/index.mjs +30 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +163 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { o as SessionReference } from "./References-URDAtapt.mjs";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
declare namespace Transfers_d_exports {
|
|
4
|
+
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, UploadReceipt };
|
|
5
|
+
}
|
|
6
|
+
declare const PositiveInt: Schema.Int;
|
|
7
|
+
/** Shared caller-owned transfer bounds. Omitted timeout retains the 60-second default. */
|
|
8
|
+
declare const ArtifactTransferPolicy: Schema.Struct<{
|
|
9
|
+
readonly maxBytes: Schema.Int;
|
|
10
|
+
readonly timeoutMillis: Schema.optionalKey<Schema.Int>;
|
|
11
|
+
}>;
|
|
12
|
+
type ArtifactTransferPolicy = typeof ArtifactTransferPolicy.Type;
|
|
13
|
+
/** Portable basename only; never a local or remote filesystem path. */
|
|
14
|
+
declare const SafeFilename: Schema.NonEmptyString;
|
|
15
|
+
/**
|
|
16
|
+
* A path the provider reported for a file it already holds. It is only ever decoded from a
|
|
17
|
+
* provider response: no caller, and certainly no model, names a remote filesystem path.
|
|
18
|
+
*/
|
|
19
|
+
declare const RemoteFilePath: Schema.NonEmptyString;
|
|
20
|
+
declare const UploadReceipt_base: Schema.Class<UploadReceipt, Schema.Struct<{
|
|
21
|
+
readonly reference: typeof SessionReference;
|
|
22
|
+
readonly filename: Schema.NonEmptyString;
|
|
23
|
+
readonly bytes: Schema.Natural;
|
|
24
|
+
readonly remotePath: Schema.optionalKey<Schema.NonEmptyString>;
|
|
25
|
+
readonly acknowledgement: Schema.optionalKey<Schema.String>;
|
|
26
|
+
}>, {}>;
|
|
27
|
+
/**
|
|
28
|
+
* Evidence of one accepted upload. `remotePath` exists only when the provider returned one;
|
|
29
|
+
* its absence is reported rather than guessed, and attachment is refused without it.
|
|
30
|
+
*/
|
|
31
|
+
declare class UploadReceipt extends UploadReceipt_base {}
|
|
32
|
+
declare const DownloadMetadata_base: Schema.Class<DownloadMetadata, Schema.Struct<{
|
|
33
|
+
readonly id: Schema.NonEmptyString;
|
|
34
|
+
readonly sessionId: Schema.NonEmptyString;
|
|
35
|
+
readonly filename: Schema.NonEmptyString;
|
|
36
|
+
readonly mimeType: Schema.NonEmptyString;
|
|
37
|
+
readonly size: Schema.Natural;
|
|
38
|
+
readonly checksum: Schema.String;
|
|
39
|
+
readonly createdAt: Schema.NonEmptyString;
|
|
40
|
+
}>, {}>;
|
|
41
|
+
declare class DownloadMetadata extends DownloadMetadata_base {}
|
|
42
|
+
declare const DownloadObservation_base: Schema.Class<DownloadObservation, Schema.Struct<{
|
|
43
|
+
readonly reference: typeof SessionReference;
|
|
44
|
+
readonly downloadId: Schema.NonEmptyString;
|
|
45
|
+
readonly filename: Schema.NonEmptyString;
|
|
46
|
+
readonly state: Schema.Literals<readonly ["started", "completed", "failed", "unknown"]>;
|
|
47
|
+
}>, {}>;
|
|
48
|
+
/** A native event identity is not a provider download ID. Associate provider metadata explicitly. */
|
|
49
|
+
declare class DownloadObservation extends DownloadObservation_base {}
|
|
50
|
+
declare const RecordingPageReference_base: Schema.Class<RecordingPageReference, Schema.Struct<{
|
|
51
|
+
readonly session: typeof SessionReference;
|
|
52
|
+
readonly pageId: Schema.NonEmptyString;
|
|
53
|
+
}>, {}>;
|
|
54
|
+
declare class RecordingPageReference extends RecordingPageReference_base {}
|
|
55
|
+
declare const RecordingPage_base: Schema.Class<RecordingPage, Schema.Struct<{
|
|
56
|
+
readonly pageId: Schema.NonEmptyString;
|
|
57
|
+
readonly status: Schema.Literals<readonly ["NOT_REQUESTED", "PENDING", "COMPLETED", "FAILED"]>;
|
|
58
|
+
readonly delivery: Schema.Literals<readonly ["not-ready", "download", "external-storage"]>;
|
|
59
|
+
readonly completedAt: Schema.optionalKey<Schema.String>;
|
|
60
|
+
}>, {}>;
|
|
61
|
+
declare class RecordingPage extends RecordingPage_base {}
|
|
62
|
+
declare const RecordingBatch_base: Schema.Class<RecordingBatch, Schema.Struct<{
|
|
63
|
+
readonly reference: typeof SessionReference;
|
|
64
|
+
readonly pages: Schema.$Array<typeof RecordingPage>;
|
|
65
|
+
readonly timedOut: Schema.Boolean;
|
|
66
|
+
}>, {}>;
|
|
67
|
+
declare class RecordingBatch extends RecordingBatch_base {}
|
|
68
|
+
declare const ReplayPage_base: Schema.Class<ReplayPage, Schema.Struct<{
|
|
69
|
+
readonly pageId: Schema.NonEmptyString;
|
|
70
|
+
readonly startTimeMs: Schema.Finite;
|
|
71
|
+
readonly endTimeMs: Schema.Finite;
|
|
72
|
+
}>, {}>;
|
|
73
|
+
declare class ReplayPage extends ReplayPage_base {}
|
|
74
|
+
//#endregion
|
|
75
|
+
export { RecordingBatch as a, RemoteFilePath as c, Transfers_d_exports as d, UploadReceipt as f, PositiveInt as i, ReplayPage as l, DownloadMetadata as n, RecordingPage as o, DownloadObservation as r, RecordingPageReference as s, ArtifactTransferPolicy as t, SafeFilename as u };
|
|
76
|
+
//# sourceMappingURL=Transfers-Czv5IZzJ.d.mts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as RecordingBatch, c as RemoteFilePath, f as UploadReceipt, i as PositiveInt, l as ReplayPage, n as DownloadMetadata, o as RecordingPage, r as DownloadObservation, s as RecordingPageReference, t as ArtifactTransferPolicy, u as SafeFilename } from "./Transfers-Czv5IZzJ.mjs";
|
|
2
|
+
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, UploadReceipt };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Identifier, SessionReference } from "./References.mjs";
|
|
3
|
+
import { Schema } from "effect";
|
|
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
|
+
/** Shared caller-owned transfer bounds. Omitted timeout retains the 60-second default. */
|
|
20
|
+
const ArtifactTransferPolicy = Schema.Struct({
|
|
21
|
+
maxBytes: Schema.Int.check(Schema.isBetween({
|
|
22
|
+
minimum: 1,
|
|
23
|
+
maximum: 2 ** 31 - 1
|
|
24
|
+
})),
|
|
25
|
+
timeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
26
|
+
minimum: 1,
|
|
27
|
+
maximum: 6e5
|
|
28
|
+
})))
|
|
29
|
+
});
|
|
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
|
+
/**
|
|
33
|
+
* A path the provider reported for a file it already holds. It is only ever decoded from a
|
|
34
|
+
* provider response: no caller, and certainly no model, names a remote filesystem path.
|
|
35
|
+
*/
|
|
36
|
+
const RemoteFilePath = Schema.NonEmptyString.check(Schema.isMaxLength(4096), Schema.makeFilter((value) => value.startsWith("/") && !value.includes("\\") && !value.includes("//") && ![...value].some((character) => character < " " || character === "") && value.split("/").every((segment) => segment !== "." && segment !== ".."), { title: "an absolute, traversal-free remote path" }));
|
|
37
|
+
/**
|
|
38
|
+
* Evidence of one accepted upload. `remotePath` exists only when the provider returned one;
|
|
39
|
+
* its absence is reported rather than guessed, and attachment is refused without it.
|
|
40
|
+
*/
|
|
41
|
+
var UploadReceipt = class extends Schema.Class("BrowserbaseUploadReceipt")({
|
|
42
|
+
reference: SessionReference,
|
|
43
|
+
filename: SafeFilename,
|
|
44
|
+
bytes: Schema.Natural,
|
|
45
|
+
remotePath: Schema.optionalKey(RemoteFilePath),
|
|
46
|
+
acknowledgement: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024)))
|
|
47
|
+
}) {};
|
|
48
|
+
var DownloadMetadata = class extends Schema.Class("BrowserbaseDownloadMetadata")({
|
|
49
|
+
id: Identifier,
|
|
50
|
+
sessionId: Identifier,
|
|
51
|
+
filename: SafeFilename,
|
|
52
|
+
mimeType: Schema.NonEmptyString.check(Schema.isMaxLength(128)),
|
|
53
|
+
size: Schema.Natural,
|
|
54
|
+
checksum: Schema.String.check(Schema.isPattern(/^[a-fA-F0-9]{64}$/)),
|
|
55
|
+
createdAt: Schema.NonEmptyString.check(Schema.isMaxLength(64))
|
|
56
|
+
}) {};
|
|
57
|
+
/** A native event identity is not a provider download ID. Associate provider metadata explicitly. */
|
|
58
|
+
var DownloadObservation = class extends Schema.Class("BrowserbaseDownloadObservation")({
|
|
59
|
+
reference: SessionReference,
|
|
60
|
+
downloadId: Identifier,
|
|
61
|
+
filename: SafeFilename,
|
|
62
|
+
state: Schema.Literals([
|
|
63
|
+
"started",
|
|
64
|
+
"completed",
|
|
65
|
+
"failed",
|
|
66
|
+
"unknown"
|
|
67
|
+
])
|
|
68
|
+
}) {};
|
|
69
|
+
var RecordingPageReference = class extends Schema.Class("BrowserbaseRecordingPageReference")({
|
|
70
|
+
session: SessionReference,
|
|
71
|
+
pageId: Identifier
|
|
72
|
+
}) {};
|
|
73
|
+
var RecordingPage = class extends Schema.Class("BrowserbaseRecordingPage")({
|
|
74
|
+
pageId: Identifier,
|
|
75
|
+
status: Schema.Literals([
|
|
76
|
+
"NOT_REQUESTED",
|
|
77
|
+
"PENDING",
|
|
78
|
+
"COMPLETED",
|
|
79
|
+
"FAILED"
|
|
80
|
+
]),
|
|
81
|
+
delivery: Schema.Literals([
|
|
82
|
+
"not-ready",
|
|
83
|
+
"download",
|
|
84
|
+
"external-storage"
|
|
85
|
+
]),
|
|
86
|
+
completedAt: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(64)))
|
|
87
|
+
}) {};
|
|
88
|
+
var RecordingBatch = class extends Schema.Class("BrowserbaseRecordingBatch")({
|
|
89
|
+
reference: SessionReference,
|
|
90
|
+
pages: Schema.Array(RecordingPage).check(Schema.isMaxLength(256)),
|
|
91
|
+
timedOut: Schema.Boolean
|
|
92
|
+
}) {};
|
|
93
|
+
var ReplayPage = class extends Schema.Class("BrowserbaseReplayPage")({
|
|
94
|
+
pageId: Identifier,
|
|
95
|
+
startTimeMs: Schema.Finite,
|
|
96
|
+
endTimeMs: Schema.Finite
|
|
97
|
+
}) {};
|
|
98
|
+
//#endregion
|
|
99
|
+
export { ArtifactTransferPolicy, DownloadMetadata, DownloadObservation, PositiveInt, RecordingBatch, RecordingPage, RecordingPageReference, RemoteFilePath, ReplayPage, SafeFilename, UploadReceipt, Transfers_exports as t };
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=Transfers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transfers.mjs","names":[],"sources":["../src/Transfers.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { Identifier, SessionReference } from \"./References.ts\";\n\nexport const PositiveInt = Schema.Int.check(Schema.isGreaterThan(0));\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/** Portable basename only; never a local or remote filesystem path. */\nexport const SafeFilename = Schema.NonEmptyString.check(\n Schema.isMaxLength(240),\n Schema.makeFilter(\n (value) =>\n value !== \".\" &&\n value !== \"..\" &&\n !/[\\x00-\\x1f\\x7f/\\\\:]/.test(value) &&\n !/[. ]$/.test(value) &&\n !/^\\s/.test(value) &&\n !/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\\.|$)/i.test(value),\n { title: \"a portable, non-path download filename\" },\n ),\n);\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"],"mappings":";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apt.mjs";
|
|
2
|
+
import { FileError } from "./Errors.mjs";
|
|
3
|
+
import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
|
|
4
|
+
import { t as BrowserbaseSessions } from "./Sessions-B8E4kMxo.mjs";
|
|
5
|
+
import { f as UploadReceipt } from "./Transfers-Czv5IZzJ.mjs";
|
|
6
|
+
import { Context, Effect, Layer } from "effect";
|
|
7
|
+
declare namespace Uploads_d_exports {
|
|
8
|
+
export { BrowserbaseUploads, UploadFile };
|
|
9
|
+
}
|
|
10
|
+
export interface UploadFile {
|
|
11
|
+
readonly filename: string;
|
|
12
|
+
readonly mediaType: string;
|
|
13
|
+
readonly bytes: Uint8Array;
|
|
14
|
+
readonly maxBytes?: number;
|
|
15
|
+
readonly timeoutMillis?: number;
|
|
16
|
+
}
|
|
17
|
+
declare const BrowserbaseUploads_base: Context.ServiceClass<BrowserbaseUploads, "effect-browserbase/Uploads", {
|
|
18
|
+
readonly create: (reference: SessionReference, file: UploadFile) => Effect.Effect<UploadReceipt, FileError>;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* A session upload places bytes where the remote browser can already reach them. It is the
|
|
22
|
+
* large-file half of file selection; small in-memory selection needs no provisioning at all.
|
|
23
|
+
*/
|
|
24
|
+
export declare class BrowserbaseUploads extends BrowserbaseUploads_base {
|
|
25
|
+
static readonly layer: Layer.Layer<BrowserbaseUploads, never, BrowserbaseClient | BrowserbaseSessions>;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Uploads_d_exports as t };
|
|
29
|
+
//# sourceMappingURL=Uploads.d.mts.map
|
package/dist/Uploads.mjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { FileError } from "./Errors.mjs";
|
|
3
|
+
import { RemoteFilePath, SafeFilename, UploadReceipt } from "./Transfers.mjs";
|
|
4
|
+
import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
|
|
5
|
+
import { t as BrowserbaseSessions } from "./Sessions-CtbseWEh.mjs";
|
|
6
|
+
import { n as recordIssuedUpload } from "./Issued-DejqoMYL.mjs";
|
|
7
|
+
import { Context, Effect, Layer, Schema } from "effect";
|
|
8
|
+
//#region src/Uploads.ts
|
|
9
|
+
var Uploads_exports = /* @__PURE__ */ __exportAll({ BrowserbaseUploads: () => BrowserbaseUploads });
|
|
10
|
+
/** The provider's documented per-file ceiling for a session upload. */
|
|
11
|
+
const MAX_UPLOAD_BYTES = 536870912;
|
|
12
|
+
const MediaType = Schema.NonEmptyString.check(Schema.isMaxLength(128), Schema.isPattern(/^[a-z0-9][a-z0-9!#$&^_+.-]*\/[a-z0-9][a-z0-9!#$&^_+.-]*$/));
|
|
13
|
+
const UploadOptions = Schema.Struct({
|
|
14
|
+
filename: SafeFilename,
|
|
15
|
+
mediaType: MediaType,
|
|
16
|
+
maxBytes: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
17
|
+
minimum: 1,
|
|
18
|
+
maximum: MAX_UPLOAD_BYTES
|
|
19
|
+
}))),
|
|
20
|
+
timeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
21
|
+
minimum: 1,
|
|
22
|
+
maximum: 6e5
|
|
23
|
+
})))
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Only fields this package can validate are carried forward. `path` is the provider's own
|
|
27
|
+
* remote location for the stored file; when the response omits it, the receipt says so
|
|
28
|
+
* instead of inventing one, and attachment by path is refused rather than guessed.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Where the provider places session uploads inside the remote browser. Observed against the
|
|
32
|
+
* provider on 21 September 2026 and documented at
|
|
33
|
+
* https://docs.browserbase.com/platform/browser/files/uploads.md; the create reply does not
|
|
34
|
+
* return it.
|
|
35
|
+
*/
|
|
36
|
+
const UPLOAD_DIRECTORY = "/tmp/.uploads";
|
|
37
|
+
const ProviderUpload = Schema.Struct({
|
|
38
|
+
message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(1024))),
|
|
39
|
+
path: Schema.optionalKey(RemoteFilePath)
|
|
40
|
+
});
|
|
41
|
+
const failure = (operation, reason) => FileError.make({
|
|
42
|
+
operation,
|
|
43
|
+
reason,
|
|
44
|
+
outcome: "undispatched"
|
|
45
|
+
});
|
|
46
|
+
const fromClient = (operation) => (error) => FileError.make({
|
|
47
|
+
operation,
|
|
48
|
+
reason: error.reason,
|
|
49
|
+
...error.outcome === void 0 ? {} : { outcome: error.outcome },
|
|
50
|
+
...error.status === void 0 ? {} : { status: error.status },
|
|
51
|
+
...error.retryAfterMillis === void 0 ? {} : { retryAfterMillis: error.retryAfterMillis }
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* A session upload places bytes where the remote browser can already reach them. It is the
|
|
55
|
+
* large-file half of file selection; small in-memory selection needs no provisioning at all.
|
|
56
|
+
*/
|
|
57
|
+
var BrowserbaseUploads = class BrowserbaseUploads extends Context.Service()("effect-browserbase/Uploads") {
|
|
58
|
+
static layer = Layer.effect(BrowserbaseUploads, Effect.gen(function* () {
|
|
59
|
+
const client = yield* BrowserbaseClient;
|
|
60
|
+
const sessions = yield* BrowserbaseSessions;
|
|
61
|
+
const create = Effect.fn("BrowserbaseUploads.create")(function* (reference, file) {
|
|
62
|
+
const { bytes, ...rest } = file;
|
|
63
|
+
const value = yield* Schema.decodeEffect(UploadOptions)(rest, { onExcessProperty: "error" }).pipe(Effect.mapError(() => failure("upload", "configuration")));
|
|
64
|
+
if (!(bytes instanceof Uint8Array)) return yield* failure("upload", "configuration");
|
|
65
|
+
const maxBytes = value.maxBytes ?? MAX_UPLOAD_BYTES;
|
|
66
|
+
if (bytes.byteLength < 1 || bytes.byteLength > maxBytes) return yield* failure("upload", "limit");
|
|
67
|
+
const state = yield* sessions.retrieve(reference).pipe(Effect.mapError((error) => FileError.make({
|
|
68
|
+
operation: "upload",
|
|
69
|
+
reason: error.reason
|
|
70
|
+
})));
|
|
71
|
+
if (state.status !== "RUNNING") return yield* failure("upload", "expired");
|
|
72
|
+
const owned = new Uint8Array(bytes);
|
|
73
|
+
const raw = yield* client.upload(`/v1/sessions/${encodeURIComponent(state.reference.sessionId)}/uploads`, {
|
|
74
|
+
field: "file",
|
|
75
|
+
filename: value.filename,
|
|
76
|
+
mediaType: value.mediaType,
|
|
77
|
+
bytes: owned
|
|
78
|
+
}, {
|
|
79
|
+
maxBytes,
|
|
80
|
+
...value.timeoutMillis === void 0 ? {} : { timeoutMillis: value.timeoutMillis }
|
|
81
|
+
}).pipe(Effect.mapError(fromClient("upload")));
|
|
82
|
+
const acknowledged = yield* Schema.decodeUnknownEffect(ProviderUpload)(raw).pipe(Effect.mapError(() => FileError.make({
|
|
83
|
+
operation: "upload",
|
|
84
|
+
reason: "malformed",
|
|
85
|
+
outcome: "unknown"
|
|
86
|
+
})));
|
|
87
|
+
const remotePath = acknowledged.path ?? `${UPLOAD_DIRECTORY}/${value.filename}`;
|
|
88
|
+
const receipt = UploadReceipt.make({
|
|
89
|
+
reference: state.reference,
|
|
90
|
+
filename: value.filename,
|
|
91
|
+
bytes: owned.byteLength,
|
|
92
|
+
remotePath,
|
|
93
|
+
...acknowledged.message === void 0 ? {} : { acknowledgement: acknowledged.message }
|
|
94
|
+
});
|
|
95
|
+
recordIssuedUpload(receipt, {
|
|
96
|
+
reference: state.reference,
|
|
97
|
+
remotePath
|
|
98
|
+
});
|
|
99
|
+
return receipt;
|
|
100
|
+
});
|
|
101
|
+
return BrowserbaseUploads.of({ create });
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
//#endregion
|
|
105
|
+
export { BrowserbaseUploads, Uploads_exports as t };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=Uploads.mjs.map
|
|
@@ -0,0 +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":";;;;;;;;;;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;CAA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C,gBAAgB,mBAAmB,MAAM,UAAU,SAAS,EAAE,WAC9D;IACE,OAAO;IACP,UAAU,MAAM;IAChB,WAAW,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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { PlatformError } from "./Errors.mjs";
|
|
2
|
+
import { t as BrowserbaseClient } from "./Client-Ca0zSg1n.mjs";
|
|
3
|
+
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
4
|
+
declare namespace Webhooks_d_exports {
|
|
5
|
+
export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookPage, WebhookRegistration, WebhookSettings, WebhookUpdate };
|
|
6
|
+
}
|
|
7
|
+
/** Provider event names. Browserbase currently emits Functions events only. */
|
|
8
|
+
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
|
+
export type WebhookEventType = typeof WebhookEventType.Type;
|
|
10
|
+
export declare const WebhookSettings: Schema.Struct<{
|
|
11
|
+
readonly endpoint: Schema.NonEmptyString;
|
|
12
|
+
readonly eventTypes: Schema.$Array<Schema.Literals<readonly ["functions.builds.running", "functions.builds.completed", "functions.builds.failed", "functions.invocations.pending", "functions.invocations.running", "functions.invocations.completed", "functions.invocations.failed"]>>;
|
|
13
|
+
}>;
|
|
14
|
+
export type WebhookSettings = typeof WebhookSettings.Type;
|
|
15
|
+
export declare const WebhookUpdate: Schema.Struct<{
|
|
16
|
+
readonly endpoint: Schema.optionalKey<Schema.NonEmptyString>;
|
|
17
|
+
readonly eventTypes: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["functions.builds.running", "functions.builds.completed", "functions.builds.failed", "functions.invocations.pending", "functions.invocations.running", "functions.invocations.completed", "functions.invocations.failed"]>>>;
|
|
18
|
+
}>;
|
|
19
|
+
export type WebhookUpdate = typeof WebhookUpdate.Type;
|
|
20
|
+
declare const WebhookMetadata_base: Schema.Class<WebhookMetadata, Schema.Struct<{
|
|
21
|
+
readonly webhookId: Schema.NonEmptyString;
|
|
22
|
+
readonly projectId: Schema.NonEmptyString;
|
|
23
|
+
readonly endpoint: Schema.String;
|
|
24
|
+
readonly eventTypes: Schema.$Array<Schema.String>;
|
|
25
|
+
readonly createdAt: Schema.String;
|
|
26
|
+
readonly updatedAt: Schema.String;
|
|
27
|
+
}>, {}>;
|
|
28
|
+
export declare class WebhookMetadata extends WebhookMetadata_base {}
|
|
29
|
+
/** A signing secret is returned once, redacted so it cannot be logged by accident. */
|
|
30
|
+
export interface WebhookRegistration {
|
|
31
|
+
readonly webhook: WebhookMetadata;
|
|
32
|
+
readonly secret: Redacted.Redacted<string>;
|
|
33
|
+
}
|
|
34
|
+
export interface WebhookPage {
|
|
35
|
+
readonly webhooks: ReadonlyArray<WebhookMetadata>;
|
|
36
|
+
readonly nextCursor: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
export declare const WebhookListQuery: Schema.Struct<{
|
|
39
|
+
readonly cursor: Schema.optionalKey<Schema.NonEmptyString>;
|
|
40
|
+
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
41
|
+
}>;
|
|
42
|
+
export type WebhookListQuery = typeof WebhookListQuery.Type;
|
|
43
|
+
declare const BrowserbaseWebhooks_base: Context.ServiceClass<BrowserbaseWebhooks, "effect-browserbase/Webhooks", {
|
|
44
|
+
readonly create: (settings: WebhookSettings) => Effect.Effect<WebhookRegistration, PlatformError>;
|
|
45
|
+
readonly list: (query?: WebhookListQuery) => Effect.Effect<WebhookPage, PlatformError>;
|
|
46
|
+
readonly retrieve: (webhookId: string) => Effect.Effect<WebhookMetadata, PlatformError>;
|
|
47
|
+
readonly update: (webhookId: string, update: WebhookUpdate) => Effect.Effect<WebhookMetadata, PlatformError>;
|
|
48
|
+
readonly delete: (webhookId: string) => Effect.Effect<void, PlatformError>;
|
|
49
|
+
/** Issues a new secret; the old one keeps working unless `revokeImmediately`. */
|
|
50
|
+
readonly rotateSecret: (webhookId: string, options?: {
|
|
51
|
+
readonly revokeImmediately?: boolean;
|
|
52
|
+
}) => Effect.Effect<Redacted.Redacted<string>, PlatformError>;
|
|
53
|
+
}>;
|
|
54
|
+
/** Webhook administration for the Client's project. Mutations are never retried. */
|
|
55
|
+
export declare class BrowserbaseWebhooks extends BrowserbaseWebhooks_base {
|
|
56
|
+
static readonly layer: Layer.Layer<BrowserbaseWebhooks, never, BrowserbaseClient>;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { Webhooks_d_exports as t };
|
|
60
|
+
//# sourceMappingURL=Webhooks.d.mts.map
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { Identifier } from "./References.mjs";
|
|
3
|
+
import { PlatformError } from "./Errors.mjs";
|
|
4
|
+
import { t as BrowserbaseClient } from "./Client-D1_xYM9o.mjs";
|
|
5
|
+
import { t as resource } from "./Resource-DBksC4zB.mjs";
|
|
6
|
+
import { Context, Effect, Layer, Redacted, Schema } from "effect";
|
|
7
|
+
//#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
|
+
const Timestamp = Schema.String.check(Schema.isMaxLength(64));
|
|
17
|
+
/** Provider event names. Browserbase currently emits Functions events only. */
|
|
18
|
+
const WebhookEventType = Schema.Literals([
|
|
19
|
+
"functions.builds.running",
|
|
20
|
+
"functions.builds.completed",
|
|
21
|
+
"functions.builds.failed",
|
|
22
|
+
"functions.invocations.pending",
|
|
23
|
+
"functions.invocations.running",
|
|
24
|
+
"functions.invocations.completed",
|
|
25
|
+
"functions.invocations.failed"
|
|
26
|
+
]);
|
|
27
|
+
const Endpoint = Schema.NonEmptyString.check(Schema.isMaxLength(2048), Schema.makeFilter((value) => {
|
|
28
|
+
try {
|
|
29
|
+
const url = new URL(value);
|
|
30
|
+
return url.protocol === "https:" && !url.username && !url.password;
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
const EventTypes = Schema.Array(WebhookEventType).check(Schema.isMinLength(1), Schema.isMaxLength(7), Schema.isUnique());
|
|
36
|
+
const WebhookSettings = Schema.Struct({
|
|
37
|
+
endpoint: Endpoint,
|
|
38
|
+
eventTypes: EventTypes
|
|
39
|
+
});
|
|
40
|
+
const WebhookUpdate = Schema.Struct({
|
|
41
|
+
endpoint: Schema.optionalKey(Endpoint),
|
|
42
|
+
eventTypes: Schema.optionalKey(EventTypes)
|
|
43
|
+
});
|
|
44
|
+
var WebhookMetadata = class extends Schema.Class("BrowserbaseWebhookMetadata")({
|
|
45
|
+
webhookId: Identifier,
|
|
46
|
+
projectId: Identifier,
|
|
47
|
+
endpoint: Schema.String.check(Schema.isMaxLength(2048)),
|
|
48
|
+
eventTypes: Schema.Array(Schema.String.check(Schema.isMaxLength(128))).check(Schema.isMaxLength(64)),
|
|
49
|
+
createdAt: Timestamp,
|
|
50
|
+
updatedAt: Timestamp
|
|
51
|
+
}) {};
|
|
52
|
+
const ProviderWebhook = Schema.Struct({
|
|
53
|
+
id: Identifier,
|
|
54
|
+
projectId: Identifier,
|
|
55
|
+
endpoint: WebhookMetadata.fields.endpoint,
|
|
56
|
+
eventTypes: WebhookMetadata.fields.eventTypes,
|
|
57
|
+
createdAt: Timestamp,
|
|
58
|
+
updatedAt: Timestamp
|
|
59
|
+
});
|
|
60
|
+
const Secret = Schema.NonEmptyString.check(Schema.isMaxLength(1024));
|
|
61
|
+
const Page = Schema.Struct({
|
|
62
|
+
data: Schema.Array(ProviderWebhook).check(Schema.isMaxLength(100)),
|
|
63
|
+
nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096))))
|
|
64
|
+
});
|
|
65
|
+
const WebhookListQuery = Schema.Struct({
|
|
66
|
+
cursor: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(4096))),
|
|
67
|
+
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
68
|
+
minimum: 1,
|
|
69
|
+
maximum: 100
|
|
70
|
+
})))
|
|
71
|
+
});
|
|
72
|
+
/** Webhook administration for the Client's project. Mutations are never retried. */
|
|
73
|
+
var BrowserbaseWebhooks = class BrowserbaseWebhooks extends Context.Service()("effect-browserbase/Webhooks") {
|
|
74
|
+
static layer = Layer.effect(BrowserbaseWebhooks, Effect.gen(function* () {
|
|
75
|
+
const client = yield* BrowserbaseClient;
|
|
76
|
+
const api = resource(client, (failure) => PlatformError.make({
|
|
77
|
+
...failure,
|
|
78
|
+
service: "webhooks"
|
|
79
|
+
}));
|
|
80
|
+
const decode = (operation, mutation, expected) => Effect.fnUntraced(function* (value) {
|
|
81
|
+
if (value.projectId !== client.projectId || expected !== void 0 && value.id !== expected) return yield* api.malformed(operation, mutation);
|
|
82
|
+
const { id, ...rest } = value;
|
|
83
|
+
return WebhookMetadata.make({
|
|
84
|
+
webhookId: id,
|
|
85
|
+
...rest
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
const path = (id) => `/v1/webhooks/${api.segment(id)}`;
|
|
89
|
+
const create = Effect.fn("BrowserbaseWebhooks.create")(function* (settings) {
|
|
90
|
+
const value = yield* api.input(WebhookSettings, settings, "webhook-create");
|
|
91
|
+
const { secret, ...webhook } = yield* api.request("POST", "/v1/webhooks", Schema.Struct({
|
|
92
|
+
...ProviderWebhook.fields,
|
|
93
|
+
secret: Secret
|
|
94
|
+
}), "webhook-create", value);
|
|
95
|
+
return {
|
|
96
|
+
webhook: yield* decode("webhook-create", true)(webhook),
|
|
97
|
+
secret: Redacted.make(secret)
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
const list = Effect.fn("BrowserbaseWebhooks.list")(function* (query = {}) {
|
|
101
|
+
const value = yield* api.input(WebhookListQuery, query, "webhook-list");
|
|
102
|
+
const page = yield* api.request("GET", `/v1/webhooks${api.query(value)}`, Page, "webhook-list");
|
|
103
|
+
return {
|
|
104
|
+
webhooks: yield* Effect.forEach(page.data, decode("webhook-list", false)),
|
|
105
|
+
nextCursor: page.nextCursor ?? void 0
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
const retrieve = Effect.fn("BrowserbaseWebhooks.retrieve")(function* (webhookId) {
|
|
109
|
+
const id = yield* api.input(Identifier, webhookId, "webhook-retrieve");
|
|
110
|
+
const value = yield* api.request("GET", path(id), ProviderWebhook, "webhook-retrieve");
|
|
111
|
+
return yield* decode("webhook-retrieve", false, id)(value);
|
|
112
|
+
});
|
|
113
|
+
const update = Effect.fn("BrowserbaseWebhooks.update")(function* (webhookId, changes) {
|
|
114
|
+
const id = yield* api.input(Identifier, webhookId, "webhook-update");
|
|
115
|
+
const value = yield* api.input(WebhookUpdate, changes, "webhook-update");
|
|
116
|
+
if (value.endpoint === void 0 && value.eventTypes === void 0) return yield* api.configuration("webhook-update");
|
|
117
|
+
const updated = yield* api.request("PATCH", path(id), ProviderWebhook, "webhook-update", value);
|
|
118
|
+
return yield* decode("webhook-update", true, id)(updated);
|
|
119
|
+
});
|
|
120
|
+
const remove = Effect.fn("BrowserbaseWebhooks.delete")(function* (webhookId) {
|
|
121
|
+
const id = yield* api.input(Identifier, webhookId, "webhook-delete");
|
|
122
|
+
yield* api.remove(path(id), "webhook-delete");
|
|
123
|
+
});
|
|
124
|
+
const rotateSecret = Effect.fn("BrowserbaseWebhooks.rotateSecret")(function* (webhookId, options = {}) {
|
|
125
|
+
const id = yield* api.input(Identifier, webhookId, "webhook-rotate-secret");
|
|
126
|
+
const value = yield* api.input(Schema.Struct({ revokeImmediately: Schema.optionalKey(Schema.Boolean) }), options, "webhook-rotate-secret");
|
|
127
|
+
const rotated = yield* api.request("POST", `${path(id)}/secret`, Schema.Struct({ secret: Secret }), "webhook-rotate-secret", value);
|
|
128
|
+
return Redacted.make(rotated.secret);
|
|
129
|
+
});
|
|
130
|
+
return BrowserbaseWebhooks.of({
|
|
131
|
+
create,
|
|
132
|
+
list,
|
|
133
|
+
retrieve,
|
|
134
|
+
update,
|
|
135
|
+
delete: remove,
|
|
136
|
+
rotateSecret
|
|
137
|
+
});
|
|
138
|
+
}));
|
|
139
|
+
};
|
|
140
|
+
//#endregion
|
|
141
|
+
export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookSettings, WebhookUpdate, Webhooks_exports as t };
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=Webhooks.mjs.map
|
|
@@ -0,0 +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,OAAO,YAAY,IAAI,GACvB,OAAO,YAAY,UAAU;CAC3B,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EAEzB,OAAO,IAAI,aAAa,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI;CAC5D,QAAQ;EACN,OAAO;CACT;AACF,CAAC,CACH;AAEA,M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