@marianmeres/collection-types 2.3.0 → 2.4.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/AGENTS.md CHANGED
@@ -15,6 +15,7 @@ entry: "./src/mod.ts"
15
15
  ## Purpose
16
16
 
17
17
  Type definitions and schema utilities for the collection management system:
18
+
18
19
  - Core types: Model, Collection, Relation
19
20
  - Branded types: UUID, ISODateString, LtreePath
20
21
  - Domain types: Account, Product, Order, Customer, Session, etc.
@@ -23,17 +24,17 @@ Type definitions and schema utilities for the collection management system:
23
24
 
24
25
  ## Quick Reference
25
26
 
26
- | Task | File | Key Export |
27
- |------|------|------------|
28
- | Branded types | `src/utils.ts` | `UUID`, `ISODateString`, `LtreePath` |
29
- | Model types | `src/model.ts` | `Model<T>`, `ModelDTOIn`, `ModelDTOOut` |
30
- | Collection types | `src/collection.ts` | `Collection`, `CollectionDTOIn` |
31
- | Relation types | `src/relation.ts` | `Relation`, `RelationType` |
32
- | Schema types | `src/schema.ts` | `PropertyDefinition`, `JsonSchema` |
33
- | Schema builder | `src/schema-builder.ts` | `createObjectSchema<T>()` |
34
- | API types | `src/api.ts` | `ApiResponse`, `PaginatedResponse` |
35
- | Asset types | `src/asset.ts` | `AssetData`, `AssetVariant` |
36
- | Navigation types | `src/navigation.ts` | `NavItem`, `UnifiedNavigation` |
27
+ | Task | File | Key Export |
28
+ | ---------------- | ----------------------- | --------------------------------------- |
29
+ | Branded types | `src/utils.ts` | `UUID`, `ISODateString`, `LtreePath` |
30
+ | Model types | `src/model.ts` | `Model<T>`, `ModelDTOIn`, `ModelDTOOut` |
31
+ | Collection types | `src/collection.ts` | `Collection`, `CollectionDTOIn` |
32
+ | Relation types | `src/relation.ts` | `Relation`, `RelationType` |
33
+ | Schema types | `src/schema.ts` | `PropertyDefinition`, `JsonSchema` |
34
+ | Schema builder | `src/schema-builder.ts` | `createObjectSchema<T>()` |
35
+ | API types | `src/api.ts` | `ApiResponse`, `PaginatedResponse` |
36
+ | Asset types | `src/asset.ts` | `AssetData`, `AssetVariant` |
37
+ | Navigation types | `src/navigation.ts` | `NavItem`, `UnifiedNavigation` |
37
38
 
38
39
  ## File Map
39
40
 
@@ -74,32 +75,54 @@ src/
74
75
 
75
76
  ```typescript
76
77
  // Branded types
77
- export type { UUID, ISODateString, LtreePath, MaybeLocalized } from "./utils.ts";
78
- export type { JsonPrimitive, JsonObject, JsonArray, JsonValue, UserData } from "./utils.ts";
78
+ export type { ISODateString, LtreePath, MaybeLocalized, UUID } from "./utils.ts";
79
+ export type {
80
+ JsonArray,
81
+ JsonObject,
82
+ JsonPrimitive,
83
+ JsonValue,
84
+ UserData,
85
+ } from "./utils.ts";
79
86
 
80
87
  // Core entities
81
- export type { Model, ModelDTOIn, ModelDTOOut, ModelDbRow, ModelUpsertData } from "./model.ts";
82
- export type { Collection, CollectionDTOIn, CollectionDTOOut, CollectionDbRow } from "./collection.ts";
83
- export type { Relation, RelationType, RelationDTOIn, RelationTypeDTOIn } from "./relation.ts";
88
+ export type {
89
+ Model,
90
+ ModelDbRow,
91
+ ModelDTOIn,
92
+ ModelDTOOut,
93
+ ModelUpsertData,
94
+ } from "./model.ts";
95
+ export type {
96
+ Collection,
97
+ CollectionDbRow,
98
+ CollectionDTOIn,
99
+ CollectionDTOOut,
100
+ } from "./collection.ts";
101
+ export type {
102
+ Relation,
103
+ RelationDTOIn,
104
+ RelationType,
105
+ RelationTypeDTOIn,
106
+ } from "./relation.ts";
84
107
 
85
108
  // Schema
86
- export type { PropertyDefinition, JsonSchema, HtmlSpec } from "./schema.ts";
87
- export type { ObjectSchema, ExtendedSchema } from "./schema-builder.ts";
88
- export { createObjectSchema } from "./schema-builder.ts"; // Runtime function
109
+ export type { HtmlSpec, JsonSchema, PropertyDefinition } from "./schema.ts";
110
+ export type { ExtendedSchema, ObjectSchema } from "./schema-builder.ts";
111
+ export { createObjectSchema } from "./schema-builder.ts"; // Runtime function
89
112
 
90
113
  // API
91
- export type { ApiResponse, PaginatedResponse, ApiMeta } from "./api.ts";
114
+ export type { ApiMeta, ApiResponse, PaginatedResponse } from "./api.ts";
92
115
 
93
116
  // Assets
94
117
  export type { AssetData, AssetVariant } from "./asset.ts";
95
118
 
96
119
  // Domain types
97
120
  export type { AccountData, AccountSession } from "./account.ts";
98
- export type { ProductData, CategoryData } from "./product.ts";
121
+ export type { CategoryData, ProductData } from "./product.ts";
99
122
  export type { CustomerData } from "./customer.ts";
100
123
  export type { OrderData, OrderItemData } from "./order.ts";
101
124
  export type { PaymentData } from "./payment.ts";
102
- export type { SessionData, CartItem } from "./session.ts";
125
+ export type { CartItem, SessionData } from "./session.ts";
103
126
  export type { TemplateData } from "./template.ts";
104
127
  export type { EmailData } from "./email.ts";
105
128
 
@@ -115,10 +138,10 @@ export type { JoyConfig } from "./joy-config.ts";
115
138
  ### Branded Types
116
139
 
117
140
  ```typescript
