@objectstack/platform-objects 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.
Files changed (46) hide show
  1. package/LICENSE +202 -0
  2. package/dist/apps/index.d.mts +427 -0
  3. package/dist/apps/index.d.ts +427 -0
  4. package/dist/apps/index.js +520 -0
  5. package/dist/apps/index.js.map +1 -0
  6. package/dist/apps/index.mjs +510 -0
  7. package/dist/apps/index.mjs.map +1 -0
  8. package/dist/audit/index.d.mts +9507 -0
  9. package/dist/audit/index.d.ts +9507 -0
  10. package/dist/audit/index.js +492 -0
  11. package/dist/audit/index.js.map +1 -0
  12. package/dist/audit/index.mjs +487 -0
  13. package/dist/audit/index.mjs.map +1 -0
  14. package/dist/identity/index.d.mts +32482 -0
  15. package/dist/identity/index.d.ts +32482 -0
  16. package/dist/identity/index.js +1404 -0
  17. package/dist/identity/index.js.map +1 -0
  18. package/dist/identity/index.mjs +1385 -0
  19. package/dist/identity/index.mjs.map +1 -0
  20. package/dist/index.d.mts +10 -0
  21. package/dist/index.d.ts +10 -0
  22. package/dist/index.js +4209 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/index.mjs +4160 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/metadata/index.d.mts +25601 -0
  27. package/dist/metadata/index.d.ts +25601 -0
  28. package/dist/metadata/index.js +911 -0
  29. package/dist/metadata/index.js.map +1 -0
  30. package/dist/metadata/index.mjs +902 -0
  31. package/dist/metadata/index.mjs.map +1 -0
  32. package/dist/security/index.d.mts +3554 -0
  33. package/dist/security/index.d.ts +3554 -0
  34. package/dist/security/index.js +178 -0
  35. package/dist/security/index.js.map +1 -0
  36. package/dist/security/index.mjs +175 -0
  37. package/dist/security/index.mjs.map +1 -0
  38. package/dist/state-machine.zod-BFg-VE0M.d-Ek3_yo9P.d.mts +41 -0
  39. package/dist/state-machine.zod-BFg-VE0M.d-Ek3_yo9P.d.ts +41 -0
  40. package/dist/tenant/index.d.mts +16454 -0
  41. package/dist/tenant/index.d.ts +16454 -0
  42. package/dist/tenant/index.js +741 -0
  43. package/dist/tenant/index.js.map +1 -0
  44. package/dist/tenant/index.mjs +733 -0
  45. package/dist/tenant/index.mjs.map +1 -0
  46. package/package.json +84 -0
