@maravilla-labs/types 0.5.1 → 0.7.0

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/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@maravilla-labs/types",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "description": "TypeScript definitions for Maravilla Runtime platform APIs",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "typecheck": "tsc --noEmit"
9
+ "typecheck": "tsc --noEmit",
10
+ "typecheck:test-d": "tsc --noEmit -p tsconfig.test.json"
10
11
  },
11
12
  "keywords": [
12
13
  "maravilla",
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "noEmit": true,
4
+ "strict": true,
5
+ "target": "ES2022",
6
+ "module": "ESNext",
7
+ "moduleResolution": "bundler"
8
+ },
9
+ "include": ["index.ts", "types.test-d.ts"]
10
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Type-level checks for the canonical `@maravilla-labs/types` surface.
3
+ * Verified by `tsc --noEmit -p tsconfig.test.json` — no runtime asserts.
4
+ *
5
+ * - `Platform['auth']` is exactly the canonical `AuthService`.
6
+ * - `DbCollection.find<T>` / `findOne<T>` return `DbDocument<T>`.
7
+ * - `insertOne` returns a `string`, NOT a `DbDocument` (@ts-expect-error).
8
+ */
9
+
10
+ import type { Platform, AuthService, DbDocument, DbCollection } from './index.js';
11
+
12
+ // BUG-8: the ambient platform auth surface IS the canonical AuthService.
13
+ const _auth: AuthService = {} as Platform['auth'];
14
+ const _authBack: Platform['auth'] = {} as AuthService;
15
+ void _auth;
16
+ void _authBack;
17
+
18
+ // DbDocument<T> round-trip.
19
+ interface Note {
20
+ body: string;
21
+ }
22
+ declare const note: DbDocument<Note>;
23
+ const _body: string = note.body;
24
+ const _id: string = note.id;
25
+ const _underId: string = note._id;
26
+ void _body;
27
+ void _id;
28
+ void _underId;
29
+
30
+ // Collection generics.
31
+ declare const col: DbCollection;
32
+ async function check() {
33
+ const rows = await col.find<Note>({});
34
+ const _row: DbDocument<Note> = rows[0];
35
+ const _rowBody: string = rows[0].body;
36
+ void _row;
37
+ void _rowBody;
38
+
39
+ const id = await col.insertOne({ body: 'x' });
40
+ const _s: string = id;
41
+ void _s;
42
+ // @ts-expect-error insertOne resolves to a string id, never a DbDocument
43
+ const _bad: DbDocument<Note> = id;
44
+ void _bad;
45
+ }
46
+ void check;