@gate-forge/pack-alembic 0.8.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/LICENSE +202 -0
- package/README.md +60 -0
- package/dist/compile.d.ts +168 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +623 -0
- package/dist/compile.js.map +1 -0
- package/dist/detector.d.ts +46 -0
- package/dist/detector.d.ts.map +1 -0
- package/dist/detector.js +77 -0
- package/dist/detector.js.map +1 -0
- package/dist/execute.d.ts +75 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +101 -0
- package/dist/execute.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lineage.d.ts +6 -0
- package/dist/lineage.d.ts.map +1 -0
- package/dist/lineage.js +6 -0
- package/dist/lineage.js.map +1 -0
- package/dist/merge-safety.d.ts +5 -0
- package/dist/merge-safety.d.ts.map +1 -0
- package/dist/merge-safety.js +5 -0
- package/dist/merge-safety.js.map +1 -0
- package/dist/obligations.d.ts +5 -0
- package/dist/obligations.d.ts.map +1 -0
- package/dist/obligations.js +5 -0
- package/dist/obligations.js.map +1 -0
- package/dist/opt-in.d.ts +21 -0
- package/dist/opt-in.d.ts.map +1 -0
- package/dist/opt-in.js +56 -0
- package/dist/opt-in.js.map +1 -0
- package/dist/preservation.d.ts +5 -0
- package/dist/preservation.d.ts.map +1 -0
- package/dist/preservation.js +5 -0
- package/dist/preservation.js.map +1 -0
- package/dist/roundtrip.d.ts +6 -0
- package/dist/roundtrip.d.ts.map +1 -0
- package/dist/roundtrip.js +6 -0
- package/dist/roundtrip.js.map +1 -0
- package/dist/scratch.d.ts +69 -0
- package/dist/scratch.d.ts.map +1 -0
- package/dist/scratch.js +131 -0
- package/dist/scratch.js.map +1 -0
- package/dist/version.d.ts +8 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +8 -0
- package/dist/version.js.map +1 -0
- package/package.json +43 -0
- package/python/gateforge_alembic_detector/__init__.py +11 -0
- package/python/gateforge_alembic_detector/__main__.py +45 -0
- package/python/gateforge_alembic_detector/runner.py +430 -0
- package/python/gateforge_alembic_detector/scan.py +386 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gate-forge/pack-alembic — Alembic migration detector.
|
|
3
|
+
*
|
|
4
|
+
* Implements the GPP/3 in-process plugin contract over python3 -m gateforge_alembic_detector.
|
|
5
|
+
*/
|
|
6
|
+
import { type DiscoveryOutcome } from '@gate-forge/plugin-protocol';
|
|
7
|
+
/** Default subprocess command for the GPP/3 detector. */
|
|
8
|
+
export declare const DEFAULT_COMMAND: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Builds the environment the python detector runs under.
|
|
11
|
+
*
|
|
12
|
+
* Args:
|
|
13
|
+
* extra: Additional leading PYTHONPATH entries.
|
|
14
|
+
*
|
|
15
|
+
* Returns:
|
|
16
|
+
* NodeJS.ProcessEnv: Combined process environment with PYTHONPATH.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pythonEnvironment(extra?: readonly string[]): NodeJS.ProcessEnv;
|
|
19
|
+
/** Options for createAlembicDetector. */
|
|
20
|
+
export interface AlembicDetectorOptions {
|
|
21
|
+
/** Repo root directory. */
|
|
22
|
+
cwd?: string;
|
|
23
|
+
/** Subprocess command. */
|
|
24
|
+
command?: readonly string[];
|
|
25
|
+
/** Subprocess environment. */
|
|
26
|
+
env?: NodeJS.ProcessEnv;
|
|
27
|
+
/** Handshake-pinned plugin id. */
|
|
28
|
+
pluginId?: string;
|
|
29
|
+
/** Handshake-pinned plugin version. */
|
|
30
|
+
pluginVersion?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The pinned in-process plugin contract: discover(paths). */
|
|
33
|
+
export interface AlembicDetector {
|
|
34
|
+
discover(paths: readonly string[]): Promise<DiscoveryOutcome>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates an Alembic detector instance implementing the GPP/3 in-process contract.
|
|
38
|
+
*
|
|
39
|
+
* Args:
|
|
40
|
+
* options: Detector configuration options.
|
|
41
|
+
*
|
|
42
|
+
* Returns:
|
|
43
|
+
* AlembicDetector: The discover-capable detector.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createAlembicDetector(options?: AlembicDetectorOptions): AlembicDetector;
|
|
46
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAWnF,yDAAyD;AACzD,eAAO,MAAM,eAAe,UAAkD,CAAC;AAE/E;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,UAAU,CAOlF;AAED,yCAAyC;AACzC,MAAM,WAAW,sBAAsB;IACrC,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0BAA0B;IAC1B,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAkC3F"}
|
package/dist/detector.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gate-forge/pack-alembic — Alembic migration detector.
|
|
3
|
+
*
|
|
4
|
+
* Implements the GPP/3 in-process plugin contract over python3 -m gateforge_alembic_detector.
|
|
5
|
+
*/
|
|
6
|
+
import { delimiter, resolve } from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { PluginSession } from '@gate-forge/plugin-protocol';
|
|
9
|
+
import { PACK_PLUGIN_ID, PACK_VERSION } from './version.js';
|
|
10
|
+
/** Absolute directory of this pack's python tree. */
|
|
11
|
+
const PACK_PYTHON_DIR = fileURLToPath(new URL('../python', import.meta.url));
|
|
12
|
+
/** Absolute directory of the sibling plugin-protocol python client. */
|
|
13
|
+
const PROTOCOL_PYTHON_DIR = fileURLToPath(new URL('../../../plugin-protocol/python', import.meta.url));
|
|
14
|
+
/** Default subprocess command for the GPP/3 detector. */
|
|
15
|
+
export const DEFAULT_COMMAND = ['python3', '-m', 'gateforge_alembic_detector'];
|
|
16
|
+
/**
|
|
17
|
+
* Builds the environment the python detector runs under.
|
|
18
|
+
*
|
|
19
|
+
* Args:
|
|
20
|
+
* extra: Additional leading PYTHONPATH entries.
|
|
21
|
+
*
|
|
22
|
+
* Returns:
|
|
23
|
+
* NodeJS.ProcessEnv: Combined process environment with PYTHONPATH.
|
|
24
|
+
*/
|
|
25
|
+
export function pythonEnvironment(extra = []) {
|
|
26
|
+
const entries = [...extra, PACK_PYTHON_DIR, PROTOCOL_PYTHON_DIR];
|
|
27
|
+
return {
|
|
28
|
+
...process.env,
|
|
29
|
+
PYTHONDONTWRITEBYTECODE: '1',
|
|
30
|
+
PYTHONPATH: entries.join(delimiter),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates an Alembic detector instance implementing the GPP/3 in-process contract.
|
|
35
|
+
*
|
|
36
|
+
* Args:
|
|
37
|
+
* options: Detector configuration options.
|
|
38
|
+
*
|
|
39
|
+
* Returns:
|
|
40
|
+
* AlembicDetector: The discover-capable detector.
|
|
41
|
+
*/
|
|
42
|
+
export function createAlembicDetector(options = {}) {
|
|
43
|
+
const command = options.command ?? DEFAULT_COMMAND;
|
|
44
|
+
const env = options.env ?? pythonEnvironment();
|
|
45
|
+
const cwd = options.cwd ?? process.cwd();
|
|
46
|
+
const pluginId = options.pluginId ?? PACK_PLUGIN_ID;
|
|
47
|
+
const pluginVersion = options.pluginVersion ?? PACK_VERSION;
|
|
48
|
+
return {
|
|
49
|
+
async discover(paths) {
|
|
50
|
+
if (paths.length === 0) {
|
|
51
|
+
return {
|
|
52
|
+
resources: [],
|
|
53
|
+
unresolved: [],
|
|
54
|
+
findings: [],
|
|
55
|
+
classificationSignals: [],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const session = new PluginSession({
|
|
59
|
+
command: [...command],
|
|
60
|
+
pluginId,
|
|
61
|
+
pluginVersion,
|
|
62
|
+
cwd,
|
|
63
|
+
env,
|
|
64
|
+
timeouts: { handshakeMs: 10_000, requestMs: 30_000, shutdownMs: 10_000 },
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
await session.start();
|
|
68
|
+
const outcome = await session.discover([...paths]);
|
|
69
|
+
return outcome;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
await session.dispose();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAyB,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5D,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AE,EAAE;oBACZ,qBAAqB,EAAE,EAAE;iBAC1B,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC;gBAChC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC;gBACrB,QAAQ;gBACR,aAAa;gBACb,GAAG;gBACH,GAAG;gBACH,QAAQ,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE;aACzE,CAAC,CAAC;YACH,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;gBACtB,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;gBACnD,OAAO,OAAO,CAAC;YACjB,CAAC;oBAAS,CAAC;gBACT,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YAC1B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** One parsed migration resource from the AST scanner. */
|
|
2
|
+
export interface ScannedMigration {
|
|
3
|
+
/** Revision id. */
|
|
4
|
+
revision: string;
|
|
5
|
+
/** Parent revision ids. */
|
|
6
|
+
downRevisions: string[];
|
|
7
|
+
/** Repo-relative path. */
|
|
8
|
+
relPath: string;
|
|
9
|
+
/** True when downgrade() is pass or missing. */
|
|
10
|
+
downgradeNoop: boolean;
|
|
11
|
+
/** True when upgrade() is pass or missing. */
|
|
12
|
+
upgradeNoop: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Lineage facts the compiler grades. */
|
|
15
|
+
export interface ScanLineage {
|
|
16
|
+
/** Scanner findings (protocol shape, no host fields). */
|
|
17
|
+
findings: Array<{
|
|
18
|
+
code: string;
|
|
19
|
+
detail: string;
|
|
20
|
+
locations: Array<{
|
|
21
|
+
file: string;
|
|
22
|
+
line: number;
|
|
23
|
+
col: number;
|
|
24
|
+
}>;
|
|
25
|
+
}>;
|
|
26
|
+
/** Parsed migrations keyed by revision. */
|
|
27
|
+
migrations: ScannedMigration[];
|
|
28
|
+
/** Head revision ids. */
|
|
29
|
+
heads: string[];
|
|
30
|
+
/** Files the scanner read. */
|
|
31
|
+
scannedPaths: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs the AST scanner. Never executes migration code.
|
|
35
|
+
*
|
|
36
|
+
* Args:
|
|
37
|
+
* cwd: repository root.
|
|
38
|
+
* paths: repo-relative files or directories.
|
|
39
|
+
* python: interpreter. Defaults to python3.
|
|
40
|
+
* extraPythonPath: leading PYTHONPATH entries.
|
|
41
|
+
*
|
|
42
|
+
* Returns:
|
|
43
|
+
* ScanLineage: revisions, heads, and findings.
|
|
44
|
+
*/
|
|
45
|
+
export declare function scanLineage(cwd: string, paths: readonly string[], python?: string, extraPythonPath?: readonly string[]): ScanLineage;
|
|
46
|
+
/** Runner result. */
|
|
47
|
+
export interface RunnerResult {
|
|
48
|
+
/** True when the command finished without a mapped cause. */
|
|
49
|
+
ok: boolean;
|
|
50
|
+
/** Stable cause when `ok` is false. */
|
|
51
|
+
cause?: string;
|
|
52
|
+
/** Single-cause detail. */
|
|
53
|
+
detail?: string;
|
|
54
|
+
/** Schema snapshot, when requested. */
|
|
55
|
+
snapshot?: unknown;
|
|
56
|
+
/** Column fingerprints, when requested. */
|
|
57
|
+
fingerprints?: Record<string, {
|
|
58
|
+
count: number;
|
|
59
|
+
columns: Record<string, string | null>;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Invokes the engine-owned Python runner. The project's env.py is not used.
|
|
64
|
+
*
|
|
65
|
+
* Args:
|
|
66
|
+
* cwd: repository root.
|
|
67
|
+
* payload: runner command document.
|
|
68
|
+
* python: interpreter.
|
|
69
|
+
* extraPythonPath: leading PYTHONPATH entries.
|
|
70
|
+
*
|
|
71
|
+
* Returns:
|
|
72
|
+
* RunnerResult: parsed JSON result. A crashed runner is a failed result.
|
|
73
|
+
*/
|
|
74
|
+
export declare function runPython(cwd: string, payload: Record<string, unknown>, python?: string, extraPythonPath?: readonly string[]): RunnerResult;
|
|
75
|
+
//# sourceMappingURL=execute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAMA,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,aAAa,EAAE,OAAO,CAAC;IACvB,8CAA8C;IAC9C,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,yDAAyD;IACzD,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IACjH,2CAA2C;IAC3C,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,yBAAyB;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,8BAA8B;IAC9B,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,SAAY,EAClB,eAAe,GAAE,SAAS,MAAM,EAAO,GACtC,WAAW,CAwCb;AAED,qBAAqB;AACrB,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,EAAE,EAAE,OAAO,CAAC;IACZ,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;KAAE,CAAC,CAAC;CAC1F;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,SAAY,EAClB,eAAe,GAAE,SAAS,MAAM,EAAO,GACtC,YAAY,CAiCd"}
|
package/dist/execute.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subprocess boundary for the Alembic detector and roundtrip runner.
|
|
3
|
+
*/
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { pythonEnvironment } from './detector.js';
|
|
6
|
+
/**
|
|
7
|
+
* Runs the AST scanner. Never executes migration code.
|
|
8
|
+
*
|
|
9
|
+
* Args:
|
|
10
|
+
* cwd: repository root.
|
|
11
|
+
* paths: repo-relative files or directories.
|
|
12
|
+
* python: interpreter. Defaults to python3.
|
|
13
|
+
* extraPythonPath: leading PYTHONPATH entries.
|
|
14
|
+
*
|
|
15
|
+
* Returns:
|
|
16
|
+
* ScanLineage: revisions, heads, and findings.
|
|
17
|
+
*/
|
|
18
|
+
export function scanLineage(cwd, paths, python = 'python3', extraPythonPath = []) {
|
|
19
|
+
const result = spawnSync(python, ['-m', 'gateforge_alembic_detector.scan', cwd, ...paths], {
|
|
20
|
+
cwd,
|
|
21
|
+
encoding: 'utf8',
|
|
22
|
+
env: pythonEnvironment(extraPythonPath),
|
|
23
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
24
|
+
});
|
|
25
|
+
if (result.status !== 0) {
|
|
26
|
+
throw new Error((result.stderr ?? result.stdout ?? 'alembic scan failed').trim());
|
|
27
|
+
}
|
|
28
|
+
const parsed = JSON.parse(result.stdout ?? '{}');
|
|
29
|
+
const migrations = [];
|
|
30
|
+
let heads = [];
|
|
31
|
+
for (const resource of parsed.resources ?? []) {
|
|
32
|
+
const attributes = resource.attributes ?? {};
|
|
33
|
+
if (resource.kind === 'alembic.migration') {
|
|
34
|
+
migrations.push({
|
|
35
|
+
revision: String(attributes['revision'] ?? ''),
|
|
36
|
+
downRevisions: Array.isArray(attributes['downRevisions'])
|
|
37
|
+
? attributes['downRevisions'].filter((item) => typeof item === 'string')
|
|
38
|
+
: [],
|
|
39
|
+
relPath: String(resource.source ?? ''),
|
|
40
|
+
downgradeNoop: attributes['downgradeNoop'] === true,
|
|
41
|
+
upgradeNoop: attributes['upgradeNoop'] === true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (resource.kind === 'alembic.chain' && Array.isArray(attributes['heads'])) {
|
|
45
|
+
heads = attributes['heads'].filter((item) => typeof item === 'string');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
findings: parsed.findings ?? [],
|
|
50
|
+
migrations,
|
|
51
|
+
heads,
|
|
52
|
+
scannedPaths: parsed.scannedPaths ?? [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Invokes the engine-owned Python runner. The project's env.py is not used.
|
|
57
|
+
*
|
|
58
|
+
* Args:
|
|
59
|
+
* cwd: repository root.
|
|
60
|
+
* payload: runner command document.
|
|
61
|
+
* python: interpreter.
|
|
62
|
+
* extraPythonPath: leading PYTHONPATH entries.
|
|
63
|
+
*
|
|
64
|
+
* Returns:
|
|
65
|
+
* RunnerResult: parsed JSON result. A crashed runner is a failed result.
|
|
66
|
+
*/
|
|
67
|
+
export function runPython(cwd, payload, python = 'python3', extraPythonPath = []) {
|
|
68
|
+
const env = pythonEnvironment(extraPythonPath);
|
|
69
|
+
delete env['DATABASE_URL'];
|
|
70
|
+
delete env['SQLALCHEMY_URL'];
|
|
71
|
+
const result = spawnSync(python, ['-m', 'gateforge_alembic_detector.runner'], {
|
|
72
|
+
cwd,
|
|
73
|
+
input: JSON.stringify(payload),
|
|
74
|
+
encoding: 'utf8',
|
|
75
|
+
env,
|
|
76
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
77
|
+
});
|
|
78
|
+
if (result.status !== 0 && (result.stdout ?? '').trim() === '') {
|
|
79
|
+
const detail = result.error?.message ??
|
|
80
|
+
(result.stderr ?? '').trim().split('\n').filter(Boolean).at(-1) ??
|
|
81
|
+
(result.signal === null
|
|
82
|
+
? `Alembic runner exited with status ${String(result.status)} without a result`
|
|
83
|
+
: `Alembic runner terminated by ${result.signal}`);
|
|
84
|
+
return {
|
|
85
|
+
ok: false,
|
|
86
|
+
cause: 'MIGRATION_ROUNDTRIP_FAILED',
|
|
87
|
+
detail,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(result.stdout ?? '{}');
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
cause: 'MIGRATION_ROUNDTRIP_FAILED',
|
|
97
|
+
detail: (result.stderr ?? result.stdout ?? 'runner returned non-JSON').trim().slice(0, 500),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../src/execute.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA4BlD;;;;;;;;;;;GAW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AAI,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/D,MAAM,MAAM,GACV,MAAM,CAAC,KAAK,EAAE,OAAO;YACrB,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/D,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI;gBACrB,CAAC,CAAC,qCAAqC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB;gBAC/E,CAAC,CAAC,gCAAgC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACvD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,4BAA4B;YACnC,MAAM;SACP,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAiB,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,4BAA4B;YACnC,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,0BAA0B,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;SAC5F,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { PACK_PLUGIN_ID, PACK_VERSION } from './version.js';
|
|
2
|
+
export { createAlembicDetector, DEFAULT_COMMAND, pythonEnvironment, type AlembicDetector, type AlembicDetectorOptions, } from './detector.js';
|
|
3
|
+
export { ALEMBIC_DATA_PRESERVED, ALEMBIC_LINEAGE_INTACT, ALEMBIC_MERGE_CLEAN, ALEMBIC_POLICY_ID, ALEMBIC_ROUNDTRIP_VERIFIED, ALEMBIC_WITNESS_KIND, compileAlembic, executePreservation, executeRoundtrip, filesDigest, globMatches, mergeTargetWorktree, previousHead, type AlembicCompileResult, type ChainLocation, } from './compile.js';
|
|
4
|
+
export { scanLineage, runPython, type ScanLineage, type ScannedMigration, type RunnerResult } from './execute.js';
|
|
5
|
+
export { SCRATCH_PREFIX, ScratchUnsafeError, createScratchDatabase, dropScratchDatabase, isScratchDatabaseName, scratchDatabaseExists, urlForDatabase, } from './scratch.js';
|
|
6
|
+
export { detectAlembicVersionsDir, renderAlembicOptIn } from './opt-in.js';
|
|
7
|
+
/** Default CLI in-process plugin module: `{ discover(paths) }`. */
|
|
8
|
+
declare const _default: import("./detector.js").AlembicDetector;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,KAAK,oBAAoB,EACzB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAClH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE3E,mEAAmE;;AACnE,wBAAuC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gate-forge/pack-alembic — opt-in Alembic migration obligations.
|
|
3
|
+
*
|
|
4
|
+
* A repository without an `alembic` key in `.gateforge.yml` does not load
|
|
5
|
+
* this compiler. The default export is the GPP/3 detector, which reports
|
|
6
|
+
* revision facts and does not by itself create obligations.
|
|
7
|
+
*/
|
|
8
|
+
import { createAlembicDetector } from './detector.js';
|
|
9
|
+
export { PACK_PLUGIN_ID, PACK_VERSION } from './version.js';
|
|
10
|
+
export { createAlembicDetector, DEFAULT_COMMAND, pythonEnvironment, } from './detector.js';
|
|
11
|
+
export { ALEMBIC_DATA_PRESERVED, ALEMBIC_LINEAGE_INTACT, ALEMBIC_MERGE_CLEAN, ALEMBIC_POLICY_ID, ALEMBIC_ROUNDTRIP_VERIFIED, ALEMBIC_WITNESS_KIND, compileAlembic, executePreservation, executeRoundtrip, filesDigest, globMatches, mergeTargetWorktree, previousHead, } from './compile.js';
|
|
12
|
+
export { scanLineage, runPython } from './execute.js';
|
|
13
|
+
export { SCRATCH_PREFIX, ScratchUnsafeError, createScratchDatabase, dropScratchDatabase, isScratchDatabaseName, scratchDatabaseExists, urlForDatabase, } from './scratch.js';
|
|
14
|
+
export { detectAlembicVersionsDir, renderAlembicOptIn } from './opt-in.js';
|
|
15
|
+
/** Default CLI in-process plugin module: `{ discover(paths) }`. */
|
|
16
|
+
export default createAlembicDetector();
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,GAGlB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,YAAY,GAGb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,SAAS,EAA8D,MAAM,cAAc,CAAC;AAClH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE3E,mEAAmE;AACnE,eAAe,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage.d.ts","sourceRoot":"","sources":["../src/lineage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/lineage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage.js","sourceRoot":"","sources":["../src/lineage.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,WAAW,EAA2C,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-safety.d.ts","sourceRoot":"","sources":["../src/merge-safety.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-safety.js","sourceRoot":"","sources":["../src/merge-safety.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obligations.d.ts","sourceRoot":"","sources":["../src/obligations.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obligations.js","sourceRoot":"","sources":["../src/obligations.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,cAAc,CAAC"}
|
package/dist/opt-in.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads `script_location` from an alembic.ini, when the file is present.
|
|
3
|
+
*
|
|
4
|
+
* Args:
|
|
5
|
+
* cwd: repository root.
|
|
6
|
+
*
|
|
7
|
+
* Returns:
|
|
8
|
+
* string | null: versions directory guess, or null when alembic.ini is absent.
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectAlembicVersionsDir(cwd: string): string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Prints the commented opt-in block and the command that proves it.
|
|
13
|
+
*
|
|
14
|
+
* Args:
|
|
15
|
+
* cwd: repository root.
|
|
16
|
+
*
|
|
17
|
+
* Returns:
|
|
18
|
+
* string | null: text to print, or null when no alembic.ini exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare function renderAlembicOptIn(cwd: string): string | null;
|
|
21
|
+
//# sourceMappingURL=opt-in.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opt-in.d.ts","sourceRoot":"","sources":["../src/opt-in.ts"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoB7D"}
|
package/dist/opt-in.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup text for the opt-in Alembic block. Init prints it. It does not
|
|
3
|
+
* enable the pack.
|
|
4
|
+
*/
|
|
5
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
6
|
+
import { join } from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Reads `script_location` from an alembic.ini, when the file is present.
|
|
9
|
+
*
|
|
10
|
+
* Args:
|
|
11
|
+
* cwd: repository root.
|
|
12
|
+
*
|
|
13
|
+
* Returns:
|
|
14
|
+
* string | null: versions directory guess, or null when alembic.ini is absent.
|
|
15
|
+
*/
|
|
16
|
+
export function detectAlembicVersionsDir(cwd) {
|
|
17
|
+
const iniPath = join(cwd, 'alembic.ini');
|
|
18
|
+
if (!existsSync(iniPath))
|
|
19
|
+
return null;
|
|
20
|
+
const text = readFileSync(iniPath, 'utf8');
|
|
21
|
+
const match = text.match(/^\s*script_location\s*=\s*(\S+)/m);
|
|
22
|
+
const script = match?.[1]?.replace(/\\/g, '/') ?? 'migrations';
|
|
23
|
+
return script.endsWith('/versions') ? script : `${script}/versions`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Prints the commented opt-in block and the command that proves it.
|
|
27
|
+
*
|
|
28
|
+
* Args:
|
|
29
|
+
* cwd: repository root.
|
|
30
|
+
*
|
|
31
|
+
* Returns:
|
|
32
|
+
* string | null: text to print, or null when no alembic.ini exists.
|
|
33
|
+
*/
|
|
34
|
+
export function renderAlembicOptIn(cwd) {
|
|
35
|
+
const versions = detectAlembicVersionsDir(cwd);
|
|
36
|
+
if (versions === null)
|
|
37
|
+
return null;
|
|
38
|
+
return [
|
|
39
|
+
'alembic detected: alembic.ini. Migration obligations are opt-in and are not enabled.',
|
|
40
|
+
'alembic-opt-in: begin',
|
|
41
|
+
'alembic:',
|
|
42
|
+
' chains:',
|
|
43
|
+
' - name: default',
|
|
44
|
+
` migrations: ${versions}`,
|
|
45
|
+
' models:',
|
|
46
|
+
' - models.py',
|
|
47
|
+
' alembicIni: alembic.ini',
|
|
48
|
+
' scratch:',
|
|
49
|
+
' # Trusted admin URL. The engine creates and drops only gf_tmp_<id> databases.',
|
|
50
|
+
' adminUrl: postgresql://gateforge:gateforge@127.0.0.1:5432/postgres',
|
|
51
|
+
' irreversible: []',
|
|
52
|
+
'alembic-opt-in: end',
|
|
53
|
+
'command: gateforge check',
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=opt-in.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opt-in.js","sourceRoot":"","sources":["../src/opt-in.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,YAAY,CAAC;IAC/D,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,WAAW,CAAC;AACtE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,QAAQ,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO;QACL,sFAAsF;QACtF,uBAAuB;QACvB,UAAU;QACV,WAAW;QACX,qBAAqB;QACrB,qBAAqB,QAAQ,EAAE;QAC/B,eAAe;QACf,qBAAqB;QACrB,+BAA+B;QAC/B,YAAY;QACZ,mFAAmF;QACnF,wEAAwE;QACxE,oBAAoB;QACpB,qBAAqB;QACrB,0BAA0B;KAC3B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preservation.d.ts","sourceRoot":"","sources":["../src/preservation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preservation.js","sourceRoot":"","sources":["../src/preservation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roundtrip.d.ts","sourceRoot":"","sources":["../src/roundtrip.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roundtrip.js","sourceRoot":"","sources":["../src/roundtrip.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Prefix every engine-created database name must carry. */
|
|
2
|
+
export declare const SCRATCH_PREFIX = "gf_tmp_";
|
|
3
|
+
/** Thrown when a database name or URL is not a disposable scratch database. */
|
|
4
|
+
export declare class ScratchUnsafeError extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Builds one scratch-safety error.
|
|
7
|
+
*
|
|
8
|
+
* Args:
|
|
9
|
+
* message: single-cause explanation.
|
|
10
|
+
*/
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether a database name is an engine-created scratch database.
|
|
15
|
+
*
|
|
16
|
+
* Args:
|
|
17
|
+
* name: database name, not a URL.
|
|
18
|
+
*
|
|
19
|
+
* Returns:
|
|
20
|
+
* boolean: true only for `gf_tmp_` plus lowercase hex.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isScratchDatabaseName(name: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Replaces the database name in a postgres URL.
|
|
25
|
+
*
|
|
26
|
+
* Args:
|
|
27
|
+
* adminUrl: trusted admin URL from configuration.
|
|
28
|
+
* name: scratch database name.
|
|
29
|
+
*
|
|
30
|
+
* Returns:
|
|
31
|
+
* string: URL pointing at `name`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function urlForDatabase(adminUrl: string, name: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a disposable database from a trusted admin URL.
|
|
36
|
+
*
|
|
37
|
+
* Args:
|
|
38
|
+
* adminUrl: trusted admin URL. Not read from the environment.
|
|
39
|
+
*
|
|
40
|
+
* Returns:
|
|
41
|
+
* object: scratch name and URL. The caller must drop the database.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createScratchDatabase(adminUrl: string): {
|
|
44
|
+
name: string;
|
|
45
|
+
url: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Drops a disposable database. Refuses any name that is not `gf_tmp_`.
|
|
49
|
+
*
|
|
50
|
+
* Args:
|
|
51
|
+
* adminUrl: trusted admin URL.
|
|
52
|
+
* name: database name to drop.
|
|
53
|
+
*
|
|
54
|
+
* Returns:
|
|
55
|
+
* void: the database is gone, or the call throws before touching it.
|
|
56
|
+
*/
|
|
57
|
+
export declare function dropScratchDatabase(adminUrl: string, name: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a scratch database still exists.
|
|
60
|
+
*
|
|
61
|
+
* Args:
|
|
62
|
+
* adminUrl: trusted admin URL.
|
|
63
|
+
* name: database name.
|
|
64
|
+
*
|
|
65
|
+
* Returns:
|
|
66
|
+
* boolean: true when the catalog lists the name.
|
|
67
|
+
*/
|
|
68
|
+
export declare function scratchDatabaseExists(adminUrl: string, name: string): boolean;
|
|
69
|
+
//# sourceMappingURL=scratch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scratch.d.ts","sourceRoot":"","sources":["../src/scratch.ts"],"names":[],"mappings":"AAUA,4DAA4D;AAC5D,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,+EAA+E;AAC/E,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C;;;;;OAKG;gBACS,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAOrE;AA2BD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAUrF;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAKxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQ7E"}
|