effect-browserbase 0.2.0-beta.8 → 0.3.0-beta.10

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.
Files changed (155) hide show
  1. package/README.md +277 -315
  2. package/dist/Browserbase-CaPKwEY9.mjs +544 -0
  3. package/dist/Browserbase-CaPKwEY9.mjs.map +1 -0
  4. package/dist/Browserbase.d.mts +110 -0
  5. package/dist/Browserbase.mjs +3 -0
  6. package/dist/BrowserbaseClient-CtAQ2rg4.d.mts +195 -0
  7. package/dist/BrowserbaseClient.d.mts +2 -0
  8. package/dist/BrowserbaseClient.mjs +190 -0
  9. package/dist/BrowserbaseClient.mjs.map +1 -0
  10. package/dist/BrowserbaseError-D1EOrLNc.d.mts +79 -0
  11. package/dist/BrowserbaseError.d.mts +2 -0
  12. package/dist/BrowserbaseError.mjs +101 -0
  13. package/dist/BrowserbaseError.mjs.map +1 -0
  14. package/dist/ContextLease.d.mts +42 -0
  15. package/dist/ContextLease.mjs +80 -0
  16. package/dist/ContextLease.mjs.map +1 -0
  17. package/dist/index.d.mts +5 -27
  18. package/dist/index.mjs +5 -26
  19. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  20. package/dist/testing/index.d.mts +136 -0
  21. package/dist/testing/index.mjs +440 -0
  22. package/dist/testing/index.mjs.map +1 -0
  23. package/package.json +51 -121
  24. package/src/Browserbase.ts +729 -0
  25. package/src/BrowserbaseClient.ts +559 -0
  26. package/src/BrowserbaseError.ts +108 -0
  27. package/src/ContextLease.ts +118 -0
  28. package/src/index.ts +7 -0
  29. package/src/internal/captureConnection.ts +214 -0
  30. package/src/testing/BrowserbaseContract.ts +170 -0
  31. package/src/testing/TestBrowserbase.ts +509 -0
  32. package/src/testing/index.ts +7 -0
  33. package/dist/Account.d.mts +0 -32
  34. package/dist/Account.mjs +0 -36
  35. package/dist/Account.mjs.map +0 -1
  36. package/dist/Acquisition-BOABu_qJ.mjs +0 -244
  37. package/dist/Acquisition-BOABu_qJ.mjs.map +0 -1
  38. package/dist/Agents-CPaTOH_g.d.mts +0 -156
  39. package/dist/Agents.d.mts +0 -3
  40. package/dist/Agents.mjs +0 -292
  41. package/dist/Agents.mjs.map +0 -1
  42. package/dist/Allocation.d.mts +0 -97
  43. package/dist/Allocation.mjs +0 -27
  44. package/dist/Allocation.mjs.map +0 -1
  45. package/dist/Authorization-Ll5f_XNM.mjs +0 -12
  46. package/dist/Authorization-Ll5f_XNM.mjs.map +0 -1
  47. package/dist/Browser-ByrWJ0ss.mjs +0 -274
  48. package/dist/Browser-ByrWJ0ss.mjs.map +0 -1
  49. package/dist/Browser.d.mts +0 -83
  50. package/dist/Browser.mjs +0 -3
  51. package/dist/BrowserBinding.d.mts +0 -13
  52. package/dist/BrowserBinding.mjs +0 -31
  53. package/dist/BrowserBinding.mjs.map +0 -1
  54. package/dist/Certificates-D4NQmyeA.d.mts +0 -34
  55. package/dist/Certificates.d.mts +0 -3
  56. package/dist/Certificates.mjs +0 -85
  57. package/dist/Certificates.mjs.map +0 -1
  58. package/dist/Cleanup-DMTDBir8.d.mts +0 -23
  59. package/dist/Cleanup.d.mts +0 -3
  60. package/dist/Cleanup.mjs +0 -43
  61. package/dist/Cleanup.mjs.map +0 -1
  62. package/dist/Client-BEC4Q8ZS.mjs +0 -564
  63. package/dist/Client-BEC4Q8ZS.mjs.map +0 -1
  64. package/dist/Client-B_f6bBLT.d.mts +0 -52
  65. package/dist/Client.d.mts +0 -3
  66. package/dist/Client.mjs +0 -2
  67. package/dist/Connection-sxyxtwlk.mjs +0 -56
  68. package/dist/Connection-sxyxtwlk.mjs.map +0 -1
  69. package/dist/ContextCoordination.d.mts +0 -29
  70. package/dist/ContextCoordination.mjs +0 -94
  71. package/dist/ContextCoordination.mjs.map +0 -1
  72. package/dist/ContextWriter-CiEma24z.mjs +0 -204
  73. package/dist/ContextWriter-CiEma24z.mjs.map +0 -1
  74. package/dist/Contexts-DqdL7cyX.d.mts +0 -31
  75. package/dist/Contexts.d.mts +0 -3
  76. package/dist/Contexts.mjs +0 -97
  77. package/dist/Contexts.mjs.map +0 -1
  78. package/dist/Deadline-CrViaogr.mjs +0 -13
  79. package/dist/Deadline-CrViaogr.mjs.map +0 -1
  80. package/dist/Downloads-CX52GOFJ.d.mts +0 -43
  81. package/dist/Downloads.d.mts +0 -3
  82. package/dist/Downloads.mjs +0 -137
  83. package/dist/Downloads.mjs.map +0 -1
  84. package/dist/Errors.d.mts +0 -100
  85. package/dist/Errors.mjs +0 -194
  86. package/dist/Errors.mjs.map +0 -1
  87. package/dist/Extensions-BTUn9zhK.mjs +0 -231
  88. package/dist/Extensions-BTUn9zhK.mjs.map +0 -1
  89. package/dist/Extensions-DBXuVM1f.d.mts +0 -43
  90. package/dist/Extensions.d.mts +0 -3
  91. package/dist/Extensions.mjs +0 -2
  92. package/dist/Functions-CsKMMUuZ.d.mts +0 -226
  93. package/dist/Functions.d.mts +0 -3
  94. package/dist/Functions.mjs +0 -318
  95. package/dist/Functions.mjs.map +0 -1
  96. package/dist/Issued-DejqoMYL.mjs +0 -15
  97. package/dist/Issued-DejqoMYL.mjs.map +0 -1
  98. package/dist/Launch-cAdE2rrZ.mjs +0 -115
  99. package/dist/Launch-cAdE2rrZ.mjs.map +0 -1
  100. package/dist/Launch.d.mts +0 -127
  101. package/dist/Launch.mjs +0 -97
  102. package/dist/Launch.mjs.map +0 -1
  103. package/dist/PageFetch-CjAM_0DS.d.mts +0 -40
  104. package/dist/PageFetch.d.mts +0 -3
  105. package/dist/PageFetch.mjs +0 -59
  106. package/dist/PageFetch.mjs.map +0 -1
  107. package/dist/Projects-tm5bTDH0.d.mts +0 -38
  108. package/dist/Projects.d.mts +0 -3
  109. package/dist/Projects.mjs +0 -65
  110. package/dist/Projects.mjs.map +0 -1
  111. package/dist/Recordings-B9k5aODB.d.mts +0 -27
  112. package/dist/Recordings.d.mts +0 -3
  113. package/dist/Recordings.mjs +0 -144
  114. package/dist/Recordings.mjs.map +0 -1
  115. package/dist/References-DOH3Wu44.d.mts +0 -34
  116. package/dist/References.d.mts +0 -3
  117. package/dist/References.mjs +0 -33
  118. package/dist/References.mjs.map +0 -1
  119. package/dist/Replays-mV93WGtx.d.mts +0 -27
  120. package/dist/Replays.d.mts +0 -3
  121. package/dist/Replays.mjs +0 -107
  122. package/dist/Replays.mjs.map +0 -1
  123. package/dist/Resource-J7Kkk5mu.mjs +0 -54
  124. package/dist/Resource-J7Kkk5mu.mjs.map +0 -1
  125. package/dist/Search-B64e7g-h.d.mts +0 -37
  126. package/dist/Search.d.mts +0 -3
  127. package/dist/Search.mjs +0 -46
  128. package/dist/Search.mjs.map +0 -1
  129. package/dist/SessionData-5xYZDshJ.d.mts +0 -38
  130. package/dist/SessionData.d.mts +0 -3
  131. package/dist/SessionData.mjs +0 -48
  132. package/dist/SessionData.mjs.map +0 -1
  133. package/dist/Sessions-D2H5m6rF.mjs +0 -260
  134. package/dist/Sessions-D2H5m6rF.mjs.map +0 -1
  135. package/dist/Sessions-oJEUmZth.d.mts +0 -69
  136. package/dist/Sessions.d.mts +0 -4
  137. package/dist/Sessions.mjs +0 -3
  138. package/dist/Testing.d.mts +0 -119
  139. package/dist/Testing.mjs +0 -206
  140. package/dist/Testing.mjs.map +0 -1
  141. package/dist/TransferPolicy-DQ06i7SZ.mjs +0 -25
  142. package/dist/TransferPolicy-DQ06i7SZ.mjs.map +0 -1
  143. package/dist/Transfers-GVqzrDWl.d.mts +0 -89
  144. package/dist/Transfers.d.mts +0 -3
  145. package/dist/Transfers.mjs +0 -85
  146. package/dist/Transfers.mjs.map +0 -1
  147. package/dist/Uploads-C2_bACgv.d.mts +0 -28
  148. package/dist/Uploads.d.mts +0 -3
  149. package/dist/Uploads.mjs +0 -105
  150. package/dist/Uploads.mjs.map +0 -1
  151. package/dist/Webhooks-BoeRAxzG.d.mts +0 -59
  152. package/dist/Webhooks.d.mts +0 -3
  153. package/dist/Webhooks.mjs +0 -134
  154. package/dist/Webhooks.mjs.map +0 -1
  155. package/dist/WriterFacts-BBJRDZYY.d.mts +0 -54
