readlint.com 0.5.0 → 0.7.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/cli.js +34 -6
- package/dist/gen/index.d.ts +1 -1
- package/dist/gen/types.gen.d.ts +583 -0
- package/dist/index.d.ts +27 -3
- package/dist/index.js +57 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -15,6 +15,10 @@ Commands:
|
|
|
15
15
|
list List evaluations (--limit N --offset N)
|
|
16
16
|
get UUID, delete UUID Read or delete an evaluation
|
|
17
17
|
agent-permissions get Read the owner’s agent billing policy
|
|
18
|
+
billing status|quote|portal Read billing, get a nonbinding quote or payment link
|
|
19
|
+
billing order --quote-id UUID --terms-version VERSION --agree-to-pay --idempotency-key UUID [--start-now]
|
|
20
|
+
Consumers must pass --start-now: the paid start and withdrawal charges follow the quote disclosure and accepted Terms
|
|
21
|
+
billing cancel --idempotency-key UUID (retain for recovery)
|
|
18
22
|
login, logout Approve device login or remove local credentials
|
|
19
23
|
mcp Serve four MCP tools over stdio
|
|
20
24
|
version Print the installed version
|
|
@@ -39,6 +43,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
39
43
|
const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, strict: true, options: {
|
|
40
44
|
json: { type: "boolean" }, "api-key": { type: "string" }, "base-url": { type: "string" }, timeout: { type: "string" },
|
|
41
45
|
help: { type: "boolean", short: "h" }, version: { type: "boolean" }, title: { type: "string" },
|
|
46
|
+
"quote-id": { type: "string" }, "terms-version": { type: "string" }, "agree-to-pay": { type: "boolean" }, "start-now": { type: "boolean" },
|
|
42
47
|
description: { type: "string" }, "idempotency-key": { type: "string" }, limit: { type: "string" }, offset: { type: "string" },
|
|
43
48
|
} });
|
|
44
49
|
if (values.help) {
|
|
@@ -50,14 +55,16 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
50
55
|
return 0;
|
|
51
56
|
}
|
|
52
57
|
const [command, argument] = positionals;
|
|
53
|
-
const takesArgument = ["check", "evaluate", "get", "delete", "agent-permissions"].includes(command);
|
|
54
|
-
if (!command || !["check", "evaluate", "list", "get", "delete", "login", "logout", "version", "mcp", "agent-permissions"].includes(command) ||
|
|
58
|
+
const takesArgument = ["check", "evaluate", "get", "delete", "agent-permissions", "billing"].includes(command);
|
|
59
|
+
if (!command || !["check", "evaluate", "list", "get", "delete", "login", "logout", "version", "mcp", "agent-permissions", "billing"].includes(command) ||
|
|
55
60
|
positionals.length !== (takesArgument ? 2 : 1))
|
|
56
61
|
throw new TypeError();
|
|
57
62
|
if (command === "agent-permissions" && argument !== "get")
|
|
58
63
|
throw new TypeError();
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
if (command === "billing" && !["status", "quote", "portal", "order", "cancel"].includes(argument))
|
|
65
|
+
throw new TypeError();
|
|
66
|
+
for (const flag of ["title", "description", "idempotency-key", "limit", "offset", "quote-id", "terms-version", "agree-to-pay", "start-now"]) {
|
|
67
|
+
if (values[flag] !== undefined && !(["check", "evaluate"].includes(command) ? ["title", "description", "idempotency-key"] : command === "list" ? ["limit", "offset"] : command === "billing" && argument === "order" ? ["idempotency-key", "quote-id", "terms-version", "agree-to-pay", "start-now"] : command === "billing" && argument === "cancel" ? ["idempotency-key"] : []).includes(flag))
|
|
61
68
|
throw new TypeError();
|
|
62
69
|
}
|
|
63
70
|
const timeoutMs = values.timeout === undefined ? 120_000 : Math.ceil(Number(values.timeout) * 1000);
|
|
@@ -98,6 +105,27 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
98
105
|
}
|
|
99
106
|
else if (command === "agent-permissions")
|
|
100
107
|
result = await client.getAgentPermissions();
|
|
108
|
+
else if (command === "billing") {
|
|
109
|
+
if (argument === "status")
|
|
110
|
+
result = await client.getBillingStatus();
|
|
111
|
+
else if (argument === "quote")
|
|
112
|
+
result = await client.createBillingQuote();
|
|
113
|
+
else if (argument === "portal")
|
|
114
|
+
result = await client.createBillingPortal();
|
|
115
|
+
else {
|
|
116
|
+
if (!values["idempotency-key"] || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(values["idempotency-key"]))
|
|
117
|
+
throw new TypeError();
|
|
118
|
+
if (argument === "order" && (!values["quote-id"] || !values["terms-version"] || values["agree-to-pay"] !== true))
|
|
119
|
+
throw new TypeError();
|
|
120
|
+
submissionKey = values["idempotency-key"].toLowerCase();
|
|
121
|
+
activeSubmissionKey = submissionKey;
|
|
122
|
+
console.error(`Idempotency key: ${submissionKey}`);
|
|
123
|
+
if (argument === "cancel")
|
|
124
|
+
result = await client.cancelBillingPlan({ idempotencyKey: submissionKey });
|
|
125
|
+
else
|
|
126
|
+
result = await client.confirmBillingOrder(values["quote-id"], { termsVersion: values["terms-version"], paidOrderConfirmed: true, idempotencyKey: submissionKey, startNow: values["start-now"] === true });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
101
129
|
else if (command === "get")
|
|
102
130
|
result = await client.getEvaluation(argument);
|
|
103
131
|
else {
|
|
@@ -110,12 +138,12 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
110
138
|
return 0;
|
|
111
139
|
}
|
|
112
140
|
catch (error) {
|
|
113
|
-
const problem = error instanceof ReadlintError ? { code: error.code, message: error.message, status: error.status, evaluation_id: error.evaluationId } : {
|
|
141
|
+
const problem = error instanceof ReadlintError ? { code: error.code, message: error.message, status: error.status, evaluation_id: error.evaluationId, ...error.details } : {
|
|
114
142
|
code: "invalid_input", message: "Check the command, UTF-8 input file, URL and credential file permissions. Run `readlint --help`.",
|
|
115
143
|
};
|
|
116
144
|
if (submissionKey)
|
|
117
145
|
problem.idempotency_key = submissionKey;
|
|
118
|
-
console.error(machine ? JSON.stringify({ error: problem }) : `${problem.code}: ${problem.message}`);
|
|
146
|
+
console.error(machine ? JSON.stringify({ error: problem }) : `${problem.code}: ${problem.message}${problem.settings_url ? ` ${problem.action} ${problem.settings_url}` : problem.action_url ? ` ${problem.action_url}` : ""}`);
|
|
119
147
|
return 1;
|
|
120
148
|
}
|
|
121
149
|
}
|
package/dist/gen/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { AgentPermissions, BodyCreateDeviceCode, BodyCreateDeviceToken, CheckResult, ClientOptions, CreateDeviceCodeData, CreateDeviceCodeError, CreateDeviceCodeErrors, CreateDeviceCodeResponse, CreateDeviceCodeResponses, CreateDeviceTokenData, CreateDeviceTokenError, CreateDeviceTokenErrors, CreateDeviceTokenResponse, CreateDeviceTokenResponses, CreateEvaluationV1EvaluationsPostData, CreateEvaluationV1EvaluationsPostError, CreateEvaluationV1EvaluationsPostErrors, CreateEvaluationV1EvaluationsPostResponse, CreateEvaluationV1EvaluationsPostResponses, DeviceCodeResponse, DeviceTokenResponse, ErrorDetail, ErrorResponse, EvaluationPage, EvaluationReport, EvaluationRequest, EvaluationResult, EvaluationSummary, GetAgentPermissionsData, GetAgentPermissionsError, GetAgentPermissionsErrors, GetAgentPermissionsResponse, GetAgentPermissionsResponses, GetEvaluationV1EvaluationsEvaluationIdGetData, GetEvaluationV1EvaluationsEvaluationIdGetError, GetEvaluationV1EvaluationsEvaluationIdGetErrors, GetEvaluationV1EvaluationsEvaluationIdGetResponse, GetEvaluationV1EvaluationsEvaluationIdGetResponses, HttpValidationError, InvalidField, ListEvaluationsV1EvaluationsGetData, ListEvaluationsV1EvaluationsGetError, ListEvaluationsV1EvaluationsGetErrors, ListEvaluationsV1EvaluationsGetResponse, ListEvaluationsV1EvaluationsGetResponses, OAuthError, PhraseResult, ProseResult, RemoveEvaluationV1EvaluationsEvaluationIdDeleteData, RemoveEvaluationV1EvaluationsEvaluationIdDeleteError, RemoveEvaluationV1EvaluationsEvaluationIdDeleteErrors, RemoveEvaluationV1EvaluationsEvaluationIdDeleteResponse, RemoveEvaluationV1EvaluationsEvaluationIdDeleteResponses, ValidationDetail, ValidationError, ValidationResponse } from './types.gen.js';
|
|
1
|
+
export type { AgentBillingStatus, AgentPermissions, AgentQuote, BillingErrorDetail, BillingErrorResponse, BodyCreateDeviceCode, BodyCreateDeviceToken, CancelBillingPlanData, CancelBillingPlanError, CancelBillingPlanErrors, CancelBillingPlanResponse, CancelBillingPlanResponses, Cancellation, CheckResult, ClientOptions, ConfirmBillingOrderData, ConfirmBillingOrderError, ConfirmBillingOrderErrors, ConfirmBillingOrderResponse, ConfirmBillingOrderResponses, CreateBillingPortalData, CreateBillingPortalError, CreateBillingPortalErrors, CreateBillingPortalResponse, CreateBillingPortalResponses, CreateBillingQuoteData, CreateBillingQuoteError, CreateBillingQuoteErrors, CreateBillingQuoteResponse, CreateBillingQuoteResponses, CreateDeviceCodeData, CreateDeviceCodeError, CreateDeviceCodeErrors, CreateDeviceCodeResponse, CreateDeviceCodeResponses, CreateDeviceTokenData, CreateDeviceTokenError, CreateDeviceTokenErrors, CreateDeviceTokenResponse, CreateDeviceTokenResponses, CreateEvaluationV1EvaluationsPostData, CreateEvaluationV1EvaluationsPostError, CreateEvaluationV1EvaluationsPostErrors, CreateEvaluationV1EvaluationsPostResponse, CreateEvaluationV1EvaluationsPostResponses, DeviceCodeResponse, DeviceTokenResponse, EmptyInstruction, ErrorDetail, ErrorResponse, EvaluationPage, EvaluationReport, EvaluationRequest, EvaluationResult, EvaluationSummary, GetAgentPermissionsData, GetAgentPermissionsError, GetAgentPermissionsErrors, GetAgentPermissionsResponse, GetAgentPermissionsResponses, GetBillingStatusData, GetBillingStatusError, GetBillingStatusErrors, GetBillingStatusResponse, GetBillingStatusResponses, GetEvaluationV1EvaluationsEvaluationIdGetData, GetEvaluationV1EvaluationsEvaluationIdGetError, GetEvaluationV1EvaluationsEvaluationIdGetErrors, GetEvaluationV1EvaluationsEvaluationIdGetResponse, GetEvaluationV1EvaluationsEvaluationIdGetResponses, HttpValidationError, InvalidField, InvoiceView, ListEvaluationsV1EvaluationsGetData, ListEvaluationsV1EvaluationsGetError, ListEvaluationsV1EvaluationsGetErrors, ListEvaluationsV1EvaluationsGetResponse, ListEvaluationsV1EvaluationsGetResponses, OAuthError, OrderAccepted, PaidInstruction, PaymentAction, PendingSetup, PermissionDenial, PermissionErrorResponse, PhraseResult, PortalLink, ProseResult, RemoveEvaluationV1EvaluationsEvaluationIdDeleteData, RemoveEvaluationV1EvaluationsEvaluationIdDeleteError, RemoveEvaluationV1EvaluationsEvaluationIdDeleteErrors, RemoveEvaluationV1EvaluationsEvaluationIdDeleteResponse, RemoveEvaluationV1EvaluationsEvaluationIdDeleteResponses, ValidationDetail, ValidationError, ValidationResponse } from './types.gen.js';
|
package/dist/gen/types.gen.d.ts
CHANGED
|
@@ -1,6 +1,81 @@
|
|
|
1
1
|
export type ClientOptions = {
|
|
2
2
|
baseUrl: `${string}://${string}` | (string & {});
|
|
3
3
|
};
|
|
4
|
+
/**
|
|
5
|
+
* AgentBillingStatus
|
|
6
|
+
*/
|
|
7
|
+
export type AgentBillingStatus = {
|
|
8
|
+
/**
|
|
9
|
+
* Access Active
|
|
10
|
+
*/
|
|
11
|
+
access_active: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Business
|
|
14
|
+
*/
|
|
15
|
+
business: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Cancelled At
|
|
18
|
+
*/
|
|
19
|
+
cancelled_at: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Credits Remaining Cents
|
|
22
|
+
*/
|
|
23
|
+
credits_remaining_cents: number;
|
|
24
|
+
/**
|
|
25
|
+
* Enabled
|
|
26
|
+
*/
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Fractional Balance Cents
|
|
30
|
+
*/
|
|
31
|
+
fractional_balance_cents: number;
|
|
32
|
+
/**
|
|
33
|
+
* Invoices
|
|
34
|
+
*/
|
|
35
|
+
invoices: Array<InvoiceView>;
|
|
36
|
+
/**
|
|
37
|
+
* Order Id
|
|
38
|
+
*/
|
|
39
|
+
order_id: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Order State
|
|
42
|
+
*/
|
|
43
|
+
order_state: 'none' | 'scheduled' | 'payment_pending' | 'requires_action' | 'active' | 'cancelled';
|
|
44
|
+
/**
|
|
45
|
+
* Paid Order Confirmed
|
|
46
|
+
*/
|
|
47
|
+
paid_order_confirmed: boolean;
|
|
48
|
+
payment_action: PaymentAction | null;
|
|
49
|
+
/**
|
|
50
|
+
* Payment Method Ready
|
|
51
|
+
*/
|
|
52
|
+
payment_method_ready: boolean;
|
|
53
|
+
pending_setup: PendingSetup | null;
|
|
54
|
+
/**
|
|
55
|
+
* Period Ends At
|
|
56
|
+
*/
|
|
57
|
+
period_ends_at: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Period Kind
|
|
60
|
+
*/
|
|
61
|
+
period_kind: 'trial' | 'paid' | null;
|
|
62
|
+
/**
|
|
63
|
+
* Suspended
|
|
64
|
+
*/
|
|
65
|
+
suspended: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Trial Available
|
|
68
|
+
*/
|
|
69
|
+
trial_available: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Trial Ends At
|
|
72
|
+
*/
|
|
73
|
+
trial_ends_at: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Usage Above Credits Cents
|
|
76
|
+
*/
|
|
77
|
+
usage_above_credits_cents: number;
|
|
78
|
+
};
|
|
4
79
|
/**
|
|
5
80
|
* AgentPermissions
|
|
6
81
|
*/
|
|
@@ -18,6 +93,118 @@ export type AgentPermissions = {
|
|
|
18
93
|
*/
|
|
19
94
|
agents_can_start_trials: boolean;
|
|
20
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* AgentQuote
|
|
98
|
+
*/
|
|
99
|
+
export type AgentQuote = {
|
|
100
|
+
/**
|
|
101
|
+
* Affirmation
|
|
102
|
+
*/
|
|
103
|
+
affirmation: string;
|
|
104
|
+
/**
|
|
105
|
+
* Cancellation Terms
|
|
106
|
+
*/
|
|
107
|
+
cancellation_terms: string;
|
|
108
|
+
/**
|
|
109
|
+
* Credit Expiry
|
|
110
|
+
*/
|
|
111
|
+
credit_expiry: string;
|
|
112
|
+
/**
|
|
113
|
+
* Currency
|
|
114
|
+
*/
|
|
115
|
+
currency: 'usd';
|
|
116
|
+
/**
|
|
117
|
+
* Disclosure Text
|
|
118
|
+
*/
|
|
119
|
+
disclosure_text: string;
|
|
120
|
+
/**
|
|
121
|
+
* Disclosure Version
|
|
122
|
+
*/
|
|
123
|
+
disclosure_version: string;
|
|
124
|
+
/**
|
|
125
|
+
* Expires At
|
|
126
|
+
*/
|
|
127
|
+
expires_at: string;
|
|
128
|
+
/**
|
|
129
|
+
* First Charge Timing
|
|
130
|
+
*/
|
|
131
|
+
first_charge_timing: string;
|
|
132
|
+
/**
|
|
133
|
+
* Monthly Credits Cents
|
|
134
|
+
*/
|
|
135
|
+
monthly_credits_cents: number;
|
|
136
|
+
/**
|
|
137
|
+
* Plan Line
|
|
138
|
+
*/
|
|
139
|
+
plan_line: string;
|
|
140
|
+
/**
|
|
141
|
+
* Privacy Url
|
|
142
|
+
*/
|
|
143
|
+
privacy_url: string;
|
|
144
|
+
/**
|
|
145
|
+
* Privacy Version
|
|
146
|
+
*/
|
|
147
|
+
privacy_version: string;
|
|
148
|
+
/**
|
|
149
|
+
* Quote Id
|
|
150
|
+
*/
|
|
151
|
+
quote_id: string;
|
|
152
|
+
/**
|
|
153
|
+
* Renewal Terms
|
|
154
|
+
*/
|
|
155
|
+
renewal_terms: string;
|
|
156
|
+
/**
|
|
157
|
+
* Start Now Action
|
|
158
|
+
*/
|
|
159
|
+
start_now_action: string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Start Now Required
|
|
162
|
+
*/
|
|
163
|
+
start_now_required: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Subtotal Cents
|
|
166
|
+
*/
|
|
167
|
+
subtotal_cents: number;
|
|
168
|
+
/**
|
|
169
|
+
* Tax Cents
|
|
170
|
+
*/
|
|
171
|
+
tax_cents: number;
|
|
172
|
+
/**
|
|
173
|
+
* Terms Url
|
|
174
|
+
*/
|
|
175
|
+
terms_url: string;
|
|
176
|
+
/**
|
|
177
|
+
* Terms Version
|
|
178
|
+
*/
|
|
179
|
+
terms_version: string;
|
|
180
|
+
/**
|
|
181
|
+
* Total Cents
|
|
182
|
+
*/
|
|
183
|
+
total_cents: number;
|
|
184
|
+
/**
|
|
185
|
+
* Usage Rate Cents Per Million
|
|
186
|
+
*/
|
|
187
|
+
usage_rate_cents_per_million: number;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* BillingErrorDetail
|
|
191
|
+
*/
|
|
192
|
+
export type BillingErrorDetail = {
|
|
193
|
+
/**
|
|
194
|
+
* Action Url
|
|
195
|
+
*/
|
|
196
|
+
action_url?: string | null;
|
|
197
|
+
/**
|
|
198
|
+
* Code
|
|
199
|
+
*/
|
|
200
|
+
code: string;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* BillingErrorResponse
|
|
204
|
+
*/
|
|
205
|
+
export type BillingErrorResponse = {
|
|
206
|
+
detail: BillingErrorDetail;
|
|
207
|
+
};
|
|
21
208
|
/**
|
|
22
209
|
* Body_createDeviceCode
|
|
23
210
|
*/
|
|
@@ -52,6 +239,24 @@ export type BodyCreateDeviceToken = {
|
|
|
52
239
|
*/
|
|
53
240
|
grant_type: string;
|
|
54
241
|
};
|
|
242
|
+
/**
|
|
243
|
+
* Cancellation
|
|
244
|
+
*/
|
|
245
|
+
export type Cancellation = {
|
|
246
|
+
/**
|
|
247
|
+
* Cancelled
|
|
248
|
+
*/
|
|
249
|
+
cancelled: true;
|
|
250
|
+
current: AgentBillingStatus;
|
|
251
|
+
/**
|
|
252
|
+
* Order Id
|
|
253
|
+
*/
|
|
254
|
+
order_id: string | null;
|
|
255
|
+
/**
|
|
256
|
+
* Trial Period Id
|
|
257
|
+
*/
|
|
258
|
+
trial_period_id: string | null;
|
|
259
|
+
};
|
|
55
260
|
/**
|
|
56
261
|
* CheckResult
|
|
57
262
|
*/
|
|
@@ -119,6 +324,12 @@ export type DeviceTokenResponse = {
|
|
|
119
324
|
*/
|
|
120
325
|
token_type?: string;
|
|
121
326
|
};
|
|
327
|
+
/**
|
|
328
|
+
* EmptyInstruction
|
|
329
|
+
*/
|
|
330
|
+
export type EmptyInstruction = {
|
|
331
|
+
[key: string]: never;
|
|
332
|
+
};
|
|
122
333
|
/**
|
|
123
334
|
* ErrorDetail
|
|
124
335
|
*/
|
|
@@ -288,6 +499,35 @@ export type InvalidField = {
|
|
|
288
499
|
*/
|
|
289
500
|
type: string;
|
|
290
501
|
};
|
|
502
|
+
/**
|
|
503
|
+
* InvoiceView
|
|
504
|
+
*/
|
|
505
|
+
export type InvoiceView = {
|
|
506
|
+
/**
|
|
507
|
+
* Amount Paid Cents
|
|
508
|
+
*/
|
|
509
|
+
amount_paid_cents: number;
|
|
510
|
+
/**
|
|
511
|
+
* Amount Remaining Cents
|
|
512
|
+
*/
|
|
513
|
+
amount_remaining_cents: number | null;
|
|
514
|
+
/**
|
|
515
|
+
* Id
|
|
516
|
+
*/
|
|
517
|
+
id: string;
|
|
518
|
+
/**
|
|
519
|
+
* Status
|
|
520
|
+
*/
|
|
521
|
+
status: string;
|
|
522
|
+
/**
|
|
523
|
+
* Subtotal Cents
|
|
524
|
+
*/
|
|
525
|
+
subtotal_cents: number;
|
|
526
|
+
/**
|
|
527
|
+
* Url
|
|
528
|
+
*/
|
|
529
|
+
url: string | null;
|
|
530
|
+
};
|
|
291
531
|
/**
|
|
292
532
|
* OAuthError
|
|
293
533
|
*/
|
|
@@ -297,6 +537,118 @@ export type OAuthError = {
|
|
|
297
537
|
*/
|
|
298
538
|
error: string;
|
|
299
539
|
};
|
|
540
|
+
/**
|
|
541
|
+
* OrderAccepted
|
|
542
|
+
*/
|
|
543
|
+
export type OrderAccepted = {
|
|
544
|
+
/**
|
|
545
|
+
* Accepted
|
|
546
|
+
*/
|
|
547
|
+
accepted: true;
|
|
548
|
+
/**
|
|
549
|
+
* Accepted At
|
|
550
|
+
*/
|
|
551
|
+
accepted_at: string;
|
|
552
|
+
/**
|
|
553
|
+
* Accepted State
|
|
554
|
+
*/
|
|
555
|
+
accepted_state: 'scheduled' | 'payment_pending' | null;
|
|
556
|
+
current: AgentBillingStatus;
|
|
557
|
+
/**
|
|
558
|
+
* Order Id
|
|
559
|
+
*/
|
|
560
|
+
order_id: string;
|
|
561
|
+
/**
|
|
562
|
+
* Retryable
|
|
563
|
+
*/
|
|
564
|
+
retryable: boolean;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* PaidInstruction
|
|
568
|
+
*/
|
|
569
|
+
export type PaidInstruction = {
|
|
570
|
+
/**
|
|
571
|
+
* Paid Order Confirmed
|
|
572
|
+
*/
|
|
573
|
+
paid_order_confirmed: boolean;
|
|
574
|
+
/**
|
|
575
|
+
* Quote Id
|
|
576
|
+
*/
|
|
577
|
+
quote_id: string;
|
|
578
|
+
/**
|
|
579
|
+
* Start Now
|
|
580
|
+
*/
|
|
581
|
+
start_now?: boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Terms Version
|
|
584
|
+
*/
|
|
585
|
+
terms_version: string;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* PaymentAction
|
|
589
|
+
*/
|
|
590
|
+
export type PaymentAction = {
|
|
591
|
+
/**
|
|
592
|
+
* Action Url
|
|
593
|
+
*/
|
|
594
|
+
action_url: string;
|
|
595
|
+
/**
|
|
596
|
+
* Reason
|
|
597
|
+
*/
|
|
598
|
+
reason: 'payment_authentication_required' | 'payment_method_required';
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* PendingSetup
|
|
602
|
+
*/
|
|
603
|
+
export type PendingSetup = {
|
|
604
|
+
/**
|
|
605
|
+
* Action Url
|
|
606
|
+
*/
|
|
607
|
+
action_url: string | null;
|
|
608
|
+
/**
|
|
609
|
+
* Attempt Id
|
|
610
|
+
*/
|
|
611
|
+
attempt_id: string;
|
|
612
|
+
/**
|
|
613
|
+
* Expires At
|
|
614
|
+
*/
|
|
615
|
+
expires_at: string;
|
|
616
|
+
/**
|
|
617
|
+
* State
|
|
618
|
+
*/
|
|
619
|
+
state: 'pending' | 'complete' | 'expired' | 'blocked';
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* PermissionDenial
|
|
623
|
+
*/
|
|
624
|
+
export type PermissionDenial = {
|
|
625
|
+
/**
|
|
626
|
+
* Action
|
|
627
|
+
*/
|
|
628
|
+
action: string;
|
|
629
|
+
/**
|
|
630
|
+
* Code
|
|
631
|
+
*/
|
|
632
|
+
code: 'agent_permission_disabled';
|
|
633
|
+
/**
|
|
634
|
+
* Message
|
|
635
|
+
*/
|
|
636
|
+
message: string;
|
|
637
|
+
/**
|
|
638
|
+
* Retryable
|
|
639
|
+
*/
|
|
640
|
+
retryable: false;
|
|
641
|
+
/**
|
|
642
|
+
* Settings Url
|
|
643
|
+
*/
|
|
644
|
+
settings_url: '/app/settings#agent-permissions';
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* PermissionErrorResponse
|
|
648
|
+
*/
|
|
649
|
+
export type PermissionErrorResponse = {
|
|
650
|
+
detail: PermissionDenial;
|
|
651
|
+
};
|
|
300
652
|
/**
|
|
301
653
|
* PhraseResult
|
|
302
654
|
*/
|
|
@@ -314,6 +666,15 @@ export type PhraseResult = {
|
|
|
314
666
|
*/
|
|
315
667
|
where: string;
|
|
316
668
|
};
|
|
669
|
+
/**
|
|
670
|
+
* PortalLink
|
|
671
|
+
*/
|
|
672
|
+
export type PortalLink = {
|
|
673
|
+
/**
|
|
674
|
+
* Url
|
|
675
|
+
*/
|
|
676
|
+
url: string;
|
|
677
|
+
};
|
|
317
678
|
/**
|
|
318
679
|
* ProseResult
|
|
319
680
|
*/
|
|
@@ -457,6 +818,228 @@ export type GetAgentPermissionsResponses = {
|
|
|
457
818
|
200: AgentPermissions;
|
|
458
819
|
};
|
|
459
820
|
export type GetAgentPermissionsResponse = GetAgentPermissionsResponses[keyof GetAgentPermissionsResponses];
|
|
821
|
+
export type CancelBillingPlanData = {
|
|
822
|
+
body: EmptyInstruction;
|
|
823
|
+
headers: {
|
|
824
|
+
/**
|
|
825
|
+
* Idempotency-Key
|
|
826
|
+
*/
|
|
827
|
+
'Idempotency-Key': string;
|
|
828
|
+
};
|
|
829
|
+
path?: never;
|
|
830
|
+
query?: never;
|
|
831
|
+
url: '/v1/billing/cancel';
|
|
832
|
+
};
|
|
833
|
+
export type CancelBillingPlanErrors = {
|
|
834
|
+
/**
|
|
835
|
+
* Unauthorized
|
|
836
|
+
*/
|
|
837
|
+
401: ErrorResponse;
|
|
838
|
+
/**
|
|
839
|
+
* Response 403 Cancelbillingplan
|
|
840
|
+
*
|
|
841
|
+
* Forbidden
|
|
842
|
+
*/
|
|
843
|
+
403: PermissionErrorResponse | ErrorResponse;
|
|
844
|
+
/**
|
|
845
|
+
* Not Found
|
|
846
|
+
*/
|
|
847
|
+
404: ErrorResponse;
|
|
848
|
+
/**
|
|
849
|
+
* Conflict
|
|
850
|
+
*/
|
|
851
|
+
409: BillingErrorResponse;
|
|
852
|
+
/**
|
|
853
|
+
* Unprocessable Content
|
|
854
|
+
*/
|
|
855
|
+
422: ValidationResponse;
|
|
856
|
+
/**
|
|
857
|
+
* Service Unavailable
|
|
858
|
+
*/
|
|
859
|
+
503: ErrorResponse;
|
|
860
|
+
};
|
|
861
|
+
export type CancelBillingPlanError = CancelBillingPlanErrors[keyof CancelBillingPlanErrors];
|
|
862
|
+
export type CancelBillingPlanResponses = {
|
|
863
|
+
/**
|
|
864
|
+
* Successful Response
|
|
865
|
+
*/
|
|
866
|
+
200: Cancellation;
|
|
867
|
+
};
|
|
868
|
+
export type CancelBillingPlanResponse = CancelBillingPlanResponses[keyof CancelBillingPlanResponses];
|
|
869
|
+
export type ConfirmBillingOrderData = {
|
|
870
|
+
body: PaidInstruction;
|
|
871
|
+
headers: {
|
|
872
|
+
/**
|
|
873
|
+
* Idempotency-Key
|
|
874
|
+
*/
|
|
875
|
+
'Idempotency-Key': string;
|
|
876
|
+
};
|
|
877
|
+
path?: never;
|
|
878
|
+
query?: never;
|
|
879
|
+
url: '/v1/billing/order';
|
|
880
|
+
};
|
|
881
|
+
export type ConfirmBillingOrderErrors = {
|
|
882
|
+
/**
|
|
883
|
+
* Unauthorized
|
|
884
|
+
*/
|
|
885
|
+
401: ErrorResponse;
|
|
886
|
+
/**
|
|
887
|
+
* Response 403 Confirmbillingorder
|
|
888
|
+
*
|
|
889
|
+
* Forbidden
|
|
890
|
+
*/
|
|
891
|
+
403: PermissionErrorResponse | ErrorResponse;
|
|
892
|
+
/**
|
|
893
|
+
* Not Found
|
|
894
|
+
*/
|
|
895
|
+
404: ErrorResponse;
|
|
896
|
+
/**
|
|
897
|
+
* Conflict
|
|
898
|
+
*/
|
|
899
|
+
409: BillingErrorResponse;
|
|
900
|
+
/**
|
|
901
|
+
* Unprocessable Content
|
|
902
|
+
*/
|
|
903
|
+
422: ValidationResponse;
|
|
904
|
+
/**
|
|
905
|
+
* Service Unavailable
|
|
906
|
+
*/
|
|
907
|
+
503: ErrorResponse;
|
|
908
|
+
};
|
|
909
|
+
export type ConfirmBillingOrderError = ConfirmBillingOrderErrors[keyof ConfirmBillingOrderErrors];
|
|
910
|
+
export type ConfirmBillingOrderResponses = {
|
|
911
|
+
/**
|
|
912
|
+
* Successful Response
|
|
913
|
+
*/
|
|
914
|
+
200: OrderAccepted;
|
|
915
|
+
};
|
|
916
|
+
export type ConfirmBillingOrderResponse = ConfirmBillingOrderResponses[keyof ConfirmBillingOrderResponses];
|
|
917
|
+
export type CreateBillingPortalData = {
|
|
918
|
+
body?: never;
|
|
919
|
+
path?: never;
|
|
920
|
+
query?: never;
|
|
921
|
+
url: '/v1/billing/portal';
|
|
922
|
+
};
|
|
923
|
+
export type CreateBillingPortalErrors = {
|
|
924
|
+
/**
|
|
925
|
+
* Unauthorized
|
|
926
|
+
*/
|
|
927
|
+
401: ErrorResponse;
|
|
928
|
+
/**
|
|
929
|
+
* Response 403 Createbillingportal
|
|
930
|
+
*
|
|
931
|
+
* Forbidden
|
|
932
|
+
*/
|
|
933
|
+
403: PermissionErrorResponse | ErrorResponse;
|
|
934
|
+
/**
|
|
935
|
+
* Not Found
|
|
936
|
+
*/
|
|
937
|
+
404: ErrorResponse;
|
|
938
|
+
/**
|
|
939
|
+
* Conflict
|
|
940
|
+
*/
|
|
941
|
+
409: BillingErrorResponse;
|
|
942
|
+
/**
|
|
943
|
+
* Unprocessable Content
|
|
944
|
+
*/
|
|
945
|
+
422: ValidationResponse;
|
|
946
|
+
/**
|
|
947
|
+
* Service Unavailable
|
|
948
|
+
*/
|
|
949
|
+
503: ErrorResponse;
|
|
950
|
+
};
|
|
951
|
+
export type CreateBillingPortalError = CreateBillingPortalErrors[keyof CreateBillingPortalErrors];
|
|
952
|
+
export type CreateBillingPortalResponses = {
|
|
953
|
+
/**
|
|
954
|
+
* Successful Response
|
|
955
|
+
*/
|
|
956
|
+
200: PortalLink;
|
|
957
|
+
};
|
|
958
|
+
export type CreateBillingPortalResponse = CreateBillingPortalResponses[keyof CreateBillingPortalResponses];
|
|
959
|
+
export type CreateBillingQuoteData = {
|
|
960
|
+
body?: never;
|
|
961
|
+
path?: never;
|
|
962
|
+
query?: never;
|
|
963
|
+
url: '/v1/billing/quote';
|
|
964
|
+
};
|
|
965
|
+
export type CreateBillingQuoteErrors = {
|
|
966
|
+
/**
|
|
967
|
+
* Unauthorized
|
|
968
|
+
*/
|
|
969
|
+
401: ErrorResponse;
|
|
970
|
+
/**
|
|
971
|
+
* Response 403 Createbillingquote
|
|
972
|
+
*
|
|
973
|
+
* Forbidden
|
|
974
|
+
*/
|
|
975
|
+
403: PermissionErrorResponse | ErrorResponse;
|
|
976
|
+
/**
|
|
977
|
+
* Not Found
|
|
978
|
+
*/
|
|
979
|
+
404: ErrorResponse;
|
|
980
|
+
/**
|
|
981
|
+
* Conflict
|
|
982
|
+
*/
|
|
983
|
+
409: BillingErrorResponse;
|
|
984
|
+
/**
|
|
985
|
+
* Unprocessable Content
|
|
986
|
+
*/
|
|
987
|
+
422: ValidationResponse;
|
|
988
|
+
/**
|
|
989
|
+
* Service Unavailable
|
|
990
|
+
*/
|
|
991
|
+
503: ErrorResponse;
|
|
992
|
+
};
|
|
993
|
+
export type CreateBillingQuoteError = CreateBillingQuoteErrors[keyof CreateBillingQuoteErrors];
|
|
994
|
+
export type CreateBillingQuoteResponses = {
|
|
995
|
+
/**
|
|
996
|
+
* Successful Response
|
|
997
|
+
*/
|
|
998
|
+
200: AgentQuote;
|
|
999
|
+
};
|
|
1000
|
+
export type CreateBillingQuoteResponse = CreateBillingQuoteResponses[keyof CreateBillingQuoteResponses];
|
|
1001
|
+
export type GetBillingStatusData = {
|
|
1002
|
+
body?: never;
|
|
1003
|
+
path?: never;
|
|
1004
|
+
query?: never;
|
|
1005
|
+
url: '/v1/billing/status';
|
|
1006
|
+
};
|
|
1007
|
+
export type GetBillingStatusErrors = {
|
|
1008
|
+
/**
|
|
1009
|
+
* Unauthorized
|
|
1010
|
+
*/
|
|
1011
|
+
401: ErrorResponse;
|
|
1012
|
+
/**
|
|
1013
|
+
* Response 403 Getbillingstatus
|
|
1014
|
+
*
|
|
1015
|
+
* Forbidden
|
|
1016
|
+
*/
|
|
1017
|
+
403: PermissionErrorResponse | ErrorResponse;
|
|
1018
|
+
/**
|
|
1019
|
+
* Not Found
|
|
1020
|
+
*/
|
|
1021
|
+
404: ErrorResponse;
|
|
1022
|
+
/**
|
|
1023
|
+
* Conflict
|
|
1024
|
+
*/
|
|
1025
|
+
409: BillingErrorResponse;
|
|
1026
|
+
/**
|
|
1027
|
+
* Unprocessable Content
|
|
1028
|
+
*/
|
|
1029
|
+
422: ValidationResponse;
|
|
1030
|
+
/**
|
|
1031
|
+
* Service Unavailable
|
|
1032
|
+
*/
|
|
1033
|
+
503: ErrorResponse;
|
|
1034
|
+
};
|
|
1035
|
+
export type GetBillingStatusError = GetBillingStatusErrors[keyof GetBillingStatusErrors];
|
|
1036
|
+
export type GetBillingStatusResponses = {
|
|
1037
|
+
/**
|
|
1038
|
+
* Successful Response
|
|
1039
|
+
*/
|
|
1040
|
+
200: AgentBillingStatus;
|
|
1041
|
+
};
|
|
1042
|
+
export type GetBillingStatusResponse = GetBillingStatusResponses[keyof GetBillingStatusResponses];
|
|
460
1043
|
export type ListEvaluationsV1EvaluationsGetData = {
|
|
461
1044
|
body?: never;
|
|
462
1045
|
path?: never;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import type { EvaluationResult, EvaluationPage, DeviceCodeResponse, DeviceTokenResponse, AgentPermissions } from "./gen/types.gen.js";
|
|
2
|
-
export type { EvaluationResult as Evaluation, EvaluationPage, EvaluationReport, EvaluationSummary, CheckResult, ProseResult, PhraseResult, DeviceCodeResponse, DeviceTokenResponse, AgentPermissions, } from "./gen/types.gen.js";
|
|
1
|
+
import type { EvaluationResult, EvaluationPage, DeviceCodeResponse, DeviceTokenResponse, AgentPermissions, AgentBillingStatus, AgentQuote, OrderAccepted, Cancellation, PortalLink } from "./gen/types.gen.js";
|
|
2
|
+
export type { EvaluationResult as Evaluation, EvaluationPage, EvaluationReport, EvaluationSummary, CheckResult, ProseResult, PhraseResult, DeviceCodeResponse, DeviceTokenResponse, AgentPermissions, AgentBillingStatus, AgentQuote, OrderAccepted, Cancellation, PortalLink, } from "./gen/types.gen.js";
|
|
3
3
|
/** Sanitized failure. status is null when no reliable HTTP answer arrived. */
|
|
4
4
|
export declare class ReadlintError extends Error {
|
|
5
5
|
readonly code: string;
|
|
6
6
|
readonly status: number | null;
|
|
7
7
|
readonly evaluationId: string | null;
|
|
8
|
+
readonly details: {
|
|
9
|
+
action?: string;
|
|
10
|
+
settings_url?: string;
|
|
11
|
+
retryable?: false;
|
|
12
|
+
action_url?: string;
|
|
13
|
+
};
|
|
8
14
|
readonly name = "ReadlintError";
|
|
9
|
-
constructor(code: string, message: string, status?: number | null, evaluationId?: string | null
|
|
15
|
+
constructor(code: string, message: string, status?: number | null, evaluationId?: string | null, details?: {
|
|
16
|
+
action?: string;
|
|
17
|
+
settings_url?: string;
|
|
18
|
+
retryable?: false;
|
|
19
|
+
action_url?: string;
|
|
20
|
+
});
|
|
10
21
|
}
|
|
11
22
|
export interface ReadlintOptions {
|
|
12
23
|
apiKey?: string;
|
|
@@ -31,6 +42,19 @@ export declare class Readlint {
|
|
|
31
42
|
constructor(options?: ReadlintOptions);
|
|
32
43
|
/** Read account-wide policy. Changes require the owner's browser session. */
|
|
33
44
|
getAgentPermissions(): Promise<AgentPermissions>;
|
|
45
|
+
getBillingStatus(): Promise<AgentBillingStatus>;
|
|
46
|
+
createBillingQuote(): Promise<AgentQuote>;
|
|
47
|
+
/** Explicit paid instruction; never automatically retried. Consumers must pass startNow: true: start the paid plan as disclosed in the quote; withdrawal charges follow its disclosure and accepted Terms. */
|
|
48
|
+
confirmBillingOrder(quoteId: string, options: {
|
|
49
|
+
termsVersion: string;
|
|
50
|
+
paidOrderConfirmed: true;
|
|
51
|
+
idempotencyKey: string;
|
|
52
|
+
startNow?: boolean;
|
|
53
|
+
}): Promise<OrderAccepted>;
|
|
54
|
+
cancelBillingPlan(options: {
|
|
55
|
+
idempotencyKey: string;
|
|
56
|
+
}): Promise<Cancellation>;
|
|
57
|
+
createBillingPortal(): Promise<PortalLink>;
|
|
34
58
|
evaluate(article: string, options: EvaluateOptions): Promise<EvaluationResult>;
|
|
35
59
|
listEvaluations(options?: {
|
|
36
60
|
limit?: number;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,18 @@ const RECOVERY = {
|
|
|
5
5
|
evaluation_disabled: "Try again later with the same idempotency key and article.",
|
|
6
6
|
evaluation_context_exceeded: "Shorten the article and submit with a new key.",
|
|
7
7
|
evaluation_not_found: "List evaluations to find an unexpired evaluation ID.",
|
|
8
|
-
idempotency_key_reused: "
|
|
8
|
+
idempotency_key_reused: "Reuse the original key and identical input to recover its outcome; use a new key only for a deliberate new instruction.",
|
|
9
|
+
agent_orders_unavailable: "API-key paid orders are not available yet. Use the owner Billing page.",
|
|
10
|
+
billing_disabled: "Billing is not available. Read billing status before trying again.",
|
|
11
|
+
quote_expired: "Read billing status, then request a fresh quote for a new instruction.",
|
|
12
|
+
quote_changed: "Review a fresh quote and its disclosure before confirming a new instruction.",
|
|
13
|
+
quote_not_found: "Use a quote belonging to this account.",
|
|
14
|
+
terms_version_mismatch: "Use the Terms version in a fresh quote.",
|
|
15
|
+
paid_order_consent_required: "Explicit paid-order confirmation is required.",
|
|
16
|
+
paid_order_already_confirmed: "Read the current order in billing status.",
|
|
17
|
+
start_now_required: "Upgrade to readlint/readlint.com 0.7.0 or later if needed. Consumers must ask to start the paid plan now: pass --start-now / startNow: true after reading the quote's disclosure.",
|
|
18
|
+
save_card_first: "Save a payment method using the returned payment link.",
|
|
19
|
+
billing_address_required: "Complete the billing address using the returned payment link.",
|
|
9
20
|
validation_error: "Check the input before retrying.",
|
|
10
21
|
invalid_request: "Check the request fields before trying again.",
|
|
11
22
|
invalid_page_size: "Choose a smaller limit.",
|
|
@@ -21,12 +32,14 @@ export class ReadlintError extends Error {
|
|
|
21
32
|
code;
|
|
22
33
|
status;
|
|
23
34
|
evaluationId;
|
|
35
|
+
details;
|
|
24
36
|
name = "ReadlintError";
|
|
25
|
-
constructor(code, message, status = null, evaluationId = null) {
|
|
37
|
+
constructor(code, message, status = null, evaluationId = null, details = {}) {
|
|
26
38
|
super(message);
|
|
27
39
|
this.code = code;
|
|
28
40
|
this.status = status;
|
|
29
41
|
this.evaluationId = evaluationId;
|
|
42
|
+
this.details = details;
|
|
30
43
|
}
|
|
31
44
|
}
|
|
32
45
|
function env(name) {
|
|
@@ -49,18 +62,37 @@ function origin(value) {
|
|
|
49
62
|
}
|
|
50
63
|
function uuid(value) {
|
|
51
64
|
if (typeof value !== "string" || value.length !== 36 || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)) {
|
|
52
|
-
throw new TypeError("Use a valid
|
|
65
|
+
throw new TypeError("Use a valid UUID.");
|
|
53
66
|
}
|
|
54
67
|
return value.toLowerCase();
|
|
55
68
|
}
|
|
56
69
|
function object(value) {
|
|
57
70
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
58
71
|
}
|
|
59
|
-
function problem(status, body) {
|
|
72
|
+
function problem(status, body, baseUrl) {
|
|
60
73
|
const raw = object(body) ? (object(body.detail) ? body.detail.code : body.error) : null;
|
|
74
|
+
const detail = object(body) && object(body.detail) ? body.detail : null;
|
|
75
|
+
if (status === 403 && detail && raw === "agent_permission_disabled") {
|
|
76
|
+
for (const label of ["Agents can start trials", "Agents can confirm paid orders", "Agents can cancel plans"]) {
|
|
77
|
+
const message = `The account has turned off "${label}".`;
|
|
78
|
+
const action = `Ask the account owner to enable "${label}" in Settings → Agent permissions.`;
|
|
79
|
+
if (detail.message === message && detail.action === action && detail.settings_url === "/app/settings#agent-permissions" && detail.retryable === false) {
|
|
80
|
+
return new ReadlintError(raw, message, 403, null, { action, settings_url: baseUrl + "/app/settings#agent-permissions", retryable: false });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
61
84
|
const code = typeof raw === "string" && Object.hasOwn(RECOVERY, raw) ? raw :
|
|
62
85
|
({ 401: "authentication_required", 422: "validation_error", 429: "rate_limited" }[status] ?? "api_error");
|
|
63
|
-
|
|
86
|
+
let action_url;
|
|
87
|
+
if (["save_card_first", "billing_address_required"].includes(code) && typeof detail?.action_url === "string") {
|
|
88
|
+
try {
|
|
89
|
+
const url = new URL(detail.action_url);
|
|
90
|
+
if (url.protocol === "https:" && ["billing.stripe.com", "checkout.stripe.com"].includes(url.host) && !url.username && !url.password && !url.hash && !/[\x00-\x20]/.test(detail.action_url))
|
|
91
|
+
action_url = detail.action_url;
|
|
92
|
+
}
|
|
93
|
+
catch { /* omit an unsafe recovery URL */ }
|
|
94
|
+
}
|
|
95
|
+
return new ReadlintError(code, `HTTP ${status}: ${code}. ${RECOVERY[code] ?? "Retry later; for a submission reuse its key and identical input."}`, status, null, action_url ? { action_url } : {});
|
|
64
96
|
}
|
|
65
97
|
function retryDelay(response, attempt) {
|
|
66
98
|
let seconds = 2 ** attempt;
|
|
@@ -97,6 +129,24 @@ export class Readlint {
|
|
|
97
129
|
getAgentPermissions() {
|
|
98
130
|
return this.#request("GET", "/v1/agent-permissions", true);
|
|
99
131
|
}
|
|
132
|
+
getBillingStatus() {
|
|
133
|
+
return this.#request("GET", "/v1/billing/status", true);
|
|
134
|
+
}
|
|
135
|
+
createBillingQuote() {
|
|
136
|
+
return this.#request("POST", "/v1/billing/quote", false);
|
|
137
|
+
}
|
|
138
|
+
/** Explicit paid instruction; never automatically retried. Consumers must pass startNow: true: start the paid plan as disclosed in the quote; withdrawal charges follow its disclosure and accepted Terms. */
|
|
139
|
+
confirmBillingOrder(quoteId, options) {
|
|
140
|
+
if (options?.paidOrderConfirmed !== true)
|
|
141
|
+
throw new TypeError("paidOrderConfirmed must be explicitly true.");
|
|
142
|
+
return this.#request("POST", "/v1/billing/order", false, JSON.stringify({ quote_id: uuid(quoteId), terms_version: options.termsVersion, paid_order_confirmed: true, start_now: options.startNow ?? false }), { "Content-Type": "application/json", "Idempotency-Key": uuid(options.idempotencyKey) });
|
|
143
|
+
}
|
|
144
|
+
cancelBillingPlan(options) {
|
|
145
|
+
return this.#request("POST", "/v1/billing/cancel", false, "{}", { "Content-Type": "application/json", "Idempotency-Key": uuid(options.idempotencyKey) });
|
|
146
|
+
}
|
|
147
|
+
createBillingPortal() {
|
|
148
|
+
return this.#request("POST", "/v1/billing/portal", false);
|
|
149
|
+
}
|
|
100
150
|
evaluate(article, options) {
|
|
101
151
|
if (typeof options?.idempotencyKey !== "string" || !/^[!-~]{1,255}$(?![\s\S])/.test(options.idempotencyKey)) {
|
|
102
152
|
throw new TypeError("idempotencyKey must be 1–255 printable ASCII characters without spaces.");
|
|
@@ -184,13 +234,13 @@ export class Readlint {
|
|
|
184
234
|
throw new ReadlintError("evaluation_failed", "Evaluation failed. Read its ID for details; a deliberate new attempt needs a new idempotency key.", response.status, id);
|
|
185
235
|
}
|
|
186
236
|
if (!retry || ![429, 502, 503, 504].includes(response.status) || attempt === this.#maxRetries) {
|
|
187
|
-
throw problem(response.status, json);
|
|
237
|
+
throw problem(response.status, json, this.baseUrl);
|
|
188
238
|
}
|
|
189
239
|
}
|
|
190
240
|
const delay = retryDelay(response, attempt);
|
|
191
241
|
if (delay === null) {
|
|
192
242
|
if (response)
|
|
193
|
-
throw problem(response.status, json);
|
|
243
|
+
throw problem(response.status, json, this.baseUrl);
|
|
194
244
|
throw new ReadlintError("network_error", "No reliable response. Check your connection; for a submission reuse its key and identical input.");
|
|
195
245
|
}
|
|
196
246
|
await new Promise(resolve => setTimeout(resolve, delay));
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.7.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.7.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "readlint.com",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "TypeScript SDK, CLI and MCP server for readlint.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc -p tsconfig.build.json",
|
|
31
31
|
"typecheck": "tsc --noEmit",
|
|
32
|
-
"test": "npm run build && node --test test/*.test.mjs",
|
|
32
|
+
"test": "npm run build && npm run build:examples && node --test test/*.test.mjs",
|
|
33
|
+
"build:examples": "tsc -p tsconfig.examples.json",
|
|
33
34
|
"generate": "node scripts/openapi.mjs",
|
|
34
35
|
"check:openapi": "node scripts/openapi.mjs --check",
|
|
35
36
|
"prepack": "npm run build"
|