@brickkit/core 0.15.0 → 0.16.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.
@@ -1,4 +1,4 @@
1
- import { Q as BrickSocketConnectOptions, X as BrickSocketClient, Y as BrickClientSocket, c as ActionExecutionError, jr as HttpMethod, kt as StandardErrorCode, s as ActionErrorDefinition, t as Action } from "./types.js";
1
+ import { $ as BrickSocketClient, It as StandardErrorCode, Q as BrickClientSocket, c as ActionExecutionError, ri as HttpMethod, s as ActionErrorDefinition, t as Action, tt as BrickSocketConnectOptions } from "./types.js";
2
2
  import { Static, TSchema } from "@sinclair/typebox";
3
3
  /**
4
4
  * The URL segment for a declared name: `orderBilling` becomes `order-billing`,
@@ -21,6 +21,10 @@ declare const ATTR: {
21
21
  readonly urlPath: "url.path";
22
22
  readonly service: "brick.service";
23
23
  readonly action: "brick.action";
24
+ /** A webhook delivery: the webhook's name, its event id and what became of it. Never the body or the signature. */
25
+ readonly webhook: "brick.webhook";
26
+ readonly webhookEventId: "brick.webhook.event_id";
27
+ readonly webhookOutcome: "brick.webhook.outcome";
24
28
  readonly traceId: "brick.trace_id";
25
29
  readonly errorCode: "brick.error.code";
26
30
  readonly errorMessage: "brick.error.message";
@@ -270,5 +274,4 @@ declare function createBrickClient<TApp extends Record<string, any>>(options: Br
270
274
  contract: TApp;
271
275
  }): BrickClient<TApp>;
272
276
  declare function createBrickClient<TApp extends Record<string, any>>(options: BrickClientOptions): BrickClient<TApp>;
273
- export { GLOBAL_SYMBOL as _, BrickClientOptions as a, BrickTransportError as c, InferActionInput as d, InferActionOutput as f, ATTR as g, isBrickTransportError as h, BrickClientAction as i, InferActionErrorCodes as l, isBrickServerError as m, BrickCallOptions as n, BrickServerError as o, createBrickClient as p, BrickClient as r, BrickServices as s, BrickActionCaller as t, InferActionFailure as u, SPAN as v, kebabCase as y };
274
- //# sourceMappingURL=client.d.ts.map
277
+ export { GLOBAL_SYMBOL as _, BrickClientOptions as a, BrickTransportError as c, InferActionInput as d, InferActionOutput as f, ATTR as g, isBrickTransportError as h, BrickClientAction as i, InferActionErrorCodes as l, isBrickServerError as m, BrickCallOptions as n, BrickServerError as o, createBrickClient as p, BrickClient as r, BrickServices as s, BrickActionCaller as t, InferActionFailure as u, SPAN as v, kebabCase as y };
@@ -1,6 +1,13 @@
1
1
  import { Kind, TransformKind } from "@sinclair/typebox";
2
2
  import { Check } from "@sinclair/typebox/value";
3
3
  // src/types.ts
