@blocksdiy/blocks-client-sdk 1.10.5 → 1.11.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/EntityLiveSync.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export type EntityDataOperation = "insert" | "update" | "delete";
|
|
|
3
3
|
/** Fetches the current server rows for the given ids (typically `findMany({ id: ids })`). */
|
|
4
4
|
export type EntityRowsByIdsFetcher = (tableBlockId: string, ids: (string | number)[]) => Promise<unknown>;
|
|
5
5
|
export interface EntityDataEventPayload {
|
|
6
|
+
/** Canonical table block id. */
|
|
6
7
|
table?: string;
|
|
8
|
+
tableName?: string;
|
|
7
9
|
affectedRowsData?: {
|
|
8
10
|
id?: unknown;
|
|
9
11
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityLiveSync.d.ts","sourceRoot":"","sources":["../src/EntityLiveSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"EntityLiveSync.d.ts","sourceRoot":"","sources":["../src/EntityLiveSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAcpD,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjE,6FAA6F;AAC7F,MAAM,MAAM,sBAAsB,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE1G,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,WAAW,CAAC;IACzB,cAAc,EAAE,sBAAsB,CAAC;IACvC,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qGAAqG;IACrG,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAiBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,wBAAwB,GACnC,aAAa,WAAW,EACxB,cAAc,MAAM,EACpB,gBAAgB,sBAAsB,EACtC,sCAIG;IACD,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CACjC,KACA,OAAO,CAAC,IAAI,CA6Cd,CAAC;AAkBF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,kEAKlC,qBAAqB;iCA0Fc,mBAAmB,WAAW,sBAAsB,KAAG,IAAI;mBA2B3E,IAAI;CAiBzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/EntityLiveSync.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { applyEntityRowsDeleted, applyEntityRowsUpserted, hasDirectlyMaintainedEntityQueries, invalidateEntityQueriesAfterWrite, invalidateEntityTable, normalizeRowsResult, prepareEntityCacheWrite, sameId, } from "./EntityCache.js";
|
|
1
|
+
import { applyEntityRowsDeleted, applyEntityRowsUpserted, entityTableKey, hasDirectlyMaintainedEntityQueries, invalidateEntityQueriesAfterWrite, invalidateEntityTable, normalizeRowsResult, prepareEntityCacheWrite, sameId, } from "./EntityCache.js";
|
|
2
2
|
const DEFAULT_BATCH_DELAY_MS = 150;
|
|
3
3
|
const DEFAULT_MAX_ROW_FETCH_COUNT = 100;
|
|
4
4
|
const isIdValue = (value) => (typeof value === "string" && value.length > 0) || (typeof value === "number" && Number.isFinite(value));
|
|
@@ -142,11 +142,23 @@ export const createEntityLiveSync = ({ queryClient, fetchRowsByIds, batchDelayMs
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* Cache keys use whatever identifier the app's entity configs use: the table
|
|
147
|
+
* name in name-based apps, the block id otherwise. Prefer the event's table
|
|
148
|
+
* name only when this app actually holds cached queries under it.
|
|
149
|
+
*/
|
|
150
|
+
const resolveEventTable = (payload) => {
|
|
151
|
+
const { table, tableName } = payload ?? {};
|
|
152
|
+
if (tableName && queryClient.getQueryCache().findAll({ queryKey: entityTableKey(tableName) }).length > 0) {
|
|
153
|
+
return tableName;
|
|
154
|
+
}
|
|
155
|
+
return table;
|
|
156
|
+
};
|
|
145
157
|
const handleDataEvent = (operation, payload) => {
|
|
146
158
|
if (disposed) {
|
|
147
159
|
return;
|
|
148
160
|
}
|
|
149
|
-
const table = payload
|
|
161
|
+
const table = resolveEventTable(payload);
|
|
150
162
|
if (!table) {
|
|
151
163
|
return;
|
|
152
164
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocksdiy/blocks-client-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Blocks client sdk",
|
|
6
6
|
"keywords": [],
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@tanstack/react-query": "^5.101.0",
|
|
50
|
-
"@blocksdiy/blocks-client-api": "1.
|
|
51
|
-
"@blocksdiy/react-common": "1.
|
|
50
|
+
"@blocksdiy/blocks-client-api": "1.19.0",
|
|
51
|
+
"@blocksdiy/react-common": "1.35.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"tsc-alias": "^1.8.10",
|