ugly-app 0.1.210 → 0.1.211

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.
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.1.210";
1
+ export declare const CLI_VERSION = "0.1.211";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by prebuild — do not edit manually
2
- export const CLI_VERSION = "0.1.210";
2
+ export const CLI_VERSION = "0.1.211";
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-app",
3
- "version": "0.1.210",
3
+ "version": "0.1.211",
4
4
  "type": "module",
5
5
  "main": "./dist/server/index.js",
6
6
  "exports": {
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by prebuild — do not edit manually
2
- export const CLI_VERSION = "0.1.210";
2
+ export const CLI_VERSION = "0.1.211";
@@ -59,10 +59,10 @@ submitFeedback: authReq({
59
59
  Every endpoint is accessible via both WebSocket (`socket.request(name, input)`) and HTTP (`POST /api/:name { input }`).
60
60
 
61
61
  ## Adding a collection
62
- 1. Define the Zod schema and TypeScript type in `shared/collections.ts`:
62
+ 1. Define the Zod schema and derive the type in `shared/collections.ts`:
63
63
  ```typescript
64
64
  export const TodoSchema = z.object({ userId: z.string(), text: z.string(), done: z.boolean() });
65
- export type Todo = z.infer<typeof TodoSchema> & DBObject;
65
+ export type Todo = InferDocType<typeof TodoSchema>;
66
66
  ```
67
67
  2. Add the collection to `defineCollections()` with `schema: TodoSchema`
68
68
  3. Add indexes in `shared/collections.ts`, then run `npm run db:init`
@@ -1,17 +1,23 @@
1
1
  import { z } from 'zod';
2
- import type { DBObject, UserBase } from 'ugly-app/shared';
2
+ import type { InferDocType, UserBase } from 'ugly-app/shared';
3
3
  import { defineCollections, defineDbIndexes } from 'ugly-app/shared';
4
4
 
5
- // --- Schemas & Types ---
6
- export const UserSchema = z.object({});
7
- export type User = z.infer<typeof UserSchema> & UserBase;
5
+ // ─── Schemas & Types ─────────────────────────────────────────────────────────
6
+ // Define each collection's Zod schema, then derive the type with InferDocType.
7
+ // The schema is the single source of truth — never define a separate interface.
8
+
9
+ export const UserSchema = z.object({
10
+ // name: z.string().optional(),
11
+ // avatarUrl: z.string().optional(),
12
+ });
13
+ export type User = InferDocType<typeof UserSchema> & UserBase;
8
14
 
9
15
  export const TodoSchema = z.object({
10
16
  userId: z.string(),
11
17
  text: z.string(),
12
18
  done: z.boolean(),
13
19
  });
14
- export type Todo = z.infer<typeof TodoSchema> & DBObject;
20
+ export type Todo = InferDocType<typeof TodoSchema>;
15
21
 
16
22
  // --- Collections ---
17
23
  // meta options: