camusdb 0.2.1 → 0.4.0

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.
Files changed (88) hide show
  1. package/README.md +92 -5
  2. package/dist/auth/rest-login-client.d.ts.map +1 -1
  3. package/dist/auth/rest-login-client.js +15 -1
  4. package/dist/auth/rest-login-client.js.map +1 -1
  5. package/dist/auth/token-provider.d.ts +14 -0
  6. package/dist/auth/token-provider.d.ts.map +1 -1
  7. package/dist/auth/token-provider.js +39 -11
  8. package/dist/auth/token-provider.js.map +1 -1
  9. package/dist/client.d.ts +84 -9
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +156 -14
  12. package/dist/client.js.map +1 -1
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/config.js +5 -0
  15. package/dist/config.js.map +1 -1
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/json.d.ts.map +1 -1
  21. package/dist/json.js +42 -8
  22. package/dist/json.js.map +1 -1
  23. package/dist/own-record.d.ts +16 -0
  24. package/dist/own-record.d.ts.map +1 -0
  25. package/dist/own-record.js +18 -0
  26. package/dist/own-record.js.map +1 -0
  27. package/dist/query-stream.d.ts +4 -4
  28. package/dist/query-stream.js +4 -4
  29. package/dist/result-set.d.ts +4 -2
  30. package/dist/result-set.d.ts.map +1 -1
  31. package/dist/result-set.js +25 -8
  32. package/dist/result-set.js.map +1 -1
  33. package/dist/retry.d.ts +4 -1
  34. package/dist/retry.d.ts.map +1 -1
  35. package/dist/retry.js +16 -4
  36. package/dist/retry.js.map +1 -1
  37. package/dist/sequence.d.ts +62 -0
  38. package/dist/sequence.d.ts.map +1 -0
  39. package/dist/sequence.js +70 -0
  40. package/dist/sequence.js.map +1 -0
  41. package/dist/sql-syntax.d.ts +31 -1
  42. package/dist/sql-syntax.d.ts.map +1 -1
  43. package/dist/sql-syntax.js +94 -1
  44. package/dist/sql-syntax.js.map +1 -1
  45. package/dist/statements.d.ts +5 -0
  46. package/dist/statements.d.ts.map +1 -1
  47. package/dist/statements.js +14 -0
  48. package/dist/statements.js.map +1 -1
  49. package/dist/transport/grpc/batch-frames.d.ts +7 -1
  50. package/dist/transport/grpc/batch-frames.d.ts.map +1 -1
  51. package/dist/transport/grpc/batch-frames.js +11 -3
  52. package/dist/transport/grpc/batch-frames.js.map +1 -1
  53. package/dist/transport/grpc/batcher.d.ts +7 -0
  54. package/dist/transport/grpc/batcher.d.ts.map +1 -1
  55. package/dist/transport/grpc/batcher.js +4 -0
  56. package/dist/transport/grpc/batcher.js.map +1 -1
  57. package/dist/transport/grpc/grpc-transport.d.ts +3 -1
  58. package/dist/transport/grpc/grpc-transport.d.ts.map +1 -1
  59. package/dist/transport/grpc/grpc-transport.js +22 -4
  60. package/dist/transport/grpc/grpc-transport.js.map +1 -1
  61. package/dist/transport/grpc/messages.d.ts +6 -0
  62. package/dist/transport/grpc/messages.d.ts.map +1 -1
  63. package/dist/transport/grpc/messages.js.map +1 -1
  64. package/dist/transport/http.d.ts.map +1 -1
  65. package/dist/transport/http.js +5 -1
  66. package/dist/transport/http.js.map +1 -1
  67. package/dist/transport/ndjson-row-source.d.ts.map +1 -1
  68. package/dist/transport/ndjson-row-source.js +16 -3
  69. package/dist/transport/ndjson-row-source.js.map +1 -1
  70. package/dist/transport/rest-transport.d.ts.map +1 -1
  71. package/dist/transport/rest-transport.js +18 -5
  72. package/dist/transport/rest-transport.js.map +1 -1
  73. package/dist/transport/transport.d.ts +25 -6
  74. package/dist/transport/transport.d.ts.map +1 -1
  75. package/dist/transport/transport.js.map +1 -1
  76. package/dist/values/encode.d.ts +2 -0
  77. package/dist/values/encode.d.ts.map +1 -1
  78. package/dist/values/encode.js +23 -2
  79. package/dist/values/encode.js.map +1 -1
  80. package/dist/values/typed.d.ts.map +1 -1
  81. package/dist/values/typed.js +22 -1
  82. package/dist/values/typed.js.map +1 -1
  83. package/dist/values/uuid.d.ts +7 -1
  84. package/dist/values/uuid.d.ts.map +1 -1
  85. package/dist/values/uuid.js +15 -6
  86. package/dist/values/uuid.js.map +1 -1
  87. package/package.json +1 -1
  88. package/proto/camus_sql.proto +17 -0