@@ -0,0 +1,902 @@
1
+ import { ObjectSchema, Field } from '@objectstack/spec/data';
2
+
3
+ // src/metadata/sys-metadata.object.ts
4
+ var SysMetadataObject = ObjectSchema.create({
5
+ name: "sys_metadata",
6
+ label: "System Metadata",
7
+ pluralLabel: "System Metadata",
8
+ icon: "settings",
9
+ isSystem: true,
10
+ description: "Stores platform and user-scope metadata records (objects, views, flows, etc.)",
11
+ fields: {
12
+ /** Primary Key (UUID) */
13
+ id: Field.text({
14
+ label: "ID",
15
+ required: true,
16
+ readonly: true
17
+ }),
18
+ /** Machine name — unique identifier used in code references */
19
+ name: Field.text({
20
+ label: "Name",
21
+ required: true,
22
+ searchable: true,
23
+ maxLength: 255
24
+ }),
25
+ /** Metadata type (e.g. "object", "view", "flow") */
26
+ type: Field.text({
27
+ label: "Metadata Type",
28
+ required: true,
29
+ searchable: true,
30
+ maxLength: 100
31
+ }),
32
+ /** Namespace / module grouping (e.g. "crm", "core") */
33
+ namespace: Field.text({
34
+ label: "Namespace",
35
+ required: false,
36
+ defaultValue: "default",
37
+ maxLength: 100
38
+ }),
39
+ /** Package that owns/delivered this metadata (legacy string identifier, kept for compat) */
40
+ package_id: Field.text({
41
+ label: "Package ID",
42
+ required: false,
43
+ maxLength: 255,
44
+ description: "Legacy package manifest ID string. Use package_version_id for new records."
45
+ }),
46
+ /**
47
+ * FK → sys_package_version (UUID). Set for metadata that belongs to a specific
48
+ * package release snapshot. NULL = platform-built-in or environment override.
49
+ */
50
+ package_version_id: Field.lookup("sys_package_version", {
51
+ label: "Package Version",
52
+ required: false,
53
+ description: "Foreign key to sys_package_version (UUID). Null = platform-built-in or env-level override."
54
+ }),
55
+ /** Who manages this record: package, platform, or user */
56
+ managed_by: Field.select(["package", "platform", "user"], {
57
+ label: "Managed By",
58
+ required: false
59
+ }),
60
+ /** Scope: system (code), platform (admin DB), user (personal DB) */
61
+ scope: Field.select(["system", "platform", "user"], {
62
+ label: "Scope",
63
+ required: true,
64
+ defaultValue: "platform"
65
+ }),
66
+ /** JSON payload — the actual metadata configuration */
67
+ metadata: Field.textarea({
68
+ label: "Metadata",
69
+ required: true,
70
+ description: "JSON-serialized metadata payload"
71
+ }),
72
+ /** Parent metadata name for extension/override */
73
+ extends: Field.text({
74
+ label: "Extends",
75
+ required: false,
76
+ maxLength: 255
77
+ }),
78
+ /** Merge strategy when extending parent metadata */
79
+ strategy: Field.select(["merge", "replace"], {
80
+ label: "Strategy",
81
+ required: false,
82
+ defaultValue: "merge"
83
+ }),
84
+ /** Owner user ID (for user-scope items) */
85
+ owner: Field.text({
86
+ label: "Owner",
87
+ required: false,
88
+ maxLength: 255
89
+ }),
90
+ /** Lifecycle state */
91
+ state: Field.select(["draft", "active", "archived", "deprecated"], {
92
+ label: "State",
93
+ required: false,
94
+ defaultValue: "active"
95
+ }),
96
+ /** Organization ID for multi-tenant isolation */
97
+ organization_id: Field.lookup("sys_organization", {
98
+ label: "Organization",
99
+ required: false,
100
+ description: "Organization for multi-tenant isolation."
101
+ }),
102
+ /** Project ID — null = platform-global, set = project-scoped */
103
+ project_id: Field.lookup("sys_project", {
104
+ label: "Project",
105
+ required: false,
106
+ description: "Foreign key to sys_project (UUID). Null = platform-global."
107
+ }),
108
+ /** Version number for optimistic concurrency */
109
+ version: Field.number({
110
+ label: "Version",
111
+ required: false,
112
+ defaultValue: 1
113
+ }),
114
+ /** Content checksum for change detection */
115
+ checksum: Field.text({
116
+ label: "Checksum",
117
+ required: false,
118
+ maxLength: 64
119
+ }),
120
+ /** Origin of this metadata record */
121
+ source: Field.select(["filesystem", "database", "api", "migration"], {
122
+ label: "Source",
123
+ required: false
124
+ }),
125
+ /** Classification tags (JSON array) */
126
+ tags: Field.textarea({
127
+ label: "Tags",
128
+ required: false,
129
+ description: "JSON-serialized array of classification tags"
130
+ }),
131
+ /** Audit fields */
132
+ created_by: Field.lookup("sys_user", {
133
+ label: "Created By",
134
+ required: false,
135
+ readonly: true
136
+ }),
137
+ created_at: Field.datetime({
138
+ label: "Created At",
139
+ required: false,
140
+ readonly: true
141
+ }),
142
+ updated_by: Field.lookup("sys_user", {
143
+ label: "Updated By",
144
+ required: false
145
+ }),
146
+ updated_at: Field.datetime({
147
+ label: "Updated At",
148
+ required: false
149
+ })
150
+ },
151
+ indexes: [
152
+ { fields: ["type", "name", "project_id"], unique: true },
153
+ { fields: ["type", "scope"] },
154
+ { fields: ["organization_id"] },
155
+ { fields: ["project_id"] },
156
+ { fields: ["package_version_id"] },
157
+ { fields: ["state"] },
158
+ { fields: ["namespace"] }
159
+ ],
160
+ enable: {
161
+ trackHistory: true,
162
+ searchable: false,
163
+ apiEnabled: true,
164
+ apiMethods: ["get", "list", "create", "update", "delete"],
165
+ trash: false
166
+ }
167
+ });
168
+ var SysMetadataHistoryObject = ObjectSchema.create({
169
+ name: "sys_metadata_history",
170
+ label: "Metadata History",
171
+ pluralLabel: "Metadata History",
172
+ icon: "history",
173
+ isSystem: true,
174
+ description: "Version history and audit trail for metadata changes",
175
+ fields: {
176
+ /** Primary Key (UUID) */
177
+ id: Field.text({
178
+ label: "ID",
179
+ required: true,
180
+ readonly: true
181
+ }),
182
+ /** Foreign key to sys_metadata.id */
183
+ metadata_id: Field.lookup("sys_metadata", {
184
+ label: "Metadata",
185
+ required: true,
186
+ readonly: true
187
+ }),
188
+ /** Machine name (denormalized for easier querying) */
189
+ name: Field.text({
190
+ label: "Name",
191
+ required: true,
192
+ searchable: true,
193
+ readonly: true,
194
+ maxLength: 255
195
+ }),
196
+ /** Metadata type (denormalized for easier querying) */
197
+ type: Field.text({
198
+ label: "Metadata Type",
199
+ required: true,
200
+ searchable: true,
201
+ readonly: true,
202
+ maxLength: 100
203
+ }),
204
+ /** Version number at this snapshot */
205
+ version: Field.number({
206
+ label: "Version",
207
+ required: true,
208
+ readonly: true
209
+ }),
210
+ /** Type of operation that created this history entry */
211
+ operation_type: Field.select(["create", "update", "publish", "revert", "delete"], {
212
+ label: "Operation Type",
213
+ required: true,
214
+ readonly: true
215
+ }),
216
+ /** Historical metadata snapshot (JSON payload) */
217
+ metadata: Field.textarea({
218
+ label: "Metadata",
219
+ required: true,
220
+ readonly: true,
221
+ description: "JSON-serialized metadata snapshot at this version"
222
+ }),
223
+ /** SHA-256 checksum of metadata content */
224
+ checksum: Field.text({
225
+ label: "Checksum",
226
+ required: true,
227
+ readonly: true,
228
+ maxLength: 64
229
+ }),
230
+ /** Checksum of the previous version */
231
+ previous_checksum: Field.text({
232
+ label: "Previous Checksum",
233
+ required: false,
234
+ readonly: true,
235
+ maxLength: 64
236
+ }),
237
+ /** Human-readable description of changes */
238
+ change_note: Field.textarea({
239
+ label: "Change Note",
240
+ required: false,
241
+ readonly: true,
242
+ description: "Description of what changed in this version"
243
+ }),
244
+ /** Organization ID for multi-tenant isolation */
245
+ organization_id: Field.lookup("sys_organization", {
246
+ label: "Organization",
247
+ required: false,
248
+ readonly: true,
249
+ description: "Organization for multi-tenant isolation."
250
+ }),
251
+ /** Environment ID — null = platform-global, set = env-scoped */
252
+ project_id: Field.text({
253
+ label: "Environment ID",
254
+ required: false,
255
+ readonly: true,
256
+ maxLength: 255,
257
+ description: "Scopes this history entry to a specific environment."
258
+ }),
259
+ /** User who made this change */
260
+ recorded_by: Field.lookup("sys_user", {
261
+ label: "Recorded By",
262
+ required: false,
263
+ readonly: true
264
+ }),
265
+ /** When was this version recorded */
266
+ recorded_at: Field.datetime({
267
+ label: "Recorded At",
268
+ required: true,
269
+ readonly: true
270
+ })
271
+ },
272
+ indexes: [
273
+ { fields: ["metadata_id", "version"], unique: true },
274
+ { fields: ["metadata_id", "recorded_at"] },
275
+ { fields: ["type", "name"] },
276
+ { fields: ["recorded_at"] },
277
+ { fields: ["operation_type"] },
278
+ { fields: ["organization_id"] },
279
+ { fields: ["project_id"] }
280
+ ],
281
+ enable: {
282
+ trackHistory: false,
283
+ // Don't track history of history records
284
+ searchable: false,
285
+ apiEnabled: true,
286
+ apiMethods: ["get", "list"],
287
+ // Read-only via API
288
+ trash: false
289
+ }
290
+ });
291
+ var SysObject = ObjectSchema.create({
292
+ name: "sys_object",
293
+ label: "Object Definition",
294
+ pluralLabel: "Object Definitions",
295
+ description: "Metadata for business objects",
296
+ icon: "database",
297
+ isSystem: true,
298
+ fields: {
299
+ // Core Identity
300
+ name: Field.text({
301
+ label: "Object Name",
302
+ required: true,
303
+ maxLength: 255,
304
+ description: "Machine name (snake_case)"
305
+ }),
306
+ project_id: Field.text({
307
+ label: "Environment ID",
308
+ maxLength: 255,
309
+ description: "Project/environment scope \u2014 null = control-plane global"
310
+ }),
311
+ label: Field.text({
312
+ label: "Display Label",
313
+ required: true,
314
+ maxLength: 255
315
+ }),
316
+ plural_label: Field.text({
317
+ label: "Plural Label",
318
+ maxLength: 255
319
+ }),
320
+ description: Field.textarea({
321
+ label: "Description"
322
+ }),
323
+ icon: Field.text({
324
+ label: "Icon",
325
+ maxLength: 100
326
+ }),
327
+ // Classification
328
+ namespace: Field.text({
329
+ label: "Namespace",
330
+ maxLength: 100,
331
+ description: "Logical domain namespace"
332
+ }),
333
+ tags: Field.text({
334
+ label: "Tags",
335
+ description: "Comma-separated categorization tags"
336
+ }),
337
+ active: Field.boolean({
338
+ label: "Active",
339
+ defaultValue: true
340
+ }),
341
+ is_system: Field.boolean({
342
+ label: "System Object",
343
+ defaultValue: false,
344
+ description: "Protected from deletion"
345
+ }),
346
+ abstract: Field.boolean({
347
+ label: "Abstract",
348
+ defaultValue: false,
349
+ description: "Cannot be instantiated"
350
+ }),
351
+ // Storage
352
+ datasource: Field.text({
353
+ label: "Datasource",
354
+ maxLength: 100,
355
+ defaultValue: "default"
356
+ }),
357
+ table_name: Field.text({
358
+ label: "Table Name",
359
+ maxLength: 255,
360
+ description: "Physical table/collection name"
361
+ }),
362
+ // Complex Data (stored as JSON)
363
+ fields_json: Field.textarea({
364
+ label: "Fields (JSON)",
365
+ description: "Field definitions as JSON"
366
+ }),
367
+ indexes_json: Field.textarea({
368
+ label: "Indexes (JSON)",
369
+ description: "Index definitions as JSON"
370
+ }),
371
+ validations_json: Field.textarea({
372
+ label: "Validations (JSON)",
373
+ description: "Validation rules as JSON"
374
+ }),
375
+ state_machines_json: Field.textarea({
376
+ label: "State Machines (JSON)",
377
+ description: "State machine definitions as JSON"
378
+ }),
379
+ capabilities_json: Field.textarea({
380
+ label: "Capabilities (JSON)",
381
+ description: "Enabled system features as JSON"
382
+ }),
383
+ // Denormalized Fields
384
+ field_count: Field.number({
385
+ label: "Field Count",
386
+ description: "Number of fields defined"
387
+ }),
388
+ // Display
389
+ display_name_field: Field.text({
390
+ label: "Display Name Field",
391
+ maxLength: 100,
392
+ description: "Field to use as record display name"
393
+ }),
394
+ title_format: Field.text({
395
+ label: "Title Format",
396
+ maxLength: 255,
397
+ description: "Title expression template"
398
+ }),
399
+ compact_layout: Field.text({
400
+ label: "Compact Layout",
401
+ description: "Comma-separated field names for cards"
402
+ }),
403
+ // Capabilities
404
+ track_history: Field.boolean({
405
+ label: "Track History",
406
+ defaultValue: false
407
+ }),
408
+ searchable: Field.boolean({
409
+ label: "Searchable",
410
+ defaultValue: true
411
+ }),
412
+ api_enabled: Field.boolean({
413
+ label: "API Enabled",
414
+ defaultValue: true
415
+ }),
416
+ files: Field.boolean({
417
+ label: "Files",
418
+ defaultValue: false
419
+ }),
420
+ feeds: Field.boolean({
421
+ label: "Feeds",
422
+ defaultValue: false
423
+ }),
424
+ activities: Field.boolean({
425
+ label: "Activities",
426
+ defaultValue: false
427
+ }),
428
+ trash: Field.boolean({
429
+ label: "Trash",
430
+ defaultValue: true
431
+ }),
432
+ mru: Field.boolean({
433
+ label: "MRU",
434
+ defaultValue: true
435
+ }),
436
+ clone: Field.boolean({
437
+ label: "Clone",
438
+ defaultValue: true
439
+ }),
440
+ // Package Management
441
+ package_id: Field.lookup("sys_package", {
442
+ label: "Package"
443
+ }),
444
+ managed_by: Field.select({
445
+ label: "Managed By",
446
+ options: [
447
+ { value: "package", label: "Package" },
448
+ { value: "platform", label: "Platform" },
449
+ { value: "user", label: "User" }
450
+ ]
451
+ }),
452
+ // Audit
453
+ created_by: Field.lookup("sys_user", { label: "Created By" }),
454
+ created_at: Field.datetime({ label: "Created At" }),
455
+ updated_by: Field.lookup("sys_user", { label: "Updated By" }),
456
+ updated_at: Field.datetime({ label: "Updated At" })
457
+ },
458
+ indexes: [
459
+ { fields: ["name", "project_id"], unique: true },
460
+ { fields: ["project_id"] },
461
+ { fields: ["namespace"] },
462
+ { fields: ["package_id"] },
463
+ { fields: ["active"] },
464
+ { fields: ["is_system"] }
465
+ ],
466
+ enable: {
467
+ trackHistory: true,
468
+ searchable: true,
469
+ apiEnabled: true,
470
+ trash: true,
471
+ mru: true
472
+ }
473
+ });
474
+ var SysView = ObjectSchema.create({
475
+ name: "sys_view",
476
+ label: "View Definition",
477
+ pluralLabel: "View Definitions",
478
+ description: "Metadata for UI views (grid, kanban, calendar, etc.)",
479
+ icon: "layout-grid",
480
+ isSystem: true,
481
+ fields: {
482
+ // Core Identity
483
+ name: Field.text({
484
+ label: "View Name",
485
+ required: true,
486
+ maxLength: 255
487
+ }),
488
+ project_id: Field.text({
489
+ label: "Environment ID",
490
+ maxLength: 255,
491
+ description: "Project/environment scope \u2014 null = control-plane global"
492
+ }),
493
+ label: Field.text({
494
+ label: "Display Label",
495
+ required: true,
496
+ maxLength: 255
497
+ }),
498
+ description: Field.textarea({
499
+ label: "Description"
500
+ }),
501
+ // Reference to Object
502
+ object_name: Field.text({
503
+ label: "Object Name",
504
+ required: true,
505
+ maxLength: 255,
506
+ description: "The object this view displays"
507
+ }),
508
+ // View Type
509
+ view_type: Field.select({
510
+ label: "View Type",
511
+ required: true,
512
+ options: [
513
+ { value: "grid", label: "Grid" },
514
+ { value: "kanban", label: "Kanban" },
515
+ { value: "calendar", label: "Calendar" },
516
+ { value: "gantt", label: "Gantt" },
517
+ { value: "form", label: "Form" },
518
+ { value: "timeline", label: "Timeline" }
519
+ ]
520
+ }),
521
+ // Complex Configuration
522
+ columns_json: Field.textarea({
523
+ label: "Columns (JSON)",
524
+ description: "Column definitions as JSON"
525
+ }),
526
+ filters_json: Field.textarea({
527
+ label: "Filters (JSON)",
528
+ description: "Filter definitions as JSON"
529
+ }),
530
+ sort_json: Field.textarea({
531
+ label: "Sort (JSON)",
532
+ description: "Sort configuration as JSON"
533
+ }),
534
+ config_json: Field.textarea({
535
+ label: "Configuration (JSON)",
536
+ description: "View-specific configuration as JSON"
537
+ }),
538
+ // Display Options
539
+ page_size: Field.number({
540
+ label: "Page Size",
541
+ defaultValue: 25,
542
+ min: 1,
543
+ max: 200
544
+ }),
545
+ show_search: Field.boolean({
546
+ label: "Show Search",
547
+ defaultValue: true
548
+ }),
549
+ show_filters: Field.boolean({
550
+ label: "Show Filters",
551
+ defaultValue: true
552
+ }),
553
+ // Classification
554
+ namespace: Field.text({
555
+ label: "Namespace",
556
+ maxLength: 100
557
+ }),
558
+ // Package Management
559
+ package_id: Field.lookup("sys_package", {
560
+ label: "Package"
561
+ }),
562
+ managed_by: Field.select({
563
+ label: "Managed By",
564
+ options: [
565
+ { value: "package", label: "Package" },
566
+ { value: "platform", label: "Platform" },
567
+ { value: "user", label: "User" }
568
+ ]
569
+ }),
570
+ // Audit
571
+ created_by: Field.lookup("sys_user", { label: "Created By" }),
572
+ created_at: Field.datetime({ label: "Created At" }),
573
+ updated_by: Field.lookup("sys_user", { label: "Updated By" }),
574
+ updated_at: Field.datetime({ label: "Updated At" })
575
+ },
576
+ indexes: [
577
+ { fields: ["name", "project_id"], unique: true },
578
+ { fields: ["project_id"] },
579
+ { fields: ["object_name"] },
580
+ { fields: ["view_type"] },
581
+ { fields: ["namespace"] },
582
+ { fields: ["package_id"] }
583
+ ],
584
+ enable: {
585
+ trackHistory: true,
586
+ searchable: true,
587
+ apiEnabled: true,
588
+ trash: true,
589
+ mru: true
590
+ }
591
+ });
592
+ var SysAgent = ObjectSchema.create({
593
+ name: "sys_agent",
594
+ label: "AI Agent",
595
+ pluralLabel: "AI Agents",
596
+ description: "AI agent definitions",
597
+ icon: "bot",
598
+ isSystem: true,
599
+ fields: {
600
+ // Core Identity
601
+ name: Field.text({
602
+ label: "Agent Name",
603
+ required: true,
604
+ maxLength: 255
605
+ }),
606
+ project_id: Field.text({
607
+ label: "Environment ID",
608
+ maxLength: 255,
609
+ description: "Project/environment scope \u2014 null = control-plane global"
610
+ }),
611
+ label: Field.text({
612
+ label: "Display Label",
613
+ required: true,
614
+ maxLength: 255
615
+ }),
616
+ description: Field.textarea({
617
+ label: "Description"
618
+ }),
619
+ // Agent Type
620
+ agent_type: Field.select({
621
+ label: "Agent Type",
622
+ options: [
623
+ { value: "conversational", label: "Conversational" },
624
+ { value: "task", label: "Task-Based" },
625
+ { value: "analytical", label: "Analytical" },
626
+ { value: "workflow", label: "Workflow" }
627
+ ]
628
+ }),
629
+ // Model Configuration
630
+ model: Field.text({
631
+ label: "Model ID",
632
+ maxLength: 255,
633
+ description: "AI model identifier"
634
+ }),
635
+ temperature: Field.number({
636
+ label: "Temperature",
637
+ min: 0,
638
+ max: 2,
639
+ defaultValue: 0.7
640
+ }),
641
+ max_tokens: Field.number({
642
+ label: "Max Tokens",
643
+ min: 1,
644
+ max: 1e5
645
+ }),
646
+ top_p: Field.number({
647
+ label: "Top P",
648
+ min: 0,
649
+ max: 1
650
+ }),
651
+ // System Prompt
652
+ system_prompt: Field.textarea({
653
+ label: "System Prompt",
654
+ description: "Instructions for the AI agent"
655
+ }),
656
+ // Tools Configuration
657
+ tools_json: Field.textarea({
658
+ label: "Tools (JSON)",
659
+ description: "Available tools as JSON array"
660
+ }),
661
+ // Skills Configuration
662
+ skills_json: Field.textarea({
663
+ label: "Skills (JSON)",
664
+ description: "Available skills as JSON array"
665
+ }),
666
+ // Memory Configuration
667
+ memory_enabled: Field.boolean({
668
+ label: "Memory Enabled",
669
+ defaultValue: false
670
+ }),
671
+ memory_window: Field.number({
672
+ label: "Memory Window",
673
+ description: "Number of conversation turns to remember",
674
+ defaultValue: 10
675
+ }),
676
+ // Classification
677
+ namespace: Field.text({
678
+ label: "Namespace",
679
+ maxLength: 100
680
+ }),
681
+ // Package Management
682
+ package_id: Field.lookup("sys_package", {
683
+ label: "Package"
684
+ }),
685
+ managed_by: Field.select({
686
+ label: "Managed By",
687
+ options: [
688
+ { value: "package", label: "Package" },
689
+ { value: "platform", label: "Platform" },
690
+ { value: "user", label: "User" }
691
+ ]
692
+ }),
693
+ // Audit
694
+ created_by: Field.lookup("sys_user", { label: "Created By" }),
695
+ created_at: Field.datetime({ label: "Created At" }),
696
+ updated_by: Field.lookup("sys_user", { label: "Updated By" }),
697
+ updated_at: Field.datetime({ label: "Updated At" })
698
+ },
699
+ indexes: [
700
+ { fields: ["name", "project_id"], unique: true },
701
+ { fields: ["project_id"] },
702
+ { fields: ["agent_type"] },
703
+ { fields: ["namespace"] },
704
+ { fields: ["package_id"] }
705
+ ],
706
+ enable: {
707
+ trackHistory: true,
708
+ searchable: true,
709
+ apiEnabled: true,
710
+ trash: true,
711
+ mru: true
712
+ }
713
+ });
714
+ var SysTool = ObjectSchema.create({
715
+ name: "sys_tool",
716
+ label: "AI Tool",
717
+ pluralLabel: "AI Tools",
718
+ description: "AI tool definitions",
719
+ icon: "wrench",
720
+ isSystem: true,
721
+ fields: {
722
+ // Core Identity
723
+ name: Field.text({
724
+ label: "Tool Name",
725
+ required: true,
726
+ maxLength: 255
727
+ }),
728
+ project_id: Field.text({
729
+ label: "Environment ID",
730
+ maxLength: 255,
731
+ description: "Project/environment scope \u2014 null = control-plane global"
732
+ }),
733
+ label: Field.text({
734
+ label: "Display Label",
735
+ required: true,
736
+ maxLength: 255
737
+ }),
738
+ description: Field.textarea({
739
+ label: "Description",
740
+ required: true
741
+ }),
742
+ // Parameters
743
+ parameters_json: Field.textarea({
744
+ label: "Parameters (JSON)",
745
+ description: "Tool parameter schema as JSON"
746
+ }),
747
+ // Implementation
748
+ handler_code: Field.textarea({
749
+ label: "Handler Code",
750
+ description: "Tool implementation code"
751
+ }),
752
+ // Classification
753
+ namespace: Field.text({
754
+ label: "Namespace",
755
+ maxLength: 100
756
+ }),
757
+ // Package Management
758
+ package_id: Field.lookup("sys_package", {
759
+ label: "Package"
760
+ }),
761
+ managed_by: Field.select({
762
+ label: "Managed By",
763
+ options: [
764
+ { value: "package", label: "Package" },
765
+ { value: "platform", label: "Platform" },
766
+ { value: "user", label: "User" }
767
+ ]
768
+ }),
769
+ // Audit
770
+ created_by: Field.lookup("sys_user", { label: "Created By" }),
771
+ created_at: Field.datetime({ label: "Created At" }),
772
+ updated_by: Field.lookup("sys_user", { label: "Updated By" }),
773
+ updated_at: Field.datetime({ label: "Updated At" })
774
+ },
775
+ indexes: [
776
+ { fields: ["name", "project_id"], unique: true },
777
+ { fields: ["project_id"] },
778
+ { fields: ["namespace"] },
779
+ { fields: ["package_id"] }
780
+ ],
781
+ enable: {
782
+ trackHistory: true,
783
+ searchable: true,
784
+ apiEnabled: true,
785
+ trash: true,
786
+ mru: true
787
+ }
788
+ });
789
+ var SysFlow = ObjectSchema.create({
790
+ name: "sys_flow",
791
+ label: "Flow",
792
+ pluralLabel: "Flows",
793
+ description: "Visual logic flow definitions",
794
+ icon: "workflow",
795
+ isSystem: true,
796
+ fields: {
797
+ // Core Identity
798
+ name: Field.text({
799
+ label: "Flow Name",
800
+ required: true,
801
+ maxLength: 255
802
+ }),
803
+ project_id: Field.text({
804
+ label: "Environment ID",
805
+ maxLength: 255,
806
+ description: "Project/environment scope \u2014 null = control-plane global"
807
+ }),
808
+ label: Field.text({
809
+ label: "Display Label",
810
+ required: true,
811
+ maxLength: 255
812
+ }),
813
+ description: Field.textarea({
814
+ label: "Description"
815
+ }),
816
+ // Flow Type
817
+ flow_type: Field.select({
818
+ label: "Flow Type",
819
+ required: true,
820
+ options: [
821
+ { value: "autolaunched", label: "Autolaunched" },
822
+ { value: "screen", label: "Screen Flow" },
823
+ { value: "schedule", label: "Scheduled" },
824
+ { value: "trigger", label: "Trigger-Based" }
825
+ ]
826
+ }),
827
+ // Flow Definition
828
+ nodes_json: Field.textarea({
829
+ label: "Nodes (JSON)",
830
+ description: "Flow nodes as JSON"
831
+ }),
832
+ edges_json: Field.textarea({
833
+ label: "Edges (JSON)",
834
+ description: "Flow edges as JSON"
835
+ }),
836
+ variables_json: Field.textarea({
837
+ label: "Variables (JSON)",
838
+ description: "Flow variables as JSON"
839
+ }),
840
+ // Trigger Configuration
841
+ trigger_type: Field.select({
842
+ label: "Trigger Type",
843
+ options: [
844
+ { value: "record_created", label: "Record Created" },
845
+ { value: "record_updated", label: "Record Updated" },
846
+ { value: "record_deleted", label: "Record Deleted" },
847
+ { value: "schedule", label: "Schedule" },
848
+ { value: "platform_event", label: "Platform Event" }
849
+ ]
850
+ }),
851
+ trigger_object: Field.text({
852
+ label: "Trigger Object",
853
+ maxLength: 255
854
+ }),
855
+ // Status
856
+ active: Field.boolean({
857
+ label: "Active",
858
+ defaultValue: false
859
+ }),
860
+ // Classification
861
+ namespace: Field.text({
862
+ label: "Namespace",
863
+ maxLength: 100
864
+ }),
865
+ // Package Management
866
+ package_id: Field.lookup("sys_package", {
867
+ label: "Package"
868
+ }),
869
+ managed_by: Field.select({
870
+ label: "Managed By",
871
+ options: [
872
+ { value: "package", label: "Package" },
873
+ { value: "platform", label: "Platform" },
874
+ { value: "user", label: "User" }
875
+ ]
876
+ }),
877
+ // Audit
878
+ created_by: Field.lookup("sys_user", { label: "Created By" }),
879
+ created_at: Field.datetime({ label: "Created At" }),
880
+ updated_by: Field.lookup("sys_user", { label: "Updated By" }),
881
+ updated_at: Field.datetime({ label: "Updated At" })
882
+ },
883
+ indexes: [
884
+ { fields: ["name", "project_id"], unique: true },
885
+ { fields: ["project_id"] },
886
+ { fields: ["flow_type"] },
887
+ { fields: ["active"] },
888
+ { fields: ["namespace"] },
889
+ { fields: ["package_id"] }
890
+ ],
891
+ enable: {
892
+ trackHistory: true,
893
+ searchable: true,
894
+ apiEnabled: true,
895
+ trash: true,
896
+ mru: true
897
+ }
898
+ });
899
+
900
+ export { SysAgent, SysFlow, SysMetadataObject as SysMetadata, SysMetadataHistoryObject, SysMetadataObject, SysObject, SysTool, SysView };
901
+ //# sourceMappingURL=index.mjs.map
902
+ //# sourceMappingURL=index.mjs.map