@proofline/sdk 5.11.0 → 5.11.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/README.md CHANGED
@@ -21,7 +21,7 @@ This repository is the published distribution of the Proofline TypeScript SDK. T
21
21
 
22
22
  ## Errors and refusals
23
23
 
24
- A refused request throws `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repositoryName`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. The token is redacted from every text field, and `String(error)`, `inspect(error)` and `JSON.stringify(error)` show only the status.
24
+ A refused request throws `ProoflineError` with the server problem's `status`, `type`, `title` and `detail`. When a review request creates nothing, the error also carries `refusal`, whose `reason` names the setting to change, such as `NO_LINKED_ENVIRONMENT` or `ENVIRONMENT_NOT_READY`, and `repositoryName`. A refusal that does not match the public contract keeps its status, `title` and `detail` with the type `urn:proofline:sdk:invalid-response` and no `refusal`. Any other status, such as the 402 a review request answers when credits cannot pay, is a plain problem with no `refusal`. The token is redacted from every text field, and `String(error)`, `inspect(error)` and `JSON.stringify(error)` show only the status.
25
25
 
26
26
  ```typescript
27
27
  import { ProoflineError } from "@proofline/sdk";
package/dist/index.js CHANGED
@@ -165,10 +165,7 @@ function validateReview(value, reviewId) {
165
165
  typeof assessment[field] !== "string")
166
166
  throw protocol("an assessment gap is malformed");
167
167
  }
168
- if (assessment.reason_codes !== undefined &&
169
- assessment.reason_codes !== null &&
170
- (!Array.isArray(assessment.reason_codes) ||
171
- !assessment.reason_codes.every((reason) => typeof reason === "string")))
168
+ if (!optionalTexts(assessment.reason_codes))
172
169
  throw protocol("an assessment reason code is malformed");
173
170
  for (const check of assessment.checks.families) {
174
171
  if (!isObject(check) ||
@@ -233,7 +230,8 @@ function codeAssessment(review) {
233
230
  !["PENDING", "RUNNING", "COMPLETED", "INCOMPLETE", "EXCLUDED"].includes(code.status) ||
234
231
  (code.incompleteness_kind !== null &&
235
232
  code.incompleteness_kind !== undefined &&
236
- typeof code.incompleteness_kind !== "string"))
233
+ typeof code.incompleteness_kind !== "string") ||
234
+ !optionalTexts(code.reason_codes))
237
235
  return null;
238
236
  if ((typeof review.head_commit_sha === "string" &&
239
237
  review.head_commit_sha.toLowerCase() !==
@@ -245,6 +243,12 @@ function codeAssessment(review) {
245
243
  return null;
246
244
  return code;
247
245
  }
246
+ function optionalTexts(value) {
247
+ return (value === undefined ||
248
+ value === null ||
249
+ (Array.isArray(value) &&
250
+ value.every((item) => typeof item === "string")));
251
+ }
248
252
  function assessmentReasons(assessment) {
249
253
  const reasons = [...(assessment.reason_codes ?? [])];
250
254
  if (assessment.incompleteness_kind)
@@ -285,13 +289,19 @@ function outcome(status, reviewUrl, review, reason) {
285
289
  })),
286
290
  }));
287
291
  const code = review && codeAssessment(review);
288
- if (code && (code.status !== "COMPLETED" || code.incompleteness_kind)) {
292
+ if (code &&
293
+ (code.status !== "COMPLETED" ||
294
+ code.incompleteness_kind ||
295
+ code.reason_codes?.length)) {
296
+ const reasons = [...(code.reason_codes ?? [])];
297
+ if (code.incompleteness_kind)
298
+ reasons.push(code.incompleteness_kind);
289
299
  gaps.push({
290
300
  assessmentId: code.id,
291
301
  status: code.status,
292
302
  incompletenessKind: code.incompleteness_kind ?? null,
293
- reasonCodes: code.incompleteness_kind
294
- ? [code.incompleteness_kind]
303
+ reasonCodes: reasons.length
304
+ ? reasons
295
305
  : ["CODE_ASSESSMENT_STATE_UNAVAILABLE"],
296
306
  releaseEvidenceGap: null,
297
307
  checks: [],
package/dist/transport.js CHANGED
@@ -1,4 +1,4 @@
1
- const VERSION = "5.11.0";
1
+ const VERSION = "5.11.1";
2
2
  const MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
3
3
  const MAX_RETRIES = 3;
4
4
  const MAX_RETRY_SECONDS = 60;
@@ -210,7 +210,9 @@ function problem(status, value, token) {
210
210
  : // Logged internal errors omit detail; the problem itself still arrived.
211
211
  `the server returned the problem "${title}" without a detail`;
212
212
  const fields = title === undefined ? {} : { title };
213
- if (!("refusal" in body))
213
+ // The contract types a refusal only as a review request's 400. The 402 a
214
+ // credit refusal answers is undocumented, so it stays a plain problem.
215
+ if (status !== 400 || !("refusal" in body))
214
216
  return new ProoflineError(status, type, detail, fields);
215
217
  const view = refusal(body.refusal);
216
218
  if (view === undefined ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proofline/sdk",
3
- "version": "5.11.0",
3
+ "version": "5.11.1",
4
4
  "description": "Typed clients for the token-scoped Proofline review API",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",