@@ -49,7 +49,7 @@ test('consumer projects can import package APIs through the @async/db package',
4949 await writeFile ( path . join ( cwd , 'check-package.mjs' ) , `import { createDbOperationHandler, createDbRequestHandler, createDbRuntime, createIndexedDbCacheStorage, createMemoryFs, inspectSchemaMigration, loadDbSchema, openDb, reloadDb, watchDbSources } from '@async/db';
5050import { createDbClient, createIndexedDbCacheStorage as createClientIndexedDbCacheStorage } from '@async/db/client';
5151import { defineConfig } from '@async/db/config';
52- import { fileStorage, jsonStore, jsonStoreCapabilities, readJsonState, s3Storage, writeJsonState } from '@async/db/json';
52+ import { fileStorage, json, jsonStore, jsonStoreCapabilities, readJsonState, s3Storage, writeJsonState } from '@async/db/json';
5353import { sqliteStore } from '@async/db/sqlite';
5454import { compoundKeyId, defineSqliteImportPlan, openLegacySqlite } from '@async/db/sqlite/compat';
5555import { openPostgresDb, postgresStore } from '@async/db/postgres';
@@ -73,6 +73,7 @@ if (typeof createIndexedDbCacheStorage !== 'function') throw new Error('missing
7373if (typeof createClientIndexedDbCacheStorage !== 'function') throw new Error('missing client indexeddb cache API');
7474if (typeof defineConfig !== 'function') throw new Error('missing config API');
7575if (jsonStoreCapabilities.persistence !== 'local-file') throw new Error('missing json store capabilities');
76+ if (typeof json !== 'function') throw new Error('missing json standalone API');
7677if (typeof jsonStore !== 'function') throw new Error('missing json store helper');
7778if (typeof fileStorage !== 'function') throw new Error('missing json file storage helper');
7879if (typeof s3Storage !== 'function') throw new Error('missing json s3 storage helper');
@@ -162,6 +163,7 @@ import {
162163 atomicWriteJson,
163164 atomicWriteJsonVersioned,
164165 fileStorage,
166+ json,
165167 jsonStateVersionsDir,
166168 jsonStore,
167169 jsonStatePathForResource,
@@ -173,6 +175,7 @@ import {
173175 s3Storage,
174176 withJsonStateWrite,
175177 writeJsonState,
178+ type JsonOpenOptions,
176179 type JsonStoreCapabilities,
177180} from '@async/db/json';
178181import { kvStore } from '@async/db/kv';
@@ -309,6 +312,7 @@ void recoverJsonStateDir('.db/state');
309312void jsonStateVersionsDir(jsonStatePath);
310313void jsonStore({ durability: 'versioned', maxVersions: 5, encryption: { key: () => 'k' } });
311314void jsonStore();
315+ void json('./db/package-versions.json', { identity: { fields: ['name', 'version'] } } satisfies JsonOpenOptions);
312316void s3Storage({
313317 bucket: 'app-json-db',
314318 prefix: 'prod',
@@ -485,7 +489,7 @@ test('generated async-pipeline workflow owns release, preview, snapshot, and Pag
485489 assert . match ( workflow , / i d - t o k e n : w r i t e / ) ;
486490 assert . match ( workflow , / p a c k a g e s : w r i t e / ) ;
487491 assert . match ( workflow , / p u l l - r e q u e s t s : w r i t e / ) ;
488- assert . match ( workflow , / N O D E _ A U T H _ T O K E N : \$ \{ \{ s e c r e t s \. N P M _ T O K E N \} \} / ) ;
492+ assert . match ( workflow , / N O D E _ A U T H _ T O K E N : \$ \{ \{ s e c r e t s \. n p m _ t o k e n \} \} / ) ;
489493 const releaseDoctorJob = workflow . match ( / r e l e a s e - d o c t o r : [ \s \S ] * ?\n \n s n a p s h o t : / ) ?. [ 0 ] ?? '' ;
490494 assert . match ( releaseDoctorJob , / c o n t e n t s : r e a d / ) ;
491495 assert . match ( releaseDoctorJob , / p a c k a g e s : r e a d / ) ;
@@ -631,6 +635,12 @@ test('public JSON declarations expose file database helpers', async () => {
631635 assert . match ( declarations , / e x p o r t f u n c t i o n r e s t o r e J s o n S t a t e V e r s i o n \( / ) ;
632636 assert . match ( declarations , / e x p o r t f u n c t i o n l i s t J s o n S t a t e V e r s i o n s \( / ) ;
633637 assert . match ( declarations , / e x p o r t f u n c t i o n r e c o v e r J s o n S t a t e D i r \( / ) ;
638+ assert . match ( declarations , / e x p o r t t y p e J s o n I d e n t i t y D e f i n i t i o n = \{ / ) ;
639+ assert . match ( declarations , / e x p o r t t y p e J s o n O p e n O p t i o n s = \{ / ) ;
640+ assert . match ( declarations , / i d e n t i t y \? : J s o n I d e n t i t y D e f i n i t i o n ; / ) ;
641+ assert . match ( declarations , / w r i t e P o l i c y \? : ' a p p e n d - o n l y ' \| s t r i n g ; / ) ;
642+ assert . match ( declarations , / e x p o r t t y p e J s o n K e y = s t r i n g \| n u m b e r \| b o o l e a n \| R e c o r d < s t r i n g , u n k n o w n > ; / ) ;
643+ assert . match ( declarations , / e x p o r t f u n c t i o n j s o n \( t a r g e t : s t r i n g , o p t i o n s \? : J s o n O p e n O p t i o n s \) : P r o m i s e < J s o n O p e n R e s u l t > ; / ) ;
634644 assert . match ( declarations , / e x p o r t t y p e J s o n S t o r e E n c r y p t i o n O p t i o n s = \{ / ) ;
635645 assert . match ( declarations , / e x p o r t t y p e J s o n S t a t e W r i t e O p t i o n s = \{ / ) ;
636646 assert . match ( declarations , / c r o s s P r o c e s s L o c k \? : b o o l e a n ; / ) ;
0 commit comments