118
- type UUID = string; // UUID string
119
- type ISODateString = string; // ISO 8601 date string
120
- type LtreePath = string; // PostgreSQL ltree path
121
- type MaybeLocalized<T> = T | Record<string, T>; // i18n support
141
+ type UUID = string; // UUID string
142
+ type ISODateString = string; // ISO 8601 date string
143
+ type LtreePath = string; // PostgreSQL ltree path
144
+ type MaybeLocalized<T> = T | Record<string, T>; // i18n support
122
145
  ```
123
146
 
124
147
  ### Model Layer Types
@@ -126,39 +149,45 @@ type MaybeLocalized<T> = T | Record<string, T>; // i18n support
126
149
  ```typescript
127
150
  // Input (user-provided)
128
151
  interface ModelDTOIn {
129
- type?: string;
130
- parent_id?: UUID | null;
131
- path?: LtreePath | null;
132
- folder?: string | null;
133
- tags?: string[];
134
- data?: UserData;
135
- meta?: UserData;
136
- is_unlisted?: boolean;
137
- is_deletable?: boolean;
138
- is_readonly?: boolean;
139
- is_starred?: boolean;
140
- is_enabled?: boolean;
141
- red?, orange?, yellow?, green?, blue?, purple?, gray?: boolean;
152
+ type?: string;
153
+ parent_id?: UUID | null;
154
+ path?: LtreePath | null;
155
+ folder?: string | null;
156
+ tags?: string[];
157
+ data?: UserData;
158
+ meta?: UserData;
159
+ is_unlisted?: boolean;
160
+ is_deletable?: boolean;
161
+ is_readonly?: boolean;
162
+ is_starred?: boolean;
163
+ is_enabled?: boolean;
164
+ red?;
165
+ orange?;
166
+ yellow?;
167
+ green?;
168
+ blue?;
169
+ purple?;
170
+ gray?: boolean;
142
171
  }
143
172
 
144
173
  // Output (+ server fields)
145
174
  interface ModelDTOOut extends ModelDTOIn {
146
- model_id: UUID;
147
- collection_id: UUID;
148
- type: string;
149
- depth: number;
150
- _label?: MaybeLocalized<string> | null;
151
- _hierarchy_label?: string | null;
152
- _created_at: ISODateString;
153
- _updated_at: ISODateString;
175
+ model_id: UUID;
176
+ collection_id: UUID;
177
+ type: string;
178
+ depth: number;
179
+ _label?: MaybeLocalized<string> | null;
180
+ _hierarchy_label?: string | null;
181
+ _created_at: ISODateString;
182
+ _updated_at: ISODateString;
154
183
  }
155
184
 
156
185
  // Database (+ internal fields)
157
186
  interface ModelDbRow extends ModelDTOOut {
158
- __is_rest_disabled: boolean;
159
- __searchable: Record<string, unknown>;
160
- __searchable2: string;
161
- __hierarchy_path: LtreePath | null;
187
+ __is_rest_disabled: boolean;
188
+ __searchable: Record<string, unknown>;
189
+ __searchable2: string;
190
+ __hierarchy_path: LtreePath | null;
162
191
  }
163
192
 
164
193
  // Generic typed model
@@ -169,13 +198,13 @@ type Model<TData extends UserData = UserData> = ModelDbRow & { data: TData };
169
198
 
170
199
  ```typescript
171
200
  interface ObjectSchema<T> {
172
- type: "object";
173
- required?: (keyof T)[];
174
- properties: { [K in keyof T]?: PropertyDefinition };
175
- additionalProperties?: boolean;
176
- _title?: MaybeLocalized<string>;
177
- _description?: MaybeLocalized<string>;
178
- _extra_form_fields?: Record<string, PropertyDefinition>;
201
+ type: "object";
202
+ required?: (keyof T)[];
203
+ properties: { [K in keyof T]?: PropertyDefinition };
204
+ additionalProperties?: boolean;
205
+ _title?: MaybeLocalized<string>;
206
+ _description?: MaybeLocalized<string>;
207
+ _extra_form_fields?: Record<string, PropertyDefinition>;
179
208
  }
180
209
 
181
210
  // Type-safe schema creation
@@ -183,8 +212,8 @@ function createObjectSchema<T>(schema: ObjectSchema<T>): ObjectSchema<T>;
183
212
 
184
213
  // Inheritance pattern
185
214
  type ExtendedSchema = {
186
- __extends: string;
187
- properties?: Record<string, PropertyDefinition>;
215
+ __extends: string;
216
+ properties?: Record<string, PropertyDefinition>;
188
217
  };
189
218
  ```
190
219
 
@@ -213,26 +242,26 @@ Field Prefixes:
213
242
  import { createObjectSchema, type Model } from "@marianmeres/collection-types";
214
243
 
215
244
  interface ProductData {
216
- name: string;
217
- price: number;
218
- sku: string;
245
+ name: string;
246
+ price: number;
247
+ sku: string;
219
248
  }
220
249
 
221
250
  // TypeScript validates property keys match interface
