@electric-sql/next
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -171,2 +171,3 @@ type Value = string | number | boolean | bigint | null | Value[] | { | ||
private fetchClient; | ||
private schema?; | ||
private subscribers; | ||
@@ -173,0 +174,0 @@ private upToDateSubscribers; |
@@ -40,2 +40,3 @@ var __defProp = Object.defineProperty; | ||
bool: parseBool, | ||
float4: parseNumber, | ||
float8: parseNumber, | ||
@@ -191,3 +192,3 @@ json: parseJson, | ||
async start() { | ||
var _a; | ||
var _a, _b; | ||
this.isUpToDate = false; | ||
@@ -232,9 +233,12 @@ const { url, where, signal } = this.options; | ||
} | ||
const schemaHeader = headers.get(`X-Electric-Schema`); | ||
const schema = schemaHeader ? JSON.parse(schemaHeader) : {}; | ||
const getSchema = () => { | ||
const schemaHeader = headers.get(`X-Electric-Schema`); | ||
return schemaHeader ? JSON.parse(schemaHeader) : {}; | ||
}; | ||
this.schema = (_a = this.schema) != null ? _a : getSchema(); | ||
const messages = status === 204 ? `[]` : await response.text(); | ||
const batch = this.messageParser.parse(messages, schema); | ||
const batch = this.messageParser.parse(messages, this.schema); | ||
if (batch.length > 0) { | ||
const lastMessage = batch[batch.length - 1]; | ||
if (((_a = lastMessage.headers) == null ? void 0 : _a[`control`]) === `up-to-date` && !this.isUpToDate) { | ||
if (((_b = lastMessage.headers) == null ? void 0 : _b[`control`]) === `up-to-date` && !this.isUpToDate) { | ||
this.isUpToDate = true; | ||
@@ -296,2 +300,3 @@ this.notifyUpToDateSubscribers(); | ||
this.isUpToDate = false; | ||
this.schema = void 0; | ||
} | ||
@@ -298,0 +303,0 @@ validateOptions(options) { |
{ | ||
"name": "@electric-sql/next", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Postgres everywhere - your data, in sync, wherever you need it.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
import { ArgumentsType } from 'vitest' | ||
import { Message, Value, Offset } from './types' | ||
import { Message, Value, Offset, Schema } from './types' | ||
import { MessageParser, Parser } from './parser' | ||
@@ -172,2 +172,3 @@ | ||
private fetchClient: typeof fetch | ||
private schema?: Schema | ||
@@ -259,8 +260,11 @@ private subscribers = new Map< | ||
const schemaHeader = headers.get(`X-Electric-Schema`)! | ||
const schema = schemaHeader ? JSON.parse(schemaHeader) : {} | ||
const getSchema = (): Schema => { | ||
const schemaHeader = headers.get(`X-Electric-Schema`) | ||
return schemaHeader ? JSON.parse(schemaHeader) : {} | ||
} | ||
this.schema = this.schema ?? getSchema() | ||
const messages = status === 204 ? `[]` : await response.text() | ||
const batch = this.messageParser.parse(messages, schema) | ||
const batch = this.messageParser.parse(messages, this.schema) | ||
@@ -351,2 +355,3 @@ // Update isUpToDate | ||
this.isUpToDate = false | ||
this.schema = undefined | ||
} | ||
@@ -353,0 +358,0 @@ |
@@ -19,2 +19,3 @@ import { ColumnInfo, Message, Schema, Value } from './types' | ||
bool: parseBool, | ||
float4: parseNumber, | ||
float8: parseNumber, | ||
@@ -21,0 +22,0 @@ json: parseJson, |
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
212159
2395