@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/action.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export type ActionInputDefinition = Record<string, FieldConfig>;
|
|
|
36
36
|
*
|
|
37
37
|
* RUNTIME TYPE: Used during action execution.
|
|
38
38
|
*/
|
|
39
|
-
export interface ActionContext<
|
|
39
|
+
export interface ActionContext<_BaseT = Record<string, unknown>, InputT = Record<string, unknown>> {
|
|
40
40
|
/** The object this action belongs to. */
|
|
41
41
|
objectName: string;
|
|
42
42
|
/** The name of the action being executed. */
|
|
@@ -59,7 +59,7 @@ export interface ActionContext<BaseT = any, InputT = any> {
|
|
|
59
59
|
*/
|
|
60
60
|
user?: {
|
|
61
61
|
id: string | number;
|
|
62
|
-
[key: string]:
|
|
62
|
+
[key: string]: unknown;
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
@@ -101,10 +101,10 @@ export interface ActionConfig {
|
|
|
101
101
|
*
|
|
102
102
|
* RUNTIME TYPE: Includes the handler function for execution.
|
|
103
103
|
*/
|
|
104
|
-
export interface ActionDefinition<BaseT =
|
|
104
|
+
export interface ActionDefinition<BaseT = Record<string, unknown>, InputT = Record<string, unknown>, ReturnT = unknown> extends ActionConfig {
|
|
105
105
|
/**
|
|
106
106
|
* The business logic implementation.
|
|
107
107
|
*/
|
|
108
108
|
handler: (ctx: ActionContext<BaseT, InputT>) => Promise<ReturnT>;
|
|
109
109
|
}
|
|
110
|
-
export type ActionHandler<BaseT =
|
|
110
|
+
export type ActionHandler<BaseT = Record<string, unknown>, InputT = Record<string, unknown>, ReturnT = unknown> = (ctx: ActionContext<BaseT, InputT>) => Promise<ReturnT>;
|
package/dist/api.d.ts
CHANGED
|
@@ -27,7 +27,23 @@ export declare enum ApiErrorCode {
|
|
|
27
27
|
CONFLICT = "CONFLICT",
|
|
28
28
|
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
29
29
|
DATABASE_ERROR = "DATABASE_ERROR",
|
|
30
|
-
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED"
|
|
30
|
+
RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
|
|
31
|
+
DRIVER_ERROR = "DRIVER_ERROR",
|
|
32
|
+
DRIVER_CONNECTION_FAILED = "DRIVER_CONNECTION_FAILED",
|
|
33
|
+
DRIVER_QUERY_FAILED = "DRIVER_QUERY_FAILED",
|
|
34
|
+
DRIVER_TRANSACTION_FAILED = "DRIVER_TRANSACTION_FAILED",
|
|
35
|
+
DRIVER_UNSUPPORTED_OPERATION = "DRIVER_UNSUPPORTED_OPERATION",
|
|
36
|
+
PROTOCOL_ERROR = "PROTOCOL_ERROR",
|
|
37
|
+
PROTOCOL_INVALID_REQUEST = "PROTOCOL_INVALID_REQUEST",
|
|
38
|
+
PROTOCOL_METHOD_NOT_FOUND = "PROTOCOL_METHOD_NOT_FOUND",
|
|
39
|
+
PROTOCOL_BATCH_ERROR = "PROTOCOL_BATCH_ERROR",
|
|
40
|
+
TENANT_ISOLATION_VIOLATION = "TENANT_ISOLATION_VIOLATION",
|
|
41
|
+
TENANT_NOT_FOUND = "TENANT_NOT_FOUND",
|
|
42
|
+
WORKFLOW_TRANSITION_DENIED = "WORKFLOW_TRANSITION_DENIED",
|
|
43
|
+
FORMULA_EVALUATION_ERROR = "FORMULA_EVALUATION_ERROR",
|
|
44
|
+
CONFIG_ERROR = "CONFIG_ERROR",
|
|
45
|
+
SCAFFOLD_ERROR = "SCAFFOLD_ERROR",
|
|
46
|
+
MIGRATION_ERROR = "MIGRATION_ERROR"
|
|
31
47
|
}
|
|
32
48
|
/**
|
|
33
49
|
* Error details structure with optional field-specific information
|
|
@@ -79,7 +95,7 @@ export interface PaginationMeta {
|
|
|
79
95
|
/**
|
|
80
96
|
* Base response structure for Data API operations
|
|
81
97
|
*/
|
|
82
|
-
export interface DataApiResponse<
|
|
98
|
+
export interface DataApiResponse<_T = unknown> {
|
|
83
99
|
/** Error information if the operation failed */
|
|
84
100
|
error?: ApiError;
|
|
85
101
|
/** Additional response fields for successful operations */
|
|
@@ -185,7 +201,7 @@ export interface DataApiDeleteResponse extends DataApiResponse {
|
|
|
185
201
|
/**
|
|
186
202
|
* Base response structure for Metadata API operations
|
|
187
203
|
*/
|
|
188
|
-
export interface MetadataApiResponse<
|
|
204
|
+
export interface MetadataApiResponse<_T = unknown> {
|
|
189
205
|
/** Error information if the operation failed */
|
|
190
206
|
error?: ApiError;
|
|
191
207
|
/** Additional response fields */
|
package/dist/api.js
CHANGED
|
@@ -26,6 +26,26 @@ var ApiErrorCode;
|
|
|
26
26
|
ApiErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
27
27
|
ApiErrorCode["DATABASE_ERROR"] = "DATABASE_ERROR";
|
|
28
28
|
ApiErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
|
|
29
|
+
// Driver error codes
|
|
30
|
+
ApiErrorCode["DRIVER_ERROR"] = "DRIVER_ERROR";
|
|
31
|
+
ApiErrorCode["DRIVER_CONNECTION_FAILED"] = "DRIVER_CONNECTION_FAILED";
|
|
32
|
+
ApiErrorCode["DRIVER_QUERY_FAILED"] = "DRIVER_QUERY_FAILED";
|
|
33
|
+
ApiErrorCode["DRIVER_TRANSACTION_FAILED"] = "DRIVER_TRANSACTION_FAILED";
|
|
34
|
+
ApiErrorCode["DRIVER_UNSUPPORTED_OPERATION"] = "DRIVER_UNSUPPORTED_OPERATION";
|
|
35
|
+
// Protocol error codes
|
|
36
|
+
ApiErrorCode["PROTOCOL_ERROR"] = "PROTOCOL_ERROR";
|
|
37
|
+
ApiErrorCode["PROTOCOL_INVALID_REQUEST"] = "PROTOCOL_INVALID_REQUEST";
|
|
38
|
+
ApiErrorCode["PROTOCOL_METHOD_NOT_FOUND"] = "PROTOCOL_METHOD_NOT_FOUND";
|
|
39
|
+
ApiErrorCode["PROTOCOL_BATCH_ERROR"] = "PROTOCOL_BATCH_ERROR";
|
|
40
|
+
// Plugin error codes
|
|
41
|
+
ApiErrorCode["TENANT_ISOLATION_VIOLATION"] = "TENANT_ISOLATION_VIOLATION";
|
|
42
|
+
ApiErrorCode["TENANT_NOT_FOUND"] = "TENANT_NOT_FOUND";
|
|
43
|
+
ApiErrorCode["WORKFLOW_TRANSITION_DENIED"] = "WORKFLOW_TRANSITION_DENIED";
|
|
44
|
+
ApiErrorCode["FORMULA_EVALUATION_ERROR"] = "FORMULA_EVALUATION_ERROR";
|
|
45
|
+
// CLI/Tool error codes
|
|
46
|
+
ApiErrorCode["CONFIG_ERROR"] = "CONFIG_ERROR";
|
|
47
|
+
ApiErrorCode["SCAFFOLD_ERROR"] = "SCAFFOLD_ERROR";
|
|
48
|
+
ApiErrorCode["MIGRATION_ERROR"] = "MIGRATION_ERROR";
|
|
29
49
|
})(ApiErrorCode || (exports.ApiErrorCode = ApiErrorCode = {}));
|
|
30
50
|
/**
|
|
31
51
|
* ObjectQL Error class for throwing structured errors
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAqlBH,4CASC;AAhlBD,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;GAEG;AACH,IAAY,YAkCX;AAlCD,WAAY,YAAY;IACpB,mDAAmC,CAAA;IACnC,qDAAqC,CAAA;IACrC,6CAA6B,CAAA;IAC7B,uCAAuB,CAAA;IACvB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;IACjC,2DAA2C,CAAA;IAE3C,qBAAqB;IACrB,6CAA6B,CAAA;IAC7B,qEAAqD,CAAA;IACrD,2DAA2C,CAAA;IAC3C,uEAAuD,CAAA;IACvD,6EAA6D,CAAA;IAE7D,uBAAuB;IACvB,iDAAiC,CAAA;IACjC,qEAAqD,CAAA;IACrD,uEAAuD,CAAA;IACvD,6DAA6C,CAAA;IAE7C,qBAAqB;IACrB,yEAAyD,CAAA;IACzD,qDAAqC,CAAA;IACrC,yEAAyD,CAAA;IACzD,qEAAqD,CAAA;IAErD,uBAAuB;IACvB,6CAA6B,CAAA;IAC7B,iDAAiC,CAAA;IACjC,mDAAmC,CAAA;AACvC,CAAC,EAlCW,YAAY,4BAAZ,YAAY,QAkCvB;AAwBD;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAIpC,YAAY,KAAkF;QAC1F,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAE7B,uDAAuD;QACvD,MAAM,gBAAgB,GAAG,KAA8G,CAAC;QACxI,IAAI,OAAO,gBAAgB,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;YAC3D,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;CACJ;AAhBD,sCAgBC;AAqeD;;GAEG;AACU,QAAA,kBAAkB,GAA2B;IACtD,GAAG,EAAE,eAAe;IACpB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,YAAY;CACtB,CAAC;AAEF;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAuB;;IACpD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;IAEzF,OAAO;QACH,GAAG,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,mCAAI,0BAAkB,CAAC,GAAG,CAAC;QACzD,IAAI,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,0BAAkB,CAAC,IAAI,CAAC;QAC5D,QAAQ,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,0BAAkB,CAAC,QAAQ,CAAC;QACxE,KAAK,EAAE,aAAa,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,mCAAI,0BAAkB,CAAC,KAAK,CAAC;KAClE,CAAC;AACN,CAAC"}
|
package/dist/app.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export interface IObjectQL {
|
|
|
22
22
|
on(event: HookName, objectName: string, handler: HookHandler): void;
|
|
23
23
|
triggerHook(event: HookName, objectName: string, ctx: HookContext): Promise<void>;
|
|
24
24
|
registerAction(objectName: string, actionName: string, handler: ActionHandler): void;
|
|
25
|
-
executeAction(objectName: string, actionName: string, ctx: ActionContext): Promise<
|
|
25
|
+
executeAction(objectName: string, actionName: string, ctx: ActionContext): Promise<unknown>;
|
|
26
26
|
/**
|
|
27
27
|
* Get the underlying ObjectKernel instance
|
|
28
28
|
* @returns The ObjectKernel instance
|
|
29
29
|
*/
|
|
30
|
-
getKernel():
|
|
30
|
+
getKernel(): unknown;
|
|
31
31
|
}
|
package/dist/application.d.ts
CHANGED
package/dist/context.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface ObjectQLContext {
|
|
|
23
23
|
* Execute a function within a transaction.
|
|
24
24
|
* The callback receives a new context 'trxCtx' which inherits userId, spaceId from this context.
|
|
25
25
|
*/
|
|
26
|
-
transaction(callback: (trxCtx: ObjectQLContext) => Promise<
|
|
26
|
+
transaction(callback: (trxCtx: ObjectQLContext) => Promise<unknown>): Promise<unknown>;
|
|
27
27
|
/**
|
|
28
28
|
* Returns a new context with system privileges (isSystem: true).
|
|
29
29
|
* It shares the same transaction scope as the current context.
|
|
@@ -32,7 +32,7 @@ export interface ObjectQLContext {
|
|
|
32
32
|
/**
|
|
33
33
|
* Internal: Driver-specific transaction handle.
|
|
34
34
|
*/
|
|
35
|
-
transactionHandle?:
|
|
35
|
+
transactionHandle?: unknown;
|
|
36
36
|
}
|
|
37
37
|
export interface ObjectQLContextOptions {
|
|
38
38
|
userId?: string;
|
package/dist/driver.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface IntrospectedColumn {
|
|
|
16
16
|
/** Whether the column is nullable */
|
|
17
17
|
nullable: boolean;
|
|
18
18
|
/** Default value if any */
|
|
19
|
-
defaultValue?:
|
|
19
|
+
defaultValue?: unknown;
|
|
20
20
|
/** Whether this is a primary key */
|
|
21
21
|
isPrimary?: boolean;
|
|
22
22
|
/** Whether this column has a unique constraint */
|
|
@@ -59,8 +59,10 @@ export interface IntrospectedSchema {
|
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Transaction isolation levels supported by the driver.
|
|
62
|
+
*
|
|
63
|
+
* Aligned with @objectstack/spec DriverCapabilitiesSchema — uses snake_case per protocol convention.
|
|
62
64
|
*/
|
|
63
|
-
export type IsolationLevel = '
|
|
65
|
+
export type IsolationLevel = 'read_uncommitted' | 'read_committed' | 'repeatable_read' | 'serializable' | 'snapshot';
|
|
64
66
|
/**
|
|
65
67
|
* Driver Capabilities
|
|
66
68
|
*
|
|
@@ -104,6 +106,21 @@ export interface DriverCapabilities {
|
|
|
104
106
|
readonly preparedStatements?: boolean;
|
|
105
107
|
readonly queryCache?: boolean;
|
|
106
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Runtime Driver Capabilities (extends spec with sync-specific properties)
|
|
111
|
+
*
|
|
112
|
+
* These properties are NOT part of the @objectstack/spec DriverCapabilitiesSchema
|
|
113
|
+
* (which sets additionalProperties: false). They are runtime-only extensions
|
|
114
|
+
* used by the Offline-First Sync Protocol (Q3).
|
|
115
|
+
*
|
|
116
|
+
* Use this interface for drivers that need sync capabilities.
|
|
117
|
+
*/
|
|
118
|
+
export interface RuntimeDriverCapabilities extends DriverCapabilities {
|
|
119
|
+
/** Driver can record mutations to an append-only log for offline sync */
|
|
120
|
+
readonly mutationLog?: boolean;
|
|
121
|
+
/** Driver supports checkpoint-based change tracking */
|
|
122
|
+
readonly changeTracking?: boolean;
|
|
123
|
+
}
|
|
107
124
|
/**
|
|
108
125
|
* Driver type discriminator — aligned with @objectstack/spec DriverConfigSchema.
|
|
109
126
|
*/
|
|
@@ -116,6 +133,15 @@ export interface BaseDriverConfig {
|
|
|
116
133
|
/** Driver type discriminator */
|
|
117
134
|
readonly type?: DriverType;
|
|
118
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Database driver interface. All storage backends implement this contract.
|
|
138
|
+
*
|
|
139
|
+
* Type strategy:
|
|
140
|
+
* - `Record<string, unknown>` for data payloads (plain field-value maps)
|
|
141
|
+
* - `object` for query/filter/command parameters that may receive named interfaces
|
|
142
|
+
* (e.g., UnifiedQuery, Filter) which lack implicit index signatures
|
|
143
|
+
* - `unknown` for opaque values (transaction handles, heterogeneous returns)
|
|
144
|
+
*/
|
|
119
145
|
export interface Driver {
|
|
120
146
|
/** Driver identifier (e.g., 'memory', 'sql', 'mongo') */
|
|
121
147
|
readonly name?: string;
|
|
@@ -123,59 +149,122 @@ export interface Driver {
|
|
|
123
149
|
readonly version?: string;
|
|
124
150
|
/** Capabilities declaration — what this driver supports */
|
|
125
151
|
readonly supports?: DriverCapabilities;
|
|
126
|
-
find(objectName: string, query:
|
|
127
|
-
findOne(objectName: string, id: string | number, query?:
|
|
128
|
-
create(objectName: string, data:
|
|
129
|
-
update(objectName: string, id: string | number, data:
|
|
130
|
-
delete(objectName: string, id: string | number, options?:
|
|
131
|
-
count(objectName: string, filters:
|
|
152
|
+
find(objectName: string, query: object, options?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
|
|
153
|
+
findOne(objectName: string, id: string | number, query?: object, options?: Record<string, unknown>): Promise<Record<string, unknown> | null>;
|
|
154
|
+
create(objectName: string, data: Record<string, unknown>, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
155
|
+
update(objectName: string, id: string | number, data: Record<string, unknown>, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
156
|
+
delete(objectName: string, id: string | number, options?: Record<string, unknown>): Promise<unknown>;
|
|
157
|
+
count(objectName: string, filters: object, options?: Record<string, unknown>): Promise<number>;
|
|
132
158
|
connect?(): Promise<void>;
|
|
133
159
|
disconnect?(): Promise<void>;
|
|
134
160
|
checkHealth?(): Promise<boolean>;
|
|
135
|
-
execute?(command:
|
|
136
|
-
bulkCreate?(objectName: string, data:
|
|
161
|
+
execute?(command: object, parameters?: unknown[], options?: Record<string, unknown>): Promise<unknown>;
|
|
162
|
+
bulkCreate?(objectName: string, data: Record<string, unknown>[], options?: Record<string, unknown>): Promise<unknown>;
|
|
137
163
|
bulkUpdate?(objectName: string, updates: Array<{
|
|
138
164
|
id: string | number;
|
|
139
|
-
data:
|
|
140
|
-
}>, options?:
|
|
141
|
-
bulkDelete?(objectName: string, ids: Array<string | number>, options?:
|
|
142
|
-
distinct?(objectName: string, field: string, filters?:
|
|
143
|
-
aggregate?(objectName: string, query:
|
|
144
|
-
beginTransaction?(): Promise<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
165
|
+
data: Record<string, unknown>;
|
|
166
|
+
}>, options?: Record<string, unknown>): Promise<unknown>;
|
|
167
|
+
bulkDelete?(objectName: string, ids: Array<string | number>, options?: Record<string, unknown>): Promise<unknown>;
|
|
168
|
+
distinct?(objectName: string, field: string, filters?: object, options?: Record<string, unknown>): Promise<unknown[]>;
|
|
169
|
+
aggregate?(objectName: string, query: object, options?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
|
|
170
|
+
beginTransaction?(): Promise<unknown>;
|
|
171
|
+
/** @deprecated Use `commit` — aligned with @objectstack/spec DriverInterfaceSchema. Will be removed in v5.0. */
|
|
172
|
+
commitTransaction?(transaction: unknown): Promise<void>;
|
|
173
|
+
/** @deprecated Use `rollback` — aligned with @objectstack/spec DriverInterfaceSchema. Will be removed in v5.0. */
|
|
174
|
+
rollbackTransaction?(transaction: unknown): Promise<void>;
|
|
175
|
+
/** Commit a transaction (spec-aligned name) */
|
|
176
|
+
commit?(transaction: unknown): Promise<void>;
|
|
177
|
+
/** Rollback a transaction (spec-aligned name) */
|
|
178
|
+
rollback?(transaction: unknown): Promise<void>;
|
|
179
|
+
init?(objects: object[]): Promise<void>;
|
|
148
180
|
/**
|
|
149
181
|
* Introspect the database schema to discover existing tables, columns, and relationships.
|
|
150
182
|
* @returns Complete schema information including tables, columns, and foreign keys
|
|
151
183
|
*/
|
|
152
184
|
introspectSchema?(): Promise<IntrospectedSchema>;
|
|
153
|
-
createMany?(objectName: string, data:
|
|
154
|
-
updateMany?(objectName: string, filters:
|
|
155
|
-
deleteMany?(objectName: string, filters:
|
|
156
|
-
findOneAndUpdate?(objectName: string, filters:
|
|
185
|
+
createMany?(objectName: string, data: Record<string, unknown>[], options?: Record<string, unknown>): Promise<unknown>;
|
|
186
|
+
updateMany?(objectName: string, filters: object, data: Record<string, unknown>, options?: Record<string, unknown>): Promise<unknown>;
|
|
187
|
+
deleteMany?(objectName: string, filters: object, options?: Record<string, unknown>): Promise<unknown>;
|
|
188
|
+
findOneAndUpdate?(objectName: string, filters: object, update: Record<string, unknown>, options?: Record<string, unknown>): Promise<Record<string, unknown> | null>;
|
|
157
189
|
/**
|
|
158
190
|
* Execute a query using QueryAST format (DriverInterface v4.0)
|
|
159
191
|
*/
|
|
160
|
-
executeQuery?(ast:
|
|
161
|
-
value:
|
|
192
|
+
executeQuery?(ast: object, options?: Record<string, unknown>): Promise<{
|
|
193
|
+
value: Record<string, unknown>[];
|
|
162
194
|
count?: number;
|
|
163
195
|
}>;
|
|
164
196
|
/**
|
|
165
197
|
* Execute a command using Command format (DriverInterface v4.0)
|
|
166
198
|
*/
|
|
167
|
-
executeCommand?(command:
|
|
199
|
+
executeCommand?(command: object, options?: Record<string, unknown>): Promise<{
|
|
168
200
|
success: boolean;
|
|
169
|
-
data?:
|
|
201
|
+
data?: unknown;
|
|
170
202
|
affected: number;
|
|
171
203
|
}>;
|
|
172
204
|
/**
|
|
173
205
|
* Alternative method name for findOne (some drivers use 'get')
|
|
174
206
|
*/
|
|
175
|
-
get?(objectName: string, id: string, options?:
|
|
207
|
+
get?(objectName: string, id: string, options?: Record<string, unknown>): Promise<Record<string, unknown> | null>;
|
|
176
208
|
/**
|
|
177
209
|
* Direct query execution (legacy)
|
|
178
210
|
*/
|
|
179
|
-
directQuery?(sql: string, params?:
|
|
180
|
-
query?(sql: string, params?:
|
|
211
|
+
directQuery?(sql: string, params?: unknown[]): Promise<Record<string, unknown>[]>;
|
|
212
|
+
query?(sql: string, params?: unknown[]): Promise<Record<string, unknown>[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Upsert (create or update) a record.
|
|
215
|
+
* If the record exists (matched by ID or unique key), update it; otherwise, create it.
|
|
216
|
+
*
|
|
217
|
+
* @param objectName - The object name.
|
|
218
|
+
* @param data - Key-value map of field data (must include ID or unique key).
|
|
219
|
+
* @param options - Driver options.
|
|
220
|
+
* @returns The upserted record.
|
|
221
|
+
*/
|
|
222
|
+
upsert?(objectName: string, data: Record<string, unknown>, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
223
|
+
/**
|
|
224
|
+
* Stream records matching the structured query.
|
|
225
|
+
* Optimized for large datasets to avoid memory overflow.
|
|
226
|
+
*
|
|
227
|
+
* @param objectName - The name of the object.
|
|
228
|
+
* @param query - The structured QueryAST.
|
|
229
|
+
* @param options - Driver options.
|
|
230
|
+
* @returns AsyncIterable/ReadableStream of records.
|
|
231
|
+
*/
|
|
232
|
+
findStream?(objectName: string, query: object, options?: Record<string, unknown>): AsyncIterable<Record<string, unknown>> | unknown;
|
|
233
|
+
/**
|
|
234
|
+
* Get connection pool statistics.
|
|
235
|
+
* Useful for monitoring database load.
|
|
236
|
+
*
|
|
237
|
+
* @returns Pool stats object, or undefined if pooling is not supported by the driver.
|
|
238
|
+
*/
|
|
239
|
+
getPoolStats?(): {
|
|
240
|
+
total: number;
|
|
241
|
+
idle: number;
|
|
242
|
+
active: number;
|
|
243
|
+
waiting: number;
|
|
244
|
+
} | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* Synchronize the schema for one or more objects.
|
|
247
|
+
* Creates or alters tables/collections to match the object definitions.
|
|
248
|
+
*
|
|
249
|
+
* @param objects - Object definitions to synchronize.
|
|
250
|
+
* @param options - Driver options.
|
|
251
|
+
*/
|
|
252
|
+
syncSchema?(objects: object[], options?: Record<string, unknown>): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Drop a table/collection by name.
|
|
255
|
+
*
|
|
256
|
+
* @param objectName - The name of the object/table to drop.
|
|
257
|
+
* @param options - Driver options.
|
|
258
|
+
*/
|
|
259
|
+
dropTable?(objectName: string, options?: Record<string, unknown>): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Explain the execution plan for a query.
|
|
262
|
+
* Useful for debugging and performance optimization.
|
|
263
|
+
*
|
|
264
|
+
* @param objectName - The name of the object.
|
|
265
|
+
* @param query - The structured QueryAST.
|
|
266
|
+
* @param options - Driver options.
|
|
267
|
+
* @returns Execution plan details.
|
|
268
|
+
*/
|
|
269
|
+
explain?(objectName: string, query: object, options?: Record<string, unknown>): Promise<unknown>;
|
|
181
270
|
}
|
package/dist/edge.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* Supported edge runtime environments.
|
|
10
|
+
*/
|
|
11
|
+
export type EdgeRuntime = 'cloudflare-workers' | 'deno-deploy' | 'vercel-edge' | 'bun' | 'node';
|
|
12
|
+
/**
|
|
13
|
+
* Edge-specific driver binding.
|
|
14
|
+
*
|
|
15
|
+
* Maps an ObjectQL driver to an edge-platform-native storage primitive.
|
|
16
|
+
* For example, Cloudflare Workers binds `driver-sqlite-wasm` to D1.
|
|
17
|
+
*/
|
|
18
|
+
export interface EdgeDriverBinding {
|
|
19
|
+
/**
|
|
20
|
+
* The ObjectQL driver package name.
|
|
21
|
+
* e.g., `'@objectql/driver-memory'`, `'@objectql/driver-sqlite-wasm'`
|
|
22
|
+
*/
|
|
23
|
+
readonly driver: string;
|
|
24
|
+
/**
|
|
25
|
+
* Edge-platform binding name (environment variable or resource identifier).
|
|
26
|
+
* e.g., `'D1_DATABASE'` for Cloudflare D1, `'POSTGRES_URL'` for Deno Postgres.
|
|
27
|
+
*/
|
|
28
|
+
readonly binding?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Driver-specific configuration overrides for the edge environment.
|
|
31
|
+
*/
|
|
32
|
+
readonly config?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Edge runtime adapter configuration.
|
|
36
|
+
*
|
|
37
|
+
* Declares how ObjectQL should adapt to a specific edge runtime.
|
|
38
|
+
* Used by the edge adapter packages (e.g., `@objectql/adapter-cloudflare`).
|
|
39
|
+
*/
|
|
40
|
+
export interface EdgeAdapterConfig {
|
|
41
|
+
/** Target edge runtime */
|
|
42
|
+
readonly runtime: EdgeRuntime;
|
|
43
|
+
/**
|
|
44
|
+
* Driver bindings for this edge environment.
|
|
45
|
+
* Maps datasource names to edge-specific driver bindings.
|
|
46
|
+
*/
|
|
47
|
+
readonly bindings?: Record<string, EdgeDriverBinding>;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum execution time in milliseconds.
|
|
50
|
+
* Edge runtimes impose strict CPU time limits.
|
|
51
|
+
* Default varies by runtime (e.g., 30000 for Cloudflare Workers).
|
|
52
|
+
*/
|
|
53
|
+
readonly maxExecutionTime?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Enable request-scoped driver connections.
|
|
56
|
+
* Edge runtimes are stateless; connections are created per-request.
|
|
57
|
+
* Default: true
|
|
58
|
+
*/
|
|
59
|
+
readonly requestScoped?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Edge runtime environment capabilities.
|
|
63
|
+
*
|
|
64
|
+
* Declares what platform APIs are available in the target edge runtime.
|
|
65
|
+
* Used by ObjectQL to select compatible code paths.
|
|
66
|
+
*/
|
|
67
|
+
export interface EdgeCapabilities {
|
|
68
|
+
/** WebAssembly support */
|
|
69
|
+
readonly wasm: boolean;
|
|
70
|
+
/** Persistent storage available (OPFS, KV, D1, etc.) */
|
|
71
|
+
readonly persistentStorage: boolean;
|
|
72
|
+
/** WebSocket support for real-time sync */
|
|
73
|
+
readonly webSocket: boolean;
|
|
74
|
+
/** Cron/scheduled trigger support */
|
|
75
|
+
readonly scheduledTriggers: boolean;
|
|
76
|
+
/** Maximum request body size in bytes */
|
|
77
|
+
readonly maxRequestBodySize?: number;
|
|
78
|
+
/** Maximum execution time in milliseconds */
|
|
79
|
+
readonly maxExecutionTime?: number;
|
|
80
|
+
/** Available storage primitives */
|
|
81
|
+
readonly storagePrimitives: readonly string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Predefined edge capability profiles for known runtimes.
|
|
85
|
+
*/
|
|
86
|
+
export declare const EDGE_CAPABILITIES: Readonly<Record<EdgeRuntime, EdgeCapabilities>>;
|
package/dist/edge.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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.EDGE_CAPABILITIES = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Predefined edge capability profiles for known runtimes.
|
|
13
|
+
*/
|
|
14
|
+
exports.EDGE_CAPABILITIES = {
|
|
15
|
+
'cloudflare-workers': {
|
|
16
|
+
wasm: true,
|
|
17
|
+
persistentStorage: true,
|
|
18
|
+
webSocket: true,
|
|
19
|
+
scheduledTriggers: true,
|
|
20
|
+
maxRequestBodySize: 100 * 1024 * 1024, // 100MB
|
|
21
|
+
maxExecutionTime: 30000,
|
|
22
|
+
storagePrimitives: ['D1', 'KV', 'R2', 'Durable Objects'],
|
|
23
|
+
},
|
|
24
|
+
'deno-deploy': {
|
|
25
|
+
wasm: true,
|
|
26
|
+
persistentStorage: true,
|
|
27
|
+
webSocket: true,
|
|
28
|
+
scheduledTriggers: true,
|
|
29
|
+
maxRequestBodySize: 512 * 1024, // 512KB
|
|
30
|
+
maxExecutionTime: 50000,
|
|
31
|
+
storagePrimitives: ['Deno KV', 'Deno Postgres'],
|
|
32
|
+
},
|
|
33
|
+
'vercel-edge': {
|
|
34
|
+
wasm: true,
|
|
35
|
+
persistentStorage: false,
|
|
36
|
+
webSocket: false,
|
|
37
|
+
scheduledTriggers: false,
|
|
38
|
+
maxRequestBodySize: 4 * 1024 * 1024, // 4MB
|
|
39
|
+
maxExecutionTime: 25000,
|
|
40
|
+
storagePrimitives: ['KV (via Vercel KV)', 'Postgres (via Vercel Postgres)'],
|
|
41
|
+
},
|
|
42
|
+
'bun': {
|
|
43
|
+
wasm: true,
|
|
44
|
+
persistentStorage: true,
|
|
45
|
+
webSocket: true,
|
|
46
|
+
scheduledTriggers: false,
|
|
47
|
+
maxRequestBodySize: Infinity,
|
|
48
|
+
maxExecutionTime: Infinity,
|
|
49
|
+
storagePrimitives: ['SQLite (bun:sqlite)', 'File System'],
|
|
50
|
+
},
|
|
51
|
+
'node': {
|
|
52
|
+
wasm: true,
|
|
53
|
+
persistentStorage: true,
|
|
54
|
+
webSocket: true,
|
|
55
|
+
scheduledTriggers: false,
|
|
56
|
+
maxRequestBodySize: Infinity,
|
|
57
|
+
maxExecutionTime: Infinity,
|
|
58
|
+
storagePrimitives: ['All drivers'],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=edge.js.map
|
package/dist/edge.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAqGH;;GAEG;AACU,QAAA,iBAAiB,GAAoD;IAC9E,oBAAoB,EAAE;QAClB,IAAI,EAAE,IAAI;QACV,iBAAiB,EAAE,IAAI;QACvB,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,IAAI;QACvB,kBAAkB,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,QAAQ;QAC/C,gBAAgB,EAAE,KAAM;QACxB,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB,CAAC;KAC3D;IACD,aAAa,EAAE;QACX,IAAI,EAAE,IAAI;QACV,iBAAiB,EAAE,IAAI;QACvB,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,IAAI;QACvB,kBAAkB,EAAE,GAAG,GAAG,IAAI,EAAE,QAAQ;QACxC,gBAAgB,EAAE,KAAM;QACxB,iBAAiB,EAAE,CAAC,SAAS,EAAE,eAAe,CAAC;KAClD;IACD,aAAa,EAAE;QACX,IAAI,EAAE,IAAI;QACV,iBAAiB,EAAE,KAAK;QACxB,SAAS,EAAE,KAAK;QAChB,iBAAiB,EAAE,KAAK;QACxB,kBAAkB,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,MAAM;QAC3C,gBAAgB,EAAE,KAAM;QACxB,iBAAiB,EAAE,CAAC,oBAAoB,EAAE,gCAAgC,CAAC;KAC9E;IACD,KAAK,EAAE;QACH,IAAI,EAAE,IAAI;QACV,iBAAiB,EAAE,IAAI;QACvB,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,KAAK;QACxB,kBAAkB,EAAE,QAAQ;QAC5B,gBAAgB,EAAE,QAAQ;QAC1B,iBAAiB,EAAE,CAAC,qBAAqB,EAAE,aAAa,CAAC;KAC5D;IACD,MAAM,EAAE;QACJ,IAAI,EAAE,IAAI;QACV,iBAAiB,EAAE,IAAI;QACvB,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,KAAK;QACxB,kBAAkB,EAAE,QAAQ;QAC5B,gBAAgB,EAAE,QAAQ;QAC1B,iBAAiB,EAAE,CAAC,aAAa,CAAC;KACrC;CACJ,CAAC"}
|
package/dist/field.d.ts
CHANGED
|
@@ -70,10 +70,10 @@ export interface ImageAttachmentData extends AttachmentData {
|
|
|
70
70
|
* Runtime Field Type
|
|
71
71
|
*
|
|
72
72
|
* Extends the Protocol FieldType with runtime-specific types.
|
|
73
|
-
* The Protocol Constitution defines the core field types.
|
|
74
|
-
* We add runtime-specific types like '
|
|
73
|
+
* The Protocol Constitution defines the core field types (including 'location' and 'vector').
|
|
74
|
+
* We add runtime-specific types like 'grid' and 'object' here.
|
|
75
75
|
*/
|
|
76
|
-
export type FieldType = ProtocolFieldType | '
|
|
76
|
+
export type FieldType = ProtocolFieldType | 'object' | 'grid';
|
|
77
77
|
/**
|
|
78
78
|
* Runtime Field Option
|
|
79
79
|
*
|
package/dist/formula.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formula.js","sourceRoot":"","sources":["../src/formula.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;;;;GAQG;AAEH,+
|
|
1
|
+
{"version":3,"file":"formula.js","sourceRoot":"","sources":["../src/formula.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH;;;;;;;;GAQG;AAEH,+BAAsC;AA0OtC;;GAEG;AACH,IAAY,gBAwBX;AAxBD,WAAY,gBAAgB;IACxB,qCAAqC;IACrC,iDAA6B,CAAA;IAE7B,sCAAsC;IACtC,uDAAmC,CAAA;IAEnC,iCAAiC;IACjC,6CAAyB,CAAA;IAEzB,uBAAuB;IACvB,yDAAqC,CAAA;IAErC,2CAA2C;IAC3C,qDAAiC,CAAA;IAEjC,yBAAyB;IACzB,uCAAmB,CAAA;IAEnB,gDAAgD;IAChD,6DAAyC,CAAA;IAEzC,4BAA4B;IAC5B,mDAA+B,CAAA;AACnC,CAAC,EAxBW,gBAAgB,gCAAhB,gBAAgB,QAwB3B;AAmBD;;;GAGG;AACH,MAAa,YAAa,SAAQ,mBAAa;IAK3C,YACI,IAAsB,EACtB,OAAe,EACf,UAAmB,EACnB,OAA6B;QAE7B,KAAK,CAAC;YACF,IAAI,EAAE,IAAc;YACpB,OAAO;YACP,OAAO,EAAE;gBACL,kBAAkB,EAAE,IAAI;gBACxB,UAAU;gBACV,GAAG,OAAO;aACb;SACJ,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;IAChC,CAAC;CACJ;AAzBD,oCAyBC"}
|
package/dist/gateway.d.ts
CHANGED
|
@@ -10,14 +10,14 @@ export interface ApiRequest {
|
|
|
10
10
|
path: string;
|
|
11
11
|
method: ApiMethod;
|
|
12
12
|
headers: Record<string, string | string[] | undefined>;
|
|
13
|
-
query: Record<string,
|
|
14
|
-
body?:
|
|
13
|
+
query: Record<string, unknown>;
|
|
14
|
+
body?: unknown;
|
|
15
15
|
protocol?: string;
|
|
16
16
|
}
|
|
17
17
|
export interface ApiResponse {
|
|
18
18
|
status: number;
|
|
19
19
|
headers?: Record<string, string | string[]>;
|
|
20
|
-
body:
|
|
20
|
+
body: unknown;
|
|
21
21
|
}
|
|
22
22
|
export interface GatewayProtocol {
|
|
23
23
|
name: string;
|
package/dist/hook.d.ts
CHANGED
|
@@ -17,17 +17,17 @@ export type HookTiming = 'before' | 'after';
|
|
|
17
17
|
* Minimal API surface exposed to hooks for performing side-effects or checks.
|
|
18
18
|
*/
|
|
19
19
|
export interface HookAPI {
|
|
20
|
-
find(objectName: string, query?:
|
|
21
|
-
findOne(objectName: string, id: string | number): Promise<
|
|
22
|
-
count(objectName: string, query?:
|
|
23
|
-
create(objectName: string, data:
|
|
24
|
-
update(objectName: string, id: string | number, data:
|
|
25
|
-
delete(objectName: string, id: string | number): Promise<
|
|
20
|
+
find(objectName: string, query?: Record<string, unknown>): Promise<Record<string, unknown>[]>;
|
|
21
|
+
findOne(objectName: string, id: string | number): Promise<Record<string, unknown> | null>;
|
|
22
|
+
count(objectName: string, query?: Record<string, unknown>): Promise<number>;
|
|
23
|
+
create(objectName: string, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
24
|
+
update(objectName: string, id: string | number, data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
25
|
+
delete(objectName: string, id: string | number): Promise<Record<string, unknown>>;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Base context available in all hooks.
|
|
29
29
|
*/
|
|
30
|
-
export interface BaseHookContext<
|
|
30
|
+
export interface BaseHookContext<_T = Record<string, unknown>> {
|
|
31
31
|
/** The name of the object (entity) being acted upon. */
|
|
32
32
|
objectName: string;
|
|
33
33
|
/** The triggering operation. */
|
|
@@ -37,28 +37,32 @@ export interface BaseHookContext<T = any> {
|
|
|
37
37
|
/** User/Session context (Authentication info). */
|
|
38
38
|
user?: {
|
|
39
39
|
id: string | number;
|
|
40
|
-
[key: string]:
|
|
40
|
+
[key: string]: unknown;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Shared state for passing data between matching 'before' and 'after' hooks.
|
|
44
44
|
* e.g. Calculate a diff in 'beforeUpdate' and read it in 'afterUpdate'.
|
|
45
45
|
*/
|
|
46
|
-
state: Record<string,
|
|
46
|
+
state: Record<string, unknown>;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Context for Retrieval operations (Find, Count).
|
|
50
50
|
*/
|
|
51
|
-
export interface RetrievalHookContext<T =
|
|
51
|
+
export interface RetrievalHookContext<T = Record<string, unknown>> extends BaseHookContext<T> {
|
|
52
52
|
operation: 'find' | 'count';
|
|
53
|
-
/**
|
|
54
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The query criteria being executed. Modifiable in 'before' hooks.
|
|
55
|
+
* Typed as `object` (not `Record<string, unknown>`) because named interfaces
|
|
56
|
+
* like UnifiedQuery lack index signatures and aren't assignable to Record types.
|
|
57
|
+
*/
|
|
58
|
+
query: object;
|
|
55
59
|
/** The result of the query. Only available in 'after' hooks. */
|
|
56
60
|
result?: T[] | number;
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
63
|
* Context for Modification operations (Create, Update, Delete).
|
|
60
64
|
*/
|
|
61
|
-
export interface MutationHookContext<T =
|
|
65
|
+
export interface MutationHookContext<T = Record<string, unknown>> extends BaseHookContext<T> {
|
|
62
66
|
operation: 'create' | 'update' | 'delete';
|
|
63
67
|
/** The record ID. Undefined for 'create'. */
|
|
64
68
|
id?: string | number;
|
|
@@ -83,7 +87,7 @@ export interface MutationHookContext<T = any> extends BaseHookContext<T> {
|
|
|
83
87
|
/**
|
|
84
88
|
* Specialized context for Updates, including change tracking.
|
|
85
89
|
*/
|
|
86
|
-
export interface UpdateHookContext<T =
|
|
90
|
+
export interface UpdateHookContext<T = Record<string, unknown>> extends MutationHookContext<T> {
|
|
87
91
|
operation: 'update';
|
|
88
92
|
/**
|
|
89
93
|
* Helper to check if a specific field is being modified.
|
|
@@ -94,7 +98,7 @@ export interface UpdateHookContext<T = any> extends MutationHookContext<T> {
|
|
|
94
98
|
/**
|
|
95
99
|
* Definition interface for a set of hooks for a specific object.
|
|
96
100
|
*/
|
|
97
|
-
export interface ObjectHookDefinition<T =
|
|
101
|
+
export interface ObjectHookDefinition<T = Record<string, unknown>> {
|
|
98
102
|
beforeFind?: (ctx: RetrievalHookContext<T>) => Promise<void> | void;
|
|
99
103
|
afterFind?: (ctx: RetrievalHookContext<T>) => Promise<void> | void;
|
|
100
104
|
beforeCount?: (ctx: RetrievalHookContext<T>) => Promise<void> | void;
|
|
@@ -107,5 +111,5 @@ export interface ObjectHookDefinition<T = any> {
|
|
|
107
111
|
afterUpdate?: (ctx: UpdateHookContext<T>) => Promise<void> | void;
|
|
108
112
|
}
|
|
109
113
|
export type HookName = keyof ObjectHookDefinition;
|
|
110
|
-
export type HookContext<T =
|
|
111
|
-
export type HookHandler<T =
|
|
114
|
+
export type HookContext<T = Record<string, unknown>> = RetrievalHookContext<T> | MutationHookContext<T> | UpdateHookContext<T>;
|
|
115
|
+
export type HookHandler<T = Record<string, unknown>> = (ctx: HookContext<T>) => Promise<void> | void;
|