@oxy.so/contracts 5.7.0 → 6.0.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/accountAccess.js +6 -5
- package/dist/cjs/accountEmail.js +13 -5
- package/dist/cjs/accountGraph.js +10 -9
- package/dist/cjs/accountName.js +3 -2
- package/dist/cjs/agency.js +91 -34
- package/dist/cjs/agentKeys.js +21 -17
- package/dist/cjs/appAssertions.js +14 -13
- package/dist/cjs/applicationRoles.js +19 -12
- package/dist/cjs/civic.js +10 -9
- package/dist/cjs/client/check.js +61 -53
- package/dist/cjs/client/consoleOnboarding.js +24 -0
- package/dist/cjs/client/index.js +7 -3
- package/dist/cjs/client/safety.js +9 -1
- package/dist/cjs/consoleOnboarding.js +56 -0
- package/dist/cjs/contentClaims.js +23 -14
- package/dist/cjs/deviceDirectory.js +11 -9
- package/dist/cjs/deviceSession.js +27 -25
- package/dist/cjs/email/messages.js +20 -18
- package/dist/cjs/emailAgentContext.js +11 -9
- package/dist/cjs/externalIdentity.js +15 -11
- package/dist/cjs/federationInstanceFetch.js +12 -7
- package/dist/cjs/identity.js +19 -17
- package/dist/cjs/identityLink.js +6 -4
- package/dist/cjs/identityProof.js +6 -4
- package/dist/cjs/inboxPush.js +5 -4
- package/dist/cjs/index.js +16 -6
- package/dist/cjs/inference/accountBilling.js +35 -33
- package/dist/cjs/inference/aliaModelRelease.js +9 -7
- package/dist/cjs/inference/attribution.js +14 -12
- package/dist/cjs/inference/catalogue.js +35 -29
- package/dist/cjs/inference/economics.js +24 -19
- package/dist/cjs/inference/embeddings.js +9 -7
- package/dist/cjs/inference/entitlement.js +17 -15
- package/dist/cjs/inference/errors.js +15 -8
- package/dist/cjs/inference/identifiers.js +33 -21
- package/dist/cjs/inference/inbox.js +37 -35
- package/dist/cjs/inference/modelDocumentation.js +16 -14
- package/dist/cjs/inference/money.js +5 -4
- package/dist/cjs/inference/priceVersion.js +10 -5
- package/dist/cjs/inference/providerConnection.js +21 -14
- package/dist/cjs/inference/realtime.js +88 -47
- package/dist/cjs/inference/request.js +27 -25
- package/dist/cjs/inference/routingPolicy.js +12 -10
- package/dist/cjs/inference/streamEvents.js +22 -16
- package/dist/cjs/inference/usage.js +32 -15
- package/dist/cjs/keyRecovery.js +8 -6
- package/dist/cjs/keyRotation.js +5 -4
- package/dist/cjs/linkedAccounts.js +22 -18
- package/dist/cjs/moderationReputation.js +29 -27
- package/dist/cjs/notifications.js +25 -9
- package/dist/cjs/numberChecks.js +45 -0
- package/dist/cjs/oauth.js +14 -12
- package/dist/cjs/organizations.js +23 -21
- package/dist/cjs/products/access.js +10 -8
- package/dist/cjs/products/billing.js +10 -8
- package/dist/cjs/products/checkout.js +22 -10
- package/dist/cjs/products/plans.js +15 -10
- package/dist/cjs/protocol.js +6 -5
- package/dist/cjs/recommendations.js +27 -19
- package/dist/cjs/reputation.js +15 -13
- package/dist/cjs/safety.js +46 -29
- package/dist/cjs/serviceToken.js +81 -2
- package/dist/cjs/sessionRevocation.js +8 -6
- package/dist/cjs/signIn.js +42 -24
- package/dist/cjs/stickers.js +19 -15
- package/dist/cjs/stringChecks.js +70 -0
- package/dist/cjs/transparency.js +14 -12
- package/dist/cjs/updates.js +24 -22
- package/dist/cjs/userInvalidation.js +7 -5
- package/dist/cjs/userResponse.js +8 -7
- package/dist/cjs/username.js +7 -6
- package/dist/esm/accountAccess.js +4 -3
- package/dist/esm/accountEmail.js +13 -5
- package/dist/esm/accountGraph.js +8 -7
- package/dist/esm/accountName.js +3 -2
- package/dist/esm/agency.js +90 -33
- package/dist/esm/agentKeys.js +21 -17
- package/dist/esm/appAssertions.js +11 -10
- package/dist/esm/applicationRoles.js +16 -9
- package/dist/esm/civic.js +8 -7
- package/dist/esm/client/check.js +61 -53
- package/dist/esm/client/consoleOnboarding.js +21 -0
- package/dist/esm/client/index.js +2 -1
- package/dist/esm/client/safety.js +8 -0
- package/dist/esm/consoleOnboarding.js +51 -0
- package/dist/esm/contentClaims.js +23 -14
- package/dist/esm/deviceDirectory.js +11 -9
- package/dist/esm/deviceSession.js +27 -25
- package/dist/esm/email/messages.js +18 -16
- package/dist/esm/emailAgentContext.js +11 -9
- package/dist/esm/externalIdentity.js +15 -11
- package/dist/esm/federationInstanceFetch.js +10 -5
- package/dist/esm/identity.js +17 -15
- package/dist/esm/identityLink.js +6 -4
- package/dist/esm/identityProof.js +6 -4
- package/dist/esm/inboxPush.js +3 -2
- package/dist/esm/index.js +5 -2
- package/dist/esm/inference/accountBilling.js +33 -31
- package/dist/esm/inference/aliaModelRelease.js +7 -5
- package/dist/esm/inference/attribution.js +14 -12
- package/dist/esm/inference/catalogue.js +33 -27
- package/dist/esm/inference/economics.js +22 -17
- package/dist/esm/inference/embeddings.js +9 -7
- package/dist/esm/inference/entitlement.js +15 -13
- package/dist/esm/inference/errors.js +13 -6
- package/dist/esm/inference/identifiers.js +31 -19
- package/dist/esm/inference/inbox.js +37 -35
- package/dist/esm/inference/modelDocumentation.js +14 -12
- package/dist/esm/inference/money.js +3 -2
- package/dist/esm/inference/priceVersion.js +8 -3
- package/dist/esm/inference/providerConnection.js +19 -12
- package/dist/esm/inference/realtime.js +85 -44
- package/dist/esm/inference/request.js +25 -23
- package/dist/esm/inference/routingPolicy.js +9 -7
- package/dist/esm/inference/streamEvents.js +20 -14
- package/dist/esm/inference/usage.js +30 -13
- package/dist/esm/keyRecovery.js +8 -6
- package/dist/esm/keyRotation.js +5 -4
- package/dist/esm/linkedAccounts.js +20 -16
- package/dist/esm/moderationReputation.js +27 -25
- package/dist/esm/notifications.js +23 -7
- package/dist/esm/numberChecks.js +41 -0
- package/dist/esm/oauth.js +14 -12
- package/dist/esm/organizations.js +23 -21
- package/dist/esm/products/access.js +10 -8
- package/dist/esm/products/billing.js +10 -8
- package/dist/esm/products/checkout.js +22 -10
- package/dist/esm/products/plans.js +15 -10
- package/dist/esm/protocol.js +4 -3
- package/dist/esm/recommendations.js +25 -17
- package/dist/esm/reputation.js +13 -11
- package/dist/esm/safety.js +45 -29
- package/dist/esm/serviceToken.js +80 -1
- package/dist/esm/sessionRevocation.js +6 -4
- package/dist/esm/signIn.js +42 -24
- package/dist/esm/stickers.js +17 -13
- package/dist/esm/stringChecks.js +63 -0
- package/dist/esm/transparency.js +14 -12
- package/dist/esm/updates.js +22 -20
- package/dist/esm/userInvalidation.js +4 -2
- package/dist/esm/userResponse.js +4 -3
- package/dist/esm/username.js +3 -2
- package/dist/types/accountAccess.d.ts +29 -70
- package/dist/types/accountEmail.d.ts +2 -14
- package/dist/types/accountGraph.d.ts +179 -171
- package/dist/types/accountName.d.ts +1 -1
- package/dist/types/accountSubject.d.ts +20 -93
- package/dist/types/agency.d.ts +528 -2924
- package/dist/types/agentKeys.d.ts +48 -421
- package/dist/types/appAssertions.d.ts +56 -210
- package/dist/types/applicationRoles.d.ts +30 -276
- package/dist/types/avatarCharacter.d.ts +1 -1
- package/dist/types/civic.d.ts +1 -13
- package/dist/types/client/agentKeys.d.ts +18 -18
- package/dist/types/client/appAssertions.d.ts +3 -3
- package/dist/types/client/check.d.ts +13 -13
- package/dist/types/client/consoleOnboarding.d.ts +16 -0
- package/dist/types/client/deviceDirectory.d.ts +51 -51
- package/dist/types/client/deviceSession.d.ts +14 -14
- package/dist/types/client/index.d.ts +2 -1
- package/dist/types/client/organizations.d.ts +25 -25
- package/dist/types/client/products.d.ts +33 -33
- package/dist/types/client/recommendations.d.ts +2 -2
- package/dist/types/client/safety.d.ts +53 -45
- package/dist/types/client/sessionStatus.d.ts +4 -4
- package/dist/types/client/signIn.d.ts +1 -1
- package/dist/types/commonsSignIn.d.ts +4 -1
- package/dist/types/consoleOnboarding.d.ts +57 -0
- package/dist/types/contentClaims.d.ts +24 -180
- package/dist/types/deviceDirectory.d.ts +109 -1040
- package/dist/types/deviceSession.d.ts +36 -298
- package/dist/types/email/messages.d.ts +212 -1793
- package/dist/types/emailAgentContext.d.ts +10 -194
- package/dist/types/externalIdentity.d.ts +121 -615
- package/dist/types/federationInstanceFetch.d.ts +3 -32
- package/dist/types/identity.d.ts +15 -92
- package/dist/types/identityLink.d.ts +6 -84
- package/dist/types/identityProof.d.ts +5 -17
- package/dist/types/inboxPush.d.ts +1 -9
- package/dist/types/index.d.ts +6 -3
- package/dist/types/inference/accountBilling.d.ts +151 -488
- package/dist/types/inference/aliaModelRelease.d.ts +42 -439
- package/dist/types/inference/attribution.d.ts +75 -104
- package/dist/types/inference/catalogue.d.ts +417 -1599
- package/dist/types/inference/economics.d.ts +69 -276
- package/dist/types/inference/embeddings.d.ts +110 -406
- package/dist/types/inference/entitlement.d.ts +80 -335
- package/dist/types/inference/errors.d.ts +90 -102
- package/dist/types/inference/identifiers.d.ts +12 -4
- package/dist/types/inference/inbox.d.ts +105 -420
- package/dist/types/inference/modelDocumentation.d.ts +201 -1390
- package/dist/types/inference/money.d.ts +65 -32
- package/dist/types/inference/priceVersion.d.ts +53 -120
- package/dist/types/inference/providerConnection.d.ts +253 -710
- package/dist/types/inference/realtime.d.ts +954 -6825
- package/dist/types/inference/request.d.ts +300 -2572
- package/dist/types/inference/routingPolicy.d.ts +95 -503
- package/dist/types/inference/streamEvents.d.ts +253 -721
- package/dist/types/inference/usage.d.ts +317 -950
- package/dist/types/keyRecovery.d.ts +3 -51
- package/dist/types/keyRotation.d.ts +3 -38
- package/dist/types/linkedAccounts.d.ts +50 -236
- package/dist/types/moderationReputation.d.ts +81 -14
- package/dist/types/notifications.d.ts +19 -51
- package/dist/types/numberChecks.d.ts +9 -0
- package/dist/types/oauth.d.ts +101 -809
- package/dist/types/organizations.d.ts +268 -921
- package/dist/types/oxyRecordTypes.d.ts +11 -1
- package/dist/types/products/access.d.ts +125 -775
- package/dist/types/products/billing.d.ts +67 -503
- package/dist/types/products/checkout.d.ts +16 -69
- package/dist/types/products/plans.d.ts +33 -366
- package/dist/types/recommendations.d.ts +76 -389
- package/dist/types/reputation.d.ts +37 -5
- package/dist/types/safety.d.ts +410 -2050
- package/dist/types/serviceToken.d.ts +247 -7
- package/dist/types/sessionRevocation.d.ts +2 -17
- package/dist/types/sessionStatus.d.ts +27 -115
- package/dist/types/signIn.d.ts +53 -553
- package/dist/types/stickers.d.ts +67 -819
- package/dist/types/stringChecks.d.ts +16 -0
- package/dist/types/transparency.d.ts +14 -302
- package/dist/types/updates.d.ts +60 -316
- package/dist/types/userInvalidation.d.ts +4 -13
- package/dist/types/userResponse.d.ts +302 -2400
- package/dist/types/username.d.ts +3 -3
- package/package.json +3 -4
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck, safeNumberCheck } from '../numberChecks.js';
|
|
2
|
+
import { isoDateTime, utf16MaxLength, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* The account-scoped billing surface: who pays, what they hold, what bounds
|
|
3
5
|
* them, and how it reconciles against the payment processor.
|
|
@@ -100,8 +102,8 @@ export const billingProfileSchema = z
|
|
|
100
102
|
*/
|
|
101
103
|
creditLimit: exactDecimalSchema,
|
|
102
104
|
autoRecharge: autoRechargeSchema,
|
|
103
|
-
createdAt: z.string().
|
|
104
|
-
updatedAt: z.string().
|
|
105
|
+
createdAt: z.string().check(isoDateTime()),
|
|
106
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
105
107
|
})
|
|
106
108
|
.strict();
|
|
107
109
|
/* -------------------------------------------------------------------------- */
|
|
@@ -166,20 +168,20 @@ export const billingInvoiceSchema = z
|
|
|
166
168
|
.object({
|
|
167
169
|
/** See `version.ts`: this shape is served to Console and to Alia. */
|
|
168
170
|
schemaVersion: z.literal(1),
|
|
169
|
-
id: z.string().
|
|
171
|
+
id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
170
172
|
accountId: oxyAccountIdSchema,
|
|
171
173
|
currency: currencyCodeSchema,
|
|
172
|
-
periodStart: z.string().
|
|
173
|
-
periodEnd: z.string().
|
|
174
|
+
periodStart: z.string().check(isoDateTime()),
|
|
175
|
+
periodEnd: z.string().check(isoDateTime()),
|
|
174
176
|
status: billingInvoiceStatusSchema,
|
|
175
177
|
subtotalAmount: exactDecimalSchema,
|
|
176
178
|
totalAmount: exactDecimalSchema,
|
|
177
|
-
minorUnitExponent: z.number().
|
|
179
|
+
minorUnitExponent: z.number().check(integerCheck()).min(0).max(4),
|
|
178
180
|
/** The processor's own invoice id, for reconciliation. Never an authority. */
|
|
179
|
-
externalInvoiceRef: z.string().
|
|
180
|
-
issuedAt: z.string().
|
|
181
|
-
paidAt: z.string().
|
|
182
|
-
receiptCount: z.number().
|
|
181
|
+
externalInvoiceRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
|
|
182
|
+
issuedAt: z.string().check(isoDateTime()).optional(),
|
|
183
|
+
paidAt: z.string().check(isoDateTime()).optional(),
|
|
184
|
+
receiptCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
|
|
183
185
|
})
|
|
184
186
|
.strict();
|
|
185
187
|
/* -------------------------------------------------------------------------- */
|
|
@@ -207,16 +209,16 @@ export const externalPaymentKindSchema = z.enum(EXTERNAL_PAYMENT_KINDS);
|
|
|
207
209
|
*/
|
|
208
210
|
export const externalPaymentSchema = z
|
|
209
211
|
.object({
|
|
210
|
-
id: z.string().
|
|
212
|
+
id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
211
213
|
accountId: oxyAccountIdSchema,
|
|
212
214
|
provider: externalPaymentProviderSchema,
|
|
213
215
|
externalKind: externalPaymentKindSchema,
|
|
214
|
-
externalRef: z.string().
|
|
216
|
+
externalRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)),
|
|
215
217
|
amount: exactDecimalSchema,
|
|
216
218
|
currency: currencyCodeSchema,
|
|
217
|
-
ledgerEntryId: z.string().
|
|
218
|
-
occurredAt: z.string().
|
|
219
|
-
createdAt: z.string().
|
|
219
|
+
ledgerEntryId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
220
|
+
occurredAt: z.string().check(isoDateTime()),
|
|
221
|
+
createdAt: z.string().check(isoDateTime()),
|
|
220
222
|
})
|
|
221
223
|
.strict();
|
|
222
224
|
/** Lifecycle of one automatic top-up. */
|
|
@@ -234,18 +236,18 @@ export const autoRechargeAttemptSchema = z
|
|
|
234
236
|
.object({
|
|
235
237
|
/** See `version.ts`: this shape is served to Console and to Alia. */
|
|
236
238
|
schemaVersion: z.literal(1),
|
|
237
|
-
id: z.string().
|
|
239
|
+
id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
238
240
|
accountId: oxyAccountIdSchema,
|
|
239
241
|
currency: currencyCodeSchema,
|
|
240
242
|
requestedAmount: exactDecimalSchema,
|
|
241
243
|
/** The spendable balance that triggered it — why this attempt exists. */
|
|
242
244
|
balanceAtTrigger: exactDecimalSchema,
|
|
243
245
|
status: autoRechargeStatusSchema,
|
|
244
|
-
externalRef: z.string().
|
|
246
|
+
externalRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
|
|
245
247
|
/** The processor's own decline code. Never a free-form message. */
|
|
246
|
-
failureCode: z.string().
|
|
247
|
-
createdAt: z.string().
|
|
248
|
-
updatedAt: z.string().
|
|
248
|
+
failureCode: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)).optional(),
|
|
249
|
+
createdAt: z.string().check(isoDateTime()),
|
|
250
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
249
251
|
})
|
|
250
252
|
.strict();
|
|
251
253
|
/* -------------------------------------------------------------------------- */
|
|
@@ -280,18 +282,18 @@ export const reconciliationDiscrepancySchema = z
|
|
|
280
282
|
.object({
|
|
281
283
|
/** See `version.ts`: this shape is served to Console and to Alia. */
|
|
282
284
|
schemaVersion: z.literal(1),
|
|
283
|
-
id: z.string().
|
|
284
|
-
runId: z.string().
|
|
285
|
+
id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
286
|
+
runId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
285
287
|
kind: reconciliationDiscrepancyKindSchema,
|
|
286
288
|
accountId: oxyAccountIdSchema.optional(),
|
|
287
|
-
externalRef: z.string().
|
|
288
|
-
ledgerEntryId: z.string().
|
|
289
|
+
externalRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
|
|
290
|
+
ledgerEntryId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)).optional(),
|
|
289
291
|
/** What Oxy recorded. Absent for `missing_in_ledger`. */
|
|
290
292
|
ledgerAmount: exactDecimalSchema.optional(),
|
|
291
293
|
/** What the processor recorded. Absent for `missing_in_external`. */
|
|
292
294
|
externalAmount: exactDecimalSchema.optional(),
|
|
293
295
|
currency: currencyCodeSchema,
|
|
294
|
-
createdAt: z.string().
|
|
296
|
+
createdAt: z.string().check(isoDateTime()),
|
|
295
297
|
})
|
|
296
298
|
.strict();
|
|
297
299
|
/**
|
|
@@ -306,19 +308,19 @@ export const reconciliationRunSchema = z
|
|
|
306
308
|
.object({
|
|
307
309
|
/** See `version.ts`: this shape is served to Console and to Alia. */
|
|
308
310
|
schemaVersion: z.literal(1),
|
|
309
|
-
id: z.string().
|
|
311
|
+
id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
310
312
|
provider: externalPaymentProviderSchema,
|
|
311
313
|
/** Absent for a platform-wide pass. */
|
|
312
314
|
accountId: oxyAccountIdSchema.optional(),
|
|
313
315
|
currency: currencyCodeSchema,
|
|
314
|
-
periodStart: z.string().
|
|
315
|
-
periodEnd: z.string().
|
|
316
|
+
periodStart: z.string().check(isoDateTime()),
|
|
317
|
+
periodEnd: z.string().check(isoDateTime()),
|
|
316
318
|
status: reconciliationRunStatusSchema,
|
|
317
319
|
ledgerTotal: exactDecimalSchema,
|
|
318
320
|
externalTotal: exactDecimalSchema,
|
|
319
|
-
discrepancyCount: z.number().
|
|
320
|
-
startedAt: z.string().
|
|
321
|
-
completedAt: z.string().
|
|
321
|
+
discrepancyCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
|
|
322
|
+
startedAt: z.string().check(isoDateTime()),
|
|
323
|
+
completedAt: z.string().check(isoDateTime()).optional(),
|
|
322
324
|
})
|
|
323
325
|
.strict();
|
|
324
326
|
export const reconciliationReportSchema = z
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck, safeNumberCheck } from '../numberChecks.js';
|
|
2
|
+
import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* The signed Alia model release manifest — the ingestion contract for a
|
|
3
5
|
* first-party model release.
|
|
@@ -93,10 +95,10 @@ import { inferenceTimestampSchema, RESERVED_ALIA_PUBLISHER, sha256DigestSchema,
|
|
|
93
95
|
export const aliaReleaseArtifactSchema = z
|
|
94
96
|
.object({
|
|
95
97
|
/** Path within the release, e.g. `model-00001-of-00004.safetensors`. */
|
|
96
|
-
path: z.string().
|
|
98
|
+
path: z.string().check(utf16MinLength(1)).check(utf16MaxLength(512)),
|
|
97
99
|
digest: sha256DigestSchema,
|
|
98
|
-
sizeBytes: z.number().
|
|
99
|
-
mediaType: z.string().
|
|
100
|
+
sizeBytes: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
|
|
101
|
+
mediaType: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
|
|
100
102
|
})
|
|
101
103
|
.strict();
|
|
102
104
|
/**
|
|
@@ -125,7 +127,7 @@ export const aliaReleaseSignatureSchema = z
|
|
|
125
127
|
algorithm: z.enum(['ed25519']),
|
|
126
128
|
canonicalization: z.enum(['jcs']),
|
|
127
129
|
/** Opaque identifier of the public key. Resolving it is undecided. */
|
|
128
|
-
keyId: z.string().
|
|
130
|
+
keyId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(256)),
|
|
129
131
|
/**
|
|
130
132
|
* Unpadded base64url. Exactly 86 characters, which is a 64-byte Ed25519
|
|
131
133
|
* signature — the one algorithm above. A second algorithm moves this length
|
|
@@ -150,7 +152,7 @@ export const aliaModelReleaseManifestSchema = z
|
|
|
150
152
|
/** See `version.ts`: an ingestion payload is a whole message on the wire. */
|
|
151
153
|
schemaVersion: z.literal(1),
|
|
152
154
|
/** The release's own identity, so ingestion is idempotent on it. */
|
|
153
|
-
releaseId: z.string().
|
|
155
|
+
releaseId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
154
156
|
issuedAt: inferenceTimestampSchema,
|
|
155
157
|
/**
|
|
156
158
|
* The revision being released. Carries its OWN `schemaVersion`, like
|
|
@@ -27,15 +27,7 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import { z } from 'zod';
|
|
29
29
|
import { delegatedUserIdSchema, generationIdSchema, inferenceEnvironmentSchema, oxyAccountIdSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from './identifiers.js';
|
|
30
|
-
/**
|
|
31
|
-
* The inference capability scopes the data plane needs to know about.
|
|
32
|
-
*
|
|
33
|
-
* A credential may carry many other Oxy scopes; only these cross the boundary,
|
|
34
|
-
* because the data plane's authorization questions are exactly "may this caller
|
|
35
|
-
* invoke", "may it read the catalogue", "may it read usage", "may it read or
|
|
36
|
-
* write routing", "may it read or write provider connections". Everything else
|
|
37
|
-
* is the control plane's business and is not the data plane's to hold.
|
|
38
|
-
*/
|
|
30
|
+
/** External caller limits recorded by Oxy. First-party instructions carry no scopes. */
|
|
39
31
|
export const INFERENCE_SCOPES = [
|
|
40
32
|
'inference:invoke',
|
|
41
33
|
'inference:models:read',
|
|
@@ -70,13 +62,23 @@ export const billingPrincipalSchema = z
|
|
|
70
62
|
* envelope; it does not re-derive access from its own database, because it has
|
|
71
63
|
* no account graph to re-derive it from.
|
|
72
64
|
*/
|
|
73
|
-
|
|
65
|
+
const principalIdentity = {
|
|
74
66
|
billing: billingPrincipalSchema,
|
|
75
67
|
applicationId: oxyApplicationIdSchema,
|
|
76
68
|
credentialId: oxyCredentialIdSchema,
|
|
77
69
|
environment: inferenceEnvironmentSchema,
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
};
|
|
71
|
+
/** Oxy has authorized this instruction; the discriminator never grants customer access in Kaana. */
|
|
72
|
+
export const authenticatedPrincipalSchema = z.discriminatedUnion('authority', [
|
|
73
|
+
z.object({ ...principalIdentity, authority: z.literal('first_party') }).strict(),
|
|
74
|
+
z
|
|
75
|
+
.object({
|
|
76
|
+
...principalIdentity,
|
|
77
|
+
authority: z.literal('external').optional(),
|
|
78
|
+
inferenceScopes: z.array(inferenceScopeSchema),
|
|
79
|
+
})
|
|
80
|
+
.strict(),
|
|
81
|
+
]);
|
|
80
82
|
/**
|
|
81
83
|
* The attribution block carried by every request, receipt and ledger record.
|
|
82
84
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck, safeNumberCheck } from '../numberChecks.js';
|
|
2
|
+
import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* The canonical model catalogue.
|
|
3
5
|
*
|
|
@@ -152,8 +154,8 @@ export const modelCapabilitiesSchema = z
|
|
|
152
154
|
reasoningEfforts: z.array(reasoningEffortSchema).default([]),
|
|
153
155
|
streaming: z.boolean(),
|
|
154
156
|
promptCaching: z.boolean(),
|
|
155
|
-
maxContextTokens: z.number().
|
|
156
|
-
maxOutputTokens: z.number().
|
|
157
|
+
maxContextTokens: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
|
|
158
|
+
maxOutputTokens: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
|
|
157
159
|
/**
|
|
158
160
|
* The request dialects a route to this model can EXECUTE. Modalities say
|
|
159
161
|
* what a model consumes and produces; they do not say which request shape a
|
|
@@ -216,8 +218,8 @@ export const modelCapabilitiesSchema = z
|
|
|
216
218
|
export const modelLicenseSchema = z
|
|
217
219
|
.object({
|
|
218
220
|
/** SPDX identifier where one exists, otherwise the publisher's own name. */
|
|
219
|
-
licenseId: z.string().
|
|
220
|
-
displayName: z.string().
|
|
221
|
+
licenseId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
222
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
221
223
|
url: inferenceHttpsUrlSchema.optional(),
|
|
222
224
|
commercialUseAllowed: z.boolean(),
|
|
223
225
|
requiresAttribution: z.boolean(),
|
|
@@ -241,7 +243,7 @@ export const modelProvenanceSchema = z
|
|
|
241
243
|
]),
|
|
242
244
|
/** The model this one was derived/fine-tuned from, where there is one. */
|
|
243
245
|
baseModelId: modelIdSchema.optional(),
|
|
244
|
-
trainingOrganization: z.string().
|
|
246
|
+
trainingOrganization: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)).optional(),
|
|
245
247
|
})
|
|
246
248
|
.strict();
|
|
247
249
|
/**
|
|
@@ -254,11 +256,13 @@ export const inferenceDataPolicySchema = z
|
|
|
254
256
|
.object({
|
|
255
257
|
retainsPayloads: z.boolean(),
|
|
256
258
|
/** Zero when nothing is retained. */
|
|
257
|
-
retentionDays: z.number().
|
|
259
|
+
retentionDays: z.number().check(integerCheck()).nonnegative().max(3650),
|
|
258
260
|
trainsOnCustomerData: z.boolean(),
|
|
259
261
|
zeroDataRetentionAvailable: z.boolean(),
|
|
260
262
|
/** Named subprocessors a payload may pass through, for compliance review. */
|
|
261
|
-
subprocessors: z
|
|
263
|
+
subprocessors: z
|
|
264
|
+
.array(z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)))
|
|
265
|
+
.default([]),
|
|
262
266
|
policyUrl: inferenceHttpsUrlSchema.optional(),
|
|
263
267
|
})
|
|
264
268
|
.strict()
|
|
@@ -323,10 +327,10 @@ export const modelDeprecationSchema = z
|
|
|
323
327
|
/** One published evaluation result for a revision. */
|
|
324
328
|
export const modelEvaluationResultSchema = z
|
|
325
329
|
.object({
|
|
326
|
-
suite: z.string().
|
|
327
|
-
metric: z.string().
|
|
330
|
+
suite: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
331
|
+
metric: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
328
332
|
/** Kept as a string: an eval score is published text, not arithmetic. */
|
|
329
|
-
score: z.string().
|
|
333
|
+
score: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
330
334
|
evaluatedAt: inferenceTimestampSchema.optional(),
|
|
331
335
|
reportUrl: inferenceHttpsUrlSchema.optional(),
|
|
332
336
|
})
|
|
@@ -339,7 +343,9 @@ export const modelSafetyMetadataSchema = z
|
|
|
339
343
|
.object({
|
|
340
344
|
safetyCardUrl: inferenceHttpsUrlSchema.optional(),
|
|
341
345
|
contentFilteringDefault: z.enum(['none', 'provider_default', 'strict']),
|
|
342
|
-
knownLimitations: z
|
|
346
|
+
knownLimitations: z
|
|
347
|
+
.array(z.string().check(utf16MinLength(1)).check(utf16MaxLength(500)))
|
|
348
|
+
.default([]),
|
|
343
349
|
/** Content-provenance marking the modality requires, where it requires one. */
|
|
344
350
|
provenanceMarking: z.enum(['none', 'visible_watermark', 'invisible_watermark', 'c2pa']),
|
|
345
351
|
})
|
|
@@ -351,10 +357,10 @@ export const modelSafetyMetadataSchema = z
|
|
|
351
357
|
export const modelPublisherSchema = z.object({
|
|
352
358
|
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
353
359
|
schemaVersion: z.literal(1),
|
|
354
|
-
publisherId: z.string().
|
|
360
|
+
publisherId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
355
361
|
slug: publisherSlugSchema,
|
|
356
|
-
displayName: z.string().
|
|
357
|
-
description: z.string().
|
|
362
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
363
|
+
description: z.string().check(utf16MaxLength(2000)).optional(),
|
|
358
364
|
websiteUrl: inferenceHttpsUrlSchema.optional(),
|
|
359
365
|
});
|
|
360
366
|
/* -------------------------------------------------------------------------- */
|
|
@@ -374,8 +380,8 @@ export const catalogueModelSchema = z
|
|
|
374
380
|
modelId: modelIdSchema,
|
|
375
381
|
publisher: publisherSlugSchema,
|
|
376
382
|
slug: modelSlugSchema,
|
|
377
|
-
displayName: z.string().
|
|
378
|
-
description: z.string().
|
|
383
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
384
|
+
description: z.string().check(utf16MaxLength(4000)).optional(),
|
|
379
385
|
capabilities: modelCapabilitiesSchema,
|
|
380
386
|
license: modelLicenseSchema,
|
|
381
387
|
provenance: modelProvenanceSchema,
|
|
@@ -421,7 +427,7 @@ export const modelRevisionSchema = z
|
|
|
421
427
|
.object({
|
|
422
428
|
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
423
429
|
schemaVersion: z.literal(1),
|
|
424
|
-
revisionId: z.string().
|
|
430
|
+
revisionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
425
431
|
modelId: modelIdSchema,
|
|
426
432
|
revision: modelRevisionLabelSchema,
|
|
427
433
|
reference: modelReferenceSchema,
|
|
@@ -449,9 +455,9 @@ export const modelRevisionSchema = z
|
|
|
449
455
|
export const inferenceProviderSchema = z.object({
|
|
450
456
|
/** See `version.ts`: served on its own by the catalogue, so it is versioned. */
|
|
451
457
|
schemaVersion: z.literal(1),
|
|
452
|
-
providerId: z.string().
|
|
458
|
+
providerId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
453
459
|
slug: inferenceProviderSlugSchema,
|
|
454
|
-
displayName: z.string().
|
|
460
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
455
461
|
/**
|
|
456
462
|
* `customer_byok` means the customer's own upstream account is billed
|
|
457
463
|
* directly by the provider and Oxy charges only its platform fee.
|
|
@@ -494,7 +500,7 @@ export const modelDeploymentSchema = z
|
|
|
494
500
|
/** Reserved capacity for one enterprise account rather than shared. */
|
|
495
501
|
dedicatedCapacity: z.boolean(),
|
|
496
502
|
/** The price version customers are charged under on this route. */
|
|
497
|
-
priceVersionId: z.string().
|
|
503
|
+
priceVersionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)).optional(),
|
|
498
504
|
})
|
|
499
505
|
.superRefine((deployment, ctx) => {
|
|
500
506
|
if (!deployment.modelReference.includes('@')) {
|
|
@@ -545,7 +551,7 @@ export const routingProfileCandidateSchema = z
|
|
|
545
551
|
.object({
|
|
546
552
|
modelReference: modelReferenceSchema,
|
|
547
553
|
/** Lower sorts first. Ties are broken by the profile's optimisation target. */
|
|
548
|
-
priority: z.number().
|
|
554
|
+
priority: z.number().check(integerCheck()).nonnegative().max(1000),
|
|
549
555
|
})
|
|
550
556
|
.strict();
|
|
551
557
|
/**
|
|
@@ -561,8 +567,8 @@ export const routingProfileSchema = z.object({
|
|
|
561
567
|
schemaVersion: z.literal(1),
|
|
562
568
|
routingProfileId: routingProfileIdSchema,
|
|
563
569
|
slug: routingProfileSlugSchema,
|
|
564
|
-
displayName: z.string().
|
|
565
|
-
description: z.string().
|
|
570
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
571
|
+
description: z.string().check(utf16MaxLength(2000)).optional(),
|
|
566
572
|
/** What the profile optimises for when several candidates qualify. */
|
|
567
573
|
optimiseFor: z.enum(['price', 'latency', 'throughput', 'quality', 'balanced']),
|
|
568
574
|
candidates: z.array(routingProfileCandidateSchema).min(1),
|
|
@@ -590,7 +596,7 @@ export const routingProfileSchema = z.object({
|
|
|
590
596
|
export const cataloguePublisherSummarySchema = z
|
|
591
597
|
.object({
|
|
592
598
|
slug: publisherSlugSchema,
|
|
593
|
-
displayName: z.string().
|
|
599
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
594
600
|
websiteUrl: inferenceHttpsUrlSchema.optional(),
|
|
595
601
|
})
|
|
596
602
|
.strict();
|
|
@@ -604,7 +610,7 @@ export const cataloguePublisherSummarySchema = z
|
|
|
604
610
|
export const catalogueServingProviderSummarySchema = z
|
|
605
611
|
.object({
|
|
606
612
|
slug: inferenceProviderSlugSchema,
|
|
607
|
-
displayName: z.string().
|
|
613
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
608
614
|
regions: z.array(inferenceRegionSchema).default([]),
|
|
609
615
|
dataPolicy: inferenceDataPolicySchema,
|
|
610
616
|
})
|
|
@@ -621,8 +627,8 @@ export const modelCatalogueEntrySchema = z.object({
|
|
|
621
627
|
schemaVersion: z.literal(3),
|
|
622
628
|
modelId: modelIdSchema,
|
|
623
629
|
publisher: cataloguePublisherSummarySchema,
|
|
624
|
-
displayName: z.string().
|
|
625
|
-
description: z.string().
|
|
630
|
+
displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
|
|
631
|
+
description: z.string().check(utf16MaxLength(4000)).optional(),
|
|
626
632
|
currentRevision: modelRevisionLabelSchema,
|
|
627
633
|
/** Revisions a customer may pin today, newest first. */
|
|
628
634
|
availableRevisions: z.array(modelRevisionLabelSchema).min(1),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck, safeNumberCheck } from '../numberChecks.js';
|
|
2
|
+
import { isoDateTime, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* Economic treatment and durable usage/cost reporting for inference
|
|
3
5
|
* (issue #1526, plan item I09).
|
|
@@ -41,7 +43,7 @@ export const inferenceEconomicTreatmentSchema = z.enum(INFERENCE_ECONOMIC_TREATM
|
|
|
41
43
|
*/
|
|
42
44
|
export const PROVIDER_COST_SOURCES = ['provider_reported', 'rate_card', 'unknown'];
|
|
43
45
|
export const providerCostSourceSchema = z.enum(PROVIDER_COST_SOURCES);
|
|
44
|
-
const nonNegativeCount = z.number().
|
|
46
|
+
const nonNegativeCount = z.number().check(integerCheck()).nonnegative().check(safeNumberCheck());
|
|
45
47
|
/** One amount family, with the rows it could not include counted beside it. */
|
|
46
48
|
const knownAmountSchema = z
|
|
47
49
|
.object({
|
|
@@ -66,8 +68,8 @@ export const costCenterUsageSchema = z
|
|
|
66
68
|
costCenter: costCenterSchema.nullable(),
|
|
67
69
|
treatment: inferenceEconomicTreatmentSchema,
|
|
68
70
|
currency: currencyCodeSchema,
|
|
69
|
-
periodStart: z.string().
|
|
70
|
-
periodEnd: z.string().
|
|
71
|
+
periodStart: z.string().check(isoDateTime()),
|
|
72
|
+
periodEnd: z.string().check(isoDateTime()),
|
|
71
73
|
/** Requests settled in the window (completed, failed, cancelled or partial). */
|
|
72
74
|
requestCount: nonNegativeCount,
|
|
73
75
|
/** Requests admitted and not yet settled when the report was read. */
|
|
@@ -87,10 +89,10 @@ export const costCenterUsageSchema = z
|
|
|
87
89
|
/** Attempts priced in a different currency, excluded without currency conversion. */
|
|
88
90
|
otherCurrencyCount: nonNegativeCount.default(0),
|
|
89
91
|
/** Amount stated by the provider; this is not a copy of its invoice. */
|
|
90
|
-
providerReportedAmount: exactDecimalSchema.
|
|
92
|
+
providerReportedAmount: exactDecimalSchema.prefault('0'),
|
|
91
93
|
providerReportedCount: nonNegativeCount.default(0),
|
|
92
94
|
/** Amount estimated from Kaana's immutable rate card, never described as invoiced. */
|
|
93
|
-
estimatedAmount: exactDecimalSchema.
|
|
95
|
+
estimatedAmount: exactDecimalSchema.prefault('0'),
|
|
94
96
|
estimatedCount: nonNegativeCount.default(0),
|
|
95
97
|
}),
|
|
96
98
|
/**
|
|
@@ -108,35 +110,38 @@ export const meteredGenerationSchema = z
|
|
|
108
110
|
.object({
|
|
109
111
|
schemaVersion: z.literal(2),
|
|
110
112
|
kind: z.literal('metered_usage'),
|
|
111
|
-
meteredUsageId: z.string().
|
|
112
|
-
requestId: z.string().
|
|
113
|
-
generationId: z.string().
|
|
114
|
-
parentRequestId: z.string().
|
|
115
|
-
applicationId: z.string().
|
|
116
|
-
credentialId: z.string().
|
|
117
|
-
delegatedUserId: z.string().
|
|
113
|
+
meteredUsageId: z.string().check(utf16MinLength(1)),
|
|
114
|
+
requestId: z.string().check(utf16MinLength(1)),
|
|
115
|
+
generationId: z.string().check(utf16MinLength(1)).optional(),
|
|
116
|
+
parentRequestId: z.string().check(utf16MinLength(1)).optional(),
|
|
117
|
+
applicationId: z.string().check(utf16MinLength(1)),
|
|
118
|
+
credentialId: z.string().check(utf16MinLength(1)),
|
|
119
|
+
delegatedUserId: z.string().check(utf16MinLength(1)).optional(),
|
|
118
120
|
environment: inferenceEnvironmentSchema,
|
|
119
121
|
economicTreatment: z.literal('internal_metered'),
|
|
120
|
-
economicPolicyVersion: z.string().
|
|
122
|
+
economicPolicyVersion: z.string().check(utf16MinLength(1)),
|
|
121
123
|
outcome: inferenceRequestOutcomeSchema,
|
|
122
124
|
usageSource: usageSourceSchema,
|
|
123
125
|
units: z.array(usageQuantitySchema),
|
|
124
126
|
resolvedModelReference: modelReferenceSchema,
|
|
125
|
-
servingProvider: z.string().
|
|
127
|
+
servingProvider: z.string().check(utf16MinLength(1)),
|
|
126
128
|
tariff: z.discriminatedUnion('status', [
|
|
127
129
|
z
|
|
128
130
|
.object({
|
|
129
131
|
status: z.literal('quoted'),
|
|
130
132
|
amount: exactDecimalSchema,
|
|
131
133
|
currency: currencyCodeSchema,
|
|
132
|
-
priceVersionId: z.string().
|
|
134
|
+
priceVersionId: z.string().check(utf16MinLength(1)),
|
|
133
135
|
})
|
|
134
136
|
.strict(),
|
|
135
137
|
z
|
|
136
|
-
.object({
|
|
138
|
+
.object({
|
|
139
|
+
status: z.literal('unpriced'),
|
|
140
|
+
priceVersionId: z.string().check(utf16MinLength(1)).nullable(),
|
|
141
|
+
})
|
|
137
142
|
.strict(),
|
|
138
143
|
]),
|
|
139
144
|
customerCharge: z.object({ status: z.literal('not_charged') }).strict(),
|
|
140
|
-
settledAt: z.string().
|
|
145
|
+
settledAt: z.string().check(isoDateTime()),
|
|
141
146
|
})
|
|
142
147
|
.strict();
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { integerCheck } from '../numberChecks.js';
|
|
2
|
+
import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
import { z } from 'zod';
|
|
2
4
|
import { inferenceErrorSchema } from './errors.js';
|
|
3
5
|
export const embeddingVectorSchema = z
|
|
4
6
|
.object({
|
|
5
|
-
index: z.number().
|
|
7
|
+
index: z.number().check(integerCheck()).nonnegative(),
|
|
6
8
|
embedding: z.array(z.number().finite()).min(1).max(1024),
|
|
7
9
|
})
|
|
8
10
|
.strict();
|
|
9
11
|
export const embeddingUsageSchema = z
|
|
10
12
|
.object({
|
|
11
|
-
inputTokens: z.number().
|
|
12
|
-
totalTokens: z.number().
|
|
13
|
+
inputTokens: z.number().check(integerCheck()).nonnegative(),
|
|
14
|
+
totalTokens: z.number().check(integerCheck()).nonnegative(),
|
|
13
15
|
})
|
|
14
16
|
.strict()
|
|
15
17
|
.refine((usage) => usage.totalTokens >= usage.inputTokens, {
|
|
@@ -19,9 +21,9 @@ export const embeddingUsageSchema = z
|
|
|
19
21
|
export const embeddingSuccessSchema = z
|
|
20
22
|
.object({
|
|
21
23
|
schemaVersion: z.literal(1),
|
|
22
|
-
requestId: z.string().
|
|
23
|
-
model: z.string().
|
|
24
|
-
dimension: z.number().
|
|
24
|
+
requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
25
|
+
model: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)),
|
|
26
|
+
dimension: z.number().check(integerCheck()).positive().max(1024),
|
|
25
27
|
data: z.array(embeddingVectorSchema).min(1).max(2048),
|
|
26
28
|
usage: embeddingUsageSchema,
|
|
27
29
|
})
|
|
@@ -47,7 +49,7 @@ export const embeddingSuccessSchema = z
|
|
|
47
49
|
export const embeddingFailureSchema = z
|
|
48
50
|
.object({
|
|
49
51
|
schemaVersion: z.literal(1),
|
|
50
|
-
requestId: z.string().
|
|
52
|
+
requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
|
|
51
53
|
error: inferenceErrorSchema,
|
|
52
54
|
})
|
|
53
55
|
.strict();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck, safeNumberCheck } from '../numberChecks.js';
|
|
2
|
+
import { isoDateTime, utf16MaxLength, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* Product entitlements — the interface a first-party product (Alia) queries to
|
|
3
5
|
* learn what an account is entitled to, WITHOUT learning anything it could
|
|
@@ -87,8 +89,8 @@ export const planAllowanceSchema = z
|
|
|
87
89
|
/** A stable machine name, e.g. `api_credits_per_month`. */
|
|
88
90
|
key: z.string().regex(/^[a-z][a-z0-9_]{0,62}$/),
|
|
89
91
|
/** Whole units included per period. Never money. */
|
|
90
|
-
included: z.number().
|
|
91
|
-
remaining: z.number().
|
|
92
|
+
included: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
|
|
93
|
+
remaining: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()).optional(),
|
|
92
94
|
})
|
|
93
95
|
.strict();
|
|
94
96
|
/**
|
|
@@ -101,12 +103,12 @@ export const planAllowanceSchema = z
|
|
|
101
103
|
*/
|
|
102
104
|
export const productPlanSchema = z
|
|
103
105
|
.object({
|
|
104
|
-
id: z.string().
|
|
105
|
-
name: z.string().
|
|
106
|
+
id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
|
|
107
|
+
name: z.string().check(utf16MinLength(1)).check(utf16MaxLength(120)),
|
|
106
108
|
status: productPlanStatusSchema,
|
|
107
109
|
live: z.boolean(),
|
|
108
|
-
currentPeriodStart: z.string().
|
|
109
|
-
currentPeriodEnd: z.string().
|
|
110
|
+
currentPeriodStart: z.string().check(isoDateTime()),
|
|
111
|
+
currentPeriodEnd: z.string().check(isoDateTime()),
|
|
110
112
|
cancelAtPeriodEnd: z.boolean(),
|
|
111
113
|
allowances: z.array(planAllowanceSchema),
|
|
112
114
|
})
|
|
@@ -156,10 +158,10 @@ export const costCenterSchema = z
|
|
|
156
158
|
schemaVersion: z.literal(1),
|
|
157
159
|
accountId: oxyAccountIdSchema,
|
|
158
160
|
slug: z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/),
|
|
159
|
-
label: z.string().
|
|
161
|
+
label: z.string().check(utf16MinLength(1)).check(utf16MaxLength(120)),
|
|
160
162
|
status: costCenterStatusSchema,
|
|
161
|
-
createdAt: z.string().
|
|
162
|
-
updatedAt: z.string().
|
|
163
|
+
createdAt: z.string().check(isoDateTime()),
|
|
164
|
+
updatedAt: z.string().check(isoDateTime()),
|
|
163
165
|
})
|
|
164
166
|
.strict();
|
|
165
167
|
/**
|
|
@@ -175,10 +177,10 @@ export const costCenterSpendSchema = z
|
|
|
175
177
|
schemaVersion: z.literal(1),
|
|
176
178
|
costCenter: costCenterSchema,
|
|
177
179
|
currency: currencyCodeSchema,
|
|
178
|
-
periodStart: z.string().
|
|
179
|
-
periodEnd: z.string().
|
|
180
|
+
periodStart: z.string().check(isoDateTime()),
|
|
181
|
+
periodEnd: z.string().check(isoDateTime()),
|
|
180
182
|
billedAmount: exactDecimalSchema,
|
|
181
|
-
requestCount: z.number().
|
|
183
|
+
requestCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
|
|
182
184
|
})
|
|
183
185
|
.strict();
|
|
184
186
|
/* -------------------------------------------------------------------------- */
|
|
@@ -209,6 +211,6 @@ export const productEntitlementSchema = z
|
|
|
209
211
|
payAsYouGo: payAsYouGoEntitlementSchema.nullable(),
|
|
210
212
|
costCenter: costCenterSchema.nullable(),
|
|
211
213
|
/** When this view was computed. Entitlements are eventually consistent. */
|
|
212
|
-
resolvedAt: z.string().
|
|
214
|
+
resolvedAt: z.string().check(isoDateTime()),
|
|
213
215
|
})
|
|
214
216
|
.strict();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { integerCheck, safeNumberCheck } from '../numberChecks.js';
|
|
2
|
+
import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
|
|
1
3
|
/**
|
|
2
4
|
* Inference errors and retryability.
|
|
3
5
|
*
|
|
@@ -223,8 +225,8 @@ const CREDENTIAL_PATTERNS = [
|
|
|
223
225
|
*/
|
|
224
226
|
export const safeErrorTextSchema = z
|
|
225
227
|
.string()
|
|
226
|
-
.
|
|
227
|
-
.
|
|
228
|
+
.check(utf16MinLength(1))
|
|
229
|
+
.check(utf16MaxLength(2000))
|
|
228
230
|
.refine((value) => !CREDENTIAL_PATTERNS.some((pattern) => pattern.test(value)), 'error text must not contain credential-shaped material');
|
|
229
231
|
/**
|
|
230
232
|
* A coarse classification of an upstream failure (ADR 0010's `upstreamCategory`).
|
|
@@ -258,9 +260,9 @@ export const providerErrorPassthroughSchema = z
|
|
|
258
260
|
.object({
|
|
259
261
|
provider: inferenceProviderSlugSchema,
|
|
260
262
|
/** The upstream HTTP status, when the upstream spoke HTTP. */
|
|
261
|
-
status: z.number().
|
|
263
|
+
status: z.number().check(integerCheck()).min(100).max(599).optional(),
|
|
262
264
|
/** The upstream's own error code, verbatim and uninterpreted. */
|
|
263
|
-
code: z.string().
|
|
265
|
+
code: z.string().check(utf16MaxLength(128)).optional(),
|
|
264
266
|
/** The upstream's message, subject to the same credential refusal. */
|
|
265
267
|
message: safeErrorTextSchema.optional(),
|
|
266
268
|
})
|
|
@@ -281,9 +283,14 @@ export const inferenceErrorSchema = z
|
|
|
281
283
|
retryable: z.boolean(),
|
|
282
284
|
requestId: requestIdSchema,
|
|
283
285
|
/** How long to wait before retrying. Only meaningful when `retryable`. */
|
|
284
|
-
retryAfterMs: z
|
|
286
|
+
retryAfterMs: z
|
|
287
|
+
.number()
|
|
288
|
+
.check(integerCheck())
|
|
289
|
+
.nonnegative()
|
|
290
|
+
.check(safeNumberCheck())
|
|
291
|
+
.optional(),
|
|
285
292
|
/** The request field at fault, for `invalid_request`. */
|
|
286
|
-
param: z.string().
|
|
293
|
+
param: z.string().check(utf16MaxLength(128)).optional(),
|
|
287
294
|
/** Present only when an upstream provider was reached and failed. */
|
|
288
295
|
upstreamCategory: upstreamErrorCategorySchema.optional(),
|
|
289
296
|
providerError: providerErrorPassthroughSchema.optional(),
|