@olivia-db/client 0.1.1 → 0.1.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/dist/dsl.d.ts +498 -0
- package/dist/dsl.js +957 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +8 -0
- package/dist/native.d.ts +10 -0
- package/dist/native.js +19 -4
- package/package.json +5 -1
- package/src/dsl.ts +1228 -0
- package/src/index.ts +9 -0
- package/src/native.ts +26 -4
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,12 @@ export declare class OliviaDbClient {
|
|
|
104
104
|
private next;
|
|
105
105
|
private send;
|
|
106
106
|
private json;
|
|
107
|
+
/**
|
|
108
|
+
* Any route of the network API: `path` from `/v1`, with its query, already encoded. The
|
|
109
|
+
* answer's JSON; a failure throws OliviaDbError after the client's retries and failover.
|
|
110
|
+
* The typed models and queries (`@olivia-db/client/dsl`) send their requests through it.
|
|
111
|
+
*/
|
|
112
|
+
request<T = Json>(method: string, path: string, body?: object): Promise<T>;
|
|
107
113
|
remember(a: RememberArgs): Promise<Json>;
|
|
108
114
|
recall(a: RecallArgs): Promise<RecallResult>;
|
|
109
115
|
expand(pack: string, ref: string): Promise<Json>;
|
package/dist/index.js
CHANGED
|
@@ -120,6 +120,14 @@ export class OliviaDbClient {
|
|
|
120
120
|
const t = await r.text();
|
|
121
121
|
return (t ? JSON.parse(t) : {});
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Any route of the network API: `path` from `/v1`, with its query, already encoded. The
|
|
125
|
+
* answer's JSON; a failure throws OliviaDbError after the client's retries and failover.
|
|
126
|
+
* The typed models and queries (`@olivia-db/client/dsl`) send their requests through it.
|
|
127
|
+
*/
|
|
128
|
+
request(method, path, body) {
|
|
129
|
+
return this.json(method, path, body);
|
|
130
|
+
}
|
|
123
131
|
remember(a) {
|
|
124
132
|
return this.json("POST", "/v1/memory/remember", a);
|
|
125
133
|
}
|
package/dist/native.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ export interface Field {
|
|
|
37
37
|
disc: number;
|
|
38
38
|
values: string[];
|
|
39
39
|
};
|
|
40
|
+
/** The type as the descriptor writes it (`string(80)`, `decimal(18,2)`, the canonical JSON
|
|
41
|
+
* of an enum or a reference). */
|
|
42
|
+
typeText?: string;
|
|
40
43
|
}
|
|
41
44
|
export interface KeyPart {
|
|
42
45
|
name: string;
|
|
@@ -163,6 +166,10 @@ export declare class NativeClient {
|
|
|
163
166
|
private streams;
|
|
164
167
|
private nextStream;
|
|
165
168
|
private descs;
|
|
169
|
+
/** The fields of every writer layout a descriptor of this connection described, by layout
|
|
170
|
+
* id: [number, name, type text] each (typed code reads a node of an older layout by them;
|
|
171
|
+
* never dropped, a few hundred bytes per layout). */
|
|
172
|
+
private layouts;
|
|
166
173
|
private buf;
|
|
167
174
|
private closedWhy;
|
|
168
175
|
private handshake;
|
|
@@ -203,6 +210,9 @@ export declare class NativeClient {
|
|
|
203
210
|
* a record's): its records as they come, until the iteration stops (the stream is then
|
|
204
211
|
* cancelled). */
|
|
205
212
|
changes(paths: string[], from: string): AsyncGenerator<Change>;
|
|
213
|
+
/** The fields of a writer layout a descriptor of this connection described: [number, name,
|
|
214
|
+
* type text] each, the fixed, variant-case and tail fields (spec native-protocol.md 5). */
|
|
215
|
+
layoutFields(id: string): ReadonlyArray<readonly [number, string, string]> | undefined;
|
|
206
216
|
close(): void;
|
|
207
217
|
}
|
|
208
218
|
/** One change record. */
|
package/dist/native.js
CHANGED
|
@@ -219,10 +219,14 @@ export class Desc {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
function readField(r) {
|
|
222
|
+
const number = r.varint();
|
|
223
|
+
const name = r.str();
|
|
224
|
+
const typeText = r.str();
|
|
222
225
|
return {
|
|
223
|
-
number
|
|
224
|
-
name
|
|
225
|
-
|
|
226
|
+
number,
|
|
227
|
+
name,
|
|
228
|
+
typeText,
|
|
229
|
+
type: parseType(typeText),
|
|
226
230
|
tail: r.u8() === 1,
|
|
227
231
|
offset: r.varint(),
|
|
228
232
|
length: r.varint(),
|
|
@@ -869,6 +873,10 @@ export class NativeClient {
|
|
|
869
873
|
streams = new Map();
|
|
870
874
|
nextStream = 3;
|
|
871
875
|
descs = new Map();
|
|
876
|
+
/** The fields of every writer layout a descriptor of this connection described, by layout
|
|
877
|
+
* id: [number, name, type text] each (typed code reads a node of an older layout by them;
|
|
878
|
+
* never dropped, a few hundred bytes per layout). */
|
|
879
|
+
layouts = new Map();
|
|
872
880
|
buf = new Uint8Array(0);
|
|
873
881
|
closedWhy;
|
|
874
882
|
handshake = new Queue();
|
|
@@ -945,7 +953,7 @@ export class NativeClient {
|
|
|
945
953
|
const hello = [0, 1, 0, 1];
|
|
946
954
|
putVarint(hello, 1);
|
|
947
955
|
putLp(hello, enc.encode("client"));
|
|
948
|
-
putLp(hello, enc.encode("oliviadb-js 0.1.
|
|
956
|
+
putLp(hello, enc.encode("oliviadb-js 0.1.2"));
|
|
949
957
|
const auth = [];
|
|
950
958
|
putLp(auth, enc.encode(scheme));
|
|
951
959
|
putLp(auth, enc.encode(credential));
|
|
@@ -1004,6 +1012,8 @@ export class NativeClient {
|
|
|
1004
1012
|
}
|
|
1005
1013
|
if (op === OP.DESCRIBE) {
|
|
1006
1014
|
const [id, d] = describe(body);
|
|
1015
|
+
if (!this.layouts.has(d.layout))
|
|
1016
|
+
this.layouts.set(d.layout, d.fields.map((f) => [f.number, f.name, f.typeText ?? ""]));
|
|
1007
1017
|
const m = new Map(this.descs);
|
|
1008
1018
|
m.set(id, d);
|
|
1009
1019
|
this.descs = m;
|
|
@@ -1146,6 +1156,11 @@ export class NativeClient {
|
|
|
1146
1156
|
this.streams.delete(s);
|
|
1147
1157
|
}
|
|
1148
1158
|
}
|
|
1159
|
+
/** The fields of a writer layout a descriptor of this connection described: [number, name,
|
|
1160
|
+
* type text] each, the fixed, variant-case and tail fields (spec native-protocol.md 5). */
|
|
1161
|
+
layoutFields(id) {
|
|
1162
|
+
return this.layouts.get(id);
|
|
1163
|
+
}
|
|
1149
1164
|
close() {
|
|
1150
1165
|
this.sock.destroy();
|
|
1151
1166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olivia-db/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Client for OliviaDB's network API: agent memory and layer-1 reads, and the native protocol (Node.js)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"./native": {
|
|
15
15
|
"types": "./dist/native.d.ts",
|
|
16
16
|
"default": "./dist/native.js"
|
|
17
|
+
},
|
|
18
|
+
"./dsl": {
|
|
19
|
+
"types": "./dist/dsl.d.ts",
|
|
20
|
+
"default": "./dist/dsl.js"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"files": [
|