@brickkit/core 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/client.d.ts +3 -1
- package/dist/chunks/client.js +32 -18
- package/dist/chunks/client.js.map +1 -1
- package/dist/chunks/server.d.ts +18 -3
- package/dist/chunks/server.js +197 -39
- package/dist/chunks/server.js.map +1 -1
- package/dist/chunks/types.d.ts +49 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.d.ts +27 -4
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/workflow.d.ts +1 -1
- package/package.json +1 -1
package/dist/chunks/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Q as BrickSocketConnectOptions,
|
|
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";
|
|
2
2
|
import { Static, TSchema } from "@sinclair/typebox";
|
|
3
3
|
/**
|
|
4
4
|
* The URL segment for a declared name: `orderBilling` becomes `order-billing`,
|
|
@@ -45,6 +45,8 @@ declare const GLOBAL_SYMBOL: {
|
|
|
45
45
|
readonly logsRecord: "brickkit.logs.record";
|
|
46
46
|
/** The set of running event hubs, so the CLI can stop them all. */
|
|
47
47
|
readonly eventsStarted: "brickkit.events.started";
|
|
48
|
+
/** The key the dashboard signs `/app/*` identities with. */
|
|
49
|
+
readonly dashboardKey: "brickkit.dashboard.key";
|
|
48
50
|
};
|
|
49
51
|
/**
|
|
50
52
|
* Eden/tRPC-style typed HTTP client inferred from Brick-TS application contracts.
|
package/dist/chunks/client.js
CHANGED
|
@@ -93,7 +93,9 @@ const GLOBAL_SYMBOL = {
|
|
|
93
93
|
/** Core's function that records a log line on the running span. */
|
|
94
94
|
logsRecord: "brickkit.logs.record",
|
|
95
95
|
/** The set of running event hubs, so the CLI can stop them all. */
|
|
96
|
-
eventsStarted: "brickkit.events.started"
|
|
96
|
+
eventsStarted: "brickkit.events.started",
|
|
97
|
+
/** The key the dashboard signs `/app/*` identities with. */
|
|
98
|
+
dashboardKey: "brickkit.dashboard.key"
|
|
97
99
|
};
|
|
98
100
|
// src/protocol.ts
|
|
99
101
|
/** The codes every action, listener and socket handler can raise, with their status and default message. */
|
|
@@ -404,20 +406,20 @@ const kinds = /* @__PURE__ */ new Set([
|
|
|
404
406
|
"Union"
|
|
405
407
|
]);
|
|
406
408
|
/** Keep validators browser-safe and reject schemas whose behavior cannot cross JSON. */
|
|
407
|
-
function serializeSocketSchema(schema) {
|
|
408
|
-
const visit = (value) => {
|
|
409
|
-
if (Array.isArray(value)) return value.map(visit);
|
|
409
|
+
function serializeSocketSchema(schema, path = "schema") {
|
|
410
|
+
const visit = (value, at) => {
|
|
411
|
+
if (Array.isArray(value)) return value.map((child, i) => visit(child, `${at}[${i}]`));
|
|
410
412
|
if (!value || typeof value !== "object") return value;
|
|
411
413
|
if (TransformKind in value) throw new Error("Socket schemas cannot contain transforms");
|
|
412
|
-
const entries = Object.entries(value).map(([key, child]) => [key, visit(child)]);
|
|
414
|
+
const entries = Object.entries(value).map(([key, child]) => [key, visit(child, `${at}.${key}`)]);
|
|
413
415
|
if (Kind in value) {
|
|
414
|
-
if (typeof value[Kind] !== "string" || !kinds.has(value[Kind])) throw new Error(
|
|
416
|
+
if (typeof value[Kind] !== "string" || !kinds.has(value[Kind])) throw new Error(`Socket schemas must describe JSON values (got kind "${String(value[Kind])}" at ${at}); use t.Json() for any JSON value`);
|
|
415
417
|
if ("format" in value || "__brick_kind" in value) throw new Error("Socket schemas cannot contain formats or reserved __brick_kind annotations");
|
|
416
418
|
entries.push(["__brick_kind", value[Kind]]);
|
|
417
419
|
}
|
|
418
420
|
return Object.fromEntries(entries);
|
|
419
421
|
};
|
|
420
|
-
return visit(schema);
|
|
422
|
+
return visit(schema, path);
|
|
421
423
|
}
|
|
422
424
|
function restoreSocketSchema(value) {
|
|
423
425
|
const visit = (node) => {
|
|
@@ -864,21 +866,28 @@ function normalizePrefix(prefix) {
|
|
|
864
866
|
const withLeading = prefix.startsWith("/") ? prefix : `/${prefix}`;
|
|
865
867
|
return withLeading.length > 1 ? withLeading.replace(/\/+$/, "") : withLeading;
|
|
866
868
|
}
|
|
869
|
+
function appendFields(target, input) {
|
|
870
|
+
for (const [key, value] of Object.entries(input)) for (const item of Array.isArray(value) ? value : [value]) {
|
|
871
|
+
if (item === void 0 || item === null) continue;
|
|
872
|
+
if (item instanceof Blob) target.append(key, item);
|
|
873
|
+
else target.append(key, typeof item === "object" ? JSON.stringify(item) : String(item));
|
|
874
|
+
}
|
|
875
|
+
}
|
|
867
876
|
function toQueryString(input) {
|
|
868
877
|
if (input == null || typeof input !== "object") return "";
|
|
869
878
|
const params = new URLSearchParams();
|
|
870
|
-
|
|
871
|
-
if (value === void 0 || value === null) continue;
|
|
872
|
-
if (Array.isArray(value)) for (const item of value) {
|
|
873
|
-
if (item === void 0 || item === null) continue;
|
|
874
|
-
params.append(key, typeof item === "object" ? JSON.stringify(item) : String(item));
|
|
875
|
-
}
|
|
876
|
-
else if (typeof value === "object") params.append(key, JSON.stringify(value));
|
|
877
|
-
else params.append(key, String(value));
|
|
878
|
-
}
|
|
879
|
+
appendFields(params, input);
|
|
879
880
|
const qs = params.toString();
|
|
880
881
|
return qs ? `?${qs}` : "";
|
|
881
882
|
}
|
|
883
|
+
function formDataIfFiles(body) {
|
|
884
|
+
if (body == null || typeof body !== "object") return void 0;
|
|
885
|
+
const isFile = (value) => value instanceof Blob || Array.isArray(value) && value.some((item) => item instanceof Blob);
|
|
886
|
+
if (!Object.values(body).some(isFile)) return void 0;
|
|
887
|
+
const form = new FormData();
|
|
888
|
+
appendFields(form, body);
|
|
889
|
+
return form;
|
|
890
|
+
}
|
|
882
891
|
function isActionValue(value) {
|
|
883
892
|
return typeof value === "function" && !!value.config && typeof value.config.execute === "function";
|
|
884
893
|
}
|
|
@@ -941,8 +950,13 @@ async function dispatch(resolved, path, target, input, callOptions) {
|
|
|
941
950
|
};
|
|
942
951
|
let payload;
|
|
943
952
|
if (hasBody) {
|
|
944
|
-
|
|
945
|
-
|
|
953
|
+
payload = formDataIfFiles(body);
|
|
954
|
+
if (payload) {
|
|
955
|
+
for (const key of Object.keys(headers)) if (key.toLowerCase() === "content-type") delete headers[key];
|
|
956
|
+
} else {
|
|
957
|
+
headers["content-type"] = "application/json";
|
|
958
|
+
payload = JSON.stringify(body ?? null);
|
|
959
|
+
}
|
|
946
960
|
}
|
|
947
961
|
const timeoutMs = callOptions?.timeoutMs ?? resolved.timeoutMs;
|
|
948
962
|
let timeoutSignal;
|