@electric-sql/client 1.5.10 → 1.5.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/bin/intent.mjs +6 -0
- package/dist/cjs/index.cjs +31 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.browser.mjs +4 -4
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.legacy-esm.js +31 -6
- package/dist/index.legacy-esm.js.map +1 -1
- package/dist/index.mjs +31 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -2
- package/skills/electric-debugging/SKILL.md +217 -0
- package/skills/electric-deployment/SKILL.md +196 -0
- package/skills/electric-new-feature/SKILL.md +366 -0
- package/skills/electric-orm/SKILL.md +189 -0
- package/skills/electric-postgres-security/SKILL.md +196 -0
- package/skills/electric-proxy-auth/SKILL.md +269 -0
- package/skills/electric-schema-shapes/SKILL.md +200 -0
- package/skills/electric-shapes/SKILL.md +339 -0
- package/skills/electric-shapes/references/type-parsers.md +64 -0
- package/skills/electric-shapes/references/where-clause.md +64 -0
- package/src/client.ts +39 -13
package/bin/intent.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Auto-generated by @tanstack/intent setup
|
|
3
|
+
// Exposes the intent end-user CLI for consumers of this library.
|
|
4
|
+
// Commit this file, then add to your package.json:
|
|
5
|
+
// "bin": { "intent": "./bin/intent.mjs" }
|
|
6
|
+
await import(`@tanstack/intent/intent-library`)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1940,6 +1940,9 @@ var RESERVED_PARAMS = /* @__PURE__ */ new Set([
|
|
|
1940
1940
|
CACHE_BUSTER_QUERY_PARAM
|
|
1941
1941
|
]);
|
|
1942
1942
|
var TROUBLESHOOTING_URL = `https://electric-sql.com/docs/guides/troubleshooting`;
|
|
1943
|
+
function createCacheBuster() {
|
|
1944
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1945
|
+
}
|
|
1943
1946
|
async function resolveValue(value) {
|
|
1944
1947
|
if (typeof value === `function`) {
|
|
1945
1948
|
return value();
|
|
@@ -1980,7 +1983,7 @@ function canonicalShapeKey(url) {
|
|
|
1980
1983
|
cleanUrl.searchParams.sort();
|
|
1981
1984
|
return cleanUrl.toString();
|
|
1982
1985
|
}
|
|
1983
|
-
var _error, _fetchClient2, _sseFetchClient, _messageParser, _subscribers, _started, _syncState, _connected, _mode, _onError, _requestAbortController, _refreshCount, _snapshotCounter, _ShapeStream_instances, isRefreshing_get, _tickPromise, _tickPromiseResolver, _tickPromiseRejecter, _messageChain, _snapshotTracker, _pauseLock, _currentFetchUrl, _lastSseConnectionStartTime, _minSseConnectionDuration, _maxShortSseConnections, _sseBackoffBaseDelay, _sseBackoffMaxDelay, _unsubscribeFromVisibilityChanges, _unsubscribeFromWakeDetection, _maxStaleCacheRetries, _recentRequestEntries, _fastLoopWindowMs, _fastLoopThreshold, _fastLoopBackoffBaseMs, _fastLoopBackoffMaxMs, _fastLoopConsecutiveCount, _fastLoopMaxCount, start_fn, teardown_fn, requestShape_fn, checkFastLoop_fn, constructUrl_fn, createAbortListener_fn, onInitialResponse_fn, onMessages_fn, fetchShape_fn, requestShapeLongPoll_fn, requestShapeSSE_fn, nextTick_fn, publish_fn, sendErrorToSubscribers_fn, hasBrowserVisibilityAPI_fn, subscribeToVisibilityChanges_fn, subscribeToWakeDetection_fn, reset_fn, buildSubsetBody_fn;
|
|
1986
|
+
var _error, _fetchClient2, _sseFetchClient, _messageParser, _subscribers, _started, _syncState, _connected, _mode, _onError, _requestAbortController, _refreshCount, _snapshotCounter, _ShapeStream_instances, isRefreshing_get, _tickPromise, _tickPromiseResolver, _tickPromiseRejecter, _messageChain, _snapshotTracker, _pauseLock, _currentFetchUrl, _lastSseConnectionStartTime, _minSseConnectionDuration, _maxShortSseConnections, _sseBackoffBaseDelay, _sseBackoffMaxDelay, _unsubscribeFromVisibilityChanges, _unsubscribeFromWakeDetection, _maxStaleCacheRetries, _recentRequestEntries, _fastLoopWindowMs, _fastLoopThreshold, _fastLoopBackoffBaseMs, _fastLoopBackoffMaxMs, _fastLoopConsecutiveCount, _fastLoopMaxCount, _refetchCacheBuster, start_fn, teardown_fn, requestShape_fn, checkFastLoop_fn, constructUrl_fn, createAbortListener_fn, onInitialResponse_fn, onMessages_fn, fetchShape_fn, requestShapeLongPoll_fn, requestShapeSSE_fn, nextTick_fn, publish_fn, sendErrorToSubscribers_fn, hasBrowserVisibilityAPI_fn, subscribeToVisibilityChanges_fn, subscribeToWakeDetection_fn, reset_fn, buildSubsetBody_fn;
|
|
1984
1987
|
var ShapeStream = class {
|
|
1985
1988
|
constructor(options) {
|
|
1986
1989
|
__privateAdd(this, _ShapeStream_instances);
|
|
@@ -2027,6 +2030,7 @@ var ShapeStream = class {
|
|
|
2027
2030
|
__privateAdd(this, _fastLoopBackoffMaxMs, 5e3);
|
|
2028
2031
|
__privateAdd(this, _fastLoopConsecutiveCount, 0);
|
|
2029
2032
|
__privateAdd(this, _fastLoopMaxCount, 5);
|
|
2033
|
+
__privateAdd(this, _refetchCacheBuster);
|
|
2030
2034
|
var _a, _b, _c, _d;
|
|
2031
2035
|
this.options = __spreadValues({ subscribe: true }, options);
|
|
2032
2036
|
validateOptions(this.options);
|
|
@@ -2207,7 +2211,7 @@ var ShapeStream = class {
|
|
|
2207
2211
|
expiredHandle: null,
|
|
2208
2212
|
now: Date.now(),
|
|
2209
2213
|
maxStaleCacheRetries: __privateGet(this, _maxStaleCacheRetries),
|
|
2210
|
-
createCacheBuster
|
|
2214
|
+
createCacheBuster
|
|
2211
2215
|
});
|
|
2212
2216
|
if (transition.action === `accepted`) {
|
|
2213
2217
|
__privateSet(this, _syncState, transition.state);
|
|
@@ -2268,8 +2272,15 @@ var ShapeStream = class {
|
|
|
2268
2272
|
const shapeKey = canonicalShapeKey(fetchUrl);
|
|
2269
2273
|
expiredShapesCache.markExpired(shapeKey, usedHandle);
|
|
2270
2274
|
}
|
|
2271
|
-
const nextHandle = e.headers[SHAPE_HANDLE_HEADER]
|
|
2272
|
-
|
|
2275
|
+
const nextHandle = e.headers[SHAPE_HANDLE_HEADER];
|
|
2276
|
+
if (nextHandle) {
|
|
2277
|
+
__privateSet(this, _syncState, __privateGet(this, _syncState).withHandle(nextHandle));
|
|
2278
|
+
} else {
|
|
2279
|
+
console.warn(
|
|
2280
|
+
`[Electric] Received 409 response without a shape handle header. This likely indicates a proxy or CDN stripping required headers.`
|
|
2281
|
+
);
|
|
2282
|
+
__privateSet(this, _refetchCacheBuster, createCacheBuster());
|
|
2283
|
+
}
|
|
2273
2284
|
return this.fetchSnapshot(opts);
|
|
2274
2285
|
}
|
|
2275
2286
|
throw e;
|
|
@@ -2330,6 +2341,7 @@ _fastLoopBackoffBaseMs = new WeakMap();
|
|
|
2330
2341
|
_fastLoopBackoffMaxMs = new WeakMap();
|
|
2331
2342
|
_fastLoopConsecutiveCount = new WeakMap();
|
|
2332
2343
|
_fastLoopMaxCount = new WeakMap();
|
|
2344
|
+
_refetchCacheBuster = new WeakMap();
|
|
2333
2345
|
start_fn = async function() {
|
|
2334
2346
|
var _a, _b;
|
|
2335
2347
|
__privateSet(this, _started, true);
|
|
@@ -2434,7 +2446,13 @@ requestShape_fn = async function() {
|
|
|
2434
2446
|
const shapeKey = canonicalShapeKey(fetchUrl);
|
|
2435
2447
|
expiredShapesCache.markExpired(shapeKey, __privateGet(this, _syncState).handle);
|
|
2436
2448
|
}
|
|
2437
|
-
const newShapeHandle = e.headers[SHAPE_HANDLE_HEADER]
|
|
2449
|
+
const newShapeHandle = e.headers[SHAPE_HANDLE_HEADER];
|
|
2450
|
+
if (!newShapeHandle) {
|
|
2451
|
+
console.warn(
|
|
2452
|
+
`[Electric] Received 409 response without a shape handle header. This likely indicates a proxy or CDN stripping required headers.`
|
|
2453
|
+
);
|
|
2454
|
+
__privateSet(this, _refetchCacheBuster, createCacheBuster());
|
|
2455
|
+
}
|
|
2438
2456
|
__privateMethod(this, _ShapeStream_instances, reset_fn).call(this, newShapeHandle);
|
|
2439
2457
|
const messages409 = Array.isArray(e.json) ? e.json : e.json != null ? [e.json] : [];
|
|
2440
2458
|
await __privateMethod(this, _ShapeStream_instances, publish_fn).call(this, messages409);
|
|
@@ -2603,6 +2621,13 @@ constructUrl_fn = async function(url, resumingFromPause, subsetParams) {
|
|
|
2603
2621
|
if (expiredHandle) {
|
|
2604
2622
|
fetchUrl.searchParams.set(EXPIRED_HANDLE_QUERY_PARAM, expiredHandle);
|
|
2605
2623
|
}
|
|
2624
|
+
if (__privateGet(this, _refetchCacheBuster)) {
|
|
2625
|
+
fetchUrl.searchParams.set(
|
|
2626
|
+
CACHE_BUSTER_QUERY_PARAM,
|
|
2627
|
+
__privateGet(this, _refetchCacheBuster)
|
|
2628
|
+
);
|
|
2629
|
+
__privateSet(this, _refetchCacheBuster, void 0);
|
|
2630
|
+
}
|
|
2606
2631
|
fetchUrl.searchParams.sort();
|
|
2607
2632
|
return {
|
|
2608
2633
|
fetchUrl,
|
|
@@ -2639,7 +2664,7 @@ onInitialResponse_fn = async function(response) {
|
|
|
2639
2664
|
expiredHandle,
|
|
2640
2665
|
now: Date.now(),
|
|
2641
2666
|
maxStaleCacheRetries: __privateGet(this, _maxStaleCacheRetries),
|
|
2642
|
-
createCacheBuster
|
|
2667
|
+
createCacheBuster
|
|
2643
2668
|
});
|
|
2644
2669
|
__privateSet(this, _syncState, transition.state);
|
|
2645
2670
|
if (transition.action === `stale-retry`) {
|