@linabase/js 0.3.0 → 0.3.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/index.cjs CHANGED
@@ -52,10 +52,9 @@ var DatabaseClient = class {
52
52
  // ─── Query Methods ──────────────────────────────────────
53
53
  /** Select columns. Supports nested joins: "*, comments(*)" and aliases: "full_name:name" */
54
54
  select(columns, options) {
55
- this.method = "GET";
56
- if (columns) this.params.set("select", columns);
55
+ this.method = options?.head ? "HEAD" : "GET";
56
+ if (columns && columns !== "*") this.params.set("select", columns);
57
57
  if (options?.count) this.preferHeaders.push(`count=${options.count}`);
58
- if (options?.head) this.method = "GET";
59
58
  return this;
60
59
  }
61
60
  insert(data) {
@@ -269,6 +268,7 @@ var DatabaseClient = class {
269
268
  async execute() {
270
269
  const qs = this.params.toString();
271
270
  const path = `/rest/v1/${this.table}${qs ? `?${qs}` : ""}`;
271
+ const isHead = this.method === "HEAD";
272
272
  const isSingle = this._single;
273
273
  const isMaybeSingle = this._maybeSingle;
274
274
  const shouldThrow = this._throwOnError;
@@ -301,8 +301,11 @@ var DatabaseClient = class {
301
301
  body: this.body ? JSON.stringify(this.body) : void 0,
302
302
  signal: abortSignal
303
303
  });
304
- const countHeader = res.headers.get("X-Total-Count");
304
+ const countHeader = res.headers.get("X-Total-Count") || res.headers.get("content-range")?.split("/")[1];
305
305
  const totalCount = countHeader ? parseInt(countHeader) : null;
306
+ if (isHead) {
307
+ return { data: null, error: res.ok ? null : { message: res.statusText }, count: totalCount };
308
+ }
306
309
  if (isCsv) {
307
310
  if (!res.ok) {
308
311
  const text = await res.text();
package/dist/index.js CHANGED
@@ -20,10 +20,9 @@ var DatabaseClient = class {
20
20
  // ─── Query Methods ──────────────────────────────────────
21
21
  /** Select columns. Supports nested joins: "*, comments(*)" and aliases: "full_name:name" */
22
22
  select(columns, options) {
23
- this.method = "GET";
24
- if (columns) this.params.set("select", columns);
23
+ this.method = options?.head ? "HEAD" : "GET";
24
+ if (columns && columns !== "*") this.params.set("select", columns);
25
25
  if (options?.count) this.preferHeaders.push(`count=${options.count}`);
26
- if (options?.head) this.method = "GET";
27
26
  return this;
28
27
  }
29
28
  insert(data) {
@@ -237,6 +236,7 @@ var DatabaseClient = class {
237
236
  async execute() {
238
237
  const qs = this.params.toString();
239
238
  const path = `/rest/v1/${this.table}${qs ? `?${qs}` : ""}`;
239
+ const isHead = this.method === "HEAD";
240
240
  const isSingle = this._single;
241
241
  const isMaybeSingle = this._maybeSingle;
242
242
  const shouldThrow = this._throwOnError;
@@ -269,8 +269,11 @@ var DatabaseClient = class {
269
269
  body: this.body ? JSON.stringify(this.body) : void 0,
270
270
  signal: abortSignal
271
271
  });
272
- const countHeader = res.headers.get("X-Total-Count");
272
+ const countHeader = res.headers.get("X-Total-Count") || res.headers.get("content-range")?.split("/")[1];
273
273
  const totalCount = countHeader ? parseInt(countHeader) : null;
274
+ if (isHead) {
275
+ return { data: null, error: res.ok ? null : { message: res.statusText }, count: totalCount };
276
+ }
274
277
  if (isCsv) {
275
278
  if (!res.ok) {
276
279
  const text = await res.text();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linabase/js",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "JavaScript/TypeScript client SDK for Linabase (database, storage, auth)",
5
5
  "license": "MIT",
6
6
  "type": "module",