vouchington-tooling 0.1.1 → 0.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
CHANGED
|
@@ -90,7 +90,11 @@ import {
|
|
|
90
90
|
import { createArtifactClassifier, runCleanup } from 'vouchington-tooling/gha-artifacts-cleanup'
|
|
91
91
|
import { validateOptionalHttpOrigin } from 'vouchington-tooling/http-origin'
|
|
92
92
|
import { boundPendingLine, splitCompleteLines } from 'vouchington-tooling/process-line-buffer'
|
|
93
|
-
import {
|
|
93
|
+
import {
|
|
94
|
+
isProcessGroupAlive,
|
|
95
|
+
runBrowserSession,
|
|
96
|
+
waitForProcessGroupExit,
|
|
97
|
+
} from 'vouchington-tooling/browser-session-runner'
|
|
94
98
|
import {
|
|
95
99
|
generateSchemaSnapshot,
|
|
96
100
|
renderSchemaMarkdown,
|
|
@@ -144,3 +148,5 @@ are terminal. Output is decoded independently per stream; unfinished lines are c
|
|
|
144
148
|
`diagnosticTailBytes` retains a UTF-8-safe tail no larger than its byte budget.
|
|
145
149
|
The runner uses monotonic elapsed time, rejects timer budgets above Node's maximum delay, and waits for
|
|
146
150
|
the dedicated process group to exit after the direct child closes so descendants cannot overlap a retry.
|
|
151
|
+
`isProcessGroupAlive` and `waitForProcessGroupExit` are also available when callers need the same
|
|
152
|
+
process-group probe and bounded-drain semantics outside a browser session.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { BrowserSessionDeps, BrowserSessionOptions, BrowserSessionResult } from './types.mts';
|
|
2
2
|
export type { BrowserSessionDeps, BrowserSessionEvent, BrowserSessionExit, BrowserSessionOptions, BrowserSessionOutput, BrowserSessionProcess, BrowserSessionResult, BrowserSessionTerminationReason, BrowserSessionWatchdog, BrowserSessionWatchdogCleanup, BrowserSessionWatchdogController, } from './types.mts';
|
|
3
|
-
export { ProcessGroupDrainTimeoutError } from './process-group.mts';
|
|
3
|
+
export { isProcessGroupAlive, ProcessGroupDrainTimeoutError, waitForProcessGroupExit, } from './process-group.mts';
|
|
4
4
|
export declare function runBrowserSession(options: BrowserSessionOptions, deps?: BrowserSessionDeps): Promise<BrowserSessionResult>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { runAttempt } from './attempt.mjs';
|
|
2
2
|
import { expiredResult } from './result.mjs';
|
|
3
3
|
import { isProcessGroupAlive, waitForProcessGroupExit } from './process-group.mjs';
|
|
4
|
-
export { ProcessGroupDrainTimeoutError } from './process-group.mjs';
|
|
4
|
+
export { isProcessGroupAlive, ProcessGroupDrainTimeoutError, waitForProcessGroupExit, } from './process-group.mjs';
|
|
5
5
|
const defaultDeps = {
|
|
6
6
|
clearInterval,
|
|
7
7
|
clearTimeout,
|
|
@@ -44,6 +44,7 @@ export async function runBrowserSession(options, deps = defaultDeps) {
|
|
|
44
44
|
}
|
|
45
45
|
function validateOptions(options) {
|
|
46
46
|
const maxTimerDelay = 2_147_483_647;
|
|
47
|
+
const drainTimeoutMs = options.graceMs + (options.processGroupDrainMs ?? options.graceMs);
|
|
47
48
|
for (const [name, value] of [
|
|
48
49
|
['attempts', options.attempts],
|
|
49
50
|
['deadlineMs', options.deadlineMs],
|
|
@@ -59,6 +60,8 @@ function validateOptions(options) {
|
|
|
59
60
|
const tailBytes = options.diagnosticTailBytes ?? 4096;
|
|
60
61
|
if (!Number.isSafeInteger(tailBytes) || tailBytes <= 0)
|
|
61
62
|
throw new RangeError('diagnosticTailBytes must be positive');
|
|
63
|
+
if (!Number.isSafeInteger(drainTimeoutMs) || drainTimeoutMs > maxTimerDelay)
|
|
64
|
+
throw new RangeError('graceMs + processGroupDrainMs must be a positive Node timer delay');
|
|
62
65
|
}
|
|
63
66
|
function omitAttempts({ attempts: _attempts, ...result }) {
|
|
64
67
|
return result;
|
|
@@ -5,6 +5,8 @@ export class ProcessGroupDrainTimeoutError extends Error {
|
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export function isProcessGroupAlive(processGroupId) {
|
|
8
|
+
validateProcessGroupId(processGroupId);
|
|
9
|
+
assertSupportedPlatform();
|
|
8
10
|
try {
|
|
9
11
|
process.kill(-processGroupId, 0);
|
|
10
12
|
return true;
|
|
@@ -14,6 +16,9 @@ export function isProcessGroupAlive(processGroupId) {
|
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
export async function waitForProcessGroupExit(processGroupId, timeoutMs) {
|
|
19
|
+
validateProcessGroupId(processGroupId);
|
|
20
|
+
validateTimerDelay(timeoutMs);
|
|
21
|
+
assertSupportedPlatform();
|
|
17
22
|
const deadline = performance.now() + timeoutMs;
|
|
18
23
|
while (isProcessGroupAlive(processGroupId)) {
|
|
19
24
|
if (performance.now() >= deadline)
|
|
@@ -21,3 +26,17 @@ export async function waitForProcessGroupExit(processGroupId, timeoutMs) {
|
|
|
21
26
|
await new Promise((resolve) => setTimeout(resolve, Math.min(10, deadline - performance.now())));
|
|
22
27
|
}
|
|
23
28
|
}
|
|
29
|
+
function assertSupportedPlatform() {
|
|
30
|
+
if (process.platform === 'win32')
|
|
31
|
+
throw new Error('process-group control is unsupported on Windows');
|
|
32
|
+
}
|
|
33
|
+
function validateProcessGroupId(processGroupId) {
|
|
34
|
+
if (!Number.isSafeInteger(processGroupId) ||
|
|
35
|
+
processGroupId <= 1 ||
|
|
36
|
+
processGroupId > 2_147_483_647)
|
|
37
|
+
throw new RangeError('processGroupId must be a positive supported PID');
|
|
38
|
+
}
|
|
39
|
+
function validateTimerDelay(timeoutMs) {
|
|
40
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 2_147_483_647)
|
|
41
|
+
throw new RangeError('timeoutMs must be a positive Node timer delay');
|
|
42
|
+
}
|
package/dist/index.d.mts
CHANGED
|
@@ -22,7 +22,7 @@ export { createArtifactClassifier, parseArtifactPatternsJson, planRunDeletions,
|
|
|
22
22
|
export type { ArtifactClassification, ArtifactClassifier, ArtifactPatterns, CleanupRequest, DeletionSummary, } from './gha-artifacts-cleanup/index.mts';
|
|
23
23
|
export { validateOptionalHttpOrigin } from './http-origin/index.mts';
|
|
24
24
|
export { boundPendingLine, DEFAULT_MAX_PENDING_LINE_LENGTH, DEFAULT_TRUNCATED_LINE_MARKER, splitCompleteLines, } from './process-line-buffer/index.mts';
|
|
25
|
-
export { ProcessGroupDrainTimeoutError, runBrowserSession, } from './browser-session-runner/index.mts';
|
|
25
|
+
export { isProcessGroupAlive, ProcessGroupDrainTimeoutError, runBrowserSession, waitForProcessGroupExit, } from './browser-session-runner/index.mts';
|
|
26
26
|
export type { BrowserSessionDeps, BrowserSessionEvent, BrowserSessionExit, BrowserSessionOptions, BrowserSessionOutput, BrowserSessionProcess, BrowserSessionResult, BrowserSessionTerminationReason, BrowserSessionWatchdog, BrowserSessionWatchdogCleanup, BrowserSessionWatchdogController, } from './browser-session-runner/index.mts';
|
|
27
27
|
export { buildSchemaSnapshot, detectRenamedIndexes, generateSchemaSnapshot, indexShapeKey, readSchemaCatalog, renderSchemaMarkdown, stableStringify, writeSchemaSnapshot, } from './pg-schema-snapshot/index.mts';
|
|
28
28
|
export type { CatalogQuery, PartitionPolicy, SchemaCatalog, SchemaGrowthMaps, SchemaSnapshot, SchemaTableSnapshot, } from './pg-schema-snapshot/index.mts';
|
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export { decodeSelectedFiles, encodeSelectedFiles, formatMultilineOutput, SELECT
|
|
|
13
13
|
export { createArtifactClassifier, parseArtifactPatternsJson, planRunDeletions, runCleanup, sweepCleanup, } from './gha-artifacts-cleanup/index.mjs';
|
|
14
14
|
export { validateOptionalHttpOrigin } from './http-origin/index.mjs';
|
|
15
15
|
export { boundPendingLine, DEFAULT_MAX_PENDING_LINE_LENGTH, DEFAULT_TRUNCATED_LINE_MARKER, splitCompleteLines, } from './process-line-buffer/index.mjs';
|
|
16
|
-
export { ProcessGroupDrainTimeoutError, runBrowserSession, } from './browser-session-runner/index.mjs';
|
|
16
|
+
export { isProcessGroupAlive, ProcessGroupDrainTimeoutError, runBrowserSession, waitForProcessGroupExit, } from './browser-session-runner/index.mjs';
|
|
17
17
|
export { buildSchemaSnapshot, detectRenamedIndexes, generateSchemaSnapshot, indexShapeKey, readSchemaCatalog, renderSchemaMarkdown, stableStringify, writeSchemaSnapshot, } from './pg-schema-snapshot/index.mjs';
|
|
18
18
|
export { buildOpenApiDocument, hashContractSchema, nodeToOpenApi, writeOpenApi, } from './openapi-document/index.mjs';
|
|
19
19
|
export { decide, deriveRetryAttempt } from './transient-retry/index.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vouchington-tooling",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Vouchington CLI and extractable tooling libraries.",
|
|
5
5
|
"homepage": "https://github.com/vouchington/vouchington-tooling/tree/main/packages/vouchington-tooling#readme",
|
|
6
6
|
"bugs": {
|