@oxyhq/contracts 0.26.0 → 0.28.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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/accountGraph.js +4 -3
- package/dist/cjs/index.js +186 -1
- package/dist/cjs/inference/accountBilling.js +334 -0
- package/dist/cjs/inference/attribution.js +106 -0
- package/dist/cjs/inference/catalogue.js +482 -0
- package/dist/cjs/inference/entitlement.js +217 -0
- package/dist/cjs/inference/errors.js +210 -0
- package/dist/cjs/inference/identifiers.js +197 -0
- package/dist/cjs/inference/money.js +188 -0
- package/dist/cjs/inference/priceVersion.js +110 -0
- package/dist/cjs/inference/providerConnection.js +142 -0
- package/dist/cjs/inference/request.js +288 -0
- package/dist/cjs/inference/routingPolicy.js +213 -0
- package/dist/cjs/inference/streamEvents.js +219 -0
- package/dist/cjs/inference/usage.js +297 -0
- package/dist/cjs/inference/version.js +85 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/accountGraph.js +4 -3
- package/dist/esm/index.js +54 -0
- package/dist/esm/inference/accountBilling.js +331 -0
- package/dist/esm/inference/attribution.js +103 -0
- package/dist/esm/inference/catalogue.js +479 -0
- package/dist/esm/inference/entitlement.js +214 -0
- package/dist/esm/inference/errors.js +207 -0
- package/dist/esm/inference/identifiers.js +194 -0
- package/dist/esm/inference/money.js +185 -0
- package/dist/esm/inference/priceVersion.js +107 -0
- package/dist/esm/inference/providerConnection.js +139 -0
- package/dist/esm/inference/request.js +285 -0
- package/dist/esm/inference/routingPolicy.js +210 -0
- package/dist/esm/inference/streamEvents.js +216 -0
- package/dist/esm/inference/usage.js +294 -0
- package/dist/esm/inference/version.js +82 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/accountGraph.d.ts +6 -5
- package/dist/types/index.d.ts +27 -0
- package/dist/types/inference/accountBilling.d.ts +738 -0
- package/dist/types/inference/attribution.d.ts +176 -0
- package/dist/types/inference/catalogue.d.ts +1612 -0
- package/dist/types/inference/entitlement.d.ts +519 -0
- package/dist/types/inference/errors.d.ts +206 -0
- package/dist/types/inference/identifiers.d.ts +157 -0
- package/dist/types/inference/money.d.ts +185 -0
- package/dist/types/inference/priceVersion.d.ts +182 -0
- package/dist/types/inference/providerConnection.d.ts +297 -0
- package/dist/types/inference/request.d.ts +2364 -0
- package/dist/types/inference/routingPolicy.d.ts +426 -0
- package/dist/types/inference/streamEvents.d.ts +906 -0
- package/dist/types/inference/usage.d.ts +1139 -0
- package/dist/types/inference/version.d.ts +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Price versions — the immutable snapshots customer pricing is quoted and
|
|
3
|
+
* settled against.
|
|
4
|
+
*
|
|
5
|
+
* A price is never edited in place. A change publishes a NEW version that
|
|
6
|
+
* supersedes the old one, and every settled receipt keeps the id of the version
|
|
7
|
+
* it was priced with. That is what makes an invoice reproducible a year later:
|
|
8
|
+
* the receipt does not say "3.00 per million tokens", it says "priced under
|
|
9
|
+
* `pv_2026_08`", and that version still exists, unchanged, with its own
|
|
10
|
+
* effective window.
|
|
11
|
+
*
|
|
12
|
+
* Prices are exact decimal strings (see `money.ts`), never floats, and they are
|
|
13
|
+
* quoted per unit. The amount a customer owes is computed from them and is
|
|
14
|
+
* carried in the same exact form, so no step of the calculation passes through
|
|
15
|
+
* a representation that cannot hold the value.
|
|
16
|
+
*
|
|
17
|
+
* Decided in: docs/adr/0009-usage-reservation-and-settlement.md.
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
/**
|
|
21
|
+
* Lifecycle of a price version.
|
|
22
|
+
*
|
|
23
|
+
* `draft` is quotable in Console previews but may never price a receipt;
|
|
24
|
+
* `active` is what live requests are priced with; `superseded` priced receipts
|
|
25
|
+
* in the past and still resolves for them forever.
|
|
26
|
+
*/
|
|
27
|
+
export declare const priceVersionStatusSchema: z.ZodEnum<["draft", "active", "superseded"]>;
|
|
28
|
+
/**
|
|
29
|
+
* A published set of customer prices for one model reference on one provider.
|
|
30
|
+
*
|
|
31
|
+
* Scoped to a `(modelReference, provider)` pair rather than to a model alone
|
|
32
|
+
* because the same model costs different amounts on different providers, and a
|
|
33
|
+
* receipt has to be reproducible against the route that actually served it.
|
|
34
|
+
*/
|
|
35
|
+
export declare const priceVersionSchema: z.ZodEffects<z.ZodObject<{
|
|
36
|
+
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
37
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
38
|
+
priceVersionId: z.ZodString;
|
|
39
|
+
status: z.ZodEnum<["draft", "active", "superseded"]>;
|
|
40
|
+
modelReference: z.ZodString;
|
|
41
|
+
provider: z.ZodString;
|
|
42
|
+
currency: z.ZodString;
|
|
43
|
+
unitPrices: z.ZodArray<z.ZodObject<{
|
|
44
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
45
|
+
amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
46
|
+
per: z.ZodNumber;
|
|
47
|
+
currency: z.ZodString;
|
|
48
|
+
}, "strict", z.ZodTypeAny, {
|
|
49
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
50
|
+
currency: string;
|
|
51
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
52
|
+
per: number;
|
|
53
|
+
}, {
|
|
54
|
+
amount: string;
|
|
55
|
+
currency: string;
|
|
56
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
57
|
+
per: number;
|
|
58
|
+
}>, "many">;
|
|
59
|
+
effectiveFrom: z.ZodString;
|
|
60
|
+
/** Absent while this version is the current one. */
|
|
61
|
+
effectiveUntil: z.ZodOptional<z.ZodString>;
|
|
62
|
+
/** The version this one replaced, absent for the first version of a route. */
|
|
63
|
+
supersedesPriceVersionId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
createdAt: z.ZodString;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
status: "active" | "superseded" | "draft";
|
|
67
|
+
createdAt: string;
|
|
68
|
+
currency: string;
|
|
69
|
+
provider: string;
|
|
70
|
+
schemaVersion: 1;
|
|
71
|
+
priceVersionId: string;
|
|
72
|
+
modelReference: string;
|
|
73
|
+
unitPrices: {
|
|
74
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
75
|
+
currency: string;
|
|
76
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
77
|
+
per: number;
|
|
78
|
+
}[];
|
|
79
|
+
effectiveFrom: string;
|
|
80
|
+
effectiveUntil?: string | undefined;
|
|
81
|
+
supersedesPriceVersionId?: string | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
status: "active" | "superseded" | "draft";
|
|
84
|
+
createdAt: string;
|
|
85
|
+
currency: string;
|
|
86
|
+
provider: string;
|
|
87
|
+
schemaVersion: 1;
|
|
88
|
+
priceVersionId: string;
|
|
89
|
+
modelReference: string;
|
|
90
|
+
unitPrices: {
|
|
91
|
+
amount: string;
|
|
92
|
+
currency: string;
|
|
93
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
94
|
+
per: number;
|
|
95
|
+
}[];
|
|
96
|
+
effectiveFrom: string;
|
|
97
|
+
effectiveUntil?: string | undefined;
|
|
98
|
+
supersedesPriceVersionId?: string | undefined;
|
|
99
|
+
}>, {
|
|
100
|
+
status: "active" | "superseded" | "draft";
|
|
101
|
+
createdAt: string;
|
|
102
|
+
currency: string;
|
|
103
|
+
provider: string;
|
|
104
|
+
schemaVersion: 1;
|
|
105
|
+
priceVersionId: string;
|
|
106
|
+
modelReference: string;
|
|
107
|
+
unitPrices: {
|
|
108
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
109
|
+
currency: string;
|
|
110
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
111
|
+
per: number;
|
|
112
|
+
}[];
|
|
113
|
+
effectiveFrom: string;
|
|
114
|
+
effectiveUntil?: string | undefined;
|
|
115
|
+
supersedesPriceVersionId?: string | undefined;
|
|
116
|
+
}, {
|
|
117
|
+
status: "active" | "superseded" | "draft";
|
|
118
|
+
createdAt: string;
|
|
119
|
+
currency: string;
|
|
120
|
+
provider: string;
|
|
121
|
+
schemaVersion: 1;
|
|
122
|
+
priceVersionId: string;
|
|
123
|
+
modelReference: string;
|
|
124
|
+
unitPrices: {
|
|
125
|
+
amount: string;
|
|
126
|
+
currency: string;
|
|
127
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
128
|
+
per: number;
|
|
129
|
+
}[];
|
|
130
|
+
effectiveFrom: string;
|
|
131
|
+
effectiveUntil?: string | undefined;
|
|
132
|
+
supersedesPriceVersionId?: string | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
/**
|
|
135
|
+
* The price snapshot a settled receipt keeps.
|
|
136
|
+
*
|
|
137
|
+
* The unit prices are COPIED onto the receipt, not just referenced, so a receipt
|
|
138
|
+
* remains readable even if the price version record is later archived, and so
|
|
139
|
+
* that a mistake in the copy is visible as a disagreement with the version it
|
|
140
|
+
* names rather than silently invisible.
|
|
141
|
+
*/
|
|
142
|
+
export declare const priceSnapshotSchema: z.ZodObject<{
|
|
143
|
+
priceVersionId: z.ZodString;
|
|
144
|
+
currency: z.ZodString;
|
|
145
|
+
unitPrices: z.ZodArray<z.ZodObject<{
|
|
146
|
+
unit: z.ZodEnum<["input_tokens", "cached_input_tokens", "output_tokens", "reasoning_tokens", "requests", "images", "audio_input_milliseconds", "audio_output_milliseconds", "video_milliseconds", "characters", "embeddings"]>;
|
|
147
|
+
amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
|
|
148
|
+
per: z.ZodNumber;
|
|
149
|
+
currency: z.ZodString;
|
|
150
|
+
}, "strict", z.ZodTypeAny, {
|
|
151
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
152
|
+
currency: string;
|
|
153
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
154
|
+
per: number;
|
|
155
|
+
}, {
|
|
156
|
+
amount: string;
|
|
157
|
+
currency: string;
|
|
158
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
159
|
+
per: number;
|
|
160
|
+
}>, "many">;
|
|
161
|
+
}, "strict", z.ZodTypeAny, {
|
|
162
|
+
currency: string;
|
|
163
|
+
priceVersionId: string;
|
|
164
|
+
unitPrices: {
|
|
165
|
+
amount: string & z.BRAND<"ExactDecimal">;
|
|
166
|
+
currency: string;
|
|
167
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
168
|
+
per: number;
|
|
169
|
+
}[];
|
|
170
|
+
}, {
|
|
171
|
+
currency: string;
|
|
172
|
+
priceVersionId: string;
|
|
173
|
+
unitPrices: {
|
|
174
|
+
amount: string;
|
|
175
|
+
currency: string;
|
|
176
|
+
unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
|
|
177
|
+
per: number;
|
|
178
|
+
}[];
|
|
179
|
+
}>;
|
|
180
|
+
export type PriceVersionStatus = z.infer<typeof priceVersionStatusSchema>;
|
|
181
|
+
export type PriceVersion = z.infer<typeof priceVersionSchema>;
|
|
182
|
+
export type PriceSnapshot = z.infer<typeof priceSnapshotSchema>;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BYOK provider connections — the metadata Oxy holds about a customer's own
|
|
3
|
+
* upstream provider credential.
|
|
4
|
+
*
|
|
5
|
+
* The credential itself is NOT here and cannot be put here. This shape carries
|
|
6
|
+
* a locator (`secretRef`) into Vault/KMS/managed secret storage, a prefix short
|
|
7
|
+
* enough to be useless, a fingerprint, and validation state. Two mechanisms
|
|
8
|
+
* make that structural rather than a convention somebody must remember:
|
|
9
|
+
*
|
|
10
|
+
* - The object is `.strict()`. A producer that attaches `apiKey`, `secret`,
|
|
11
|
+
* `token`, `privateKey` or `headers` fails the parse. Nothing is silently
|
|
12
|
+
* stripped, because a stripped field is one that still exists upstream of
|
|
13
|
+
* the parse, in a log line or an error report.
|
|
14
|
+
* - `keyPrefix` is capped at 12 characters — shorter than any provider's
|
|
15
|
+
* usable credential — so the one field designed to show part of a key cannot
|
|
16
|
+
* be widened into showing all of it without changing the contract.
|
|
17
|
+
*
|
|
18
|
+
* BYOK does not move the billing relationship: the upstream provider bills the
|
|
19
|
+
* customer's own account directly, and Oxy charges only its platform fee. The
|
|
20
|
+
* record says so explicitly so a receipt against a BYOK route can be read
|
|
21
|
+
* correctly without consulting anything else.
|
|
22
|
+
*
|
|
23
|
+
* Decided in: issue #972 workstream 10.
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
/**
|
|
27
|
+
* How widely a connection applies.
|
|
28
|
+
*
|
|
29
|
+
* In the unified account graph a project IS an account, so `account` and
|
|
30
|
+
* `project` differ by INHERITANCE, not by id space: an `account` connection is
|
|
31
|
+
* inherited by every descendant project and application, a `project` one
|
|
32
|
+
* applies to that project account alone, and an `application` one to a single
|
|
33
|
+
* application. Recording which the customer chose is what makes a later
|
|
34
|
+
* "why did this app use that key" answerable.
|
|
35
|
+
*/
|
|
36
|
+
export declare const providerConnectionScopeSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
37
|
+
kind: z.ZodLiteral<"account">;
|
|
38
|
+
accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
kind: "account";
|
|
41
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
42
|
+
}, {
|
|
43
|
+
kind: "account";
|
|
44
|
+
accountId: string;
|
|
45
|
+
}>, z.ZodObject<{
|
|
46
|
+
kind: z.ZodLiteral<"project">;
|
|
47
|
+
accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
48
|
+
}, "strict", z.ZodTypeAny, {
|
|
49
|
+
kind: "project";
|
|
50
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
51
|
+
}, {
|
|
52
|
+
kind: "project";
|
|
53
|
+
accountId: string;
|
|
54
|
+
}>, z.ZodObject<{
|
|
55
|
+
kind: z.ZodLiteral<"application">;
|
|
56
|
+
accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
57
|
+
applicationId: z.ZodString;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
kind: "application";
|
|
60
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
61
|
+
applicationId: string;
|
|
62
|
+
}, {
|
|
63
|
+
kind: "application";
|
|
64
|
+
accountId: string;
|
|
65
|
+
applicationId: string;
|
|
66
|
+
}>]>;
|
|
67
|
+
/**
|
|
68
|
+
* A locator for the credential in managed secret storage — never the credential.
|
|
69
|
+
*
|
|
70
|
+
* The scheme prefix is constrained to the stores Oxy actually uses, so a
|
|
71
|
+
* producer cannot pass a raw key through this field and have it look like a
|
|
72
|
+
* reference; whitespace is excluded for the same reason.
|
|
73
|
+
*/
|
|
74
|
+
export declare const providerSecretReferenceSchema: z.ZodString;
|
|
75
|
+
/** Why a credential check failed, as a closed set the Console can render. */
|
|
76
|
+
export declare const providerConnectionValidationSchema: z.ZodObject<{
|
|
77
|
+
state: z.ZodEnum<["unvalidated", "valid", "invalid", "expired"]>;
|
|
78
|
+
lastValidatedAt: z.ZodOptional<z.ZodString>;
|
|
79
|
+
/** Required when `invalid`: a failure nobody can act on is not a result. */
|
|
80
|
+
failureCode: z.ZodOptional<z.ZodEnum<["unauthorized", "forbidden", "not_found", "rate_limited", "network", "unknown"]>>;
|
|
81
|
+
}, "strict", z.ZodTypeAny, {
|
|
82
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
83
|
+
lastValidatedAt?: string | undefined;
|
|
84
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
87
|
+
lastValidatedAt?: string | undefined;
|
|
88
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
89
|
+
}>;
|
|
90
|
+
/** Lifecycle of a connection. `revoked` is terminal; `disabled` is reversible. */
|
|
91
|
+
export declare const providerConnectionStatusSchema: z.ZodEnum<["pending_validation", "active", "disabled", "revoked"]>;
|
|
92
|
+
/**
|
|
93
|
+
* A customer's provider connection, without secrets.
|
|
94
|
+
*
|
|
95
|
+
* This is the whole of what Oxy stores, and the whole of what the data plane
|
|
96
|
+
* is given.
|
|
97
|
+
* Resolving `secretRef` to credential material happens in the secret store, at
|
|
98
|
+
* use time, in the data plane — never in a database row, an API response, a
|
|
99
|
+
* Console screen or a log line.
|
|
100
|
+
*/
|
|
101
|
+
export declare const providerConnectionSchema: z.ZodEffects<z.ZodObject<{
|
|
102
|
+
/** See `version.ts`: exchanged with the data plane and rendered by Console. */
|
|
103
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
104
|
+
connectionId: z.ZodString;
|
|
105
|
+
provider: z.ZodString;
|
|
106
|
+
/** The Oxy account that owns the connection and answers for its use. */
|
|
107
|
+
ownerAccountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
108
|
+
scope: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
109
|
+
kind: z.ZodLiteral<"account">;
|
|
110
|
+
accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
111
|
+
}, "strict", z.ZodTypeAny, {
|
|
112
|
+
kind: "account";
|
|
113
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
114
|
+
}, {
|
|
115
|
+
kind: "account";
|
|
116
|
+
accountId: string;
|
|
117
|
+
}>, z.ZodObject<{
|
|
118
|
+
kind: z.ZodLiteral<"project">;
|
|
119
|
+
accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
120
|
+
}, "strict", z.ZodTypeAny, {
|
|
121
|
+
kind: "project";
|
|
122
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
123
|
+
}, {
|
|
124
|
+
kind: "project";
|
|
125
|
+
accountId: string;
|
|
126
|
+
}>, z.ZodObject<{
|
|
127
|
+
kind: z.ZodLiteral<"application">;
|
|
128
|
+
accountId: z.ZodBranded<z.ZodString, "OxyAccountId">;
|
|
129
|
+
applicationId: z.ZodString;
|
|
130
|
+
}, "strict", z.ZodTypeAny, {
|
|
131
|
+
kind: "application";
|
|
132
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
133
|
+
applicationId: string;
|
|
134
|
+
}, {
|
|
135
|
+
kind: "application";
|
|
136
|
+
accountId: string;
|
|
137
|
+
applicationId: string;
|
|
138
|
+
}>]>;
|
|
139
|
+
environment: z.ZodEnum<["development", "staging", "production"]>;
|
|
140
|
+
status: z.ZodEnum<["pending_validation", "active", "disabled", "revoked"]>;
|
|
141
|
+
secretRef: z.ZodString;
|
|
142
|
+
/**
|
|
143
|
+
* The leading characters of the credential, for recognition only. Capped at
|
|
144
|
+
* 12 — long enough to tell two keys apart, far too short to be one.
|
|
145
|
+
*/
|
|
146
|
+
keyPrefix: z.ZodString;
|
|
147
|
+
/** SHA-256 of the credential, so rotation is verifiable without the key. */
|
|
148
|
+
fingerprint: z.ZodString;
|
|
149
|
+
validation: z.ZodObject<{
|
|
150
|
+
state: z.ZodEnum<["unvalidated", "valid", "invalid", "expired"]>;
|
|
151
|
+
lastValidatedAt: z.ZodOptional<z.ZodString>;
|
|
152
|
+
/** Required when `invalid`: a failure nobody can act on is not a result. */
|
|
153
|
+
failureCode: z.ZodOptional<z.ZodEnum<["unauthorized", "forbidden", "not_found", "rate_limited", "network", "unknown"]>>;
|
|
154
|
+
}, "strict", z.ZodTypeAny, {
|
|
155
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
156
|
+
lastValidatedAt?: string | undefined;
|
|
157
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
160
|
+
lastValidatedAt?: string | undefined;
|
|
161
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
162
|
+
}>;
|
|
163
|
+
/**
|
|
164
|
+
* Always `true` for a BYOK connection: the provider bills the customer's own
|
|
165
|
+
* upstream account, and Oxy charges only its platform fee. Stated as data so
|
|
166
|
+
* a receipt against this route is readable without a second lookup.
|
|
167
|
+
*/
|
|
168
|
+
upstreamBillsCustomerDirectly: z.ZodLiteral<true>;
|
|
169
|
+
/** Set when the provider's terms require a per-customer acknowledgement. */
|
|
170
|
+
termsAcknowledgedAt: z.ZodOptional<z.ZodString>;
|
|
171
|
+
createdAt: z.ZodString;
|
|
172
|
+
rotatedAt: z.ZodOptional<z.ZodString>;
|
|
173
|
+
}, "strict", z.ZodTypeAny, {
|
|
174
|
+
environment: "development" | "staging" | "production";
|
|
175
|
+
validation: {
|
|
176
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
177
|
+
lastValidatedAt?: string | undefined;
|
|
178
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
179
|
+
};
|
|
180
|
+
status: "active" | "revoked" | "disabled" | "pending_validation";
|
|
181
|
+
scope: {
|
|
182
|
+
kind: "account";
|
|
183
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
184
|
+
} | {
|
|
185
|
+
kind: "project";
|
|
186
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
187
|
+
} | {
|
|
188
|
+
kind: "application";
|
|
189
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
190
|
+
applicationId: string;
|
|
191
|
+
};
|
|
192
|
+
createdAt: string;
|
|
193
|
+
provider: string;
|
|
194
|
+
schemaVersion: 1;
|
|
195
|
+
connectionId: string;
|
|
196
|
+
ownerAccountId: string & z.BRAND<"OxyAccountId">;
|
|
197
|
+
secretRef: string;
|
|
198
|
+
keyPrefix: string;
|
|
199
|
+
fingerprint: string;
|
|
200
|
+
upstreamBillsCustomerDirectly: true;
|
|
201
|
+
termsAcknowledgedAt?: string | undefined;
|
|
202
|
+
rotatedAt?: string | undefined;
|
|
203
|
+
}, {
|
|
204
|
+
environment: "development" | "staging" | "production";
|
|
205
|
+
validation: {
|
|
206
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
207
|
+
lastValidatedAt?: string | undefined;
|
|
208
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
209
|
+
};
|
|
210
|
+
status: "active" | "revoked" | "disabled" | "pending_validation";
|
|
211
|
+
scope: {
|
|
212
|
+
kind: "account";
|
|
213
|
+
accountId: string;
|
|
214
|
+
} | {
|
|
215
|
+
kind: "project";
|
|
216
|
+
accountId: string;
|
|
217
|
+
} | {
|
|
218
|
+
kind: "application";
|
|
219
|
+
accountId: string;
|
|
220
|
+
applicationId: string;
|
|
221
|
+
};
|
|
222
|
+
createdAt: string;
|
|
223
|
+
provider: string;
|
|
224
|
+
schemaVersion: 1;
|
|
225
|
+
connectionId: string;
|
|
226
|
+
ownerAccountId: string;
|
|
227
|
+
secretRef: string;
|
|
228
|
+
keyPrefix: string;
|
|
229
|
+
fingerprint: string;
|
|
230
|
+
upstreamBillsCustomerDirectly: true;
|
|
231
|
+
termsAcknowledgedAt?: string | undefined;
|
|
232
|
+
rotatedAt?: string | undefined;
|
|
233
|
+
}>, {
|
|
234
|
+
environment: "development" | "staging" | "production";
|
|
235
|
+
validation: {
|
|
236
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
237
|
+
lastValidatedAt?: string | undefined;
|
|
238
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
239
|
+
};
|
|
240
|
+
status: "active" | "revoked" | "disabled" | "pending_validation";
|
|
241
|
+
scope: {
|
|
242
|
+
kind: "account";
|
|
243
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
244
|
+
} | {
|
|
245
|
+
kind: "project";
|
|
246
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
247
|
+
} | {
|
|
248
|
+
kind: "application";
|
|
249
|
+
accountId: string & z.BRAND<"OxyAccountId">;
|
|
250
|
+
applicationId: string;
|
|
251
|
+
};
|
|
252
|
+
createdAt: string;
|
|
253
|
+
provider: string;
|
|
254
|
+
schemaVersion: 1;
|
|
255
|
+
connectionId: string;
|
|
256
|
+
ownerAccountId: string & z.BRAND<"OxyAccountId">;
|
|
257
|
+
secretRef: string;
|
|
258
|
+
keyPrefix: string;
|
|
259
|
+
fingerprint: string;
|
|
260
|
+
upstreamBillsCustomerDirectly: true;
|
|
261
|
+
termsAcknowledgedAt?: string | undefined;
|
|
262
|
+
rotatedAt?: string | undefined;
|
|
263
|
+
}, {
|
|
264
|
+
environment: "development" | "staging" | "production";
|
|
265
|
+
validation: {
|
|
266
|
+
state: "valid" | "invalid" | "expired" | "unvalidated";
|
|
267
|
+
lastValidatedAt?: string | undefined;
|
|
268
|
+
failureCode?: "unknown" | "network" | "rate_limited" | "unauthorized" | "forbidden" | "not_found" | undefined;
|
|
269
|
+
};
|
|
270
|
+
status: "active" | "revoked" | "disabled" | "pending_validation";
|
|
271
|
+
scope: {
|
|
272
|
+
kind: "account";
|
|
273
|
+
accountId: string;
|
|
274
|
+
} | {
|
|
275
|
+
kind: "project";
|
|
276
|
+
accountId: string;
|
|
277
|
+
} | {
|
|
278
|
+
kind: "application";
|
|
279
|
+
accountId: string;
|
|
280
|
+
applicationId: string;
|
|
281
|
+
};
|
|
282
|
+
createdAt: string;
|
|
283
|
+
provider: string;
|
|
284
|
+
schemaVersion: 1;
|
|
285
|
+
connectionId: string;
|
|
286
|
+
ownerAccountId: string;
|
|
287
|
+
secretRef: string;
|
|
288
|
+
keyPrefix: string;
|
|
289
|
+
fingerprint: string;
|
|
290
|
+
upstreamBillsCustomerDirectly: true;
|
|
291
|
+
termsAcknowledgedAt?: string | undefined;
|
|
292
|
+
rotatedAt?: string | undefined;
|
|
293
|
+
}>;
|
|
294
|
+
export type ProviderConnectionScope = z.infer<typeof providerConnectionScopeSchema>;
|
|
295
|
+
export type ProviderConnectionValidation = z.infer<typeof providerConnectionValidationSchema>;
|
|
296
|
+
export type ProviderConnectionStatus = z.infer<typeof providerConnectionStatusSchema>;
|
|
297
|
+
export type ProviderConnection = z.infer<typeof providerConnectionSchema>;
|