@@ -1,59 +0,0 @@
1
- import { PlatformError } from "./Errors.mjs";
2
- import { t as BrowserbaseClient } from "./Client-B_f6bBLT.mjs";
3
- import { Context, Effect, Layer, Redacted, Schema } from "effect";
4
- //#region src/Webhooks.d.ts
5
- /** Provider event names. Browserbase currently emits Functions events only. */
6
- 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"]>;
7
- type WebhookEventType = typeof WebhookEventType.Type;
8
- declare const WebhookSettings: Schema.Struct<{
9
- readonly endpoint: Schema.NonEmptyString;
10
- 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"]>>;
11
- }>;
12
- type WebhookSettings = typeof WebhookSettings.Type;
13
- declare const WebhookUpdate: Schema.Struct<{
14
- readonly endpoint: Schema.optionalKey<Schema.NonEmptyString>;
15
- 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"]>>>;
16
- }>;
17
- type WebhookUpdate = typeof WebhookUpdate.Type;
18
- declare const WebhookMetadata_base: Schema.Class<WebhookMetadata, Schema.Struct<{
19
- readonly webhookId: Schema.NonEmptyString;
20
- readonly projectId: Schema.NonEmptyString;
21
- readonly endpoint: Schema.String;
22
- readonly eventTypes: Schema.$Array<Schema.String>;
23
- readonly createdAt: Schema.String;
24
- readonly updatedAt: Schema.String;
25
- }>, {}>;
26
- declare class WebhookMetadata extends WebhookMetadata_base {}
27
- /** A signing secret is returned once, redacted so it cannot be logged by accident. */
28
- interface WebhookRegistration {
29
- readonly webhook: WebhookMetadata;
30
- readonly secret: Redacted.Redacted<string>;
31
- }
32
- interface WebhookPage {
33
- readonly webhooks: ReadonlyArray<WebhookMetadata>;
34
- readonly nextCursor: string | undefined;
35
- }
36
- declare const WebhookListQuery: Schema.Struct<{
37
- readonly cursor: Schema.optionalKey<Schema.NonEmptyString>;
38
- readonly limit: Schema.optionalKey<Schema.Int>;
39
- }>;
40
- type WebhookListQuery = typeof WebhookListQuery.Type;
41
- declare const BrowserbaseWebhooks_base: Context.ServiceClass<BrowserbaseWebhooks, "effect-browserbase/Webhooks", {
42
- readonly create: (settings: WebhookSettings) => Effect.Effect<WebhookRegistration, PlatformError>;
43
- readonly list: (query?: WebhookListQuery) => Effect.Effect<WebhookPage, PlatformError>;
44
- readonly retrieve: (webhookId: string) => Effect.Effect<WebhookMetadata, PlatformError>;
45
- readonly update: (webhookId: string, update: WebhookUpdate) => Effect.Effect<WebhookMetadata, PlatformError>;
46
- readonly delete: (webhookId: string) => Effect.Effect<void, PlatformError>;
47
- /** Issues a new secret; the old one keeps working unless `revokeImmediately`. */
48
- readonly rotateSecret: (webhookId: string, options?: {
49
- readonly revokeImmediately?: boolean;
50
- }) => Effect.Effect<Redacted.Redacted<string>, PlatformError>;
51
- }>;
52
- /** Webhook administration for the Client's project. Mutations are never retried. */
53
- declare class BrowserbaseWebhooks extends BrowserbaseWebhooks_base {
54
- static readonly layer: Layer.Layer<BrowserbaseWebhooks, never, BrowserbaseClient>;
55
- }
56
- //#endregion
57
- export { WebhookPage as a, WebhookUpdate as c, WebhookMetadata as i, WebhookEventType as n, WebhookRegistration as o, WebhookListQuery as r, WebhookSettings as s, BrowserbaseWebhooks as t };
58
- export {};
59
- //# sourceMappingURL=Webhooks-BoeRAxzG.d.mts.map
@@ -1,3 +0,0 @@
1
- import { a as WebhookPage, c as WebhookUpdate, i as WebhookMetadata, n as WebhookEventType, o as WebhookRegistration, r as WebhookListQuery, s as WebhookSettings, t as BrowserbaseWebhooks } from "./Webhooks-BoeRAxzG.mjs";
2
- export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookPage, WebhookRegistration, WebhookSettings, WebhookUpdate };
3
- export {};
package/dist/Webhooks.mjs DELETED
@@ -1,134 +0,0 @@
1
- import { Identifier } from "./References.mjs";
2
- import { PlatformError } from "./Errors.mjs";
3
- import { r as span, t as BrowserbaseClient } from "./Client-BEC4Q8ZS.mjs";
4
- import { t as resource } from "./Resource-J7Kkk5mu.mjs";
5
- import { Context, Effect, Layer, Redacted, Schema } from "effect";
6
- //#region src/Webhooks.ts
7
- const Timestamp = Schema.String.check(Schema.isMaxLength(64));
8
- /** Provider event names. Browserbase currently emits Functions events only. */
9
- const WebhookEventType = Schema.Literals([
10
- "functions.builds.running",
11
- "functions.builds.completed",
12
- "functions.builds.failed",
13
- "functions.invocations.pending",
14
- "functions.invocations.running",
15
- "functions.invocations.completed",
16
- "functions.invocations.failed"
17
- ]);
18
- const Endpoint = Schema.NonEmptyString.check(Schema.isMaxLength(2048), Schema.makeFilter((value) => {
19
- try {
20
- const url = new URL(value);
21
- return url.protocol === "https:" && !url.username && !url.password;
22
- } catch {
23
- return false;
24
- }
25
- }));
26
- const EventTypes = Schema.Array(WebhookEventType).check(Schema.isMinLength(1), Schema.isMaxLength(7), Schema.isUnique());
27
- const WebhookSettings = Schema.Struct({
28
- endpoint: Endpoint,
29
- eventTypes: EventTypes
30
- });
31
- const WebhookUpdate = Schema.Struct({
32
- endpoint: Schema.optionalKey(Endpoint),
33
- eventTypes: Schema.optionalKey(EventTypes)
34
- });
35
- var WebhookMetadata = class extends Schema.Class("BrowserbaseWebhookMetadata")({
36
- webhookId: Identifier,
37
- projectId: Identifier,
38
- endpoint: Schema.String.check(Schema.isMaxLength(2048)),
39
- eventTypes: Schema.Array(Schema.String.check(Schema.isMaxLength(128))).check(Schema.isMaxLength(64)),
40
- createdAt: Timestamp,
41
- updatedAt: Timestamp
42
- }) {};
43
- const ProviderWebhook = Schema.Struct({
44
- id: Identifier,
45
- projectId: Identifier,
46
- endpoint: WebhookMetadata.fields.endpoint,
47
- eventTypes: WebhookMetadata.fields.eventTypes,
48
- createdAt: Timestamp,
49
- updatedAt: Timestamp
50
- });
51
- const Secret = Schema.NonEmptyString.check(Schema.isMaxLength(1024));
52
- const Page = Schema.Struct({
53
- data: Schema.Array(ProviderWebhook).check(Schema.isMaxLength(100)),
54
- nextCursor: Schema.optionalKey(Schema.NullOr(Schema.String.check(Schema.isMaxLength(4096))))
55
- });
56
- const WebhookListQuery = Schema.Struct({
57
- cursor: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(4096))),
58
- limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
59
- minimum: 1,
60
- maximum: 100
61
- })))
62
- });
63
- /** Webhook administration for the Client's project. Mutations are never retried. */
64
- var BrowserbaseWebhooks = class BrowserbaseWebhooks extends Context.Service()("effect-browserbase/Webhooks") {
65
- static layer = Layer.effect(BrowserbaseWebhooks, Effect.gen(function* () {
66
- const client = yield* BrowserbaseClient;
67
- const api = resource(client, (failure) => PlatformError.make({
68
- ...failure,
69
- service: "webhooks"
70
- }));
71
- const decode = (operation, mutation, expected) => Effect.fnUntraced(function* (value) {
72
- if (value.projectId !== client.projectId || expected !== void 0 && value.id !== expected) return yield* api.malformed(operation, mutation);
73
- const { id, ...rest } = value;
74
- return WebhookMetadata.make({
75
- webhookId: id,
76
- ...rest
77
- });
78
- });
79
- const path = (id) => `/v1/webhooks/${api.segment(id)}`;
80
- const create = Effect.fnUntraced(function* (settings) {
81
- const value = yield* api.input(WebhookSettings, settings, "webhook-create");
82
- const { secret, ...webhook } = yield* api.request("POST", "/v1/webhooks", Schema.Struct({
83
- ...ProviderWebhook.fields,
84
- secret: Secret
85
- }), "webhook-create", value);
86
- return {
87
- webhook: yield* decode("webhook-create", true)(webhook),
88
- secret: Redacted.make(secret)
89
- };
90
- }, span("BrowserbaseWebhooks.create"));
91
- const list = Effect.fnUntraced(function* (query = {}) {
92
- const value = yield* api.input(WebhookListQuery, query, "webhook-list");
93
- const page = yield* api.request("GET", `/v1/webhooks${api.query(value)}`, Page, "webhook-list");
94
- return {
95
- webhooks: yield* Effect.forEach(page.data, decode("webhook-list", false)),
96
- nextCursor: page.nextCursor ?? void 0
97
- };
98
- }, span("BrowserbaseWebhooks.list"));
99
- const retrieve = Effect.fnUntraced(function* (webhookId) {
100
- const id = yield* api.input(Identifier, webhookId, "webhook-retrieve");
101
- const value = yield* api.request("GET", path(id), ProviderWebhook, "webhook-retrieve");
102
- return yield* decode("webhook-retrieve", false, id)(value);
103
- }, span("BrowserbaseWebhooks.retrieve"));
104
- const update = Effect.fnUntraced(function* (webhookId, changes) {
105
- const id = yield* api.input(Identifier, webhookId, "webhook-update");
106
- const value = yield* api.input(WebhookUpdate, changes, "webhook-update");
107
- if (value.endpoint === void 0 && value.eventTypes === void 0) return yield* api.configuration("webhook-update");
108
- const updated = yield* api.request("PATCH", path(id), ProviderWebhook, "webhook-update", value);
109
- return yield* decode("webhook-update", true, id)(updated);
110
- }, span("BrowserbaseWebhooks.update"));
111
- const remove = Effect.fnUntraced(function* (webhookId) {
112
- const id = yield* api.input(Identifier, webhookId, "webhook-delete");
113
- yield* api.remove(path(id), "webhook-delete");
114
- }, span("BrowserbaseWebhooks.delete"));
115
- const rotateSecret = Effect.fnUntraced(function* (webhookId, options = {}) {
116
- const id = yield* api.input(Identifier, webhookId, "webhook-rotate-secret");
117
- const value = yield* api.input(Schema.Struct({ revokeImmediately: Schema.optionalKey(Schema.Boolean) }), options, "webhook-rotate-secret");
118
- const rotated = yield* api.request("POST", `${path(id)}/secret`, Schema.Struct({ secret: Secret }), "webhook-rotate-secret", value);
119
- return Redacted.make(rotated.secret);
120
- }, span("BrowserbaseWebhooks.rotateSecret"));
121
- return BrowserbaseWebhooks.of({
122
- create,
123
- list,
124
- retrieve,
125
- update,
126
- delete: remove,
127
- rotateSecret
128
- });
129
- }));
130
- };
131
- //#endregion
132
- export { BrowserbaseWebhooks, WebhookEventType, WebhookListQuery, WebhookMetadata, WebhookSettings, WebhookUpdate };
133
-
134
- //# sourceMappingURL=Webhooks.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Webhooks.mjs","names":["Trace.span"],"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 * as Trace from \"./internal/Trace.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.fnUntraced(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 }, Trace.span(\"BrowserbaseWebhooks.create\"));\n\n const list = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseWebhooks.list\"));\n\n const retrieve = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseWebhooks.retrieve\"));\n\n const update = Effect.fnUntraced(function* (webhookId: string, changes: WebhookUpdate) {\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 }, Trace.span(\"BrowserbaseWebhooks.update\"));\n\n const remove = Effect.fnUntraced(function* (webhookId: string) {\n const id = yield* api.input(Identifier, webhookId, \"webhook-delete\");\n\n yield* api.remove(path(id), \"webhook-delete\");\n }, Trace.span(\"BrowserbaseWebhooks.delete\"));\n\n const rotateSecret = Effect.fnUntraced(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 }, Trace.span(\"BrowserbaseWebhooks.rotateSecret\"));\n\n return BrowserbaseWebhooks.of({\n create,\n list,\n retrieve,\n update,\n delete: remove,\n rotateSecret,\n });\n }),\n );\n}\n"],"mappings":";;;;;;AAQA,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,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O,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,GAAGA,KAAW,kCAAkC,CAAC;EAEjD,OAAO,oBAAoB,GAAG;GAC5B;GACA;GACA;GACA;GACA,QAAQ;GACR;EACF,CAAC;CACH,CAAC,CACH;AACF"}
@@ -1,54 +0,0 @@
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
- import { Effect, Schema } from "effect";
4
- //#region src/internal/session/WriterFacts.d.ts
5
- /**
6
- * The writer vocabulary both the public coordination entry point and the permit
7
- * implementation need. Keeping it here leaves one direction of dependency:
8
- * `ContextCoordination` and `ContextWriter` both read this module, never each other.
9
- */
10
- declare const PersistenceEvidence: Schema.Union<readonly [Schema.TaggedStruct<"NotRequested", {}>, Schema.TaggedStruct<"Unconfirmed", {
11
- readonly reason: Schema.Literals<readonly ["writer-active", "writer-unknown", "flush-unacknowledged"]>;
12
- }>, Schema.TaggedStruct<"Observed", {
13
- readonly method: Schema.Literal<"consumer-readback">;
14
- readonly observedAtMillis: Schema.Finite;
15
- }>]>;
16
- type PersistenceEvidence = typeof PersistenceEvidence.Type;
17
- declare const WriterAttemptFacts_base: Schema.Class<WriterAttemptFacts, Schema.Struct<{
18
- readonly attempt: typeof AllocationAttempt;
19
- readonly session: Schema.optionalKey<typeof SessionReference>;
20
- readonly state: Schema.Literals<readonly ["admitted", "rejected", "unknown", "terminal"]>;
21
- readonly cleanup: Schema.optionalKey<typeof CleanupResult>;
22
- }>, {}>;
23
- declare class WriterAttemptFacts extends WriterAttemptFacts_base {}
24
- declare const WriterSettlementFacts_base: Schema.Class<WriterSettlementFacts, Schema.Struct<{
25
- readonly reference: typeof ContextReference;
26
- readonly attempts: Schema.$Array<typeof WriterAttemptFacts>;
27
- readonly persistence: Schema.Union<readonly [Schema.TaggedStruct<"NotRequested", {}>, Schema.TaggedStruct<"Unconfirmed", {
28
- readonly reason: Schema.Literals<readonly ["writer-active", "writer-unknown", "flush-unacknowledged"]>;
29
- }>, Schema.TaggedStruct<"Observed", {
30
- readonly method: Schema.Literal<"consumer-readback">;
31
- readonly observedAtMillis: Schema.Finite;
32
- }>]>;
33
- readonly disposition: Schema.Literals<readonly ["release", "quarantine"]>;
34
- }>, {}>;
35
- declare class WriterSettlementFacts extends WriterSettlementFacts_base {}
36
- interface WriterLease<E, R> {
37
- readonly settle: (facts: WriterSettlementFacts) => Effect.Effect<void, E, R>;
38
- }
39
- interface ContextWriterBackend<E, R> {
40
- readonly acquire: (reference: ContextReference) => Effect.Effect<WriterLease<E, R>, E, R>;
41
- }
42
- interface ContextWriterPermit {
43
- readonly _tag: "ContextWriterPermit";
44
- readonly reference: ContextReference;
45
- }
46
- interface WriterOptions<A, VerifyE, VerifyR> {
47
- /** Bounded consumer-controlled readback, not a provider-wide flush acknowledgement. */
48
- readonly verify?: (value: A) => Effect.Effect<void, VerifyE, VerifyR>;
49
- readonly settlementTimeoutMillis?: number;
50
- }
51
- //#endregion
52
- export { WriterLease as a, WriterAttemptFacts as i, ContextWriterPermit as n, WriterOptions as o, PersistenceEvidence as r, WriterSettlementFacts as s, ContextWriterBackend as t };
53
- export {};
54
- //# sourceMappingURL=WriterFacts-BBJRDZYY.d.mts.map