@sealant/sdk-next 0.40.0-next.784 → 0.40.0-next.786
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/client.js +7 -2
- package/dist/effect/api-client.d.ts +190 -187
- package/dist/effect/api-client.js +9 -5
- package/dist/effect/operations.d.ts +64 -64
- package/dist/effect/operations.js +11 -11
- package/dist/effect/run-harness.js +23 -14
- package/dist/errors.d.ts +32 -2
- package/dist/errors.js +38 -0
- package/dist/facade/forward.d.ts +2 -1
- package/dist/facade/forward.js +24 -11
- package/dist/facade/session.js +15 -2
- package/dist/facade/workspace.js +10 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/config.d.ts +4 -1
- package/dist/internal/config.js +3 -0
- package/dist/internal/map-error.d.ts +0 -6
- package/dist/internal/map-error.js +15 -1
- package/dist/scope-instances.d.ts +1 -1
- package/dist/scope-instances.js +9 -1
- package/dist/types.d.ts +7 -0
- package/package.json +3 -3
|
@@ -12,15 +12,19 @@ import { ControlPlaneAPI } from "@sealant/api-contracts";
|
|
|
12
12
|
import { Context, Effect, Layer } from "effect";
|
|
13
13
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
14
14
|
import { HttpApiClient } from "effect/http-api";
|
|
15
|
+
import { resolveRequestPriority } from "../internal/config.js";
|
|
16
|
+
/** A per-operation priority; providing it never changes concurrent requests. */
|
|
17
|
+
export const CurrentRequestPriority = Context.Reference("@sealant/sdk/CurrentRequestPriority", { defaultValue: () => undefined });
|
|
15
18
|
/** Builds the contract-derived client. Requires an `HttpClient` in context (provided by the layer). */
|
|
16
19
|
const buildControlPlaneClient = (config) => {
|
|
17
|
-
const { apiKey } = config;
|
|
18
|
-
if (apiKey === undefined) {
|
|
19
|
-
return HttpApiClient.make(ControlPlaneAPI, { baseUrl: config.baseUrl });
|
|
20
|
-
}
|
|
21
20
|
return HttpApiClient.make(ControlPlaneAPI, {
|
|
22
21
|
baseUrl: config.baseUrl,
|
|
23
|
-
transformClient: (client) => HttpClient.
|
|
22
|
+
transformClient: (client) => HttpClient.mapRequestEffect(client, (request) => Effect.map(CurrentRequestPriority, (priority) => {
|
|
23
|
+
const prioritized = HttpClientRequest.setHeader(request, "x-sealant-request-priority", resolveRequestPriority(config.requestPriority, priority));
|
|
24
|
+
return config.apiKey === undefined
|
|
25
|
+
? prioritized
|
|
26
|
+
: HttpClientRequest.bearerToken(prioritized, config.apiKey);
|
|
27
|
+
})),
|
|
24
28
|
});
|
|
25
29
|
};
|
|
26
30
|
export class SealantApiClient extends Context.Service()("@sealant/sdk/SealantApiClient") {
|