4
+ function withoutRejectedValue({ path, message, type }) {
5
+ return {
6
+ path,
7
+ message,
8
+ type
9
+ };
10
+ }
4
11
  var ValidationError = class extends Error {
5
12
  code = "VALIDATION_FAILED";
6
13
  status;
@@ -9,7 +16,7 @@ var ValidationError = class extends Error {
9
16
  super(message);
10
17
  this.name = "ValidationError";
11
18
  this.status = status;
12
- this.errors = errors;
19
+ this.errors = errors.map(withoutRejectedValue);
13
20
  }
14
21
  toJSON() {
15
22
  return {
@@ -70,6 +77,10 @@ const ATTR = {
70
77
  urlPath: "url.path",
71
78
  service: "brick.service",
72
79
  action: "brick.action",
80
+ /** A webhook delivery: the webhook's name, its event id and what became of it. Never the body or the signature. */
81
+ webhook: "brick.webhook",
82
+ webhookEventId: "brick.webhook.event_id",
83
+ webhookOutcome: "brick.webhook.outcome",
73
84
  traceId: "brick.trace_id",
74
85
  errorCode: "brick.error.code",
75
86
  errorMessage: "brick.error.message",
@@ -120,6 +131,10 @@ const STANDARD_ERRORS = {
120
131
  status: 409,
121
132
  message: "Conflict"
122
133
  },
134
+ RATE_LIMITED: {
135
+ status: 429,
136
+ message: "Too Many Requests"
137
+ },
123
138
  INTERNAL_SERVER_ERROR: {
124
139
  status: 500,
125
140
  message: "Internal Server Error"
@@ -129,7 +144,7 @@ const STANDARD_ERRORS = {
129
144
  function decodeError(body, status) {
130
145
  if (body === null || typeof body !== "object") return void 0;
131
146
  const record = body;
132
- if (record.name === "ValidationError") return new ValidationError(typeof record.message === "string" ? record.message : "Validation failed", Array.isArray(record.errors) ? record.errors : [], typeof record.status === "number" ? record.status : status);
147
+ if (record.name === "ValidationError") return new ValidationError(typeof record.message === "string" ? record.message : "Validation failed", Array.isArray(record.errors) ? record.errors.filter((item) => item !== null && typeof item === "object") : [], typeof record.status === "number" ? record.status : status);
133
148
  if (typeof record.code !== "string") return void 0;
134
149
  return new ActionExecutionError(record.code, typeof record.message === "string" ? record.message : record.code, typeof record.status === "number" ? record.status : status, record.details ?? void 0);
135
150
  }
@@ -310,6 +325,9 @@ function getPluginActionRoute(action, prefix = DEFAULT_PREFIX) {
310
325
  function getActionRoute(action, prefix = DEFAULT_PREFIX) {
311
326
  return actionRoute(action, action.serviceName ?? "", prefix);
312
327
  }
328
+ function actionMethod(action) {
329
+ return actionMeta(action).route?.method ?? action.config.method ?? "POST";
330
+ }
313
331
  /** `getActionRoute` for an action that may not be registered yet, under `service`. */
314
332
  function actionRoute(action, service, prefix) {
315
333
  const plugin = getPluginActionRoute(action, prefix);
@@ -318,7 +336,7 @@ function actionRoute(action, service, prefix) {
318
336
  method: plugin.method,
319
337
  path: plugin.path
320
338
  };
321
- const method = action.config.method ?? "POST";
339
+ const method = actionMethod(action);
322
340
  const { resourceAction } = actionMeta(action);
323
341
  if (resourceAction) {
324
342
  const base = ownerPath(prefix, service, resourceAction.resource);
@@ -1030,6 +1048,6 @@ function createBrickClient(options) {
1030
1048
  timeoutMs: options.timeoutMs
1031
1049
  }, [], options.contract);
1032
1050
  }
1033
- export { byteLength as A, splitSeq as B, SOCKET_BUFFER_BYTES as C, SOCKET_PROTOCOL as D, SOCKET_MAX_BYTES as E, isSocketRoom as F, DuplicateNameError as G, GLOBAL_SYMBOL as H, isSocketSeq as I, ValidationError as K, replayFrame as L, encodeFrame as M, isControlEvent as N, SOCKET_TOKEN_PROTOCOL as O, isSocketEnvelope as P, replayHeadroom as R, actionMeta as S, SOCKET_CONTROL as T, SPAN as U, ATTR as V, ActionExecutionError as W, pathParamNames as _, isBrickTransportError as a, toOpenApiPath as b, DEFAULT_PREFIX as c, getActionRoute as d, getPluginActionRoute as f, ownerPath as g, joinRoute as h, isBrickServerError as i, compareSocketSeq as j, STANDARD_ERRORS as k, actionOwners as l, isReadLike as m, BrickTransportError as n, BrickSocketError as o, inputSource as p, createBrickClient as r, serializeSocketSchema as s, BrickServerError as t, checkSegments as u, pluginRoutePath as v, SOCKET_CLOSE as w, kebabCase as x, routeKey as y, signSeq as z };
1051
+ export { STANDARD_ERRORS as A, signSeq as B, actionMeta as C, SOCKET_MAX_BYTES as D, SOCKET_CONTROL as E, isSocketEnvelope as F, ActionExecutionError as G, ATTR as H, isSocketRoom as I, DuplicateNameError as K, isSocketSeq as L, compareSocketSeq as M, encodeFrame as N, SOCKET_PROTOCOL as O, isControlEvent as P, replayFrame as R, kebabCase as S, SOCKET_CLOSE as T, GLOBAL_SYMBOL as U, splitSeq as V, SPAN as W, ownerPath as _, isBrickTransportError as a, routeKey as b, DEFAULT_PREFIX as c, checkSegments as d, getActionRoute as f, joinRoute as g, isReadLike as h, isBrickServerError as i, byteLength as j, SOCKET_TOKEN_PROTOCOL as k, actionMethod as l, inputSource as m, BrickTransportError as n, BrickSocketError as o, getPluginActionRoute as p, ValidationError as q, createBrickClient as r, serializeSocketSchema as s, BrickServerError as t, actionOwners as u, pathParamNames as v, SOCKET_BUFFER_BYTES as w, toOpenApiPath as x, pluginRoutePath as y, replayHeadroom as z };
1034
1052
 
1035
1053
  //# sourceMappingURL=client.js.map