@objectstack/objectql 1.0.11 → 1.0.12

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/dist/index.d.mts CHANGED
@@ -1,21 +1,238 @@
1
- import { ServiceObject, HookContext, DataEngineQueryOptions, DataEngineInsertOptions, DataEngineUpdateOptions, DataEngineDeleteOptions, DataEngineCountOptions, DataEngineAggregateOptions } from '@objectstack/spec/data';
2
- import { ObjectStackManifest } from '@objectstack/spec/kernel';
1
+ import { z } from 'zod';
2
+ import { ServiceObject, ObjectOwnership, HookContext, DataEngineQueryOptions, DataEngineInsertOptions, DataEngineUpdateOptions, DataEngineDeleteOptions, DataEngineCountOptions, DataEngineAggregateOptions } from '@objectstack/spec/data';
3
+ import { ObjectStackManifest, InstalledPackage } from '@objectstack/spec/kernel';
3
4
  import { ObjectStackProtocol, MetadataCacheRequest, MetadataCacheResponse, BatchUpdateRequest, BatchUpdateResponse, UpdateManyDataRequest, DeleteManyDataRequest } from '@objectstack/spec/api';
4
5
  import { IDataEngine, DriverInterface, Logger, Plugin, PluginContext } from '@objectstack/core';
5
6
 
7
+ /**
8
+ * XState-inspired State Machine Protocol
9
+ * Used to define strict business logic constraints and lifecycle management.
10
+ * Prevent AI "hallucinations" by enforcing valid valid transitions.
11
+ */
12
+ /**
13
+ * References a named action (side effect)
14
+ * Can be a script, a webhook, or a field update.
15
+ */
16
+ declare const ActionRefSchema: z.ZodUnion<[z.ZodString, z.ZodObject<{
17
+ type: z.ZodString;
18
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ type: string;
21
+ params?: Record<string, any> | undefined;
22
+ }, {
23
+ type: string;
24
+ params?: Record<string, any> | undefined;
25
+ }>]>;
26
+ /**
27
+ * State Transition Definition
28
+ * "When EVENT happens, if GUARD is true, go to TARGET and run ACTIONS"
29
+ */
30
+ declare const TransitionSchema: z.ZodObject<{
31
+ target: z.ZodOptional<z.ZodString>;
32
+ cond: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
33
+ type: z.ZodString;
34
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ type: string;
37
+ params?: Record<string, any> | undefined;
38
+ }, {
39
+ type: string;
40
+ params?: Record<string, any> | undefined;
41
+ }>]>>;
42
+ actions: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodObject<{
43
+ type: z.ZodString;
44
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ type: string;
47
+ params?: Record<string, any> | undefined;
48
+ }, {
49
+ type: string;
50
+ params?: Record<string, any> | undefined;
51
+ }>]>, "many">>;
52
+ description: z.ZodOptional<z.ZodString>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ target?: string | undefined;
55
+ description?: string | undefined;
56
+ cond?: string | {
57
+ type: string;
58
+ params?: Record<string, any> | undefined;
59
+ } | undefined;
60
+ actions?: (string | {
61
+ type: string;
62
+ params?: Record<string, any> | undefined;
63
+ })[] | undefined;
64
+ }, {
65
+ target?: string | undefined;
66
+ description?: string | undefined;
67
+ cond?: string | {
68
+ type: string;
69
+ params?: Record<string, any> | undefined;
70
+ } | undefined;
71
+ actions?: (string | {
72
+ type: string;
73
+ params?: Record<string, any> | undefined;
74
+ })[] | undefined;
75
+ }>;
76
+ type ActionRef = z.infer<typeof ActionRefSchema>;
77
+ type Transition = z.infer<typeof TransitionSchema>;
78
+ type StateNodeConfig = {
79
+ type?: 'atomic' | 'compound' | 'parallel' | 'final' | 'history';
80
+ entry?: ActionRef[];
81
+ exit?: ActionRef[];
82
+ on?: Record<string, string | Transition | Transition[]>;
83
+ always?: Transition[];
84
+ initial?: string;
85
+ states?: Record<string, StateNodeConfig>;
86
+ meta?: {
87
+ label?: string;
88
+ description?: string;
89
+ color?: string;
90
+ aiInstructions?: string;
91
+ };
92
+ };
93
+
94
+ /**
95
+ * Reserved namespaces that do not get FQN prefix applied.
96
+ * Objects in these namespaces keep their short names (e.g., "user" not "base__user").
97
+ */
98
+ declare const RESERVED_NAMESPACES: Set<string>;
99
+ /**
100
+ * Default priorities for ownership types.
101
+ */
102
+ declare const DEFAULT_OWNER_PRIORITY = 100;
103
+ declare const DEFAULT_EXTENDER_PRIORITY = 200;
104
+ /**
105
+ * Contributor Record
106
+ * Tracks how a package contributes to an object (own or extend).
107
+ */
108
+ interface ObjectContributor {
109
+ packageId: string;
110
+ namespace: string;
111
+ ownership: ObjectOwnership;
112
+ priority: number;
113
+ definition: ServiceObject;
114
+ }
115
+ /**
116
+ * Compute Fully Qualified Name (FQN) for an object.
117
+ *
118
+ * @param namespace - The package namespace (e.g., "crm", "todo")
119
+ * @param shortName - The object's short name (e.g., "task", "account")
120
+ * @returns FQN string (e.g., "crm__task") or just shortName for reserved namespaces
121
+ *
122
+ * @example
123
+ * computeFQN('crm', 'account') // => 'crm__account'
124
+ * computeFQN('base', 'user') // => 'user' (reserved, no prefix)
125
+ * computeFQN(undefined, 'task') // => 'task' (legacy, no namespace)
126
+ */
127
+ declare function computeFQN(namespace: string | undefined, shortName: string): string;
128
+ /**
129
+ * Parse FQN back to namespace and short name.
130
+ *
131
+ * @param fqn - Fully qualified name (e.g., "crm__account" or "user")
132
+ * @returns { namespace, shortName } - namespace is undefined for unprefixed names
133
+ */
134
+ declare function parseFQN(fqn: string): {
135
+ namespace: string | undefined;
136
+ shortName: string;
137
+ };
6
138
  /**
7
139
  * Global Schema Registry
8
140
  * Unified storage for all metadata types (Objects, Apps, Flows, Layouts, etc.)
141
+ *
142
+ * ## Namespace & Ownership Model
143
+ *
144
+ * Objects use a namespace-based FQN system:
145
+ * - `namespace`: Short identifier from package manifest (e.g., "crm", "todo")
146
+ * - `FQN`: `{namespace}__{short_name}` (e.g., "crm__account")
147
+ * - Reserved namespaces (`base`, `system`) don't get prefixed
148
+ *
149
+ * Ownership modes:
150
+ * - `own`: One package owns the object (creates the table, defines base schema)
151
+ * - `extend`: Multiple packages can extend an object (add fields, merge by priority)
152
+ *
153
+ * ## Package vs App Distinction
154
+ * - **Package**: The unit of installation, stored under type 'package'.
155
+ * Each InstalledPackage wraps a ManifestSchema with lifecycle state.
156
+ * - **App**: A UI navigation shell (AppSchema), registered under type 'apps'.
157
+ * Apps are extracted from packages during registration.
158
+ * - A package may contain 0, 1, or many apps.
9
159
  */
