@electric-sql/client
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -14,2 +14,3 @@ /** | ||
} | ||
type Operation = `insert` | `update` | `delete`; | ||
type ControlMessage = { | ||
@@ -24,3 +25,3 @@ headers: Header & { | ||
headers: Header & { | ||
operation: `insert` | `update` | `delete`; | ||
operation: Operation; | ||
}; | ||
@@ -227,3 +228,3 @@ offset: Offset; | ||
interface ShapeStreamInterface<T extends Row<unknown> = Row> { | ||
subscribe(callback: (messages: Message<T>[]) => MaybePromise<void>, onError?: (error: FetchError | Error) => void): void; | ||
subscribe(callback: (messages: Message<T>[]) => MaybePromise<void>, onError?: (error: FetchError | Error) => void): () => void; | ||
unsubscribeAll(): void; | ||
@@ -277,3 +278,3 @@ isLoading(): boolean; | ||
constructor(options: ShapeStreamOptions<GetExtensions<T>>); | ||
get shapeHandle(): string; | ||
get shapeHandle(): string | undefined; | ||
get error(): unknown; | ||
@@ -337,2 +338,3 @@ get isUpToDate(): boolean; | ||
#private; | ||
readonly stream: ShapeStreamInterface<T>; | ||
constructor(stream: ShapeStreamInterface<T>); | ||
@@ -397,2 +399,2 @@ get isUpToDate(): boolean; | ||
export { BackoffDefaults, type BackoffOptions, type BitColumn, type BpcharColumn, type ChangeMessage, type ColumnInfo, type CommonColumnProps, type ControlMessage, FetchError, type GetExtensions, type IntervalColumn, type IntervalColumnWithPrecision, type MaybePromise, type Message, type NumericColumn, type Offset, type RegularColumn, type Row, type Schema, Shape, type ShapeChangedCallback, type ShapeData, ShapeStream, type ShapeStreamInterface, type ShapeStreamOptions, type TimeColumn, type TypedMessages, type Value, type VarcharColumn, isChangeMessage, isControlMessage }; | ||
export { BackoffDefaults, type BackoffOptions, type BitColumn, type BpcharColumn, type ChangeMessage, type ColumnInfo, type CommonColumnProps, type ControlMessage, FetchError, type GetExtensions, type IntervalColumn, type IntervalColumnWithPrecision, type MaybePromise, type Message, type NumericColumn, type Offset, type Operation, type RegularColumn, type Row, type Schema, Shape, type ShapeChangedCallback, type ShapeData, ShapeStream, type ShapeStreamInterface, type ShapeStreamOptions, type TimeColumn, type TypedMessages, type Value, type VarcharColumn, isChangeMessage, isControlMessage }; |
@@ -350,6 +350,6 @@ var __defProp = Object.defineProperty; | ||
const url = new URL(urlString); | ||
if (url.searchParams.has(LIVE_QUERY_PARAM, `true`)) { | ||
if (url.searchParams.get(LIVE_QUERY_PARAM) === `true`) { | ||
addMissingHeaders(requiredLiveResponseHeaders); | ||
} | ||
if (!url.searchParams.has(LIVE_QUERY_PARAM) || url.searchParams.has(LIVE_QUERY_PARAM, `false`)) { | ||
if (!url.searchParams.has(LIVE_QUERY_PARAM) || url.searchParams.get(LIVE_QUERY_PARAM) === `false`) { | ||
addMissingHeaders(requiredNonLiveResponseHeaders); | ||
@@ -736,7 +736,6 @@ } | ||
// src/shape.ts | ||
var _stream, _data, _subscribers2, _hasNotifiedSubscribersUpToDate, _error2, _Shape_instances, process_fn, handleError_fn, notify_fn; | ||
var _data, _subscribers2, _hasNotifiedSubscribersUpToDate, _error2, _Shape_instances, process_fn, handleError_fn, notify_fn; | ||
var Shape = class { | ||
constructor(stream) { | ||
__privateAdd(this, _Shape_instances); | ||
__privateAdd(this, _stream); | ||
__privateAdd(this, _data, /* @__PURE__ */ new Map()); | ||
@@ -746,4 +745,4 @@ __privateAdd(this, _subscribers2, /* @__PURE__ */ new Map()); | ||
__privateAdd(this, _error2, false); | ||
__privateSet(this, _stream, stream); | ||
__privateGet(this, _stream).subscribe( | ||
this.stream = stream; | ||
this.stream.subscribe( | ||
__privateMethod(this, _Shape_instances, process_fn).bind(this), | ||
@@ -754,9 +753,9 @@ __privateMethod(this, _Shape_instances, handleError_fn).bind(this) | ||
get isUpToDate() { | ||
return __privateGet(this, _stream).isUpToDate; | ||
return this.stream.isUpToDate; | ||
} | ||
get lastOffset() { | ||
return __privateGet(this, _stream).lastOffset; | ||
return this.stream.lastOffset; | ||
} | ||
get handle() { | ||
return __privateGet(this, _stream).shapeHandle; | ||
return this.stream.shapeHandle; | ||
} | ||
@@ -771,3 +770,3 @@ get rows() { | ||
return new Promise((resolve, reject) => { | ||
if (__privateGet(this, _stream).isUpToDate) { | ||
if (this.stream.isUpToDate) { | ||
resolve(this.currentValue); | ||
@@ -791,15 +790,15 @@ } else { | ||
lastSyncedAt() { | ||
return __privateGet(this, _stream).lastSyncedAt(); | ||
return this.stream.lastSyncedAt(); | ||
} | ||
/** Time elapsed since last sync (in ms). Infinity if we did not yet sync. */ | ||
lastSynced() { | ||
return __privateGet(this, _stream).lastSynced(); | ||
return this.stream.lastSynced(); | ||
} | ||
/** True during initial fetch. False afterwise. */ | ||
isLoading() { | ||
return __privateGet(this, _stream).isLoading(); | ||
return this.stream.isLoading(); | ||
} | ||
/** Indicates if we are connected to the Electric sync service. */ | ||
isConnected() { | ||
return __privateGet(this, _stream).isConnected(); | ||
return this.stream.isConnected(); | ||
} | ||
@@ -820,3 +819,2 @@ subscribe(callback) { | ||
}; | ||
_stream = new WeakMap(); | ||
_data = new WeakMap(); | ||
@@ -823,0 +821,0 @@ _subscribers2 = new WeakMap(); |
{ | ||
"name": "@electric-sql/client", | ||
"version": "0.9.0", | ||
"description": "Postgres everywhere - your data, in sync, wherever you need it.", | ||
"type": "module", | ||
"main": "dist/cjs/index.cjs", | ||
"module": "dist/index.legacy-esm.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"default": "./dist/cjs/index.cjs" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"sideEffects": false, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/electric-sql/electric.git" | ||
}, | ||
"version": "0.9.1", | ||
"author": "ElectricSQL team and contributors.", | ||
"license": "Apache-2", | ||
"bugs": { | ||
"url": "https://github.com/electric-sql/electric/issues" | ||
}, | ||
"homepage": "https://electric-sql.com", | ||
"dependencies": {}, | ||
@@ -52,5 +29,33 @@ "devDependencies": { | ||
}, | ||
"type": "module", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.cts", | ||
"default": "./dist/cjs/index.cjs" | ||
} | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"homepage": "https://electric-sql.com", | ||
"license": "Apache-2", | ||
"main": "./dist/cjs/index.cjs", | ||
"module": "./dist/index.legacy-esm.js", | ||
"types": "./dist/index.d.ts", | ||
"optionalDependencies": { | ||
"@rollup/rollup-darwin-arm64": "^4.18.1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/electric-sql/electric.git" | ||
}, | ||
"sideEffects": false, | ||
"typesVersions": { | ||
@@ -64,8 +69,8 @@ "*": { | ||
"scripts": { | ||
"build": "shx rm -rf dist && tsup && tsc -p tsconfig.build.json", | ||
"format": "eslint . --fix", | ||
"stylecheck": "eslint . --quiet", | ||
"test": "pnpm exec vitest", | ||
"typecheck": "tsc -p tsconfig.json", | ||
"build": "shx rm -rf dist && concurrently \"tsup\" \"tsc -p tsconfig.build.json\"", | ||
"stylecheck": "eslint . --quiet", | ||
"format": "eslint . --fix" | ||
"typecheck": "tsc -p tsconfig.json" | ||
} | ||
} |
@@ -193,3 +193,3 @@ import { | ||
onError?: (error: FetchError | Error) => void | ||
): void | ||
): () => void | ||
unsubscribeAll(): void | ||
@@ -196,0 +196,0 @@ |
@@ -180,3 +180,3 @@ import { | ||
const url = new URL(urlString) | ||
if (url.searchParams.has(LIVE_QUERY_PARAM, `true`)) { | ||
if (url.searchParams.get(LIVE_QUERY_PARAM) === `true`) { | ||
addMissingHeaders(requiredLiveResponseHeaders) | ||
@@ -187,3 +187,3 @@ } | ||
!url.searchParams.has(LIVE_QUERY_PARAM) || | ||
url.searchParams.has(LIVE_QUERY_PARAM, `false`) | ||
url.searchParams.get(LIVE_QUERY_PARAM) === `false` | ||
) { | ||
@@ -190,0 +190,0 @@ addMissingHeaders(requiredNonLiveResponseHeaders) |
@@ -49,3 +49,3 @@ import { Message, Offset, Row } from './types' | ||
export class Shape<T extends Row<unknown> = Row> { | ||
readonly #stream: ShapeStreamInterface<T> | ||
readonly stream: ShapeStreamInterface<T> | ||
@@ -59,4 +59,4 @@ readonly #data: ShapeData<T> = new Map() | ||
constructor(stream: ShapeStreamInterface<T>) { | ||
this.#stream = stream | ||
this.#stream.subscribe( | ||
this.stream = stream | ||
this.stream.subscribe( | ||
this.#process.bind(this), | ||
@@ -68,11 +68,11 @@ this.#handleError.bind(this) | ||
get isUpToDate(): boolean { | ||
return this.#stream.isUpToDate | ||
return this.stream.isUpToDate | ||
} | ||
get lastOffset(): Offset { | ||
return this.#stream.lastOffset | ||
return this.stream.lastOffset | ||
} | ||
get handle(): string | undefined { | ||
return this.#stream.shapeHandle | ||
return this.stream.shapeHandle | ||
} | ||
@@ -90,3 +90,3 @@ | ||
return new Promise((resolve, reject) => { | ||
if (this.#stream.isUpToDate) { | ||
if (this.stream.isUpToDate) { | ||
resolve(this.currentValue) | ||
@@ -113,3 +113,3 @@ } else { | ||
lastSyncedAt(): number | undefined { | ||
return this.#stream.lastSyncedAt() | ||
return this.stream.lastSyncedAt() | ||
} | ||
@@ -119,3 +119,3 @@ | ||
lastSynced() { | ||
return this.#stream.lastSynced() | ||
return this.stream.lastSynced() | ||
} | ||
@@ -125,3 +125,3 @@ | ||
isLoading() { | ||
return this.#stream.isLoading() | ||
return this.stream.isLoading() | ||
} | ||
@@ -131,3 +131,3 @@ | ||
isConnected(): boolean { | ||
return this.#stream.isConnected() | ||
return this.stream.isConnected() | ||
} | ||
@@ -134,0 +134,0 @@ |
@@ -26,2 +26,4 @@ /** | ||
export type Operation = `insert` | `update` | `delete` | ||
export type ControlMessage = { | ||
@@ -34,3 +36,3 @@ headers: Header & { control: `up-to-date` | `must-refetch` } | ||
value: T | ||
headers: Header & { operation: `insert` | `update` | `delete` } | ||
headers: Header & { operation: Operation } | ||
offset: Offset | ||
@@ -37,0 +39,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
450078
22
4543