@marianmeres/collection-types 2.2.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 +113 -79
- package/README.md +68 -74
- package/dist/adapter.d.ts +1 -1
- package/dist/asset.d.ts +1 -1
- package/dist/collection.d.ts +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/navigation.d.ts +14 -1
- package/dist/order.d.ts +10 -0
- package/dist/relation.d.ts +1 -1
- package/dist/schema.d.ts +7 -1
- package/docs/type-catalog.md +119 -119
- package/package.json +1 -1
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
|
|
27
|
-
|
|
28
|
-
| Branded types
|
|
29
|
-
| Model types
|
|
30
|
-
| Collection types | `src/collection.ts`
|
|
31
|
-
| Relation types
|
|
32
|
-
| Schema types
|
|
33
|
-
| Schema builder
|
|
34
|
-
| API types
|
|
35
|
-
| Asset types
|
|
36
|
-
| Navigation types | `src/navigation.ts`
|
|
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 {
|
|
78
|
-
export type {
|
|
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 {
|
|
82
|
-
|
|
83
|
-
|
|
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 {
|
|
87
|
-
export type {
|
|
88
|
-
export { createObjectSchema } from "./schema-builder.ts";
|
|
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
|
|
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 {
|
|
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 {
|
|
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;
|
|
119
|
-
type ISODateString = string;
|
|
120
|
-
type LtreePath = string;
|
|
121
|
-
type MaybeLocalized<T> = T | Record<string, T>;
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
187
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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);
|
|
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
|
-
|
|
246
|
-
|
|
274
|
+
type: "object",
|
|
275
|
+
properties: { name: { type: "string" } },
|
|
247
276
|
});
|
|
248
277
|
|
|
249
278
|
// Extended schema
|
|
250
279
|
const featuredSchema: ExtendedSchema = {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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 {
|
|
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";
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
35
|
-
|
|
36
|
-
| Input
|
|
37
|
-
| Output
|
|
38
|
-
| Database | `ModelDbRow`
|
|
39
|
-
| Typed
|
|
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
|
|
54
|
-
|
|
55
|
-
| `model.ts`
|
|
56
|
-
| `collection.ts` | Collection, CollectionDTOIn, CollectionDTOOut
|
|
57
|
-
| `relation.ts`
|
|
58
|
-
| `schema.ts`
|
|
59
|
-
| `utils.ts`
|
|
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
|
|
64
|
-
|
|
65
|
-
| `session.ts`
|
|
66
|
-
| `customer.ts` | CustomerData, AddressData
|
|
67
|
-
| `order.ts`
|
|
68
|
-
| `payment.ts`
|
|
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
|
|
73
|
-
|
|
74
|
-
| `account.ts`
|
|
75
|
-
| `product.ts`
|
|
76
|
-
| `project.ts`
|
|
77
|
-
| `template.ts` | TemplateData
|
|
78
|
-
| `email.ts`
|
|
79
|
-
| `asset.ts`
|
|
80
|
-
| `example.ts`
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
// Data fields
|
|
123
|
+
name: string;
|
|
124
|
+
price?: number;
|
|
125
|
+
sku?: string;
|
|
132
126
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
// UI-only fields (never stored in data)
|
|
128
|
+
category?: never;
|
|
129
|
+
images?: never;
|
|
136
130
|
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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/adapter.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface DbQueryResult<T = Record<string, unknown>> {
|
|
|
18
18
|
*/
|
|
19
19
|
export interface QueryProvider {
|
|
20
20
|
/** Query provider type */
|
|
21
|
-
type: "pg"
|
|
21
|
+
type: "pg";
|
|
22
22
|
/** Execute a query and return results */
|
|
23
23
|
query(sql: string, params?: unknown[]): Promise<DbQueryResult>;
|
|
24
24
|
/** Execute a query with cursor-style row iteration */
|
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 {
|
|
5
|
+
import type { ISODateString, UUID } from "./utils.js";
|
|
6
6
|
/**
|
|
7
7
|
* Variant of an asset (e.g., thumbnail, preview).
|
|
8
8
|
*/
|
package/dist/collection.d.ts
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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.
|
package/dist/navigation.d.ts
CHANGED
|
@@ -48,6 +48,15 @@ export interface NavConfig {
|
|
|
48
48
|
label?: MaybeLocalized<string>;
|
|
49
49
|
order?: number;
|
|
50
50
|
icon?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Stable, non-localized key that buckets this domain/entity into a
|
|
53
|
+
* nav group. Defaults to the domain. Set the SAME `groupKey` (and a
|
|
54
|
+
* matching `group` label) on several entries to merge multiple
|
|
55
|
+
* domains under one group — e.g. `order` + `invoice` → "Sales".
|
|
56
|
+
* Must be a plain string (it is used as a Map key), never a
|
|
57
|
+
* localized object.
|
|
58
|
+
*/
|
|
59
|
+
groupKey?: string;
|
|
51
60
|
group?: MaybeLocalized<string>;
|
|
52
61
|
groupIcon?: string;
|
|
53
62
|
folder?: string;
|
|
@@ -94,8 +103,12 @@ export interface NavItemDef {
|
|
|
94
103
|
* Area identifiers for the admin SPA.
|
|
95
104
|
* Each area represents a distinct section of the application with its own
|
|
96
105
|
* routing pattern and navigation structure.
|
|
106
|
+
*
|
|
107
|
+
* `todo` is a bespoke direct-route area (the `me`/`extra` precedent — NOT in the
|
|
108
|
+
* client AreaRegistry); it ships as a prebuilt passthrough from
|
|
109
|
+
* `__joy_nav__.areas.todo`, gated to root only via `requiredPermissions`.
|
|
97
110
|
*/
|
|
98
|
-
export type AreaId = "cms" | "custom" | "user" | "extra" | "me";
|
|
111
|
+
export type AreaId = "cms" | "custom" | "user" | "extra" | "me" | "todo";
|
|
99
112
|
/**
|
|
100
113
|
* Base nav item structure shared across all areas.
|
|
101
114
|
* Designed to support hierarchical navigation (groups, pages, tabs).
|
package/dist/order.d.ts
CHANGED
|
@@ -53,6 +53,16 @@ export interface DeliveryOptionSnapshot {
|
|
|
53
53
|
}
|
|
54
54
|
/** Order data field schema */
|
|
55
55
|
export interface OrderData {
|
|
56
|
+
/**
|
|
57
|
+
* Public, customer-facing order identifier shown in place of the model UUID
|
|
58
|
+
* everywhere the customer is involved (checkout confirmation, emails, the
|
|
59
|
+
* printed order document, account order history). Non-sequential Crockford
|
|
60
|
+
* base32 (uppercase, length 6), generated and uniqueness-checked at creation,
|
|
61
|
+
* then FROZEN — never changed on any subsequent update. Mirrors
|
|
62
|
+
* `InvoiceData.code`. Optional so legacy/admin-created rows that predate the
|
|
63
|
+
* field still type-check; read paths fall back to `shortOrderRef(model_id)`.
|
|
64
|
+
*/
|
|
65
|
+
code?: string;
|
|
56
66
|
/** Current order status */
|
|
57
67
|
status: OrderStatus;
|
|
58
68
|
/** Line items (snapshots) */
|
package/dist/relation.d.ts
CHANGED
|
@@ -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 {
|
|
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,6 +15,12 @@ export interface RelationTypeConfig {
|
|
|
15
15
|
type?: string;
|
|
16
16
|
/** Allow unknown relations */
|
|
17
17
|
allow_unknown?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* When true (and the relation is multi-value, i.e. `cardinality !== 1`), the
|
|
20
|
+
* admin UI exposes a manual reorder control. The chosen order is persisted as
|
|
21
|
+
* the relation `sort_order`. No-op for single-cardinality relations.
|
|
22
|
+
*/
|
|
23
|
+
ordered?: boolean;
|
|
18
24
|
}
|
|
19
25
|
/** Configuration for asset-type fields in schema */
|
|
20
26
|
export interface AssetTypeConfig {
|
package/docs/type-catalog.md
CHANGED
|
@@ -15,163 +15,163 @@ Relation: RelationDTOIn → RelationDTOOut → RelationDbRow (= Relation)
|
|
|
15
15
|
|
|
16
16
|
## utils.ts — Branded Types & Helpers
|
|
17
17
|
|
|
18
|
-
| Type
|
|
19
|
-
|
|
20
|
-
| `UUID`
|
|
21
|
-
| `ISODateString`
|
|
22
|
-
| `LtreePath`
|
|
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`
|
|
25
|
-
| `JsonObject`
|
|
26
|
-
| `JsonArray`
|
|
27
|
-
| `JsonValue`
|
|
28
|
-
| `UserData`
|
|
29
|
-
| `Brand<T, B>`
|
|
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
|
|
34
|
-
|
|
35
|
-
| `ModelDTOIn`
|
|
36
|
-
| `ModelDTOOut`
|
|
37
|
-
| `ModelDbRow`
|
|
38
|
-
| `ModelUpsertData` | +
|
|
39
|
-
| `Model<TData>`
|
|
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
|
|
44
|
-
|
|
45
|
-
| `FolderDefinition` | Folder config (label, description, color)
|
|
46
|
-
| `TagDefinition`
|
|
47
|
-
| `CollectionDTOIn`
|
|
48
|
-
| `CollectionDTOOut` | + collection_id, project_id, _created_at, _updated_at
|
|
49
|
-
| `CollectionDbRow`
|
|
50
|
-
| `Collection`
|
|
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
|
|
55
|
-
|
|
56
|
-
| `RelationTypeDTOIn`
|
|
57
|
-
| `RelationTypeDTOOut` | + _relation_type_id, cardinality fields, timestamps
|
|
58
|
-
| `RelationTypeDbRow`
|
|
59
|
-
| `RelationType`
|
|
60
|
-
| `RelationDTOIn`
|
|
61
|
-
| `RelationDTOOut`
|
|
62
|
-
| `RelationDbRow`
|
|
63
|
-
| `Relation`
|
|
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
|
|
68
|
-
|
|
69
|
-
| `SchemaHtmlType`
|
|
70
|
-
| `RelationTypeConfig`
|
|
71
|
-
| `AssetTypeConfig`
|
|
72
|
-
| `SelectConfig`
|
|
73
|
-
| `SchemaHtmlConfig`
|
|
74
|
-
| `CustomSchemaKeywords` | Custom keywords (_default, _html, _title, _description, _label_source, _unique, _searchable, _order)
|
|
75
|
-
| `PropertyDefinition`
|
|
76
|
-
| `ModelDefinition`
|
|
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
|
|
81
|
-
|
|
82
|
-
| `PaginationMeta`
|
|
83
|
-
| `ApiResponse<T>`
|
|
84
|
-
| `ApiListResponse<T>` | List response with pagination and included relations
|
|
85
|
-
| `QueryOperator`
|
|
86
|
-
| `QueryCondition`
|
|
87
|
-
| `QuerySyntax`
|
|
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
|
|
92
|
-
|
|
93
|
-
| `AssetVariant` | Asset variant (name, width, height, format, url)
|
|
94
|
-
| `AssetData`
|
|
95
|
-
| `ModelAsset`
|
|
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
|
|
100
|
-
|
|
101
|
-
| `DbQueryResult<T>` | Query result (rows, rowCount)
|
|
102
|
-
| `QueryProvider`
|
|
103
|
-
| `AdapterOptions`
|
|
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
|
|
108
|
-
|
|
109
|
-
| `LinkedAssetOperator`
|
|
110
|
-
| `LinkedAssetValueSource`
|
|
111
|
-
| `LinkedAssetCondition`
|
|
112
|
-
| `LinkedAssetUploadConfig` | Upload config (auto_fill_custom, type, accept, cardinality)
|
|
113
|
-
| `LinkedAssetUnlinkConfig` | Unlink config (field, confirm)
|
|
114
|
-
| `LinkedAssetQueryConfig`
|
|
115
|
-
| `LinkedAssetMatchConfig`
|
|
116
|
-
| `LinkedAssetRule`
|
|
117
|
-
| `LinkedAssetsConfig`
|
|
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
|
|
122
|
-
|
|
123
|
-
| `CollectionTypeEntry` | Type entry within collection (name, schemaTitle)
|
|
124
|
-
| `ModuleRegistryEntry` | Domain module registry (domain, mount, domainLabel, collections)
|
|
125
|
-
| `NavConfig`
|
|
126
|
-
| `NavItemDef`
|
|
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
|
|
131
|
-
|
|
132
|
-
| `HttpMethod`
|
|
133
|
-
| `FormRouteMatch`
|
|
134
|
-
| `FormRouteRule`
|
|
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
|
|
141
|
-
|
|
142
|
-
| `CartItem`
|
|
143
|
-
| `CartData`
|
|
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`
|
|
147
|
-
| `SessionType`
|
|
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
|
|
152
|
-
|
|
153
|
-
| `PaymentStatus`
|
|
154
|
-
| `PaymentData`
|
|
155
|
-
| `PaymentType`
|
|
156
|
-
| `PaymentInitConfig` | Payment initiation config (provider, amount, currency, return_url?)
|
|
157
|
-
| `PaymentIntent`
|
|
158
|
-
| `PaymentResult`
|
|
159
|
-
| `RefundResult`
|
|
160
|
-
| `WebhookResult`
|
|
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
|
|
165
|
-
|
|
166
|
-
| `OrderStatus`
|
|
167
|
-
| `CheckoutStage`
|
|
168
|
-
| `OrderLineItem`
|
|
169
|
-
| `OrderTotals`
|
|
170
|
-
| `DeliveryOptionSnapshot` | Delivery option snapshot (id, name, price, estimated_time?)
|
|
171
|
-
| `OrderData`
|
|
172
|
-
| `OrderEventType`
|
|
173
|
-
| `OrderEventActor`
|
|
174
|
-
| `OrderEventData`
|
|
175
|
-
| `OrderType`
|
|
176
|
-
| `OrderEventModelType`
|
|
177
|
-
| `OrderCreateResult`
|
|
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) |
|