160
+ type RegistryLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
10
161
  declare class SchemaRegistry {
162
+ /** Controls verbosity of registry console messages. Default: 'info'. */
163
+ private static _logLevel;
164
+ static get logLevel(): RegistryLogLevel;
165
+ static set logLevel(level: RegistryLogLevel);
166
+ private static log;
167
+ /** FQN → Contributor[] (all packages that own/extend this object) */
168
+ private static objectContributors;
169
+ /** FQN → Merged ServiceObject (cached, invalidated on changes) */
170
+ private static mergedObjectCache;
171
+ /** Namespace → PackageId (ensures namespace uniqueness) */
172
+ private static namespaceRegistry;
173
+ /** Type → Name/ID → MetadataItem */
11
174
  private static metadata;
12
175
  /**
13
- * Universal Register Method
14
- * @param type The category of metadata (e.g., 'object', 'app', 'plugin')
15
- * @param item The metadata item itself
16
- * @param keyField The property to use as the unique key (default: 'name')
176
+ * Register a namespace for a package.
177
+ * Enforces namespace uniqueness within the instance.
178
+ *
179
+ * @throws Error if namespace is already registered to a different package
180
+ */
181
+ static registerNamespace(namespace: string, packageId: string): void;
182
+ /**
183
+ * Unregister a namespace when a package is uninstalled.
184
+ */
185
+ static unregisterNamespace(namespace: string, packageId: string): void;
186
+ /**
187
+ * Get the package that owns a namespace.
188
+ */
189
+ static getNamespaceOwner(namespace: string): string | undefined;
190
+ /**
191
+ * Register an object with ownership semantics.
192
+ *
193
+ * @param schema - The object definition
194
+ * @param packageId - The owning package ID
195
+ * @param namespace - The package namespace (for FQN computation)
196
+ * @param ownership - 'own' (single owner) or 'extend' (additive merge)
197
+ * @param priority - Merge priority (lower applied first, higher wins on conflict)
198
+ *
199
+ * @throws Error if trying to 'own' an object that already has an owner
200
+ */
201
+ static registerObject(schema: ServiceObject, packageId: string, namespace?: string, ownership?: ObjectOwnership, priority?: number): string;
202
+ /**
203
+ * Resolve an object by FQN, merging all contributions.
204
+ * Returns the merged object or undefined if not found.
205
+ */
206
+ static resolveObject(fqn: string): ServiceObject | undefined;
207
+ /**
208
+ * Get object by name (FQN or short name with fallback scan).
209
+ * For compatibility, tries exact match first, then scans for suffix match.
210
+ */
211
+ static getObject(name: string): ServiceObject | undefined;
212
+ /**
213
+ * Get all registered objects (merged).
214
+ *
215
+ * @param packageId - Optional filter: only objects contributed by this package
216
+ */
217
+ static getAllObjects(packageId?: string): ServiceObject[];
218
+ /**
219
+ * Get all contributors for an object.
220
+ */
221
+ static getObjectContributors(fqn: string): ObjectContributor[];
222
+ /**
223
+ * Get the owner contributor for an object.
17
224
  */
18
- static registerItem<T>(type: string, item: T, keyField?: keyof T): void;
225
+ static getObjectOwner(fqn: string): ObjectContributor | undefined;
226
+ /**
227
+ * Unregister all objects contributed by a package.
228
+ *
229
+ * @throws Error if trying to uninstall an owner that has extenders
230
+ */
231
+ static unregisterObjectsByPackage(packageId: string, force?: boolean): void;
232
+ /**
233
+ * Universal Register Method for non-object metadata.
234
+ */
235
+ static registerItem<T>(type: string, item: T, keyField?: keyof T, packageId?: string): void;
19
236
  /**
20
237
  * Validate Metadata against Spec Zod Schemas
21
238
  */
@@ -224,6 +441,66 @@ declare class SchemaRegistry {
224
441
  destination: string;
225
442
  } | undefined;
226
443
  validations?: any[] | undefined;
444
+ stateMachine?: {
445
+ initial: string;
446
+ states: Record<string, StateNodeConfig>;
447
+ id: string;
448
+ on?: Record<string, string | {
449
+ target?: string | undefined;
450
+ description?: string | undefined;
451
+ cond?: string | {
452
+ type: string;
453
+ params?: Record<string, any> | undefined;
454
+ } | undefined;
455
+ actions?: (string | {
456
+ type: string;
457
+ params?: Record<string, any> | undefined;
458
+ })[] | undefined;
459
+ } | {
460
+ target?: string | undefined;
461
+ description?: string | undefined;
462
+ cond?: string | {
463
+ type: string;
464
+ params?: Record<string, any> | undefined;
465
+ } | undefined;
466
+ actions?: (string | {
467
+ type: string;
468
+ params?: Record<string, any> | undefined;
469
+ })[] | undefined;
470
+ }[]> | undefined;
471
+ description?: string | undefined;
472
+ contextSchema?: Record<string, any> | undefined;
473
+ } | undefined;
474
+ stateMachines?: Record<string, {
475
+ initial: string;
476
+ states: Record<string, StateNodeConfig>;
477
+ id: string;
478
+ on?: Record<string, string | {
479
+ target?: string | undefined;
480
+ description?: string | undefined;
481
+ cond?: string | {
482
+ type: string;
483
+ params?: Record<string, any> | undefined;
484
+ } | undefined;
485
+ actions?: (string | {
486
+ type: string;
487
+ params?: Record<string, any> | undefined;
488
+ })[] | undefined;
489
+ } | {
490
+ target?: string | undefined;
491
+ description?: string | undefined;
492
+ cond?: string | {
493
+ type: string;
494
+ params?: Record<string, any> | undefined;
495
+ } | undefined;
496
+ actions?: (string | {
497
+ type: string;
498
+ params?: Record<string, any> | undefined;
499
+ })[] | undefined;
500
+ }[]> | undefined;
501
+ description?: string | undefined;
502
+ contextSchema?: Record<string, any> | undefined;
503
+ }> | undefined;
227
504
  titleFormat?: string | undefined;
228
505
  compactLayout?: string[] | undefined;
229
506
  enable?: {
@@ -236,7 +513,7 @@ declare class SchemaRegistry {
236
513
  trash: boolean;
237
514
  mru: boolean;
238
515
  clone: boolean;
239
- apiMethods?: ("search" | "update" | "delete" | "get" | "list" | "create" | "upsert" | "bulk" | "aggregate" | "history" | "restore" | "purge" | "import" | "export")[] | undefined;
516
+ apiMethods?: ("search" | "update" | "delete" | "history" | "get" | "list" | "create" | "upsert" | "bulk" | "aggregate" | "restore" | "purge" | "import" | "export")[] | undefined;
240
517
  } | undefined;
241
518
  } | {
242
519
  label: string;
@@ -256,28 +533,315 @@ declare class SchemaRegistry {
256
533
  homePageId?: string | undefined;
257
534
  requiredPermissions?: string[] | undefined;
258
535
  apis?: any[] | undefined;
536
+ } | {
537
+ status: "error" | "disabled" | "installed" | "installing" | "uninstalling";
538
+ enabled: boolean;
539
+ manifest: {
540
+ type: "theme" | "driver" | "app" | "server" | "ui" | "agent" | "objectql" | "plugin" | "module" | "gateway" | "adapter";
541
+ name: string;
542
+ id: string;
543
+ version: string;
544
+ description?: string | undefined;
545
+ dependencies?: Record<string, string> | undefined;
546
+ data?: {
547
+ object: string;
548
+ externalId: string;
549
+ mode: "insert" | "update" | "upsert" | "replace" | "ignore";
550
+ env: ("prod" | "dev" | "test")[];
551
+ records: Record<string, any>[];
552
+ }[] | undefined;
553
+ capabilities?: {
554
+ implements?: {
555
+ protocol: {
556
+ label: string;
557
+ id: string;
558
+ version: {
559
+ major: number;
560
+ minor: number;
561
+ patch: number;
562
+ };
563
+ description?: string | undefined;
564
+ specification?: string | undefined;
565
+ };
566
+ conformance: "partial" | "full" | "deprecated" | "experimental";
567
+ certified: boolean;
568
+ metadata?: Record<string, any> | undefined;
569
+ features?: {
570
+ enabled: boolean;
571
+ name: string;
572
+ description?: string | undefined;
573
+ sinceVersion?: string | undefined;
574
+ deprecatedSince?: string | undefined;
575
+ }[] | undefined;
576
+ implementedFeatures?: string[] | undefined;
577
+ certificationDate?: string | undefined;
578
+ }[] | undefined;
579
+ provides?: {
580
+ methods: {
581
+ name: string;
582
+ async: boolean;
583
+ description?: string | undefined;
584
+ parameters?: {
585
+ type: string;
586
+ required: boolean;
587
+ name: string;
588
+ description?: string | undefined;
589
+ }[] | undefined;
590
+ returnType?: string | undefined;
591
+ }[];
592
+ name: string;
593
+ id: string;
594
+ version: {
595
+ major: number;
596
+ minor: number;
597
+ patch: number;
598
+ };
599
+ stability: "alpha" | "experimental" | "stable" | "beta";
600
+ description?: string | undefined;
601
+ events?: {
602
+ name: string;
603
+ description?: string | undefined;
604
+ payload?: string | undefined;
605
+ }[] | undefined;
606
+ }[] | undefined;
607
+ requires?: {
608
+ version: string;
609
+ optional: boolean;
610
+ pluginId: string;
611
+ reason?: string | undefined;
612
+ requiredCapabilities?: string[] | undefined;
613
+ }[] | undefined;
614
+ extensionPoints?: {
615
+ type: "provider" | "action" | "widget" | "hook" | "transformer" | "validator" | "decorator";
616
+ name: string;
617
+ id: string;
618
+ cardinality: "multiple" | "single";
619
+ description?: string | undefined;
620
+ contract?: {
621
+ signature?: string | undefined;
622
+ input?: string | undefined;
623
+ output?: string | undefined;
624
+ } | undefined;
625
+ }[] | undefined;
626
+ extensions?: {
627
+ priority: number;
628
+ implementation: string;
629
+ targetPluginId: string;
630
+ extensionPointId: string;
631
+ }[] | undefined;
632
+ } | undefined;
633
+ objects?: string[] | undefined;
634
+ permissions?: string[] | undefined;
635
+ namespace?: string | undefined;
636
+ extensions?: Record<string, any> | undefined;
637
+ loading?: {
638
+ strategy: "parallel" | "eager" | "lazy" | "deferred" | "on-demand";
639
+ caching?: {
640
+ enabled: boolean;
641
+ storage: "hybrid" | "memory" | "disk" | "indexeddb";
642
+ keyStrategy: "hash" | "version" | "timestamp";
643
+ maxSize?: number | undefined;
644
+ ttl?: number | undefined;
645
+ invalidateOn?: ("error" | "manual" | "version-change" | "dependency-change")[] | undefined;
646
+ compression?: {
647
+ enabled: boolean;
648
+ algorithm: "gzip" | "brotli" | "deflate";
649
+ } | undefined;
650
+ } | undefined;
651
+ preload?: {
652
+ enabled: boolean;
653
+ priority: number;
654
+ conditions?: {
655
+ roles?: string[] | undefined;
656
+ routes?: string[] | undefined;
657
+ deviceType?: ("desktop" | "mobile" | "tablet")[] | undefined;
658
+ minNetworkSpeed?: "slow-2g" | "2g" | "3g" | "4g" | undefined;
659
+ } | undefined;
660
+ resources?: ("code" | "dependencies" | "metadata" | "assets" | "services")[] | undefined;
661
+ } | undefined;
662
+ codeSplitting?: {
663
+ enabled: boolean;
664
+ strategy: "custom" | "size" | "route" | "feature";
665
+ chunkNaming: "hashed" | "named" | "sequential";
666
+ maxChunkSize?: number | undefined;
667
+ sharedDependencies?: {
668
+ enabled: boolean;
669
+ minChunks: number;
670
+ } | undefined;
671
+ } | undefined;
672
+ dynamicImport?: {
673
+ enabled: boolean;
674
+ timeout: number;
675
+ mode: "async" | "eager" | "lazy" | "sync";
676
+ prefetch: boolean;
677
+ preload: boolean;
678
+ retry?: {
679
+ enabled: boolean;
680
+ maxAttempts: number;
681
+ backoffMs: number;
682
+ } | undefined;
683
+ webpackChunkName?: string | undefined;
684
+ } | undefined;
685
+ initialization?: {
686
+ timeout: number;
687
+ priority: number;
688
+ mode: "async" | "parallel" | "sequential" | "sync";
689
+ critical: boolean;
690
+ retry?: {
691
+ enabled: boolean;
692
+ maxAttempts: number;
693
+ backoffMs: number;
694
+ } | undefined;
695
+ healthCheckInterval?: number | undefined;
696
+ } | undefined;
697
+ dependencyResolution?: {
698
+ strategy: "strict" | "latest" | "compatible" | "pinned";
699
+ conflictResolution: "latest" | "manual" | "fail" | "oldest";
700
+ circularDependencies: "error" | "warn" | "allow";
701
+ peerDependencies?: {
702
+ resolve: boolean;
703
+ onMissing: "error" | "warn" | "ignore";
704
+ onMismatch: "error" | "warn" | "ignore";
705
+ } | undefined;
706
+ optionalDependencies?: {
707
+ load: boolean;
708
+ onFailure: "warn" | "ignore";
709
+ } | undefined;
710
+ } | undefined;
711
+ hotReload?: {
712
+ enabled: boolean;
713
+ strategy: "partial" | "full" | "state-preserve";
714
+ debounceMs: number;
715
+ preserveState: boolean;
716
+ watchPatterns?: string[] | undefined;
717
+ ignorePatterns?: string[] | undefined;
718
+ stateSerialization?: {
719
+ enabled: boolean;
720
+ handler?: string | undefined;
721
+ } | undefined;
722
+ hooks?: {
723
+ onError?: string | undefined;
724
+ beforeReload?: string | undefined;
725
+ afterReload?: string | undefined;
726
+ } | undefined;
727
+ } | undefined;
728
+ sandboxing?: {
729
+ enabled: boolean;
730
+ isolationLevel: "none" | "process" | "vm" | "iframe" | "web-worker";
731
+ permissions?: {
732
+ allowedAPIs?: string[] | undefined;
733
+ allowedPaths?: string[] | undefined;
734
+ allowedEndpoints?: string[] | undefined;
735
+ allowedEnvVars?: string[] | undefined;
736
+ } | undefined;
737
+ allowedCapabilities?: string[] | undefined;
738
+ resourceQuotas?: {
739
+ maxMemoryMB?: number | undefined;
740
+ maxCpuTimeMs?: number | undefined;
741
+ maxFileDescriptors?: number | undefined;
742
+ maxNetworkKBps?: number | undefined;
743
+ } | undefined;
744
+ } | undefined;
745
+ monitoring?: {
746
+ enabled: boolean;
747
+ samplingRate: number;
748
+ reportingInterval: number;
749
+ onBudgetViolation: "error" | "warn" | "ignore";
750
+ metrics?: ("load-time" | "init-time" | "memory-usage" | "cpu-usage" | "api-calls" | "error-rate" | "cache-hit-rate")[] | undefined;
751
+ budgets?: {
752
+ maxMemoryMB?: number | undefined;
753
+ maxLoadTimeMs?: number | undefined;
754
+ maxInitTimeMs?: number | undefined;
755
+ } | undefined;
756
+ } | undefined;
757
+ } | undefined;
758
+ datasources?: string[] | undefined;
759
+ configuration?: {
760
+ properties: Record<string, {
761
+ type: "string" | "number" | "boolean" | "object" | "array";
762
+ required?: boolean | undefined;
763
+ default?: any;
764
+ description?: string | undefined;
765
+ enum?: string[] | undefined;
766
+ secret?: boolean | undefined;
767
+ }>;
768
+ title?: string | undefined;
769
+ } | undefined;
770
+ contributes?: {
771
+ events?: string[] | undefined;
772
+ actions?: {
773
+ name: string;
774
+ label?: string | undefined;
775
+ description?: string | undefined;
776
+ input?: any;
777
+ output?: any;
778
+ }[] | undefined;
779
+ fieldTypes?: {
780
+ label: string;
781
+ name: string;
782
+ description?: string | undefined;
783
+ }[] | undefined;
784
+ drivers?: {
785
+ label: string;
786
+ id: string;
787
+ description?: string | undefined;
788
+ }[] | undefined;
789
+ kinds?: {
790
+ id: string;
791
+ globs: string[];
792
+ description?: string | undefined;
793
+ }[] | undefined;
794
+ menus?: Record<string, {
795
+ label: string;
796
+ id: string;
797
+ command?: string | undefined;
798
+ }[]> | undefined;
799
+ themes?: {
800
+ path: string;
801
+ label: string;
802
+ id: string;
803
+ }[] | undefined;
804
+ translations?: {
805
+ path: string;
806
+ locale: string;
807
+ }[] | undefined;
808
+ functions?: {
809
+ name: string;
810
+ description?: string | undefined;
811
+ returnType?: string | undefined;
812
+ args?: string[] | undefined;
813
+ }[] | undefined;
814
+ } | undefined;
815
+ };
816
+ errorMessage?: string | undefined;
817
+ updatedAt?: string | undefined;
818
+ installedAt?: string | undefined;
819
+ statusChangedAt?: string | undefined;
820
+ settings?: Record<string, any> | undefined;
259
821
  } | {
260
822
  type: "theme" | "driver" | "app" | "server" | "ui" | "agent" | "objectql" | "plugin" | "module" | "gateway" | "adapter";
261
823
  name: string;
262
- version: string;
263
824
  id: string;
825
+ version: string;
264
826
  description?: string | undefined;
265
827
  dependencies?: Record<string, string> | undefined;
266
828
  data?: {
267
829
  object: string;
268
- mode: "insert" | "upsert" | "ignore";
830
+ externalId: string;
831
+ mode: "insert" | "update" | "upsert" | "replace" | "ignore";
832
+ env: ("prod" | "dev" | "test")[];
269
833
  records: Record<string, any>[];
270
834
  }[] | undefined;
271
835
  capabilities?: {
272
836
  implements?: {
273
837
  protocol: {
274
838
  label: string;
839
+ id: string;
275
840
  version: {
276
841
  major: number;
277
842
  minor: number;
278
843
  patch: number;
279
844
  };
280
- id: string;
281
845
  description?: string | undefined;
282
846
  specification?: string | undefined;
283
847
  };
@@ -308,12 +872,12 @@ declare class SchemaRegistry {
308
872
  returnType?: string | undefined;
309
873
  }[];
310
874
  name: string;
875
+ id: string;
311
876
  version: {
312
877
  major: number;
313
878
  minor: number;
314
879
  patch: number;
315
880
  };
316
- id: string;
317
881
  stability: "alpha" | "experimental" | "stable" | "beta";
318
882
  description?: string | undefined;
319
883
  events?: {
@@ -350,6 +914,7 @@ declare class SchemaRegistry {
350
914
  } | undefined;
351
915
  objects?: string[] | undefined;
352
916
  permissions?: string[] | undefined;
917
+ namespace?: string | undefined;
353
918
  extensions?: Record<string, any> | undefined;
354
919
  loading?: {
355
920
  strategy: "parallel" | "eager" | "lazy" | "deferred" | "on-demand";
@@ -486,11 +1051,6 @@ declare class SchemaRegistry {
486
1051
  } | undefined;
487
1052
  contributes?: {
488
1053
  events?: string[] | undefined;
489
- fieldTypes?: {
490
- label: string;
491
- name: string;
492
- description?: string | undefined;
493
- }[] | undefined;
494
1054
  actions?: {
495
1055
  name: string;
496
1056
  label?: string | undefined;
@@ -498,6 +1058,11 @@ declare class SchemaRegistry {
498
1058
  input?: any;
499
1059
  output?: any;
500
1060
  }[] | undefined;
1061
+ fieldTypes?: {
1062
+ label: string;
1063
+ name: string;
1064
+ description?: string | undefined;
1065
+ }[] | undefined;
501
1066
  drivers?: {
502
1067
  label: string;
503
1068
  id: string;
@@ -541,25 +1106,22 @@ declare class SchemaRegistry {
541
1106
  /**
542
1107
  * Universal List Method
543
1108
  */
544
- static listItems<T>(type: string): T[];
1109
+ static listItems<T>(type: string, packageId?: string): T[];
545
1110
  /**
546
1111
  * Get all registered metadata types (Kinds)
547
1112
  */
548
1113
  static getRegisteredTypes(): string[];
549
- /**
550
- * Object Helpers
551
- */
552
- static registerObject(schema: ServiceObject): void;
553
- static getObject(name: string): ServiceObject | undefined;
554
- static getAllObjects(): ServiceObject[];
555
- /**
556
- * Plugin Helpers
557
- */
1114
+ static installPackage(manifest: ObjectStackManifest, settings?: Record<string, any>): InstalledPackage;
1115
+ static uninstallPackage(id: string): boolean;
1116
+ static getPackage(id: string): InstalledPackage | undefined;
1117
+ static getAllPackages(): InstalledPackage[];
1118
+ static enablePackage(id: string): InstalledPackage | undefined;
1119
+ static disablePackage(id: string): InstalledPackage | undefined;
1120
+ static registerApp(app: any, packageId?: string): void;
1121
+ static getApp(name: string): any;
1122
+ static getAllApps(): any[];
558
1123
  static registerPlugin(manifest: ObjectStackManifest): void;
559
1124
  static getAllPlugins(): ObjectStackManifest[];
560
- /**
561
- * Kind (Metadata Type) Helpers
562
- */
563
1125
  static registerKind(kind: {
564
1126
  id: string;
565
1127
  globs: string[];
@@ -568,6 +1130,10 @@ declare class SchemaRegistry {
568
1130
  id: string;
569
1131
  globs: string[];
570
1132
  }[];
1133
+ /**
1134
+ * Clear all registry state. Use only for testing.
1135
+ */
1136
+ static reset(): void;
571
1137
  }
572
1138
 
573
1139
  declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
@@ -595,6 +1161,7 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
595
1161
  }>;
596
1162
  getMetaItems(request: {
597
1163
  type: string;
1164
+ packageId?: string;
598
1165
  }): Promise<{
599
1166
  type: string;
600
1167
  items: unknown[];
@@ -610,7 +1177,42 @@ declare class ObjectStackProtocolImplementation implements ObjectStackProtocol {
610
1177
  getUiView(request: {
611
1178
  object: string;
612
1179
  type: 'list' | 'form';
613
- }): Promise<any>;
1180
+ }): Promise<{
1181
+ list: {
1182
+ type: "grid";
1183
+ object: string;
1184
+ label: string;
1185
+ columns: {
1186
+ field: string;
1187
+ label: string;
1188
+ sortable: boolean;
1189
+ }[];
1190
+ sort: any;
1191
+ searchableFields: string[];
1192
+ };
1193
+ form?: undefined;
1194
+ } | {
1195
+ form: {
1196
+ type: "simple";
1197
+ object: string;
1198
+ label: string;
1199
+ sections: {
1200
+ label: string;
1201
+ columns: 2;
1202
+ collapsible: boolean;
1203
+ collapsed: boolean;
1204
+ fields: {
1205
+ field: string;
1206
+ label: string | undefined;
1207
+ required: boolean;
1208
+ readonly: boolean;
1209
+ type: "number" | "boolean" | "tags" | "code" | "email" | "date" | "lookup" | "text" | "textarea" | "url" | "phone" | "password" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "time" | "toggle" | "select" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "image" | "file" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "location" | "address" | "json" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
1210
+ colSpan: number;
1211
+ }[];
1212
+ }[];
1213
+ };
1214
+ list?: undefined;
1215
+ }>;
614
1216
  findData(request: {
615
1217
  object: string;
616
1218
  query?: any;
@@ -736,6 +1338,13 @@ declare class ObjectQL implements IDataEngine {
736
1338
  triggerHooks(event: string, context: HookContext): Promise<void>;
737
1339
  /**
738
1340
  * Register contribution (Manifest)
1341
+ *
1342
+ * Installs the manifest as a Package (the unit of installation),
1343
+ * then decomposes it into individual metadata items (objects, apps, actions, etc.)
1344
+ * and registers each into the SchemaRegistry.
1345
+ *
1346
+ * Key: Package ≠ App. The manifest is the package. The apps[] array inside
1347
+ * the manifest contains UI navigation definitions (AppSchema).
739
1348
  */
740
1349
  registerApp(manifest: any): void;
741
1350
  /**
@@ -950,6 +1559,66 @@ declare class ObjectQL implements IDataEngine {
950
1559
  destination: string;
951
1560
  } | undefined;
952
1561
  validations?: any[] | undefined;
1562
+ stateMachine?: {
1563
+ initial: string;
1564
+ states: Record<string, StateNodeConfig>;
1565
+ id: string;
1566
+ on?: Record<string, string | {
1567
+ target?: string | undefined;
1568
+ description?: string | undefined;
1569
+ cond?: string | {
1570
+ type: string;
1571
+ params?: Record<string, any> | undefined;
1572
+ } | undefined;
1573
+ actions?: (string | {
1574
+ type: string;
1575
+ params?: Record<string, any> | undefined;
1576
+ })[] | undefined;
1577
+ } | {
1578
+ target?: string | undefined;
1579
+ description?: string | undefined;
1580
+ cond?: string | {
1581
+ type: string;
1582
+ params?: Record<string, any> | undefined;
1583
+ } | undefined;
1584
+ actions?: (string | {
1585
+ type: string;
1586
+ params?: Record<string, any> | undefined;
1587
+ })[] | undefined;
1588
+ }[]> | undefined;
1589
+ description?: string | undefined;
1590
+ contextSchema?: Record<string, any> | undefined;
1591
+ } | undefined;
1592
+ stateMachines?: Record<string, {
1593
+ initial: string;
1594
+ states: Record<string, StateNodeConfig>;
1595
+ id: string;
1596
+ on?: Record<string, string | {
1597
+ target?: string | undefined;
1598
+ description?: string | undefined;
1599
+ cond?: string | {
1600
+ type: string;
1601
+ params?: Record<string, any> | undefined;
1602
+ } | undefined;
1603
+ actions?: (string | {
1604
+ type: string;
1605
+ params?: Record<string, any> | undefined;
1606
+ })[] | undefined;
1607
+ } | {
1608
+ target?: string | undefined;
1609
+ description?: string | undefined;
1610
+ cond?: string | {
1611
+ type: string;
1612
+ params?: Record<string, any> | undefined;
1613
+ } | undefined;
1614
+ actions?: (string | {
1615
+ type: string;
1616
+ params?: Record<string, any> | undefined;
1617
+ })[] | undefined;
1618
+ }[]> | undefined;
1619
+ description?: string | undefined;
1620
+ contextSchema?: Record<string, any> | undefined;
1621
+ }> | undefined;
953
1622
  titleFormat?: string | undefined;
954
1623
  compactLayout?: string[] | undefined;
955
1624
  enable?: {
@@ -962,9 +1631,20 @@ declare class ObjectQL implements IDataEngine {
962
1631
  trash: boolean;
963
1632
  mru: boolean;
964
1633
  clone: boolean;
965
- apiMethods?: ("search" | "update" | "delete" | "get" | "list" | "create" | "upsert" | "bulk" | "aggregate" | "history" | "restore" | "purge" | "import" | "export")[] | undefined;
1634
+ apiMethods?: ("search" | "update" | "delete" | "history" | "get" | "list" | "create" | "upsert" | "bulk" | "aggregate" | "restore" | "purge" | "import" | "export")[] | undefined;
966
1635
  } | undefined;
967
1636
  } | undefined;
1637
+ /**
1638
+ * Resolve an object name to its Fully Qualified Name (FQN).
1639
+ *
1640
+ * Short names like 'task' are resolved to FQN like 'todo__task'
1641
+ * via SchemaRegistry lookup. If no match is found, the name is
1642
+ * returned as-is (for ad-hoc / unregistered objects).
1643
+ *
1644
+ * This ensures that all driver operations use a consistent key
1645
+ * regardless of whether the caller uses the short name or FQN.
1646
+ */
1647
+ private resolveObjectName;
968
1648
  /**
969
1649
  * Helper to get the target driver
970
1650
  */
@@ -996,4 +1676,4 @@ declare class ObjectQLPlugin implements Plugin {
996
1676
  start: (ctx: PluginContext) => Promise<void>;
997
1677
  }
998
1678
 
999
- export { type HookHandler, ObjectQL, type ObjectQLHostContext, ObjectQLPlugin, ObjectStackProtocolImplementation, SchemaRegistry };
1679
+ export { DEFAULT_EXTENDER_PRIORITY, DEFAULT_OWNER_PRIORITY, type HookHandler, type ObjectContributor, ObjectQL, type ObjectQLHostContext, ObjectQLPlugin, ObjectStackProtocolImplementation, RESERVED_NAMESPACES, SchemaRegistry, computeFQN, parseFQN };