create-noy-db 0.9.0 → 0.10.0-pre.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/dist/index.d.ts CHANGED
@@ -50,6 +50,7 @@ interface WizardMessages {
50
50
  adapterMemoryLabel: string;
51
51
  /** "Include sample invoice records?" confirm label. */
52
52
  promptSampleData: string;
53
+ promptRecommended: string;
53
54
  /** Title of the "Next steps" note block. */
54
55
  freshNextStepsTitle: string;
55
56
  /** Success banner shown after the fresh project is created. */
@@ -111,15 +112,18 @@ type WizardAdapter = 'browser' | 'file' | 'memory';
111
112
  /**
112
113
  * Which starter template to scaffold in fresh-project mode.
113
114
  *
114
- * - `nuxt-default` — Nuxt 4 + Pinia + in-nuxt, SSR-friendly. Default.
115
- * - `vanilla` — Vite + TS, no framework. Smallest footprint.
115
+ * - `minimal` — Vite + TS, one file: open a vault, put/get. **Default** since 2026-10-11
116
+ * (family#115): the recommended door scaffolded Nuxt (628 packages) while the
117
+ * README promised "nothing beyond hub".
118
+ * - `nuxt-default` — Nuxt 4 + Pinia + in-nuxt, SSR-friendly.
119
+ * - `vanilla` — Vite + TS, no framework, an invoice table UI.
116
120
  * - `vite-vue` — Vite + Vue 3 + Pinia + in-pinia. Client-side SPA.
117
121
  * - `electron` — Electron + Vue 3 + to-file. USB-stick / local-disk workflow.
118
122
  *
119
123
  * Augment mode (detected Nuxt project) ignores this field — the
120
124
  * mutation path is shared regardless of the original scaffold.
121
125
  */
122
- type WizardTemplate = 'nuxt-default' | 'vanilla' | 'vite-vue' | 'electron';
126
+ type WizardTemplate = 'minimal' | 'nuxt-default' | 'vanilla' | 'vite-vue' | 'electron';
123
127
  /**
124
128
  * Inputs to `runWizard()`. All fields are optional — when a field is
125
129
  * omitted the wizard prompts for it. Tests pass everything to skip
@@ -694,4 +698,274 @@ interface BackupResult {
694
698
  declare function resolveBackupTarget(target: string, cwd?: string): string;
695
699
  declare function backup(options: BackupOptions): Promise<BackupResult>;
696
700
 
697
- export { type AddCollectionOptions, type AddUserOptions, type AddUserResult, type BackupOptions, type BackupResult, type Locale, type ReadSecret, type RotateOptions, type RotateResult, SUPPORTED_LOCALES, type VerifyResult, type WizardMessages, type WizardOptions, type WizardResult, addCollection, addUser, assertRole, backup, detectLocale, loadMessages, parseCollectionList, parseLocaleFlag, resolveBackupTarget, rotate, runWizard, verifyIntegrity };
701
+ interface InspectResult {
702
+ formatVersion: number;
703
+ handle: string;
704
+ bodyBytes: number;
705
+ bodySha256: string;
706
+ }
707
+ declare function inspect(filePath: string): Promise<InspectResult>;
708
+ declare function runInspect(argv: readonly string[]): Promise<number>;
709
+
710
+ interface VerifyReport {
711
+ ok: boolean;
712
+ file: string;
713
+ handle: string;
714
+ bodyBytes: number;
715
+ checks: {
716
+ magic: boolean;
717
+ header: boolean;
718
+ bodyHash: boolean;
719
+ };
720
+ error?: string;
721
+ }
722
+ declare function verify(filePath: string): Promise<VerifyReport>;
723
+ declare function runVerify(argv: readonly string[]): Promise<number>;
724
+
725
+ interface ValidationIssue {
726
+ severity: 'warn' | 'error';
727
+ code: string;
728
+ path: string;
729
+ message: string;
730
+ }
731
+ interface ValidationReport {
732
+ ok: boolean;
733
+ issues: ValidationIssue[];
734
+ }
735
+ declare function validateOptions(opts: unknown): ValidationReport;
736
+ /** Dynamically import a JS/MJS/CJS config file and pull the NoydbOptions
737
+ * out of it. Accepts a default export that is either the options
738
+ * object or a zero-arg function (sync or async) returning the options.
739
+ *
740
+ * **TypeScript note.** Node cannot `import()` a bare `.ts` file without
741
+ * a loader. If the adopter's config is TypeScript, they should either
742
+ * compile it first (`tsc foo.ts`) or run the CLI under a TS-capable
743
+ * runtime (e.g. `tsx $(which noy-db) config validate foo.ts`). The
744
+ * function throws a human-readable error for `.ts` input rather than
745
+ * propagating Node's cryptic `Unknown file extension` message. */
746
+ declare function loadOptionsFromFile(filePath: string): Promise<unknown>;
747
+ declare function runConfigValidate(argv: readonly string[]): Promise<number>;
748
+ /**
749
+ * The ten topology profiles. ⛔ This table IS the documentation: until 2026-10-11
750
+ * every pointer went to `docs/guides/topology-matrix.md`, a path that existed in
751
+ * no public repo, so profiles B–J were undiscoverable from the CLI (family#109).
752
+ * `noy-db config profiles` prints it; a profile's `notes` string stays the one
753
+ * authority for what it is.
754
+ */
755
+ declare const PROFILE_IDS: readonly ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"];
756
+ type Profile = (typeof PROFILE_IDS)[number];
757
+ interface ScaffoldResult {
758
+ profile: Profile;
759
+ code: string;
760
+ env: string;
761
+ notes: string;
762
+ }
763
+ declare function scaffold(profile: Profile): ScaffoldResult;
764
+ /** One line per profile — the `notes` string of each, which is the authority. */
765
+ declare function listProfiles(): string;
766
+ declare function runConfigProfiles(): number;
767
+ declare function runConfigScaffold(argv: readonly string[]): Promise<number>;
768
+
769
+ /**
770
+ * One method's timings. Names only the fields this formatter READS; the index
771
+ * signature carries the rest a real snapshot reports (`p90` today).
772
+ *
773
+ * ⭐ Open on purpose. Mirroring to-meter's exact field list would make this a
774
+ * structural twin that drifts the moment to-meter adds a percentile — and
775
+ * drift is the cost the local declaration exists to avoid, not one to
776
+ * re-import.
777
+ */
778
+ interface MeterMethodStats {
779
+ readonly count: number;
780
+ readonly errors: number;
781
+ readonly p50: number;
782
+ readonly p99: number;
783
+ readonly max: number;
784
+ readonly avg: number;
785
+ readonly [stat: string]: number;
786
+ }
787
+ /**
788
+ * The six core store methods are always present. A real snapshot carries more
789
+ * — `p90`, plus the optional half of the store contract (`listPage`, `tx`, …)
790
+ * — and the index signature is what lets it satisfy this view; the NAMED
791
+ * members are what keep `byMethod[m]` safe under `noUncheckedIndexedAccess`.
792
+ *
793
+ * ⚠️ That a real snapshot populates EVERY key is to-meter's invariant, not
794
+ * ours, and it is witnessed there (`__tests__/meter-composition.test.ts`).
795
+ * This view deliberately cannot assert it.
796
+ */
797
+ interface MeterByMethod {
798
+ readonly get: MeterMethodStats;
799
+ readonly put: MeterMethodStats;
800
+ readonly delete: MeterMethodStats;
801
+ readonly list: MeterMethodStats;
802
+ readonly loadAll: MeterMethodStats;
803
+ readonly saveAll: MeterMethodStats;
804
+ readonly [method: string]: MeterMethodStats;
805
+ }
806
+ /** The slice of to-meter's `MeterSnapshot` this formatter reads. */
807
+ interface MeterSnapshotView {
808
+ readonly collectedAt: string;
809
+ readonly status: string;
810
+ readonly totalCalls: number;
811
+ readonly casConflicts: number;
812
+ readonly windowMs: number;
813
+ readonly byMethod: MeterByMethod;
814
+ }
815
+ interface MonitorOptions {
816
+ intervalMs: number;
817
+ iterations?: number;
818
+ }
819
+ declare function runMonitor(argv: readonly string[]): Promise<number>;
820
+ declare function formatSnapshot(snap: MeterSnapshotView): string;
821
+
822
+ /**
823
+ * `noy-db describe <file.noydb>` — emit a human-readable YAML/JSON
824
+ * description of a bundle's structure (collections, fields, indexes,
825
+ * FKs, MVs, overlays, derivations) with optional counters.
826
+ *
827
+ * Loads the bundle into an in-memory store, unlocks it with the
828
+ * supplied secret + user, calls `vault.dumpSchema()`, then emits.
829
+ *
830
+ * See `design-history/2026-05-22-schema-dump-design.md`.
831
+ *
832
+ * @module
833
+ */
834
+ type DescribeFormat = 'yaml' | 'json';
835
+ type SchemasMode = 'none' | 'full' | 'sidecar';
836
+ interface DescribeOptions {
837
+ readonly bundlePath: string;
838
+ readonly user: string;
839
+ readonly secret: string;
840
+ readonly format: DescribeFormat;
841
+ readonly withStats: boolean;
842
+ readonly schemas: SchemasMode;
843
+ readonly outPath?: string;
844
+ readonly sampleSize: number;
845
+ }
846
+ /** Run the full describe pipeline and return the emitted string. */
847
+ declare function describeBundle(opts: DescribeOptions): Promise<string>;
848
+ declare function runDescribe(argv: readonly string[]): Promise<number>;
849
+
850
+ type DoctorLevel = 'error' | 'warn' | 'info';
851
+ type DoctorMode = 'dev' | 'prod';
852
+ interface DoctorFinding {
853
+ /** Stable, e.g. `NOY-R001`. */
854
+ readonly id: string;
855
+ readonly level: DoctorLevel;
856
+ /** One line: what is wrong. */
857
+ readonly message: string;
858
+ /** One line: what to do. Always present — a finding without a fix is a complaint. */
859
+ readonly fix: string;
860
+ /** Where it was seen: a config path, a file, a vault. */
861
+ readonly where?: string;
862
+ }
863
+ /** The input a check sees. Nothing here requires a secret. */
864
+ interface DoctorContext {
865
+ readonly mode: DoctorMode;
866
+ /** The project directory (where package.json lives). */
867
+ readonly root: string;
868
+ /** The config file, when one was found/given. */
869
+ readonly configPath?: string;
870
+ /** The loaded options object, untyped on purpose — a check narrows what it reads. */
871
+ readonly options?: Record<string, unknown>;
872
+ /** The store from the config, when it has one. */
873
+ readonly store?: NoydbStore;
874
+ /** Vault names to inspect. From `--vault`, else the ones the store lists, else none. */
875
+ readonly vaults: readonly string[];
876
+ /** package.json of the project, parsed. */
877
+ readonly manifest: {
878
+ dependencies?: Record<string, string>;
879
+ devDependencies?: Record<string, string>;
880
+ };
881
+ }
882
+ interface DoctorCheck {
883
+ readonly id: string;
884
+ readonly run: (ctx: DoctorContext) => Promise<readonly DoctorFinding[]> | readonly DoctorFinding[];
885
+ }
886
+ interface DoctorReport {
887
+ readonly mode: DoctorMode;
888
+ readonly findings: readonly DoctorFinding[];
889
+ readonly counts: Record<DoctorLevel, number>;
890
+ /** Which check ids ran, so a `--json` consumer can tell "clean" from "not covered". */
891
+ readonly ran: readonly string[];
892
+ }
893
+ declare const BUILTIN_CHECKS: readonly DoctorCheck[];
894
+ interface DoctorOptions {
895
+ readonly root?: string;
896
+ readonly configPath?: string;
897
+ readonly mode?: DoctorMode;
898
+ readonly vaults?: readonly string[];
899
+ /** Skip importing satellites (tests, or an untrusted node_modules). */
900
+ readonly noSatellites?: boolean;
901
+ }
902
+ declare function doctor(opts?: DoctorOptions): Promise<DoctorReport>;
903
+ /** The idempotent fixes. Returns what it changed. Only NOY-H001 today. */
904
+ declare function applyFixes(root: string, report: DoctorReport): string[];
905
+ declare function formatReport(r: DoctorReport): string;
906
+ declare function runDoctor(argv: readonly string[]): Promise<number>;
907
+
908
+ declare const CATALOG_URL = "https://noy-db.lanna.ai/catalog.json";
909
+ interface CatalogPrefix {
910
+ readonly reads: string;
911
+ readonly layer: string;
912
+ readonly plaintext: string;
913
+ readonly trust: string;
914
+ }
915
+ interface CatalogPackage {
916
+ readonly id: string;
917
+ readonly name: string;
918
+ readonly package: string;
919
+ readonly prefix: string;
920
+ readonly section: string;
921
+ readonly status: string;
922
+ readonly producer: string | null;
923
+ readonly useCase?: string;
924
+ }
925
+ interface Catalog {
926
+ readonly schemaVersion: number;
927
+ readonly prefixes: Record<string, CatalogPrefix>;
928
+ readonly packages: readonly CatalogPackage[];
929
+ }
930
+ /** The shipped snapshot — always available. */
931
+ declare function bundledCatalog(): Catalog;
932
+ /** Live first, snapshot second. Says which one it used. */
933
+ declare function loadCatalog(opts?: {
934
+ offline?: boolean;
935
+ timeoutMs?: number;
936
+ fetchImpl?: typeof fetch;
937
+ }): Promise<{
938
+ catalog: Catalog;
939
+ source: 'live' | 'bundled';
940
+ }>;
941
+ /** `to-`, `to`, `@noy-db/to-` and `storage`-style words all mean the to- prefix. */
942
+ declare function normalisePrefix(input: string | undefined): string | undefined;
943
+ declare function formatList(catalog: Catalog, prefix?: string): string;
944
+ /** Resolve a user's spelling to a catalog row: `to-aws-s3`, `aws-s3`, `@noy-db/to-aws-s3`. */
945
+ declare function findPackage(catalog: Catalog, input: string): CatalogPackage | undefined;
946
+ type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
947
+ /** Detect from the lockfile present in `root`; pnpm when nothing says otherwise. */
948
+ declare function detectPackageManager(root: string): PackageManager;
949
+ /** The install command, as argv. `yarn add` and `bun add` differ from `npm install`. */
950
+ declare function installArgv(pm: PackageManager, pkg: string, dev: boolean): string[];
951
+ /** What to paste after installing, by layer. Short on purpose: the README of the package is the manual. */
952
+ declare function snippetFor(p: CatalogPackage): string;
953
+ interface AddOptions {
954
+ readonly root?: string;
955
+ readonly dev?: boolean;
956
+ readonly dryRun?: boolean;
957
+ readonly offline?: boolean;
958
+ readonly fetchImpl?: typeof fetch;
959
+ }
960
+ interface AddResult {
961
+ readonly pkg: CatalogPackage;
962
+ readonly installed: boolean;
963
+ readonly command: string[];
964
+ readonly wired: 'nuxt-module' | null;
965
+ readonly trust: string;
966
+ readonly snippet: string;
967
+ }
968
+ declare function addPackage(input: string, opts?: AddOptions): Promise<AddResult>;
969
+ declare function runAddPackage(argv: readonly string[]): Promise<number>;
970
+
971
+ export { type AddCollectionOptions, type AddOptions, type AddResult, type AddUserOptions, type AddUserResult, BUILTIN_CHECKS, type BackupOptions, type BackupResult, CATALOG_URL, type Catalog, type CatalogPackage, type CatalogPrefix, type DescribeFormat, type DescribeOptions, type DoctorCheck, type DoctorContext, type DoctorFinding, type DoctorLevel, type DoctorMode, type DoctorOptions, type DoctorReport, type InspectResult, type Locale, type MeterSnapshotView, type MonitorOptions, PROFILE_IDS, type PackageManager, type Profile, type ReadSecret, type RotateOptions, type RotateResult, SUPPORTED_LOCALES, type ScaffoldResult, type SchemasMode, type ValidationIssue, type ValidationReport, type VerifyReport, type VerifyResult, type WizardMessages, type WizardOptions, type WizardResult, addCollection, addPackage, addUser, applyFixes, assertRole, backup, bundledCatalog, describeBundle, detectLocale, detectPackageManager, doctor, findPackage, formatList, formatReport, formatSnapshot, inspect, installArgv, listProfiles, loadCatalog, loadMessages, loadOptionsFromFile, normalisePrefix, parseCollectionList, parseLocaleFlag, resolveBackupTarget, rotate, runAddPackage, runConfigProfiles, runConfigScaffold, runConfigValidate, runDescribe, runDoctor, runInspect, runMonitor, runVerify, runWizard, scaffold, snippetFor, validateOptions, verify, verifyIntegrity };