@xemahq/app-platform-operator-api-client 0.3.13

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/LICENSE ADDED
@@ -0,0 +1,175 @@
1
+ Xema Business Source License 1.1
2
+
3
+ License text copyright (c) 2020 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+
6
+ -----------------------------------------------------------------------------
7
+
8
+ Parameters
9
+
10
+ Licensor: Neuralchowder Inc.
11
+
12
+ Licensed Work: Xema. The Licensed Work is (c) 2026 Neuralchowder Inc.
13
+
14
+ The Licensed Work includes, without limitation, Xema Core, Xema Runtime,
15
+ Xema Kernel, Xema control plane, Xema application runtime, Xema biome
16
+ runtime, Xema biome registry, Xema store services, Xema orchestration
17
+ services, Xema agents, Xema skills, Xema memory services, Xema APIs, Xema
18
+ user interfaces, Xema command-line tools, Xema deployment artifacts, Xema
19
+ templates, Xema specifications, Xema schemas, Xema manifests, Xema
20
+ documentation, Xema examples, and all source code, object code, binaries,
21
+ packages, modules, configuration files, manifests, schemas, examples,
22
+ templates, documentation, and derivative works included in or distributed
23
+ as part of the Xema software project.
24
+
25
+ The Licensed Work does not include any third-party software, libraries,
26
+ dependencies, packages, assets, or components that are distributed with the
27
+ Licensed Work but are governed by their own separate license terms. Such
28
+ third-party materials remain subject to their respective licenses.
29
+
30
+ A specific file, package, component, or directory may state that it is
31
+ governed by a different license. In that case, that specific file, package,
32
+ component, or directory is governed by the license expressly stated therein.
33
+
34
+ Additional Use Grant:
35
+
36
+ You may make production use of the Licensed Work, provided that your use
37
+ does not include offering, providing, making available, distributing,
38
+ hosting, managing, embedding, reselling, white-labeling, sublicensing,
39
+ commercializing, or otherwise making the Licensed Work, or any modified
40
+ version or derivative work of the Licensed Work, available to Third Parties
41
+ as part of a Competitive Offering.
42
+
43
+ The following definitions and clarifications form part of, and govern
44
+ the interpretation of, the Additional Use Grant set out above.
45
+
46
+ 1. "Production Use" means any use of the Licensed Work other than for
47
+ development, testing, evaluation, demonstration, experimentation,
48
+ benchmarking, or other non-production purposes.
49
+
50
+ 2. "Affiliate" means any entity that, directly or indirectly,
51
+ controls, is controlled by, or is under common control with you,
52
+ where "control" means ownership of more than fifty percent (50%) of
53
+ the voting interests of the entity, or the power to direct its
54
+ management.
55
+
56
+ 3. "Third Party" means any natural person or legal entity other than
57
+ you and your Affiliates.
58
+
59
+ 4. "Competitive Offering" means any product or service, made available
60
+ to one or more Third Parties for a fee or other consideration
61
+ (including without limitation on a paid, subscription,
62
+ advertising-supported, hosted, or managed-service basis), that is
63
+ offered or marketed as, or that competes with, a software platform,
64
+ runtime, orchestration system, agent or automation system,
65
+ extension or distribution marketplace, or other software system
66
+ that provides, in substantial part, the same or substantially
67
+ similar capabilities as those provided by the Licensed Work. A
68
+ product or service is a Competitive Offering whether the Licensed
69
+ Work is provided in whole or in part, alone or bundled with other
70
+ software, and whether modified or unmodified.
71
+
72
+ 5. Providing, hosting, or managing the Licensed Work for a Third Party,
73
+ or otherwise making the Licensed Work available to a Third Party as
74
+ a hosted or managed service such that the Third Party obtains the
75
+ principal value or functionality of the Licensed Work, is a
76
+ Competitive Offering and is not permitted by the Additional Use
77
+ Grant.
78
+
79
+ 6. Subject to the foregoing, the Additional Use Grant permits you to
80
+ make Production Use of the Licensed Work for your own internal
81
+ business purposes and to build, operate, and provide your own
82
+ products and services to Third Parties, provided that the Licensed
83
+ Work itself (whether modified or unmodified) is not the product or
84
+ service, and is not a Competitive Offering, made available to those
85
+ Third Parties.
86
+
87
+ 7. You may modify the Licensed Work and create derivative works for
88
+ any purpose permitted by this License. Any Production Use of such
89
+ modified or derivative works remains subject to the same
90
+ restrictions as the Licensed Work, including the prohibition on
91
+ Competitive Offerings.
92
+
93
+ 8. Use of the Licensed Work by your own employees, contractors, and
94
+ agents, acting on your behalf and for your benefit, is not by
95
+ itself making the Licensed Work available to a Third Party.
96
+
97
+ 9. Embedding or distributing the Licensed Work as a component of your
98
+ own product or service is permitted only where the Licensed Work
99
+ does not constitute the principal value of that product or service
100
+ and the product or service is not a Competitive Offering.
101
+
102
+ 10. Nothing in this Additional Use Grant grants any right to use any
103
+ name, trademark, service mark, or logo of the Licensor or its
104
+ Affiliates, except as reasonably required for customary
105
+ attribution.
106
+
107
+ 11. The rights stated in this Additional Use Grant are the maximum
108
+ rights granted for Production Use prior to the Change Date. Any
109
+ Production Use not expressly permitted requires a separate
110
+ commercial license from the Licensor.
111
+
112
+ 12. If any provision of this Additional Use Grant is held invalid or
113
+ unenforceable, that provision shall be limited or eliminated to
114
+ the minimum extent necessary so that the remainder of this
115
+ Additional Use Grant, and of this License, remains in full force
116
+ and effect. The Licensor reserves all rights not expressly granted
117
+ by this License.
118
+
119
+
120
+ Change Date: Four years from the date the specific version of the Licensed
121
+ Work is first publicly released by Licensor.
122
+
123
+ Change License: Mozilla Public License, Version 2.0
124
+
125
+ For information about alternative licensing arrangements, commercial
126
+ licensing, enterprise licensing, OEM licensing, appliance licensing, managed
127
+ service licensing, cloud provider licensing, or other commercial use of the
128
+ Licensed Work, please contact: licensing@neuralchowder.com
129
+
130
+ -----------------------------------------------------------------------------
131
+
132
+ Notice
133
+
134
+ Business Source License 1.1
135
+
136
+ Terms
137
+
138
+ The Licensor hereby grants you the right to copy, modify, create derivative
139
+ works, redistribute, and make non-production use of the Licensed Work. The
140
+ Licensor may make an Additional Use Grant, above, permitting limited
141
+ production use.
142
+
143
+ Effective on the Change Date, or the fourth anniversary of the first publicly
144
+ available distribution of a specific version of the Licensed Work under this
145
+ License, whichever comes first, the Licensor hereby grants you rights under
146
+ the terms of the Change License, and the rights granted in the paragraph above
147
+ terminate.
148
+
149
+ If your use of the Licensed Work does not comply with the requirements
150
+ currently in effect as described in this License, you must purchase a
151
+ commercial license from the Licensor, its affiliated entities, or authorized
152
+ resellers, or you must refrain from using the Licensed Work.
153
+
154
+ All copies of the original and modified Licensed Work, and derivative works of
155
+ the Licensed Work, are subject to this License. This License applies separately
156
+ for each version of the Licensed Work and the Change Date may vary for each
157
+ version of the Licensed Work released by Licensor.
158
+
159
+ You must conspicuously display this License on each original or modified copy
160
+ of the Licensed Work. If you receive the Licensed Work in original or modified
161
+ form from a third party, the terms and conditions set forth in this License
162
+ apply to your use of that work.
163
+
164
+ Any use of the Licensed Work in violation of this License will automatically
165
+ terminate your rights under this License for the current and all other
166
+ versions of the Licensed Work.
167
+
168
+ This License does not grant you any right in any trademark or logo of Licensor
169
+ or its affiliates, provided that you may use a trademark or logo of Licensor
170
+ as expressly required by this License.
171
+
172
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
173
+ "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS
174
+ OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS
175
+ FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ <!-- Generated by @xemahq/api-client-generator. Do not edit by hand. -->
2
+ <p align="center">
3
+ <svg width="680" height="120" viewBox="0 0 680 120" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="@xemahq/app-platform-operator-api-client">
4
+ <rect width="680" height="120" rx="14" fill="#0B1020"/>
5
+ <g transform="translate(28,34)">
6
+ <path d="M26 0 L52 15 L52 45 L26 60 L0 45 L0 15 Z" fill="#14B8A6" opacity="0.18"/>
7
+ <path d="M26 12 L41 21 L41 39 L26 48 L11 39 L11 21 Z" fill="#14B8A6"/>
8
+ </g>
9
+ <text x="92" y="52" font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="22" fill="#F8FAFC" font-weight="700">@xemahq/app-platform-operator-api-client</text>
10
+ <text x="92" y="80" font-family="ui-sans-serif,system-ui,sans-serif" font-size="15" fill="#94A3B8">Typed, generated operator HTTP client for the App Runtime API.</text>
11
+ <text x="652" y="105" text-anchor="end" font-family="ui-sans-serif,system-ui,sans-serif" font-size="12" fill="#475569">xema.dev</text>
12
+ </svg>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://xema.dev">Website</a> &middot;
17
+ <a href="https://www.npmjs.com/package/@xemahq/app-platform-operator-api-client">npm</a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ <img alt="npm" src="https://img.shields.io/npm/v/%40xemahq%2Fapp-platform-operator-api-client?color=2563eb&label=npm">
22
+ <img alt="license" src="https://img.shields.io/npm/l/%40xemahq%2Fapp-platform-operator-api-client?color=10b981">
23
+ <img alt="types" src="https://img.shields.io/npm/types/%40xemahq%2Fapp-platform-operator-api-client?color=3178c6">
24
+ </p>
25
+
26
+ # @xemahq/app-platform-operator-api-client
27
+
28
+ > Typed, generated operator HTTP client for the App Runtime API.
29
+
30
+ ## Overview
31
+
32
+ Auto-generated TypeScript client for the **App Runtime API**. It exports typed
33
+ request functions and response models that mirror the service's OpenAPI surface,
34
+ so callers get end-to-end type safety without hand-writing HTTP calls. This
35
+ package is produced by `@xemahq/api-client-generator` and regenerated whenever
36
+ the service's API changes — do not edit it by hand.
37
+
38
+ ## When to use it
39
+
40
+ - Use it from any TypeScript service or app that calls the App Runtime API over HTTP.
41
+ - You get compile-time types for every endpoint and payload; regenerate to pick
42
+ up API changes rather than editing the client.
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pnpm add @xemahq/app-platform-operator-api-client
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ```ts
53
+ // Every endpoint function and response model is exported from the package root.
54
+ import * as client from '@xemahq/app-platform-operator-api-client';
55
+ ```
56
+
57
+ Call the typed endpoint functions; request and response shapes are fully typed
58
+ from the service's OpenAPI spec.
59
+
60
+ ## License
61
+
62
+ Proprietary — &copy; Xema. All rights reserved. — [xema.dev](https://xema.dev)
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Configurable fetch wrapper for Orval-generated clients.
3
+ *
4
+ * GENERATED by `@xemahq/api-client-generator` — do not edit. Every client in
5
+ * the fleet ships this file byte-for-byte; a local edit is erased by the next
6
+ * `pnpm refresh` and, until then, makes this one client speak to the platform
7
+ * differently from all of its siblings. Change the template instead:
8
+ * `api-client-generator/src/lib/custom-fetch-template.ts`.
9
+ *
10
+ * Consumers must call `configureClient()` before using any endpoint function.
11
+ * The baseUrl is prepended to the relative paths generated by Orval.
12
+ *
13
+ * By default this transport issues exactly ONE request and adds no delay of its
14
+ * own, so a slow call is a slow server. Retrying is opt-in, and opting in
15
+ * requires supplying an observer — see `maxRetries` / `onRetry` below.
16
+ */
17
+ /** What {@link ClientConfig.onRetry} is told before each re-attempt. */
18
+ export interface RetryNotice {
19
+ /** 1-based index of the re-attempt about to be made. */
20
+ attempt: number;
21
+ /** The configured budget this re-attempt is spending from. */
22
+ maxRetries: number;
23
+ /** The response status that made the previous attempt retryable. */
24
+ status: number;
25
+ /** Delay before the re-attempt, in ms — from `Retry-After` when the server sent one. */
26
+ waitMs: number;
27
+ /** Whether {@link waitMs} came from the server's `Retry-After` header. */
28
+ retryAfterHonoured: boolean;
29
+ /** Absolute URL being re-requested. */
30
+ url: string;
31
+ /** HTTP method being re-requested. */
32
+ method: string;
33
+ }
34
+ export interface ClientConfig {
35
+ /**
36
+ * Static base URL (e.g. 'http://localhost:3140') — no trailing slash.
37
+ * Mutually exclusive with `baseUrlResolver`; exactly one MUST be set.
38
+ */
39
+ baseUrl?: string;
40
+ /**
41
+ * Per-request base-URL resolver. When set, the peer URL is resolved from
42
+ * the service registry on EVERY request (boot-order-safe). Wired by
43
+ * `configureOrvalClientResolved` from `@xemahq/platform-common`.
44
+ */
45
+ baseUrlResolver?: () => string | Promise<string>;
46
+ /** Optional async callback to get an auth token. Auto-sets Authorization header on every request. */
47
+ getAuthToken?: () => Promise<string>;
48
+ /** Optional callback returning headers to inject on every request. Per-call headers take precedence. */
49
+ getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
50
+ /**
51
+ * Optional resolver for the CORRELATION ID of the request being made — the
52
+ * handle that ties one causal chain together across every service hop.
53
+ *
54
+ * WHY IT IS A CALLBACK AND NOT A VALUE. `ClientConfig` is process-global
55
+ * (`configureClient` is called once at wiring time), and a correlation id is
56
+ * per-request. This is invoked INSIDE the request, so a server can point it
57
+ * at whatever carries its ambient request context and get the CURRENT id
58
+ * rather than the one that happened to be live at boot.
59
+ *
60
+ * WHY THE TRANSPORT DOES NOT MINT ONE. Returning `undefined` sends no header,
61
+ * and the receiving service's `RequestContextMiddleware` mints its own — a
62
+ * new trace, which is honest. A transport that minted per call would produce
63
+ * a FRESH id on every hop while looking like propagation, which is strictly
64
+ * worse than none: every row would carry a correlation id and no two rows
65
+ * that belong together would share one. That is the exact defect this exists
66
+ * to fix, so the transport must not reproduce it one layer down.
67
+ *
68
+ * A caller-supplied `X-Correlation-Id` header always wins, and so does one
69
+ * from `getHeaders`.
70
+ */
71
+ getCorrelationId?: () => string | undefined | Promise<string | undefined>;
72
+ /**
73
+ * Optional callback invoked on a 401 before ONE re-attempt. Supplying it is
74
+ * what opts this client into that re-attempt; without it a 401 comes back to
75
+ * the caller as a `ClientError` like any other 4xx.
76
+ */
77
+ onUnauthorized?: () => Promise<void>;
78
+ /**
79
+ * Re-attempts for a retryable status. **Defaults to 0 — no retry.**
80
+ *
81
+ * Setting it above 0 REQUIRES `onRetry`; `configureClient` throws otherwise.
82
+ * See the block above `customFetch` for why the budget is opt-in and why an
83
+ * observer is mandatory rather than advisory.
84
+ */
85
+ maxRetries?: number;
86
+ /**
87
+ * Called immediately before every re-attempt, with the reason and the delay.
88
+ *
89
+ * Mandatory whenever `maxRetries` is above 0. It is the difference between a
90
+ * retry and a hidden degradation path: without it a caller cannot tell a slow
91
+ * server from this transport sleeping between attempts.
92
+ */
93
+ onRetry?: (notice: RetryNotice) => void;
94
+ }
95
+ export declare class ClientError extends Error {
96
+ readonly status: number;
97
+ readonly url: string;
98
+ readonly body: unknown;
99
+ constructor(status: number, url: string, body: unknown);
100
+ }
101
+ export declare function configureClient(config: ClientConfig): void;
102
+ export declare function getClientConfig(): ClientConfig;
103
+ export declare const customFetch: <T>(url: string, options: RequestInit) => Promise<T>;
104
+ export default customFetch;
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ /**
3
+ * Configurable fetch wrapper for Orval-generated clients.
4
+ *
5
+ * GENERATED by `@xemahq/api-client-generator` — do not edit. Every client in
6
+ * the fleet ships this file byte-for-byte; a local edit is erased by the next
7
+ * `pnpm refresh` and, until then, makes this one client speak to the platform
8
+ * differently from all of its siblings. Change the template instead:
9
+ * `api-client-generator/src/lib/custom-fetch-template.ts`.
10
+ *
11
+ * Consumers must call `configureClient()` before using any endpoint function.
12
+ * The baseUrl is prepended to the relative paths generated by Orval.
13
+ *
14
+ * By default this transport issues exactly ONE request and adds no delay of its
15
+ * own, so a slow call is a slow server. Retrying is opt-in, and opting in
16
+ * requires supplying an observer — see `maxRetries` / `onRetry` below.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.customFetch = exports.ClientError = void 0;
20
+ exports.configureClient = configureClient;
21
+ exports.getClientConfig = getClientConfig;
22
+ class ClientError extends Error {
23
+ status;
24
+ url;
25
+ body;
26
+ constructor(status, url, body) {
27
+ super(`HTTP ${status} from ${url}`);
28
+ this.status = status;
29
+ this.url = url;
30
+ this.body = body;
31
+ this.name = 'ClientError';
32
+ }
33
+ }
34
+ exports.ClientError = ClientError;
35
+ let clientConfig = null;
36
+ function configureClient(config) {
37
+ // Fail at WIRING time, not on the request that happens to be retried. A
38
+ // client configured to retry without an observer is the exact defect this
39
+ // transport was rebuilt to remove, so it must not be constructible.
40
+ if ((config.maxRetries ?? 0) > 0 && !config.onRetry) {
41
+ throw new Error('configureClient: maxRetries above 0 requires onRetry. A retry nothing ' +
42
+ 'reports is indistinguishable from a slow server, which is how two ' +
43
+ 'silent re-attempts were read as a 3,312ms call.');
44
+ }
45
+ clientConfig = config;
46
+ }
47
+ function getClientConfig() {
48
+ if (!clientConfig) {
49
+ throw new Error('Client not configured. Call configureClient({ baseUrl }) before using endpoint functions.');
50
+ }
51
+ return clientConfig;
52
+ }
53
+ /*
54
+ * RETRYING IS OPT-IN, OBSERVED, AND NARROW. Do not widen any of the three.
55
+ *
56
+ * This transport used to retry up to `maxRetries` (defaulting to THREE) over
57
+ * 429/502/503/504 AND over any thrown network error, backing off from 1000ms,
58
+ * with no log line anywhere. Three properties were wrong:
59
+ *
60
+ * 1. The DEFAULT was on. ~99% of the fleet's client configurations never
61
+ * mention `maxRetries`, so two re-attempts could add ~3s to any call with
62
+ * nothing to distinguish that from a slow peer. Every caller that DID set
63
+ * it set it LOWER — canopy's control plane to 1, "so a hard outage
64
+ * surfaces inside the turn's latency budget rather than after three
65
+ * backoffs"; two llm-registry callers to 1; a test to 0. Nobody ever
66
+ * raised it. A default three separate call sites work around is not a
67
+ * default, and `configureOrvalClientResolved` cannot express the field at
68
+ * all, so most callers could not have opted out if they had wanted to.
69
+ * 2. It retried AMBIGUOUS failures. 502 and 504 mean a gateway did not get a
70
+ * timely answer from upstream — the upstream may well have APPLIED the
71
+ * request. So did a thrown network error mid-flight. Re-sending a POST in
72
+ * either case is a duplicate write, and no amount of logging makes that
73
+ * safe. Only 429 and 503 state positively that the request was NOT
74
+ * processed, so only those are retried; everything else surfaces at once.
75
+ * 3. Nothing reported it. Now `onRetry` is mandatory whenever the budget is
76
+ * above 0, enforced in `configureClient`.
77
+ *
78
+ * Also note `baseUrlResolver` is awaited ONCE, above the loop: a re-attempt
79
+ * returns to the same resolved instance. In a registry-resolved fleet the cure
80
+ * for an unhealthy peer is re-resolution, which lives above this file — which
81
+ * is a further reason not to lean on retrying here.
82
+ *
83
+ * Retry policy a caller genuinely wants belongs in `@xemahq/managed-fetch`,
84
+ * which has backoff, a circuit breaker, a token bucket and health reporting,
85
+ * and reports what it did.
86
+ *
87
+ * Enforced fleet-wide by `check-client-transport-envelope`, which compares
88
+ * every client's transport to this template.
89
+ */
90
+ /** The only statuses that state the request was NOT processed. See above. */
91
+ const RETRYABLE_STATUSES = [429, 503];
92
+ /**
93
+ * The platform's correlation header, spelled once.
94
+ *
95
+ * Value-identical to what `RequestContextMiddleware` reads in
96
+ * `@xemahq/platform-common`. It is a literal here rather than an import
97
+ * because this file has ZERO imports on purpose: it ships byte-identical into
98
+ * browser-target clients as well as server-target ones, and a dependency on a
99
+ * NestJS-peer package would follow it into every one of them.
100
+ */
101
+ const CORRELATION_ID_HEADER = 'X-Correlation-Id';
102
+ /** Backoff floor, doubling per attempt up to {@link MAX_BACKOFF_MS}. */
103
+ const BASE_BACKOFF_MS = 1000;
104
+ /** Ceiling on a single backoff, however many attempts have elapsed. */
105
+ const MAX_BACKOFF_MS = 30_000;
106
+ async function buildHeaders(config, callerHeaders) {
107
+ const headers = new Headers(callerHeaders);
108
+ // Global headers from config (caller-provided headers take precedence)
109
+ if (config.getHeaders) {
110
+ const globalHeaders = await Promise.resolve(config.getHeaders());
111
+ for (const [key, value] of Object.entries(globalHeaders)) {
112
+ if (!headers.has(key)) {
113
+ headers.set(key, value);
114
+ }
115
+ }
116
+ }
117
+ // Correlation id (caller and global headers still take precedence).
118
+ //
119
+ // Without this, every server-to-server hop through a generated client started
120
+ // a NEW trace: the id is read-or-minted per hop by the receiving service's
121
+ // RequestContextMiddleware, and nothing carried it outbound — so an audit
122
+ // journal could record a whole causal chain and offer no way to join it back
123
+ // together.
124
+ //
125
+ // Absent resolver, or a resolver that answers `undefined`: NO header. The
126
+ // receiver mints and a new trace begins, which is the truthful outcome when
127
+ // there is nothing to continue.
128
+ if (config.getCorrelationId && !headers.has(CORRELATION_ID_HEADER)) {
129
+ const correlationId = await Promise.resolve(config.getCorrelationId());
130
+ if (correlationId) {
131
+ headers.set(CORRELATION_ID_HEADER, correlationId);
132
+ }
133
+ }
134
+ // Auth token (caller or global headers take precedence)
135
+ if (config.getAuthToken && !headers.has('Authorization')) {
136
+ const token = await config.getAuthToken();
137
+ headers.set('Authorization', `Bearer ${token}`);
138
+ }
139
+ return headers;
140
+ }
141
+ /*
142
+ * THE TRANSPORT RETURNS THE BODY UNCHANGED. Do not reintroduce an unwrap here.
143
+ *
144
+ * Xema services wrap every 2xx payload in a { data: T } envelope via the global
145
+ * ResponseEnvelopeInterceptor (platform-common), and the generator emits types
146
+ * that describe THAT ENVELOPE — every endpoint returns Promise<XDataEnvelope>
147
+ * or Promise<XPaginatedEnvelope>, never a bare inner T. Consumers read the data
148
+ * property themselves.
149
+ *
150
+ * This template used to peel data, justified by a comment claiming generated
151
+ * types describe the inner T. That stopped being true when the generator moved
152
+ * to envelope-typed returns, and the comment outlived the fact — so the peel
153
+ * then contradicted every type in every package it seeded. Four clients shipped
154
+ * that way (resource-governance x3, workload-runtime-api): declared
155
+ * *DataEnvelope, returned the already-peeled inner object, so .data read
156
+ * undefined at runtime on every non-paginated endpoint. Paginated calls hid it,
157
+ * because the old peel deliberately preserved an envelope carrying pagination.
158
+ *
159
+ * Four MORE shipped it in repositories the gate could not see — license-api and
160
+ * license-internal-api in xema-operator, plus their host-web mirrors — because
161
+ * the gate ran in xema-base only. That is why it now runs in every repository
162
+ * that ships a client, and why this file is generator-owned rather than seeded.
163
+ */
164
+ const customFetch = async (url, options) => {
165
+ const config = getClientConfig();
166
+ const base = config.baseUrlResolver
167
+ ? await config.baseUrlResolver()
168
+ : config.baseUrl;
169
+ if (base === undefined) {
170
+ throw new Error('Client not configured: set baseUrl or baseUrlResolver via configureClient().');
171
+ }
172
+ const fullUrl = `${base}${url}`;
173
+ const maxRetries = config.maxRetries ?? 0;
174
+ // A caller that supplied its own Authorization header owns that credential.
175
+ // `buildHeaders` lets it win, so refreshing the CLIENT-WIDE token and
176
+ // re-sending would replay the identical failing request with the identical
177
+ // credential: one wasted round trip, plus a global refresh nobody asked for.
178
+ const callerSuppliedAuth = new Headers(options.headers).has('Authorization');
179
+ const headers = await buildHeaders(config, options.headers);
180
+ const requestInit = { ...options, headers };
181
+ let delay = BASE_BACKOFF_MS;
182
+ for (let attempt = 0;; attempt++) {
183
+ const response = await fetch(fullUrl, requestInit);
184
+ if (response.status === 401 &&
185
+ config.onUnauthorized &&
186
+ !callerSuppliedAuth &&
187
+ attempt === 0) {
188
+ await config.onUnauthorized();
189
+ const refreshedHeaders = await buildHeaders(config, options.headers);
190
+ const retryResponse = await fetch(fullUrl, {
191
+ ...options,
192
+ headers: refreshedHeaders,
193
+ });
194
+ const retryBody = await parseBody(retryResponse);
195
+ if (retryResponse.status >= 400) {
196
+ throw new ClientError(retryResponse.status, fullUrl, retryBody);
197
+ }
198
+ return retryBody;
199
+ }
200
+ if (!RETRYABLE_STATUSES.includes(response.status) ||
201
+ attempt >= maxRetries) {
202
+ const body = await parseBody(response);
203
+ if (response.status >= 400) {
204
+ throw new ClientError(response.status, fullUrl, body);
205
+ }
206
+ return body;
207
+ }
208
+ const retryAfter = parseRetryAfter(response.headers.get('Retry-After'));
209
+ const waitMs = retryAfter ?? addJitter(delay);
210
+ // Non-null: `configureClient` refuses a budget above 0 without an observer,
211
+ // and this line is unreachable unless `maxRetries` is above 0.
212
+ config.onRetry({
213
+ attempt: attempt + 1,
214
+ maxRetries,
215
+ status: response.status,
216
+ waitMs,
217
+ retryAfterHonoured: retryAfter !== undefined,
218
+ url: fullUrl,
219
+ method: options.method ?? 'GET',
220
+ });
221
+ await sleep(waitMs);
222
+ delay = Math.min(delay * 2, MAX_BACKOFF_MS);
223
+ }
224
+ };
225
+ exports.customFetch = customFetch;
226
+ async function parseBody(response) {
227
+ const contentType = response.headers.get('content-type');
228
+ if (contentType?.includes('application/json')) {
229
+ return response.json();
230
+ }
231
+ if (response.status === 204) {
232
+ return undefined;
233
+ }
234
+ return response.text();
235
+ }
236
+ function parseRetryAfter(value) {
237
+ if (!value)
238
+ return undefined;
239
+ const seconds = Number(value);
240
+ if (!isNaN(seconds) && seconds >= 0)
241
+ return seconds * 1000;
242
+ const date = new Date(value);
243
+ if (!isNaN(date.getTime()))
244
+ return Math.max(0, date.getTime() - Date.now());
245
+ return undefined;
246
+ }
247
+ function addJitter(delay) {
248
+ return delay + (Math.random() * 2 - 1) * delay * 0.25;
249
+ }
250
+ function sleep(ms) {
251
+ return new Promise((resolve) => setTimeout(resolve, ms));
252
+ }
253
+ exports.default = exports.customFetch;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ import type { RotateSigningKeyResultDtoDataEnvelope, SigningKeyRingStateDtoDataEnvelope } from '../../models';
7
+ export declare const getOperatorSigningKeysControllerStateUrl: () => string;
8
+ /**
9
+ * @summary Inspect the delegated-session signing key ring: the active kid and every retired key still being published.
10
+ */
11
+ export declare const operatorSigningKeysControllerState: (options?: RequestInit) => Promise<SigningKeyRingStateDtoDataEnvelope>;
12
+ export declare const getOperatorSigningKeysControllerRotateUrl: () => string;
13
+ /**
14
+ * @summary Rotate the delegated-session signing key. The outgoing key keeps being published for its overlap window, so tokens already in flight continue to verify.
15
+ */
16
+ export declare const operatorSigningKeysControllerRotate: (options?: RequestInit) => Promise<RotateSigningKeyResultDtoDataEnvelope>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.operatorSigningKeysControllerRotate = exports.getOperatorSigningKeysControllerRotateUrl = exports.operatorSigningKeysControllerState = exports.getOperatorSigningKeysControllerStateUrl = void 0;
4
+ const custom_fetch_1 = require("../../custom-fetch");
5
+ const getOperatorSigningKeysControllerStateUrl = () => {
6
+ return `/operator/delegated-session-keys`;
7
+ };
8
+ exports.getOperatorSigningKeysControllerStateUrl = getOperatorSigningKeysControllerStateUrl;
9
+ /**
10
+ * @summary Inspect the delegated-session signing key ring: the active kid and every retired key still being published.
11
+ */
12
+ const operatorSigningKeysControllerState = async (options) => {
13
+ return (0, custom_fetch_1.customFetch)((0, exports.getOperatorSigningKeysControllerStateUrl)(), {
14
+ ...options,
15
+ method: 'GET'
16
+ });
17
+ };
18
+ exports.operatorSigningKeysControllerState = operatorSigningKeysControllerState;
19
+ const getOperatorSigningKeysControllerRotateUrl = () => {
20
+ return `/operator/delegated-session-keys/rotate`;
21
+ };
22
+ exports.getOperatorSigningKeysControllerRotateUrl = getOperatorSigningKeysControllerRotateUrl;
23
+ /**
24
+ * @summary Rotate the delegated-session signing key. The outgoing key keeps being published for its overlap window, so tokens already in flight continue to verify.
25
+ */
26
+ const operatorSigningKeysControllerRotate = async (options) => {
27
+ return (0, custom_fetch_1.customFetch)((0, exports.getOperatorSigningKeysControllerRotateUrl)(), {
28
+ ...options,
29
+ method: 'POST'
30
+ });
31
+ };
32
+ exports.operatorSigningKeysControllerRotate = operatorSigningKeysControllerRotate;
@@ -0,0 +1,3 @@
1
+ export { configureClient, getClientConfig, ClientError, customFetch, type ClientConfig, type RetryNotice } from './custom-fetch';
2
+ export * from './models';
3
+ export * from './endpoints/delegated-session-keys/delegated-session-keys';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.customFetch = exports.ClientError = exports.getClientConfig = exports.configureClient = void 0;
18
+ // Auto-generated by @xemahq/api-client-generator — do not edit manually.
19
+ var custom_fetch_1 = require("./custom-fetch");
20
+ Object.defineProperty(exports, "configureClient", { enumerable: true, get: function () { return custom_fetch_1.configureClient; } });
21
+ Object.defineProperty(exports, "getClientConfig", { enumerable: true, get: function () { return custom_fetch_1.getClientConfig; } });
22
+ Object.defineProperty(exports, "ClientError", { enumerable: true, get: function () { return custom_fetch_1.ClientError; } });
23
+ Object.defineProperty(exports, "customFetch", { enumerable: true, get: function () { return custom_fetch_1.customFetch; } });
24
+ __exportStar(require("./models"), exports);
25
+ __exportStar(require("./endpoints/delegated-session-keys/delegated-session-keys"), exports);
@@ -0,0 +1,5 @@
1
+ export * from './publishedSigningKeyDto';
2
+ export * from './rotateSigningKeyResultDto';
3
+ export * from './rotateSigningKeyResultDtoDataEnvelope';
4
+ export * from './signingKeyRingStateDto';
5
+ export * from './signingKeyRingStateDtoDataEnvelope';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Auto-generated by tooling/codegen/regenerate-models-barrel.js — do not edit manually.
18
+ __exportStar(require("./publishedSigningKeyDto"), exports);
19
+ __exportStar(require("./rotateSigningKeyResultDto"), exports);
20
+ __exportStar(require("./rotateSigningKeyResultDtoDataEnvelope"), exports);
21
+ __exportStar(require("./signingKeyRingStateDto"), exports);
22
+ __exportStar(require("./signingKeyRingStateDtoDataEnvelope"), exports);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ export interface PublishedSigningKeyDto {
7
+ /** RFC 7638 JWK thumbprint of the retired key. */
8
+ kid: string;
9
+ /** Instant after which the key stops being published (ISO-8601). It is later than the expiry of the longest-lived token the key ever signed. */
10
+ publishUntil: string;
11
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by @xemahq/api-client-generator — do not edit manually.
4
+ * App Runtime API
5
+ * OpenAPI spec version: 0.1.2
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ export interface RotateSigningKeyResultDto {
7
+ /** `kid` that is active after this call. */
8
+ activeKid: string;
9
+ /** False when this replica lost the compare-and-set and adopted a ring another replica had already rotated — `activeKid` is then the winner’s key. The rotation still happened; it was simply not performed here. */
10
+ rotated: boolean;
11
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Generated by @xemahq/api-client-generator — do not edit manually.
4
+ * App Runtime API
5
+ * OpenAPI spec version: 0.1.2
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ import type { RotateSigningKeyResultDto } from './rotateSigningKeyResultDto.js';
7
+ export interface RotateSigningKeyResultDtoDataEnvelope {
8
+ data: RotateSigningKeyResultDto;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ import type { PublishedSigningKeyDto } from './publishedSigningKeyDto.js';
7
+ export interface SigningKeyRingStateDto {
8
+ /** `kid` of the key new tokens are signed with. */
9
+ activeKid: string;
10
+ /** JWS algorithm of the active key. Always asymmetric — there is no symmetric option. */
11
+ algorithm: string;
12
+ /** Keys that no longer sign but are still published, so tokens minted before the rotation keep verifying until they expire. */
13
+ retired: PublishedSigningKeyDto[];
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Generated by @xemahq/api-client-generator — do not edit manually.
3
+ * App Runtime API
4
+ * OpenAPI spec version: 0.1.2
5
+ */
6
+ import type { SigningKeyRingStateDto } from './signingKeyRingStateDto.js';
7
+ export interface SigningKeyRingStateDtoDataEnvelope {
8
+ data: SigningKeyRingStateDto;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@xemahq/app-platform-operator-api-client",
3
+ "version": "0.3.13",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "publishConfig": {
10
+ "access": "public",
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "5.9.3"
15
+ },
16
+ "xema": {
17
+ "kind": "api-client",
18
+ "surface": "operator",
19
+ "service": "app-platform-api",
20
+ "biome": "app-platform",
21
+ "target": "server",
22
+ "generator": "@xemahq/api-client-generator@0.14.1",
23
+ "source": "openapi.operator.json"
24
+ },
25
+ "license": "LicenseRef-Xema-BSL-1.1",
26
+ "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
27
+ "homepage": "https://xema.dev",
28
+ "bugs": "https://github.com/xema-dev/xema-community/issues",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/xema-dev/xema-base.git",
32
+ "directory": "packages/clients/app-platform-operator-api"
33
+ },
34
+ "description": "Generated operator API client for the Xema app-platform-api service.",
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.json"
37
+ }
38
+ }