@bendyline/gezk 1.0.2 → 1.0.3
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/dist/index.d.ts +112 -9
- package/dist/index.js +302 -114
- package/dist/node.d.ts +1 -1
- package/dist/node.js +302 -114
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -222,10 +222,11 @@ type KnowledgeSignature = z.infer<typeof KnowledgeSignatureSchema>;
|
|
|
222
222
|
declare const KnowledgeCatalogManifestSchema: z.ZodObject<{
|
|
223
223
|
kind: z.ZodLiteral<"gezk-catalog">;
|
|
224
224
|
formatVersion: z.ZodEnum<{
|
|
225
|
-
0.
|
|
225
|
+
0.7: "0.7";
|
|
226
226
|
0.5: "0.5";
|
|
227
|
+
0.6: "0.6";
|
|
227
228
|
}>;
|
|
228
|
-
indexSchemaVersion: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
229
|
+
indexSchemaVersion: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
229
230
|
id: z.ZodString;
|
|
230
231
|
version: z.ZodString;
|
|
231
232
|
name: z.ZodString;
|
|
@@ -340,10 +341,24 @@ declare const KnowledgeCatalogManifestSchema: z.ZodObject<{
|
|
|
340
341
|
sizeBytes: z.ZodNumber;
|
|
341
342
|
sha256: z.ZodString;
|
|
342
343
|
}, z.core.$strip>>;
|
|
344
|
+
spatial: z.ZodOptional<z.ZodObject<{
|
|
345
|
+
schema: z.ZodLiteral<"document-points@1">;
|
|
346
|
+
crs: z.ZodLiteral<"EPSG:4326">;
|
|
347
|
+
distanceModel: z.ZodLiteral<"sphere-6371000">;
|
|
348
|
+
locationCount: z.ZodNumber;
|
|
349
|
+
locatedDocuments: z.ZodNumber;
|
|
350
|
+
coverage: z.ZodArray<z.ZodObject<{
|
|
351
|
+
west: z.ZodNumber;
|
|
352
|
+
south: z.ZodNumber;
|
|
353
|
+
east: z.ZodNumber;
|
|
354
|
+
north: z.ZodNumber;
|
|
355
|
+
}, z.core.$strict>>;
|
|
356
|
+
}, z.core.$strict>>;
|
|
343
357
|
requires: z.ZodObject<{
|
|
344
358
|
formatVersion: z.ZodEnum<{
|
|
345
|
-
0.
|
|
359
|
+
0.7: "0.7";
|
|
346
360
|
0.5: "0.5";
|
|
361
|
+
0.6: "0.6";
|
|
347
362
|
}>;
|
|
348
363
|
features: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
349
364
|
}, z.core.$strip>;
|
|
@@ -393,6 +408,12 @@ declare const KnowledgeOrdinalSchema: z.ZodNumber;
|
|
|
393
408
|
*/
|
|
394
409
|
declare const KnowledgeDocumentMetaSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
395
410
|
type KnowledgeDocumentMeta = z.infer<typeof KnowledgeDocumentMetaSchema>;
|
|
411
|
+
/** An additional TOC placement of the same document, without a second body or index. */
|
|
412
|
+
declare const KnowledgeTocReferenceSchema: z.ZodObject<{
|
|
413
|
+
topicPath: z.ZodArray<z.ZodString>;
|
|
414
|
+
ordinal: z.ZodOptional<z.ZodNumber>;
|
|
415
|
+
}, z.core.$strict>;
|
|
416
|
+
type KnowledgeTocReference = z.infer<typeof KnowledgeTocReferenceSchema>;
|
|
396
417
|
/** One normalized document streamed into the compiler. */
|
|
397
418
|
declare const CatalogDocumentSchema: z.ZodObject<{
|
|
398
419
|
id: z.ZodString;
|
|
@@ -401,6 +422,10 @@ declare const CatalogDocumentSchema: z.ZodObject<{
|
|
|
401
422
|
summary: z.ZodOptional<z.ZodString>;
|
|
402
423
|
language: z.ZodString;
|
|
403
424
|
topicPath: z.ZodArray<z.ZodString>;
|
|
425
|
+
tocReferences: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
426
|
+
topicPath: z.ZodArray<z.ZodString>;
|
|
427
|
+
ordinal: z.ZodOptional<z.ZodNumber>;
|
|
428
|
+
}, z.core.$strict>>>;
|
|
404
429
|
markdown: z.ZodString;
|
|
405
430
|
sourceUrl: z.ZodOptional<z.ZodString>;
|
|
406
431
|
sourceRevision: z.ZodOptional<z.ZodString>;
|
|
@@ -409,6 +434,16 @@ declare const CatalogDocumentSchema: z.ZodObject<{
|
|
|
409
434
|
aliases: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
410
435
|
ordinal: z.ZodOptional<z.ZodNumber>;
|
|
411
436
|
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
437
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
438
|
+
id: z.ZodString;
|
|
439
|
+
latitude: z.ZodNumber;
|
|
440
|
+
longitude: z.ZodNumber;
|
|
441
|
+
role: z.ZodEnum<{
|
|
442
|
+
subject: "subject";
|
|
443
|
+
associated: "associated";
|
|
444
|
+
}>;
|
|
445
|
+
provenance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
446
|
+
}, z.core.$strict>>>;
|
|
412
447
|
}, z.core.$strip>;
|
|
413
448
|
type CatalogDocument = z.infer<typeof CatalogDocumentSchema>;
|
|
414
449
|
|
|
@@ -445,8 +480,9 @@ type KnowledgeRegistryEntry = z.infer<typeof KnowledgeRegistryEntrySchema>;
|
|
|
445
480
|
declare const KnowledgeRegistryIndexSchema: z.ZodObject<{
|
|
446
481
|
kind: z.ZodLiteral<"gezk-registry">;
|
|
447
482
|
formatVersion: z.ZodEnum<{
|
|
448
|
-
0.
|
|
483
|
+
0.7: "0.7";
|
|
449
484
|
0.5: "0.5";
|
|
485
|
+
0.6: "0.6";
|
|
450
486
|
}>;
|
|
451
487
|
publisher: z.ZodObject<{
|
|
452
488
|
id: z.ZodString;
|
|
@@ -509,9 +545,9 @@ declare function parseKnowledgeUri(raw: string): KnowledgeUri | null;
|
|
|
509
545
|
* breaking changes may land in any minor until 1.0, and a reader supports
|
|
510
546
|
* exactly the versions it names (see {@link GEZK_FORMAT_GENERATIONS}).
|
|
511
547
|
*/
|
|
512
|
-
declare const GEZK_FORMAT_VERSION = "0.
|
|
548
|
+
declare const GEZK_FORMAT_VERSION = "0.7";
|
|
513
549
|
/** SQLite schema generation this implementation writes (`PRAGMA user_version`). */
|
|
514
|
-
declare const GEZK_INDEX_SCHEMA_VERSION =
|
|
550
|
+
declare const GEZK_INDEX_SCHEMA_VERSION = 4;
|
|
515
551
|
/**
|
|
516
552
|
* Every (formatVersion, indexSchemaVersion) pairing this implementation
|
|
517
553
|
* reads. The writer always emits the current pair; older generations stay
|
|
@@ -521,6 +557,7 @@ declare const GEZK_INDEX_SCHEMA_VERSION = 3;
|
|
|
521
557
|
declare const GEZK_FORMAT_GENERATIONS: {
|
|
522
558
|
readonly '0.5': 2;
|
|
523
559
|
readonly '0.6': 3;
|
|
560
|
+
readonly '0.7': 4;
|
|
524
561
|
};
|
|
525
562
|
type GezkFormatVersion = keyof typeof GEZK_FORMAT_GENERATIONS;
|
|
526
563
|
type GezkIndexSchemaVersion = (typeof GEZK_FORMAT_GENERATIONS)[GezkFormatVersion];
|
|
@@ -554,11 +591,11 @@ declare const MAX_KNOWLEDGE_TOPIC_DEPTH = 16;
|
|
|
554
591
|
declare const ZIP_FIXED_MTIME: Date;
|
|
555
592
|
|
|
556
593
|
/**
|
|
557
|
-
* Index schema
|
|
594
|
+
* Index schema 4 DDL. Readers never migrate these. Every table is plain
|
|
558
595
|
* SQLite (FTS5 is the only virtual-table module used), so any SQLite client
|
|
559
596
|
* can read a catalog without extensions.
|
|
560
597
|
*/
|
|
561
|
-
declare const ROUTER_DDL = "\nCREATE TABLE meta(key TEXT PRIMARY KEY, value TEXT NOT NULL) WITHOUT ROWID;\n\nCREATE TABLE topics(\n id TEXT PRIMARY KEY, parent_id TEXT, name TEXT NOT NULL,\n description TEXT, sort_key TEXT NOT NULL, document_count INTEGER NOT NULL\n);\n\nCREATE TABLE documents(\n id TEXT PRIMARY KEY,\n title TEXT NOT NULL, slug TEXT NOT NULL, summary TEXT,\n language TEXT NOT NULL, topic_id TEXT NOT NULL REFERENCES topics(id),\n ordinal INTEGER,\n shard_id INTEGER NOT NULL,\n chunk_count INTEGER NOT NULL,\n source_url TEXT, source_revision TEXT, source_updated_at TEXT,\n attribution_json TEXT,\n meta_json TEXT,\n body_codec TEXT NOT NULL CHECK (body_codec IN ('none','br')),\n body_blob BLOB NOT NULL\n);\nCREATE INDEX documents_topic ON documents(topic_id, ordinal, slug);\nCREATE INDEX documents_shard ON documents(shard_id);\n\nCREATE TABLE aliases(alias TEXT NOT NULL, document_id TEXT NOT NULL,\n PRIMARY KEY (alias, document_id)) WITHOUT ROWID;\n\nCREATE TABLE shards(\n id INTEGER PRIMARY KEY,\n path TEXT NOT NULL,\n chunk_count INTEGER NOT NULL, document_count INTEGER NOT NULL,\n topic_ids_json TEXT NOT NULL, centroid_count INTEGER NOT NULL,\n bytes INTEGER NOT NULL\n);\n\nCREATE TABLE route_centroids(\n id INTEGER PRIMARY KEY,\n shard_id INTEGER NOT NULL REFERENCES shards(id),\n embedding BLOB NOT NULL,\n weight INTEGER NOT NULL\n);\nCREATE INDEX route_centroids_shard ON route_centroids(shard_id);\n\nCREATE VIRTUAL TABLE fts_documents USING fts5(\n title, summary, aliases, document_id UNINDEXED,\n tokenize = 'unicode61 remove_diacritics 2', prefix = '2 3'\n);\n";
|
|
598
|
+
declare const ROUTER_DDL = "\nCREATE TABLE meta(key TEXT PRIMARY KEY, value TEXT NOT NULL) WITHOUT ROWID;\n\nCREATE TABLE topics(\n id TEXT PRIMARY KEY, parent_id TEXT, name TEXT NOT NULL,\n description TEXT, sort_key TEXT NOT NULL, document_count INTEGER NOT NULL\n);\n\nCREATE TABLE documents(\n id TEXT PRIMARY KEY,\n title TEXT NOT NULL, slug TEXT NOT NULL, summary TEXT,\n language TEXT NOT NULL, topic_id TEXT NOT NULL REFERENCES topics(id),\n ordinal INTEGER,\n shard_id INTEGER NOT NULL,\n chunk_count INTEGER NOT NULL,\n source_url TEXT, source_revision TEXT, source_updated_at TEXT,\n attribution_json TEXT,\n meta_json TEXT,\n body_codec TEXT NOT NULL CHECK (body_codec IN ('none','br')),\n body_blob BLOB NOT NULL\n);\nCREATE INDEX documents_topic ON documents(topic_id, ordinal, slug);\nCREATE INDEX documents_shard ON documents(shard_id);\n\nCREATE TABLE document_locations(\n document_id TEXT NOT NULL REFERENCES documents(id),\n location_id TEXT NOT NULL,\n latitude REAL NOT NULL CHECK (latitude BETWEEN -90 AND 90),\n longitude REAL NOT NULL CHECK (longitude >= -180 AND longitude < 180),\n role TEXT NOT NULL CHECK (role IN ('subject','associated')),\n provenance_json TEXT,\n PRIMARY KEY (document_id, location_id)\n) WITHOUT ROWID;\nCREATE INDEX document_locations_latitude ON document_locations(latitude, longitude, document_id);\nCREATE INDEX document_locations_longitude ON document_locations(longitude, latitude, document_id);\n\n-- Includes the primary placement in documents.topic_id/ordinal as well as\n-- shared TOC references. Bodies, chunks and vectors remain keyed by document id.\nCREATE TABLE topic_documents(\n topic_id TEXT NOT NULL REFERENCES topics(id),\n document_id TEXT NOT NULL REFERENCES documents(id),\n ordinal INTEGER CHECK (ordinal IS NULL OR\n (typeof(ordinal) = 'integer' AND ordinal BETWEEN -2147483648 AND 2147483647)),\n PRIMARY KEY (topic_id, document_id)\n) WITHOUT ROWID;\nCREATE INDEX topic_documents_document ON topic_documents(document_id);\nCREATE INDEX topic_documents_order ON topic_documents(topic_id, ordinal, document_id);\n\nCREATE TABLE aliases(alias TEXT NOT NULL, document_id TEXT NOT NULL,\n PRIMARY KEY (alias, document_id)) WITHOUT ROWID;\n\nCREATE TABLE shards(\n id INTEGER PRIMARY KEY,\n path TEXT NOT NULL,\n chunk_count INTEGER NOT NULL, document_count INTEGER NOT NULL,\n topic_ids_json TEXT NOT NULL, centroid_count INTEGER NOT NULL,\n bytes INTEGER NOT NULL\n);\n\nCREATE TABLE route_centroids(\n id INTEGER PRIMARY KEY,\n shard_id INTEGER NOT NULL REFERENCES shards(id),\n embedding BLOB NOT NULL,\n weight INTEGER NOT NULL\n);\nCREATE INDEX route_centroids_shard ON route_centroids(shard_id);\n\nCREATE VIRTUAL TABLE fts_documents USING fts5(\n title, summary, aliases, document_id UNINDEXED,\n tokenize = 'unicode61 remove_diacritics 2', prefix = '2 3'\n);\n";
|
|
562
599
|
/**
|
|
563
600
|
* Per-shard tables. Vectors are plain BLOB columns keyed by chunk id:
|
|
564
601
|
* `chunk_vectors_bit.v` holds ceil(dim/8) bytes of sign bits (LSB-first; of
|
|
@@ -688,4 +725,70 @@ declare function canonicalizeJson(value: unknown): string;
|
|
|
688
725
|
/** URL-ish slug for a document title (display/dedup aid, not an identity). */
|
|
689
726
|
declare function documentSlug(title: string): string;
|
|
690
727
|
|
|
691
|
-
|
|
728
|
+
/**
|
|
729
|
+
* Portable point locations and radius predicates for gezk 0.7. Coordinates
|
|
730
|
+
* are WGS84 degrees; distances use the specified 6,371,000 m sphere. These
|
|
731
|
+
* browser-safe contracts are shared by compilers, readers, and service APIs.
|
|
732
|
+
* Bounds are conservative candidates only: membership always uses distance.
|
|
733
|
+
*/
|
|
734
|
+
|
|
735
|
+
declare const GEZK_EARTH_RADIUS_METERS = 6371000;
|
|
736
|
+
declare const MAX_DOCUMENT_LOCATIONS = 256;
|
|
737
|
+
declare const KnowledgeLocationSchema: z.ZodObject<{
|
|
738
|
+
id: z.ZodString;
|
|
739
|
+
latitude: z.ZodNumber;
|
|
740
|
+
longitude: z.ZodNumber;
|
|
741
|
+
role: z.ZodEnum<{
|
|
742
|
+
subject: "subject";
|
|
743
|
+
associated: "associated";
|
|
744
|
+
}>;
|
|
745
|
+
provenance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
746
|
+
}, z.core.$strict>;
|
|
747
|
+
type KnowledgeLocation = z.infer<typeof KnowledgeLocationSchema>;
|
|
748
|
+
declare const KnowledgeLocationsSchema: z.ZodArray<z.ZodObject<{
|
|
749
|
+
id: z.ZodString;
|
|
750
|
+
latitude: z.ZodNumber;
|
|
751
|
+
longitude: z.ZodNumber;
|
|
752
|
+
role: z.ZodEnum<{
|
|
753
|
+
subject: "subject";
|
|
754
|
+
associated: "associated";
|
|
755
|
+
}>;
|
|
756
|
+
provenance: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
757
|
+
}, z.core.$strict>>;
|
|
758
|
+
declare const KnowledgeRadiusSchema: z.ZodObject<{
|
|
759
|
+
latitude: z.ZodNumber;
|
|
760
|
+
longitude: z.ZodNumber;
|
|
761
|
+
radiusMeters: z.ZodNumber;
|
|
762
|
+
}, z.core.$strict>;
|
|
763
|
+
type KnowledgeRadius = z.infer<typeof KnowledgeRadiusSchema>;
|
|
764
|
+
declare const KnowledgeBoundsSchema: z.ZodObject<{
|
|
765
|
+
west: z.ZodNumber;
|
|
766
|
+
south: z.ZodNumber;
|
|
767
|
+
east: z.ZodNumber;
|
|
768
|
+
north: z.ZodNumber;
|
|
769
|
+
}, z.core.$strict>;
|
|
770
|
+
type KnowledgeBounds = z.infer<typeof KnowledgeBoundsSchema>;
|
|
771
|
+
declare const KnowledgeSpatialManifestSchema: z.ZodObject<{
|
|
772
|
+
schema: z.ZodLiteral<"document-points@1">;
|
|
773
|
+
crs: z.ZodLiteral<"EPSG:4326">;
|
|
774
|
+
distanceModel: z.ZodLiteral<"sphere-6371000">;
|
|
775
|
+
locationCount: z.ZodNumber;
|
|
776
|
+
locatedDocuments: z.ZodNumber;
|
|
777
|
+
coverage: z.ZodArray<z.ZodObject<{
|
|
778
|
+
west: z.ZodNumber;
|
|
779
|
+
south: z.ZodNumber;
|
|
780
|
+
east: z.ZodNumber;
|
|
781
|
+
north: z.ZodNumber;
|
|
782
|
+
}, z.core.$strict>>;
|
|
783
|
+
}, z.core.$strict>;
|
|
784
|
+
type KnowledgeSpatialManifest = z.infer<typeof KnowledgeSpatialManifestSchema>;
|
|
785
|
+
declare function normalizeLongitude(longitude: number): number;
|
|
786
|
+
declare function locationDistanceMeters(from: Pick<KnowledgeLocation, 'latitude' | 'longitude'>, to: Pick<KnowledgeLocation, 'latitude' | 'longitude'>): number;
|
|
787
|
+
declare function radiusBounds(raw: KnowledgeRadius): KnowledgeBounds[];
|
|
788
|
+
declare function locationInBounds(location: KnowledgeLocation, bounds: KnowledgeBounds): boolean;
|
|
789
|
+
declare function spatialManifest(locations: Array<{
|
|
790
|
+
documentId: string;
|
|
791
|
+
location: KnowledgeLocation;
|
|
792
|
+
}>): KnowledgeSpatialManifest;
|
|
793
|
+
|
|
794
|
+
export { ASSETS_PREFIX, ArtifactDigestSchema, BODY_CODEC_MIN_BYTES, type CatalogDocument, CatalogDocumentSchema, DEFAULT_EMBEDDING_ONNX_FILE, DEFAULT_EMBEDDING_TOKENIZER_FILE, GEZK_APPLICATION_ID, GEZK_EARTH_RADIUS_METERS, GEZK_FORMAT_GENERATIONS, GEZK_FORMAT_VERSION, GEZK_INDEX_SCHEMA_VERSION, GEZK_MANIFEST_KIND, GEZK_MIME_TYPE, GEZK_REGISTRY_KIND, GEZK_SUPPORTED_FORMAT_VERSIONS, GEZK_SUPPORTED_INDEX_SCHEMA_VERSIONS, type GezkFormatVersion, type GezkIndexSchemaVersion, KNOWLEDGE_ASSET_PATH_PATTERN, KNOWLEDGE_ASSET_TYPES, KNOWLEDGE_ID_PATTERN, KNOWLEDGE_MANIFEST_INDEX_SCHEMA_VERSIONS, KNOWLEDGE_VERSION_PATTERN, type KnowledgeAssetExtension, type KnowledgeAssetKind, KnowledgeAssetPathSchema, type KnowledgeBounds, KnowledgeBoundsSchema, type KnowledgeCatalogManifest, KnowledgeCatalogManifestSchema, KnowledgeChunkUidSchema, type KnowledgeChunkingProfile, KnowledgeChunkingProfileSchema, KnowledgeDocumentIdSchema, type KnowledgeDocumentMeta, KnowledgeDocumentMetaSchema, type KnowledgeEmbeddingProfile, KnowledgeEmbeddingProfileSchema, KnowledgeIdSchema, type KnowledgeLocation, KnowledgeLocationSchema, KnowledgeLocationsSchema, KnowledgeManifestFileSchema, KnowledgeOrdinalSchema, type KnowledgeRadius, KnowledgeRadiusSchema, type KnowledgeRegistryEntry, KnowledgeRegistryEntrySchema, type KnowledgeRegistryIndex, KnowledgeRegistryIndexSchema, type KnowledgeSignature, KnowledgeSignatureSchema, type KnowledgeSpatialManifest, KnowledgeSpatialManifestSchema, type KnowledgeTocReference, KnowledgeTocReferenceSchema, type KnowledgeUri, type KnowledgeVectorEncoding, KnowledgeVectorEncodingSchema, KnowledgeVersionSchema, LICENSE_NOTICE_PATH, MANIFEST_PATH, MAX_DOCUMENT_LOCATIONS, MAX_KNOWLEDGE_ASSETS_TOTAL_BYTES, MAX_KNOWLEDGE_ASSET_BYTES, MAX_KNOWLEDGE_ASSET_COUNT, MAX_KNOWLEDGE_ASSET_PATH_LENGTH, MAX_KNOWLEDGE_DOCUMENT_BYTES, MAX_KNOWLEDGE_DOCUMENT_META_BYTES, MAX_KNOWLEDGE_TOPIC_DEPTH, MIMETYPE_PATH, README_PATH, ROUTER_DB_PATH, ROUTER_DDL, RepoRelativePathSchema, SHARD_DDL, SOURCE_NOTICES_PATH, Sha256HexSchema, type SourceNotices, SourceNoticesSchema, ZIP_FIXED_MTIME, assetContentType, assetExtension, assetKindForExtension, canonicalizeJson, centerVector, documentSlug, embeddingProfileArtifacts, embeddingProfileCenter, embeddingProfileCenterProblem, formatKnowledgeUri, isKnowledgeAssetPath, isSupportedFormatVersion, isSupportedIndexSchemaVersion, l2Normalize, locationDistanceMeters, locationInBounds, normalizeLongitude, parseKnowledgeUri, quantizeBinary, quantizeBinaryForProfile, quantizeInt8, radiusBounds, rerankScore, sameVectorSpace, sniffAssetType, spatialManifest, svgInertnessProblem, topicSortKeyForOrder };
|