@wavehouse/chtypes 0.1.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/CHANGELOG.md +24 -0
- package/LICENSE +202 -0
- package/README.md +442 -0
- package/dist/cli.d.ts +43 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +303 -0
- package/dist/cli.js.map +1 -0
- package/dist/discover.d.ts +134 -0
- package/dist/discover.d.ts.map +1 -0
- package/dist/discover.js +291 -0
- package/dist/discover.js.map +1 -0
- package/dist/errors.d.ts +204 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +228 -0
- package/dist/errors.js.map +1 -0
- package/dist/fetch.d.ts +235 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +842 -0
- package/dist/fetch.js.map +1 -0
- package/dist/ffi.d.ts +346 -0
- package/dist/ffi.d.ts.map +1 -0
- package/dist/ffi.js +913 -0
- package/dist/ffi.js.map +1 -0
- package/dist/format.d.ts +104 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +108 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +127 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +577 -0
- package/dist/json.js.map +1 -0
- package/dist/library.d.ts +225 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +234 -0
- package/dist/library.js.map +1 -0
- package/dist/numeric.d.ts +20 -0
- package/dist/numeric.d.ts.map +1 -0
- package/dist/numeric.js +107 -0
- package/dist/numeric.js.map +1 -0
- package/dist/paths.d.ts +47 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +78 -0
- package/dist/paths.js.map +1 -0
- package/dist/registry.d.ts +204 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +409 -0
- package/dist/registry.js.map +1 -0
- package/dist/results.d.ts +326 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +235 -0
- package/dist/results.js.map +1 -0
- package/dist/schema.d.ts +444 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +448 -0
- package/dist/schema.js.map +1 -0
- package/dist/settings.d.ts +43 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +33 -0
- package/dist/settings.js.map +1 -0
- package/dist/tar.d.ts +32 -0
- package/dist/tar.d.ts.map +1 -0
- package/dist/tar.js +310 -0
- package/dist/tar.js.map +1 -0
- package/dist/transform.d.ts +73 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +527 -0
- package/dist/transform.js.map +1 -0
- package/package.json +62 -0
package/dist/paths.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where artifacts are looked for and where a fetch writes — the §1 search
|
|
3
|
+
* path of docs/fetch.md, spelled once so the loader (`Registry`), the fetch
|
|
4
|
+
* (`ensure`) and the CLI (`chtypes where`) cannot disagree about it.
|
|
5
|
+
*
|
|
6
|
+
* The search path, in order, first directory that holds the requested line
|
|
7
|
+
* wins:
|
|
8
|
+
*
|
|
9
|
+
* 1. a path given explicitly to the registry constructor
|
|
10
|
+
* 2. `CHTYPES_REGISTRY`
|
|
11
|
+
* 3. `${XDG_CACHE_HOME:-~/.cache}/chtypes/artifacts/<os>-<arch>` — the
|
|
12
|
+
* per-user cache, where fetch installs
|
|
13
|
+
* 4. `/usr/local/share/chtypes/artifacts/<os>-<arch>`, then
|
|
14
|
+
* `/opt/chtypes/artifacts/<os>-<arch>` — system locations, reserved
|
|
15
|
+
*
|
|
16
|
+
* A fetch WRITES to the first of (1), (2), (3) that is set; never to (4).
|
|
17
|
+
*/
|
|
18
|
+
import os from 'node:os';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
/**
|
|
21
|
+
* This host's platform key, `<os>-<arch>` in the artifact spellings
|
|
22
|
+
* (`linux`/`darwin`, `arm64`/`amd64`), e.g. `darwin-arm64`.
|
|
23
|
+
*/
|
|
24
|
+
export function hostPlatform() {
|
|
25
|
+
const arch = { x64: 'amd64', arm64: 'arm64' }[os.arch()] ?? os.arch();
|
|
26
|
+
return `${os.platform()}-${arch}`;
|
|
27
|
+
}
|
|
28
|
+
/** True for the four platform keys a release can carry. */
|
|
29
|
+
export function isPlatformKey(key) {
|
|
30
|
+
return /^(linux|darwin)-(arm64|amd64)$/.test(key);
|
|
31
|
+
}
|
|
32
|
+
/** `${XDG_CACHE_HOME:-~/.cache}/chtypes` — the root every chtypes cache lives under. */
|
|
33
|
+
export function cacheRoot() {
|
|
34
|
+
const xdg = process.env['XDG_CACHE_HOME'];
|
|
35
|
+
const base = xdg !== undefined && xdg !== '' ? xdg : path.join(os.homedir(), '.cache');
|
|
36
|
+
return path.join(base, 'chtypes');
|
|
37
|
+
}
|
|
38
|
+
/** The per-user artifact cache for one platform — search-path slot (3). */
|
|
39
|
+
export function cacheRegistryDir(platform = hostPlatform()) {
|
|
40
|
+
return path.join(cacheRoot(), 'artifacts', platform);
|
|
41
|
+
}
|
|
42
|
+
/** The reserved system locations — search-path slot (4), never written by fetch. */
|
|
43
|
+
export function systemRegistryDirs(platform = hostPlatform()) {
|
|
44
|
+
return [`/usr/local/share/chtypes/artifacts/${platform}`, `/opt/chtypes/artifacts/${platform}`];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The §1 search path for one platform: every candidate directory, in order,
|
|
48
|
+
* whether or not it exists. `explicit` is slot (1); `CHTYPES_REGISTRY` is
|
|
49
|
+
* slot (2) when set. Duplicates collapse to their first position.
|
|
50
|
+
*/
|
|
51
|
+
export function registrySearchPath(explicit, platform = hostPlatform()) {
|
|
52
|
+
const out = [];
|
|
53
|
+
if (explicit !== undefined && explicit !== '')
|
|
54
|
+
out.push(path.resolve(explicit));
|
|
55
|
+
const env = process.env['CHTYPES_REGISTRY'];
|
|
56
|
+
if (env !== undefined && env !== '')
|
|
57
|
+
out.push(path.resolve(env));
|
|
58
|
+
out.push(cacheRegistryDir(platform), ...systemRegistryDirs(platform));
|
|
59
|
+
return [...new Set(out)];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Where a fetch writes: the first of (1) `explicit`, (2) `CHTYPES_REGISTRY`,
|
|
63
|
+
* (3) the per-user cache that is set — never a system location.
|
|
64
|
+
*
|
|
65
|
+
* `CHTYPES_REGISTRY` names THIS host's registry, so it is only a destination
|
|
66
|
+
* for this host's own platform; artifacts fetched for another platform (a
|
|
67
|
+
* container's `linux-arm64` from a Mac) land in the cache keyed by that
|
|
68
|
+
* platform unless `explicit` says otherwise.
|
|
69
|
+
*/
|
|
70
|
+
export function fetchDestination(explicit, platform = hostPlatform()) {
|
|
71
|
+
if (explicit !== undefined && explicit !== '')
|
|
72
|
+
return path.resolve(explicit);
|
|
73
|
+
const env = process.env['CHTYPES_REGISTRY'];
|
|
74
|
+
if (env !== undefined && env !== '' && platform === hostPlatform())
|
|
75
|
+
return path.resolve(env);
|
|
76
|
+
return cacheRegistryDir(platform);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,IAAI,GAAI,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAA6B,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;IAClG,OAAO,GAAG,EAAE,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC;AACpC,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,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CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB,EAAE,QAAQ,GAAW,YAAY,EAAE;IACnF,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,IAAI,QAAQ,KAAK,YAAY,EAAE;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7F,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The artifact-directory loader: one subdirectory per ClickHouse minor line,
|
|
3
|
+
* each self-contained (spec/artifact.md).
|
|
4
|
+
*
|
|
5
|
+
* <registry>/25.8/{manifest.json, libchtypes.dylib, CH_VERSION, unsafe_families.txt}
|
|
6
|
+
*
|
|
7
|
+
* Two rules here were paid for and are not negotiable:
|
|
8
|
+
*
|
|
9
|
+
* - **The shared library's file name comes from `manifest.json`'s `library`
|
|
10
|
+
* field.** Not from a hard-coded `libchtypes.so`, not from a glob, not from
|
|
11
|
+
* the platform. The current tree proves why: every darwin artifact says
|
|
12
|
+
* `libchtypes.dylib` while the *shipping* linux artifacts still say
|
|
13
|
+
* `libchtypes_s1.so`, so a loader that constructs the name finds nothing on
|
|
14
|
+
* the platform that matters.
|
|
15
|
+
* - **Each artifact is loaded into its own symbol scope (`RTLD_LOCAL`).** That
|
|
16
|
+
* is the entire mechanism by which two builds that both define
|
|
17
|
+
* `DB::DataTypeFactory` live in one process. ffi-rs loads through libloading,
|
|
18
|
+
* which uses `RTLD_LAZY | RTLD_LOCAL`; `assertLocalSymbolScope()` in the test
|
|
19
|
+
* suite proves it from outside rather than trusting the claim.
|
|
20
|
+
*
|
|
21
|
+
* Where a registry IS follows the search path of docs/fetch.md §1 (`paths.ts`):
|
|
22
|
+
* the explicit directory, `CHTYPES_REGISTRY`, the per-user cache, then the
|
|
23
|
+
* reserved system locations. The first directory holding artifacts is scanned
|
|
24
|
+
* and loaded at construction; a line it lacks is taken, on request, from the
|
|
25
|
+
* first later directory that has it. A line no directory has is the one §7
|
|
26
|
+
* error, `ArtifactMissingError` — or, with `autofetch`, a fetch on first
|
|
27
|
+
* `open()`.
|
|
28
|
+
*/
|
|
29
|
+
import { type EnsureOptions } from './fetch.js';
|
|
30
|
+
import { Library } from './library.js';
|
|
31
|
+
/** The nine fields `lib/build.sh` writes. Unknown fields are ignored. */
|
|
32
|
+
export interface Manifest {
|
|
33
|
+
library: string;
|
|
34
|
+
library_bytes?: number;
|
|
35
|
+
library_sha256?: string;
|
|
36
|
+
clickhouse_version?: string;
|
|
37
|
+
clickhouse_minor?: string;
|
|
38
|
+
clickhouse_commit?: string;
|
|
39
|
+
os?: string;
|
|
40
|
+
arch?: string;
|
|
41
|
+
unsafe_families?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Options for `new Registry(dir, options)`. */
|
|
44
|
+
export interface RegistryOptions {
|
|
45
|
+
/**
|
|
46
|
+
* The server timezone assumed for bare DateTime / DateTime64 columns. Defaults
|
|
47
|
+
* to UTC — what a stock ClickHouse container uses — and is deliberately not
|
|
48
|
+
* read from the environment, so the host's TZ cannot leak into results.
|
|
49
|
+
*/
|
|
50
|
+
timezone?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Re-hash each library and compare against `manifest.library_sha256` before
|
|
53
|
+
* loading. SHOULD be on for an artifact that came from anywhere but a local
|
|
54
|
+
* build, and MUST be on for one that came over a network.
|
|
55
|
+
*/
|
|
56
|
+
verifyChecksums?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Lazy fetch on first open (docs/fetch.md §6): `open()` of a line no
|
|
59
|
+
* directory on the search path holds runs `ensure()` first, into the
|
|
60
|
+
* directory a fetch writes to (§1), once per process per line. Off by
|
|
61
|
+
* default — a production process must not begin a 250 MB download inside
|
|
62
|
+
* a request — and `CHTYPES_AUTOFETCH=1` turns it on from the environment.
|
|
63
|
+
* `for()` stays synchronous and never fetches.
|
|
64
|
+
*/
|
|
65
|
+
autofetch?: boolean | undefined;
|
|
66
|
+
/** Options handed to `ensure()` by autofetch: source (`url`/`tag`), lock, keys, progress. */
|
|
67
|
+
fetch?: EnsureOptions | undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The artifact-directory loader — the multi-version entry point of this
|
|
71
|
+
* package. Construction scans one subdirectory per ClickHouse version, dlopens
|
|
72
|
+
* each artifact into its own symbol scope (`RTLD_LOCAL`, ~120 MB resident per
|
|
73
|
+
* version), verifies its ABI revision against this binding's `ABI_REVISION`
|
|
74
|
+
* (a different nonzero revision is refused; 0 means the artifact predates the
|
|
75
|
+
* probe and degrades per symbol), and runs each library's one-time
|
|
76
|
+
* `chs_init` with the UTC default timezone and the artifact's own
|
|
77
|
+
* `unsafe_families.txt`.
|
|
78
|
+
*
|
|
79
|
+
* Libraries are never dlclosed; `close()` joins background threads only.
|
|
80
|
+
* Loading the same artifact path from two `Registry` instances shares one
|
|
81
|
+
* loaded image, so `chs_init` still runs exactly once per artifact.
|
|
82
|
+
*/
|
|
83
|
+
export declare class Registry {
|
|
84
|
+
/**
|
|
85
|
+
* The primary registry directory: the first on the search path that held
|
|
86
|
+
* artifacts, scanned and loaded at construction — or, with `autofetch` and
|
|
87
|
+
* nothing installed anywhere, the directory the first fetch will create.
|
|
88
|
+
*/
|
|
89
|
+
readonly dir: string;
|
|
90
|
+
/** The §1 search path, in order, every candidate whether or not it exists. */
|
|
91
|
+
readonly searchPath: readonly string[];
|
|
92
|
+
/** This host's platform key, e.g. `darwin-arm64` — the only artifacts a process can dlopen. */
|
|
93
|
+
readonly platform: string;
|
|
94
|
+
private readonly byId;
|
|
95
|
+
private readonly byPath;
|
|
96
|
+
private readonly loaded;
|
|
97
|
+
private readonly timezone;
|
|
98
|
+
private readonly verifyChecksums;
|
|
99
|
+
private readonly autofetch;
|
|
100
|
+
private readonly fetchOptions;
|
|
101
|
+
private readonly explicit;
|
|
102
|
+
/**
|
|
103
|
+
* Scan and load a registry.
|
|
104
|
+
*
|
|
105
|
+
* @param dir - the registry root; the head of the search path. Absent, the
|
|
106
|
+
* path is `CHTYPES_REGISTRY`, the per-user artifact cache, then the system
|
|
107
|
+
* locations (see `registrySearchPath` / `defaultRegistryDir`).
|
|
108
|
+
* @param options - timezone, checksum verification, autofetch — see `RegistryOptions`.
|
|
109
|
+
* @throws {RegistryError} when a directory named explicitly (the argument or
|
|
110
|
+
* `CHTYPES_REGISTRY`) does not exist and autofetch is off, when no
|
|
111
|
+
* directory on the search path holds an artifact (and autofetch is off),
|
|
112
|
+
* the primary directory cannot be read, an artifact fails its checksum,
|
|
113
|
+
* fails to load, or reports a ClickHouse version different from its
|
|
114
|
+
* manifest's.
|
|
115
|
+
* @throws {ChtypesError} when an artifact reports a different nonzero ABI
|
|
116
|
+
* revision than this binding speaks, or `chs_init` fails (e.g. an unknown
|
|
117
|
+
* timezone — the message names it).
|
|
118
|
+
*/
|
|
119
|
+
constructor(dir?: string, options?: RegistryOptions);
|
|
120
|
+
/** dlopen one artifact directory, cross-check it, `chs_init` it, index it. */
|
|
121
|
+
private load;
|
|
122
|
+
/** Load `<dir>/<minor>/` if it is an artifact directory; null when it is not. */
|
|
123
|
+
private loadLine;
|
|
124
|
+
private lookup;
|
|
125
|
+
/** The ClickHouse minor lines this registry has loaded, oldest first. */
|
|
126
|
+
versions(): string[];
|
|
127
|
+
/** Every loaded library, in release order (oldest minor line first). */
|
|
128
|
+
libraries(): readonly Library[];
|
|
129
|
+
/**
|
|
130
|
+
* Resolve a version to its library. A minor line ("25.8") or an exact patch
|
|
131
|
+
* ("25.8.28.1-lts") both work, and an unknown patch inside a loaded minor line
|
|
132
|
+
* resolves to that line — asking for "25.8.30.16" finds the loaded 25.8.
|
|
133
|
+
*
|
|
134
|
+
* A line the primary directory lacks is loaded from the first later
|
|
135
|
+
* directory on the search path that holds it (docs/fetch.md §1), and joins
|
|
136
|
+
* `versions()` / `libraries()` from then on. Never a fetch: this call is
|
|
137
|
+
* synchronous; `open()` is the one that may fetch.
|
|
138
|
+
*
|
|
139
|
+
* Failure is the one §7 error, never a fallback to the nearest version:
|
|
140
|
+
* answering 26.7 semantics from a 25.8 artifact is a lie, and silent
|
|
141
|
+
* wrongness is what the rigs score hardest.
|
|
142
|
+
*
|
|
143
|
+
* @param version - a minor line (`"25.8"`) or an exact patch
|
|
144
|
+
* (`"25.8.28.1-lts"`), e.g. what `parseVersionResult` discovered.
|
|
145
|
+
* @returns the loaded `Library` for that version.
|
|
146
|
+
* @throws {ArtifactMissingError} (`code` `CHTYPES_ARTIFACT_MISSING`, a
|
|
147
|
+
* `RegistryError`) when no directory on the search path holds the line;
|
|
148
|
+
* the message names every directory looked in and the fetch command.
|
|
149
|
+
* @throws {RegistryError} when a directory holds the line but it does not load.
|
|
150
|
+
*/
|
|
151
|
+
for(version: string): Library;
|
|
152
|
+
/**
|
|
153
|
+
* `for()`, with the lazy fetch of docs/fetch.md §6 in front of it: a line no
|
|
154
|
+
* directory on the search path holds is fetched through `ensure()` — into
|
|
155
|
+
* the directory a fetch writes to (§1), verified, once per process per line
|
|
156
|
+
* even under concurrent opens — and then loaded. With `autofetch` off (the
|
|
157
|
+
* default) this is `for()` behind a promise, and a missing line rejects
|
|
158
|
+
* with the same `ArtifactMissingError`.
|
|
159
|
+
*
|
|
160
|
+
* @throws {ArtifactMissingError} when the line is missing and autofetch is off.
|
|
161
|
+
* @throws {FetchError} the §7 fetch verdicts (`CHTYPES_ARTIFACT_UNTRUSTED`,
|
|
162
|
+
* `…_CORRUPT`, `…_PINNED`, `…_UNPUBLISHED`, `CHTYPES_SOURCE_UNREACHABLE`).
|
|
163
|
+
* @throws {RegistryError} when the fetched artifact does not load.
|
|
164
|
+
*/
|
|
165
|
+
open(version: string): Promise<Library>;
|
|
166
|
+
/**
|
|
167
|
+
* True when this registry can answer for a version: loaded already, or held
|
|
168
|
+
* by a directory on the search path (which `for()` would load). Never a
|
|
169
|
+
* fetch, and never a load.
|
|
170
|
+
*/
|
|
171
|
+
has(version: string): boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Join every loaded library's background threads. `chs_init` registers
|
|
174
|
+
* `chs_shutdown` with `atexit`, so an ordinary process needs no call; a test
|
|
175
|
+
* that must not depend on `atexit` should make one.
|
|
176
|
+
*/
|
|
177
|
+
close(): void;
|
|
178
|
+
/** `using registry = new Registry(...)` closes it at scope exit. */
|
|
179
|
+
[Symbol.dispose](): void;
|
|
180
|
+
}
|
|
181
|
+
/** Numeric ordering: 25.10 is a later minor than 25.8, whatever strings say. */
|
|
182
|
+
export declare function compareMinor(a: string, b: string): number;
|
|
183
|
+
/**
|
|
184
|
+
* Where the registry is: the explicit argument, else `CHTYPES_REGISTRY`, else
|
|
185
|
+
* the first of the per-user artifact cache and the system locations that
|
|
186
|
+
* holds artifacts (docs/fetch.md §1). An explicit path and the environment
|
|
187
|
+
* variable are returned as given — a wrong one must produce an error naming
|
|
188
|
+
* it, not a silent fallback — while the unnamed candidates only count if they
|
|
189
|
+
* actually hold artifacts.
|
|
190
|
+
*/
|
|
191
|
+
export declare function resolveRegistryDir(explicit?: string): string | null;
|
|
192
|
+
/**
|
|
193
|
+
* The per-user artifact cache for this host —
|
|
194
|
+
* `${XDG_CACHE_HOME:-~/.cache}/chtypes/artifacts/<os>-<arch>`, `<arch>` spelled
|
|
195
|
+
* the artifact way (`amd64`, `arm64`). Where `chtypes fetch` and
|
|
196
|
+
* `scripts/fetch.sh` install, where a core-repository build lands, and what
|
|
197
|
+
* every SDK's tests and playgrounds fall back to when `CHTYPES_REGISTRY` is
|
|
198
|
+
* unset — one directory the four SDKs agree on. A path, not a promise:
|
|
199
|
+
* `Registry` still throws if nothing is there.
|
|
200
|
+
*/
|
|
201
|
+
export declare function defaultRegistryDir(): string;
|
|
202
|
+
/** Does this directory hold at least one artifact with a usable manifest? */
|
|
203
|
+
export declare function looksLikeRegistry(dir: string): boolean;
|
|
204
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAMH,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,OAAO,EAAW,MAAM,cAAc,CAAC;AAGhD,yEAAyE;AACzE,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gDAAgD;AAChD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,6FAA6F;IAC7F,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CACnC;AAED;;;;;;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