@dreamlake/dreamdb 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/index.cjs +41 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +40 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,10 @@ type MultihashBytes = Uint8Array;
|
|
|
4
4
|
type Base32Hash = string;
|
|
5
5
|
/** Nanoseconds since UNIX epoch — the join key across all modalities. */
|
|
6
6
|
type TimeAnchor = number;
|
|
7
|
+
/** The spatial key for non-spatial data (images, video, JSON, scalars).
|
|
8
|
+
* 8 zero bytes in hex — used as the path segment between modality and hash
|
|
9
|
+
* for any track that isn't spatially indexed by an embedding vector. */
|
|
10
|
+
declare const ZERO_SPATIAL_KEY = "0000000000000000";
|
|
7
11
|
type FieldKind = "image" | "audio" | "video" | "embedding" | "scalar";
|
|
8
12
|
type ScalarValueType = "categorical" | "bool" | "int" | "float" | "string" | "timestamp";
|
|
9
13
|
interface ImageFieldDef {
|
|
@@ -495,4 +499,4 @@ declare class Dataset {
|
|
|
495
499
|
private _resolveScalarLabels;
|
|
496
500
|
}
|
|
497
501
|
|
|
498
|
-
export { type AudioFieldDef, type Backend, type BackendGetOptions, type BackendPutOptions, type Base32Hash, type Batch, type BucketRecord, type CborValue, type ChaCha20Stream, Dataset, type DatasetInfo, type EmbeddingFieldDef, type FieldDef, type FieldKind, type HistoryEntry, type ImageFieldDef, MULTIHASH_BYTES, type Manifest, type ManifestTrack, MemoryBackend, type MultihashBytes, type ParsedSpaceUri, type QueryStats, type RegistryEntry, type ResolvedTrack, S3Backend, SCALAR_ENCODING_MAP, type Sample, type SampleValue, type ScalarFieldDef, type ScalarValueType, Schema, type SnapshotInfo, Space, type SpaceOptions, type SpatialDispatcher, type TimeAnchor, type VectorCompressorDecoder, type VectorQueryOptions, type VectorQueryResult, type VideoFieldDef, type WhereClause, base32ToBytes, bitsFromProjections, bitsToBase2, buildPqCosineDecoder, buildRabitqCosineDecoder, bytesToBase32, chacha20Stream, decodeBucketAnchorsOnly, decodeBucketRecords, decodeCbor, deriveHyperplanesLshCosine, deriveRotationMatrix, dotF32, dotL2Normalized, encodeCbor, modalityForField, multiProbeKeys, normalizeL2, normalizeL2F32, parseSpaceUri, peekBucketHeader, projectionsLshCosine, scalarModalityFragment };
|
|
502
|
+
export { type AudioFieldDef, type Backend, type BackendGetOptions, type BackendPutOptions, type Base32Hash, type Batch, type BucketRecord, type CborValue, type ChaCha20Stream, Dataset, type DatasetInfo, type EmbeddingFieldDef, type FieldDef, type FieldKind, type HistoryEntry, type ImageFieldDef, MULTIHASH_BYTES, type Manifest, type ManifestTrack, MemoryBackend, type MultihashBytes, type ParsedSpaceUri, type QueryStats, type RegistryEntry, type ResolvedTrack, S3Backend, SCALAR_ENCODING_MAP, type Sample, type SampleValue, type ScalarFieldDef, type ScalarValueType, Schema, type SnapshotInfo, Space, type SpaceOptions, type SpatialDispatcher, type TimeAnchor, type VectorCompressorDecoder, type VectorQueryOptions, type VectorQueryResult, type VideoFieldDef, type WhereClause, ZERO_SPATIAL_KEY, base32ToBytes, bitsFromProjections, bitsToBase2, buildPqCosineDecoder, buildRabitqCosineDecoder, bytesToBase32, chacha20Stream, decodeBucketAnchorsOnly, decodeBucketRecords, decodeCbor, deriveHyperplanesLshCosine, deriveRotationMatrix, dotF32, dotL2Normalized, encodeCbor, modalityForField, multiProbeKeys, normalizeL2, normalizeL2F32, parseSpaceUri, peekBucketHeader, projectionsLshCosine, scalarModalityFragment };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ type MultihashBytes = Uint8Array;
|
|
|
4
4
|
type Base32Hash = string;
|
|
5
5
|
/** Nanoseconds since UNIX epoch — the join key across all modalities. */
|
|
6
6
|
type TimeAnchor = number;
|
|
7
|
+
/** The spatial key for non-spatial data (images, video, JSON, scalars).
|
|
8
|
+
* 8 zero bytes in hex — used as the path segment between modality and hash
|
|
9
|
+
* for any track that isn't spatially indexed by an embedding vector. */
|
|
10
|
+
declare const ZERO_SPATIAL_KEY = "0000000000000000";
|
|
7
11
|
type FieldKind = "image" | "audio" | "video" | "embedding" | "scalar";
|
|
8
12
|
type ScalarValueType = "categorical" | "bool" | "int" | "float" | "string" | "timestamp";
|
|
9
13
|
interface ImageFieldDef {
|
|
@@ -495,4 +499,4 @@ declare class Dataset {
|
|
|
495
499
|
private _resolveScalarLabels;
|
|
496
500
|
}
|
|
497
501
|
|
|
498
|
-
export { type AudioFieldDef, type Backend, type BackendGetOptions, type BackendPutOptions, type Base32Hash, type Batch, type BucketRecord, type CborValue, type ChaCha20Stream, Dataset, type DatasetInfo, type EmbeddingFieldDef, type FieldDef, type FieldKind, type HistoryEntry, type ImageFieldDef, MULTIHASH_BYTES, type Manifest, type ManifestTrack, MemoryBackend, type MultihashBytes, type ParsedSpaceUri, type QueryStats, type RegistryEntry, type ResolvedTrack, S3Backend, SCALAR_ENCODING_MAP, type Sample, type SampleValue, type ScalarFieldDef, type ScalarValueType, Schema, type SnapshotInfo, Space, type SpaceOptions, type SpatialDispatcher, type TimeAnchor, type VectorCompressorDecoder, type VectorQueryOptions, type VectorQueryResult, type VideoFieldDef, type WhereClause, base32ToBytes, bitsFromProjections, bitsToBase2, buildPqCosineDecoder, buildRabitqCosineDecoder, bytesToBase32, chacha20Stream, decodeBucketAnchorsOnly, decodeBucketRecords, decodeCbor, deriveHyperplanesLshCosine, deriveRotationMatrix, dotF32, dotL2Normalized, encodeCbor, modalityForField, multiProbeKeys, normalizeL2, normalizeL2F32, parseSpaceUri, peekBucketHeader, projectionsLshCosine, scalarModalityFragment };
|
|
502
|
+
export { type AudioFieldDef, type Backend, type BackendGetOptions, type BackendPutOptions, type Base32Hash, type Batch, type BucketRecord, type CborValue, type ChaCha20Stream, Dataset, type DatasetInfo, type EmbeddingFieldDef, type FieldDef, type FieldKind, type HistoryEntry, type ImageFieldDef, MULTIHASH_BYTES, type Manifest, type ManifestTrack, MemoryBackend, type MultihashBytes, type ParsedSpaceUri, type QueryStats, type RegistryEntry, type ResolvedTrack, S3Backend, SCALAR_ENCODING_MAP, type Sample, type SampleValue, type ScalarFieldDef, type ScalarValueType, Schema, type SnapshotInfo, Space, type SpaceOptions, type SpatialDispatcher, type TimeAnchor, type VectorCompressorDecoder, type VectorQueryOptions, type VectorQueryResult, type VideoFieldDef, type WhereClause, ZERO_SPATIAL_KEY, base32ToBytes, bitsFromProjections, bitsToBase2, buildPqCosineDecoder, buildRabitqCosineDecoder, bytesToBase32, chacha20Stream, decodeBucketAnchorsOnly, decodeBucketRecords, decodeCbor, deriveHyperplanesLshCosine, deriveRotationMatrix, dotF32, dotL2Normalized, encodeCbor, modalityForField, multiProbeKeys, normalizeL2, normalizeL2F32, parseSpaceUri, peekBucketHeader, projectionsLshCosine, scalarModalityFragment };
|
package/dist/index.js
CHANGED
|
@@ -321,16 +321,33 @@ var S3Backend = class {
|
|
|
321
321
|
return path;
|
|
322
322
|
}
|
|
323
323
|
async list(prefix) {
|
|
324
|
-
const url = `${this.baseUrl}?list-type=2&prefix=${encodeURIComponent(prefix)}`;
|
|
325
|
-
const r = await fetch(url);
|
|
326
|
-
if (!r.ok) throw new Error(`LIST ${url}: HTTP ${r.status}`);
|
|
327
|
-
const text = await r.text();
|
|
328
324
|
const keys = [];
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
325
|
+
let continuationToken;
|
|
326
|
+
do {
|
|
327
|
+
let url = `${this.baseUrl}?list-type=2&prefix=${encodeURIComponent(prefix)}`;
|
|
328
|
+
if (continuationToken) {
|
|
329
|
+
url += `&continuation-token=${encodeURIComponent(continuationToken)}`;
|
|
330
|
+
}
|
|
331
|
+
const r = await fetch(url);
|
|
332
|
+
if (!r.ok) throw new Error(`LIST ${url}: HTTP ${r.status}`);
|
|
333
|
+
const text = await r.text();
|
|
334
|
+
const regex = /<Key>([^<]+)<\/Key>/g;
|
|
335
|
+
let match;
|
|
336
|
+
while ((match = regex.exec(text)) !== null) {
|
|
337
|
+
keys.push(match[1]);
|
|
338
|
+
}
|
|
339
|
+
const truncatedMatch = text.match(/<IsTruncated>(\w+)<\/IsTruncated>/);
|
|
340
|
+
const isTruncated = truncatedMatch?.[1] === "true";
|
|
341
|
+
if (isTruncated) {
|
|
342
|
+
const tokenMatch = text.match(
|
|
343
|
+
/<NextContinuationToken>([^<]+)<\/NextContinuationToken>/
|
|
344
|
+
);
|
|
345
|
+
continuationToken = tokenMatch?.[1];
|
|
346
|
+
if (!continuationToken) break;
|
|
347
|
+
} else {
|
|
348
|
+
continuationToken = void 0;
|
|
349
|
+
}
|
|
350
|
+
} while (continuationToken);
|
|
334
351
|
return keys;
|
|
335
352
|
}
|
|
336
353
|
async delete(path) {
|
|
@@ -1310,6 +1327,17 @@ var Space = class _Space {
|
|
|
1310
1327
|
}
|
|
1311
1328
|
};
|
|
1312
1329
|
|
|
1330
|
+
// src/types.ts
|
|
1331
|
+
var ZERO_SPATIAL_KEY = "0000000000000000";
|
|
1332
|
+
var SCALAR_ENCODING_MAP = {
|
|
1333
|
+
categorical: "cat",
|
|
1334
|
+
bool: "bool",
|
|
1335
|
+
int: "i64",
|
|
1336
|
+
float: "f64",
|
|
1337
|
+
string: "str",
|
|
1338
|
+
timestamp: "ts"
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1313
1341
|
// src/dataset.ts
|
|
1314
1342
|
var Schema = class {
|
|
1315
1343
|
fields = [];
|
|
@@ -1619,7 +1647,7 @@ var Dataset = class _Dataset {
|
|
|
1619
1647
|
const fragHash = contentHash(data);
|
|
1620
1648
|
const fragHashB32 = bytesToBase32(fragHash);
|
|
1621
1649
|
await this.backend.put(
|
|
1622
|
-
`${this._timelineHash}/${modality}
|
|
1650
|
+
`${this._timelineHash}/${modality}/${ZERO_SPATIAL_KEY}/${fragHashB32}`,
|
|
1623
1651
|
data
|
|
1624
1652
|
);
|
|
1625
1653
|
newEntries.push([
|
|
@@ -1867,7 +1895,7 @@ var Dataset = class _Dataset {
|
|
|
1867
1895
|
const fragHash = bytesToBase32(e[3]);
|
|
1868
1896
|
try {
|
|
1869
1897
|
const fragBytes = await this.backend.get(
|
|
1870
|
-
`${this._timelineHash}/${bfMod}
|
|
1898
|
+
`${this._timelineHash}/${bfMod}/${ZERO_SPATIAL_KEY}/${fragHash}`
|
|
1871
1899
|
);
|
|
1872
1900
|
fieldData.set(tStart, fragBytes);
|
|
1873
1901
|
} catch {
|
|
@@ -2170,16 +2198,6 @@ function schemaFromCbor(obj) {
|
|
|
2170
2198
|
}
|
|
2171
2199
|
return schema;
|
|
2172
2200
|
}
|
|
2173
|
-
|
|
2174
|
-
// src/types.ts
|
|
2175
|
-
var SCALAR_ENCODING_MAP = {
|
|
2176
|
-
categorical: "cat",
|
|
2177
|
-
bool: "bool",
|
|
2178
|
-
int: "i64",
|
|
2179
|
-
float: "f64",
|
|
2180
|
-
string: "str",
|
|
2181
|
-
timestamp: "ts"
|
|
2182
|
-
};
|
|
2183
2201
|
export {
|
|
2184
2202
|
Dataset,
|
|
2185
2203
|
MULTIHASH_BYTES,
|
|
@@ -2188,6 +2206,7 @@ export {
|
|
|
2188
2206
|
SCALAR_ENCODING_MAP,
|
|
2189
2207
|
Schema,
|
|
2190
2208
|
Space,
|
|
2209
|
+
ZERO_SPATIAL_KEY,
|
|
2191
2210
|
base32ToBytes,
|
|
2192
2211
|
bitsFromProjections,
|
|
2193
2212
|
bitsToBase2,
|