222
251
  const productSchema = createObjectSchema<ProductData>({
223
- type: "object",
224
- required: ["name", "price"],
225
- properties: {
226
- name: { type: "string", _label_source: true },
227
- price: { type: "number" },
228
- sku: { type: "string", _unique: true }
229
- }
252
+ type: "object",
253
+ required: ["name", "price"],
254
+ properties: {
255
+ name: { type: "string", _label_source: true },
256
+ price: { type: "number" },
257
+ sku: { type: "string", _unique: true },
258
+ },
230
259
  });
231
260
 
232
261
  // Typed model usage
233
262
  type Product = Model<ProductData>;
234
263
  const product: Product = await service.findOne(id);
235
- console.log(product.data.price); // TypeScript knows this is number
264
+ console.log(product.data.price); // TypeScript knows this is number
236
265
  ```
237
266
 
238
267
  ### Schema Inheritance
@@ -242,23 +271,27 @@ import type { ExtendedSchema } from "@marianmeres/collection-types";
242
271
 
243
272
  // Base schema
244
273
  const baseSchema = createObjectSchema<{ name: string }>({
245
- type: "object",
246
- properties: { name: { type: "string" } }
274
+ type: "object",
275
+ properties: { name: { type: "string" } },
247
276
  });
248
277
 
249
278
  // Extended schema
250
279
  const featuredSchema: ExtendedSchema = {
251
- __extends: "default",
252
- properties: {
253
- featured_until: { type: "string", format: "date" }
254
- }
280
+ __extends: "default",
281
+ properties: {
282
+ featured_until: { type: "string", format: "date" },
283
+ },
255
284
  };
256
285
  ```
257
286
 
258
287
  ### API Response Types
259
288
 
260
289
  ```typescript
261
- import type { ApiResponse, PaginatedResponse, Model } from "@marianmeres/collection-types";
290
+ import type {
291
+ ApiResponse,
292
+ Model,
293
+ PaginatedResponse,
294
+ } from "@marianmeres/collection-types";
262
295
 
263
296
  // Single item response
264
297
  type ProductResponse = ApiResponse<Model<ProductData>>;
@@ -279,6 +312,7 @@ deno task rpm # Release minor
279
312
  ## Dependencies
280
313
 
281
314
  This is a types-only package with minimal dependencies:
315
+
282
316
  - None (pure TypeScript types)
283
317
 
284
318
  ## Conventions
@@ -300,7 +334,7 @@ This is a types-only package with minimal dependencies:
300
334
  2. **Import style**: Use `import type` for type-only imports to ensure tree-shaking:
301
335
  ```typescript
302
336
  import type { Model, UUID } from "@marianmeres/collection-types";
303
- import { createObjectSchema } from "@marianmeres/collection-types"; // Runtime
337
+ import { createObjectSchema } from "@marianmeres/collection-types"; // Runtime
304
338
  ```
305
339
 
306
340
  3. **MaybeLocalized**: Fields that support i18n can be either a direct value or a `Record<lang, value>`:
package/README.md CHANGED
@@ -14,29 +14,26 @@ This package provides:
14
14
 
15
15
  ```typescript
16
16
  import type {
17
- Model,
18
- Collection,
19
- UUID,
20
- ProductData,
21
- CustomerData,
17
+ Collection,
18
+ CustomerData,
19
+ Model,
20
+ ProductData,
21
+ UUID,
22
22
  } from "@marianmeres/collection-types";
23
23
 
24
- import {
25
- createObjectSchema,
26
- type ExtendedSchema,
27
- } from "@marianmeres/collection-types";
24
+ import { createObjectSchema, type ExtendedSchema } from "@marianmeres/collection-types";
28
25
  ```
29
26
 
30
27
  ## Type Layers
31
28
 
32
29
  The collection system uses a layered type structure:
33
30
 
34
- | Layer | Interface | Purpose |
35
- |-------|-----------|---------|
36
- | Input | `ModelDTOIn` | User-provided fields for create/update |
37
- | Output | `ModelDTOOut` | Response with server-generated fields |
38
- | Database | `ModelDbRow` | Full row including internal fields |
39
- | Typed | `Model<T>` | Generic model with typed `data` field |
31
+ | Layer | Interface | Purpose |
32
+ | -------- | ------------- | -------------------------------------- |
33
+ | Input | `ModelDTOIn` | User-provided fields for create/update |
34
+ | Output | `ModelDTOOut` | Response with server-generated fields |
35
+ | Database | `ModelDbRow` | Full row including internal fields |
36
+ | Typed | `Model<T>` | Generic model with typed `data` field |
40
37
 
41
38
  ```typescript
42
39
  import type { Model } from "@marianmeres/collection-types";
@@ -50,34 +47,34 @@ type ProductModel = Model<ProductData>;
50
47
 
51
48
  ### Core Types
52
49
 
53
- | File | Exports |
54
- |------|---------|
55
- | `model.ts` | ModelDTOIn, ModelDTOOut, ModelDbRow, Model |
56
- | `collection.ts` | Collection, CollectionDTOIn, CollectionDTOOut |
57
- | `relation.ts` | Relation, RelationType |
58
- | `schema.ts` | PropertyDefinition, SchemaDefinition |
59
- | `utils.ts` | UUID, LtreePath, ISODateString, MaybeLocalized |
50
+ | File | Exports |
51
+ | --------------- | ---------------------------------------------- |
52
+ | `model.ts` | ModelDTOIn, ModelDTOOut, ModelDbRow, Model |
53
+ | `collection.ts` | Collection, CollectionDTOIn, CollectionDTOOut |
54
+ | `relation.ts` | Relation, RelationType |
55
+ | `schema.ts` | PropertyDefinition, SchemaDefinition |
56
+ | `utils.ts` | UUID, LtreePath, ISODateString, MaybeLocalized |
60
57
 
