@wavehouse/chtypes 0.5.2 → 1.0.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/CHANGELOG.md +34 -0
- package/README.md +34 -38
- package/dist/abi1/buildinfo.d.ts +40 -0
- package/dist/abi1/buildinfo.d.ts.map +1 -0
- package/dist/abi1/buildinfo.js +83 -0
- package/dist/abi1/buildinfo.js.map +1 -0
- package/dist/abi1/calls.gen.d.ts +55 -0
- package/dist/abi1/calls.gen.d.ts.map +1 -0
- package/dist/abi1/calls.gen.js +110 -0
- package/dist/abi1/calls.gen.js.map +1 -0
- package/dist/abi1/decls.gen.d.ts +115 -0
- package/dist/abi1/decls.gen.d.ts.map +1 -0
- package/dist/abi1/decls.gen.js +1613 -0
- package/dist/abi1/decls.gen.js.map +1 -0
- package/dist/abi1/errmap.gen.d.ts +18 -0
- package/dist/abi1/errmap.gen.d.ts.map +1 -0
- package/dist/abi1/errmap.gen.js +66 -0
- package/dist/abi1/errmap.gen.js.map +1 -0
- package/dist/abi1/errors.d.ts +107 -0
- package/dist/abi1/errors.d.ts.map +1 -0
- package/dist/abi1/errors.js +134 -0
- package/dist/abi1/errors.js.map +1 -0
- package/dist/abi1/handles.d.ts +31 -0
- package/dist/abi1/handles.d.ts.map +1 -0
- package/dist/abi1/handles.js +76 -0
- package/dist/abi1/handles.js.map +1 -0
- package/dist/abi1/index.d.ts +17 -0
- package/dist/abi1/index.d.ts.map +1 -0
- package/dist/abi1/index.js +17 -0
- package/dist/abi1/index.js.map +1 -0
- package/dist/abi1/libc.d.ts +54 -0
- package/dist/abi1/libc.d.ts.map +1 -0
- package/dist/abi1/libc.gen.d.ts +12 -0
- package/dist/abi1/libc.gen.d.ts.map +1 -0
- package/dist/abi1/libc.gen.js +75 -0
- package/dist/abi1/libc.gen.js.map +1 -0
- package/dist/abi1/libc.js +109 -0
- package/dist/abi1/libc.js.map +1 -0
- package/dist/abi1/loader.d.ts +101 -0
- package/dist/abi1/loader.d.ts.map +1 -0
- package/dist/abi1/loader.js +274 -0
- package/dist/abi1/loader.js.map +1 -0
- package/dist/abi1/raw.d.ts +104 -0
- package/dist/abi1/raw.d.ts.map +1 -0
- package/dist/abi1/raw.js +296 -0
- package/dist/abi1/raw.js.map +1 -0
- package/dist/abi1/strictjson.d.ts +19 -0
- package/dist/abi1/strictjson.d.ts.map +1 -0
- package/dist/abi1/strictjson.js +78 -0
- package/dist/abi1/strictjson.js.map +1 -0
- package/dist/abi1/vocab.gen.d.ts +169 -0
- package/dist/abi1/vocab.gen.d.ts.map +1 -0
- package/dist/abi1/vocab.gen.js +306 -0
- package/dist/abi1/vocab.gen.js.map +1 -0
- package/dist/cli.d.ts +25 -26
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +206 -218
- package/dist/cli.js.map +1 -1
- package/dist/documents.d.ts +195 -0
- package/dist/documents.d.ts.map +1 -0
- package/dist/documents.js +389 -0
- package/dist/documents.js.map +1 -0
- package/dist/env.d.ts +16 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +57 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +19 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -23
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +11 -89
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +16 -180
- package/dist/json.js.map +1 -1
- package/dist/library.d.ts +53 -309
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +77 -315
- package/dist/library.js.map +1 -1
- package/dist/ocifetch/constants.gen.d.ts +84 -0
- package/dist/ocifetch/constants.gen.d.ts.map +1 -0
- package/dist/ocifetch/constants.gen.js +92 -0
- package/dist/ocifetch/constants.gen.js.map +1 -0
- package/dist/ocifetch/dsse.d.ts +114 -0
- package/dist/ocifetch/dsse.d.ts.map +1 -0
- package/dist/ocifetch/dsse.js +331 -0
- package/dist/ocifetch/dsse.js.map +1 -0
- package/dist/ocifetch/ensure.d.ts +65 -0
- package/dist/ocifetch/ensure.d.ts.map +1 -0
- package/dist/ocifetch/ensure.js +775 -0
- package/dist/ocifetch/ensure.js.map +1 -0
- package/dist/ocifetch/errors.d.ts +92 -0
- package/dist/ocifetch/errors.d.ts.map +1 -0
- package/dist/ocifetch/errors.js +101 -0
- package/dist/ocifetch/errors.js.map +1 -0
- package/dist/ocifetch/goldens.d.ts +44 -0
- package/dist/ocifetch/goldens.d.ts.map +1 -0
- package/dist/ocifetch/goldens.js +62 -0
- package/dist/ocifetch/goldens.js.map +1 -0
- package/dist/ocifetch/http.d.ts +124 -0
- package/dist/ocifetch/http.d.ts.map +1 -0
- package/dist/ocifetch/http.js +549 -0
- package/dist/ocifetch/http.js.map +1 -0
- package/dist/ocifetch/index.d.ts +17 -0
- package/dist/ocifetch/index.d.ts.map +1 -0
- package/dist/ocifetch/index.js +14 -0
- package/dist/ocifetch/index.js.map +1 -0
- package/dist/ocifetch/layout.d.ts +126 -0
- package/dist/ocifetch/layout.d.ts.map +1 -0
- package/dist/ocifetch/layout.js +375 -0
- package/dist/ocifetch/layout.js.map +1 -0
- package/dist/ocifetch/localverify.d.ts +43 -0
- package/dist/ocifetch/localverify.d.ts.map +1 -0
- package/dist/ocifetch/localverify.js +164 -0
- package/dist/ocifetch/localverify.js.map +1 -0
- package/dist/ocifetch/lock.d.ts +39 -0
- package/dist/ocifetch/lock.d.ts.map +1 -0
- package/dist/ocifetch/lock.js +140 -0
- package/dist/ocifetch/lock.js.map +1 -0
- package/dist/ocifetch/oci.d.ts +100 -0
- package/dist/ocifetch/oci.d.ts.map +1 -0
- package/dist/ocifetch/oci.js +323 -0
- package/dist/ocifetch/oci.js.map +1 -0
- package/dist/ocifetch/referrers.d.ts +55 -0
- package/dist/ocifetch/referrers.d.ts.map +1 -0
- package/dist/ocifetch/referrers.js +132 -0
- package/dist/ocifetch/referrers.js.map +1 -0
- package/dist/ocifetch/types.d.ts +167 -0
- package/dist/ocifetch/types.d.ts.map +1 -0
- package/dist/ocifetch/types.js +88 -0
- package/dist/ocifetch/types.js.map +1 -0
- package/dist/ocifetch/unpack.d.ts +55 -0
- package/dist/ocifetch/unpack.d.ts.map +1 -0
- package/dist/ocifetch/unpack.js +205 -0
- package/dist/ocifetch/unpack.js.map +1 -0
- package/dist/registry.d.ts +38 -387
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +95 -819
- package/dist/registry.js.map +1 -1
- package/dist/schema.d.ts +77 -588
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +87 -549
- package/dist/schema.js.map +1 -1
- package/dist/settings.d.ts +27 -36
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +75 -25
- package/dist/settings.js.map +1 -1
- package/dist/setup.d.ts +46 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +79 -0
- package/dist/setup.js.map +1 -0
- package/dist/tar.d.ts +27 -11
- package/dist/tar.d.ts.map +1 -1
- package/dist/tar.js +54 -32
- package/dist/tar.js.map +1 -1
- package/package.json +2 -2
- package/dist/discover.d.ts +0 -142
- package/dist/discover.d.ts.map +0 -1
- package/dist/discover.js +0 -288
- package/dist/discover.js.map +0 -1
- package/dist/error-codes.d.ts +0 -80
- package/dist/error-codes.d.ts.map +0 -1
- package/dist/error-codes.js +0 -139
- package/dist/error-codes.js.map +0 -1
- package/dist/errors.d.ts +0 -284
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -321
- package/dist/errors.js.map +0 -1
- package/dist/fetch.d.ts +0 -382
- package/dist/fetch.d.ts.map +0 -1
- package/dist/fetch.js +0 -1498
- package/dist/fetch.js.map +0 -1
- package/dist/ffi.d.ts +0 -410
- package/dist/ffi.d.ts.map +0 -1
- package/dist/ffi.js +0 -1154
- package/dist/ffi.js.map +0 -1
- package/dist/format.d.ts +0 -128
- package/dist/format.d.ts.map +0 -1
- package/dist/format.js +0 -132
- package/dist/format.js.map +0 -1
- package/dist/numeric.d.ts +0 -20
- package/dist/numeric.d.ts.map +0 -1
- package/dist/numeric.js +0 -107
- package/dist/numeric.js.map +0 -1
- package/dist/paths.d.ts +0 -55
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -87
- package/dist/paths.js.map +0 -1
- package/dist/results.d.ts +0 -495
- package/dist/results.d.ts.map +0 -1
- package/dist/results.js +0 -406
- package/dist/results.js.map +0 -1
- package/dist/transform.d.ts +0 -73
- package/dist/transform.d.ts.map +0 -1
- package/dist/transform.js +0 -533
- package/dist/transform.js.map +0 -1
package/dist/env.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fetch layer's environment (`docs/guides/fetch-v1.md` §2 and §4): the
|
|
3
|
+
* variables that configure a fetch without code. `CHTYPES_ARTIFACTS_URL` and
|
|
4
|
+
* `CHTYPES_CACHE` are read by the fetch layer itself; the rest are read here,
|
|
5
|
+
* once, and an option the caller passed always wins over its variable.
|
|
6
|
+
*
|
|
7
|
+
* CHTYPES_DOWNLOAD_TOKEN `token`
|
|
8
|
+
* CHTYPES_TRUSTED_KEYS `trustedKeys`: comma-separated raw ed25519 keys, 64 hex characters each; REPLACES the default list
|
|
9
|
+
* CHTYPES_ALLOW_UNSIGNED `allowUnsigned`: `1`, `true`, `yes` or `on`
|
|
10
|
+
* CHTYPES_TARGET `platform`: one of the three platform keys
|
|
11
|
+
* CHTYPES_REGISTRY retired: one warning, otherwise ignored
|
|
12
|
+
*/
|
|
13
|
+
import { usageError } from './abi1/index.js';
|
|
14
|
+
import { ENV_ALLOW_UNSIGNED_NAME, ENV_BASES_NAME, ENV_CACHE_NAME, ENV_RETIRED, ENV_TARGET_NAME, ENV_TOKEN_NAME, ENV_TRUSTED_KEYS_NAME, PLATFORMS, } from './ocifetch/constants.gen.js';
|
|
15
|
+
import { isPlatformKey, keyIdOfRawKey } from './ocifetch/index.js';
|
|
16
|
+
const RAW_KEY = /^[0-9a-fA-F]{64}$/;
|
|
17
|
+
let warnedRetired = false;
|
|
18
|
+
function flag(name) {
|
|
19
|
+
const v = process.env[name];
|
|
20
|
+
return v !== undefined && ['1', 'true', 'yes', 'on'].includes(v.trim().toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
/** Fills each option the caller left unset from its environment variable. Pure over `process.env`, except the one retired-variable warning. */
|
|
23
|
+
export function withEnvironment(options) {
|
|
24
|
+
const out = { ...options };
|
|
25
|
+
for (const name of ENV_RETIRED) {
|
|
26
|
+
const v = process.env[name];
|
|
27
|
+
if (v !== undefined && v !== '' && !warnedRetired) {
|
|
28
|
+
warnedRetired = true;
|
|
29
|
+
process.emitWarning(`${name} is retired and ignored; ${ENV_BASES_NAME} and ${ENV_CACHE_NAME} replace it`, { code: 'CHTYPES_ENV_RETIRED' });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const token = process.env[ENV_TOKEN_NAME];
|
|
33
|
+
if (out.token === undefined && token !== undefined && token !== '')
|
|
34
|
+
out.token = token;
|
|
35
|
+
if (out.allowUnsigned === undefined && flag(ENV_ALLOW_UNSIGNED_NAME))
|
|
36
|
+
out.allowUnsigned = true;
|
|
37
|
+
const keys = process.env[ENV_TRUSTED_KEYS_NAME];
|
|
38
|
+
if (out.trustedKeys === undefined && keys !== undefined && keys.trim() !== '') {
|
|
39
|
+
const list = [];
|
|
40
|
+
for (const k of keys.split(',').map((x) => x.trim()).filter((x) => x !== '')) {
|
|
41
|
+
if (!RAW_KEY.test(k)) {
|
|
42
|
+
throw usageError(`${ENV_TRUSTED_KEYS_NAME}: ${JSON.stringify(k)} is not a raw ed25519 public key (64 hex characters)`);
|
|
43
|
+
}
|
|
44
|
+
list.push({ keyid: keyIdOfRawKey(k), ed25519Hex: k.toLowerCase() });
|
|
45
|
+
}
|
|
46
|
+
out.trustedKeys = list;
|
|
47
|
+
}
|
|
48
|
+
const target = process.env[ENV_TARGET_NAME];
|
|
49
|
+
if (out.platform === undefined && target !== undefined && target !== '') {
|
|
50
|
+
if (!isPlatformKey(target)) {
|
|
51
|
+
throw usageError(`${ENV_TARGET_NAME}: ${JSON.stringify(target)} is not a platform; use one of ${PLATFORMS.map((p) => p.key).join(', ')}`);
|
|
52
|
+
}
|
|
53
|
+
out.platform = target;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@wavehouse/chtypes
|
|
2
|
+
* `@wavehouse/chtypes`: ClickHouse's own type system, per version, over the
|
|
3
|
+
* ABI v1 C layer (`docs/reference/bindings-v1.md` is the contract).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* setup(...) optional, once, before the first open
|
|
6
|
+
* Registry.open() --for(request)--> Library --compileTable(createTable)--> Schema --rows(...)--> BatchResult
|
|
7
|
+
* | |
|
|
8
|
+
* validateType(expr) row(...) --> RowResult
|
|
7
9
|
*
|
|
8
|
-
* Nothing here reimplements a
|
|
9
|
-
* own C
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `transformed`, and it is the reason the product exists.
|
|
10
|
+
* Nothing here reimplements a ClickHouse rule: every answer comes from
|
|
11
|
+
* ClickHouse's own C++, vendored per release behind the C ABI, and every result
|
|
12
|
+
* is a one-to-one decode of the document the library returned. `Registry.open`,
|
|
13
|
+
* `for` and `installed` are asynchronous only because the fetch layer is.
|
|
13
14
|
*/
|
|
14
|
-
export { type
|
|
15
|
-
export { type
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export
|
|
22
|
-
export {
|
|
23
|
-
export { compareMinor, defaultRegistryDir, looksLikeRegistry, type Manifest, Registry, type RegistryOptions, type Resolution, resolveRegistryDir, } from './registry.js';
|
|
24
|
-
export { type BatchResult, type ColumnDoc, type Computed, DefaultKind, FilterOutcome, type FilterResult, type FilterRowError, isAnswer, Outcome, type RowResult, Source, type Span, type Substitution, type Transform, type Value, Verdict, } from './results.js';
|
|
25
|
-
export { Block, type ColumnInfo, type CompileFilterOptions, type EngineOptions, Filter, type RowOptions, type RowsOptions, Schema, } from './schema.js';
|
|
26
|
-
export { encodeSettings, type Settings, type SettingValue } from './settings.js';
|
|
27
|
-
export { type ExtractedEntry, extractTarGz } from './tar.js';
|
|
28
|
-
export { isLossyReason, Reason } from './transform.js';
|
|
15
|
+
export { type BuildInfo, type Capabilities, type BatchOutcome, DefaultKind, DiscoverQueryParam, DocFlags, EXPORT_NONE, FilterOutcome, Format, formatChName, Outcome, Reason, reasonLossy, Source, sourceIsStored, Status, Verdict, verdictAnswered, } from './abi1/index.js';
|
|
16
|
+
export { ArtifactCorruptError, ArtifactError, ArtifactIncompatibleError, CallError, type CallErrorFields, ChtypesError, InternalError, isChtypesError, LoaderCorruptError, type LoaderErrorFields, SchemaError, UnsupportedError, UsageError, } from './abi1/index.js';
|
|
17
|
+
export { type BatchResult, type Column, type Computed, type DiscoveredColumn, type EngineCell, type Discovery, type ErrorCodeEntry, ErrorCodeTable, type FilterResult, type FilterRowError, type Framing, type Header, type RowResult, type SchemaDescription, type Span, type Transform, type Value, } from './documents.js';
|
|
18
|
+
export { Library, openUnverified } from './library.js';
|
|
19
|
+
export { ArtifactMissingError, ArtifactPinnedError, ArtifactUnpublishedError, ArtifactUntrustedError, type Resolved, SourceForbiddenError, SourceIncompatibleError, SourceUnauthorizedError, SourceUnreachableError, } from './ocifetch/index.js';
|
|
20
|
+
export { type FetchOptions, Registry, type RegistryOptions } from './registry.js';
|
|
21
|
+
export { Block, type CompileOptions, type EvalOptions, Filter, type FilterOptions, type RowOptions, type RowsOptions, Schema, } from './schema.js';
|
|
22
|
+
export type { BytesIn, Settings } from './settings.js';
|
|
23
|
+
export { setup, type SetupOptions } from './setup.js';
|
|
29
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,MAAM,EACN,YAAY,EACZ,OAAO,EACP,MAAM,EACN,WAAW,EACX,MAAM,EACN,cAAc,EACd,MAAM,EACN,OAAO,EACP,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,yBAAyB,EACzB,SAAS,EACT,KAAK,eAAe,EACpB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,WAAW,EACX,gBAAgB,EAChB,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,KAAK,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,KAAK,QAAQ,EACb,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,YAAY,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EACL,KAAK,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@wavehouse/chtypes
|
|
2
|
+
* `@wavehouse/chtypes`: ClickHouse's own type system, per version, over the
|
|
3
|
+
* ABI v1 C layer (`docs/reference/bindings-v1.md` is the contract).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* setup(...) optional, once, before the first open
|
|
6
|
+
* Registry.open() --for(request)--> Library --compileTable(createTable)--> Schema --rows(...)--> BatchResult
|
|
7
|
+
* | |
|
|
8
|
+
* validateType(expr) row(...) --> RowResult
|
|
7
9
|
*
|
|
8
|
-
* Nothing here reimplements a
|
|
9
|
-
* own C
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `transformed`, and it is the reason the product exists.
|
|
10
|
+
* Nothing here reimplements a ClickHouse rule: every answer comes from
|
|
11
|
+
* ClickHouse's own C++, vendored per release behind the C ABI, and every result
|
|
12
|
+
* is a one-to-one decode of the document the library returned. `Registry.open`,
|
|
13
|
+
* `for` and `installed` are asynchronous only because the fetch layer is.
|
|
13
14
|
*/
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export { isValidUtf8, Json, parseDocument, parseJsonValue, rawBytes, rawText, repairBareDenormals, } from './json.js';
|
|
21
|
-
export { CompileMode, Library, minorOf } from './library.js';
|
|
22
|
-
export { cacheRegistryDir, ENV_AUTOFETCH, ENV_REGISTRY, fetchDestination, hostPlatform, isPlatformKey, registrySearchPath, systemRegistryDirs, } from './paths.js';
|
|
23
|
-
export { compareMinor, defaultRegistryDir, looksLikeRegistry, Registry, resolveRegistryDir, } from './registry.js';
|
|
24
|
-
export { DefaultKind, FilterOutcome, isAnswer, Outcome, Source, Verdict, } from './results.js';
|
|
15
|
+
export { DefaultKind, DiscoverQueryParam, DocFlags, EXPORT_NONE, FilterOutcome, Format, formatChName, Outcome, Reason, reasonLossy, Source, sourceIsStored, Status, Verdict, verdictAnswered, } from './abi1/index.js';
|
|
16
|
+
export { ArtifactCorruptError, ArtifactError, ArtifactIncompatibleError, CallError, ChtypesError, InternalError, isChtypesError, LoaderCorruptError, SchemaError, UnsupportedError, UsageError, } from './abi1/index.js';
|
|
17
|
+
export { ErrorCodeTable, } from './documents.js';
|
|
18
|
+
export { Library, openUnverified } from './library.js';
|
|
19
|
+
export { ArtifactMissingError, ArtifactPinnedError, ArtifactUnpublishedError, ArtifactUntrustedError, SourceForbiddenError, SourceIncompatibleError, SourceUnauthorizedError, SourceUnreachableError, } from './ocifetch/index.js';
|
|
20
|
+
export { Registry } from './registry.js';
|
|
25
21
|
export { Block, Filter, Schema, } from './schema.js';
|
|
26
|
-
export {
|
|
27
|
-
export { extractTarGz } from './tar.js';
|
|
28
|
-
export { isLossyReason, Reason } from './transform.js';
|
|
22
|
+
export { setup } from './setup.js';
|
|
29
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,MAAM,EACN,YAAY,EACZ,OAAO,EACP,MAAM,EACN,WAAW,EACX,MAAM,EACN,cAAc,EACd,MAAM,EACN,OAAO,EACP,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,yBAAyB,EACzB,SAAS,EAET,YAAY,EACZ,aAAa,EACb,cAAc,EACd,kBAAkB,EAElB,WAAW,EACX,gBAAgB,EAChB,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAQL,cAAc,GAUf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EAEtB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAqB,QAAQ,EAAwB,MAAM,eAAe,CAAC;AAClF,OAAO,EACL,KAAK,EAGL,MAAM,EAIN,MAAM,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC"}
|
package/dist/json.d.ts
CHANGED
|
@@ -1,42 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* bytes and passes everything else through). Decoding that document into a JS
|
|
9
|
-
* string replaces every invalid byte with U+FFFD, which then reads downstream
|
|
10
|
-
* as a silent transformation that never happened — an *invented* answer, the
|
|
11
|
-
* failure mode this product exists to prevent (the C ABI contract §Per-column
|
|
12
|
-
* fields: "`stored` and `ref` MUST be handled as raw bytes / raw JSON"; the
|
|
13
|
-
* reference implementation keeps `json.RawMessage`). So the document is parsed
|
|
14
|
-
* from a `Buffer`, and every value remembers the exact slice it was cut from.
|
|
15
|
-
*
|
|
16
|
-
* 2. **Numbers must keep their exact text.** ClickHouse integers go to 2^256.
|
|
17
|
-
* `JSON.parse` turns 18446744073709551615 into 18446744073709552000 and an
|
|
18
|
-
* Int256 into -5.78960446186581e+76 — a value difference no scorer can tell
|
|
19
|
-
* from a real coercion defect. A number is never converted here: it *is* its
|
|
20
|
-
* own source bytes.
|
|
21
|
-
*
|
|
22
|
-
* 3. **Duplicate keys and escape spellings survive.** ClickHouse can store a
|
|
23
|
-
* `Map` with a repeated key (`{"a":1,"a":2}`), and it writes the escape
|
|
24
|
-
* `\\u000B` where a JS re-serialization writes `\\u000b`. `JSON.parse` collapses
|
|
25
|
-
* the first and loses the second, and either reports bytes the table does not
|
|
26
|
-
* hold.
|
|
27
|
-
* Object members are therefore kept as an ordered key/value list, and nothing
|
|
28
|
-
* is ever re-rendered: `rawBytes` hands back the library's own slice.
|
|
29
|
-
*
|
|
30
|
-
* The bare-denormal repair is the one edit made to the bytes, and it is
|
|
31
|
-
* required, not optional: ClickHouse's `serializeTextJSON` writes IEEE denormals
|
|
32
|
-
* as the bare tokens `inf`, `-inf` and `nan` unless
|
|
33
|
-
* `output_format_json_quote_denormals` is set. That is faithful ClickHouse
|
|
34
|
-
* output and it is not valid JSON — one QBit column full of infinities took an
|
|
35
|
-
* entire result document down and cost 18 arbiter cases at once.
|
|
36
|
-
* `repairBareDenormals` is the port of `quoteBareDenormals`
|
|
37
|
-
* (go/chtypes/chtypes.go): it quotes the token and changes nothing
|
|
38
|
-
* else, and it runs before any slice is cut, so the reference implementation and
|
|
39
|
-
* this one end up holding the same bytes.
|
|
2
|
+
* The fetch layer's JSON plumbing: a parser over bytes whose values remember the
|
|
3
|
+
* exact slice they were cut from, with duplicate keys kept in source order (the
|
|
4
|
+
* fetch layer's own duplicate-key refusals read them). The result documents of
|
|
5
|
+
* the C layer no longer use it: they are decoded with the stock `JSON.parse`
|
|
6
|
+
* (`./documents.ts`), because the library's documents are valid RFC 8259 JSON.
|
|
7
|
+
* It is kept for the fetch layer's use only.
|
|
40
8
|
*/
|
|
41
9
|
/** The six JSON kinds. `number` keeps its text; nothing is ever converted. */
|
|
42
10
|
export type JsonKind = 'null' | 'bool' | 'number' | 'string' | 'array' | 'object';
|
|
@@ -60,68 +28,22 @@ export declare class Json {
|
|
|
60
28
|
/** True when these bytes are valid UTF-8 — i.e. when their text is exact. */
|
|
61
29
|
export declare function isValidUtf8(bytes: Uint8Array): boolean;
|
|
62
30
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Is this supplied text **one JSON value**? A spec rule rather than a language
|
|
69
|
-
* default (docs/reference/bindings.md §detectors, measured 2026-08-17): the text is a JSON
|
|
70
|
-
* value only if a strict parse consumes **all** of it, with whitespace being
|
|
71
|
-
* exactly JSON's four (space, tab, LF, CR).
|
|
72
|
-
*
|
|
73
|
-
* Both edges cost real false transforms. A numeric *prefix* must not count —
|
|
74
|
-
* `1.2.3.4` is not `1.2` — and U+FEFF is **not** whitespace: JS's own
|
|
75
|
-
* `String.prototype.trim()` counts `<ZWNBSP>` as `WhiteSpace`, so a
|
|
76
|
-
* `trim()`-then-`JSON.parse` reading took a BOM-prefixed CSV field for the
|
|
77
|
-
* number after it and reported 12 `reformat` transforms that never happened.
|
|
78
|
-
* Deciding over bytes with this grammar makes both impossible.
|
|
31
|
+
* Is this byte string **one JSON value**? It is only if a strict parse consumes
|
|
32
|
+
* **all** of it, with whitespace being exactly JSON's four (space, tab, LF, CR).
|
|
33
|
+
* A numeric *prefix* does not count (`1.2.3.4` is not `1.2`), and U+FEFF is
|
|
34
|
+
* **not** whitespace, though JS's own `String.prototype.trim()` counts it as one.
|
|
79
35
|
*
|
|
80
|
-
* Returns `null` when the bytes are not a single JSON value
|
|
81
|
-
* CSV token, raw bytes).
|
|
36
|
+
* Returns `null` when the bytes are not a single JSON value.
|
|
82
37
|
*/
|
|
83
38
|
export declare function parseJsonValue(bytes: Buffer): Json | null;
|
|
84
|
-
/**
|
|
85
|
-
* Quote the bare `inf` / `-inf` / `nan` tokens ClickHouse writes outside JSON
|
|
86
|
-
* strings. Port of `quoteBareDenormals`; the stored text is preserved exactly and
|
|
87
|
-
* only the quoting is added, so the slices this module hands out are the bytes
|
|
88
|
-
* ClickHouse would have written.
|
|
89
|
-
*/
|
|
90
|
-
export declare function repairBareDenormals(text: Buffer): Buffer;
|
|
91
39
|
/**
|
|
92
40
|
* One member of an object, by key. The **last** wins, which is what a JS object,
|
|
93
41
|
* a Go map and the arbiter's own `json.loads` all do — a document field is never
|
|
94
42
|
* repeated, and a stored value is read through `rawBytes`, never by key.
|
|
95
43
|
*/
|
|
96
44
|
export declare function field(value: Json | undefined, key: string): Json | undefined;
|
|
97
|
-
/** Is this key present at all? `"stored": null` is a value; absence is not. */
|
|
98
|
-
export declare function hasField(value: Json | undefined, key: string): boolean;
|
|
99
45
|
/** The elements of an array (or an object's values); `[]` for anything else. */
|
|
100
46
|
export declare function items(value: Json | undefined): readonly Json[];
|
|
101
47
|
/** A JSON string's text, decoded as UTF-8. `''` for any other kind. */
|
|
102
48
|
export declare function asString(value: Json | undefined): string;
|
|
103
|
-
/** A JSON string's **unescaped bytes** — authoritative where `asString` is not. */
|
|
104
|
-
export declare function asBytes(value: Json | undefined): Buffer;
|
|
105
|
-
export declare function asStringArray(value: Json | undefined): string[];
|
|
106
|
-
export declare function asInt(value: Json | undefined): number;
|
|
107
|
-
export declare function asBool(value: Json | undefined): boolean;
|
|
108
|
-
/**
|
|
109
|
-
* The exact source bytes of a value — the equivalent of holding a
|
|
110
|
-
* `json.RawMessage`. Duplicate keys, escape spellings and 256-bit digits all
|
|
111
|
-
* survive, because nothing is re-rendered.
|
|
112
|
-
*
|
|
113
|
-
* Not the same thing as `asBytes`, and the difference decides correctness: for
|
|
114
|
-
* the string `"a\\u000Bb"` this returns all nine bytes **including the quotes and
|
|
115
|
-
* the escape**, which is what a stored value's rendering is, while `asBytes`
|
|
116
|
-
* returns the three bytes the escape stands for, which is what a *field of the
|
|
117
|
-
* document* (`input`, `name`, `err`) means.
|
|
118
|
-
*/
|
|
119
|
-
export declare function rawBytes(value: Json | undefined): Buffer;
|
|
120
|
-
/**
|
|
121
|
-
* `rawBytes` decoded as UTF-8, for logs, comparisons and messages. **Lossy when
|
|
122
|
-
* the value is not valid UTF-8** — a ClickHouse `String` column holds arbitrary
|
|
123
|
-
* bytes, `isValidUtf8(rawBytes(v))` says whether this text is exact, and
|
|
124
|
-
* `rawBytes` is the authority.
|
|
125
|
-
*/
|
|
126
|
-
export declare function rawText(value: Json | undefined): string;
|
|
127
49
|
//# sourceMappingURL=json.d.ts.map
|
package/dist/json.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAMlF;;;;;;;;GAQG;AACH,qBAAa,IAAI;IAEb,QAAQ,CAAC,IAAI,EAAE,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE;IALlC,YACW,IAAI,EAAE,QAAQ,EACd,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,MAAc,EACrB,KAAK,GAAE,SAAS,IAAI,EAAa,EACjC,IAAI,GAAE,SAAS,MAAM,EAAY,EACxC;CACL;AAED,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD;AAySD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAUzD;AASD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAO5E;AAoBD,gFAAgF;AAChF,wBAAgB,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,SAAS,IAAI,EAAE,CAE9D;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS,GAAG,MAAM,CAExD"}
|
package/dist/json.js
CHANGED
|
@@ -1,45 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* bytes and passes everything else through). Decoding that document into a JS
|
|
9
|
-
* string replaces every invalid byte with U+FFFD, which then reads downstream
|
|
10
|
-
* as a silent transformation that never happened — an *invented* answer, the
|
|
11
|
-
* failure mode this product exists to prevent (the C ABI contract §Per-column
|
|
12
|
-
* fields: "`stored` and `ref` MUST be handled as raw bytes / raw JSON"; the
|
|
13
|
-
* reference implementation keeps `json.RawMessage`). So the document is parsed
|
|
14
|
-
* from a `Buffer`, and every value remembers the exact slice it was cut from.
|
|
15
|
-
*
|
|
16
|
-
* 2. **Numbers must keep their exact text.** ClickHouse integers go to 2^256.
|
|
17
|
-
* `JSON.parse` turns 18446744073709551615 into 18446744073709552000 and an
|
|
18
|
-
* Int256 into -5.78960446186581e+76 — a value difference no scorer can tell
|
|
19
|
-
* from a real coercion defect. A number is never converted here: it *is* its
|
|
20
|
-
* own source bytes.
|
|
21
|
-
*
|
|
22
|
-
* 3. **Duplicate keys and escape spellings survive.** ClickHouse can store a
|
|
23
|
-
* `Map` with a repeated key (`{"a":1,"a":2}`), and it writes the escape
|
|
24
|
-
* `\\u000B` where a JS re-serialization writes `\\u000b`. `JSON.parse` collapses
|
|
25
|
-
* the first and loses the second, and either reports bytes the table does not
|
|
26
|
-
* hold.
|
|
27
|
-
* Object members are therefore kept as an ordered key/value list, and nothing
|
|
28
|
-
* is ever re-rendered: `rawBytes` hands back the library's own slice.
|
|
29
|
-
*
|
|
30
|
-
* The bare-denormal repair is the one edit made to the bytes, and it is
|
|
31
|
-
* required, not optional: ClickHouse's `serializeTextJSON` writes IEEE denormals
|
|
32
|
-
* as the bare tokens `inf`, `-inf` and `nan` unless
|
|
33
|
-
* `output_format_json_quote_denormals` is set. That is faithful ClickHouse
|
|
34
|
-
* output and it is not valid JSON — one QBit column full of infinities took an
|
|
35
|
-
* entire result document down and cost 18 arbiter cases at once.
|
|
36
|
-
* `repairBareDenormals` is the port of `quoteBareDenormals`
|
|
37
|
-
* (go/chtypes/chtypes.go): it quotes the token and changes nothing
|
|
38
|
-
* else, and it runs before any slice is cut, so the reference implementation and
|
|
39
|
-
* this one end up holding the same bytes.
|
|
2
|
+
* The fetch layer's JSON plumbing: a parser over bytes whose values remember the
|
|
3
|
+
* exact slice they were cut from, with duplicate keys kept in source order (the
|
|
4
|
+
* fetch layer's own duplicate-key refusals read them). The result documents of
|
|
5
|
+
* the C layer no longer use it: they are decoded with the stock `JSON.parse`
|
|
6
|
+
* (`./documents.ts`), because the library's documents are valid RFC 8259 JSON.
|
|
7
|
+
* It is kept for the fetch layer's use only.
|
|
40
8
|
*/
|
|
41
9
|
import { isUtf8 } from 'node:buffer';
|
|
42
|
-
import {
|
|
10
|
+
import { ArtifactCorruptError } from './ocifetch/errors.js';
|
|
43
11
|
const EMPTY = Buffer.alloc(0);
|
|
44
12
|
const NO_ITEMS = [];
|
|
45
13
|
const NO_KEYS = [];
|
|
@@ -115,7 +83,7 @@ class Parser {
|
|
|
115
83
|
this.b = b;
|
|
116
84
|
}
|
|
117
85
|
fail(what) {
|
|
118
|
-
throw new
|
|
86
|
+
throw new ArtifactCorruptError(`chtypes: bad result document: ${what} at offset ${this.i}`);
|
|
119
87
|
}
|
|
120
88
|
skipSpace() {
|
|
121
89
|
while (this.i < this.b.length && isSpace(this.b[this.i]))
|
|
@@ -161,10 +129,9 @@ class Parser {
|
|
|
161
129
|
}
|
|
162
130
|
/**
|
|
163
131
|
* A JSON number, strictly: no leading `+`, no bare `.5`, no `1.`, no leading
|
|
164
|
-
* zeros. The strictness is load-bearing rather than pedantic
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* §detectors).
|
|
132
|
+
* zeros. The strictness is load-bearing rather than pedantic: the fetch layer
|
|
133
|
+
* reads signed statements and manifests with this grammar, and a lenient reading
|
|
134
|
+
* would accept bytes the signature never covered.
|
|
168
135
|
*/
|
|
169
136
|
number() {
|
|
170
137
|
const start = this.i;
|
|
@@ -374,32 +341,12 @@ class Parser {
|
|
|
374
341
|
}
|
|
375
342
|
}
|
|
376
343
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const p = new Parser(repairBareDenormals(bytes));
|
|
382
|
-
const v = p.value();
|
|
383
|
-
p.skipSpace();
|
|
384
|
-
if (!p.atEnd())
|
|
385
|
-
p.fail('unexpected data after the document');
|
|
386
|
-
return v;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Is this supplied text **one JSON value**? A spec rule rather than a language
|
|
390
|
-
* default (docs/reference/bindings.md §detectors, measured 2026-08-17): the text is a JSON
|
|
391
|
-
* value only if a strict parse consumes **all** of it, with whitespace being
|
|
392
|
-
* exactly JSON's four (space, tab, LF, CR).
|
|
393
|
-
*
|
|
394
|
-
* Both edges cost real false transforms. A numeric *prefix* must not count —
|
|
395
|
-
* `1.2.3.4` is not `1.2` — and U+FEFF is **not** whitespace: JS's own
|
|
396
|
-
* `String.prototype.trim()` counts `<ZWNBSP>` as `WhiteSpace`, so a
|
|
397
|
-
* `trim()`-then-`JSON.parse` reading took a BOM-prefixed CSV field for the
|
|
398
|
-
* number after it and reported 12 `reformat` transforms that never happened.
|
|
399
|
-
* Deciding over bytes with this grammar makes both impossible.
|
|
344
|
+
* Is this byte string **one JSON value**? It is only if a strict parse consumes
|
|
345
|
+
* **all** of it, with whitespace being exactly JSON's four (space, tab, LF, CR).
|
|
346
|
+
* A numeric *prefix* does not count (`1.2.3.4` is not `1.2`), and U+FEFF is
|
|
347
|
+
* **not** whitespace, though JS's own `String.prototype.trim()` counts it as one.
|
|
400
348
|
*
|
|
401
|
-
* Returns `null` when the bytes are not a single JSON value
|
|
402
|
-
* CSV token, raw bytes).
|
|
349
|
+
* Returns `null` when the bytes are not a single JSON value.
|
|
403
350
|
*/
|
|
404
351
|
export function parseJsonValue(bytes) {
|
|
405
352
|
if (bytes.length === 0)
|
|
@@ -414,73 +361,6 @@ export function parseJsonValue(bytes) {
|
|
|
414
361
|
return null;
|
|
415
362
|
}
|
|
416
363
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Quote the bare `inf` / `-inf` / `nan` tokens ClickHouse writes outside JSON
|
|
419
|
-
* strings. Port of `quoteBareDenormals`; the stored text is preserved exactly and
|
|
420
|
-
* only the quoting is added, so the slices this module hands out are the bytes
|
|
421
|
-
* ClickHouse would have written.
|
|
422
|
-
*/
|
|
423
|
-
export function repairBareDenormals(text) {
|
|
424
|
-
// Fast path: nothing that could be a bare denormal token.
|
|
425
|
-
if (!text.includes('inf') && !text.includes('nan'))
|
|
426
|
-
return text;
|
|
427
|
-
const startsWith = (word, at) => {
|
|
428
|
-
for (let k = 0; k < word.length; k++) {
|
|
429
|
-
if (text[at + k] !== word.charCodeAt(k))
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
return true;
|
|
433
|
-
};
|
|
434
|
-
const out = [];
|
|
435
|
-
let inString = false;
|
|
436
|
-
for (let i = 0; i < text.length; i++) {
|
|
437
|
-
const c = text[i];
|
|
438
|
-
if (inString) {
|
|
439
|
-
out.push(c);
|
|
440
|
-
if (c === BACKSLASH && i + 1 < text.length) {
|
|
441
|
-
i++;
|
|
442
|
-
out.push(text[i]);
|
|
443
|
-
}
|
|
444
|
-
else if (c === QUOTE) {
|
|
445
|
-
inString = false;
|
|
446
|
-
}
|
|
447
|
-
continue;
|
|
448
|
-
}
|
|
449
|
-
if (c === QUOTE) {
|
|
450
|
-
inString = true;
|
|
451
|
-
out.push(c);
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
// A value can only start right after one of these structural bytes.
|
|
455
|
-
if (out.length > 0) {
|
|
456
|
-
const prev = out[out.length - 1];
|
|
457
|
-
if (prev !== COLON && prev !== COMMA && prev !== ARRAY_OPEN && !isSpace(prev)) {
|
|
458
|
-
out.push(c);
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
let token = 0;
|
|
463
|
-
if (startsWith('-inf', i))
|
|
464
|
-
token = 4;
|
|
465
|
-
else if (startsWith('inf', i))
|
|
466
|
-
token = 3;
|
|
467
|
-
else if (startsWith('nan', i))
|
|
468
|
-
token = 3;
|
|
469
|
-
if (token > 0) {
|
|
470
|
-
const after = text[i + token];
|
|
471
|
-
if (after === undefined || after === COMMA || after === OBJECT_CLOSE || after === ARRAY_CLOSE) {
|
|
472
|
-
out.push(QUOTE);
|
|
473
|
-
for (let k = 0; k < token; k++)
|
|
474
|
-
out.push(text[i + k]);
|
|
475
|
-
out.push(QUOTE);
|
|
476
|
-
i += token - 1;
|
|
477
|
-
continue;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
out.push(c);
|
|
481
|
-
}
|
|
482
|
-
return Buffer.from(out);
|
|
483
|
-
}
|
|
484
364
|
// ------------------------------------------------------------------ accessors
|
|
485
365
|
//
|
|
486
366
|
// Every field of a result document is optional: a rejected row's document omits
|
|
@@ -522,10 +402,6 @@ function keyIs(key, want) {
|
|
|
522
402
|
}
|
|
523
403
|
return true;
|
|
524
404
|
}
|
|
525
|
-
/** Is this key present at all? `"stored": null` is a value; absence is not. */
|
|
526
|
-
export function hasField(value, key) {
|
|
527
|
-
return field(value, key) !== undefined;
|
|
528
|
-
}
|
|
529
405
|
/** The elements of an array (or an object's values); `[]` for anything else. */
|
|
530
406
|
export function items(value) {
|
|
531
407
|
return value === undefined ? NO_ITEMS : value.items;
|
|
@@ -534,44 +410,4 @@ export function items(value) {
|
|
|
534
410
|
export function asString(value) {
|
|
535
411
|
return value !== undefined && value.kind === 'string' ? value.bytes.toString('utf8') : '';
|
|
536
412
|
}
|
|
537
|
-
/** A JSON string's **unescaped bytes** — authoritative where `asString` is not. */
|
|
538
|
-
export function asBytes(value) {
|
|
539
|
-
return value !== undefined && value.kind === 'string' ? value.bytes : EMPTY;
|
|
540
|
-
}
|
|
541
|
-
export function asStringArray(value) {
|
|
542
|
-
return items(value).map((v) => asString(v));
|
|
543
|
-
}
|
|
544
|
-
export function asInt(value) {
|
|
545
|
-
if (value !== undefined && value.kind === 'number') {
|
|
546
|
-
const n = Number(value.raw.toString('utf8'));
|
|
547
|
-
return Number.isFinite(n) ? n : 0;
|
|
548
|
-
}
|
|
549
|
-
return 0;
|
|
550
|
-
}
|
|
551
|
-
export function asBool(value) {
|
|
552
|
-
return value !== undefined && value.kind === 'bool' && value.raw[0] === LOWER_T;
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* The exact source bytes of a value — the equivalent of holding a
|
|
556
|
-
* `json.RawMessage`. Duplicate keys, escape spellings and 256-bit digits all
|
|
557
|
-
* survive, because nothing is re-rendered.
|
|
558
|
-
*
|
|
559
|
-
* Not the same thing as `asBytes`, and the difference decides correctness: for
|
|
560
|
-
* the string `"a\\u000Bb"` this returns all nine bytes **including the quotes and
|
|
561
|
-
* the escape**, which is what a stored value's rendering is, while `asBytes`
|
|
562
|
-
* returns the three bytes the escape stands for, which is what a *field of the
|
|
563
|
-
* document* (`input`, `name`, `err`) means.
|
|
564
|
-
*/
|
|
565
|
-
export function rawBytes(value) {
|
|
566
|
-
return value === undefined ? EMPTY : value.raw;
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* `rawBytes` decoded as UTF-8, for logs, comparisons and messages. **Lossy when
|
|
570
|
-
* the value is not valid UTF-8** — a ClickHouse `String` column holds arbitrary
|
|
571
|
-
* bytes, `isValidUtf8(rawBytes(v))` says whether this text is exact, and
|
|
572
|
-
* `rawBytes` is the authority.
|
|
573
|
-
*/
|
|
574
|
-
export function rawText(value) {
|
|
575
|
-
return rawBytes(value).toString('utf8');
|
|
576
|
-
}
|
|
577
413
|
//# sourceMappingURL=json.js.map
|