@self-review/core 2.0.4 → 2.1.2
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 +441 -0
- package/dist/chunk-5SGPWHGH.cjs +106 -0
- package/dist/chunk-5SGPWHGH.cjs.map +1 -0
- package/dist/chunk-6OEFXBIZ.cjs +5212 -0
- package/dist/chunk-6OEFXBIZ.cjs.map +1 -0
- package/dist/chunk-6X3PJHP5.cjs +416 -0
- package/dist/chunk-6X3PJHP5.cjs.map +1 -0
- package/dist/chunk-CJQEOLI3.js +37 -0
- package/dist/chunk-CJQEOLI3.js.map +1 -0
- package/dist/chunk-IG2YF5LH.js +416 -0
- package/dist/chunk-IG2YF5LH.js.map +1 -0
- package/dist/chunk-IX226KG4.js +106 -0
- package/dist/chunk-IX226KG4.js.map +1 -0
- package/dist/chunk-LSLCQQBN.cjs +3684 -0
- package/dist/chunk-LSLCQQBN.cjs.map +1 -0
- package/dist/chunk-MOYO4RIX.js +3684 -0
- package/dist/chunk-MOYO4RIX.js.map +1 -0
- package/dist/chunk-TOUYY7I6.js +5212 -0
- package/dist/chunk-TOUYY7I6.js.map +1 -0
- package/dist/chunk-VOYTFLPH.cjs +37 -0
- package/dist/chunk-VOYTFLPH.cjs.map +1 -0
- package/dist/filesystem.cjs +56 -0
- package/dist/filesystem.cjs.map +1 -0
- package/dist/filesystem.d.cts +22 -0
- package/dist/filesystem.d.ts +22 -0
- package/dist/filesystem.js +56 -0
- package/dist/index.cjs +348 -6192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -1332
- package/dist/index.d.ts +80 -1332
- package/dist/index.js +234 -5172
- package/dist/index.js.map +1 -1
- package/dist/node-scan-fs-CaufzUZR.d.cts +5 -0
- package/dist/node-scan-fs-DcHI_BYB.d.ts +5 -0
- package/dist/operations-Bqhi9EBH.d.ts +765 -0
- package/dist/operations-UyiUD2Nx.d.cts +765 -0
- package/dist/operations.cjs +91 -0
- package/dist/operations.cjs.map +1 -0
- package/dist/operations.d.cts +6 -0
- package/dist/operations.d.ts +6 -0
- package/dist/operations.js +91 -0
- package/dist/resume-worker.cjs +152 -0
- package/dist/resume-worker.cjs.map +1 -0
- package/dist/resume-worker.d.cts +56 -0
- package/dist/resume-worker.d.ts +56 -0
- package/dist/resume-worker.js +152 -0
- package/dist/resume-worker.js.map +1 -0
- package/dist/review-request-validation-VJG7XZiE.d.cts +62 -0
- package/dist/review-request-validation-VJG7XZiE.d.ts +62 -0
- package/dist/review-xml-decoder-COgRtfkf.d.cts +33 -0
- package/dist/review-xml-decoder-COgRtfkf.d.ts +33 -0
- package/dist/source-identity-CQpAzugz.d.cts +959 -0
- package/dist/source-identity-CQpAzugz.d.ts +959 -0
- package/dist/validation.cjs +67 -0
- package/dist/validation.cjs.map +1 -0
- package/dist/validation.d.cts +30 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.js +67 -0
- package/dist/validation.js.map +1 -0
- package/package.json +44 -3
- package/dist/chunk-4YO2MI6B.js +0 -269
- package/dist/chunk-4YO2MI6B.js.map +0 -1
- package/dist/chunk-QHS36X6T.js +0 -450
- package/dist/chunk-QHS36X6T.js.map +0 -1
- package/dist/diff-parser-B6S3KG5T.js +0 -9
- package/dist/git-N5HVNPKQ.js +0 -24
- /package/dist/{diff-parser-B6S3KG5T.js.map → filesystem.js.map} +0 -0
- /package/dist/{git-N5HVNPKQ.js.map → operations.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resume-worker-protocol.ts","../src/resume-worker.ts"],"sourcesContent":["import type { ParsedReview } from './xml-parser';\n\nexport interface ResumeParseRequest {\n id: string;\n path: string;\n}\n\n/** Name/stack/cause are additive; legacy serve failures only carried message/code/details. */\nexport interface ResumeParseFailure {\n name?: string;\n message: string;\n stack?: string;\n code?: string;\n details?: readonly string[];\n cause?: unknown;\n}\n\nexport type ResumeParseReply =\n | { id: string; kind: 'parsed'; parsed: ParsedReview }\n | { id: string; kind: 'failed'; error: ResumeParseFailure };\n\n/** Validates the reply envelope without changing the parser's result or optional metadata. */\nexport function readResumeReply(\n reply: unknown,\n id: string,\n restoreFailure: (failure: ResumeParseFailure) => Error\n): ParsedReview {\n if (!isRecord(reply) || reply.id !== id) {\n throw new Error('Resume parser returned an unowned reply');\n }\n if (reply.kind === 'failed' && isFailure(reply.error)) throw restoreFailure(reply.error);\n if (\n reply.kind === 'parsed' &&\n isRecord(reply.parsed) &&\n Array.isArray(reply.parsed.comments) &&\n Array.isArray(reply.parsed.viewedFiles) &&\n Array.isArray(reply.parsed.importDiagnostics)\n ) {\n return reply.parsed as unknown as ParsedReview;\n }\n throw new Error('Resume parser returned an invalid reply');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object';\n}\n\nfunction isFailure(value: unknown): value is ResumeParseFailure {\n return (\n isRecord(value) &&\n typeof value.message === 'string' &&\n ['name', 'stack', 'code'].every(\n key => value[key] === undefined || typeof value[key] === 'string'\n ) &&\n (value.details === undefined ||\n (Array.isArray(value.details) && value.details.every(detail => typeof detail === 'string')))\n );\n}\n\nexport function describeResumeFailure(\n error: unknown,\n xmlDetails: (error: Error) => Pick<ResumeParseFailure, 'code' | 'details'> | undefined\n): ResumeParseFailure {\n if (!(error instanceof Error)) return { name: 'Error', message: String(error) };\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...xmlDetails(error),\n cause: describeCause((error as Error & { cause?: unknown }).cause),\n };\n}\n\nexport function restoreResumeFailure(\n failure: ResumeParseFailure,\n createXmlError: (\n code: string,\n message: string,\n options: { details?: readonly string[]; cause?: unknown }\n ) => Error\n): Error {\n const cause = restoreCause(failure.cause);\n const error = failure.code\n ? createXmlError(failure.code, failure.message, { details: failure.details, cause })\n : Object.assign(new Error(failure.message), cause === undefined ? {} : { cause });\n if (failure.name !== undefined) error.name = failure.name;\n if (failure.stack) error.stack = failure.stack;\n return error;\n}\n\n// Native Error structured cloning drops errno/code/path. Preserve read diagnostics explicitly.\nfunction describeCause(cause: unknown): unknown {\n if (!(cause instanceof Error)) return cause;\n const native = cause as NodeJS.ErrnoException;\n return {\n name: native.name,\n message: native.message,\n stack: native.stack,\n code: native.code,\n errno: native.errno,\n path: native.path,\n syscall: native.syscall,\n };\n}\n\nfunction restoreCause(cause: unknown): unknown {\n if (!isRecord(cause) || typeof cause.message !== 'string') return cause;\n return Object.assign(new Error(cause.message), cause);\n}\n","// Host-owned one-shot resume work. No parser, filesystem or runtime Core class imports.\nimport type { Worker } from 'node:worker_threads';\nimport type { ParsedReview } from './xml-parser';\nimport { readResumeReply } from './resume-worker-protocol';\nimport type { ResumeParseFailure, ResumeParseRequest } from './resume-worker-protocol';\nexport * from './resume-worker-protocol';\n\nexport interface ResumeWorkerOptions {\n signal?: AbortSignal;\n /** Omitted/zero: 30s; positive fractions round up; capped at 2^31-1 ms. */\n timeoutMs?: number;\n /** The host must revoke ownership when replacing the operation. */\n isCurrent?: () => boolean;\n}\n\nexport function checkResumeOwnership(options: ResumeWorkerOptions): void {\n options.signal?.throwIfAborted();\n if (options.isCurrent && !options.isCurrent()) {\n throw new DOMException('Resume operation is no longer current', 'AbortError');\n }\n}\n\n/** A rejected terminate cannot establish that cancellation released the worker. */\nexport class ResumeWorkerTerminationError extends Error {\n readonly cause: unknown;\n readonly terminationError: unknown;\n\n constructor(terminationError: unknown, cause: unknown) {\n super('Resume parser termination failed; worker release is unconfirmed');\n this.name = 'ResumeWorkerTerminationError';\n this.cause = cause;\n this.terminationError = terminationError;\n }\n}\n\n/**\n * Owns the supplied worker immediately, even on admission/delivery failure. Never\n * adopts a reply before termination. Abort/deadline remain active until reaped.\n * The host reconstructs failures with its installed peer's error constructors.\n */\nexport async function runResumeWorker(\n worker: Pick<Worker, 'on' | 'off' | 'postMessage' | 'terminate'>,\n request: ResumeParseRequest,\n options: ResumeWorkerOptions,\n restoreFailure: (failure: ResumeParseFailure) => Error\n): Promise<ParsedReview> {\n let cancellation: { reason: unknown } | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let onMessage!: (reply: unknown) => void;\n let onError!: (error: Error) => void;\n let onExit!: (code: number) => void;\n let onAbort!: () => void;\n const outcome = await new Promise<ParsedReview>((resolve, reject) => {\n const cancel = (reason: unknown) => {\n // Retain even falsy abort reasons, and the first deadline/abort identity.\n cancellation ??= { reason };\n reject(cancellation.reason);\n };\n onAbort = () => cancel(options.signal!.reason);\n onMessage = reply => {\n try {\n resolve(readResumeReply(reply, request.id, restoreFailure));\n } catch (error) {\n reject(error);\n }\n };\n onError = reject;\n onExit = code => reject(new Error(`Resume parser exited before replying (code ${code})`));\n worker.on('message', onMessage);\n worker.on('error', onError);\n worker.on('exit', onExit);\n options.signal?.addEventListener('abort', onAbort, { once: true });\n try {\n const requested = options.timeoutMs ?? 30_000;\n if (!Number.isFinite(requested) || requested < 0) {\n throw new RangeError('Resume timeout must be a nonnegative finite number');\n }\n const timeoutMs = requested === 0 ? 30_000 : Math.min(Math.ceil(requested), 2_147_483_647);\n timer = setTimeout(\n () => cancel(new DOMException('Resume parsing timed out', 'TimeoutError')),\n timeoutMs\n );\n checkResumeOwnership(options);\n if (!request || typeof request.id !== 'string' || typeof request.path !== 'string') {\n throw new Error('Invalid resume parser request');\n }\n worker.postMessage(request);\n } catch (error) {\n reject(error);\n }\n }).then(\n parsed => ({ ok: true as const, parsed }),\n (error: unknown) => ({ ok: false as const, error })\n );\n let termination: { error: unknown } | undefined;\n try {\n await worker.terminate();\n } catch (error) {\n termination = { error };\n } finally {\n clearTimeout(timer);\n worker.off('message', onMessage);\n worker.off('error', onError);\n worker.off('exit', onExit);\n options.signal?.removeEventListener('abort', onAbort);\n }\n let failure = cancellation ?? (outcome.ok ? undefined : { reason: outcome.error });\n try {\n checkResumeOwnership(options);\n } catch (reason) {\n failure = { reason };\n }\n if (termination) {\n if (failure) throw new ResumeWorkerTerminationError(termination.error, failure.reason);\n throw termination.error;\n }\n if (failure) throw failure.reason;\n if (outcome.ok) return outcome.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EACxB,UAAE;AACA,iBAAa,KAAK;AAClB,WAAO,IAAI,WAAW,SAAS;AAC/B,WAAO,IAAI,SAAS,OAAO;AAC3B,WAAO,IAAI,QAAQ,MAAM;AACzB,YAAQ,QAAQ,oBAAoB,SAAS,OAAO;AAAA,EACtD;AACA,MAAI,UAAU,iBAAiB,QAAQ,KAAK,SAAY,EAAE,QAAQ,QAAQ,MAAM;AAChF,MAAI;AACF,yBAAqB,OAAO;AAAA,EAC9B,SAAS,QAAQ;AACf,cAAU,EAAE,OAAO;AAAA,EACrB;AACA,MAAI,aAAa;AACf,QAAI,QAAS,OAAM,IAAI,6BAA6B,YAAY,OAAO,QAAQ,MAAM;AACrF,UAAM,YAAY;AAAA,EACpB;AACA,MAAI,QAAS,OAAM,QAAQ;AAC3B,MAAI,QAAQ,GAAI,QAAO,QAAQ;AAC/B,QAAM,QAAQ;AAChB;","names":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReviewState, SuggestionApplyRequest } from '@self-review/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validate the complete in-memory DTO without I/O. Unknown extension fields are retained.
|
|
5
|
+
* Historical submissions may omit nullable anchors/suggestions; the returned DTO defaults them to null.
|
|
6
|
+
* Already complete DTOs are returned unchanged.
|
|
7
|
+
* Hosts can catch ReviewXmlError (`invalid-state`) before accepting a submission. Serialization and
|
|
8
|
+
* publication use the same boundary, including when the XSD validator is unavailable.
|
|
9
|
+
*/
|
|
10
|
+
declare function validateReviewState(value: unknown): ReviewState;
|
|
11
|
+
|
|
12
|
+
type ReviewXmlErrorCode = 'read-failed'
|
|
13
|
+
/** Over a safety budget (input-budgets.ts): byte size or attachment count. */
|
|
14
|
+
| 'input-too-large' | 'parse-failed'
|
|
15
|
+
/** Well-formed, but with no `<review>` root element. */
|
|
16
|
+
| 'missing-root'
|
|
17
|
+
/** The generated document does not validate against the v3 XSD. */
|
|
18
|
+
| 'schema-invalid'
|
|
19
|
+
/** The in-memory review DTO is malformed or has an unusable anchor. */
|
|
20
|
+
| 'invalid-state' | 'xml-illegal-character';
|
|
21
|
+
declare class ReviewXmlError extends Error {
|
|
22
|
+
readonly code: ReviewXmlErrorCode;
|
|
23
|
+
readonly cause?: unknown;
|
|
24
|
+
/** One rendered line per problem (e.g. a schema violation with its line number). */
|
|
25
|
+
readonly details: readonly string[];
|
|
26
|
+
constructor(code: ReviewXmlErrorCode, message: string, options?: {
|
|
27
|
+
cause?: unknown;
|
|
28
|
+
details?: readonly string[];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
interface XmlIllegalCharacterLocation {
|
|
32
|
+
/** e.g. `body`, `original-code`, `path`, `author`. */
|
|
33
|
+
field: string;
|
|
34
|
+
filePath?: string;
|
|
35
|
+
commentId?: string;
|
|
36
|
+
replyId?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown before anything is written: no escaped form exists, and dropping the character would
|
|
40
|
+
* change the reviewer's text or a suggestion's code.
|
|
41
|
+
*/
|
|
42
|
+
declare class XmlIllegalCharacterError extends ReviewXmlError {
|
|
43
|
+
readonly codePoint: number;
|
|
44
|
+
readonly field: string;
|
|
45
|
+
readonly filePath?: string;
|
|
46
|
+
readonly commentId?: string;
|
|
47
|
+
readonly replyId?: string;
|
|
48
|
+
constructor(codePoint: number, location: XmlIllegalCharacterLocation);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare const MAX_CONTEXT_LINES = 99999;
|
|
52
|
+
type RequestDecodeResult<T> = {
|
|
53
|
+
ok: true;
|
|
54
|
+
value: T;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
/** Preserves extension fields; each transport decides its own unknown-key policy. */
|
|
60
|
+
declare function decodeSuggestionApplyRequest(value: unknown): RequestDecodeResult<SuggestionApplyRequest>;
|
|
61
|
+
|
|
62
|
+
export { MAX_CONTEXT_LINES as M, ReviewXmlError as R, XmlIllegalCharacterError as X, type RequestDecodeResult as a, type ReviewXmlErrorCode as b, type XmlIllegalCharacterLocation as c, decodeSuggestionApplyRequest as d, validateReviewState as v };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ReviewState, SuggestionApplyRequest } from '@self-review/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Validate the complete in-memory DTO without I/O. Unknown extension fields are retained.
|
|
5
|
+
* Historical submissions may omit nullable anchors/suggestions; the returned DTO defaults them to null.
|
|
6
|
+
* Already complete DTOs are returned unchanged.
|
|
7
|
+
* Hosts can catch ReviewXmlError (`invalid-state`) before accepting a submission. Serialization and
|
|
8
|
+
* publication use the same boundary, including when the XSD validator is unavailable.
|
|
9
|
+
*/
|
|
10
|
+
declare function validateReviewState(value: unknown): ReviewState;
|
|
11
|
+
|
|
12
|
+
type ReviewXmlErrorCode = 'read-failed'
|
|
13
|
+
/** Over a safety budget (input-budgets.ts): byte size or attachment count. */
|
|
14
|
+
| 'input-too-large' | 'parse-failed'
|
|
15
|
+
/** Well-formed, but with no `<review>` root element. */
|
|
16
|
+
| 'missing-root'
|
|
17
|
+
/** The generated document does not validate against the v3 XSD. */
|
|
18
|
+
| 'schema-invalid'
|
|
19
|
+
/** The in-memory review DTO is malformed or has an unusable anchor. */
|
|
20
|
+
| 'invalid-state' | 'xml-illegal-character';
|
|
21
|
+
declare class ReviewXmlError extends Error {
|
|
22
|
+
readonly code: ReviewXmlErrorCode;
|
|
23
|
+
readonly cause?: unknown;
|
|
24
|
+
/** One rendered line per problem (e.g. a schema violation with its line number). */
|
|
25
|
+
readonly details: readonly string[];
|
|
26
|
+
constructor(code: ReviewXmlErrorCode, message: string, options?: {
|
|
27
|
+
cause?: unknown;
|
|
28
|
+
details?: readonly string[];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
interface XmlIllegalCharacterLocation {
|
|
32
|
+
/** e.g. `body`, `original-code`, `path`, `author`. */
|
|
33
|
+
field: string;
|
|
34
|
+
filePath?: string;
|
|
35
|
+
commentId?: string;
|
|
36
|
+
replyId?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Thrown before anything is written: no escaped form exists, and dropping the character would
|
|
40
|
+
* change the reviewer's text or a suggestion's code.
|
|
41
|
+
*/
|
|
42
|
+
declare class XmlIllegalCharacterError extends ReviewXmlError {
|
|
43
|
+
readonly codePoint: number;
|
|
44
|
+
readonly field: string;
|
|
45
|
+
readonly filePath?: string;
|
|
46
|
+
readonly commentId?: string;
|
|
47
|
+
readonly replyId?: string;
|
|
48
|
+
constructor(codePoint: number, location: XmlIllegalCharacterLocation);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare const MAX_CONTEXT_LINES = 99999;
|
|
52
|
+
type RequestDecodeResult<T> = {
|
|
53
|
+
ok: true;
|
|
54
|
+
value: T;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
/** Preserves extension fields; each transport decides its own unknown-key policy. */
|
|
60
|
+
declare function decodeSuggestionApplyRequest(value: unknown): RequestDecodeResult<SuggestionApplyRequest>;
|
|
61
|
+
|
|
62
|
+
export { MAX_CONTEXT_LINES as M, ReviewXmlError as R, XmlIllegalCharacterError as X, type RequestDecodeResult as a, type ReviewXmlErrorCode as b, type XmlIllegalCharacterLocation as c, decodeSuggestionApplyRequest as d, validateReviewState as v };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReviewComment, DiffSource, RemoteForge } from '@self-review/types';
|
|
2
|
+
|
|
3
|
+
interface ReviewXmlDecoderOptions {
|
|
4
|
+
/** Called once per comment and reply, in document order. */
|
|
5
|
+
createId?: () => string;
|
|
6
|
+
}
|
|
7
|
+
interface ParsedReview {
|
|
8
|
+
comments: ReviewComment[];
|
|
9
|
+
/** Paths of files the previous review marked as done (`viewed="true"`). */
|
|
10
|
+
viewedFiles: string[];
|
|
11
|
+
gitDiffArgs: string;
|
|
12
|
+
source: DiffSource;
|
|
13
|
+
/**
|
|
14
|
+
* One line per comment downgraded to file-level feedback, with its suggestion text folded into
|
|
15
|
+
* the body.
|
|
16
|
+
*/
|
|
17
|
+
importDiagnostics: string[];
|
|
18
|
+
remoteUrl?: string;
|
|
19
|
+
remoteBaseSha?: string;
|
|
20
|
+
remoteHeadSha?: string;
|
|
21
|
+
remoteForge?: RemoteForge;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Namespace-blind by design: v1, v2 and v3 documents read identically.
|
|
25
|
+
*
|
|
26
|
+
* @throws ReviewXmlError `parse-failed`, `missing-root`, or `input-too-large`
|
|
27
|
+
* (over `MAX_RESUME_XML_BYTES` in UTF-8, or `MAX_REVIEW_ATTACHMENTS`).
|
|
28
|
+
* Oversized strings are refused before XML validation or parsing, like file input.
|
|
29
|
+
* Parsing remains synchronous; this byte budget does not make it preemptible.
|
|
30
|
+
*/
|
|
31
|
+
declare function parseReviewXmlString(xmlContent: string, options?: ReviewXmlDecoderOptions): ParsedReview;
|
|
32
|
+
|
|
33
|
+
export { type ParsedReview as P, type ReviewXmlDecoderOptions as R, parseReviewXmlString as p };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReviewComment, DiffSource, RemoteForge } from '@self-review/types';
|
|
2
|
+
|
|
3
|
+
interface ReviewXmlDecoderOptions {
|
|
4
|
+
/** Called once per comment and reply, in document order. */
|
|
5
|
+
createId?: () => string;
|
|
6
|
+
}
|
|
7
|
+
interface ParsedReview {
|
|
8
|
+
comments: ReviewComment[];
|
|
9
|
+
/** Paths of files the previous review marked as done (`viewed="true"`). */
|
|
10
|
+
viewedFiles: string[];
|
|
11
|
+
gitDiffArgs: string;
|
|
12
|
+
source: DiffSource;
|
|
13
|
+
/**
|
|
14
|
+
* One line per comment downgraded to file-level feedback, with its suggestion text folded into
|
|
15
|
+
* the body.
|
|
16
|
+
*/
|
|
17
|
+
importDiagnostics: string[];
|
|
18
|
+
remoteUrl?: string;
|
|
19
|
+
remoteBaseSha?: string;
|
|
20
|
+
remoteHeadSha?: string;
|
|
21
|
+
remoteForge?: RemoteForge;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Namespace-blind by design: v1, v2 and v3 documents read identically.
|
|
25
|
+
*
|
|
26
|
+
* @throws ReviewXmlError `parse-failed`, `missing-root`, or `input-too-large`
|
|
27
|
+
* (over `MAX_RESUME_XML_BYTES` in UTF-8, or `MAX_REVIEW_ATTACHMENTS`).
|
|
28
|
+
* Oversized strings are refused before XML validation or parsing, like file input.
|
|
29
|
+
* Parsing remains synchronous; this byte budget does not make it preemptible.
|
|
30
|
+
*/
|
|
31
|
+
declare function parseReviewXmlString(xmlContent: string, options?: ReviewXmlDecoderOptions): ParsedReview;
|
|
32
|
+
|
|
33
|
+
export { type ParsedReview as P, type ReviewXmlDecoderOptions as R, parseReviewXmlString as p };
|