61
58
  ### E-commerce Types
62
59
 
63
- | File | Exports |
64
- |------|---------|
65
- | `session.ts` | SessionData, CartData, CartItem |
66
- | `customer.ts` | CustomerData, AddressData |
67
- | `order.ts` | OrderData, OrderEventData, OrderLineItem, OrderTotals |
68
- | `payment.ts` | PaymentData, PaymentIntent, PaymentResult |
60
+ | File | Exports |
61
+ | ------------- | ----------------------------------------------------- |
62
+ | `session.ts` | SessionData, CartData, CartItem |
63
+ | `customer.ts` | CustomerData, AddressData |
64
+ | `order.ts` | OrderData, OrderEventData, OrderLineItem, OrderTotals |
65
+ | `payment.ts` | PaymentData, PaymentIntent, PaymentResult |
69
66
 
70
67
  ### Stack Domain Types
71
68
 
72
- | File | Exports |
73
- |------|---------|
74
- | `account.ts` | AccountData, PasswordData, TokenData |
75
- | `product.ts` | ProductData, CategoryData |
76
- | `project.ts` | ConfigData, ConfigDataDefault, ConfigDataRbac |
77
- | `template.ts` | TemplateData |
78
- | `email.ts` | EmailData, EmailStatus |
79
- | `asset.ts` | AssetData, AssetVariant, ModelAsset |
80
- | `example.ts` | ExampleData, ExampleDataDefault, CommentData |
69
+ | File | Exports |
70
+ | ------------- | --------------------------------------------- |
71
+ | `account.ts` | AccountData, PasswordData, TokenData |
72
+ | `product.ts` | ProductData, CategoryData |
73
+ | `project.ts` | ConfigData, ConfigDataDefault, ConfigDataRbac |
74
+ | `template.ts` | TemplateData |
75
+ | `email.ts` | EmailData, EmailStatus |
76
+ | `asset.ts` | AssetData, AssetVariant, ModelAsset |
77
+ | `example.ts` | ExampleData, ExampleDataDefault, CommentData |
81
78
 
82
79
  ## Type-Safe Schema Definitions
83
80
 
@@ -90,28 +87,25 @@ Without type safety, typos in schema property names are not caught:
90
87
  ```typescript
91
88
  // BAD: TypeScript does NOT catch the typo "namex"
92
89
  const schema = {
93
- type: "object",
94
- properties: {
95
- namex: { type: "string" }, // Typo! Should be "name"
96
- },
90
+ type: "object",
91
+ properties: {
92
+ namex: { type: "string" }, // Typo! Should be "name"
93
+ },
97
94
  };
98
95
  ```
99
96
 
100
97
  ### The Solution
101
98
 
102
99
  ```typescript
103
- import {
104
- createObjectSchema,
105
- type ProductData,
106
- } from "@marianmeres/collection-types";
100
+ import { createObjectSchema, type ProductData } from "@marianmeres/collection-types";
107
101
 
108
102
  // GOOD: TypeScript catches typos!
109
103
  const schema = createObjectSchema<ProductData>({
110
- type: "object",
111
- required: ["name"],
112
- properties: {
113
- namex: { type: "string" }, // TS Error: 'namex' does not exist
114
- },
104
+ type: "object",
105
+ required: ["name"],
106
+ properties: {
107
+ namex: { type: "string" }, // TS Error: 'namex' does not exist
108
+ },
115
109
  });
116
110
  ```
117
111
 
@@ -125,17 +119,17 @@ Data interfaces must include:
125
119
 
126
120
  ```typescript
127
121
  export interface ProductData {
128
- // Data fields
129
- name: string;
130
- price?: number;
131
- sku?: string;
122
+ // Data fields
123
+ name: string;
124
+ price?: number;
125
+ sku?: string;
132
126
 
133
- // UI-only fields (never stored in data)
134
- category?: never;
135
- images?: never;
127
+ // UI-only fields (never stored in data)
128
+ category?: never;
129
+ images?: never;
136
130
 
137
- // Index signature for Model<T> compatibility
138
- [key: string]: unknown;
131
+ // Index signature for Model<T> compatibility
132
+ [key: string]: unknown;
139
133
  }
140
134
  ```
141
135
 
@@ -147,21 +141,21 @@ For schemas using `__extends`, use `ExtendedSchema`:
147
141
  import { type ExtendedSchema } from "@marianmeres/collection-types";
148
142
 
149
143
  const schemas = {
150
- default: createObjectSchema<ProductData>({
151
- type: "object",
152
- required: ["name"],
153
- properties: {
154
- name: { type: "string" },
155
- price: { type: "integer" },
156
- },
157
- }),
158
-
159
- premium: {
160
- __extends: "default",
161
- properties: {
162
- warranty_years: { type: "integer" },
163
- },
164
- } as ExtendedSchema,
144
+ default: createObjectSchema<ProductData>({
145
+ type: "object",
146
+ required: ["name"],
147
+ properties: {
148
+ name: { type: "string" },
149
+ price: { type: "integer" },
150
+ },
151
+ }),
152
+
153
+ premium: {
154
+ __extends: "default",
155
+ properties: {
156
+ warranty_years: { type: "integer" },
157
+ },
158
+ } as ExtendedSchema,
165
159
  };
