@electric-sql/client 1.2.0 → 1.2.2

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.
@@ -327,6 +327,10 @@ function makeNullableParser(parser, columnInfo, columnName) {
327
327
  }
328
328
 
329
329
  // src/column-mapper.ts
330
+ function quoteIdentifier(identifier) {
331
+ const escaped = identifier.replace(/"/g, `""`);
332
+ return `"${escaped}"`;
333
+ }
330
334
  function snakeToCamel(str) {
331
335
  var _a, _b, _c, _d;
332
336
  const leadingUnderscores = (_b = (_a = str.match(/^_+/)) == null ? void 0 : _a[0]) != null ? _b : ``;
@@ -1491,7 +1495,7 @@ requestShape_fn = function() {
1491
1495
  };
1492
1496
  constructUrl_fn = function(url, resumingFromPause, subsetParams) {
1493
1497
  return __async(this, null, function* () {
1494
- var _a, _b, _c;
1498
+ var _a, _b, _c, _d;
1495
1499
  const [requestHeaders, params] = yield Promise.all([
1496
1500
  resolveHeaders(this.options.headers),
1497
1501
  this.options.params ? toInternalParams(convertWhereParamsToObj(this.options.params)) : void 0
@@ -1507,8 +1511,21 @@ constructUrl_fn = function(url, resumingFromPause, subsetParams) {
1507
1511
  );
1508
1512
  setQueryParam(fetchUrl, WHERE_QUERY_PARAM, encodedWhere);
1509
1513
  }
1510
- if (params.columns)
1511
- setQueryParam(fetchUrl, COLUMNS_QUERY_PARAM, params.columns);
1514
+ if (params.columns) {
1515
+ const originalColumns = yield resolveValue((_b = this.options.params) == null ? void 0 : _b.columns);
1516
+ if (Array.isArray(originalColumns)) {
1517
+ let encodedColumns = originalColumns.map(String);
1518
+ if (this.options.columnMapper) {
1519
+ encodedColumns = encodedColumns.map(
1520
+ this.options.columnMapper.encode
1521
+ );
1522
+ }
1523
+ const serializedColumns = encodedColumns.map(quoteIdentifier).join(`,`);
1524
+ setQueryParam(fetchUrl, COLUMNS_QUERY_PARAM, serializedColumns);
1525
+ } else {
1526
+ setQueryParam(fetchUrl, COLUMNS_QUERY_PARAM, params.columns);
1527
+ }
1528
+ }
1512
1529
  if (params.replica) setQueryParam(fetchUrl, REPLICA_PARAM, params.replica);
1513
1530
  if (params.params)
1514
1531
  setQueryParam(fetchUrl, WHERE_PARAMS_PARAM, params.params);
@@ -1526,7 +1543,7 @@ constructUrl_fn = function(url, resumingFromPause, subsetParams) {
1526
1543
  if (subsetParams.where && typeof subsetParams.where === `string`) {
1527
1544
  const encodedWhere = encodeWhereClause(
1528
1545
  subsetParams.where,
1529
- (_b = this.options.columnMapper) == null ? void 0 : _b.encode
1546
+ (_c = this.options.columnMapper) == null ? void 0 : _c.encode
1530
1547
  );
1531
1548
  setQueryParam(fetchUrl, SUBSET_PARAM_WHERE, encodedWhere);
1532
1549
  }
@@ -1542,7 +1559,7 @@ constructUrl_fn = function(url, resumingFromPause, subsetParams) {
1542
1559
  if (subsetParams.orderBy && typeof subsetParams.orderBy === `string`) {
1543
1560
  const encodedOrderBy = encodeWhereClause(
1544
1561
  subsetParams.orderBy,
1545
- (_c = this.options.columnMapper) == null ? void 0 : _c.encode
1562
+ (_d = this.options.columnMapper) == null ? void 0 : _d.encode
1546
1563
  );
1547
1564
  setQueryParam(fetchUrl, SUBSET_PARAM_ORDER_BY, encodedOrderBy);
1548
1565
  }
@@ -1693,10 +1710,13 @@ requestShapeSSE_fn = function(opts) {
1693
1710
  const { fetchUrl, requestAbortController, headers } = opts;
1694
1711
  const fetch2 = __privateGet(this, _sseFetchClient);
1695
1712
  __privateSet(this, _lastSseConnectionStartTime, Date.now());
1713
+ const sseHeaders = __spreadProps(__spreadValues({}, headers), {
1714
+ Accept: `text/event-stream`
1715
+ });
1696
1716
  try {
1697
1717
  let buffer = [];
1698
1718
  yield (0, import_fetch_event_source.fetchEventSource)(fetchUrl.toString(), {
1699
- headers,
1719
+ headers: sseHeaders,
1700
1720
  fetch: fetch2,
1701
1721
  onopen: (response) => __async(this, null, function* () {
1702
1722
  __privateSet(this, _connected, true);