package/README.md CHANGED
@@ -231,7 +231,7 @@ change what the statement means.
231
231
  | `Uint8Array`, `Buffer`, `ArrayBuffer` | `Bytes` |
232
232
  | `Float32Array` | `Bytes`, packed as a vector |
233
233
  | `CamusObjectId` | `Id` |
234
- | an array | `Array`, with the element type read from the first element that is not null |
234
+ | an array | `Array`, with the element type read from the first element that is not null. When that element is a whole `number` and another `number` element is not whole, the element type is `Float64`. |
235
235
 
236
236
  A UUID-shaped string is **not** read as a `uuid`. A 36-character string that happens to look like
237
237
  one would otherwise change type silently.
@@ -269,6 +269,14 @@ await client.query('SELECT * FROM robots WHERE key = @key AND made = @made AND t
269
269
 
270
270
  An empty array needs `camus.array`: there is no element to read a type from.
271
271
 
272
+ Each helper validates its argument, so a bad value is reported at the call site rather than by the
273
+ server. `camus.id` takes the 24 hexadecimal characters of an ObjectId, and `camus.uuid` takes the
274
+ canonical hyphenated string.
275
+
276
+ A UUID string is always sent as a `Uuid`, also when an array declares its element type as
277
+ `ColumnType.Id`. A 16-byte UUID can never be a 12-byte ObjectId, so the server never matches it
278
+ against an `OID` column. `camus.array(uuids, ColumnType.Id)` therefore sends a `Uuid` array.
279
+
272
280
  ---
273
281
 
274
282
  ## Types
@@ -378,6 +386,47 @@ await client.insert('robots', {
378
386
 
379
387
  Column names carry no `@` here, because they bind to columns rather than to placeholders.
380
388
 
389
+ ### `INSERT … RETURNING`
390
+
391
+ An `INSERT` can send back values from the rows that it inserted. The values are the stored values,
392
+ so they include column defaults, sequence and identity values, and coerced types. Use `query`,
393
+ `queryOne`, or `scalar` to read them:
394
+
395
+ ```ts
396
+ const result = await client.query<{ id: string; name: string; doubled: number }>(
397
+ `INSERT INTO robots (id, name, year) VALUES (GEN_ID(), @name, @year)
398
+ RETURNING id, name, year * 2 AS doubled`,
399
+ { name: 'R2-D2', year: 1977 },
400
+ );
401
+
402
+ result.rows; // one row for each inserted row, in insert order
403
+ result.affectedRows; // the inserted-row count
404
+
405
+ const id = await client.scalar<string>(
406
+ 'INSERT INTO robots (id, name) VALUES (GEN_ID(), @name) RETURNING id',
407
+ { name: 'C-3PO' },
408
+ );
409
+ ```
410
+
411
+ - The driver sends an `INSERT` with a `RETURNING` clause to the non-query route, also when you
412
+ call `query`. The keyword test skips string literals, comments, backtick names, and
413
+ `@parameters`.
414
+ - `execute` returns the count only. The driver tells the server not to send the rows. The server
415
+ still checks the `RETURNING` list and the `SELECT` privilege.
416
+ - The `transactionOptions` of `query`, `queryOne`, `scalar`, and `queryStream` apply to the short
417
+ transaction of an `INSERT … RETURNING`. A read ignores them.
418
+ - The `RETURNING` list accepts `*`, columns, expressions, aliases, and parameters. It does not
419
+ accept aggregates, subqueries, or sequence functions.
420
+ - `INSERT … RETURNING` needs the `SELECT` privilege on the table, in addition to `INSERT`.
421
+ - `RETURNING` is a reserved word. A column or a table called `returning` needs backticks.
422
+ - The server has no `UPDATE … RETURNING` or `DELETE … RETURNING`.
423
+
424
+ `query`, `queryOne`, and `scalar` receive all rows in one reply. On gRPC, the server refuses a reply
425
+ that is larger than 4 MiB with `CADB0550`, before the commit, so the statement stores nothing. For
426
+ a large `INSERT … SELECT … RETURNING`, use `queryStream`. It sends the statement to the streaming
427
+ query endpoint, which sends no row before the commit. The stream reports no inserted-row count, so
428
+ count the rows as you read them.
429
+
381
430
  ### `TRUNCATE`
382
431
 
383
432
  `TRUNCATE` commits a replicated schema entry that a rollback cannot undo, so the server refuses it
@@ -458,6 +507,40 @@ Three codes belong to this feature:
458
507
  A read without a snapshot that keeps seeing a row change under it fails with the retryable
459
508
  `CADB0504`, which `withRetry` and `client.transaction` already retry.
460
509
 
510
+ ### Sequences
511
+
512
+ A server from 0.13.2 on has sequences. A sequence stores `int64` values only, has a positive
513
+ increment, and never cycles. The server refuses `CYCLE` with `CADB0533`, because a counter that
514
+ wraps would issue again the values that committed rows already hold.
515
+
516
+ `CREATE SEQUENCE`, `ALTER SEQUENCE`, and `DROP SEQUENCE` go to the DDL route. Two helpers compose
517
+ the create and the drop statements:
518
+
519
+ ```ts
520
+ import { createSequenceStatement, dropSequenceStatement, nextValueExpression } from 'camusdb';
521
+
522
+ await client.executeDdl(createSequenceStatement('ticket_numbers', { startWith: 1000, ifNotExists: true }));
523
+
524
+ await client.executeDdl(
525
+ `CREATE TABLE tickets (
526
+ id OID PRIMARY KEY NOT NULL,
527
+ number INT64 DEFAULT (${nextValueExpression('ticket_numbers')}),
528
+ subject STRING
529
+ )`,
530
+ );
531
+
532
+ const next = await client.nextSequenceValue('ticket_numbers'); // a bigint
533
+ ```
534
+
535
+ When you leave out `minValue`, the minimum is the server default, 1. The helper never writes
536
+ `NO MINVALUE`, because the server reads it as the smallest 64-bit value.
537
+
538
+ `nextSequenceValue` runs `SELECT nextval('…')`, inside the `transaction` option when you give one. A
539
+ rollback does not return the value: the server never issues a sequence value two times. Inside the
540
+ same transaction, `SELECT currval('…')` returns the value again. The server accepts `nextval` only
541
+ where it can count the values before the statement runs, so a `nextval` in a derived table fails
542
+ with `CADB0547`.
543
+
461
544
  ---
462
545
 
463
546
  ## Streaming
@@ -484,10 +567,14 @@ Two limits are worth knowing:
484
567
  - **It is incremental over REST only.** The gRPC data plane multiplexes results over shared streams
485
568
  that decode a whole result before returning, so gRPC buffers and replays. Your code is the same;
486
569
  the memory saving is not there.
487
- - **It gives up the transparent retry of a lost conflict.** Rows can reach you before the
488
- statement's own short transaction commits, so a conflict that surfaces late is raised from the
489
- iteration rather than retried. Use `query`, or drive an explicit transaction and retry it
490
- yourself, when you need that.
570
+ - **A lost conflict surfaces while you read.** Rows can reach you before the statement's own short
571
+ transaction commits, so a conflict that surfaces late is raised from the iteration rather than
572
+ from the call. The driver retries no autocommit statement, `query` included: run the work in
573
+ `client.transaction`, or wrap it in `withRetry`, when you need a retry.
574
+
575
+ `queryStream` also accepts an `INSERT … RETURNING`. The server sends no row of it before the
576
+ commit, so a conflict never surfaces mid-read for it. See
577
+ [`INSERT … RETURNING`](#insert--returning).
491
578
 
492
579
  ---
493
580
 
@@ -1 +1 @@
1
- {"version":3,"file":"rest-login-client.d.ts","sourceRoot":"","sources":["../../src/auth/rest-login-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAW5E;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IAChD,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,gBAAgB,CAAC;IA0BtB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB3G"}
1
+ {"version":3,"file":"rest-login-client.d.ts","sourceRoot":"","sources":["../../src/auth/rest-login-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAW5E;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;IAChD,KAAK,CACT,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,gBAAgB,CAAC;IA6CtB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB3G"}
@@ -26,7 +26,21 @@ export class RestLoginClient {
26
26
  const text = await readBody(response);
27
27
  if (!response.ok)
28
28
  throw translateErrorBody(response.status, text);
29
- const body = (text.length > 0 ? parseLossless(text) : null);
29
+ if (text.length === 0) {
30
+ // A 200 with nothing in it is a broken reply, not a rejected credential. Reporting it as
31
+ // `AuthenticationFailed` would make the provider throw away a token the server never
32
+ // refused.
33
+ throw new CamusError(CamusErrorCode.Generic, 'The login endpoint returned an empty body.');
34
+ }
35
+ let body;
36
+ try {
37
+ body = parseLossless(text);
38
+ }
39
+ catch (error) {
40
+ throw new CamusError(CamusErrorCode.Generic, 'The login endpoint returned a body that is not valid JSON.', {
41
+ cause: error,
42
+ });
43
+ }
30
44
  if (body === null || body.status !== 'ok' || body.token === undefined || body.token.length === 0) {
31
45
  throw new CamusError(body?.code ?? CamusErrorCode.AuthenticationFailed, body?.message ?? 'Authentication failed');
32
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rest-login-client.js","sourceRoot":"","sources":["../../src/auth/rest-login-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAY9E;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAC,KAAK,CACT,QAAgB,EAChB,IAAY,EACZ,QAAgB,EAChB,cAAsB,EACtB,MAAoB;QAEpB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE;YAC7C,QAAQ;YACR,IAAI,EAAE,CAAC,OAAO,CAAC;YACf,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,EAAE,IAAI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AAM;YACd,KAAK;YACL,cAAc;YACd,MAAM;SACP,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,kBAAkB,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEtF,+FAA+F;QAC/F,4CAA4C;QAC5C,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,IAAuB;IAC3C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;IAEnD,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,OAAO,GAAG,IAAI,CAAC;IAEvC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAEpD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzC,IAAI,SAAS,GAAG,CAAC;YAAE,OAAO,SAAS,CAAC;IACtC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -62,6 +62,11 @@ export declare class CamusTokenProvider {
62
62
  private readonly lifetimeMs;
63
63
  /** The single login in flight, if any. Every racing caller awaits this same promise. */
64
64
  private inFlight;
65
+ /**
66
+ * Which credential set a login belongs to. `login()` raises it, so a login started with the
67
+ * credentials that call replaced cannot publish its token over the new ones.
68
+ */
69
+ private generation;
65
70
  /** @internal Test hook: the wall clock this provider reads. */
66
71
  clock: () => number;
67
72
  constructor(init: {
@@ -109,6 +114,15 @@ export declare class CamusTokenProvider {
109
114
  */
110
115
  logout(signal?: AbortSignal): Promise<void>;
111
116
  private tryGetCached;
117
+ /**
118
+ * Starts the one login every racing caller joins.
119
+ *
120
+ * The finally clause clears `inFlight` only when it still points at this login. A login that
121
+ * `login()` superseded therefore leaves the newer flight in place, and a caller that arrives
122
+ * after it settles joins that flight rather than starting a third login against a rate-limited
123
+ * endpoint.
124
+ */
125
+ private startLogin;
112
126
  private loginOnce;
113
127
  /**
114
128
  * When to mint the next token.
@@ -1 +1 @@
1
- {"version":3,"file":"token-provider.d.ts","sourceRoot":"","sources":["../../src/auth/token-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAE5E,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,SAAU,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAA4C;IAE1E;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,GAAG,kBAAkB;IAIjF,wDAAwD;IACxD,MAAM,CAAC,WAAW,IAAI,IAAI;IAI1B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAmB;IAEtD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;IAW/E,OAAO,CAAC,WAAW,CAAmB;IAEtC,OAAO,CAAC,KAAK,CAAqB;IAElC,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqD;IAExF,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAe;IAE/C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAe;IAErD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAEpC,wFAAwF;IACxF,OAAO,CAAC,QAAQ,CAA8B;IAE9C,+DAA+D;IAC/D,KA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GAAG,SAAS,CAErC;IAED;;;OAGG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAWjE;;;;;;OAMG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAShD;;;OAGG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAalF;;;;OAIG;IACG,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjD,OAAO,CAAC,YAAY;IAOpB;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU;YASJ,SAAS;IAuCvB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;CAMvB"}
@@ -77,6 +77,11 @@ export class CamusTokenProvider {
77
77
  lifetimeMs;
78
78
  /** The single login in flight, if any. Every racing caller awaits this same promise. */
79
79
  inFlight;
80
+ /**
81
+ * Which credential set a login belongs to. `login()` raises it, so a login started with the
82
+ * credentials that call replaced cannot publish its token over the new ones.
83
+ */
84
+ generation = 0;
80
85
  /** @internal Test hook: the wall clock this provider reads. */
81
86
  clock = () => Date.now();
82
87
  constructor(init) {
@@ -119,9 +124,7 @@ export class CamusTokenProvider {
119
124
  if (!this.isEnabled)
120
125
  return undefined;
121
126
  // A caller that arrives during a login awaits that login rather than issuing its own.
122
- this.inFlight ??= this.loginOnce(signal).finally(() => {
123
- this.inFlight = undefined;
124
- });
127
+ this.inFlight ??= this.startLogin(signal);
125
128
  return this.inFlight;
126
129
  }
127
130
  /**
@@ -149,11 +152,11 @@ export class CamusTokenProvider {
149
152
  this.credentials = credentialsFromPassword(user, password);
150
153
  this.token = undefined;
151
154
  this.renewAfter = 0;
152
- const pending = this.loginOnce(signal).finally(() => {
153
- this.inFlight = undefined;
154
- });
155
- this.inFlight = pending;
156
- return pending;
155
+ // A login already in flight carries the credentials this call replaces. The new generation
156
+ // stops it from publishing its token, and it is no longer the flight a queued caller joins.
157
+ this.generation++;
158
+ this.inFlight = undefined;
159
+ return this.startLogin(signal);
157
160
  }
158
161
  /**
159
162
  * Revokes the cached token on the server and forgets it. The configured credentials are kept, so
@@ -176,6 +179,22 @@ export class CamusTokenProvider {
176
179
  return undefined;
177
180
  return this.clock() < this.renewAfter ? this.token : undefined;
178
181
  }
182
+ /**
183
+ * Starts the one login every racing caller joins.
184
+ *
185
+ * The finally clause clears `inFlight` only when it still points at this login. A login that
186
+ * `login()` superseded therefore leaves the newer flight in place, and a caller that arrives
187
+ * after it settles joins that flight rather than starting a third login against a rate-limited
188
+ * endpoint.
189
+ */
190
+ startLogin(signal) {
191
+ const pending = this.loginOnce(signal).finally(() => {
192
+ if (this.inFlight === pending)
193
+ this.inFlight = undefined;
194
+ });
195
+ this.inFlight = pending;
196
+ return pending;
197
+ }
179
198
  async loginOnce(signal) {
180
199
  // Re-checked inside the single-flight gate: the caller that queued behind the winner finds the
181
200
  // token it minted.
@@ -185,10 +204,19 @@ export class CamusTokenProvider {
185
204
  if (!this.canRenew) {
186
205
  throw new CamusError(CamusErrorCode.AuthenticationFailed, 'The supplied access token was rejected and this client has no credentials to obtain a new one.');
187
206
  }
207
+ // Both are read before the first await. A `login()` call during the round trip must not change
208
+ // which identity this flight authenticates as, and it must not let this flight publish a token
209
+ // over the credentials that call installed.
210
+ const credentials = this.credentials;
211
+ const generation = this.generation;
188
212
  const client = await this.resolveLoginClient();
189
- const minted = await client.login(this.resolveEndpoint(), this.credentials.user, this.credentials.password, this.resolveTimeoutSeconds(), signal);
190
- this.token = minted.token;
191
- this.renewAfter = this.clock() + this.renewalDelayMs(minted.expiresInMs);
213
+ const minted = await client.login(this.resolveEndpoint(), credentials.user, credentials.password, this.resolveTimeoutSeconds(), signal);
214
+ // A `login()` call during the round trip replaced the credentials this token was minted with.
215
+ // The caller that asked for it still receives it; it does not become the cached token.
216
+ if (generation === this.generation) {
217
+ this.token = minted.token;
218
+ this.renewAfter = this.clock() + this.renewalDelayMs(minted.expiresInMs);
219
+ }
192
220
  return minted.token;
193
221
  }
194
222
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"token-provider.js","sourceRoot":"","sources":["../../src/auth/token-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGrF,sFAAsF;AACtF,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAU,MAAM,GAAG,IAAI,cAAc,EAAsB,CAAC;IAE1E;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAW,EAAE,OAAiC;QAC1D,OAAO,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,wDAAwD;IACxD,MAAM,CAAC,WAAW;QAChB,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAED;;;;;;OAMG;IACK,MAAM,CAAU,WAAW,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IAEtD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,WAA6B,EAAE,aAAqB;QACpE,MAAM,QAAQ,GAAG;YACf,WAAW,CAAC,IAAI,IAAI,EAAE;YACtB,WAAW,CAAC,QAAQ,IAAI,EAAE;YAC1B,WAAW,CAAC,WAAW,IAAI,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CAAC,QAA4B;QACjD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC;QAEnD,MAAM,OAAO,GAAG,QAAQ,GAAG,GAAG,CAAC;QAC/B,OAAO,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACtC,CAAC"}
package/dist/client.d.ts CHANGED
@@ -28,7 +28,11 @@ export interface StatementOptions {
28
28
  }
29
29
  /** Options for a statement that begins its own short transaction. */
30
30
  export interface AutocommitStatementOptions extends StatementOptions {
31
- /** Concurrency knobs for the short transaction the server begins for this statement. */
31
+ /**
32
+ * Concurrency knobs for the short transaction the server begins for this statement. A read
33
+ * ignores them: it runs in a read-only snapshot. They apply to a write, which includes an
34
+ * `INSERT … RETURNING` that is sent through `query` or `queryStream`.
35
+ */
32
36
  readonly transactionOptions?: CamusTransactionOptions | undefined;
33
37
  }
34
38
  /** The rows of one query, and what the server reported about running it. */
@@ -38,6 +42,11 @@ export interface QueryResult<T> {
38
42
  /** The output columns, in order. Present even when there are no rows. */
39
43
  readonly columns: CamusColumn[];
40
44
  readonly rowCount: number;
45
+ /**
46
+ * The inserted-row count of an `INSERT … RETURNING` that `query` ran, or `undefined` for a read.
47
+ * The server sends one row for each inserted row, so it equals `rowCount`.
48
+ */
49
+ readonly affectedRows?: number | undefined;
41
50
  /** How a cache-hinted `SELECT` resolved, or `undefined` when the statement carried no hint. */
42
51
  readonly cacheMetadata?: CamusCacheMetadata | undefined;
43
52
  /**
@@ -138,18 +147,43 @@ export declare class CamusClient implements AsyncDisposable {
138
147
  * column to the JavaScript value its declared type calls for.
139
148
  *
140
149
  * Use `queryStream` when the result may be large: this method holds every row in memory.
150
+ *
151
+ * An `INSERT … RETURNING` is accepted here too. It goes to the non-query route, and the rows are
152
+ * the stored values of the inserted rows, in insert order:
153
+ *
154
+ * ```ts
155
+ * const { rows } = await client.query<{ id: string }>(
156
+ * 'INSERT INTO robots (id, name) VALUES (GEN_ID(), @name) RETURNING id',
157
+ * { name: 'R2-D2' },
158
+ * );
159
+ * ```
160
+ *
161
+ * All the rows of an `INSERT … RETURNING` arrive in one reply. On gRPC the server refuses a reply
162
+ * larger than 4 MiB with `CADB0550`, before the commit, so the statement stores nothing. Use
163
+ * `queryStream` for a large `INSERT … SELECT … RETURNING`.
164
+ */
165
+ query<T = Record<string, unknown>>(sql: string, parameters?: Parameters, options?: AutocommitStatementOptions): Promise<QueryResult<T>>;
166
+ /**
167
+ * Runs a `SELECT` and reads its first row, or `undefined` when it returned none. It accepts an
168
+ * `INSERT … RETURNING` as `query` does.
141
169
  */
142
- query<T = Record<string, unknown>>(sql: string, parameters?: Parameters, options?: StatementOptions): Promise<QueryResult<T>>;
143
- /** Runs a `SELECT` and reads its first row, or `undefined` when it returned none. */
144
- queryOne<T = Record<string, unknown>>(sql: string, parameters?: Parameters, options?: StatementOptions): Promise<T | undefined>;
170
+ queryOne<T = Record<string, unknown>>(sql: string, parameters?: Parameters, options?: AutocommitStatementOptions): Promise<T | undefined>;
145
171
  /**
146
172
  * Runs a `SELECT` and reads the first column of its first row, or `undefined`.
147
173
  *
148
174
  * ```ts
149
175
  * const total = await client.scalar<number>('SELECT COUNT(*) FROM robots');
150
176
  * ```
177
+ *
178
+ * It accepts an `INSERT … RETURNING` as `query` does, so it can read a generated key:
179
+ *
180
+ * ```ts
181
+ * const id = await client.scalar<string>('INSERT INTO robots (id, name) VALUES (GEN_ID(), @name) RETURNING id', {
182
+ * name: 'R2-D2',
183
+ * });
184
+ * ```
151
185
  */
152
- scalar<T = unknown>(sql: string, parameters?: Parameters, options?: StatementOptions): Promise<T | undefined>;
186
+ scalar<T = unknown>(sql: string, parameters?: Parameters, options?: AutocommitStatementOptions): Promise<T | undefined>;
153
187
  /**
154
188
  * Runs a `SELECT` and reports its rows one at a time, so a large result never fully materializes
155
189
  * on this side.
@@ -166,10 +200,17 @@ export declare class CamusClient implements AsyncDisposable {
166
200
  * shared streams that decode a whole result before returning, so this buffers and replays: the
167
201
  * caller's code is the same, but the memory saving is not there.
168
202
  *
169
- * The streaming path gives up the transparent retry of a serializable conflict that `query` has;
170
- * see `CamusQueryStream`.
203
+ * A serializable conflict is reported to the caller here, as it is on the buffered `query` path:
204
+ * neither path retries a statement on its own. Rows can reach this side before the statement's
205
+ * own short transaction commits, so a late conflict surfaces from the iteration. Run the work in
206
+ * `client.transaction`, or wrap the call in `withRetry`, when you need a retry.
207
+ *
208
+ * An `INSERT … RETURNING` is accepted here too, and goes to the same streaming query endpoint.
209
+ * Use this method for a `RETURNING` result that is too large for `query`. The server sends no row
210
+ * before the commit, so a conflict never surfaces mid-read for it. The stream reports no
211
+ * inserted-row count, so count the rows as you read them.
171
212
  */
172
- queryStream<T = Record<string, unknown>>(sql: string, parameters?: Parameters, options?: StatementOptions): Promise<CamusQueryStream<T>>;
213
+ queryStream<T = Record<string, unknown>>(sql: string, parameters?: Parameters, options?: AutocommitStatementOptions): Promise<CamusQueryStream<T>>;
173
214
  /**
174
215
  * Runs an `INSERT`, `UPDATE`, or `DELETE` and reports how many rows it changed.
175
216
  *
@@ -181,6 +222,10 @@ export declare class CamusClient implements AsyncDisposable {
181
222
  * ```
182
223
  *
183
224
  * A DDL statement is accepted here too and is sent to the DDL route, where it reports zero rows.
225
+ *
226
+ * For an `INSERT … RETURNING`, this reports the inserted-row count and the server does not send
227
+ * the rows. The server still checks the `RETURNING` list and the `SELECT` privilege that it needs.
228
+ * To read the rows, use `query`, `queryOne`, `scalar`, or `queryStream`.
184
229
  */
185
230
  execute(sql: string, parameters?: Parameters, options?: AutocommitStatementOptions): Promise<ExecuteResult>;
186
231
  /**
@@ -353,6 +398,23 @@ export declare class CamusClient implements AsyncDisposable {
353
398
  signal?: AbortSignal;
354
399
  timeoutSeconds?: number;
355
400
  }): Promise<void>;
401
+ /**
402
+ * Draws the next value of a sequence with `SELECT nextval('…')` and returns it as a `bigint`.
403
+ *
404
+ * ```ts
405
+ * const ticket = await client.nextSequenceValue('ticket_numbers');
406
+ * ```
407
+ *
408
+ * With a `transaction`, the call runs inside it. A rollback does not return the value: the server
409
+ * never issues a sequence value two times. Inside the same transaction, `SELECT currval('…')`
410
+ * returns the value again.
411
+ *
412
+ * The server accepts `nextval` only where it can count the values before the statement runs. A
413
+ * `nextval` in a derived table fails with `CADB0547`.
414
+ *
415
+ * @throws {TypeError} when the name cannot be a sequence name.
416
+ */
417
+ nextSequenceValue(name: string, options?: StatementOptions): Promise<bigint>;
356
418
  /** Drops every cached query result in one family, for the current database. */
357
419
  evictCache(name: string, options?: StatementOptions): Promise<void>;
358
420
  /** Drops every cached query result for the current database. It never touches another one's. */
@@ -366,7 +428,18 @@ export declare class CamusClient implements AsyncDisposable {
366
428
  */
367
429
  close(): Promise<void>;
368
430
  [Symbol.asyncDispose](): Promise<void>;
431
+ /**
432
+ * Runs a write and reports its count only. `discardReturningRows` has no effect on a statement
433
+ * without `RETURNING`, so this sets it on every statement and does not parse the SQL for the clause.
434
+ */
369
435
  private executeNonQuery;
436
+ /** Runs an `INSERT … RETURNING` on the non-query route and maps the rows it sent back. */
437
+ private queryInsertReturning;
438
+ /**
439
+ * Runs a write on the non-query route. The endpoint, the negotiation flag, and the learning after
440
+ * a success follow the same routing rules as the query path.
441
+ */
442
+ private executeNonQueryCore;
370
443
  /**
371
444
  * Resolves where one statement is sent, in strict order of precedence.
372
445
  *
@@ -408,7 +481,9 @@ export declare class CamusClient implements AsyncDisposable {
408
481
  * does decide is whether to ask again. A refusal specific to this statement stops asking for that
409
482
  * statement; anything that says the node has no prepared-statement support at all stops asking
410
483
  * for every statement, because one round trip per distinct SQL to relearn that is worse than not
411
- * trying.
484
+ * trying. A failure that never reached a verdict — a timeout, an unreachable node — drops the
485
+ * entry instead, so one network blip does not cost this statement its registration for the life
486
+ * of the process.
412
487
  */
413
488
  private register;
414
489
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;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