@objectstack/spec 0.1.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.
@@ -0,0 +1,430 @@
1
+ /**
2
+ * Object View Interface
3
+ *
4
+ * Defines the structure of a view in the ObjectStack metamodel.
5
+ * Views represent different UI presentations of entity data (list, form, detail, etc.).
6
+ *
7
+ * @module types/meta/object-view
8
+ */
9
+ /**
10
+ * Available view types in the ObjectStack metamodel
11
+ *
12
+ * @remarks
13
+ * Each view type corresponds to a different UI presentation pattern:
14
+ *
15
+ * - `list`: Tabular list view (grid/table)
16
+ * - `detail`: Single record detail view (read-only)
17
+ * - `form`: Single record form view (editable)
18
+ * - `card`: Card-based list view
19
+ * - `kanban`: Kanban board view
20
+ * - `calendar`: Calendar view (for date-based records)
21
+ * - `chart`: Chart/graph visualization
22
+ * - `map`: Geographic map view
23
+ * - `timeline`: Timeline view for chronological data
24
+ * - `custom`: Custom view implementation
25
+ */
26
+ export type ViewType = 'list' | 'detail' | 'form' | 'card' | 'kanban' | 'calendar' | 'chart' | 'map' | 'timeline' | 'custom';
27
+ /**
28
+ * Layout configuration for a view
29
+ *
30
+ * @remarks
31
+ * Defines how fields are organized visually in the view
32
+ */
33
+ export interface ViewLayout {
34
+ /**
35
+ * Layout type/strategy
36
+ *
37
+ * @remarks
38
+ * - `single-column`: One field per row
39
+ * - `two-column`: Two fields per row
40
+ * - `grid`: Flexible grid layout
41
+ * - `tabs`: Fields organized in tabs
42
+ * - `sections`: Fields grouped in named sections
43
+ *
44
+ * @defaultValue 'single-column'
45
+ */
46
+ type?: 'single-column' | 'two-column' | 'grid' | 'tabs' | 'sections';
47
+ /**
48
+ * Sections for organizing fields
49
+ *
50
+ * @remarks
51
+ * Only applicable when layout type is 'sections' or 'tabs'
52
+ */
53
+ sections?: Array<{
54
+ /** Section identifier */
55
+ id: string;
56
+ /** Section title */
57
+ title: string;
58
+ /** Field names to include in this section */
59
+ fields: string[];
60
+ /** Whether section is collapsed by default */
61
+ collapsed?: boolean;
62
+ }>;
63
+ }
64
+ /**
65
+ * Filter configuration for a view
66
+ *
67
+ * @remarks
68
+ * Defines how records are filtered in the view
69
+ */
70
+ export interface ViewFilter {
71
+ /**
72
+ * Field name to filter on
73
+ *
74
+ * @example 'status', 'createdAt', 'owner'
75
+ */
76
+ field: string;
77
+ /**
78
+ * Filter operator
79
+ *
80
+ * @remarks
81
+ * Available operators depend on the field type:
82
+ * - Text: equals, contains, startsWith, endsWith
83
+ * - Number: equals, gt, gte, lt, lte, between
84
+ * - Boolean: equals
85
+ * - Date: equals, before, after, between
86
+ * - Lookup: equals, in
87
+ */
88
+ operator: 'equals' | 'contains' | 'startsWith' | 'endsWith' | 'gt' | 'gte' | 'lt' | 'lte' | 'between' | 'before' | 'after' | 'in' | 'notIn';
89
+ /**
90
+ * Filter value(s)
91
+ *
92
+ * @remarks
93
+ * Type depends on operator and field type.
94
+ * For 'between' operator, should be an array of two values.
95
+ */
96
+ value: unknown;
97
+ }
98
+ /**
99
+ * Sort configuration for a view
100
+ *
101
+ * @remarks
102
+ * Defines how records are sorted in the view
103
+ */
104
+ export interface ViewSort {
105
+ /**
106
+ * Field name to sort by
107
+ *
108
+ * @example 'name', 'createdAt', 'priority'
109
+ */
110
+ field: string;
111
+ /**
112
+ * Sort direction
113
+ *
114
+ * @defaultValue 'asc'
115
+ */
116
+ direction: 'asc' | 'desc';
117
+ }
118
+ /**
119
+ * Column configuration for list views
120
+ *
121
+ * @remarks
122
+ * Defines how a field is displayed as a column in a list/table view
123
+ */
124
+ export interface ViewColumn {
125
+ /**
126
+ * Field name to display
127
+ *
128
+ * @remarks
129
+ * Must be a valid field name from the entity
130
+ */
131
+ field: string;
132
+ /**
133
+ * Column header label
134
+ *
135
+ * @remarks
136
+ * If not provided, uses the field's label
137
+ */
138
+ label?: string;
139
+ /**
140
+ * Column width
141
+ *
142
+ * @remarks
143
+ * Can be in pixels (e.g., 100) or percentage (e.g., '20%')
144
+ */
145
+ width?: number | string;
146
+ /**
147
+ * Whether the column is sortable
148
+ *
149
+ * @defaultValue true
150
+ */
151
+ sortable?: boolean;
152
+ /**
153
+ * Whether the column is visible by default
154
+ *
155
+ * @defaultValue true
156
+ */
157
+ visible?: boolean;
158
+ /**
159
+ * Text alignment in the column
160
+ *
161
+ * @defaultValue 'left'
162
+ */
163
+ align?: 'left' | 'center' | 'right';
164
+ /**
165
+ * Custom formatting function name
166
+ *
167
+ * @remarks
168
+ * Reference to a formatting function (e.g., 'currency', 'date', 'percentage')
169
+ *
170
+ * @example 'currency', 'date:MM/DD/YYYY', 'number:2' (2 decimal places)
171
+ */
172
+ format?: string;
173
+ }
174
+ /**
175
+ * Represents a view definition for an ObjectEntity
176
+ *
177
+ * @remarks
178
+ * ObjectView defines how an entity's data is presented in the UI.
179
+ * Multiple views can exist for the same entity, each tailored for
180
+ * different use cases (e.g., "All Users", "Active Users", "Admin Users").
181
+ *
182
+ * Views are used by ObjectUI to:
183
+ * - Render lists with specific columns and filters
184
+ * - Display forms with specific field layouts
185
+ * - Show detailed records with custom presentations
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * const allUsersView: ObjectView = {
190
+ * name: 'all_users',
191
+ * label: 'All Users',
192
+ * entityName: 'User',
193
+ * type: 'list',
194
+ * columns: [
195
+ * { field: 'name', width: '30%' },
196
+ * { field: 'email', width: '30%' },
197
+ * { field: 'status', width: '20%' },
198
+ * { field: 'createdAt', width: '20%', format: 'date:MM/DD/YYYY' }
199
+ * ],
200
+ * sort: [
201
+ * { field: 'name', direction: 'asc' }
202
+ * ]
203
+ * };
204
+ *
205
+ * const userFormView: ObjectView = {
206
+ * name: 'user_form',
207
+ * label: 'User Form',
208
+ * entityName: 'User',
209
+ * type: 'form',
210
+ * fields: ['name', 'email', 'role', 'status'],
211
+ * layout: {
212
+ * type: 'sections',
213
+ * sections: [
214
+ * {
215
+ * id: 'basic',
216
+ * title: 'Basic Information',
217
+ * fields: ['name', 'email']
218
+ * },
219
+ * {
220
+ * id: 'settings',
221
+ * title: 'Settings',
222
+ * fields: ['role', 'status']
223
+ * }
224
+ * ]
225
+ * }
226
+ * };
227
+ * ```
228
+ */
229
+ export interface ObjectView {
230
+ /**
231
+ * Technical name of the view
232
+ *
233
+ * @remarks
234
+ * Used in code and URLs.
235
+ * Should be in snake_case format.
236
+ * Must be unique within the entity's views.
237
+ *
238
+ * @example 'all_users', 'active_orders', 'recent_products'
239
+ */
240
+ name: string;
241
+ /**
242
+ * Human-readable label for the view
243
+ *
244
+ * @remarks
245
+ * Used in UI menus, tabs, and headers.
246
+ *
247
+ * @example 'All Users', 'Active Orders', 'Recent Products'
248
+ */
249
+ label: string;
250
+ /**
251
+ * Name of the entity this view is for
252
+ *
253
+ * @remarks
254
+ * Must be a valid entity name in the system.
255
+ *
256
+ * @example 'User', 'SalesOrder', 'Product'
257
+ */
258
+ entityName: string;
259
+ /**
260
+ * Type of view presentation
261
+ *
262
+ * @see ViewType
263
+ */
264
+ type: ViewType;
265
+ /**
266
+ * Detailed description of the view's purpose
267
+ *
268
+ * @remarks
269
+ * Used for tooltips and documentation
270
+ */
271
+ description?: string;
272
+ /**
273
+ * Field names to display in the view
274
+ *
275
+ * @remarks
276
+ * For form/detail views: determines which fields to show and in what order.
277
+ * For list views: used if columns are not specified.
278
+ * Must be valid field names from the entity.
279
+ */
280
+ fields?: string[];
281
+ /**
282
+ * Column configurations for list views
283
+ *
284
+ * @remarks
285
+ * Only applicable to 'list', 'card', 'kanban' view types.
286
+ * Defines how each field is rendered as a column.
287
+ *
288
+ * @see ViewColumn
289
+ */
290
+ columns?: ViewColumn[];
291
+ /**
292
+ * Layout configuration for the view
293
+ *
294
+ * @remarks
295
+ * Only applicable to 'form' and 'detail' view types.
296
+ *
297
+ * @see ViewLayout
298
+ */
299
+ layout?: ViewLayout;
300
+ /**
301
+ * Default filters to apply to the view
302
+ *
303
+ * @remarks
304
+ * Filters are applied when the view is loaded.
305
+ * Users can typically modify or remove these filters.
306
+ *
307
+ * @see ViewFilter
308
+ */
309
+ filters?: ViewFilter[];
310
+ /**
311
+ * Default sort order for the view
312
+ *
313
+ * @remarks
314
+ * Can specify multiple sort levels (first by field1, then by field2, etc.)
315
+ *
316
+ * @see ViewSort
317
+ */
318
+ sort?: ViewSort[];
319
+ /**
320
+ * Number of records to display per page
321
+ *
322
+ * @remarks
323
+ * Only applicable to list-based views.
324
+ *
325
+ * @defaultValue 25
326
+ */
327
+ pageSize?: number;
328
+ /**
329
+ * Icon identifier for the view
330
+ *
331
+ * @remarks
332
+ * Used in view switchers, menus, and tabs.
333
+ *
334
+ * @example 'list', 'grid', 'calendar'
335
+ */
336
+ icon?: string;
337
+ /**
338
+ * Whether this is the default view for the entity
339
+ *
340
+ * @remarks
341
+ * The default view is shown when navigating to the entity
342
+ * without specifying a view.
343
+ *
344
+ * @defaultValue false
345
+ */
346
+ default?: boolean;
347
+ /**
348
+ * Whether the view is visible in navigation menus
349
+ *
350
+ * @remarks
351
+ * Hidden views can still be accessed directly via URL
352
+ *
353
+ * @defaultValue true
354
+ */
355
+ visible?: boolean;
356
+ /**
357
+ * Permission required to access this view
358
+ *
359
+ * @remarks
360
+ * Users without this permission cannot see or access the view.
361
+ *
362
+ * @example 'user.read', 'sales.order.view.active'
363
+ */
364
+ permission?: string;
365
+ /**
366
+ * Query string for advanced filtering
367
+ *
368
+ * @remarks
369
+ * Alternative to the filters array for complex queries.
370
+ * Uses the ObjectQL query syntax.
371
+ *
372
+ * @example 'status = "active" AND createdAt > NOW() - 30d'
373
+ */
374
+ query?: string;
375
+ /**
376
+ * Field name for grouping records (kanban view)
377
+ *
378
+ * @remarks
379
+ * Only applicable to 'kanban' view type.
380
+ * The field should have predefined options (select/lookup).
381
+ *
382
+ * @example 'status', 'priority', 'assignedTo'
383
+ */
384
+ groupBy?: string;
385
+ /**
386
+ * Date field name for calendar/timeline views
387
+ *
388
+ * @remarks
389
+ * Only applicable to 'calendar' and 'timeline' view types.
390
+ * Must be a date or datetime field.
391
+ *
392
+ * @example 'dueDate', 'scheduledAt', 'eventDate'
393
+ */
394
+ dateField?: string;
395
+ /**
396
+ * Chart configuration for chart views
397
+ *
398
+ * @remarks
399
+ * Only applicable to 'chart' view type.
400
+ */
401
+ chartConfig?: {
402
+ /** Chart type (bar, line, pie, etc.) */
403
+ type: 'bar' | 'line' | 'pie' | 'donut' | 'area' | 'scatter';
404
+ /** Field for x-axis */
405
+ xAxis?: string;
406
+ /** Field for y-axis */
407
+ yAxis?: string;
408
+ /** Aggregation function (count, sum, avg, etc.) */
409
+ aggregation?: 'count' | 'sum' | 'avg' | 'min' | 'max';
410
+ };
411
+ /**
412
+ * Custom component reference for custom views
413
+ *
414
+ * @remarks
415
+ * Only applicable to 'custom' view type.
416
+ * References a registered custom component.
417
+ *
418
+ * @example 'MyCustomDashboard', 'AnalyticsView'
419
+ */
420
+ customComponent?: string;
421
+ /**
422
+ * Custom metadata for extensions and plugins
423
+ *
424
+ * @remarks
425
+ * Allows third-party code to attach arbitrary metadata to views
426
+ * without modifying the core interface
427
+ */
428
+ metadata?: Record<string, unknown>;
429
+ }
430
+ //# sourceMappingURL=object-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-view.d.ts","sourceRoot":"","sources":["../../../src/types/meta/object-view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,UAAU,GACV,OAAO,GACP,KAAK,GACL,UAAU,GACV,QAAQ,CAAC;AAEb;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,eAAe,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;IAErE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;QACf,yBAAyB;QACzB,EAAE,EAAE,MAAM,C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EAAE,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;KACvD,CAAC;IAEF;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Object View Interface
3
+ *
4
+ * Defines the structure of a view in the ObjectStack metamodel.
5
+ * Views represent different UI presentations of entity data (list, form, detail, etc.).
6
+ *
7
+ * @module types/meta/object-view
8
+ */
9
+ export {};
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@objectstack/spec",
3
+ "version": "0.1.0",
4
+ "description": "ObjectStack Protocol & Specification - Type definitions and schemas",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "clean": "rm -rf dist",
14
+ "changeset": "changeset",
15
+ "version": "changeset version",
16
+ "release": "npm run build && changeset publish"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/objectstack-ai/spec.git"
21
+ },
22
+ "keywords": [
23
+ "objectstack",
24
+ "specification",
25
+ "types",
26
+ "metamodel"
27
+ ],
28
+ "author": "ObjectStack",
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "@changesets/cli": "^2.29.8",
32
+ "typescript": "^5.9.3"
33
+ }
34
+ }