@oxyhq/contracts 0.25.0 → 0.27.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/NOTICE +10 -9
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/accountGraph.js +4 -3
- package/dist/cjs/browserHub.js +215 -0
- package/dist/cjs/deviceDirectory.js +189 -0
- package/dist/cjs/index.js +172 -2
- package/dist/cjs/inference/attribution.js +101 -0
- package/dist/cjs/inference/catalogue.js +482 -0
- package/dist/cjs/inference/errors.js +195 -0
- package/dist/cjs/inference/identifiers.js +189 -0
- package/dist/cjs/inference/money.js +145 -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 +291 -0
- package/dist/cjs/inference/version.js +57 -0
- package/dist/cjs/oauth.js +66 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/accountGraph.js +4 -3
- package/dist/esm/browserHub.js +212 -0
- package/dist/esm/deviceDirectory.js +186 -0
- package/dist/esm/index.js +48 -0
- package/dist/esm/inference/attribution.js +98 -0
- package/dist/esm/inference/catalogue.js +479 -0
- package/dist/esm/inference/errors.js +192 -0
- package/dist/esm/inference/identifiers.js +186 -0
- package/dist/esm/inference/money.js +142 -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 +288 -0
- package/dist/esm/inference/version.js +54 -0
- package/dist/esm/oauth.js +63 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/accountGraph.d.ts +6 -5
- package/dist/types/browserHub.d.ts +856 -0
- package/dist/types/deviceDirectory.d.ts +1317 -0
- package/dist/types/deviceSession.d.ts +46 -46
- package/dist/types/index.d.ts +29 -0
- package/dist/types/inference/attribution.d.ts +171 -0
- package/dist/types/inference/catalogue.d.ts +1612 -0
- package/dist/types/inference/errors.d.ts +193 -0
- package/dist/types/inference/identifiers.d.ts +149 -0
- package/dist/types/inference/money.d.ts +142 -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 +1133 -0
- package/dist/types/inference/version.d.ts +54 -0
- package/dist/types/oauth.d.ts +86 -0
- package/dist/types/sessionStatus.d.ts +8 -8
- package/dist/types/userResponse.d.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version rule for the Oxy↔data-plane inference contracts.
|
|
3
|
+
*
|
|
4
|
+
* Oxy is the control plane; the inference data plane is a separate service.
|
|
5
|
+
* They are deployed independently, in different repositories, possibly in
|
|
6
|
+
* different languages.
|
|
7
|
+
* Every shape they exchange therefore carries its version IN THE PARSED DATA,
|
|
8
|
+
* never as a comment or an out-of-band assumption, so a producer running ahead
|
|
9
|
+
* of a consumer fails loudly at the parse instead of being silently reinterpreted.
|
|
10
|
+
*
|
|
11
|
+
* The rule, enforced by `src/__tests__/inference.compatibility.test.ts`:
|
|
12
|
+
*
|
|
13
|
+
* - A schema carries `schemaVersion: z.literal(<n>)` **if and only if** it can
|
|
14
|
+
* appear on the wire as a whole message — a request envelope, a stream event,
|
|
15
|
+
* a catalogue descriptor, a ledger record, an error body.
|
|
16
|
+
* - A schema that only ever appears EMBEDDED inside such a message (the
|
|
17
|
+
* attribution block, one message part, one usage quantity, a data-retention
|
|
18
|
+
* policy) carries no version of its own: it inherits the version of the
|
|
19
|
+
* envelope it rides in. Versioning it separately would create two versions
|
|
20
|
+
* that can disagree about one byte stream.
|
|
21
|
+
* - A shape that is BOTH — `inferenceErrorSchema` is returned as an HTTP body
|
|
22
|
+
* and also rides inside the stream's error event — keeps its own version.
|
|
23
|
+
* The envelope's version then governs the envelope and the payload's governs
|
|
24
|
+
* the payload, which is two versions of two things rather than two versions
|
|
25
|
+
* of one.
|
|
26
|
+
* - Every exported object schema in `src/inference/` must fall into exactly one
|
|
27
|
+
* of those groups. The compatibility test holds both lists as exact
|
|
28
|
+
* equalities, so a new shape that is in neither fails the build rather than
|
|
29
|
+
* quietly shipping unversioned.
|
|
30
|
+
*
|
|
31
|
+
* A shape's own version is bumped when its meaning changes in a way a consumer
|
|
32
|
+
* pinned to the previous version would misread — a field removed, a field's
|
|
33
|
+
* units changed, a closed enum's member given a new meaning. Adding an OPTIONAL
|
|
34
|
+
* field is additive and does not bump it, because a consumer on the previous
|
|
35
|
+
* version parses the message correctly and simply does not read the new field.
|
|
36
|
+
*
|
|
37
|
+
* Decided in: docs/adr/0006-oxy-relay-boundary.md, docs/adr/0010-public-api-compatibility.md.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Version of the contract SET as a whole — the value the control plane and the
|
|
41
|
+
* data plane exchange in a startup/health handshake to establish that they were built against
|
|
42
|
+
* compatible definitions before a single inference request is served.
|
|
43
|
+
*
|
|
44
|
+
* MAJOR is bumped when any individual shape's `schemaVersion` increments (at
|
|
45
|
+
* least one message is now read differently by the two sides); MINOR when a
|
|
46
|
+
* shape or an optional field is added; PATCH for documentation-only changes
|
|
47
|
+
* that leave every parsed byte identical.
|
|
48
|
+
*
|
|
49
|
+
* This constant is deliberately NOT embedded in the request envelope. Pinning a
|
|
50
|
+
* request to the version of the whole set would make an unrelated additive
|
|
51
|
+
* change to, say, the catalogue reject every in-flight inference request; the
|
|
52
|
+
* per-shape `schemaVersion` is what a message is validated against.
|
|
53
|
+
*/
|
|
54
|
+
export declare const INFERENCE_CONTRACT_VERSION = "1.0.0";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The two `/auth/oauth/*` responses the browser hub's edge layer reads.
|
|
4
|
+
*
|
|
5
|
+
* They existed on the wire long before this file — `GET /auth/oauth/consent`
|
|
6
|
+
* and `POST /auth/oauth/authorize` are the surface `auth.oxy.so` has always
|
|
7
|
+
* driven with a bearer. What is new (issue #937 Phase 5) is a SECOND consumer
|
|
8
|
+
* that is not the SPA: the IdP's edge layer runs both calls server-side so the
|
|
9
|
+
* device-wide bearer never enters the browser's script context. A shape read by
|
|
10
|
+
* two independently deployed consumers is a contract, so it is written down
|
|
11
|
+
* once here and validated on both sides rather than transcribed into the edge.
|
|
12
|
+
*
|
|
13
|
+
* These are NOT the RFC 6749 token/userinfo responses. Those two speak flat
|
|
14
|
+
* OAuth/OIDC on the wire and are the one place in the API that does not use the
|
|
15
|
+
* `{ data }` envelope; these two are ordinary internal API responses that happen
|
|
16
|
+
* to be about OAuth.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Server-authoritative answer to "must this user be shown a consent screen".
|
|
20
|
+
*
|
|
21
|
+
* Discriminated on `consentRequired` so the two arms cannot be confused by a
|
|
22
|
+
* consumer that reads `reason` first: `trusted`/`granted` are reasons NOT to
|
|
23
|
+
* ask, `new`/`scope_changed` are reasons to ask, and a flat object would let a
|
|
24
|
+
* typo in one produce a plausible value of the other.
|
|
25
|
+
*
|
|
26
|
+
* - `trusted` — the application is first-party/internal/system/official
|
|
27
|
+
* by the REGISTRY's verdict (`isTrustedApplication`), and
|
|
28
|
+
* the request names no scope over the user's own follow
|
|
29
|
+
* graph. Never inferred from a hostname.
|
|
30
|
+
* - `granted` — a prior `AppGrant` already covers every requested scope.
|
|
31
|
+
* - `scope_changed` — a prior grant exists and is missing one.
|
|
32
|
+
* - `new` — no prior grant.
|
|
33
|
+
*
|
|
34
|
+
* `userConsentScopes` names the scopes that FORCED the screen, so the consent UI
|
|
35
|
+
* can say which one it is asking about. Present only on the `true` arm, and only
|
|
36
|
+
* when such a scope exists — a trusted app asked for one is still asked.
|
|
37
|
+
*/
|
|
38
|
+
export declare const oauthConsentDecisionSchema: z.ZodDiscriminatedUnion<"consentRequired", [z.ZodObject<{
|
|
39
|
+
consentRequired: z.ZodLiteral<false>;
|
|
40
|
+
reason: z.ZodEnum<["trusted", "granted"]>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
reason: "trusted" | "granted";
|
|
43
|
+
consentRequired: false;
|
|
44
|
+
}, {
|
|
45
|
+
reason: "trusted" | "granted";
|
|
46
|
+
consentRequired: false;
|
|
47
|
+
}>, z.ZodObject<{
|
|
48
|
+
consentRequired: z.ZodLiteral<true>;
|
|
49
|
+
reason: z.ZodEnum<["new", "scope_changed"]>;
|
|
50
|
+
userConsentScopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
reason: "new" | "scope_changed";
|
|
53
|
+
consentRequired: true;
|
|
54
|
+
userConsentScopes?: string[] | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
reason: "new" | "scope_changed";
|
|
57
|
+
consentRequired: true;
|
|
58
|
+
userConsentScopes?: string[] | undefined;
|
|
59
|
+
}>]>;
|
|
60
|
+
/**
|
|
61
|
+
* A minted authorization code.
|
|
62
|
+
*
|
|
63
|
+
* `state` is echoed back as the caller sent it and is `null` when they sent
|
|
64
|
+
* none — never omitted, so a consumer cannot read "the server dropped my state"
|
|
65
|
+
* as "I sent none". `redirectUri` is echoed for the same reason the code is
|
|
66
|
+
* bound to it server-side: the caller must be able to see that the value the
|
|
67
|
+
* code was issued against is the one it registered.
|
|
68
|
+
*/
|
|
69
|
+
export declare const oauthAuthorizeCodeResponseSchema: z.ZodObject<{
|
|
70
|
+
code: z.ZodString;
|
|
71
|
+
state: z.ZodNullable<z.ZodString>;
|
|
72
|
+
redirectUri: z.ZodString;
|
|
73
|
+
expiresIn: z.ZodNumber;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
code: string;
|
|
76
|
+
state: string | null;
|
|
77
|
+
redirectUri: string;
|
|
78
|
+
expiresIn: number;
|
|
79
|
+
}, {
|
|
80
|
+
code: string;
|
|
81
|
+
state: string | null;
|
|
82
|
+
redirectUri: string;
|
|
83
|
+
expiresIn: number;
|
|
84
|
+
}>;
|
|
85
|
+
export type OauthConsentDecision = z.infer<typeof oauthConsentDecisionSchema>;
|
|
86
|
+
export type OauthAuthorizeCodeResponse = z.infer<typeof oauthAuthorizeCodeResponseSchema>;
|
|
@@ -179,12 +179,12 @@ export declare const sessionStatusSchema: z.ZodObject<{
|
|
|
179
179
|
openedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
180
180
|
}, "strip", z.ZodTypeAny, {
|
|
181
181
|
status: string;
|
|
182
|
-
publicKey?: string | null | undefined;
|
|
183
|
-
userId?: string | null | undefined;
|
|
184
|
-
expiresAt?: string | undefined;
|
|
185
182
|
sessionId?: string | null | undefined;
|
|
186
|
-
|
|
183
|
+
expiresAt?: string | undefined;
|
|
184
|
+
userId?: string | null | undefined;
|
|
185
|
+
publicKey?: string | null | undefined;
|
|
187
186
|
sessionToken?: string | undefined;
|
|
187
|
+
authorized?: boolean | undefined;
|
|
188
188
|
application?: {
|
|
189
189
|
type: "system" | "first_party" | "third_party" | "internal";
|
|
190
190
|
name: string;
|
|
@@ -204,12 +204,12 @@ export declare const sessionStatusSchema: z.ZodObject<{
|
|
|
204
204
|
openedAt?: string | null | undefined;
|
|
205
205
|
}, {
|
|
206
206
|
status: string;
|
|
207
|
-
publicKey?: string | null | undefined;
|
|
208
|
-
userId?: string | null | undefined;
|
|
209
|
-
expiresAt?: string | undefined;
|
|
210
207
|
sessionId?: string | null | undefined;
|
|
211
|
-
|
|
208
|
+
expiresAt?: string | undefined;
|
|
209
|
+
userId?: string | null | undefined;
|
|
210
|
+
publicKey?: string | null | undefined;
|
|
212
211
|
sessionToken?: string | undefined;
|
|
212
|
+
authorized?: boolean | undefined;
|
|
213
213
|
application?: {
|
|
214
214
|
type: "system" | "first_party" | "third_party" | "internal";
|
|
215
215
|
name: string;
|
|
@@ -813,13 +813,13 @@ export declare const currentUserResponseSchema: z.ZodObject<{
|
|
|
813
813
|
publicKey?: string | undefined;
|
|
814
814
|
did?: string | undefined;
|
|
815
815
|
verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
|
|
816
|
-
verified?: boolean | undefined;
|
|
817
|
-
email?: string | undefined;
|
|
818
816
|
_id?: string | undefined;
|
|
817
|
+
email?: string | undefined;
|
|
819
818
|
phone?: string | undefined;
|
|
820
819
|
address?: string | undefined;
|
|
821
820
|
birthday?: string | undefined;
|
|
822
821
|
color?: string | null | undefined;
|
|
822
|
+
verified?: boolean | undefined;
|
|
823
823
|
languages?: string[] | undefined;
|
|
824
824
|
relationship?: UserRelationship | undefined;
|
|
825
825
|
themePreference?: ThemePreference | undefined;
|
|
@@ -837,13 +837,13 @@ export declare const currentUserResponseSchema: z.ZodObject<{
|
|
|
837
837
|
publicKey?: string | undefined;
|
|
838
838
|
did?: string | undefined;
|
|
839
839
|
verifiedDomains?: import("./identity").VerifiedDomain[] | undefined;
|
|
840
|
-
verified?: boolean | undefined;
|
|
841
|
-
email?: string | undefined;
|
|
842
840
|
_id?: string | undefined;
|
|
841
|
+
email?: string | undefined;
|
|
843
842
|
phone?: string | undefined;
|
|
844
843
|
address?: string | undefined;
|
|
845
844
|
birthday?: string | undefined;
|
|
846
845
|
color?: string | null | undefined;
|
|
846
|
+
verified?: boolean | undefined;
|
|
847
847
|
languages?: string[] | undefined;
|
|
848
848
|
relationship?: UserRelationship | undefined;
|
|
849
849
|
themePreference?: ThemePreference | undefined;
|
|
@@ -1107,6 +1107,7 @@ export declare const deviceLinkedSessionSchema: z.ZodObject<{
|
|
|
1107
1107
|
}, z.ZodTypeAny, "passthrough">>>>;
|
|
1108
1108
|
}, "strip", z.ZodTypeAny, {
|
|
1109
1109
|
sessionId: string;
|
|
1110
|
+
isCurrent?: boolean | undefined;
|
|
1110
1111
|
user?: z.objectOutputType<{
|
|
1111
1112
|
/** MongoDB ObjectId as a string. Present on `formatUserResponse` output. */
|
|
1112
1113
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1189,9 +1190,9 @@ export declare const deviceLinkedSessionSchema: z.ZodObject<{
|
|
|
1189
1190
|
*/
|
|
1190
1191
|
themePreference: z.ZodOptional<z.ZodType<ThemePreference, z.ZodTypeDef, ThemePreference>>;
|
|
1191
1192
|
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
1192
|
-
isCurrent?: boolean | undefined;
|
|
1193
1193
|
}, {
|
|
1194
1194
|
sessionId: string;
|
|
1195
|
+
isCurrent?: boolean | undefined;
|
|
1195
1196
|
user?: z.objectInputType<{
|
|
1196
1197
|
/** MongoDB ObjectId as a string. Present on `formatUserResponse` output. */
|
|
1197
1198
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1274,7 +1275,6 @@ export declare const deviceLinkedSessionSchema: z.ZodObject<{
|
|
|
1274
1275
|
*/
|
|
1275
1276
|
themePreference: z.ZodOptional<z.ZodType<ThemePreference, z.ZodTypeDef, ThemePreference>>;
|
|
1276
1277
|
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
1277
|
-
isCurrent?: boolean | undefined;
|
|
1278
1278
|
}>;
|
|
1279
1279
|
export type DeviceLinkedSessionResponse = z.infer<typeof deviceLinkedSessionSchema>;
|
|
1280
1280
|
/** Wire shape of `GET /session/device/sessions/:sessionId` (an array). */
|
|
@@ -1527,6 +1527,7 @@ export declare const deviceLinkedSessionsResponseSchema: z.ZodArray<z.ZodObject<
|
|
|
1527
1527
|
}, z.ZodTypeAny, "passthrough">>>>;
|
|
1528
1528
|
}, "strip", z.ZodTypeAny, {
|
|
1529
1529
|
sessionId: string;
|
|
1530
|
+
isCurrent?: boolean | undefined;
|
|
1530
1531
|
user?: z.objectOutputType<{
|
|
1531
1532
|
/** MongoDB ObjectId as a string. Present on `formatUserResponse` output. */
|
|
1532
1533
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1609,9 +1610,9 @@ export declare const deviceLinkedSessionsResponseSchema: z.ZodArray<z.ZodObject<
|
|
|
1609
1610
|
*/
|
|
1610
1611
|
themePreference: z.ZodOptional<z.ZodType<ThemePreference, z.ZodTypeDef, ThemePreference>>;
|
|
1611
1612
|
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
1612
|
-
isCurrent?: boolean | undefined;
|
|
1613
1613
|
}, {
|
|
1614
1614
|
sessionId: string;
|
|
1615
|
+
isCurrent?: boolean | undefined;
|
|
1615
1616
|
user?: z.objectInputType<{
|
|
1616
1617
|
/** MongoDB ObjectId as a string. Present on `formatUserResponse` output. */
|
|
1617
1618
|
id: z.ZodOptional<z.ZodString>;
|
|
@@ -1694,7 +1695,6 @@ export declare const deviceLinkedSessionsResponseSchema: z.ZodArray<z.ZodObject<
|
|
|
1694
1695
|
*/
|
|
1695
1696
|
themePreference: z.ZodOptional<z.ZodType<ThemePreference, z.ZodTypeDef, ThemePreference>>;
|
|
1696
1697
|
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
1697
|
-
isCurrent?: boolean | undefined;
|
|
1698
1698
|
}>, "many">;
|
|
1699
1699
|
export type DeviceLinkedSessionsResponseContract = z.infer<typeof deviceLinkedSessionsResponseSchema>;
|
|
1700
1700
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "OxyHQ API contracts — single source of truth for request/response Zod schemas and inferred types, shared by the backend and the client SDKs",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|