166
160
  ```
167
161
 
package/dist/asset.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Asset types for the collection system.
3
3
  * Assets are file attachments associated with models.
4
4
  */
5
- import type { UUID, ISODateString } from "./utils.js";
5
+ import type { ISODateString, UUID } from "./utils.js";
6
6
  /**
7
7
  * Variant of an asset (e.g., thumbnail, preview).
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Collection types for the collection system.
3
3
  * Collections are containers for models with schema definitions.
4
4
  */
5
- import type { UUID, ISODateString, LtreePath, UserData } from "./utils.js";
5
+ import type { ISODateString, LtreePath, UserData, UUID } from "./utils.js";
6
6
  import type { PropertyDefinition } from "./schema.js";
7
7
  /**
8
8
  * Defines how ownership (`owner_id`) behaves for a collection.
package/dist/model.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Model types for the collection system.
3
3
  * Defines the structure of model records at different layers (input, output, database).
4
4
  */
5
- import type { UUID, ISODateString, LtreePath, UserData, MaybeLocalized } from "./utils.js";
5
+ import type { ISODateString, LtreePath, MaybeLocalized, UserData, UUID } from "./utils.js";
6
6
  /**
7
7
  * Input DTO for creating/updating a model.
8
8
  * Contains user-provided fields for model creation.
@@ -2,7 +2,7 @@
2
2
  * Relation types for the collection system.
3
3
  * Relations link models across collections with typed relationships.
4
4
  */
5
- import type { UUID, ISODateString, UserData } from "./utils.js";
5
+ import type { ISODateString, UserData, UUID } from "./utils.js";
6
6
  /**
7
7
  * Input DTO for creating/updating a relation type.
8
8
  * A RelationType defines a typed relationship between models from different collections.
package/dist/schema.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { MaybeLocalized } from "./utils.js";
6
6
  /** HTML field type for UI rendering */
7
- export type SchemaHtmlType = "text" | "textarea" | "wysiwyg" | "markdown" | "number" | "money" | "boolean" | "checkbox" | "parent" | "object" | "select" | "status" | "multiselect" | "date" | "datetime" | "time" | "color" | "relation" | "asset" | "json" | "code" | "keyvalues" | "password";
7
+ export type SchemaHtmlType = "text" | "textarea" | "wysiwyg" | "markdown" | "number" | "money" | "boolean" | "checkbox" | "parent" | "object" | "select" | "status" | "multiselect" | "date" | "datetime" | "time" | "color" | "relation" | "asset" | "json" | "code" | "keyvalues" | "password" | "user";
8
8
  /** Configuration for relation-type fields in schema */
9
9
  export interface RelationTypeConfig {
10
10
  relation_type: string;
@@ -15,163 +15,163 @@ Relation: RelationDTOIn → RelationDTOOut → RelationDbRow (= Relation)
15
15
 
16
16
  ## utils.ts — Branded Types & Helpers
17
17
 
18
- | Type | Description |
19
- |------|-------------|
20
- | `UUID` | String type for UUIDs |
21
- | `ISODateString` | String type for ISO 8601 dates |
22
- | `LtreePath` | String type for PostgreSQL ltree paths |
18
+ | Type | Description |
19
+ | ------------------- | --------------------------------------------- |
20
+ | `UUID` | String type for UUIDs |
21
+ | `ISODateString` | String type for ISO 8601 dates |
22
+ | `LtreePath` | String type for PostgreSQL ltree paths |
23
23
  | `MaybeLocalized<T>` | `T \| Record<string, T>` for localized values |
24
- | `JsonPrimitive` | `string \| number \| boolean \| null` |
25
- | `JsonObject` | `{ [key: string]: JsonValue }` |
26
- | `JsonArray` | `JsonValue[]` |
27
- | `JsonValue` | `JsonPrimitive \| JsonObject \| JsonArray` |
28
- | `UserData` | `Record<string, unknown>` for flexible data |
29
- | `Brand<T, B>` | Helper for creating branded types |
24
+ | `JsonPrimitive` | `string \| number \| boolean \| null` |
25
+ | `JsonObject` | `{ [key: string]: JsonValue }` |
26
+ | `JsonArray` | `JsonValue[]` |
27
+ | `JsonValue` | `JsonPrimitive \| JsonObject \| JsonArray` |
28
+ | `UserData` | `Record<string, unknown>` for flexible data |
29
+ | `Brand<T, B>` | Helper for creating branded types |
30
30
 
31
31
  ## model.ts — Model Entity Types
32
32
 
33
- | Type | Description |
34
- |------|-------------|
35
- | `ModelDTOIn` | Input DTO (type, parent_id, path, folder, tags, data, meta, flags) |
36
- | `ModelDTOOut` | + model_id, collection_id, depth, _label, _created_at, _updated_at |
37
- | `ModelDbRow` | + __is_rest_disabled, __searchable, __searchable2, __hierarchy_path |
38
- | `ModelUpsertData` | + __relations__ for relation upserts |
39
- | `Model<TData>` | Generic type with typed data field |
33
+ | Type | Description |
34
+ | ----------------- | ------------------------------------------------------------------- |
35
+ | `ModelDTOIn` | Input DTO (type, parent_id, path, folder, tags, data, meta, flags) |
36
+ | `ModelDTOOut` | + model_id, collection_id, depth, _label, _created_at, _updated_at |
37
+ | `ModelDbRow` | + __is_rest_disabled, __searchable, __searchable2, __hierarchy_path |
38
+ | `ModelUpsertData` | + **relations** for relation upserts |
39
+ | `Model<TData>` | Generic type with typed data field |
40
40
 
41
41
  ## collection.ts — Collection Container Types
42
42
 
43
- | Type | Description |
44
- |------|-------------|
45
- | `FolderDefinition` | Folder config (label, description, color) |
46
- | `TagDefinition` | Tag config (label, color) |
47
- | `CollectionDTOIn` | Input DTO (path, cardinality, types, schemas, defaults, folders, tags) |
48
- | `CollectionDTOOut` | + collection_id, project_id, _created_at, _updated_at |
49
- | `CollectionDbRow` | + __is_rest_disabled |
50
- | `Collection` | Alias for CollectionDbRow |
43
+ | Type | Description |
44
+ | ------------------ | ---------------------------------------------------------------------- |
45
+ | `FolderDefinition` | Folder config (label, description, color) |
46
+ | `TagDefinition` | Tag config (label, color) |
47
+ | `CollectionDTOIn` | Input DTO (path, cardinality, types, schemas, defaults, folders, tags) |
48
+ | `CollectionDTOOut` | + collection_id, project_id, _created_at, _updated_at |
49
+ | `CollectionDbRow` | + __is_rest_disabled |
50
+ | `Collection` | Alias for CollectionDbRow |
51
51
 
52
52
  ## relation.ts — Relationship Types
53
53
 
54
- | Type | Description |
55
- |------|-------------|
56
- | `RelationTypeDTOIn` | Input DTO (relation_type, model_collection_id, related_collection_id) |
57
- | `RelationTypeDTOOut` | + _relation_type_id, cardinality fields, timestamps |
58
- | `RelationTypeDbRow` | + __is_rest_disabled |
59
- | `RelationType` | Alias for RelationTypeDbRow |
60
- | `RelationDTOIn` | Input DTO (related_id, weak_related_id, sort_order, flags, meta) |
61
- | `RelationDTOOut` | + relation_id, _relation_type_id, model_id, timestamps |
62
- | `RelationDbRow` | Equals RelationDTOOut |
63
- | `Relation` | Alias for RelationDbRow |
54
+ | Type | Description |
55
+ | -------------------- | --------------------------------------------------------------------- |
56
+ | `RelationTypeDTOIn` | Input DTO (relation_type, model_collection_id, related_collection_id) |
57
+ | `RelationTypeDTOOut` | + _relation_type_id, cardinality fields, timestamps |
58
+ | `RelationTypeDbRow` | + __is_rest_disabled |
59
+ | `RelationType` | Alias for RelationTypeDbRow |
60
+ | `RelationDTOIn` | Input DTO (related_id, weak_related_id, sort_order, flags, meta) |
61
+ | `RelationDTOOut` | + relation_id, _relation_type_id, model_id, timestamps |
62
+ | `RelationDbRow` | Equals RelationDTOOut |
63
+ | `Relation` | Alias for RelationDbRow |
64
64
 
65
65
  ## schema.ts — JSON Schema Extensions
66
66
 
67
- | Type | Description |
68
- |------|-------------|
69
- | `SchemaHtmlType` | Union: text, textarea, wysiwyg, number, boolean, select, multiselect, date, datetime, time, color, relation, asset, json, code |
70
- | `RelationTypeConfig` | Config for relation fields (relation_type, domain, entity, cardinality) |
71
- | `AssetTypeConfig` | Config for asset fields (accept, maxSize, variants) |
72
- | `SelectConfig` | Config for select fields (options array) |
73
- | `SchemaHtmlConfig` | HTML field config (type, _type_config, rows, placeholder, help, readonly, hidden) |
74
- | `CustomSchemaKeywords` | Custom keywords (_default, _html, _title, _description, _label_source, _unique, _searchable, _order) |
75
- | `PropertyDefinition` | JSON Schema + custom keywords |
76
- | `ModelDefinition` | Model type schema (properties, required) |
67
+ | Type | Description |
68
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
69
+ | `SchemaHtmlType` | Union: text, textarea, wysiwyg, number, boolean, select, multiselect, date, datetime, time, color, relation, asset, json, code |
70
+ | `RelationTypeConfig` | Config for relation fields (relation_type, domain, entity, cardinality) |
71
+ | `AssetTypeConfig` | Config for asset fields (accept, maxSize, variants) |
72
+ | `SelectConfig` | Config for select fields (options array) |
73
+ | `SchemaHtmlConfig` | HTML field config (type, _type_config, rows, placeholder, help, readonly, hidden) |
74
+ | `CustomSchemaKeywords` | Custom keywords (_default, _html, _title, _description, _label_source, _unique, _searchable, _order) |
75
+ | `PropertyDefinition` | JSON Schema + custom keywords |
76
+ | `ModelDefinition` | Model type schema (properties, required) |
77
77
 
78
78
  ## api.ts — API & Query Types
79
79
 
80
- | Type | Description |
81
- |------|-------------|
82
- | `PaginationMeta` | Pagination info (limit, offset, total, hasMore) |
83
- | `ApiResponse<T>` | Generic response wrapper (data, meta) |
84
- | `ApiListResponse<T>` | List response with pagination and included relations |
85
- | `QueryOperator` | Filter operators: eq, neq, gt, gte, lt, lte, like, nlike, match, nmatch, is, nis, in, nin, ltree, ancestor, descendant |
86
- | `QueryCondition` | Single filter condition (field, operator, value) |
87
- | `QuerySyntax` | Query params (where, search, order, asc, limit, offset) |
80
+ | Type | Description |
81
+ | -------------------- | ---------------------------------------------------------------------------------------------------------------------- |
82
+ | `PaginationMeta` | Pagination info (limit, offset, total, hasMore) |
83
+ | `ApiResponse<T>` | Generic response wrapper (data, meta) |
84
+ | `ApiListResponse<T>` | List response with pagination and included relations |
85
+ | `QueryOperator` | Filter operators: eq, neq, gt, gte, lt, lte, like, nlike, match, nmatch, is, nis, in, nin, ltree, ancestor, descendant |
86
+ | `QueryCondition` | Single filter condition (field, operator, value) |
87
+ | `QuerySyntax` | Query params (where, search, order, asc, limit, offset) |
88
88
 
89
89
  ## asset.ts — File Attachment Types
90
90
 
91
- | Type | Description |
92
- |------|-------------|
93
- | `AssetVariant` | Asset variant (name, width, height, format, url) |
94
- | `AssetData` | Asset metadata (filename, mimetype, size, url, variants, metadata) |
95
- | `ModelAsset` | Asset attached to model (asset_id, model_id, field_name, sort_order, data, timestamps) |
91
+ | Type | Description |
92
+ | -------------- | -------------------------------------------------------------------------------------- |
93
+ | `AssetVariant` | Asset variant (name, width, height, format, url) |
94
+ | `AssetData` | Asset metadata (filename, mimetype, size, url, variants, metadata) |
95
+ | `ModelAsset` | Asset attached to model (asset_id, model_id, field_name, sort_order, data, timestamps) |
96
96
 
97
97
  ## adapter.ts — Database Adapter Types
98
98
 
99
- | Type | Description |
100
- |------|-------------|
101
- | `DbQueryResult<T>` | Query result (rows, rowCount) |
102
- | `QueryProvider` | DB interface (type: "pg" \| "sqlite", query, each) |
103
- | `AdapterOptions` | Adapter config (tablePrefix, preInitSql, postInitSql, projectIdFk, resetAll) |
99
+ | Type | Description |
100
+ | ------------------ | ---------------------------------------------------------------------------- |
101
+ | `DbQueryResult<T>` | Query result (rows, rowCount) |
102
+ | `QueryProvider` | DB interface (type: "pg" \| "sqlite", query, each) |
103
+ | `AdapterOptions` | Adapter config (tablePrefix, preInitSql, postInitSql, projectIdFk, resetAll) |
104
104
 
105
105
  ## linked-assets.ts — Metadata-Based Asset Linking
106
106
 
107
- | Type | Description |
108
- |------|-------------|
109
- | `LinkedAssetOperator` | Match operators: eq, neq, lt, lte, gt, gte, like, ilike, in, nin, ?, descendant |
110
- | `LinkedAssetValueSource` | Value source: "literal" or "model_field" |
111
- | `LinkedAssetCondition` | Single matching condition (asset_field, operator, value_source, value) |
112
- | `LinkedAssetUploadConfig` | Upload config (auto_fill_custom, type, accept, cardinality) |
113
- | `LinkedAssetUnlinkConfig` | Unlink config (field, confirm) |
114
- | `LinkedAssetQueryConfig` | Query config (domain, entity, type, conditions, base_conditions) |
115
- | `LinkedAssetMatchConfig` | Match context (domain, entity, type) |
116
- | `LinkedAssetRule` | Single rule (id, label, match, asset_query, upload, unlink, enabled, order) |
117
- | `LinkedAssetsConfig` | Complete config with version and rules array |
107
+ | Type | Description |
108
+ | ------------------------- | ------------------------------------------------------------------------------- |
109
+ | `LinkedAssetOperator` | Match operators: eq, neq, lt, lte, gt, gte, like, ilike, in, nin, ?, descendant |
110
+ | `LinkedAssetValueSource` | Value source: "literal" or "model_field" |
111
+ | `LinkedAssetCondition` | Single matching condition (asset_field, operator, value_source, value) |
112
+ | `LinkedAssetUploadConfig` | Upload config (auto_fill_custom, type, accept, cardinality) |
113
+ | `LinkedAssetUnlinkConfig` | Unlink config (field, confirm) |
114
+ | `LinkedAssetQueryConfig` | Query config (domain, entity, type, conditions, base_conditions) |
115
+ | `LinkedAssetMatchConfig` | Match context (domain, entity, type) |
116
+ | `LinkedAssetRule` | Single rule (id, label, match, asset_query, upload, unlink, enabled, order) |
117
+ | `LinkedAssetsConfig` | Complete config with version and rules array |
118
118
 
119
119
  ## navigation.ts — Admin UI Navigation
120
120
 
121
- | Type | Description |
122
- |------|-------------|
123
- | `CollectionTypeEntry` | Type entry within collection (name, schemaTitle) |
124
- | `ModuleRegistryEntry` | Domain module registry (domain, mount, domainLabel, collections) |
125
- | `NavConfig` | Navigation customization (overrides, hidden, custom items) |
126
- | `NavItemDef` | Output nav item (label, href, domain, entity, type, id, folder, icon, group) |
121
+ | Type | Description |
122
+ | --------------------- | ---------------------------------------------------------------------------- |
123
+ | `CollectionTypeEntry` | Type entry within collection (name, schemaTitle) |
124
+ | `ModuleRegistryEntry` | Domain module registry (domain, mount, domainLabel, collections) |
125
+ | `NavConfig` | Navigation customization (overrides, hidden, custom items) |
126
+ | `NavItemDef` | Output nav item (label, href, domain, entity, type, id, folder, icon, group) |
127
127
 
128
128
  ## form-routes.ts — Form Route Overrides
129
129
 
130
- | Type | Description |
131
- |------|-------------|
132
- | `HttpMethod` | HTTP methods for forms: "POST", "PUT", "DELETE" |
133
- | `FormRouteMatch` | Matching context (domain, entity, type, method) with wildcard support |
134
- | `FormRouteRule` | Single override rule (id, description, match, endpoint, enabled, priority) |
135
- | `FormRoutesConfig` | Complete config with version and rules array |
136
- | `FormRouteContext` | Runtime lookup context for route resolution |
130
+ | Type | Description |
131
+ | ------------------ | -------------------------------------------------------------------------- |
132
+ | `HttpMethod` | HTTP methods for forms: "POST", "PUT", "DELETE" |
133
+ | `FormRouteMatch` | Matching context (domain, entity, type, method) with wildcard support |
134
+ | `FormRouteRule` | Single override rule (id, description, match, endpoint, enabled, priority) |
135
+ | `FormRoutesConfig` | Complete config with version and rules array |
136
+ | `FormRouteContext` | Runtime lookup context for route resolution |
137
137
 
138
138
  ## session.ts — Session & Cart Types
139
139
 
140
- | Type | Description |
141
- |------|-------------|
142
- | `CartItem` | Single cart item (product_id, quantity) |
143
- | `CartData` | Cart contents (items: CartItem[]) |
140
+ | Type | Description |
141
+ | -------------- | -------------------------------------------- |
142
+ | `CartItem` | Single cart item (product_id, quantity) |
143
+ | `CartData` | Cart contents (items: CartItem[]) |
144
144
  | `WishlistItem` | Single wishlist item (product_id, added_at?) |
145
- | `WishlistData` | Wishlist contents (items: WishlistItem[]) |
146
- | `SessionData` | Session data (cart, wishlist) |
147
- | `SessionType` | Type identifier: "session" |
145
+ | `WishlistData` | Wishlist contents (items: WishlistItem[]) |
146
+ | `SessionData` | Session data (cart, wishlist) |
147
+ | `SessionType` | Type identifier: "session" |
148
148
 
149
149
  ## payment.ts — Payment Types
150
150
 
151
- | Type | Description |
152
- |------|-------------|
153
- | `PaymentStatus` | Status: pending, completed, failed, refunded |
154
- | `PaymentData` | Payment data (provider, status, amount, currency, provider_reference) |
155
- | `PaymentType` | Type identifier: "payment" |
156
- | `PaymentInitConfig` | Payment initiation config (provider, amount, currency, return_url?) |
157
- | `PaymentIntent` | Payment initiation result (id, redirect_url, provider_data?) |
158
- | `PaymentResult` | Payment capture result (provider_reference) |
159
- | `RefundResult` | Refund result (refund_id) |
160
- | `WebhookResult` | Webhook processing result (event_type, payment_id?) |
151
+ | Type | Description |
152
+ | ------------------- | --------------------------------------------------------------------- |
153
+ | `PaymentStatus` | Status: pending, completed, failed, refunded |
154
+ | `PaymentData` | Payment data (provider, status, amount, currency, provider_reference) |
155
+ | `PaymentType` | Type identifier: "payment" |
156
+ | `PaymentInitConfig` | Payment initiation config (provider, amount, currency, return_url?) |
157
+ | `PaymentIntent` | Payment initiation result (id, redirect_url, provider_data?) |
158
+ | `PaymentResult` | Payment capture result (provider_reference) |
159
+ | `RefundResult` | Refund result (refund_id) |
160
+ | `WebhookResult` | Webhook processing result (event_type, payment_id?) |
161
161
 
162
162
  ## order.ts — Order Types
163
163
 
164
- | Type | Description |
165
- |------|-------------|
166
- | `OrderStatus` | Status: pending, paid, processing, shipped, delivered, cancelled |
167
- | `CheckoutStage` | Checkout stages: cart, addresses, delivery, confirm, payment, complete |
168
- | `OrderLineItem` | Line item snapshot (product_id, sku?, name, price, quantity) |
169
- | `OrderTotals` | Price totals (subtotal, tax, shipping, discount, total) |
170
- | `DeliveryOptionSnapshot` | Delivery option snapshot (id, name, price, estimated_time?) |
171
- | `OrderData` | Order data (status, items, currency, totals, addresses, delivery, checkout) |
172
- | `OrderEventType` | Event types: created, status_changed, payment_added, note_added, cancelled |
173
- | `OrderEventActor` | Event actor (type: customer/admin/system, id?) |
174
- | `OrderEventData` | Order event audit trail (event_type, statuses, actor, details?) |
175
- | `OrderType` | Type identifier: "order" |
176
- | `OrderEventModelType` | Event type identifier: "event" |
177
- | `OrderCreateResult` | Order creation result (model_id, data: OrderData) |
164
+ | Type | Description |
165
+ | ------------------------ | --------------------------------------------------------------------------- |
166
+ | `OrderStatus` | Status: pending, paid, processing, shipped, delivered, cancelled |
167
+ | `CheckoutStage` | Checkout stages: cart, addresses, delivery, confirm, payment, complete |
168
+ | `OrderLineItem` | Line item snapshot (product_id, sku?, name, price, quantity) |
169
+ | `OrderTotals` | Price totals (subtotal, tax, shipping, discount, total) |
170
+ | `DeliveryOptionSnapshot` | Delivery option snapshot (id, name, price, estimated_time?) |
171
+ | `OrderData` | Order data (status, items, currency, totals, addresses, delivery, checkout) |
172
+ | `OrderEventType` | Event types: created, status_changed, payment_added, note_added, cancelled |
173
+ | `OrderEventActor` | Event actor (type: customer/admin/system, id?) |
174
+ | `OrderEventData` | Order event audit trail (event_type, statuses, actor, details?) |
175
+ | `OrderType` | Type identifier: "order" |
176
+ | `OrderEventModelType` | Event type identifier: "event" |
177
+ | `OrderCreateResult` | Order creation result (model_id, data: OrderData) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/collection-types",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "main": "dist/mod.js",
6
6
  "types": "dist/mod.d.ts",