Compare commits
2 Commits
6d31cd4717
...
978450888c
| Author | SHA1 | Date | |
|---|---|---|---|
| 978450888c | |||
| 300592d1b5 |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 1,
|
||||
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git",
|
||||
"sourceCommit": "d3e9e4b0f6d083d578dc7ce36e0f169023603116",
|
||||
"sourceCommit": "e0d8da526c065f66ece8a8230a31be4168ccddcc",
|
||||
"sourcePath": "quixos-instance/packages/camino-package-runtime",
|
||||
"exportName": "camino-package-runtime",
|
||||
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git"
|
||||
|
||||
+53
-1
@@ -6,6 +6,7 @@ import {
|
||||
createClient,
|
||||
type Client,
|
||||
type HandlerContext,
|
||||
type Interceptor,
|
||||
} from "@connectrpc/connect";
|
||||
import {
|
||||
connectNodeAdapter,
|
||||
@@ -569,6 +570,46 @@ export const protoFieldsToJs = (
|
||||
]),
|
||||
);
|
||||
|
||||
const normalizeForCanonicalJson = (value: unknown): unknown => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(normalizeForCanonicalJson);
|
||||
}
|
||||
if (!value || typeof value !== "object") {
|
||||
return value;
|
||||
}
|
||||
return Object.fromEntries(
|
||||
Object.entries(value)
|
||||
.filter(([, entryValue]) => entryValue !== undefined)
|
||||
.sort(([left], [right]) => left.localeCompare(right))
|
||||
.map(([key, entryValue]) => [key, normalizeForCanonicalJson(entryValue)]),
|
||||
);
|
||||
};
|
||||
|
||||
export const canonicalFieldParams = (
|
||||
params: Record<string, Value> | undefined,
|
||||
) =>
|
||||
JSON.stringify(
|
||||
normalizeForCanonicalJson(
|
||||
Object.fromEntries(
|
||||
Object.entries(params ?? {}).map(([key, value]) => [
|
||||
key,
|
||||
protoValueToJs(value),
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
export const fieldOperationKey = (params: {
|
||||
objectId: string;
|
||||
fieldName: string;
|
||||
input?: Record<string, Value>;
|
||||
}) =>
|
||||
[
|
||||
params.objectId,
|
||||
params.fieldName,
|
||||
Buffer.from(canonicalFieldParams(params.input)).toString("base64url"),
|
||||
].join(":");
|
||||
|
||||
const derivedDependencyToProto = (dependency: DerivedDependency) =>
|
||||
create(DerivedDependencySchema, {
|
||||
kind: dependency.kind,
|
||||
@@ -679,9 +720,20 @@ export const serveQuixosPackageRuntime = <
|
||||
const host = process.env.QUIXOS_RUNTIME_HOST ?? "127.0.0.1";
|
||||
const port = Number(process.env.QUIXOS_RUNTIME_PORT ?? "0");
|
||||
const caminoUrl = process.env.CAMINO_URL ?? "http://127.0.0.1:7310";
|
||||
const runtimeToken = process.env.CAMINO_RUNTIME_AUTH_TOKEN ?? "";
|
||||
const runtimeTokenInterceptor: Interceptor = (next) => async (request) => {
|
||||
if (runtimeToken) {
|
||||
request.header.set("x-camino-runtime-token", runtimeToken);
|
||||
}
|
||||
return await next(request);
|
||||
};
|
||||
const camino = createClient(
|
||||
CaminoService,
|
||||
createConnectTransport({ baseUrl: caminoUrl, httpVersion: "1.1" }),
|
||||
createConnectTransport({
|
||||
baseUrl: caminoUrl,
|
||||
httpVersion: "1.1",
|
||||
interceptors: runtimeToken ? [runtimeTokenInterceptor] : [],
|
||||
}),
|
||||
);
|
||||
const trackingCamino = createDependencyTrackingCaminoClient(camino);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user