@gettersethya/mira-collection 0.1.0-alpha.10

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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +164 -0
  3. package/dist/src/collection/auth.d.ts +79 -0
  4. package/dist/src/collection/auth.d.ts.map +1 -0
  5. package/dist/src/collection/auth.js +55 -0
  6. package/dist/src/collection/auth.js.map +1 -0
  7. package/dist/src/collection/base.d.ts +64 -0
  8. package/dist/src/collection/base.d.ts.map +1 -0
  9. package/dist/src/collection/base.js +45 -0
  10. package/dist/src/collection/base.js.map +1 -0
  11. package/dist/src/collection/bytes.d.ts +51 -0
  12. package/dist/src/collection/bytes.d.ts.map +1 -0
  13. package/dist/src/collection/bytes.js +51 -0
  14. package/dist/src/collection/bytes.js.map +1 -0
  15. package/dist/src/collection/errors.d.ts +29 -0
  16. package/dist/src/collection/errors.d.ts.map +1 -0
  17. package/dist/src/collection/errors.js +23 -0
  18. package/dist/src/collection/errors.js.map +1 -0
  19. package/dist/src/collection/field.d.ts +334 -0
  20. package/dist/src/collection/field.d.ts.map +1 -0
  21. package/dist/src/collection/field.js +201 -0
  22. package/dist/src/collection/field.js.map +1 -0
  23. package/dist/src/collection/index-builder.d.ts +59 -0
  24. package/dist/src/collection/index-builder.d.ts.map +1 -0
  25. package/dist/src/collection/index-builder.js +43 -0
  26. package/dist/src/collection/index-builder.js.map +1 -0
  27. package/dist/src/collection/index.d.ts +22 -0
  28. package/dist/src/collection/index.d.ts.map +1 -0
  29. package/dist/src/collection/index.js +21 -0
  30. package/dist/src/collection/index.js.map +1 -0
  31. package/dist/src/collection/serialize.d.ts +24 -0
  32. package/dist/src/collection/serialize.d.ts.map +1 -0
  33. package/dist/src/collection/serialize.js +133 -0
  34. package/dist/src/collection/serialize.js.map +1 -0
  35. package/dist/src/collection/types.d.ts +127 -0
  36. package/dist/src/collection/types.d.ts.map +1 -0
  37. package/dist/src/collection/types.js +2 -0
  38. package/dist/src/collection/types.js.map +1 -0
  39. package/dist/src/collection/view.d.ts +57 -0
  40. package/dist/src/collection/view.d.ts.map +1 -0
  41. package/dist/src/collection/view.js +54 -0
  42. package/dist/src/collection/view.js.map +1 -0
  43. package/dist/src/filter/builder.d.ts +127 -0
  44. package/dist/src/filter/builder.d.ts.map +1 -0
  45. package/dist/src/filter/builder.js +72 -0
  46. package/dist/src/filter/builder.js.map +1 -0
  47. package/dist/src/filter/compiler.d.ts +48 -0
  48. package/dist/src/filter/compiler.d.ts.map +1 -0
  49. package/dist/src/filter/compiler.js +132 -0
  50. package/dist/src/filter/compiler.js.map +1 -0
  51. package/dist/src/filter/index.d.ts +6 -0
  52. package/dist/src/filter/index.d.ts.map +1 -0
  53. package/dist/src/filter/index.js +4 -0
  54. package/dist/src/filter/index.js.map +1 -0
  55. package/dist/src/filter/types.d.ts +96 -0
  56. package/dist/src/filter/types.d.ts.map +1 -0
  57. package/dist/src/filter/types.js +44 -0
  58. package/dist/src/filter/types.js.map +1 -0
  59. package/dist/src/index.d.ts +5 -0
  60. package/dist/src/index.d.ts.map +1 -0
  61. package/dist/src/index.js +4 -0
  62. package/dist/src/index.js.map +1 -0
  63. package/dist/src/rule/builder.d.ts +91 -0
  64. package/dist/src/rule/builder.d.ts.map +1 -0
  65. package/dist/src/rule/builder.js +138 -0
  66. package/dist/src/rule/builder.js.map +1 -0
  67. package/dist/src/rule/index.d.ts +3 -0
  68. package/dist/src/rule/index.d.ts.map +1 -0
  69. package/dist/src/rule/index.js +3 -0
  70. package/dist/src/rule/index.js.map +1 -0
  71. package/dist/src/rule/types.d.ts +132 -0
  72. package/dist/src/rule/types.d.ts.map +1 -0
  73. package/dist/src/rule/types.js +2 -0
  74. package/dist/src/rule/types.js.map +1 -0
  75. package/dist/tests/collection/auth.test.d.ts +2 -0
  76. package/dist/tests/collection/auth.test.d.ts.map +1 -0
  77. package/dist/tests/collection/auth.test.js +44 -0
  78. package/dist/tests/collection/auth.test.js.map +1 -0
  79. package/dist/tests/collection/base.test.d.ts +2 -0
  80. package/dist/tests/collection/base.test.d.ts.map +1 -0
  81. package/dist/tests/collection/base.test.js +70 -0
  82. package/dist/tests/collection/base.test.js.map +1 -0
  83. package/dist/tests/collection/bytes.test.d.ts +2 -0
  84. package/dist/tests/collection/bytes.test.d.ts.map +1 -0
  85. package/dist/tests/collection/bytes.test.js +9 -0
  86. package/dist/tests/collection/bytes.test.js.map +1 -0
  87. package/dist/tests/collection/field.test.d.ts +2 -0
  88. package/dist/tests/collection/field.test.d.ts.map +1 -0
  89. package/dist/tests/collection/field.test.js +165 -0
  90. package/dist/tests/collection/field.test.js.map +1 -0
  91. package/dist/tests/collection/index-type.test.d.ts +2 -0
  92. package/dist/tests/collection/index-type.test.d.ts.map +1 -0
  93. package/dist/tests/collection/index-type.test.js +28 -0
  94. package/dist/tests/collection/index-type.test.js.map +1 -0
  95. package/dist/tests/collection/serialize.test.d.ts +2 -0
  96. package/dist/tests/collection/serialize.test.d.ts.map +1 -0
  97. package/dist/tests/collection/serialize.test.js +193 -0
  98. package/dist/tests/collection/serialize.test.js.map +1 -0
  99. package/dist/tests/collection/view.test.d.ts +2 -0
  100. package/dist/tests/collection/view.test.d.ts.map +1 -0
  101. package/dist/tests/collection/view.test.js +66 -0
  102. package/dist/tests/collection/view.test.js.map +1 -0
  103. package/dist/tests/filter/compiler.test.d.ts +2 -0
  104. package/dist/tests/filter/compiler.test.d.ts.map +1 -0
  105. package/dist/tests/filter/compiler.test.js +156 -0
  106. package/dist/tests/filter/compiler.test.js.map +1 -0
  107. package/dist/tests/rule/builder.test.d.ts +2 -0
  108. package/dist/tests/rule/builder.test.d.ts.map +1 -0
  109. package/dist/tests/rule/builder.test.js +342 -0
  110. package/dist/tests/rule/builder.test.js.map +1 -0
  111. package/dist/tsconfig.tsbuildinfo +1 -0
  112. package/package.json +36 -0
