@warpfx/server 0.3.0 → 0.3.1
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.ts +25 -1
- package/dist/index.js +5 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -195,6 +195,15 @@ interface ActionError {
|
|
|
195
195
|
code: string;
|
|
196
196
|
message: string;
|
|
197
197
|
}
|
|
198
|
+
/** Describes a single table row change. */
|
|
199
|
+
interface TableChange<T = any> {
|
|
200
|
+
/** The type of change. */
|
|
201
|
+
type: "insert" | "update" | "delete";
|
|
202
|
+
/** The current row (new on insert/update, deleted row on delete). */
|
|
203
|
+
row: T;
|
|
204
|
+
/** The previous row (on update only, undefined otherwise). */
|
|
205
|
+
oldRow?: T;
|
|
206
|
+
}
|
|
198
207
|
/**
|
|
199
208
|
* Register an action handler that clients can invoke.
|
|
200
209
|
*
|
|
@@ -256,6 +265,21 @@ declare function error(code: string, message?: string): Error;
|
|
|
256
265
|
* await accounts.update(citizenId, { balance: 500 });
|
|
257
266
|
*/
|
|
258
267
|
declare function table<T = any>(name: string): Table<T>;
|
|
268
|
+
/**
|
|
269
|
+
* React to any change in a database table.
|
|
270
|
+
*
|
|
271
|
+
* Fires on insert, update, or delete — regardless of what caused the change
|
|
272
|
+
* (action, another module, migration, Studio edit). Works on all tables
|
|
273
|
+
* including server-only tables without an `access` field.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* onTableChange<Account>('economy_accounts', (change) => {
|
|
277
|
+
* if (change.type === 'update' && change.row.balance < 0) {
|
|
278
|
+
* accounts.update(change.row.citizenId, { frozen: true });
|
|
279
|
+
* }
|
|
280
|
+
* });
|
|
281
|
+
*/
|
|
282
|
+
declare function onTableChange<T = any>(table: string, handler: (change: TableChange<T>) => void): void;
|
|
259
283
|
/**
|
|
260
284
|
* Register a callback to run when Warp is fully booted.
|
|
261
285
|
* If Warp is already ready, the callback fires immediately.
|
|
@@ -290,4 +314,4 @@ declare function getBridge(): any;
|
|
|
290
314
|
/** Subscribe to database tables. */
|
|
291
315
|
declare function subscribe(queries: string[]): Promise<void>;
|
|
292
316
|
|
|
293
|
-
export { type AccessMode, type ActionError, type ColumnDef, type ColumnType, type CommandOptions, type CommandParam, type EntityStore, type Player, type PlayerEntity, type PlayerRow, type PlayerState, type ServerEventBus, type Table, type TableDef, type WarpSchema, action, command, error, fn, getBridge, getEntities, getEntity, getEvents, getPlayer, getPlayers, isReady, onPlayerConnect, onPlayerDisconnect, onPlayerSpawned, onReady, provide, spawnPlayer, subscribe, table, use };
|
|
317
|
+
export { type AccessMode, type ActionError, type ColumnDef, type ColumnType, type CommandOptions, type CommandParam, type EntityStore, type Player, type PlayerEntity, type PlayerRow, type PlayerState, type ServerEventBus, type Table, type TableChange, type TableDef, type WarpSchema, action, command, error, fn, getBridge, getEntities, getEntity, getEvents, getPlayer, getPlayers, isReady, onPlayerConnect, onPlayerDisconnect, onPlayerSpawned, onReady, onTableChange, provide, spawnPlayer, subscribe, table, use };
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ __export(index_exports, {
|
|
|
35
35
|
onPlayerDisconnect: () => onPlayerDisconnect,
|
|
36
36
|
onPlayerSpawned: () => onPlayerSpawned,
|
|
37
37
|
onReady: () => onReady,
|
|
38
|
+
onTableChange: () => onTableChange,
|
|
38
39
|
provide: () => provide,
|
|
39
40
|
spawnPlayer: () => spawnPlayer,
|
|
40
41
|
subscribe: () => subscribe,
|
|
@@ -64,6 +65,9 @@ function error(code, message) {
|
|
|
64
65
|
function table(name) {
|
|
65
66
|
return warp().table(name);
|
|
66
67
|
}
|
|
68
|
+
function onTableChange(table2, handler) {
|
|
69
|
+
warp().onTableChange(table2, handler);
|
|
70
|
+
}
|
|
67
71
|
function onReady(cb) {
|
|
68
72
|
warp().onReady(cb);
|
|
69
73
|
}
|
|
@@ -126,6 +130,7 @@ function subscribe(queries) {
|
|
|
126
130
|
onPlayerDisconnect,
|
|
127
131
|
onPlayerSpawned,
|
|
128
132
|
onReady,
|
|
133
|
+
onTableChange,
|
|
129
134
|
provide,
|
|
130
135
|
spawnPlayer,
|
|
131
136
|
subscribe,
|