toiljs 0.0.66 → 0.0.67
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 +5 -0
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/index.js +6 -4
- package/build/compiler/toil-docs.generated.js +1 -1
- package/build/devserver/.tsbuildinfo +1 -1
- package/build/devserver/daemon/index.js +4 -3
- package/build/devserver/db/catalog.js +8 -12
- package/build/devserver/wasm/surface.d.ts +1 -1
- package/build/devserver/wasm/surface.js +1 -1
- package/docs/tiers.md +15 -9
- package/package.json +2 -2
- package/src/compiler/index.ts +19 -13
- package/src/compiler/toil-docs.generated.ts +1 -1
- package/src/devserver/daemon/index.ts +7 -7
- package/src/devserver/db/catalog.ts +9 -13
- package/src/devserver/wasm/surface.ts +5 -7
- package/test/daemon-build.test.ts +15 -7
- package/test/daemon-catalog.test.ts +17 -8
- package/test/devserver-database.test.ts +8 -8
- package/test/rpc-bignum-wire.test.ts +8 -8
|
@@ -92,7 +92,7 @@ function routeKindsSection(routes: readonly (readonly [number, number, string])[
|
|
|
92
92
|
return Buffer.concat(chunks);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function
|
|
95
|
+
function catalogSectionV1(fillMaxWaitMs: number, fillAllowStale: number, replication = 5): Buffer {
|
|
96
96
|
const chunks: Buffer[] = [];
|
|
97
97
|
const u8 = (v: number) => chunks.push(Buffer.from([v & 0xff]));
|
|
98
98
|
const u16 = (v: number) => {
|
|
@@ -111,7 +111,7 @@ function catalogSectionV2(fillMaxWaitMs: number, fillAllowStale: number, replica
|
|
|
111
111
|
chunks.push(b);
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
u16(
|
|
114
|
+
u16(1); // catalog version
|
|
115
115
|
u16(1); // databases
|
|
116
116
|
str('App');
|
|
117
117
|
u16(1); // collections
|
|
@@ -215,8 +215,8 @@ describe('toildb dev emulator (record family)', () => {
|
|
|
215
215
|
expect(imports['data.resolve_collection'](p, l, 16)).toBe(-1070);
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
it('parses catalog
|
|
219
|
-
setDbCatalog(wasmWithSection('toildb.catalog',
|
|
218
|
+
it('parses catalog v1 fill policy and backend replication bytes', () => {
|
|
219
|
+
setDbCatalog(wasmWithSection('toildb.catalog', catalogSectionV1(7, 0)));
|
|
220
220
|
const { imports, buf, db } = setupRaw();
|
|
221
221
|
const h = resolve(imports, buf, 'App/users');
|
|
222
222
|
|
|
@@ -231,9 +231,9 @@ describe('toildb dev emulator (record family)', () => {
|
|
|
231
231
|
});
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
it('rejects replication policies that require
|
|
234
|
+
it('rejects replication policies that require explicit policy metadata', () => {
|
|
235
235
|
for (const replication of [3, 4]) {
|
|
236
|
-
setDbCatalog(wasmWithSection('toildb.catalog',
|
|
236
|
+
setDbCatalog(wasmWithSection('toildb.catalog', catalogSectionV1(7, 0, replication)));
|
|
237
237
|
const { imports, buf } = setupRaw();
|
|
238
238
|
const [p, l] = put(buf, 0, 'App/users');
|
|
239
239
|
|
|
@@ -241,8 +241,8 @@ describe('toildb dev emulator (record family)', () => {
|
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
-
it('rejects malformed catalog
|
|
245
|
-
setDbCatalog(wasmWithSection('toildb.catalog',
|
|
244
|
+
it('rejects malformed catalog v1 fill policy', () => {
|
|
245
|
+
setDbCatalog(wasmWithSection('toildb.catalog', catalogSectionV1(7, 2)));
|
|
246
246
|
const { imports, buf } = setupRaw();
|
|
247
247
|
const [p, l] = put(buf, 0, 'App/users');
|
|
248
248
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Compiles test/fixtures/bignum-wire/spec.ts with the installed toilscript (so it
|
|
8
8
|
* exercises the published compiler + generated client, not a hand-written stub), then
|
|
9
9
|
* imports the generated TS client and asserts the wire shape both directions, including
|
|
10
|
-
* values far above 2^53
|
|
10
|
+
* values far above 2^53.
|
|
11
11
|
*/
|
|
12
12
|
import { spawnSync } from 'node:child_process';
|
|
13
13
|
import fs from 'node:fs';
|
|
@@ -24,6 +24,9 @@ const codec = path.join(here, '..', 'src', 'io', 'codec.ts');
|
|
|
24
24
|
|
|
25
25
|
/** Resolves the installed toilscript CLI entry (no PATH / .bin assumptions). */
|
|
26
26
|
function toilscriptBin(): string {
|
|
27
|
+
if (process.env.TOILSCRIPT_BIN) return process.env.TOILSCRIPT_BIN;
|
|
28
|
+
const sibling = path.resolve(here, '..', '..', 'toilscript', 'bin', 'toilscript.js');
|
|
29
|
+
if (fs.existsSync(sibling)) return sibling;
|
|
27
30
|
const pkgPath = require.resolve('toilscript/package.json');
|
|
28
31
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) as { bin?: Record<string, string> };
|
|
29
32
|
const binRel = pkg.bin?.toilscript;
|
|
@@ -83,6 +86,10 @@ beforeAll(async () => {
|
|
|
83
86
|
{ encoding: 'utf8' },
|
|
84
87
|
);
|
|
85
88
|
if (res.status !== 0) throw new Error('toilscript compile failed:\n' + res.stderr);
|
|
89
|
+
const generatedSource = fs.readFileSync(mod, 'utf8');
|
|
90
|
+
const removedHelper = ['__toil', 'Unlimb'].join('');
|
|
91
|
+
expect(generatedSource).toContain('__toilBigInt');
|
|
92
|
+
expect(generatedSource).not.toContain(removedHelper);
|
|
86
93
|
const gen = (await import(pathToFileURL(mod).href)) as {
|
|
87
94
|
Wallet: WalletStatic;
|
|
88
95
|
Account: AccountStatic;
|
|
@@ -142,13 +149,6 @@ describe('generated client bignum JSON wire format', () => {
|
|
|
142
149
|
expect(back.d).toBe(BigInt('-' + huge));
|
|
143
150
|
});
|
|
144
151
|
|
|
145
|
-
it('still revives the legacy little-endian limb-array shape (back-compat)', () => {
|
|
146
|
-
// u256 [5,0,4,0] little-endian = 5 + 4*2^128.
|
|
147
|
-
const w = Wallet.fromJSONValue({ c: [5, 0, 4, 0], a: [9, 1] });
|
|
148
|
-
expect(w.c).toBe(2n ** 130n + 5n);
|
|
149
|
-
expect(w.a).toBe(2n ** 64n + 9n);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
152
|
it('recurses into nested @data and arrays of bignums', () => {
|
|
153
153
|
const a = new Account();
|
|
154
154
|
a.main.c = BigInt(huge);
|