@@ -0,0 +1,334 @@
1
+ import type { AnyCollectionDef, EmailConstraintKind, FieldDef, IntegerConstraintKind, LiteralTextConstraintKind, NumberConstraintKind, SimpleConstraintKind, TextConstraintKind } from "./types.js";
2
+ /** Common options shared by all field types. */
3
+ type BaseFieldOptions = {
4
+ /** Alternative field name in the database (defaults to the key in the fields map). */
5
+ name?: string;
6
+ /** Whether the field is required (defaults to `true` if no default is set). */
7
+ required?: boolean;
8
+ /** Creates a unique index on this field. */
9
+ unique?: boolean;
10
+ /** Creates a non-unique index on this field. */
11
+ indexed?: boolean;
12
+ /** Default value for the field when creating a record. */
13
+ default?: unknown;
14
+ };
15
+ /**
16
+ * Field builder API.
17
+ * Every method returns a typed `FieldDef` with `.view()` for use in `ViewCollection`.
18
+ *
19
+ * @example
20
+ * const Posts = BaseCollection.define("posts", {
21
+ * title: Field.text({ maxLength: 200 }),
22
+ * body: Field.text({ required: false }),
23
+ * published: Field.boolean({ default: false }),
24
+ * author: Field.relation(Users)
25
+ * })
26
+ */
27
+ export declare const Field: {
28
+ /**
29
+ * A UTF-8 text/string field with optional min/max length constraints.
30
+ * Stored as `TEXT` in SQLite.
31
+ *
32
+ * @param opts.required - Whether the field is required (default: true, unless `default` is set)
33
+ * @param opts.default - Default value for new records
34
+ * @param opts.unique - Create a unique index on this field
35
+ * @param opts.indexed - Create a non-unique index on this field
36
+ * @param opts.name - Alternative column name in the database
37
+ * @param opts.minLength - Minimum string length (validated on create and update)
38
+ * @param opts.maxLength - Maximum string length (validated on create and update)
39
+ * @param opts.error - Callback for custom validation error messages, keyed by constraint kind
40
+ * @returns A text-type FieldDef with `.view()` method
41
+ *
42
+ * @example
43
+ * Field.text({ maxLength: 500, required: true })
44
+ * Field.text({ minLength: 3, maxLength: 100, default: "untitled" })
45
+ */
46
+ text: <O extends BaseFieldOptions & {
47
+ minLength?: number;
48
+ maxLength?: number;
49
+ }>(opts?: O & {
50
+ error?: (kind: TextConstraintKind) => string | undefined;
51
+ }) => FieldDef & {
52
+ kind: "text";
53
+ } & O & {
54
+ error?: (kind: TextConstraintKind) => string | undefined;
55
+ } & {
56
+ view(): FieldDef & {
57
+ kind: "text";
58
+ } & O & {
59
+ error?: (kind: TextConstraintKind) => string | undefined;
60
+ } & {
61
+ viewOnly: true;
62
+ };
63
+ };
64
+ /**
65
+ * A text field restricted to a fixed set of literal string values.
66
+ * Stored as `TEXT` in SQLite. The server rejects values not in the
67
+ * `literal` array on create and update operations.
68
+ *
69
+ * The TypeScript type narrows to the literal union for type-safe
70
+ * filter expressions and client SDK usage.
71
+ *
72
+ * @param opts.literal - Required: the allowed string values (automatically narrowed via `const` type parameter)
73
+ * @param opts.error - Callback for custom validation error messages
74
+ *
75
+ * @example
76
+ * Field.literalText({ literal: ["admin", "agent", "readonly"] })
77
+ * Field.literalText({ literal: ["draft", "published"], default: "draft" })
78
+ */
79
+ literalText: <const L extends readonly string[], O extends Omit<BaseFieldOptions, "default"> & {
80
+ default?: L[number];
81
+ }>(opts: {
82
+ literal: L;
83
+ } & O & {
84
+ error?: (kind: LiteralTextConstraintKind) => string | undefined;
85
+ }) => FieldDef & {
86
+ kind: "literalText";
87
+ literal: L;
88
+ _literal: L;
89
+ } & O & {
90
+ view(): FieldDef & {
91
+ kind: "literalText";
92
+ literal: L;
93
+ _literal: L;
94
+ } & O & {
95
+ viewOnly: true;
96
+ };
97
+ };
98
+ /**
99
+ * A floating-point number field with optional min/max constraints.
100
+ * Stored as `REAL` in SQLite.
101
+ *
102
+ * @param opts.min - Minimum allowed value (inclusive)
103
+ * @param opts.max - Maximum allowed value (inclusive)
104
+ *
105
+ * @example
106
+ * Field.number({ min: 0, max: 100 })
107
+ * Field.number({ required: false })
108
+ */
109
+ number: <O extends BaseFieldOptions & {
110
+ min?: number;
111
+ max?: number;
112
+ }>(opts?: O & {
113
+ error?: (kind: NumberConstraintKind) => string | undefined;
114
+ }) => FieldDef & {
115
+ kind: "number";
116
+ } & O & {
117
+ error?: (kind: NumberConstraintKind) => string | undefined;
118
+ } & {
119
+ view(): FieldDef & {
120
+ kind: "number";
121
+ } & O & {
122
+ error?: (kind: NumberConstraintKind) => string | undefined;
123
+ } & {
124
+ viewOnly: true;
125
+ };
126
+ };
127
+ /**
128
+ * An integer field with optional min/max constraints.
129
+ * Stored as `INTEGER` in SQLite. Values are validated to be whole numbers.
130
+ *
131
+ * @param opts.min - Minimum allowed value (inclusive)
132
+ * @param opts.max - Maximum allowed value (inclusive)
133
+ *
134
+ * @example
135
+ * Field.integer({ min: 1, max: 5 })
136
+ */
137
+ integer: <O extends BaseFieldOptions & {
138
+ min?: number;
139
+ max?: number;
140
+ }>(opts?: O & {
141
+ error?: (kind: IntegerConstraintKind) => string | undefined;
142
+ }) => FieldDef & {
143
+ kind: "integer";
144
+ } & O & {
145
+ error?: (kind: IntegerConstraintKind) => string | undefined;
146
+ } & {
147
+ view(): FieldDef & {
148
+ kind: "integer";
149
+ } & O & {
150
+ error?: (kind: IntegerConstraintKind) => string | undefined;
151
+ } & {
152
+ viewOnly: true;
153
+ };
154
+ };
155
+ /**
156
+ * A boolean (true/false) field.
157
+ * Stored as `INTEGER` (0/1) in SQLite.
158
+ * Typically paired with a `default` value since new records default to false.
159
+ *
160
+ * @param opts.default - Default value (recommended to always set this)
161
+ *
162
+ * @example
163
+ * Field.boolean({ default: false })
164
+ */
165
+ boolean: <O extends Omit<BaseFieldOptions, "default"> & {
166
+ default?: boolean;
167
+ }>(opts?: O & {
168
+ error?: (kind: SimpleConstraintKind) => string | undefined;
169
+ }) => FieldDef & {
170
+ kind: "boolean";
171
+ } & O & {
172
+ error?: (kind: SimpleConstraintKind) => string | undefined;
173
+ } & {
174
+ view(): FieldDef & {
175
+ kind: "boolean";
176
+ } & O & {
177
+ error?: (kind: SimpleConstraintKind) => string | undefined;
178
+ } & {
179
+ viewOnly: true;
180
+ };
181
+ };
182
+ /**
183
+ * A date/time field stored as an ISO 8601 string.
184
+ * Stored as `TEXT` in SQLite. Values should be ISO 8601 strings.
185
+ * The server does not parse or transform date values — they are stored verbatim.
186
+ *
187
+ * @example
188
+ * Field.date({ required: true })
189
+ */
190
+ date: <O extends BaseFieldOptions>(opts?: O & {
191
+ error?: (kind: SimpleConstraintKind) => string | undefined;
192
+ }) => FieldDef & {
193
+ kind: "date";
194
+ } & O & {
195
+ error?: (kind: SimpleConstraintKind) => string | undefined;
196
+ } & {
197
+ view(): FieldDef & {
198
+ kind: "date";
199
+ } & O & {
200
+ error?: (kind: SimpleConstraintKind) => string | undefined;
201
+ } & {
202
+ viewOnly: true;
203
+ };
204
+ };
205
+ /**
206
+ * An email address field with built-in format validation.
207
+ * Stored as `TEXT` in SQLite. The server validates the email format
208
+ * on both create and update operations.
209
+ *
210
+ * @example
211
+ * Field.email({ required: false })
212
+ */
213
+ email: <O extends BaseFieldOptions>(opts?: O & {
214
+ error?: (kind: EmailConstraintKind) => string | undefined;
215
+ }) => FieldDef & {
216
+ kind: "email";
217
+ } & O & {
218
+ error?: (kind: EmailConstraintKind) => string | undefined;
219
+ } & {
220
+ view(): FieldDef & {
221
+ kind: "email";
222
+ } & O & {
223
+ error?: (kind: EmailConstraintKind) => string | undefined;
224
+ } & {
225
+ viewOnly: true;
226
+ };
227
+ };
228
+ /**
229
+ * A JSON field for storing arbitrary structured data.
230
+ * Stored as `TEXT` (JSON string) in SQLite. The server serializes/deserializes
231
+ * values automatically. Can be used for dynamic metadata, nested objects, arrays, etc.
232
+ *
233
+ * @example
234
+ * Field.json({ required: false })
235
+ */
236
+ json: <O extends BaseFieldOptions>(opts?: O & {
237
+ error?: (kind: SimpleConstraintKind) => string | undefined;
238
+ }) => FieldDef & {
239
+ kind: "json";
240
+ } & O & {
241
+ error?: (kind: SimpleConstraintKind) => string | undefined;
242
+ } & {
243
+ view(): FieldDef & {
244
+ kind: "json";
245
+ } & O & {
246
+ error?: (kind: SimpleConstraintKind) => string | undefined;
247
+ } & {
248
+ viewOnly: true;
249
+ };
250
+ };
251
+ /**
252
+ * Auto-incrementing sequence ID (system-managed, hidden from API responses).
253
+ * Stored as `INTEGER` in SQLite with `AUTOINCREMENT`.
254
+ * This field is always present on base and auth collections and does NOT expose
255
+ * `.view()` — it is always a physical column.
256
+ *
257
+ * @example
258
+ * // seqId is automatically included in base/auth collections — typically
259
+ * // only used in ViewCollection where you map a query column to seqId.
260
+ * Field.seqId()
261
+ */
262
+ seqId: (opts?: BaseFieldOptions) => FieldDef;
263
+ /**
264
+ * A file/attachment field referencing an uploaded file.
265
+ * Stored as `TEXT` (filename string) in SQLite. The actual file content is
266
+ * stored in the file storage backend (local disk or S3).
267
+ *
268
+ * When `protected: true`, the file requires a short-lived JWT token to access.
269
+ * Protected files are served via the async token endpoint.
270
+ *
271
+ * @param opts.maxSize - Maximum file size in bytes (use `Bytes.*` helpers)
272
+ * @param opts.mimeTypes - Allowed MIME types (e.g., ["image/jpeg", "image/png"])
273
+ * @param opts.protected - Whether the file requires auth token to access
274
+ *
275
+ * @example
276
+ * Field.file({ maxSize: Bytes.fromMB(5), mimeTypes: ["image/jpeg"] })
277
+ * Field.file({ protected: true, maxSize: Bytes.fromMB(10) })
278
+ *
279
+ * @see Bytes — byte size helpers for maxSize
280
+ */
281
+ file: <O extends BaseFieldOptions & {
282
+ maxSize?: number;
283
+ mimeTypes?: Array<string>;
284
+ protected?: boolean;
285
+ }>(opts?: O & {
286
+ error?: (kind: SimpleConstraintKind) => string | undefined;
287
+ }) => FieldDef & {
288
+ kind: "file";
289
+ } & O & {
290
+ error?: (kind: SimpleConstraintKind) => string | undefined;
291
+ } & {
292
+ view(): FieldDef & {
293
+ kind: "file";
294
+ } & O & {
295
+ error?: (kind: SimpleConstraintKind) => string | undefined;
296
+ } & {
297
+ viewOnly: true;
298
+ };
299
+ };
300
+ /**
301
+ * A relation field referencing another collection's record.
302
+ * Stores the target record's field value (defaults to `"id"`).
303
+ * Resolves collection names at definition time — only the name string survives
304
+ * into the serialized JSON Schema.
305
+ *
306
+ * The `_target` phantom property carries the collection definition at compile time
307
+ * for type inference in `WithExpand`.
308
+ *
309
+ * @param collection - The target collection definition (AnyCollectionDef)
310
+ * @param opts.field - The target field to reference (defaults to `"id"`)
311
+ *
312
+ * @example
313
+ * Field.relation(Users)
314
+ * Field.relation(Users, { field: "email" })
315
+ *
316
+ * @see WithExpand — uses _target to type expanded related records
317
+ */
318
+ relation: <C extends AnyCollectionDef, O extends BaseFieldOptions>(collection: C, opts?: O & {
319
+ field?: (keyof C["fields"] & string) | "id" | "created" | "updated";
320
+ error?: (kind: SimpleConstraintKind) => string | undefined;
321
+ }) => FieldDef & {
322
+ kind: "relation";
323
+ _target: C;
324
+ } & O & {
325
+ view(): FieldDef & {
326
+ kind: "relation";
327
+ _target: C;
328
+ } & O & {
329
+ viewOnly: true;
330
+ };
331
+ };
332
+ };
333
+ export {};
334
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/collection/field.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EAER,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAEnB,gDAAgD;AAChD,KAAK,gBAAgB,GAAG;IACtB,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,gDAAgD;IAChD,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAqBD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;;;;;;;;;;;;OAiBG;WACI,CAAC,SAAS,gBAAgB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,SACrE,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,CAAC,IAAI,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oBAAoB,KAAK,MAAM,GAAG,SAAS,CAAA;KAAE;;;gBAApD,CAAC,IAAI,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS;;;;;oBAAlD,CAAC,IAAI,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS;;sBAjJQ,IAAI;;;IAoJrF;;;;;;;;;;OAUG;mBACY,gBAAgB,KAAG,QAAQ;IAM1C;;;;;;;;;;;;;;;;;OAiBG;WACI,CAAC,SAAS,gBAAgB,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,SAC/F,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS,CAAA;KAAE;;;gBAApD,CAAC,IAAI,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS;;;;;oBAAlD,CAAC,IAAI,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS;;sBAxLQ,IAAI;;;IA2LrF;;;;;;;;;;;;;;;;;OAiBG;eACQ,CAAC,SAAS,gBAAgB,EAAE,CAAC,SAAS,gBAAgB,cACnD,CAAC,SACN,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,CAAC;QAAC,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,MAAM,GAAG,SAAS,CAAA;KAAE;cAWtH,UAAU;iBAAW,CAAC;;;kBAAtB,UAAU;qBAAW,CAAC;;sBAtO2B,IAAI;;;CAyOhF,CAAA"}
@@ -0,0 +1,201 @@
1
+ // Generic over D so the caller's specific field type (kind literal, required literal, etc.) is preserved.
2
+ // Object.assign is used (not spread) because TypeScript infers the intersection type precisely.
3
+ function withView(def) {
4
+ const viewOnlyPatch = { viewOnly: true };
5
+ function view() {
6
+ return Object.assign({}, def, viewOnlyPatch);
7
+ }
8
+ return Object.assign({}, def, { view });
9
+ }
10
+ // Generic field builder — K is the kind literal, O is the caller's opts (preserving required: false, etc.)
11
+ function makeField(kind, opts) {
12
+ const def = { _tag: "FieldDef", kind, ...opts };
13
+ return withView(def);
14
+ }
15
+ /**
16
+ * Field builder API.
17
+ * Every method returns a typed `FieldDef` with `.view()` for use in `ViewCollection`.
18
+ *
19
+ * @example
20
+ * const Posts = BaseCollection.define("posts", {
21
+ * title: Field.text({ maxLength: 200 }),
22
+ * body: Field.text({ required: false }),
23
+ * published: Field.boolean({ default: false }),
24
+ * author: Field.relation(Users)
25
+ * })
26
+ */
27
+ export const Field = {
28
+ /**
29
+ * A UTF-8 text/string field with optional min/max length constraints.
30
+ * Stored as `TEXT` in SQLite.
31
+ *
32
+ * @param opts.required - Whether the field is required (default: true, unless `default` is set)
33
+ * @param opts.default - Default value for new records
34
+ * @param opts.unique - Create a unique index on this field
35
+ * @param opts.indexed - Create a non-unique index on this field
36
+ * @param opts.name - Alternative column name in the database
37
+ * @param opts.minLength - Minimum string length (validated on create and update)
38
+ * @param opts.maxLength - Maximum string length (validated on create and update)
39
+ * @param opts.error - Callback for custom validation error messages, keyed by constraint kind
40
+ * @returns A text-type FieldDef with `.view()` method
41
+ *
42
+ * @example
43
+ * Field.text({ maxLength: 500, required: true })
44
+ * Field.text({ minLength: 3, maxLength: 100, default: "untitled" })
45
+ */
46
+ text: (opts) => makeField("text", opts),
47
+ /**
48
+ * A text field restricted to a fixed set of literal string values.
49
+ * Stored as `TEXT` in SQLite. The server rejects values not in the
50
+ * `literal` array on create and update operations.
51
+ *
52
+ * The TypeScript type narrows to the literal union for type-safe
53
+ * filter expressions and client SDK usage.
54
+ *
55
+ * @param opts.literal - Required: the allowed string values (automatically narrowed via `const` type parameter)
56
+ * @param opts.error - Callback for custom validation error messages
57
+ *
58
+ * @example
59
+ * Field.literalText({ literal: ["admin", "agent", "readonly"] })
60
+ * Field.literalText({ literal: ["draft", "published"], default: "draft" })
61
+ */
62
+ literalText: (opts) => {
63
+ const { literal, ...rest } = opts;
64
+ const def = {
65
+ _tag: "FieldDef",
66
+ kind: "literalText",
67
+ literal,
68
+ _literal: literal,
69
+ ...rest
70
+ };
71
+ return withView(def);
72
+ },
73
+ /**
74
+ * A floating-point number field with optional min/max constraints.
75
+ * Stored as `REAL` in SQLite.
76
+ *
77
+ * @param opts.min - Minimum allowed value (inclusive)
78
+ * @param opts.max - Maximum allowed value (inclusive)
79
+ *
80
+ * @example
81
+ * Field.number({ min: 0, max: 100 })
82
+ * Field.number({ required: false })
83
+ */
84
+ number: (opts) => makeField("number", opts),
85
+ /**
86
+ * An integer field with optional min/max constraints.
87
+ * Stored as `INTEGER` in SQLite. Values are validated to be whole numbers.
88
+ *
89
+ * @param opts.min - Minimum allowed value (inclusive)
90
+ * @param opts.max - Maximum allowed value (inclusive)
91
+ *
92
+ * @example
93
+ * Field.integer({ min: 1, max: 5 })
94
+ */
95
+ integer: (opts) => makeField("integer", opts),
96
+ /**
97
+ * A boolean (true/false) field.
98
+ * Stored as `INTEGER` (0/1) in SQLite.
99
+ * Typically paired with a `default` value since new records default to false.
100
+ *
101
+ * @param opts.default - Default value (recommended to always set this)
102
+ *
103
+ * @example
104
+ * Field.boolean({ default: false })
105
+ */
106
+ boolean: (opts) => makeField("boolean", opts),
107
+ /**
108
+ * A date/time field stored as an ISO 8601 string.
109
+ * Stored as `TEXT` in SQLite. Values should be ISO 8601 strings.
110
+ * The server does not parse or transform date values — they are stored verbatim.
111
+ *
112
+ * @example
113
+ * Field.date({ required: true })
114
+ */
115
+ date: (opts) => makeField("date", opts),
116
+ /**
117
+ * An email address field with built-in format validation.
118
+ * Stored as `TEXT` in SQLite. The server validates the email format
119
+ * on both create and update operations.
120
+ *
121
+ * @example
122
+ * Field.email({ required: false })
123
+ */
124
+ email: (opts) => makeField("email", opts),
125
+ /**
126
+ * A JSON field for storing arbitrary structured data.
127
+ * Stored as `TEXT` (JSON string) in SQLite. The server serializes/deserializes
128
+ * values automatically. Can be used for dynamic metadata, nested objects, arrays, etc.
129
+ *
130
+ * @example
131
+ * Field.json({ required: false })
132
+ */
133
+ json: (opts) => makeField("json", opts),
134
+ /**
135
+ * Auto-incrementing sequence ID (system-managed, hidden from API responses).
136
+ * Stored as `INTEGER` in SQLite with `AUTOINCREMENT`.
137
+ * This field is always present on base and auth collections and does NOT expose
138
+ * `.view()` — it is always a physical column.
139
+ *
140
+ * @example
141
+ * // seqId is automatically included in base/auth collections — typically
142
+ * // only used in ViewCollection where you map a query column to seqId.
143
+ * Field.seqId()
144
+ */
145
+ seqId: (opts) => ({
146
+ _tag: "FieldDef",
147
+ kind: "seqId",
148
+ ...opts
149
+ }),
150
+ /**
151
+ * A file/attachment field referencing an uploaded file.
152
+ * Stored as `TEXT` (filename string) in SQLite. The actual file content is
153
+ * stored in the file storage backend (local disk or S3).
154
+ *
155
+ * When `protected: true`, the file requires a short-lived JWT token to access.
156
+ * Protected files are served via the async token endpoint.
157
+ *
158
+ * @param opts.maxSize - Maximum file size in bytes (use `Bytes.*` helpers)
159
+ * @param opts.mimeTypes - Allowed MIME types (e.g., ["image/jpeg", "image/png"])
160
+ * @param opts.protected - Whether the file requires auth token to access
161
+ *
162
+ * @example
163
+ * Field.file({ maxSize: Bytes.fromMB(5), mimeTypes: ["image/jpeg"] })
164
+ * Field.file({ protected: true, maxSize: Bytes.fromMB(10) })
165
+ *
166
+ * @see Bytes — byte size helpers for maxSize
167
+ */
168
+ file: (opts) => makeField("file", opts),
169
+ /**
170
+ * A relation field referencing another collection's record.
171
+ * Stores the target record's field value (defaults to `"id"`).
172
+ * Resolves collection names at definition time — only the name string survives
173
+ * into the serialized JSON Schema.
174
+ *
175
+ * The `_target` phantom property carries the collection definition at compile time
176
+ * for type inference in `WithExpand`.
177
+ *
178
+ * @param collection - The target collection definition (AnyCollectionDef)
179
+ * @param opts.field - The target field to reference (defaults to `"id"`)
180
+ *
181
+ * @example
182
+ * Field.relation(Users)
183
+ * Field.relation(Users, { field: "email" })
184
+ *
185
+ * @see WithExpand — uses _target to type expanded related records
186
+ */
187
+ relation: (collection, opts) => {
188
+ const targetField = opts?.field ?? "id";
189
+ const { field: _field, ...fieldOpts } = (opts ?? {});
190
+ const def = {
191
+ _tag: "FieldDef",
192
+ kind: "relation",
193
+ targetCollection: collection.name,
194
+ targetField,
195
+ _target: collection,
196
+ ...fieldOpts
197
+ };
198
+ return withView(def);
199
+ }
200
+ };
201
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../../src/collection/field.ts"],"names":[],"mappings":"AA0BA,0GAA0G;AAC1G,gGAAgG;AAChG,SAAS,QAAQ,CAAqB,GAAM;IAC1C,MAAM,aAAa,GAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC5D,SAAS,IAAI;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,aAAa,CAAC,CAAA;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC;AAED,2GAA2G;AAC3G,SAAS,SAAS,CAChB,IAAO,EACP,IAAQ;IAER,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,UAAwB,EAAE,IAAI,EAAE,GAAG,IAAI,EAAgC,CAAA;IAC3F,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAA;AACtB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,EAAE,CACJ,IAAuE,EACvE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC;IAE5B;;;;;;;;;;;;;;OAcG;IACH,WAAW,EAAE,CACX,IAA8F,EAC9F,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,EACb,IAA8I,EAC9I,EAAE;QACF,MAAM,WAAW,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,CAAA;QACvC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAA2B,CAAA;QAC9E,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,UAAwB;YAC9B,IAAI,EAAE,UAAwB;YAC9B,gBAAgB,EAAE,UAAU,CAAC,IAAI;YACjC,WAAW;YACX,OAAO,EAAE,UAAU;YACnB,GAAG,SAAS;SACsC,CAAA;QACpD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAA;IACtB,CAAC;CACF,CAAA"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * A database index entry with field names and uniqueness flag.
3
+ * Created via `Index.on()` or `Index.unique()`.
4
+ */
5
+ export interface IndexEntry<K extends string> {
6
+ readonly fields: Array<K>;
7
+ readonly unique: boolean;
8
+ }
9
+ /**
10
+ * A narrowed version of the Index builder where methods only accept field
11
+ * names from `K`. Used as the argument type for the `indexes` callback.
12
+ */
13
+ export type IndexBuilder<K extends string> = {
14
+ on<F extends K>(...fields: Array<F>): IndexEntry<F>;
15
+ unique<F extends K>(...fields: Array<F>): IndexEntry<F>;
16
+ };
17
+ /**
18
+ * Index builder API.
19
+ * Pass the result to a collection config's `indexes` option.
20
+ *
21
+ * @example
22
+ * BaseCollection.define({
23
+ * name: "posts",
24
+ * fields: { slug: Field.text(), authorId: Field.text() },
25
+ * indexes: [
26
+ * Index.unique("slug"),
27
+ * Index.on("authorId", "createdAt")
28
+ * ]
29
+ * })
30
+ */
31
+ export declare const Index: {
32
+ /**
33
+ * Create a non-unique (plain) index on one or more fields.
34
+ * Composite indexes are created by passing multiple field names — order matters
35
+ * for query performance (leftmost prefix rule).
36
+ *
37
+ * @param fields - One or more field names to include in the index
38
+ * @returns An IndexEntry with `unique: false`
39
+ *
40
+ * @example
41
+ * Index.on("authorId") // single-field index
42
+ * Index.on("authorId", "createdAt") // composite index
43
+ */
44
+ on: <const K extends string>(...fields: Array<K>) => IndexEntry<K>;
45
+ /**
46
+ * Create a unique index on one or more fields.
47
+ * Enforces that the combination of field values is unique across all records.
48
+ * Composite unique indexes check uniqueness across all listed columns together.
49
+ *
50
+ * @param fields - One or more field names to include in the unique constraint
51
+ * @returns An IndexEntry with `unique: true`
52
+ *
53
+ * @example
54
+ * Index.unique("slug") // single-field unique constraint
55
+ * Index.unique("teamId", "name") // composite unique constraint
56
+ */
57
+ unique: <const K extends string>(...fields: Array<K>) => IndexEntry<K>;
58
+ };
59
+ //# sourceMappingURL=index-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-builder.d.ts","sourceRoot":"","sources":["../../../src/collection/index-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,MAAM;IAC1C,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CACzB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI;IAC3C,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;IACnD,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;CACxD,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;;;;;;;OAWG;eACQ,CAAC,SAAS,MAAM,aAAa,KAAK,CAAC,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CAAC;IAEhE;;;;;;;;;;;OAWG;mBACY,CAAC,SAAS,MAAM,aAAa,KAAK,CAAC,CAAC,CAAC,KAAG,UAAU,CAAC,CAAC,CAAC;CACrE,CAAA"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Index builder API.
3
+ * Pass the result to a collection config's `indexes` option.
4
+ *
5
+ * @example
6
+ * BaseCollection.define({
7
+ * name: "posts",
8
+ * fields: { slug: Field.text(), authorId: Field.text() },
9
+ * indexes: [
10
+ * Index.unique("slug"),
11
+ * Index.on("authorId", "createdAt")
12
+ * ]
13
+ * })
14
+ */
15
+ export const Index = {
16
+ /**
17
+ * Create a non-unique (plain) index on one or more fields.
18
+ * Composite indexes are created by passing multiple field names — order matters
19
+ * for query performance (leftmost prefix rule).
20
+ *
21
+ * @param fields - One or more field names to include in the index
22
+ * @returns An IndexEntry with `unique: false`
23
+ *
24
+ * @example
25
+ * Index.on("authorId") // single-field index
26
+ * Index.on("authorId", "createdAt") // composite index
27
+ */
28
+ on: (...fields) => ({ fields, unique: false }),
29
+ /**
30
+ * Create a unique index on one or more fields.
31
+ * Enforces that the combination of field values is unique across all records.
32
+ * Composite unique indexes check uniqueness across all listed columns together.
33
+ *
34
+ * @param fields - One or more field names to include in the unique constraint
35
+ * @returns An IndexEntry with `unique: true`
36
+ *
37
+ * @example
38
+ * Index.unique("slug") // single-field unique constraint
39
+ * Index.unique("teamId", "name") // composite unique constraint
40
+ */
41
+ unique: (...fields) => ({ fields, unique: true })
42
+ };
43
+ //# sourceMappingURL=index-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-builder.js","sourceRoot":"","sources":["../../../src/collection/index-builder.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB;;;;;;;;;;;OAWG;IACH,EAAE,EAAE,CAAyB,GAAG,MAAgB,EAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAE/F;;;;;;;;;;;OAWG;IACH,MAAM,EAAE,CAAyB,GAAG,MAAgB,EAAiB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;CACnG,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Collection definition system.
3
+ *
4
+ * Provides builders for defining collections (base, auth, view), their fields,
5
+ * indexes, and byte-size helpers. The primary entry points are:
6
+ *
7
+ * - `BaseCollection.define()` — standard CRUD collections
8
+ * - `AuthCollection.define()` — auth/user collections with system fields
9
+ * - `ViewCollection.define()` — read-only SQL view collections
10
+ * - `Field.*()` — field type builders
11
+ * - `Index.*()` — index builders
12
+ * - `Bytes.*` — human-readable byte size constants
13
+ */
14
+ export { AuthCollection } from "./auth.js";
15
+ export { BaseCollection } from "./base.js";
16
+ export { Bytes } from "./bytes.js";
17
+ export { ValidationError } from "./errors.js";
18
+ export { Field } from "./field.js";
19
+ export { Index } from "./index-builder.js";
20
+ export type { AnyCollectionDef, CollectionSchema, FieldDef, FieldsMap, LiteralTextConstraintKind } from "./types.js";
21
+ export { ViewCollection } from "./view.js";
22
+ //# sourceMappingURL=index.d.ts.map