@dork-labs/cloud-api 0.75.1
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 +21 -0
- package/README.md +192 -0
- package/dist/billing.d.ts +328 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +267 -0
- package/dist/billing.js.map +1 -0
- package/dist/client.d.ts +130 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +192 -0
- package/dist/client.js.map +1 -0
- package/dist/connections.d.ts +281 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +241 -0
- package/dist/connections.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/inference.d.ts +123 -0
- package/dist/inference.d.ts.map +1 -0
- package/dist/inference.js +114 -0
- package/dist/inference.js.map +1 -0
- package/dist/instances.d.ts +60 -0
- package/dist/instances.d.ts.map +1 -0
- package/dist/instances.js +65 -0
- package/dist/instances.js.map +1 -0
- package/dist/primitives.d.ts +74 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +98 -0
- package/dist/primitives.js.map +1 -0
- package/dist/problem.d.ts +96 -0
- package/dist/problem.d.ts.map +1 -0
- package/dist/problem.js +94 -0
- package/dist/problem.js.map +1 -0
- package/dist/remote.d.ts +268 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +267 -0
- package/dist/remote.js.map +1 -0
- package/dist/routes.d.ts +273 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +302 -0
- package/dist/routes.js.map +1 -0
- package/dist/seats.d.ts +529 -0
- package/dist/seats.d.ts.map +1 -0
- package/dist/seats.js +266 -0
- package/dist/seats.js.map +1 -0
- package/dist/session.d.ts +135 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +143 -0
- package/dist/session.js.map +1 -0
- package/fixtures/v1/billing/balance-owed.json +16 -0
- package/fixtures/v1/billing/balance.json +16 -0
- package/fixtures/v1/billing/entitlements-free.json +34 -0
- package/fixtures/v1/billing/hosted-page.json +3 -0
- package/fixtures/v1/billing/nudge.json +9 -0
- package/fixtures/v1/billing/price-list.json +13 -0
- package/fixtures/v1/billing/statement.json +5 -0
- package/fixtures/v1/billing/usage-by-model.json +21 -0
- package/fixtures/v1/connections/catalog.json +12 -0
- package/fixtures/v1/connections/events-ack.json +3 -0
- package/fixtures/v1/connections/events-pull.json +16 -0
- package/fixtures/v1/connections/execution.json +12 -0
- package/fixtures/v1/connections/list.json +16 -0
- package/fixtures/v1/connections/usage.json +16 -0
- package/fixtures/v1/index.json +58 -0
- package/fixtures/v1/inference/models.json +17 -0
- package/fixtures/v1/inference/token-revoke.json +3 -0
- package/fixtures/v1/inference/token.json +14 -0
- package/fixtures/v1/instances/heartbeat.json +5 -0
- package/fixtures/v1/instances/list.json +15 -0
- package/fixtures/v1/instances/revoke.json +3 -0
- package/fixtures/v1/problem/handle-tombstoned.json +6 -0
- package/fixtures/v1/problem/person-seat-required.json +7 -0
- package/fixtures/v1/problem/unauthenticated.json +7 -0
- package/fixtures/v1/remote/address.json +5 -0
- package/fixtures/v1/remote/command-keepalive.json +4 -0
- package/fixtures/v1/remote/command-open.json +6 -0
- package/fixtures/v1/remote/commands-ack.json +3 -0
- package/fixtures/v1/remote/credential.json +7 -0
- package/fixtures/v1/remote/custom-address.json +12 -0
- package/fixtures/v1/remote/designation.json +5 -0
- package/fixtures/v1/remote/enrolment.json +5 -0
- package/fixtures/v1/remote/events.json +3 -0
- package/fixtures/v1/remote/open.json +5 -0
- package/fixtures/v1/remote/status-closed.json +7 -0
- package/fixtures/v1/remote/status-open.json +10 -0
- package/fixtures/v1/remote/wake-token.json +5 -0
- package/fixtures/v1/seats/addons.json +11 -0
- package/fixtures/v1/seats/agent.json +9 -0
- package/fixtures/v1/seats/grants.json +20 -0
- package/fixtures/v1/seats/inbox-browse.json +17 -0
- package/fixtures/v1/seats/inbox-pull.json +17 -0
- package/fixtures/v1/seats/invitation.json +9 -0
- package/fixtures/v1/seats/members.json +12 -0
- package/fixtures/v1/seats/org.json +7 -0
- package/fixtures/v1/seats/presence.json +6 -0
- package/fixtures/v1/seats/seat.json +21 -0
- package/fixtures/v1/session/account-export.json +6 -0
- package/fixtures/v1/session/device-code.json +8 -0
- package/fixtures/v1/session/device-token-pending.json +4 -0
- package/fixtures/v1/session/device-token.json +7 -0
- package/fixtures/v1/session/signed-in.json +14 -0
- package/fixtures/v1/session/signed-out.json +4 -0
- package/package.json +58 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* `POST /v1/inference/tokens` — mint a short-lived inference token.
|
|
4
|
+
*
|
|
5
|
+
* The caller is taken from the bearer credential; `seatRef` and `agentRef` only
|
|
6
|
+
* narrow it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const InferenceTokenRequestSchema: z.ZodObject<{
|
|
9
|
+
instanceId: z.ZodString;
|
|
10
|
+
seatRef: z.ZodOptional<z.ZodString>;
|
|
11
|
+
agentRef: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
/**
|
|
14
|
+
* The endpoints a minted token may be used against.
|
|
15
|
+
*
|
|
16
|
+
* Runtime values. No host, origin or URL literal belongs in this package, and
|
|
17
|
+
* which provider serves a request is not part of this contract.
|
|
18
|
+
*/
|
|
19
|
+
export declare const InferenceEndpointsSchema: z.ZodObject<{
|
|
20
|
+
anthropicMessages: z.ZodString;
|
|
21
|
+
openaiChat: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
/** What a minted token is allowed to do at once. */
|
|
24
|
+
export declare const InferenceLimitsSchema: z.ZodObject<{
|
|
25
|
+
concurrentStreams: z.ZodNumber;
|
|
26
|
+
requestsPerMinute: z.ZodNumber;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
/**
|
|
29
|
+
* A minted inference token.
|
|
30
|
+
*
|
|
31
|
+
* `token` is a credential returned once. Consumers hold it as a credential
|
|
32
|
+
* reference, never as a configuration string, and never log it.
|
|
33
|
+
*
|
|
34
|
+
* No price, rate, multiplier or unit cost appears on this route. The published
|
|
35
|
+
* price list is the one place a price belongs.
|
|
36
|
+
*/
|
|
37
|
+
export declare const InferenceTokenSchema: z.ZodObject<{
|
|
38
|
+
tokenId: z.ZodString;
|
|
39
|
+
token: z.ZodString;
|
|
40
|
+
expiresAt: z.ZodISODateTime;
|
|
41
|
+
endpoints: z.ZodObject<{
|
|
42
|
+
anthropicMessages: z.ZodString;
|
|
43
|
+
openaiChat: z.ZodString;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
limits: z.ZodObject<{
|
|
46
|
+
concurrentStreams: z.ZodNumber;
|
|
47
|
+
requestsPerMinute: z.ZodNumber;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
catalogVersion: z.ZodString;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/** A minted inference token. */
|
|
52
|
+
export type InferenceToken = z.infer<typeof InferenceTokenSchema>;
|
|
53
|
+
/**
|
|
54
|
+
* What one routed model supports.
|
|
55
|
+
*
|
|
56
|
+
* Booleans, and mechanism rather than catalog: they say what a caller may send,
|
|
57
|
+
* not which model it is or who serves it.
|
|
58
|
+
*/
|
|
59
|
+
export declare const ModelSupportsSchema: z.ZodObject<{
|
|
60
|
+
tools: z.ZodBoolean;
|
|
61
|
+
promptCaching: z.ZodBoolean;
|
|
62
|
+
streaming: z.ZodBoolean;
|
|
63
|
+
thinking: z.ZodBoolean;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
/**
|
|
66
|
+
* One routed model.
|
|
67
|
+
*
|
|
68
|
+
* `id` is an opaque string. Publishing the set of routed models would freeze
|
|
69
|
+
* the catalog into a `.d.ts` on public npm, and read beside the published price
|
|
70
|
+
* list it would say more than the list does.
|
|
71
|
+
*/
|
|
72
|
+
export declare const InferenceModelSchema: z.ZodObject<{
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
displayName: z.ZodString;
|
|
75
|
+
contextWindow: z.ZodNumber;
|
|
76
|
+
maxOutputTokens: z.ZodNumber;
|
|
77
|
+
supports: z.ZodObject<{
|
|
78
|
+
tools: z.ZodBoolean;
|
|
79
|
+
promptCaching: z.ZodBoolean;
|
|
80
|
+
streaming: z.ZodBoolean;
|
|
81
|
+
thinking: z.ZodBoolean;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
/** One routed model. */
|
|
85
|
+
export type InferenceModel = z.infer<typeof InferenceModelSchema>;
|
|
86
|
+
/** `GET /v1/inference/models` — the models this caller may route to. */
|
|
87
|
+
export declare const InferenceModelsResponseSchema: z.ZodObject<{
|
|
88
|
+
catalogVersion: z.ZodString;
|
|
89
|
+
models: z.ZodArray<z.ZodObject<{
|
|
90
|
+
id: z.ZodString;
|
|
91
|
+
displayName: z.ZodString;
|
|
92
|
+
contextWindow: z.ZodNumber;
|
|
93
|
+
maxOutputTokens: z.ZodNumber;
|
|
94
|
+
supports: z.ZodObject<{
|
|
95
|
+
tools: z.ZodBoolean;
|
|
96
|
+
promptCaching: z.ZodBoolean;
|
|
97
|
+
streaming: z.ZodBoolean;
|
|
98
|
+
thinking: z.ZodBoolean;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
/** `POST /v1/inference/tokens/{tokenId}/revoke`. */
|
|
103
|
+
export declare const InferenceTokenRevokeResponseSchema: z.ZodObject<{
|
|
104
|
+
revoked: z.ZodBoolean;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
/**
|
|
107
|
+
* Why an inference request was refused.
|
|
108
|
+
*
|
|
109
|
+
* Mechanism: each value names a condition a caller can act on, and none of them
|
|
110
|
+
* names a subscription, a model or a supplier.
|
|
111
|
+
*/
|
|
112
|
+
export declare const InferenceRefusalReasonSchema: z.ZodEnum<{
|
|
113
|
+
rate_limited: "rate_limited";
|
|
114
|
+
entitlement_required: "entitlement_required";
|
|
115
|
+
balance_exhausted: "balance_exhausted";
|
|
116
|
+
concurrency_exceeded: "concurrency_exceeded";
|
|
117
|
+
model_unavailable: "model_unavailable";
|
|
118
|
+
token_revoked: "token_revoked";
|
|
119
|
+
token_expired: "token_expired";
|
|
120
|
+
}>;
|
|
121
|
+
/** Why an inference request was refused. */
|
|
122
|
+
export type InferenceRefusalReason = z.infer<typeof InferenceRefusalReasonSchema>;
|
|
123
|
+
//# sourceMappingURL=inference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../src/inference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B;;;;iBAM2B,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;iBAOlC,CAAC;AAEJ,oDAAoD;AACpD,eAAO,MAAM,qBAAqB;;;iBAKsC,CAAC;AAEzE;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;iBAa9B,CAAC;AAEJ,gCAAgC;AAChC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB;;;;;iBAOsC,CAAC;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;iBAUsD,CAAC;AAExF,wBAAwB;AACxB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,wEAAwE;AACxE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;iBAOvC,CAAC;AAEJ,oDAAoD;AACpD,eAAO,MAAM,kCAAkC;;iBAEoD,CAAC;AAEpG;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;EAYtC,CAAC;AAEJ,4CAA4C;AAC5C,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IdSchema, SecretValueSchema, TimestampSchema } from './primitives.js';
|
|
3
|
+
/**
|
|
4
|
+
* `POST /v1/inference/tokens` — mint a short-lived inference token.
|
|
5
|
+
*
|
|
6
|
+
* The caller is taken from the bearer credential; `seatRef` and `agentRef` only
|
|
7
|
+
* narrow it.
|
|
8
|
+
*/
|
|
9
|
+
export const InferenceTokenRequestSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
instanceId: IdSchema,
|
|
12
|
+
seatRef: IdSchema.optional(),
|
|
13
|
+
agentRef: IdSchema.optional(),
|
|
14
|
+
})
|
|
15
|
+
.describe('Mint a short-lived inference token for one instance.');
|
|
16
|
+
/**
|
|
17
|
+
* The endpoints a minted token may be used against.
|
|
18
|
+
*
|
|
19
|
+
* Runtime values. No host, origin or URL literal belongs in this package, and
|
|
20
|
+
* which provider serves a request is not part of this contract.
|
|
21
|
+
*/
|
|
22
|
+
export const InferenceEndpointsSchema = z
|
|
23
|
+
.object({
|
|
24
|
+
anthropicMessages: z.string().url(),
|
|
25
|
+
openaiChat: z.string().url(),
|
|
26
|
+
})
|
|
27
|
+
.describe('Where to send inference requests. Runtime values; no origin is baked into this package.');
|
|
28
|
+
/** What a minted token is allowed to do at once. */
|
|
29
|
+
export const InferenceLimitsSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
concurrentStreams: z.number().int().positive(),
|
|
32
|
+
requestsPerMinute: z.number().int().positive(),
|
|
33
|
+
})
|
|
34
|
+
.describe('The concurrency and rate ceilings a minted token carries.');
|
|
35
|
+
/**
|
|
36
|
+
* A minted inference token.
|
|
37
|
+
*
|
|
38
|
+
* `token` is a credential returned once. Consumers hold it as a credential
|
|
39
|
+
* reference, never as a configuration string, and never log it.
|
|
40
|
+
*
|
|
41
|
+
* No price, rate, multiplier or unit cost appears on this route. The published
|
|
42
|
+
* price list is the one place a price belongs.
|
|
43
|
+
*/
|
|
44
|
+
export const InferenceTokenSchema = z
|
|
45
|
+
.object({
|
|
46
|
+
tokenId: IdSchema,
|
|
47
|
+
token: SecretValueSchema,
|
|
48
|
+
expiresAt: TimestampSchema,
|
|
49
|
+
endpoints: InferenceEndpointsSchema,
|
|
50
|
+
limits: InferenceLimitsSchema,
|
|
51
|
+
catalogVersion: z
|
|
52
|
+
.string()
|
|
53
|
+
.describe('An opaque version string for the model catalog this token was minted against.'),
|
|
54
|
+
})
|
|
55
|
+
.describe('A minted inference token. The `token` value is returned once and is a credential. No price appears here.');
|
|
56
|
+
/**
|
|
57
|
+
* What one routed model supports.
|
|
58
|
+
*
|
|
59
|
+
* Booleans, and mechanism rather than catalog: they say what a caller may send,
|
|
60
|
+
* not which model it is or who serves it.
|
|
61
|
+
*/
|
|
62
|
+
export const ModelSupportsSchema = z
|
|
63
|
+
.object({
|
|
64
|
+
tools: z.boolean(),
|
|
65
|
+
promptCaching: z.boolean(),
|
|
66
|
+
streaming: z.boolean(),
|
|
67
|
+
thinking: z.boolean(),
|
|
68
|
+
})
|
|
69
|
+
.describe('What a routed model supports. Capability booleans only.');
|
|
70
|
+
/**
|
|
71
|
+
* One routed model.
|
|
72
|
+
*
|
|
73
|
+
* `id` is an opaque string. Publishing the set of routed models would freeze
|
|
74
|
+
* the catalog into a `.d.ts` on public npm, and read beside the published price
|
|
75
|
+
* list it would say more than the list does.
|
|
76
|
+
*/
|
|
77
|
+
export const InferenceModelSchema = z
|
|
78
|
+
.object({
|
|
79
|
+
id: IdSchema.describe('An opaque model identifier. The set is never enumerated in this package.'),
|
|
80
|
+
displayName: z.string(),
|
|
81
|
+
contextWindow: z.number().int().positive(),
|
|
82
|
+
maxOutputTokens: z.number().int().positive(),
|
|
83
|
+
supports: ModelSupportsSchema,
|
|
84
|
+
})
|
|
85
|
+
.describe('One routed model. No provider or vendor is named anywhere in this shape.');
|
|
86
|
+
/** `GET /v1/inference/models` — the models this caller may route to. */
|
|
87
|
+
export const InferenceModelsResponseSchema = z
|
|
88
|
+
.object({
|
|
89
|
+
catalogVersion: z.string(),
|
|
90
|
+
models: z.array(InferenceModelSchema),
|
|
91
|
+
})
|
|
92
|
+
.describe('The models this caller may route to, and the opaque version of the catalog they came from.');
|
|
93
|
+
/** `POST /v1/inference/tokens/{tokenId}/revoke`. */
|
|
94
|
+
export const InferenceTokenRevokeResponseSchema = z
|
|
95
|
+
.object({ revoked: z.boolean() })
|
|
96
|
+
.describe('Whether the token is now revoked. Revoking an already-revoked token is not an error.');
|
|
97
|
+
/**
|
|
98
|
+
* Why an inference request was refused.
|
|
99
|
+
*
|
|
100
|
+
* Mechanism: each value names a condition a caller can act on, and none of them
|
|
101
|
+
* names a subscription, a model or a supplier.
|
|
102
|
+
*/
|
|
103
|
+
export const InferenceRefusalReasonSchema = z
|
|
104
|
+
.enum([
|
|
105
|
+
'balance_exhausted',
|
|
106
|
+
'rate_limited',
|
|
107
|
+
'concurrency_exceeded',
|
|
108
|
+
'model_unavailable',
|
|
109
|
+
'token_revoked',
|
|
110
|
+
'token_expired',
|
|
111
|
+
'entitlement_required',
|
|
112
|
+
])
|
|
113
|
+
.describe('Why an inference request was refused. Conditions a caller can act on; nothing about what they bought.');
|
|
114
|
+
//# sourceMappingURL=inference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inference.js","sourceRoot":"","sources":["../src/inference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC;KACzC,MAAM,CAA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One machine registered against an account or organization. */
|
|
3
|
+
export declare const InstanceSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
orgId: z.ZodNullable<z.ZodString>;
|
|
6
|
+
displayName: z.ZodString;
|
|
7
|
+
appVersion: z.ZodString;
|
|
8
|
+
platform: z.ZodString;
|
|
9
|
+
firstSeenAt: z.ZodISODateTime;
|
|
10
|
+
lastSeenAt: z.ZodISODateTime;
|
|
11
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
/** One machine registered against an account or organization. */
|
|
14
|
+
export type Instance = z.infer<typeof InstanceSchema>;
|
|
15
|
+
/** `POST /v1/instances/heartbeat` — an instance reporting that it is alive. */
|
|
16
|
+
export declare const InstanceHeartbeatRequestSchema: z.ZodObject<{
|
|
17
|
+
instanceId: z.ZodString;
|
|
18
|
+
appVersion: z.ZodString;
|
|
19
|
+
platform: z.ZodString;
|
|
20
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
/** The acknowledgement of a heartbeat. */
|
|
23
|
+
export declare const InstanceHeartbeatResponseSchema: z.ZodObject<{
|
|
24
|
+
acknowledgedAt: z.ZodISODateTime;
|
|
25
|
+
nextHeartbeatAfterMs: z.ZodNumber;
|
|
26
|
+
revoked: z.ZodBoolean;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
/**
|
|
29
|
+
* `POST /v1/instances/revoke` — cut a machine off.
|
|
30
|
+
*
|
|
31
|
+
* Revoking an instance also revokes that instance's tunnel credential, so a
|
|
32
|
+
* revoked machine cannot keep serving on an address this service issued. Same
|
|
33
|
+
* request, same response: the extra effect is behaviour, not a new field.
|
|
34
|
+
*/
|
|
35
|
+
export declare const InstanceRevokeRequestSchema: z.ZodObject<{
|
|
36
|
+
instanceId: z.ZodString;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
/** The result of a revocation. */
|
|
39
|
+
export declare const InstanceRevokeResponseSchema: z.ZodObject<{
|
|
40
|
+
revokedAt: z.ZodISODateTime;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
/** `POST /v1/instances/{instanceId}/org` — move an instance to another organization. */
|
|
43
|
+
export declare const InstanceRelinkRequestSchema: z.ZodObject<{
|
|
44
|
+
orgId: z.ZodNullable<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/** `GET /v1/instances` — the caller`s registered machines. */
|
|
47
|
+
export declare const InstanceListResponseSchema: z.ZodObject<{
|
|
48
|
+
items: z.ZodArray<z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
orgId: z.ZodNullable<z.ZodString>;
|
|
51
|
+
displayName: z.ZodString;
|
|
52
|
+
appVersion: z.ZodString;
|
|
53
|
+
platform: z.ZodString;
|
|
54
|
+
firstSeenAt: z.ZodISODateTime;
|
|
55
|
+
lastSeenAt: z.ZodISODateTime;
|
|
56
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
57
|
+
}, z.core.$strip>>;
|
|
58
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
//# sourceMappingURL=instances.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../src/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,iEAAiE;AACjE,eAAO,MAAM,cAAc;;;;;;;;;iBAW8C,CAAC;AAE1E,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,+EAA+E;AAC/E,eAAO,MAAM,8BAA8B;;;;;iBAOkC,CAAC;AAE9E,0CAA0C;AAC1C,eAAO,MAAM,+BAA+B;;;;iBAcqD,CAAC;AAElG;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;iBAMrC,CAAC;AAEJ,kCAAkC;AAClC,eAAO,MAAM,4BAA4B;;iBAIM,CAAC;AAEhD,wFAAwF;AACxF,eAAO,MAAM,2BAA2B;;iBAI+C,CAAC;AAExF,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B;;;;;;;;;;;;iBAGtC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { IdSchema, TimestampSchema, pageOf } from './primitives.js';
|
|
3
|
+
/** One machine registered against an account or organization. */
|
|
4
|
+
export const InstanceSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
id: IdSchema,
|
|
7
|
+
orgId: IdSchema.nullable().describe('The organization this instance is linked to, or null.'),
|
|
8
|
+
displayName: z.string().describe('The name a person gave this machine.'),
|
|
9
|
+
appVersion: z.string().describe('The DorkOS version the instance last reported.'),
|
|
10
|
+
platform: z.string().describe('The operating system the instance last reported.'),
|
|
11
|
+
firstSeenAt: TimestampSchema,
|
|
12
|
+
lastSeenAt: TimestampSchema,
|
|
13
|
+
revokedAt: TimestampSchema.nullable().describe('When this instance was revoked, or null.'),
|
|
14
|
+
})
|
|
15
|
+
.describe('One machine registered against an account or organization.');
|
|
16
|
+
/** `POST /v1/instances/heartbeat` — an instance reporting that it is alive. */
|
|
17
|
+
export const InstanceHeartbeatRequestSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
instanceId: IdSchema,
|
|
20
|
+
appVersion: z.string(),
|
|
21
|
+
platform: z.string(),
|
|
22
|
+
displayName: z.string().optional(),
|
|
23
|
+
})
|
|
24
|
+
.describe('An instance reporting that it is alive and what it is running.');
|
|
25
|
+
/** The acknowledgement of a heartbeat. */
|
|
26
|
+
export const InstanceHeartbeatResponseSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
acknowledgedAt: TimestampSchema,
|
|
29
|
+
nextHeartbeatAfterMs: z
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.positive()
|
|
33
|
+
.describe('How long the instance should wait before its next heartbeat.'),
|
|
34
|
+
revoked: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.describe('True when this instance has been revoked and should stop and clear its credentials.'),
|
|
37
|
+
})
|
|
38
|
+
.describe('The acknowledgement of a heartbeat, carrying the next interval and any revocation.');
|
|
39
|
+
/**
|
|
40
|
+
* `POST /v1/instances/revoke` — cut a machine off.
|
|
41
|
+
*
|
|
42
|
+
* Revoking an instance also revokes that instance's tunnel credential, so a
|
|
43
|
+
* revoked machine cannot keep serving on an address this service issued. Same
|
|
44
|
+
* request, same response: the extra effect is behaviour, not a new field.
|
|
45
|
+
*/
|
|
46
|
+
export const InstanceRevokeRequestSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
instanceId: IdSchema,
|
|
49
|
+
})
|
|
50
|
+
.describe('Cut a machine off. Also revokes that instance`s tunnel credential, so it cannot keep serving on an issued address.');
|
|
51
|
+
/** The result of a revocation. */
|
|
52
|
+
export const InstanceRevokeResponseSchema = z
|
|
53
|
+
.object({
|
|
54
|
+
revokedAt: TimestampSchema,
|
|
55
|
+
})
|
|
56
|
+
.describe('When the revocation took effect.');
|
|
57
|
+
/** `POST /v1/instances/{instanceId}/org` — move an instance to another organization. */
|
|
58
|
+
export const InstanceRelinkRequestSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
orgId: IdSchema.nullable().describe('The organization to link to, or null to unlink.'),
|
|
61
|
+
})
|
|
62
|
+
.describe('Move an instance to another organization, or detach it from all of them.');
|
|
63
|
+
/** `GET /v1/instances` — the caller`s registered machines. */
|
|
64
|
+
export const InstanceListResponseSchema = pageOf(InstanceSchema, 'A page of the machines the caller can see.');
|
|
65
|
+
//# sourceMappingURL=instances.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instances.js","sourceRoot":"","sources":["../src/instances.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ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;CACJ,CAAC;KACD,QAAQ,CAAC,oFAAoF,CAAC,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC;KACzC,MAAM,CAAC;IACN,UAAU,EAAE,QAAQ;CACrB,CAAC;KACD,QAAQ,CACP,oHAAoH,CACrH,CAAC;AAEJ,kCAAkC;AAClC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC;KAC1C,MAAM,CAAC;IACN,SAAS,EAAE,eAAe;CAC3B,CAAC;KACD,QAAQ,CAAC,kCAAkC,CAAC,CAAC;AAEhD,wFAAwF;AACxF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC;KACzC,MAAM,CAAC;IACN,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;CACvF,CAAC;KACD,QAAQ,CAAC,0EAA0E,CAAC,CAAC;AAExF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAC9C,cAAc,EACd,4CAA4C,CAC7C,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The wire version this package describes. Every path in the contract is
|
|
4
|
+
* prefixed with it, and the service serves `/v1` beside any future `/v2` for at
|
|
5
|
+
* least two releases.
|
|
6
|
+
*/
|
|
7
|
+
export declare const WIRE_VERSION: 1;
|
|
8
|
+
/** The `/v1` path prefix every route in this contract is served under. */
|
|
9
|
+
export declare const WIRE_PATH_PREFIX: "/v1";
|
|
10
|
+
/**
|
|
11
|
+
* The header every request and response carries, so a proxy or a log can tell
|
|
12
|
+
* which contract a call belongs to without parsing its path.
|
|
13
|
+
*/
|
|
14
|
+
export declare const WIRE_VERSION_HEADER: "X-DorkOS-Wire";
|
|
15
|
+
/** The value of {@link WIRE_VERSION_HEADER} for this contract. */
|
|
16
|
+
export declare const WIRE_VERSION_HEADER_VALUE: string;
|
|
17
|
+
/**
|
|
18
|
+
* An ISO-8601 timestamp with an explicit offset.
|
|
19
|
+
*
|
|
20
|
+
* Every time in this contract is absolute. A local time without an offset is
|
|
21
|
+
* ambiguous on the wire and is rejected.
|
|
22
|
+
*/
|
|
23
|
+
export declare const TimestampSchema: z.ZodISODateTime;
|
|
24
|
+
/**
|
|
25
|
+
* An opaque server-issued identifier.
|
|
26
|
+
*
|
|
27
|
+
* Opaque means exactly that: clients compare, store and echo these, and never
|
|
28
|
+
* parse, order or enumerate them. Nothing in this package narrows an id to a
|
|
29
|
+
* set of values — see the package README on catalog blindness.
|
|
30
|
+
*/
|
|
31
|
+
export declare const IdSchema: z.ZodString;
|
|
32
|
+
/**
|
|
33
|
+
* An integer count of micro-units carried as a string.
|
|
34
|
+
*
|
|
35
|
+
* Money never crosses this wire as a JavaScript number. A `number` loses
|
|
36
|
+
* precision above 2^53 micro-units and invites float arithmetic in a renderer,
|
|
37
|
+
* so every amount is the exact integer, base-10, as text.
|
|
38
|
+
*/
|
|
39
|
+
export declare const MicroAmountSchema: z.ZodString;
|
|
40
|
+
/**
|
|
41
|
+
* A value returned once and never again.
|
|
42
|
+
*
|
|
43
|
+
* Marks a field the caller must persist at the moment it is received: a token,
|
|
44
|
+
* a credential, a one-time secret. The server cannot re-issue it, and a client
|
|
45
|
+
* that logs it has leaked it. Consumers hold these as credential references,
|
|
46
|
+
* never as configuration strings.
|
|
47
|
+
*/
|
|
48
|
+
export declare const SecretValueSchema: z.ZodString;
|
|
49
|
+
/**
|
|
50
|
+
* An opaque pagination cursor.
|
|
51
|
+
*
|
|
52
|
+
* Supplied by a previous page's `nextCursor`, passed back verbatim. It encodes
|
|
53
|
+
* server-side position and carries no meaning a client may read.
|
|
54
|
+
*/
|
|
55
|
+
export declare const CursorSchema: z.ZodString;
|
|
56
|
+
/** Query parameters every cursor-paginated collection accepts. */
|
|
57
|
+
export declare const PageParamsSchema: z.ZodObject<{
|
|
58
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
59
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
/** Cursor pagination parameters accepted by every collection route. */
|
|
62
|
+
export type PageParams = z.infer<typeof PageParamsSchema>;
|
|
63
|
+
/**
|
|
64
|
+
* Wraps an item schema in the cursor-paginated page envelope every collection
|
|
65
|
+
* in this contract returns.
|
|
66
|
+
*
|
|
67
|
+
* @param item - The schema for one element of the page.
|
|
68
|
+
* @param description - What this particular page contains, for the generated types.
|
|
69
|
+
*/
|
|
70
|
+
export declare function pageOf<T extends z.ZodTypeAny>(item: T, description: string): z.ZodObject<{
|
|
71
|
+
items: z.ZodArray<T>;
|
|
72
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAG,CAAU,CAAC;AAEvC,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,EAAG,KAAc,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAG,eAAwB,CAAC;AAE5D,kEAAkE;AAClE,eAAO,MAAM,yBAAyB,QAAuB,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,kBAEmC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,aAGkE,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,aAQ3B,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,aAK3B,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,YAAY,aAG6D,CAAC;AAEvF,kEAAkE;AAClE,eAAO,MAAM,gBAAgB;;;iBAa4D,CAAC;AAE1F,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM;;;kBAS1E"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* The wire version this package describes. Every path in the contract is
|
|
4
|
+
* prefixed with it, and the service serves `/v1` beside any future `/v2` for at
|
|
5
|
+
* least two releases.
|
|
6
|
+
*/
|
|
7
|
+
export const WIRE_VERSION = 1;
|
|
8
|
+
/** The `/v1` path prefix every route in this contract is served under. */
|
|
9
|
+
export const WIRE_PATH_PREFIX = '/v1';
|
|
10
|
+
/**
|
|
11
|
+
* The header every request and response carries, so a proxy or a log can tell
|
|
12
|
+
* which contract a call belongs to without parsing its path.
|
|
13
|
+
*/
|
|
14
|
+
export const WIRE_VERSION_HEADER = 'X-DorkOS-Wire';
|
|
15
|
+
/** The value of {@link WIRE_VERSION_HEADER} for this contract. */
|
|
16
|
+
export const WIRE_VERSION_HEADER_VALUE = String(WIRE_VERSION);
|
|
17
|
+
/**
|
|
18
|
+
* An ISO-8601 timestamp with an explicit offset.
|
|
19
|
+
*
|
|
20
|
+
* Every time in this contract is absolute. A local time without an offset is
|
|
21
|
+
* ambiguous on the wire and is rejected.
|
|
22
|
+
*/
|
|
23
|
+
export const TimestampSchema = z.iso
|
|
24
|
+
.datetime({ offset: true })
|
|
25
|
+
.describe('An ISO-8601 instant with an explicit UTC offset.');
|
|
26
|
+
/**
|
|
27
|
+
* An opaque server-issued identifier.
|
|
28
|
+
*
|
|
29
|
+
* Opaque means exactly that: clients compare, store and echo these, and never
|
|
30
|
+
* parse, order or enumerate them. Nothing in this package narrows an id to a
|
|
31
|
+
* set of values — see the package README on catalog blindness.
|
|
32
|
+
*/
|
|
33
|
+
export const IdSchema = z
|
|
34
|
+
.string()
|
|
35
|
+
.min(1)
|
|
36
|
+
.describe('An opaque server-issued identifier. Clients never parse or enumerate it.');
|
|
37
|
+
/**
|
|
38
|
+
* An integer count of micro-units carried as a string.
|
|
39
|
+
*
|
|
40
|
+
* Money never crosses this wire as a JavaScript number. A `number` loses
|
|
41
|
+
* precision above 2^53 micro-units and invites float arithmetic in a renderer,
|
|
42
|
+
* so every amount is the exact integer, base-10, as text.
|
|
43
|
+
*/
|
|
44
|
+
export const MicroAmountSchema = z
|
|
45
|
+
.string()
|
|
46
|
+
.regex(/^-?(0|[1-9][0-9]*)$/, 'must be a base-10 integer count of micro-units carried as a string')
|
|
47
|
+
.describe('An exact integer count of micro-units, carried as a string so no value goes through a JavaScript number.');
|
|
48
|
+
/**
|
|
49
|
+
* A value returned once and never again.
|
|
50
|
+
*
|
|
51
|
+
* Marks a field the caller must persist at the moment it is received: a token,
|
|
52
|
+
* a credential, a one-time secret. The server cannot re-issue it, and a client
|
|
53
|
+
* that logs it has leaked it. Consumers hold these as credential references,
|
|
54
|
+
* never as configuration strings.
|
|
55
|
+
*/
|
|
56
|
+
export const SecretValueSchema = z
|
|
57
|
+
.string()
|
|
58
|
+
.min(1)
|
|
59
|
+
.describe('A credential returned exactly once. Store it as a credential reference; never log it or persist it as configuration.');
|
|
60
|
+
/**
|
|
61
|
+
* An opaque pagination cursor.
|
|
62
|
+
*
|
|
63
|
+
* Supplied by a previous page's `nextCursor`, passed back verbatim. It encodes
|
|
64
|
+
* server-side position and carries no meaning a client may read.
|
|
65
|
+
*/
|
|
66
|
+
export const CursorSchema = z
|
|
67
|
+
.string()
|
|
68
|
+
.min(1)
|
|
69
|
+
.describe('An opaque pagination cursor, passed back verbatim from a previous page.');
|
|
70
|
+
/** Query parameters every cursor-paginated collection accepts. */
|
|
71
|
+
export const PageParamsSchema = z
|
|
72
|
+
.object({
|
|
73
|
+
cursor: CursorSchema.optional(),
|
|
74
|
+
limit: z
|
|
75
|
+
.number()
|
|
76
|
+
.int()
|
|
77
|
+
.min(1)
|
|
78
|
+
.max(200)
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('Maximum items in the page. The server may return fewer, and clamps anything larger.'),
|
|
81
|
+
})
|
|
82
|
+
.describe('Cursor pagination parameters, shared by every collection in this contract.');
|
|
83
|
+
/**
|
|
84
|
+
* Wraps an item schema in the cursor-paginated page envelope every collection
|
|
85
|
+
* in this contract returns.
|
|
86
|
+
*
|
|
87
|
+
* @param item - The schema for one element of the page.
|
|
88
|
+
* @param description - What this particular page contains, for the generated types.
|
|
89
|
+
*/
|
|
90
|
+
export function pageOf(item, description) {
|
|
91
|
+
return z
|
|
92
|
+
.object({
|
|
93
|
+
items: z.array(item),
|
|
94
|
+
nextCursor: CursorSchema.nullable().describe('The cursor for the next page, or null when this is the last page.'),
|
|
95
|
+
})
|
|
96
|
+
.describe(description);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=primitives.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAU,CAAC;AAEvC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAc,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAwB,CAAC;AAE5D,kEAAkE;AAClE,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,GAAG;KACjC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;KAC1B,QAAQ,CAAC,kDAAkD,CAAC,CAAC;AAEhE;;;;;;GA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@ -0,0 +1,96 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Every machine-readable failure code this contract can return.
|
|
4
|
+
*
|
|
5
|
+
* These are mechanism, not catalog: they name what went wrong with a request,
|
|
6
|
+
* which is a property of the protocol and is published on purpose. Nothing here
|
|
7
|
+
* names a plan, a model, a supplier or an amount.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ProblemCodeSchema: z.ZodEnum<{
|
|
10
|
+
unauthenticated: "unauthenticated";
|
|
11
|
+
invalid_token: "invalid_token";
|
|
12
|
+
expired_token: "expired_token";
|
|
13
|
+
forbidden: "forbidden";
|
|
14
|
+
scope_required: "scope_required";
|
|
15
|
+
malformed_request: "malformed_request";
|
|
16
|
+
unsupported_wire_version: "unsupported_wire_version";
|
|
17
|
+
not_found: "not_found";
|
|
18
|
+
conflict: "conflict";
|
|
19
|
+
precondition_failed: "precondition_failed";
|
|
20
|
+
rate_limited: "rate_limited";
|
|
21
|
+
person_seat_required: "person_seat_required";
|
|
22
|
+
seat_unavailable: "seat_unavailable";
|
|
23
|
+
handle_taken: "handle_taken";
|
|
24
|
+
handle_reserved: "handle_reserved";
|
|
25
|
+
handle_tombstoned: "handle_tombstoned";
|
|
26
|
+
claim_not_approved: "claim_not_approved";
|
|
27
|
+
inbox_full: "inbox_full";
|
|
28
|
+
entitlement_required: "entitlement_required";
|
|
29
|
+
balance_exhausted: "balance_exhausted";
|
|
30
|
+
quota_exceeded: "quota_exceeded";
|
|
31
|
+
enrolment_required: "enrolment_required";
|
|
32
|
+
remote_disabled: "remote_disabled";
|
|
33
|
+
address_unavailable: "address_unavailable";
|
|
34
|
+
internal_error: "internal_error";
|
|
35
|
+
temporarily_unavailable: "temporarily_unavailable";
|
|
36
|
+
}>;
|
|
37
|
+
/** A machine-readable failure code from {@link ProblemCodeSchema}. */
|
|
38
|
+
export type ProblemCode = z.infer<typeof ProblemCodeSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* The single error envelope every endpoint in this contract returns.
|
|
41
|
+
*
|
|
42
|
+
* A response is either the route's success schema or this. There is no third
|
|
43
|
+
* shape and no per-route error type, so a client writes one failure path.
|
|
44
|
+
*
|
|
45
|
+
* `requiredPlanId` is present only on a refusal a subscription would lift. It
|
|
46
|
+
* is an opaque identifier paired with a server-supplied display string: the
|
|
47
|
+
* client renders what it is given and never switches on the value, and no
|
|
48
|
+
* amount ever appears here.
|
|
49
|
+
*/
|
|
50
|
+
export declare const ProblemSchema: z.ZodObject<{
|
|
51
|
+
code: z.ZodEnum<{
|
|
52
|
+
unauthenticated: "unauthenticated";
|
|
53
|
+
invalid_token: "invalid_token";
|
|
54
|
+
expired_token: "expired_token";
|
|
55
|
+
forbidden: "forbidden";
|
|
56
|
+
scope_required: "scope_required";
|
|
57
|
+
malformed_request: "malformed_request";
|
|
58
|
+
unsupported_wire_version: "unsupported_wire_version";
|
|
59
|
+
not_found: "not_found";
|
|
60
|
+
conflict: "conflict";
|
|
61
|
+
precondition_failed: "precondition_failed";
|
|
62
|
+
rate_limited: "rate_limited";
|
|
63
|
+
person_seat_required: "person_seat_required";
|
|
64
|
+
seat_unavailable: "seat_unavailable";
|
|
65
|
+
handle_taken: "handle_taken";
|
|
66
|
+
handle_reserved: "handle_reserved";
|
|
67
|
+
handle_tombstoned: "handle_tombstoned";
|
|
68
|
+
claim_not_approved: "claim_not_approved";
|
|
69
|
+
inbox_full: "inbox_full";
|
|
70
|
+
entitlement_required: "entitlement_required";
|
|
71
|
+
balance_exhausted: "balance_exhausted";
|
|
72
|
+
quota_exceeded: "quota_exceeded";
|
|
73
|
+
enrolment_required: "enrolment_required";
|
|
74
|
+
remote_disabled: "remote_disabled";
|
|
75
|
+
address_unavailable: "address_unavailable";
|
|
76
|
+
internal_error: "internal_error";
|
|
77
|
+
temporarily_unavailable: "temporarily_unavailable";
|
|
78
|
+
}>;
|
|
79
|
+
status: z.ZodNumber;
|
|
80
|
+
title: z.ZodString;
|
|
81
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
82
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
83
|
+
retryAfterMs: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
requiredPlanId: z.ZodOptional<z.ZodString>;
|
|
85
|
+
requiredPlanDisplayName: z.ZodOptional<z.ZodString>;
|
|
86
|
+
freesAt: z.ZodOptional<z.ZodISODateTime>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
/** The error envelope every endpoint returns in place of its success body. */
|
|
89
|
+
export type Problem = z.infer<typeof ProblemSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* Narrows an unknown value to a {@link Problem}.
|
|
92
|
+
*
|
|
93
|
+
* @param value - A parsed response body of unknown shape.
|
|
94
|
+
*/
|
|
95
|
+
export declare function isProblem(value: unknown): value is Problem;
|
|
96
|
+
//# sourceMappingURL=problem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"problem.d.ts","sourceRoot":"","sources":["../src/problem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqC3B,CAAC;AAEJ,sEAAsE;AACtE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoCvB,CAAC;AAEJ,8EAA8E;AAC9E,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D"}
|