cloesce 0.0.4-unstable.3 → 0.0.4-unstable.5

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.
@@ -33,5 +33,5 @@ export declare function invokeOrmWasm<T>(fn: (...args: number[]) => boolean, arg
33
33
  * Calls `object_relational_mapping` to turn a row of SQL records into
34
34
  * an instantiated object.
35
35
  */
36
- export declare function fromSql<T extends object>(ctor: new () => T, records: Record<string, any>[], includeTree: IncludeTree<T> | CidlIncludeTree | null): Either<string, T[]>;
36
+ export declare function mapSql<T extends object>(ctor: new () => T, records: Record<string, any>[], includeTree: IncludeTree<T> | CidlIncludeTree | null): Either<string, T[]>;
37
37
  //# sourceMappingURL=wasm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/router/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,UAAU,EACV,MAAM,EAIP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;IAC3B,cAAc,IAAI,MAAM,CAAC;IACzB,cAAc,IAAI,MAAM,CAAC;IACzB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/C,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC,yBAAyB,CACvB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;IAEX,YAAY,CACV,cAAc,EAAE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,KAAK,OAAO,EAClC,IAAI,EAAE,YAAY,EAAE,EACpB,IAAI,EAAE,cAAc,GACnB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAkBnB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EACrC,IAAI,EAAE,UAAU,CAAC,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC9B,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,GAAG,IAAI,GACnD,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CA0DrB"}
@@ -61,7 +61,7 @@ export function invokeOrmWasm(fn, args, wasm) {
61
61
  * Calls `object_relational_mapping` to turn a row of SQL records into
62
62
  * an instantiated object.
63
63
  */
64
- export function fromSql(ctor, records, includeTree) {
64
+ export function mapSql(ctor, records, includeTree) {
65
65
  const { ast, constructorRegistry, wasm } = RuntimeContainer.get();
66
66
  const args = [
67
67
  WasmResource.fromString(ctor.name, wasm),
@@ -1,42 +1,363 @@
1
1
  import { D1Database } from "@cloudflare/workers-types/experimental/index.js";
2
- import { CrudKind, Either, KeysOfType } from "../common.js";
2
+ import { CrudKind, DeepPartial, Either, KeysOfType } from "../common.js";
3
3
  export { cloesce } from "../router/router.js";
4
4
  export type { HttpResult, Either, DeepPartial, InstanceRegistry, CrudKind, } from "../common.js";
5
5
  export { CloesceApp } from "../common.js";
6
+ /**
7
+ * Marks a class as a D1-backed SQL model.
8
+ *
9
+ * Classes annotated with `@D1` are compiled into:
10
+ * - a D1 table definition (via `cloesce migrate`)
11
+ * - backend API endpoints (Workers)
12
+ * - a frontend client API
13
+ * - Cloudflare Wrangler configurations
14
+ *
15
+ * Each `@D1` class must define exactly one `@PrimaryKey`.
16
+ *
17
+ * Example:
18
+ *```ts
19
+ * @D1
20
+ * export class Horse {
21
+ * @PrimaryKey id: number;
22
+ * name: string;
23
+ * }
24
+ * ```
25
+ */
6
26
  export declare const D1: ClassDecorator;
27
+ /**
28
+ * Marks a class as a plain serializable object.
29
+ *
30
+ * `@PlainOldObject` types represent data that can be safely
31
+ * returned from a model method or API endpoint without being
32
+ * treated as a database model.
33
+ *
34
+ * These are often used for DTOs or view models.
35
+ *
36
+ * Example:
37
+ * ```ts
38
+ * @PlainOldObject
39
+ * export class CatStuff {
40
+ * catFacts: string[];
41
+ * catNames: string[];
42
+ * }
43
+ * ```
44
+ */
7
45
  export declare const PlainOldObject: ClassDecorator;
46
+ /**
47
+ * Declares a Wrangler environment definition.
48
+ *
49
+ * A `@WranglerEnv` class describes environment bindings
50
+ * available to your Cloudflare Worker at runtime.
51
+ *
52
+ * The environment instance is automatically injected into
53
+ * decorated methods using `@Inject`.
54
+ *
55
+ * Example:
56
+ * ```ts
57
+ * @WranglerEnv
58
+ * export class Env {
59
+ * db: D1Database;
60
+ * motd: string;
61
+ * }
62
+ *
63
+ * // in a method...
64
+ * foo(@Inject env: WranglerEnv) {...}
65
+ * ```
66
+ */
8
67
  export declare const WranglerEnv: ClassDecorator;
68
+ /**
69
+ * Marks a property as the SQL primary key for a model.
70
+ *
71
+ * Every `@D1` class must define exactly one primary key.
72
+ *
73
+ * Cannot be null.
74
+ *
75
+ * Example:
76
+ * ```ts
77
+ * @D1
78
+ * export class User {
79
+ * @PrimaryKey id: number;
80
+ * name: string;
81
+ * }
82
+ * ```
83
+ */
9
84
  export declare const PrimaryKey: PropertyDecorator;
85
+ /**
86
+ * Exposes a class method as an HTTP GET endpoint.
87
+ * The method will appear in both backend and generated client APIs.
88
+ */
10
89
  export declare const GET: MethodDecorator;
90
+ /**
91
+ * Exposes a class method as an HTTP POST endpoint.
92
+ * The method will appear in both backend and generated client APIs.
93
+ */
11
94
  export declare const POST: MethodDecorator;
95
+ /**
96
+ * Exposes a class method as an HTTP PUT endpoint.
97
+ * The method will appear in both backend and generated client APIs.
98
+ */
12
99
  export declare const PUT: MethodDecorator;
100
+ /**
101
+ * Exposes a class method as an HTTP PATCH endpoint.
102
+ * The method will appear in both backend and generated client APIs.
103
+ */
13
104
  export declare const PATCH: MethodDecorator;
105
+ /**
106
+ * Exposes a class method as an HTTP DEL endpoint.
107
+ * The method will appear in both backend and generated client APIs.
108
+ */
14
109
  export declare const DELETE: MethodDecorator;
110
+ /**
111
+ * Declares a static property as a data source.
112
+ *
113
+ * Data sources describe SQL view definitions (joins) for
114
+ * model relationships. They define which related models
115
+ * are automatically included when querying. Data sources
116
+ * can only reference navigation properties, not scalar
117
+ * attributes.
118
+ *
119
+ * Example:
120
+ * ```ts
121
+ * @D1
122
+ * export class Dog {
123
+ * @PrimaryKey
124
+ * id: number;
125
+ *
126
+ * name: string;
127
+ * }
128
+ *
129
+ * @D1
130
+ * export class Person {
131
+ * @PrimaryKey
132
+ * id: number;
133
+ *
134
+ * @ForeignKey(Dog)
135
+ * dogId: number;
136
+ *
137
+ * @OneToOne("dogId")
138
+ * dog: Dog | undefined;
139
+ *
140
+ * // 👇 Defines a data source that joins the related Dog record
141
+ * @DataSource
142
+ * static readonly default: IncludeTree<Person> = {
143
+ * dog: {},
144
+ * };
145
+ * }
146
+ *
147
+ * // The above will generate an SQL view similar to:
148
+ * // CREATE VIEW "Person.default" AS
149
+ * // SELECT
150
+ * // "Person"."id" AS "id",
151
+ * // "Person"."dogId" AS "dogId",
152
+ * // "Dog"."id" AS "dog.id",
153
+ * // "Dog"."name" AS "dog.name"
154
+ * // FROM "Person"
155
+ * // LEFT JOIN "Dog" ON "Person"."dogId" = "Dog"."id";
156
+ *
157
+ * // When queried via the ORM or client API:
158
+ * const orm = Orm.fromD1(env.db);
159
+ * const people = (await orm.list(Person, "default")).value;
160
+ * // Each Person instance will now include a populated .dog property.
161
+ * ```
162
+ */
15
163
  export declare const DataSource: PropertyDecorator;
164
+ /**
165
+ * Declares a one-to-many relationship between models.
166
+ *
167
+ * The argument is the foreign key property name on the
168
+ * related model.
169
+ *
170
+ * Example:
171
+ * ```ts
172
+ * @OneToMany("personId")
173
+ * dogs: Dog[];
174
+ * ```
175
+ */
16
176
  export declare const OneToMany: (_: string) => PropertyDecorator;
177
+ /**
178
+ * Declares a one-to-one relationship between models.
179
+ *
180
+ * The argument is the foreign key property name that links
181
+ * the two tables.
182
+ *
183
+ * Example:
184
+ * ```ts
185
+ * @OneToOne("dogId")
186
+ * dog: Dog | undefined;
187
+ * ```
188
+ */
17
189
  export declare const OneToOne: (_: string) => PropertyDecorator;
190
+ /**
191
+ * Declares a many-to-many relationship between models.
192
+ *
193
+ * The argument is a unique identifier for the generated
194
+ * junction table used to connect the two entities.
195
+ *
196
+ * Example:
197
+ * ```ts
198
+ * @ManyToMany("StudentsCourses")
199
+ * courses: Course[];
200
+ * ```
201
+ */
18
202
  export declare const ManyToMany: (_: string) => PropertyDecorator;
203
+ /**
204
+ * Declares a foreign key relationship between models.
205
+ * Directly translates to a SQLite foreign key.
206
+ *
207
+ * The argument must reference either a model class or the
208
+ * name of a model class as a string. The property type must
209
+ * match the target model’s primary key type.
210
+ *
211
+ * Example:
212
+ * ```ts
213
+ * @ForeignKey(Dog)
214
+ * dogId: number;
215
+ * ```
216
+ */
19
217
  export declare const ForeignKey: <T>(_: T | string) => PropertyDecorator;
218
+ /**
219
+ * Marks a method parameter for dependency injection.
220
+ *
221
+ * Injected parameters can receive environment bindings,
222
+ * middleware-provided objects, or other registered values.
223
+ *
224
+ * Example:
225
+ * ```ts
226
+ * @POST
227
+ * async neigh(@Inject env: WranglerEnv) {
228
+ * return `i am ${this.name}`;
229
+ * }
230
+ * ```
231
+ */
20
232
  export declare const Inject: ParameterDecorator;
233
+ /**
234
+ * Enables automatic CRUD method generation for a model.
235
+ *
236
+ * The argument is a list of CRUD operation kinds
237
+ * (e.g. `"SAVE"`, `"GET"`, `"LIST"`) to generate for the model.
238
+ *
239
+ * Cloesce will emit corresponding backend methods and frontend
240
+ * client bindings automatically, removing the need to manually
241
+ * define common API operations.
242
+ *
243
+ * Supported kinds:
244
+ * - **"SAVE"** — Performs an *upsert* (insert or update) for a model instance.
245
+ * - **"GET"** — Retrieves a single record by its primary key, optionally using a `DataSource`.
246
+ * - **"LIST"** — Retrieves all records for the model, using the specified `DataSource`.
247
+ * - **(future)** `"DELETE"` — Will remove a record by primary key once implemented.
248
+ *
249
+ * The generated methods are static, exposed through both the backend
250
+ * (Worker endpoints) and the frontend client API.
251
+ *
252
+ * Example:
253
+ * ```ts
254
+ * @CRUD(["SAVE", "GET", "LIST"])
255
+ * @D1
256
+ * export class CrudHaver {
257
+ * @PrimaryKey id: number;
258
+ * name: string;
259
+ * }
260
+ *
261
+ * // Generated methods (conceptually):
262
+ * // static async save(item: CrudHaver): Promise<HttpResult<CrudHaver>>
263
+ * // static async get(id: number, dataSource?: string): Promise<HttpResult<CrudHaver>>
264
+ * // static async list(dataSource?: string): Promise<HttpResult<CrudHaver[]>>
265
+ * ```
266
+ */
21
267
  export declare const CRUD: (_kinds: CrudKind[]) => ClassDecorator;
22
268
  type Primitive = string | number | boolean | bigint | symbol | null | undefined;
269
+ /**
270
+ * A recursive type describing which related models to include
271
+ * when querying a `@D1` model.
272
+ *
273
+ * An `IncludeTree<T>` mirrors the shape of the model class,
274
+ * where each navigation property can be replaced with another
275
+ * `IncludeTree` describing nested joins.
276
+ *
277
+ * - Scalar properties (string, number, etc.) are excluded automatically.
278
+ * - Navigation properties (e.g. `dogs: Dog[]`, `owner: Person`) may appear
279
+ * as keys with empty objects `{}` or nested trees.
280
+ *
281
+ * Example:
282
+ * ```ts
283
+ * @D1
284
+ * export class Person {
285
+ * @PrimaryKey id: number;
286
+ * @OneToMany("personId") dogs: Dog[];
287
+ *
288
+ * @DataSource
289
+ * static readonly default: IncludeTree<Person> = {
290
+ * dogs: {}, // join Dog table when querying Person
291
+ * };
292
+ * }
293
+ * ```
294
+ */
23
295
  export type IncludeTree<T> = (T extends Primitive ? never : {
24
296
  [K in keyof T]?: T[K] extends (infer U)[] ? IncludeTree<NonNullable<U>> : IncludeTree<NonNullable<T[K]>>;
25
297
  }) & {
26
298
  __brand?: "IncludeTree";
27
299
  };
300
+ /**
301
+ * Represents the name of a `@DataSource` available on a model type `T`,
302
+ * or `"none"` when no data source (no joins) should be applied.
303
+ *
304
+ * This type is used by ORM and CRUD methods to restrict valid
305
+ * data source names to the actual static properties declared on the model.
306
+ *
307
+ * Example:
308
+ * ```ts
309
+ * @D1
310
+ * export class Person {
311
+ * @PrimaryKey id: number;
312
+ *
313
+ * @DataSource
314
+ * static readonly default: IncludeTree<Person> = { dogs: {} };
315
+ * }
316
+ *
317
+ * type DS = DataSourceOf<Person>;
318
+ * // => "default" | "none"
319
+ * ```
320
+ */
28
321
  export type DataSourceOf<T extends object> = (KeysOfType<T, IncludeTree<T>> | "none") & {
29
322
  __brand?: "DataSource";
30
323
  };
31
324
  /**
32
- * A JavaScript `number` that signals to Cloesce the SQL table type
33
- * should be of Integer
325
+ * A branded `number` type indicating that the corresponding
326
+ * SQL column should be created as an `INTEGER`.
327
+ *
328
+ * While all numbers are valid JavaScript types, annotating a
329
+ * field with `Integer` communicates to the Cloesce compiler
330
+ * that this property represents an integer column in SQLite.
331
+ *
332
+ * Example:
333
+ * ```ts
334
+ * @D1
335
+ * export class Horse {
336
+ * @PrimaryKey id: Integer;
337
+ * height: number; // stored as REAL
338
+ * }
339
+ * ```
34
340
  */
35
341
  export type Integer = number & {
36
342
  __brand?: "Integer";
37
343
  };
38
344
  /**
39
- * ORM functions which use metadata to translate arguments to valid SQL queries.
345
+ * Provides helper methods for performing ORM operations against a D1 database.
346
+ *
347
+ * The `Orm` class uses the Cloesce metadata system to generate, execute,
348
+ * and map SQL queries for model classes decorated with `@D1`.
349
+ *
350
+ * Typical operations include:
351
+ * - `fromD1(db)` — create an ORM instance bound to a `D1Database`
352
+ * - `upsert()` — insert or update a model
353
+ * - `list()` — fetch all instances of a model
354
+ * - `get()` — fetch one instance by primary key
355
+ *
356
+ * Example:
357
+ * ```ts
358
+ * const orm = Orm.fromD1(env.db);
359
+ * const horses = (await orm.list(Horse, "default")).value;
360
+ * ```
40
361
  */
41
362
  export declare class Orm {
42
363
  private db;
@@ -53,9 +374,8 @@ export declare class Orm {
53
374
  * @param ctor The model constructor
54
375
  * @param records D1 Result records
55
376
  * @param includeTree Include tree to define the relationships to join.
56
- * @returns
57
377
  */
58
- static fromSql<T extends object>(ctor: new () => T, records: Record<string, any>[], includeTree: IncludeTree<T> | null): Either<string, T[]>;
378
+ static mapSql<T extends object>(ctor: new () => T, records: Record<string, any>[], includeTree?: IncludeTree<T> | null): Either<string, T[]>;
59
379
  /**
60
380
  * Returns a SQL query to insert a model into the database. Uses an IncludeTree as a guide for
61
381
  * foreign key relationships, only inserting the explicitly stated pattern in the tree.
@@ -69,7 +389,7 @@ export declare class Orm {
69
389
  * @param includeTree An include tree describing which foreign keys to join.
70
390
  * @returns Either an error string, or the insert query string.
71
391
  */
72
- static upsertQuery<T extends object>(ctor: new () => T, newModel: T, includeTree: IncludeTree<T> | null): Either<string, string>;
392
+ static upsertQuery<T extends object>(ctor: new () => T, newModel: DeepPartial<T>, includeTree?: IncludeTree<T> | null): Either<string, string>;
73
393
  /**
74
394
  * Executes an "upsert" query, adding or augmenting a model in the database.
75
395
  * If a model's primary key is not defined in `newModel`, the query is assumed to be an insert.
@@ -111,25 +431,25 @@ export declare class Orm {
111
431
  * @param includeTree An include tree describing which foreign keys to join.
112
432
  * @returns An error string, or the primary key of the inserted model.
113
433
  */
114
- upsert<T extends object>(ctor: new () => T, newModel: T, includeTree: IncludeTree<T> | null): Promise<Either<string, any>>;
434
+ upsert<T extends object>(ctor: new () => T, newModel: DeepPartial<T>, includeTree?: IncludeTree<T> | null): Promise<Either<string, any>>;
115
435
  /**
116
436
  * Returns a query of the form `SELECT * FROM [Model.DataSource]`
117
437
  */
118
- static listQuery<T extends object>(ctor: new () => T, includeTree: KeysOfType<T, IncludeTree<T>> | null): string;
438
+ static listQuery<T extends object>(ctor: new () => T, includeTree?: KeysOfType<T, IncludeTree<T>> | null): string;
119
439
  /**
120
- * Returns a query of the form `SELECT * FROM [Model.DataSource] WHERE [Model.PrimaryKey] = ?`.
440
+ * Returns a query of the form `SELECT * FROM [Model.DataSource] WHERE [PrimaryKey] = ?`.
121
441
  * Requires the id parameter to be bound (use db.prepare().bind)
122
442
  */
123
- static getQuery<T extends object>(ctor: new () => T, includeTree: KeysOfType<T, IncludeTree<T>> | null): string;
443
+ static getQuery<T extends object>(ctor: new () => T, includeTree?: KeysOfType<T, IncludeTree<T>> | null): string;
124
444
  /**
125
445
  * Executes a query of the form `SELECT * FROM [Model.DataSource]`, returning all results
126
446
  * as instantiated models.
127
447
  */
128
- list<T extends object>(ctor: new () => T, includeTreeKey: KeysOfType<T, IncludeTree<T>> | null): Promise<Either<string, T[]>>;
448
+ list<T extends object>(ctor: new () => T, includeTreeKey?: KeysOfType<T, IncludeTree<T>> | null): Promise<Either<string, T[]>>;
129
449
  /**
130
450
  * Executes a query of the form `SELECT * FROM [Model.DataSource] WHERE [Model.PrimaryKey] = ?`
131
451
  * returning all results as instantiated models.
132
452
  */
133
- get<T extends object>(ctor: new () => T, id: any, includeTreeKey: KeysOfType<T, IncludeTree<T>> | null): Promise<Either<string, T>>;
453
+ get<T extends object>(ctor: new () => T, id: any, includeTreeKey?: KeysOfType<T, IncludeTree<T>> | null): Promise<Either<string, T>>;
134
454
  }
135
455
  //# sourceMappingURL=backend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/ui/backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAIzE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,YAAY,EACV,UAAU,EACV,MAAM,EACN,WAAW,EACX,gBAAgB,EAChB,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CA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