@objectql/types 4.2.0 → 4.2.2
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/action.d.ts +4 -4
- package/dist/api.d.ts +19 -3
- package/dist/api.js +20 -0
- package/dist/api.js.map +1 -1
- package/dist/app.d.ts +2 -2
- package/dist/application.d.ts +1 -1
- package/dist/context.d.ts +2 -2
- package/dist/driver.d.ts +119 -30
- package/dist/edge.d.ts +86 -0
- package/dist/edge.js +61 -0
- package/dist/edge.js.map +1 -0
- package/dist/field.d.ts +3 -3
- package/dist/formula.js.map +1 -1
- package/dist/gateway.d.ts +3 -3
- package/dist/hook.d.ts +21 -17
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/kernel-service.d.ts +84 -0
- package/dist/kernel-service.js +33 -0
- package/dist/kernel-service.js.map +1 -0
- package/dist/loader.d.ts +1 -1
- package/dist/object.d.ts +15 -1
- package/dist/object.js.map +1 -1
- package/dist/permission.d.ts +5 -5
- package/dist/plugin.d.ts +2 -2
- package/dist/registry.d.ts +5 -5
- package/dist/registry.js +3 -3
- package/dist/registry.js.map +1 -1
- package/dist/repository.d.ts +24 -15
- package/dist/sync.d.ts +184 -0
- package/dist/sync.js +10 -0
- package/dist/sync.js.map +1 -0
- package/dist/validation.d.ts +11 -11
- package/dist/workflow.d.ts +11 -11
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -51,4 +51,7 @@ __exportStar(require("./plugin"), exports);
|
|
|
51
51
|
__exportStar(require("./gateway"), exports);
|
|
52
52
|
__exportStar(require("./logger"), exports);
|
|
53
53
|
__exportStar(require("./ai"), exports);
|
|
54
|
+
__exportStar(require("./sync"), exports);
|
|
55
|
+
__exportStar(require("./edge"), exports);
|
|
56
|
+
__exportStar(require("./kernel-service"), exports);
|
|
54
57
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH;;;;;;GAMG;AACH,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,uCAAqB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH;;;;;;GAMG;AACH,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,wCAAsB;AACtB,2CAAyB;AACzB,4CAA0B;AAC1B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,gDAA8B;AAC9B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B;AAC3B,4CAA0B;AAC1B,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB;AACzB,uCAAqB;AACrB,yCAAuB;AACvB,yCAAuB;AACvB,mDAAiC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Kernel Service Types
|
|
10
|
+
*
|
|
11
|
+
* Defines the 17 kernel services specified by the ObjectStack protocol.
|
|
12
|
+
* Each service maps to a set of protocol methods governed by the ObjectStackProtocol interface.
|
|
13
|
+
*
|
|
14
|
+
* @see https://protocol.objectstack.ai/docs/guides/kernel-services
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The 17 kernel services registered via CoreServiceName.
|
|
18
|
+
* Each service maps to a set of protocol methods.
|
|
19
|
+
*/
|
|
20
|
+
export type CoreServiceName = 'metadata' | 'data' | 'analytics' | 'auth' | 'ui' | 'workflow' | 'automation' | 'realtime' | 'notification' | 'ai' | 'i18n' | 'file-storage' | 'search' | 'cache' | 'queue' | 'job' | 'graphql';
|
|
21
|
+
/**
|
|
22
|
+
* Criticality levels for kernel services.
|
|
23
|
+
* - required: System cannot start without this service
|
|
24
|
+
* - core: Falls back to in-memory implementation with a warning if missing
|
|
25
|
+
* - optional: Feature disabled; API returns 501 Not Implemented if missing
|
|
26
|
+
*/
|
|
27
|
+
export type ServiceCriticality = 'required' | 'core' | 'optional';
|
|
28
|
+
/**
|
|
29
|
+
* Service availability status reported via the discovery endpoint.
|
|
30
|
+
*/
|
|
31
|
+
export type ServiceStatusValue = 'available' | 'degraded' | 'unavailable';
|
|
32
|
+
/**
|
|
33
|
+
* Per-service status entry in the discovery response.
|
|
34
|
+
*/
|
|
35
|
+
export interface ServiceStatus {
|
|
36
|
+
/** Whether the service is enabled */
|
|
37
|
+
readonly enabled: boolean;
|
|
38
|
+
/** Current operational status */
|
|
39
|
+
readonly status: ServiceStatusValue;
|
|
40
|
+
/** Route mount point (if available) */
|
|
41
|
+
readonly route?: string;
|
|
42
|
+
/** Provider name (e.g., 'kernel', plugin name) */
|
|
43
|
+
readonly provider?: string;
|
|
44
|
+
/** Human-readable status message */
|
|
45
|
+
readonly message?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Service criticality mapping per the kernel-services specification.
|
|
49
|
+
*/
|
|
50
|
+
export declare const SERVICE_CRITICALITY: Readonly<Record<CoreServiceName, ServiceCriticality>>;
|
|
51
|
+
/**
|
|
52
|
+
* Discovery response structure returned by getDiscovery.
|
|
53
|
+
* Clients use this to determine which services are available and adapt UI accordingly.
|
|
54
|
+
*/
|
|
55
|
+
export interface KernelDiscoveryResponse {
|
|
56
|
+
/** Engine name */
|
|
57
|
+
readonly name: string;
|
|
58
|
+
/** API name identifier for the spec discovery endpoint */
|
|
59
|
+
readonly apiName: string;
|
|
60
|
+
/** Engine version */
|
|
61
|
+
readonly version: string;
|
|
62
|
+
/** Supported protocol transports */
|
|
63
|
+
readonly protocols: readonly string[];
|
|
64
|
+
/** Per-service status map */
|
|
65
|
+
readonly services: Readonly<Record<CoreServiceName, ServiceStatus>>;
|
|
66
|
+
/** Optional capabilities flags */
|
|
67
|
+
readonly capabilities?: {
|
|
68
|
+
readonly search: boolean;
|
|
69
|
+
readonly files: boolean;
|
|
70
|
+
readonly graphql: boolean;
|
|
71
|
+
readonly notifications: boolean;
|
|
72
|
+
readonly analytics: boolean;
|
|
73
|
+
readonly ai: boolean;
|
|
74
|
+
readonly i18n: boolean;
|
|
75
|
+
readonly workflow: boolean;
|
|
76
|
+
readonly websockets: boolean;
|
|
77
|
+
};
|
|
78
|
+
/** Optional endpoint URLs */
|
|
79
|
+
readonly endpoints?: {
|
|
80
|
+
readonly rest?: string;
|
|
81
|
+
readonly graphql?: string;
|
|
82
|
+
readonly websocket?: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ObjectQL
|
|
4
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SERVICE_CRITICALITY = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Service criticality mapping per the kernel-services specification.
|
|
13
|
+
*/
|
|
14
|
+
exports.SERVICE_CRITICALITY = {
|
|
15
|
+
metadata: 'required',
|
|
16
|
+
data: 'required',
|
|
17
|
+
analytics: 'optional',
|
|
18
|
+
auth: 'required',
|
|
19
|
+
ui: 'optional',
|
|
20
|
+
workflow: 'optional',
|
|
21
|
+
automation: 'optional',
|
|
22
|
+
realtime: 'optional',
|
|
23
|
+
notification: 'optional',
|
|
24
|
+
ai: 'optional',
|
|
25
|
+
i18n: 'optional',
|
|
26
|
+
'file-storage': 'optional',
|
|
27
|
+
search: 'optional',
|
|
28
|
+
cache: 'core',
|
|
29
|
+
queue: 'core',
|
|
30
|
+
job: 'core',
|
|
31
|
+
graphql: 'optional',
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=kernel-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel-service.js","sourceRoot":"","sources":["../src/kernel-service.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA+DH;;GAEG;AACU,QAAA,mBAAmB,GAA0D;IACtF,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,UAAU;IAChB,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,UAAU;IAChB,EAAE,EAAE,UAAU;IACd,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,UAAU;IACtB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,UAAU;IACxB,EAAE,EAAE,UAAU;IACd,IAAI,EAAE,UAAU;IAChB,cAAc,EAAE,UAAU;IAC1B,MAAM,EAAE,UAAU;IAClB,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,UAAU;CACtB,CAAC"}
|
package/dist/loader.d.ts
CHANGED
package/dist/object.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { z } from 'zod';
|
|
|
10
10
|
import { FieldConfig } from './field';
|
|
11
11
|
import { ActionConfig } from './action';
|
|
12
12
|
import { AnyValidationRule } from './validation';
|
|
13
|
+
import { SyncConfig } from './sync';
|
|
13
14
|
/**
|
|
14
15
|
* Re-export Protocol Types from @objectstack/spec 1.1.0
|
|
15
16
|
* State Machine, Object Ownership, and Object Extension types.
|
|
@@ -145,6 +146,19 @@ export interface ObjectConfig {
|
|
|
145
146
|
validation_strategy?: string;
|
|
146
147
|
};
|
|
147
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Offline-First Sync configuration (RUNTIME ONLY).
|
|
151
|
+
* Opt-in per object. See {@link SyncConfig} for details.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```yaml
|
|
155
|
+
* sync:
|
|
156
|
+
* enabled: true
|
|
157
|
+
* strategy: last-write-wins
|
|
158
|
+
* conflict_fields: [status]
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
sync?: SyncConfig;
|
|
148
162
|
}
|
|
149
163
|
/**
|
|
150
164
|
* Base interface for all ObjectQL documents.
|
|
@@ -155,5 +169,5 @@ export interface ObjectDoc {
|
|
|
155
169
|
_id?: string | number;
|
|
156
170
|
created_at?: Date | string;
|
|
157
171
|
updated_at?: Date | string;
|
|
158
|
-
[key: string]:
|
|
172
|
+
[key: string]: unknown;
|
|
159
173
|
}
|
package/dist/object.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,4CAAqD;
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../src/object.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,4CAAqD;AAoB5C,qFApBA,WAAI,OAoBA;AAAE,2FApBA,iBAAU,OAoBA"}
|
package/dist/permission.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface SimpleCondition {
|
|
|
70
70
|
/** Comparison operator */
|
|
71
71
|
operator: PermissionOperator;
|
|
72
72
|
/** Value to compare against (can include variables like $current_user.id) */
|
|
73
|
-
value:
|
|
73
|
+
value: unknown;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Simple condition element (inline form for complex expressions)
|
|
@@ -78,7 +78,7 @@ export interface SimpleCondition {
|
|
|
78
78
|
export interface ConditionElement {
|
|
79
79
|
field: string;
|
|
80
80
|
operator: PermissionOperator;
|
|
81
|
-
value:
|
|
81
|
+
value: unknown;
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Expression element in complex conditions
|
|
@@ -208,7 +208,7 @@ export interface ActionCondition {
|
|
|
208
208
|
/** Comparison operator */
|
|
209
209
|
operator: PermissionOperator;
|
|
210
210
|
/** Value to compare */
|
|
211
|
-
value:
|
|
211
|
+
value: unknown;
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Rate limiting configuration for actions
|
|
@@ -372,7 +372,7 @@ export interface PermissionCheckContext {
|
|
|
372
372
|
roles?: string[];
|
|
373
373
|
department_id?: string;
|
|
374
374
|
team_id?: string;
|
|
375
|
-
[key: string]:
|
|
375
|
+
[key: string]: unknown;
|
|
376
376
|
};
|
|
377
377
|
/** Object name */
|
|
378
378
|
object: string;
|
|
@@ -383,7 +383,7 @@ export interface PermissionCheckContext {
|
|
|
383
383
|
/** Field name (for field-level checks) */
|
|
384
384
|
field?: string;
|
|
385
385
|
/** Record data (for condition evaluation) */
|
|
386
|
-
record?:
|
|
386
|
+
record?: Record<string, unknown>;
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
389
|
* Result of a permission check
|
package/dist/plugin.d.ts
CHANGED
|
@@ -21,12 +21,12 @@ export interface RuntimeContext {
|
|
|
21
21
|
* - action manager
|
|
22
22
|
* - CRUD operations
|
|
23
23
|
*/
|
|
24
|
-
engine:
|
|
24
|
+
engine: unknown;
|
|
25
25
|
/**
|
|
26
26
|
* Get the kernel instance (alternative accessor)
|
|
27
27
|
* Some implementations may use getKernel() instead of engine
|
|
28
28
|
*/
|
|
29
|
-
getKernel?: () =>
|
|
29
|
+
getKernel?: () => unknown;
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* RuntimePlugin Interface
|
package/dist/registry.d.ts
CHANGED
|
@@ -16,11 +16,11 @@ export declare class MetadataRegistry {
|
|
|
16
16
|
private items;
|
|
17
17
|
private packageIndex;
|
|
18
18
|
constructor();
|
|
19
|
-
register(type: string, nameOrConfig:
|
|
20
|
-
get<T =
|
|
21
|
-
list<T =
|
|
19
|
+
register(type: string, nameOrConfig: string | Record<string, unknown>, config?: Record<string, unknown>): void;
|
|
20
|
+
get<T = unknown>(type: string, name: string): T;
|
|
21
|
+
list<T = unknown>(type: string): T[];
|
|
22
22
|
getTypes(): string[];
|
|
23
|
-
getEntry<T =
|
|
23
|
+
getEntry<T = unknown>(type: string, name: string): T;
|
|
24
24
|
unregister(type: string, name: string): void;
|
|
25
25
|
/**
|
|
26
26
|
* Optimized package unregistration with O(k) complexity
|
|
@@ -31,7 +31,7 @@ export declare class MetadataRegistry {
|
|
|
31
31
|
*/
|
|
32
32
|
unregisterPackage(packageName: string): void;
|
|
33
33
|
}
|
|
34
|
-
export type MetadataItem =
|
|
34
|
+
export type MetadataItem = Record<string, unknown>;
|
|
35
35
|
/**
|
|
36
36
|
* Legacy Metadata interface - kept for backward compatibility
|
|
37
37
|
* @deprecated Use MetadataItem from @objectstack/runtime instead
|
package/dist/registry.js
CHANGED
|
@@ -33,12 +33,12 @@ class MetadataRegistry {
|
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
item = nameOrConfig;
|
|
36
|
-
name = item.name || item.id;
|
|
36
|
+
name = (item.name || item.id);
|
|
37
37
|
}
|
|
38
38
|
if (name) {
|
|
39
39
|
this.items[type][name] = item;
|
|
40
40
|
// Update package index
|
|
41
|
-
const packageName = item.package || item._package || item.packageName;
|
|
41
|
+
const packageName = (item.package || item._package || item.packageName);
|
|
42
42
|
if (packageName) {
|
|
43
43
|
if (!this.packageIndex.has(packageName)) {
|
|
44
44
|
this.packageIndex.set(packageName, new Set());
|
|
@@ -77,7 +77,7 @@ class MetadataRegistry {
|
|
|
77
77
|
const item = (_a = this.items[type]) === null || _a === void 0 ? void 0 : _a[name];
|
|
78
78
|
if (item) {
|
|
79
79
|
// Update package index
|
|
80
|
-
const packageName = item.package || item._package || item.packageName;
|
|
80
|
+
const packageName = (item.package || item._package || item.packageName);
|
|
81
81
|
if (packageName) {
|
|
82
82
|
const refs = this.packageIndex.get(packageName);
|
|
83
83
|
if (refs) {
|
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAUH;;;;;;GAMG;AACH,MAAa,gBAAgB;IAMzB;QALQ,UAAK,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAUH;;;;;;GAMG;AACH,MAAa,gBAAgB;IAMzB;QALQ,UAAK,GAA4D,EAAE,CAAC;QAE5E,+DAA+D;QACvD,iBAAY,GAAG,IAAI,GAAG,EAA4B,CAAC;IAE5C,CAAC;IAEhB,QAAQ,CAAC,IAAY,EAAE,YAA8C,EAAE,MAAgC;QACnG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;QAED,IAAI,IAAY,CAAC;QACjB,IAAI,IAA6B,CAAC;QAElC,IAAI,MAAM,EAAE,CAAC;YACT,IAAI,GAAG,YAAsB,CAAC;YAC9B,IAAI,GAAG,MAAM,CAAC;QAClB,CAAC;aAAM,CAAC;YACJ,IAAI,GAAG,YAAuC,CAAC;YAC/C,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI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AiB,CAAC,WAAmB;;QACjC,sCAAsC;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,IAAI,EAAE,CAAC;YACP,8CAA8C;YAC9C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,MAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,0CAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;oBACnC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC1C,CAAC;YACL,CAAC;YACD,4BAA4B;YAC5B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;CACJ;AA9GD,4CA8GC"}
|
package/dist/repository.d.ts
CHANGED
|
@@ -5,19 +5,28 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
-
import { UnifiedQuery } from "./query";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
import { UnifiedQuery, Filter } from "./query";
|
|
9
|
+
/**
|
|
10
|
+
* Repository interface for CRUD operations on a single object type.
|
|
11
|
+
*
|
|
12
|
+
* Note: `object` is used for filter/query parameters instead of `Record<string, unknown>`
|
|
13
|
+
* because named TypeScript interfaces (e.g., UnifiedQuery, Filter) lack implicit index
|
|
14
|
+
* signatures and are not assignable to `Record<string, unknown>`.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam T - The document shape returned by queries. Defaults to `Record<string, unknown>`.
|
|
17
|
+
*/
|
|
18
|
+
export interface IObjectRepository<T = Record<string, unknown>> {
|
|
19
|
+
find(query?: UnifiedQuery): Promise<T[]>;
|
|
20
|
+
findOne(idOrQuery: string | number | UnifiedQuery): Promise<T | null>;
|
|
21
|
+
count(filters: Filter | object): Promise<number>;
|
|
22
|
+
create(doc: Record<string, unknown>): Promise<T>;
|
|
23
|
+
update(id: string | number, doc: Record<string, unknown>, options?: Record<string, unknown>): Promise<T>;
|
|
24
|
+
delete(id: string | number): Promise<T>;
|
|
25
|
+
aggregate(query: object): Promise<unknown[]>;
|
|
26
|
+
distinct(field: string, filters?: Filter | object): Promise<unknown[]>;
|
|
27
|
+
findOneAndUpdate?(filters: Filter | object, update: Record<string, unknown>, options?: Record<string, unknown>): Promise<T | null>;
|
|
28
|
+
createMany(data: Record<string, unknown>[]): Promise<T[]>;
|
|
29
|
+
updateMany(filters: Filter | object, data: Record<string, unknown>): Promise<unknown>;
|
|
30
|
+
deleteMany(filters: Filter | object): Promise<unknown>;
|
|
31
|
+
execute(actionName: string, id: string | number | undefined, params: Record<string, unknown>): Promise<unknown>;
|
|
23
32
|
}
|
package/dist/sync.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Sync conflict resolution strategy.
|
|
10
|
+
*
|
|
11
|
+
* - `last-write-wins`: Server accepts the most recent mutation based on timestamp.
|
|
12
|
+
* - `crdt`: Conflict-free Replicated Data Type — field-level merge without conflicts.
|
|
13
|
+
* - `manual`: Conflicts are flagged for manual resolution via a callback.
|
|
14
|
+
*/
|
|
15
|
+
export type SyncStrategy = 'last-write-wins' | 'crdt' | 'manual';
|
|
16
|
+
/**
|
|
17
|
+
* Per-object sync configuration.
|
|
18
|
+
*
|
|
19
|
+
* Declared in `*.object.yml` under the `sync` key. Opt-in per object.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```yaml
|
|
23
|
+
* name: story
|
|
24
|
+
* sync:
|
|
25
|
+
* enabled: true
|
|
26
|
+
* strategy: last-write-wins
|
|
27
|
+
* conflict_fields: [status]
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export interface SyncConfig {
|
|
31
|
+
/** Enable offline sync for this object. Default: false */
|
|
32
|
+
readonly enabled: boolean;
|
|
33
|
+
/** Conflict resolution strategy. Default: 'last-write-wins' */
|
|
34
|
+
readonly strategy?: SyncStrategy;
|
|
35
|
+
/**
|
|
36
|
+
* Fields requiring manual merge when strategy is 'last-write-wins'.
|
|
37
|
+
* Changes to these fields during concurrent edits trigger a conflict.
|
|
38
|
+
*/
|
|
39
|
+
readonly conflict_fields?: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* Sync direction.
|
|
42
|
+
* - `bidirectional`: Client ↔ Server (default)
|
|
43
|
+
* - `push-only`: Client → Server
|
|
44
|
+
* - `pull-only`: Server → Client
|
|
45
|
+
*/
|
|
46
|
+
readonly direction?: 'bidirectional' | 'push-only' | 'pull-only';
|
|
47
|
+
/**
|
|
48
|
+
* Debounce interval in milliseconds before syncing mutations.
|
|
49
|
+
* Batches rapid mutations into a single sync request.
|
|
50
|
+
* Default: 1000
|
|
51
|
+
*/
|
|
52
|
+
readonly debounce_ms?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Maximum number of mutations to batch in a single sync request.
|
|
55
|
+
* Default: 50
|
|
56
|
+
*/
|
|
57
|
+
readonly batch_size?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Mutation operation type recorded in the client-side mutation log.
|
|
61
|
+
*/
|
|
62
|
+
export type MutationOperation = 'create' | 'update' | 'delete';
|
|
63
|
+
/**
|
|
64
|
+
* A single entry in the client-side append-only mutation log.
|
|
65
|
+
*
|
|
66
|
+
* Recorded by WASM drivers when offline. Replayed to the server
|
|
67
|
+
* during sync to achieve eventual consistency.
|
|
68
|
+
*/
|
|
69
|
+
export interface MutationLogEntry {
|
|
70
|
+
/** Unique mutation identifier (UUID v7 for time-ordered sorting) */
|
|
71
|
+
readonly id: string;
|
|
72
|
+
/** Object name this mutation applies to */
|
|
73
|
+
readonly objectName: string;
|
|
74
|
+
/** Record identifier */
|
|
75
|
+
readonly recordId: string | number;
|
|
76
|
+
/** Type of mutation */
|
|
77
|
+
readonly operation: MutationOperation;
|
|
78
|
+
/**
|
|
79
|
+
* The mutation payload.
|
|
80
|
+
* - `create`: Full record data.
|
|
81
|
+
* - `update`: Partial field updates (only changed fields).
|
|
82
|
+
* - `delete`: undefined.
|
|
83
|
+
*/
|
|
84
|
+
readonly data?: Record<string, unknown>;
|
|
85
|
+
/** ISO 8601 timestamp when the mutation was recorded on the client */
|
|
86
|
+
readonly timestamp: string;
|
|
87
|
+
/** Client device identifier for multi-device conflict resolution */
|
|
88
|
+
readonly clientId: string;
|
|
89
|
+
/** Monotonically increasing sequence number per client */
|
|
90
|
+
readonly sequence: number;
|
|
91
|
+
/**
|
|
92
|
+
* Server-assigned version of the record at the time of mutation.
|
|
93
|
+
* Used for optimistic concurrency during sync.
|
|
94
|
+
* `null` for new records created offline.
|
|
95
|
+
*/
|
|
96
|
+
readonly baseVersion: number | null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Conflict descriptor returned when the server detects a merge conflict.
|
|
100
|
+
*/
|
|
101
|
+
export interface SyncConflict {
|
|
102
|
+
/** Object name */
|
|
103
|
+
readonly objectName: string;
|
|
104
|
+
/** Record identifier */
|
|
105
|
+
readonly recordId: string | number;
|
|
106
|
+
/** The client's mutation that caused the conflict */
|
|
107
|
+
readonly clientMutation: MutationLogEntry;
|
|
108
|
+
/** Current server-side record state */
|
|
109
|
+
readonly serverRecord: Record<string, unknown>;
|
|
110
|
+
/** Fields that are in conflict */
|
|
111
|
+
readonly conflictingFields: readonly string[];
|
|
112
|
+
/** Suggested resolution (server-computed) */
|
|
113
|
+
readonly suggestedResolution?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Outcome of a single mutation during sync.
|
|
117
|
+
*/
|
|
118
|
+
export type SyncMutationResult = {
|
|
119
|
+
readonly status: 'applied';
|
|
120
|
+
readonly serverVersion: number;
|
|
121
|
+
} | {
|
|
122
|
+
readonly status: 'conflict';
|
|
123
|
+
readonly conflict: SyncConflict;
|
|
124
|
+
} | {
|
|
125
|
+
readonly status: 'rejected';
|
|
126
|
+
readonly reason: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Client → Server sync request payload.
|
|
130
|
+
*/
|
|
131
|
+
export interface SyncPushRequest {
|
|
132
|
+
/** Client device identifier */
|
|
133
|
+
readonly clientId: string;
|
|
134
|
+
/** Mutations to push, ordered by sequence number */
|
|
135
|
+
readonly mutations: readonly MutationLogEntry[];
|
|
136
|
+
/**
|
|
137
|
+
* Last server checkpoint the client has seen.
|
|
138
|
+
* The server uses this to determine what changes to send back.
|
|
139
|
+
*/
|
|
140
|
+
readonly lastCheckpoint: string | null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Server → Client sync response payload.
|
|
144
|
+
*/
|
|
145
|
+
export interface SyncPushResponse {
|
|
146
|
+
/** Results for each pushed mutation (same order as request) */
|
|
147
|
+
readonly results: readonly SyncMutationResult[];
|
|
148
|
+
/** Server changes since the client's lastCheckpoint */
|
|
149
|
+
readonly serverChanges: readonly SyncServerChange[];
|
|
150
|
+
/** New checkpoint for the client to store */
|
|
151
|
+
readonly checkpoint: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A server-side change to be applied on the client.
|
|
155
|
+
*/
|
|
156
|
+
export interface SyncServerChange {
|
|
157
|
+
/** Object name */
|
|
158
|
+
readonly objectName: string;
|
|
159
|
+
/** Record identifier */
|
|
160
|
+
readonly recordId: string | number;
|
|
161
|
+
/** Operation that occurred on the server */
|
|
162
|
+
readonly operation: MutationOperation;
|
|
163
|
+
/** Record data (full for create, partial for update, undefined for delete) */
|
|
164
|
+
readonly data?: Record<string, unknown>;
|
|
165
|
+
/** Server version after this change */
|
|
166
|
+
readonly serverVersion: number;
|
|
167
|
+
/** ISO 8601 timestamp of the server change */
|
|
168
|
+
readonly timestamp: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Sync endpoint configuration for the server-side sync service.
|
|
172
|
+
*/
|
|
173
|
+
export interface SyncEndpointConfig {
|
|
174
|
+
/** Enable the sync endpoint. Default: false */
|
|
175
|
+
readonly enabled: boolean;
|
|
176
|
+
/** URL path for the sync endpoint. Default: '/api/sync' */
|
|
177
|
+
readonly path?: string;
|
|
178
|
+
/** Maximum mutations per push request. Default: 100 */
|
|
179
|
+
readonly maxMutationsPerRequest?: number;
|
|
180
|
+
/** Maximum age (in days) for server-side change log retention. Default: 30 */
|
|
181
|
+
readonly changeLogRetentionDays?: number;
|
|
182
|
+
/** Enable WebSocket for real-time push from server. Default: false */
|
|
183
|
+
readonly realtime?: boolean;
|
|
184
|
+
}
|
package/dist/sync.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ObjectQL
|
|
4
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
package/dist/validation.d.ts
CHANGED
|
@@ -43,8 +43,8 @@ export interface ValidationAiContext {
|
|
|
43
43
|
external_dependency?: string;
|
|
44
44
|
/** Examples of valid/invalid data */
|
|
45
45
|
examples?: {
|
|
46
|
-
valid?:
|
|
47
|
-
invalid?:
|
|
46
|
+
valid?: unknown[];
|
|
47
|
+
invalid?: unknown[];
|
|
48
48
|
};
|
|
49
49
|
/** Algorithm description for complex validation */
|
|
50
50
|
algorithm?: string;
|
|
@@ -66,7 +66,7 @@ export interface ValidationCondition {
|
|
|
66
66
|
/** Comparison operator */
|
|
67
67
|
operator?: ValidationOperator;
|
|
68
68
|
/** Value to compare against */
|
|
69
|
-
value?:
|
|
69
|
+
value?: unknown;
|
|
70
70
|
/** Field name to compare against (for cross-field validation) */
|
|
71
71
|
compare_to?: string;
|
|
72
72
|
/** Expression to evaluate */
|
|
@@ -199,7 +199,7 @@ export interface CrossFieldValidationRule extends ValidationRule {
|
|
|
199
199
|
/** Shorthand: Comparison operator (alternative to using rule property) */
|
|
200
200
|
operator?: ValidationOperator;
|
|
201
201
|
/** Shorthand: Value to compare against (mutually exclusive with compare_to) */
|
|
202
|
-
value?:
|
|
202
|
+
value?: unknown;
|
|
203
203
|
/** Shorthand: Field name to compare against for cross-field validation (mutually exclusive with value) */
|
|
204
204
|
compare_to?: string;
|
|
205
205
|
}
|
|
@@ -223,7 +223,7 @@ export interface StateMachineValidationRule extends ValidationRule {
|
|
|
223
223
|
/** Initial states */
|
|
224
224
|
initial_states?: string[];
|
|
225
225
|
/** Transition conditions */
|
|
226
|
-
transition_conditions?: Record<string,
|
|
226
|
+
transition_conditions?: Record<string, unknown>;
|
|
227
227
|
}
|
|
228
228
|
/**
|
|
229
229
|
* Uniqueness validation rule.
|
|
@@ -266,7 +266,7 @@ export interface CustomValidationRule extends ValidationRule {
|
|
|
266
266
|
/** Error message template */
|
|
267
267
|
error_message_template?: string;
|
|
268
268
|
/** Message parameters */
|
|
269
|
-
message_params?: Record<string,
|
|
269
|
+
message_params?: Record<string, unknown>;
|
|
270
270
|
}
|
|
271
271
|
/**
|
|
272
272
|
* Union type for all validation rules.
|
|
@@ -313,18 +313,18 @@ export interface ValidationContext {
|
|
|
313
313
|
/** Previous record data (for updates) */
|
|
314
314
|
previousRecord?: ObjectDoc;
|
|
315
315
|
/** Current user */
|
|
316
|
-
user?:
|
|
316
|
+
user?: unknown;
|
|
317
317
|
/** API access for queries */
|
|
318
|
-
api?:
|
|
318
|
+
api?: unknown;
|
|
319
319
|
/** HTTP client for external calls */
|
|
320
|
-
http?:
|
|
320
|
+
http?: unknown;
|
|
321
321
|
/** Operation type */
|
|
322
322
|
operation: ValidationTrigger;
|
|
323
323
|
/** Additional metadata */
|
|
324
324
|
metadata?: {
|
|
325
325
|
objectName: string;
|
|
326
326
|
ruleName: string;
|
|
327
|
-
[key: string]:
|
|
327
|
+
[key: string]: unknown;
|
|
328
328
|
};
|
|
329
329
|
/** Changed fields (for updates) */
|
|
330
330
|
changedFields?: string[];
|
|
@@ -346,7 +346,7 @@ export interface ValidationRuleResult {
|
|
|
346
346
|
/** Field(s) that failed validation */
|
|
347
347
|
fields?: string[];
|
|
348
348
|
/** Additional context */
|
|
349
|
-
context?:
|
|
349
|
+
context?: unknown;
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
352
352
|
* Overall validation result for a record.
|