@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.17

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 (235) hide show
  1. package/README.md +111 -101
  2. package/app_meta.ts +56 -54
  3. package/config/config.ts +60 -57
  4. package/config/secrets.ts +45 -52
  5. package/config/value.ts +23 -26
  6. package/cron/mod.ts +28 -29
  7. package/dist/app_meta.d.ts +52 -50
  8. package/dist/app_meta.d.ts.map +1 -1
  9. package/dist/app_meta.js +2 -2
  10. package/dist/app_meta.js.map +1 -1
  11. package/dist/config/config.d.ts +58 -55
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +8 -9
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/secrets.d.ts +45 -52
  16. package/dist/config/secrets.d.ts.map +1 -1
  17. package/dist/config/secrets.js +8 -9
  18. package/dist/config/secrets.js.map +1 -1
  19. package/dist/config/value.d.ts +20 -23
  20. package/dist/config/value.d.ts.map +1 -1
  21. package/dist/config/value.js +20 -23
  22. package/dist/config/value.js.map +1 -1
  23. package/dist/cron/mod.d.ts +26 -27
  24. package/dist/cron/mod.d.ts.map +1 -1
  25. package/dist/cron/mod.js +13 -14
  26. package/dist/cron/mod.js.map +1 -1
  27. package/dist/frontends/mod.d.ts +20 -19
  28. package/dist/frontends/mod.d.ts.map +1 -1
  29. package/dist/frontends/mod.js +20 -19
  30. package/dist/frontends/mod.js.map +1 -1
  31. package/dist/gateway/errors.d.ts +28 -30
  32. package/dist/gateway/errors.d.ts.map +1 -1
  33. package/dist/gateway/errors.js +29 -31
  34. package/dist/gateway/errors.js.map +1 -1
  35. package/dist/gateway/match.d.ts +54 -54
  36. package/dist/gateway/match.d.ts.map +1 -1
  37. package/dist/gateway/match.js +56 -56
  38. package/dist/gateway/match.js.map +1 -1
  39. package/dist/gateway/middleware.d.ts +62 -64
  40. package/dist/gateway/middleware.d.ts.map +1 -1
  41. package/dist/gateway/middleware.js +1 -1
  42. package/dist/gateway/middleware.js.map +1 -1
  43. package/dist/gateway/mod.d.ts +64 -67
  44. package/dist/gateway/mod.d.ts.map +1 -1
  45. package/dist/gateway/mod.js +72 -76
  46. package/dist/gateway/mod.js.map +1 -1
  47. package/dist/gateway/request.d.ts +138 -134
  48. package/dist/gateway/request.d.ts.map +1 -1
  49. package/dist/gateway/request.js +117 -108
  50. package/dist/gateway/request.js.map +1 -1
  51. package/dist/gateway/serve.d.ts +29 -34
  52. package/dist/gateway/serve.d.ts.map +1 -1
  53. package/dist/gateway/serve.js +51 -56
  54. package/dist/gateway/serve.js.map +1 -1
  55. package/dist/gateways/mod.d.ts +23 -21
  56. package/dist/gateways/mod.d.ts.map +1 -1
  57. package/dist/gateways/mod.js +25 -23
  58. package/dist/gateways/mod.js.map +1 -1
  59. package/dist/internal/runtime/napi/napi.cjs +1 -1
  60. package/dist/internal/runtime/napi/napi.d.cts +10 -3
  61. package/dist/internal/runtime/shutdown.d.ts +75 -57
  62. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  63. package/dist/internal/runtime/shutdown.js +88 -84
  64. package/dist/internal/runtime/shutdown.js.map +1 -1
  65. package/dist/log/logger.d.ts +43 -37
  66. package/dist/log/logger.d.ts.map +1 -1
  67. package/dist/log/logger.js +26 -25
  68. package/dist/log/logger.js.map +1 -1
  69. package/dist/metrics/mod.d.ts +133 -114
  70. package/dist/metrics/mod.d.ts.map +1 -1
  71. package/dist/metrics/mod.js +109 -101
  72. package/dist/metrics/mod.js.map +1 -1
  73. package/dist/otel.d.ts +6 -3
  74. package/dist/otel.d.ts.map +1 -1
  75. package/dist/otel.js +6 -3
  76. package/dist/otel.js.map +1 -1
  77. package/dist/pubsub/subscription.d.ts +88 -116
  78. package/dist/pubsub/subscription.d.ts.map +1 -1
  79. package/dist/pubsub/subscription.js +14 -17
  80. package/dist/pubsub/subscription.js.map +1 -1
  81. package/dist/pubsub/topic.d.ts +86 -113
  82. package/dist/pubsub/topic.d.ts.map +1 -1
  83. package/dist/pubsub/topic.js +68 -82
  84. package/dist/pubsub/topic.js.map +1 -1
  85. package/dist/reqctx/mod.d.ts +83 -86
  86. package/dist/reqctx/mod.d.ts.map +1 -1
  87. package/dist/reqctx/mod.js +39 -41
  88. package/dist/reqctx/mod.js.map +1 -1
  89. package/dist/services/index.d.ts +76 -75
  90. package/dist/services/index.d.ts.map +1 -1
  91. package/dist/services/index.js +73 -71
  92. package/dist/services/index.js.map +1 -1
  93. package/dist/shutdown/mod.d.ts +26 -25
  94. package/dist/shutdown/mod.d.ts.map +1 -1
  95. package/dist/shutdown/mod.js +26 -25
  96. package/dist/shutdown/mod.js.map +1 -1
  97. package/dist/storage/clickhouse/database.d.ts +113 -115
  98. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  99. package/dist/storage/clickhouse/database.js +65 -79
  100. package/dist/storage/clickhouse/database.js.map +1 -1
  101. package/dist/storage/clickhouse/errors.d.ts +25 -26
  102. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  103. package/dist/storage/clickhouse/errors.js +15 -17
  104. package/dist/storage/clickhouse/errors.js.map +1 -1
  105. package/dist/storage/clickhouse/mod.d.ts +10 -10
  106. package/dist/storage/clickhouse/mod.js +10 -10
  107. package/dist/storage/objects/bucket.d.ts +196 -225
  108. package/dist/storage/objects/bucket.d.ts.map +1 -1
  109. package/dist/storage/objects/bucket.js +71 -84
  110. package/dist/storage/objects/bucket.js.map +1 -1
  111. package/dist/storage/objects/error.d.ts +4 -4
  112. package/dist/storage/objects/error.js +4 -4
  113. package/dist/storage/postgres/database.d.ts +124 -149
  114. package/dist/storage/postgres/database.d.ts.map +1 -1
  115. package/dist/storage/postgres/database.js +98 -135
  116. package/dist/storage/postgres/database.js.map +1 -1
  117. package/dist/storage/postgres/errors.d.ts +42 -48
  118. package/dist/storage/postgres/errors.d.ts.map +1 -1
  119. package/dist/storage/postgres/errors.js +44 -51
  120. package/dist/storage/postgres/errors.js.map +1 -1
  121. package/dist/storage/postgres/interval.d.ts +19 -19
  122. package/dist/storage/postgres/interval.d.ts.map +1 -1
  123. package/dist/storage/postgres/interval.js +21 -21
  124. package/dist/storage/postgres/interval.js.map +1 -1
  125. package/dist/storage/redis/bitfield.d.ts +48 -23
  126. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  127. package/dist/storage/redis/bitfield.js +38 -19
  128. package/dist/storage/redis/bitfield.js.map +1 -1
  129. package/dist/storage/redis/command.d.ts +16 -12
  130. package/dist/storage/redis/command.d.ts.map +1 -1
  131. package/dist/storage/redis/command.js +16 -12
  132. package/dist/storage/redis/command.js.map +1 -1
  133. package/dist/storage/redis/commands.d.ts +99 -100
  134. package/dist/storage/redis/commands.d.ts.map +1 -1
  135. package/dist/storage/redis/commands.js +84 -85
  136. package/dist/storage/redis/commands.js.map +1 -1
  137. package/dist/storage/redis/database.d.ts +138 -122
  138. package/dist/storage/redis/database.d.ts.map +1 -1
  139. package/dist/storage/redis/database.js +120 -101
  140. package/dist/storage/redis/database.js.map +1 -1
  141. package/dist/storage/redis/mod.d.ts +52 -48
  142. package/dist/storage/redis/mod.d.ts.map +1 -1
  143. package/dist/storage/redis/mod.js +52 -48
  144. package/dist/storage/redis/mod.js.map +1 -1
  145. package/dist/storage/redis/options.d.ts +26 -24
  146. package/dist/storage/redis/options.d.ts.map +1 -1
  147. package/dist/storage/redis/options.js.map +1 -1
  148. package/dist/storage/redis/pubsub.d.ts +16 -16
  149. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  150. package/dist/storage/redis/pubsub.js +14 -14
  151. package/dist/storage/redis/pubsub.js.map +1 -1
  152. package/dist/storage/redis/reply.d.ts +80 -72
  153. package/dist/storage/redis/reply.d.ts.map +1 -1
  154. package/dist/storage/redis/reply.js +53 -46
  155. package/dist/storage/redis/reply.js.map +1 -1
  156. package/dist/storage/redis/scan.d.ts +4 -4
  157. package/dist/storage/redis/scan.d.ts.map +1 -1
  158. package/dist/storage/redis/scan.js +6 -6
  159. package/dist/storage/redis/scan.js.map +1 -1
  160. package/dist/storage/redis/script.d.ts +28 -21
  161. package/dist/storage/redis/script.d.ts.map +1 -1
  162. package/dist/storage/redis/script.js +29 -22
  163. package/dist/storage/redis/script.js.map +1 -1
  164. package/dist/storage/redis/target.d.ts +17 -1
  165. package/dist/storage/redis/target.d.ts.map +1 -1
  166. package/dist/storage/redis/target.js +30 -1
  167. package/dist/storage/redis/target.js.map +1 -1
  168. package/dist/storage/redis/wire.d.ts +6 -6
  169. package/dist/storage/redis/wire.d.ts.map +1 -1
  170. package/dist/storage/redis/wire.js +6 -6
  171. package/dist/storage/redis/wire.js.map +1 -1
  172. package/dist/testing/mod.d.ts +83 -88
  173. package/dist/testing/mod.d.ts.map +1 -1
  174. package/dist/testing/mod.js +75 -81
  175. package/dist/testing/mod.js.map +1 -1
  176. package/dist/testing/playwright.d.ts +28 -32
  177. package/dist/testing/playwright.d.ts.map +1 -1
  178. package/dist/testing/playwright.js +22 -27
  179. package/dist/testing/playwright.js.map +1 -1
  180. package/dist/testing/puppeteer.d.ts +11 -12
  181. package/dist/testing/puppeteer.d.ts.map +1 -1
  182. package/dist/testing/puppeteer.js +17 -18
  183. package/dist/testing/puppeteer.js.map +1 -1
  184. package/dist/testing/system.d.ts +72 -90
  185. package/dist/testing/system.d.ts.map +1 -1
  186. package/dist/testing/system.js +90 -107
  187. package/dist/testing/system.js.map +1 -1
  188. package/dist/tsconfig.build.tsbuildinfo +1 -1
  189. package/frontends/mod.test.ts +6 -2
  190. package/frontends/mod.ts +20 -19
  191. package/gateway/errors.ts +30 -32
  192. package/gateway/match.ts +61 -57
  193. package/gateway/middleware.ts +62 -64
  194. package/gateway/mod.ts +73 -76
  195. package/gateway/request.ts +143 -140
  196. package/gateway/serve.ts +58 -63
  197. package/gateways/mod.ts +25 -23
  198. package/internal/runtime/napi/napi.cjs +1 -1
  199. package/internal/runtime/napi/napi.d.cts +10 -3
  200. package/internal/runtime/shutdown.ts +113 -101
  201. package/log/logger.test.ts +8 -0
  202. package/log/logger.ts +48 -45
  203. package/metrics/mod.ts +138 -122
  204. package/otel.ts +6 -3
  205. package/package.json +1 -1
  206. package/pubsub/subscription.ts +93 -123
  207. package/pubsub/topic.ts +96 -130
  208. package/reqctx/mod.ts +83 -86
  209. package/services/index.ts +78 -78
  210. package/shutdown/mod.ts +26 -25
  211. package/storage/clickhouse/database.ts +115 -129
  212. package/storage/clickhouse/errors.ts +27 -29
  213. package/storage/clickhouse/mod.ts +10 -10
  214. package/storage/objects/bucket.ts +209 -239
  215. package/storage/objects/error.ts +4 -4
  216. package/storage/postgres/database.ts +131 -164
  217. package/storage/postgres/errors.ts +45 -52
  218. package/storage/postgres/interval.ts +21 -21
  219. package/storage/redis/bitfield.ts +51 -26
  220. package/storage/redis/command.ts +16 -12
  221. package/storage/redis/commands.ts +99 -100
  222. package/storage/redis/database.ts +145 -123
  223. package/storage/redis/mod.ts +52 -48
  224. package/storage/redis/options.ts +26 -24
  225. package/storage/redis/pubsub.ts +14 -14
  226. package/storage/redis/redis.test.ts +17 -2
  227. package/storage/redis/reply.ts +85 -77
  228. package/storage/redis/scan.ts +6 -6
  229. package/storage/redis/script.ts +29 -22
  230. package/storage/redis/target.ts +34 -1
  231. package/storage/redis/wire.ts +8 -8
  232. package/testing/mod.ts +99 -105
  233. package/testing/playwright.ts +32 -37
  234. package/testing/puppeteer.ts +22 -23
  235. package/testing/system.ts +117 -133
@@ -3,20 +3,20 @@ import * as runtime from '../../internal/runtime/mod.js';
3
3
  import { currentScope, testMode } from '../../internal/testing/scope.js';
4
4
  import { Decimal } from '../../types/mod.js';
5
5
  import { native, nativeSync, TooManyRowsError } from './errors.js';
6
- /** The marker the native module recognizes a {@link Typed} by: on the
7
- * prototype, so a parameter that is an object of data is never taken for one. */
6
+ /** Prototype marker used by the native module to identify {@link Typed} wrappers. */
8
7
  const TYPED_MARKER = '__encore_clickhouse_type';
9
8
  /**
10
- * A value with the ClickHouse type it is bound as: see {@link typed}.
9
+ * Wraps a query parameter value with an explicit ClickHouse type (see
10
+ * {@link typed}).
11
11
  */
12
12
  export class Typed {
13
13
  value;
14
14
  type;
15
15
  /** @internal */
16
16
  constructor(
17
- /** The value. */
17
+ /** The parameter value. */
18
18
  value,
19
- /** Its ClickHouse type, such as `'UUID'` or `'Array(UInt32)'`. */
19
+ /** Explicit ClickHouse type name (e.g. `'UUID'` or `'Array(UInt32)'`). */
20
20
  type) {
21
21
  this.value = value;
22
22
  this.type = type;
@@ -24,10 +24,10 @@ export class Typed {
24
24
  }
25
25
  Object.defineProperty(Typed.prototype, TYPED_MARKER, { value: true });
26
26
  /**
27
- * Binds `value` as the ClickHouse type `type` rather than the one inferred
28
- * from it, in a tagged template: `` ${typed(id, 'UUID')} `` becomes
29
- * `{p0:UUID}`. A `Date` bound as `DateTime` is its whole seconds, and as
30
- * `Date` or `Date32` its day in UTC.
27
+ * Binds `value` as the explicit ClickHouse type `type` instead of inferring
28
+ * one in tagged-template queries (e.g. `` ${typed(id, 'UUID')} `` emits
29
+ * `{p0:UUID}`). A `Date` bound as `DateTime` truncates to whole seconds; bound
30
+ * as `Date` or `Date32`, it uses the UTC calendar date.
31
31
  *
32
32
  * @example
33
33
  * await db.queryAll`SELECT * FROM events WHERE user_id = ${typed(userId, 'UUID')}`;
@@ -35,7 +35,7 @@ Object.defineProperty(Typed.prototype, TYPED_MARKER, { value: true });
35
35
  export function typed(value, type) {
36
36
  return new Typed(value, type);
37
37
  }
38
- /** Base class with the query methods every handle has. */
38
+ /** Base class providing shared ClickHouse query and execution methods. */
39
39
  class BaseQueryExecutor {
40
40
  handle;
41
41
  access;
@@ -44,71 +44,70 @@ class BaseQueryExecutor {
44
44
  this.handle = handle;
45
45
  this.access = access;
46
46
  }
47
- /** The native database: in test mode the current test's instance. */
47
+ /** Native database handle (resolves to the current test's instance in test mode). */
48
48
  get impl() {
49
49
  return typeof this.handle === 'function' ? this.handle() : this.handle;
50
50
  }
51
51
  /**
52
- * The connection string to connect to the database with another client,
53
- * as this handle's user: `http://user:password@host:port/database`.
54
- * `@clickhouse/client` reads it as its `url`.
52
+ * HTTP connection string (`http://user:password@host:port/database`) scoped
53
+ * to this handle's access level, compatible with `@clickhouse/client`'s `url`
54
+ * option.
55
55
  */
56
56
  get connectionString() {
57
57
  return nativeSync(() => this.impl.connectionString(this.access));
58
58
  }
59
59
  /**
60
- * Queries the database with a template string, binding each `${value}` as
61
- * a parameter of the type inferred from it (see {@link Param}):
62
- * `` query`SELECT * FROM events WHERE id = ${id}` `` runs `SELECT * FROM
63
- * events WHERE id = {p0:Int64}`. Wrap a value in {@link typed} to bind it
64
- * as another type.
65
- *
66
- * It streams the rows: iterate it with `for await`.
60
+ * Streams rows from a tagged-template query, binding each `${value}` as a
61
+ * typed server parameter (see {@link Param}). For example,
62
+ * `` query`SELECT * FROM events WHERE id = ${id}` `` sends
63
+ * `SELECT * FROM events WHERE id = {p0:Int64}`. Use {@link typed} to
64
+ * override the inferred type. Iterate results with `for await`.
67
65
  */
68
66
  async *query(strings, ...params) {
69
67
  const { sql, args } = buildQuery(strings, params);
70
68
  yield* this.rows(sql, args, undefined);
71
69
  }
72
70
  /**
73
- * Queries the database with SQL whose parameters it names, with their
74
- * types, as `{name:Type}`, and `params` their values by name:
71
+ * Streams rows from a raw SQL query with named typed placeholders (such as
72
+ * `{id:UInt64}`) and matching entries in `params`. Iterate results with
73
+ * `for await`.
75
74
  *
76
75
  * ```ts
77
76
  * db.rawQuery('SELECT * FROM events WHERE id = {id:UInt64}', {id: 5});
78
77
  * ```
79
- *
80
- * It streams the rows: iterate it with `for await`.
81
78
  */
82
79
  async *rawQuery(sql, params, options) {
83
80
  yield* this.rows(sql, namedParams(params), options);
84
81
  }
85
- /** {@link query}, returning every row. */
82
+ /** Runs a tagged-template query (like {@link query}) and collects all rows into an array. */
86
83
  async queryAll(strings, ...params) {
87
84
  const { sql, args } = buildQuery(strings, params);
88
85
  return this.all(sql, args, undefined);
89
86
  }
90
- /** {@link rawQuery}, returning every row. */
87
+ /** Runs a raw query (like {@link rawQuery}) and collects all rows into an array. */
91
88
  async rawQueryAll(sql, params, options) {
92
89
  return this.all(sql, namedParams(params), options);
93
90
  }
94
91
  /**
95
- * {@link query}, returning its one row: `null` if there is none, and a
96
- * {@link TooManyRowsError} if there is more than one.
92
+ * Runs a tagged-template query (like {@link query}) expecting at most one
93
+ * row. Returns `null` if no rows match, or throws {@link TooManyRowsError}
94
+ * if more than one row is returned.
97
95
  */
98
96
  async queryRow(strings, ...params) {
99
97
  const { sql, args } = buildQuery(strings, params);
100
98
  return this.one(sql, args, undefined);
101
99
  }
102
100
  /**
103
- * {@link rawQuery}, returning its one row: `null` if there is none, and a
104
- * {@link TooManyRowsError} if there is more than one.
101
+ * Runs a raw query (like {@link rawQuery}) expecting at most one row.
102
+ * Returns `null` if no rows match, or throws {@link TooManyRowsError} if
103
+ * more than one row is returned.
105
104
  */
106
105
  async rawQueryRow(sql, params, options) {
107
106
  return this.one(sql, namedParams(params), options);
108
107
  }
109
108
  /**
110
- * Runs a statement with a template string, binding each `${value}` as
111
- * {@link query} does, and discards any rows it returns.
109
+ * Executes a tagged-template statement (binding `${value}` placeholders like
110
+ * {@link query}) and discards any returned rows.
112
111
  *
113
112
  * @example
114
113
  * await db.exec`ALTER TABLE events DELETE WHERE user_id = ${id}`;
@@ -118,21 +117,20 @@ class BaseQueryExecutor {
118
117
  return this.run(sql, args, undefined);
119
118
  }
120
119
  /**
121
- * Runs a statement whose parameters it names, as {@link rawQuery} does,
122
- * and discards any rows it returns.
120
+ * Executes a raw statement with named typed parameters (like
121
+ * {@link rawQuery}) and discards any returned rows.
123
122
  */
124
123
  async rawExec(sql, params, options) {
125
124
  return this.run(sql, namedParams(params), options);
126
125
  }
127
126
  /**
128
- * Inserts `rows` into `table` (`table`, or `database.table`). Each row is
129
- * an object, or a `Map`, keyed by column name. The columns are those the
130
- * rows have keys for; a row without one of them, or with it `undefined`,
131
- * leaves it out, so it gets the column's default. `null` is `NULL`, which
132
- * a column that isn't `Nullable` also takes as its default.
127
+ * Bulk-inserts `rows` into `table` (`table` or `database.table`). Each row
128
+ * is an object or `Map` keyed by column name. Omitted or `undefined` fields
129
+ * use the column's default; `null` inserts `NULL` (or the column default for
130
+ * non-`Nullable` columns).
133
131
  *
134
- * The rows travel as JSON: binary strings that aren't UTF-8 don't survive
135
- * it, so insert those with a parameterized `INSERT … VALUES`.
132
+ * Rows are serialized as JSON, so non-UTF-8 binary strings are not preserved
133
+ * — use a parameterized `INSERT ... VALUES` statement for binary data.
136
134
  *
137
135
  * @example
138
136
  * await db.insert('events', [
@@ -211,26 +209,25 @@ class BaseQueryExecutor {
211
209
  }
212
210
  }
213
211
  /**
214
- * A query handle that can be passed to application/library code. Obtain one
215
- * with `read()`, `write()` or `admin()`. A `Database` declaration
216
- * deliberately does not implement this class.
212
+ * A scoped query handle safe to pass into application or library code. Obtain
213
+ * one with `read()`, `write()`, or `admin()`. {@link Database} deliberately
214
+ * does not extend `Queryable`.
217
215
  */
218
216
  export class Queryable extends BaseQueryExecutor {
219
217
  queryableBrand = true;
220
218
  }
221
219
  /**
222
- * A handle to a database with one access level, which Encore's parser
223
- * records where it is made:
220
+ * A ClickHouse database handle scoped to a specific access level recorded by
221
+ * Encore's parser where it is created:
224
222
  *
225
- * - `read()`: `SELECT` and `SHOW`. Its writes are refused, by its user's
226
- * grants, or the `readonly` setting when the runtime config gives the read
227
- * level no user of its own.
228
- * - `write()`: reads, and `INSERT`, `ALTER … UPDATE/DELETE` and lightweight
223
+ * - `read()`: `SELECT` and `SHOW` only (writes are rejected by the user's
224
+ * grants or the `readonly` setting).
225
+ * - `write()`: reads plus `INSERT`, `ALTER ... UPDATE/DELETE`, and lightweight
229
226
  * `DELETE`.
230
- * - `admin()`: anything on the database: DDL, `TRUNCATE`, `OPTIMIZE`.
227
+ * - `admin()`: full access including DDL, `TRUNCATE`, and `OPTIMIZE`.
231
228
  *
232
- * Each level is its own ClickHouse user, so its connection string connects
233
- * with that level's grants.
229
+ * Each access level uses its own ClickHouse user, so `connectionString`
230
+ * connects with matching grants.
234
231
  */
235
232
  export class DatabaseRef extends Queryable {
236
233
  /** @internal */
@@ -239,13 +236,13 @@ export class DatabaseRef extends Queryable {
239
236
  }
240
237
  }
241
238
  /**
242
- * A ClickHouse database. Constructing one makes Encore provision a database
243
- * with that name, run its migrations, and return this object to represent
244
- * it. Its own methods have write access; `read()`, `write()` and `admin()`
245
- * select a level.
239
+ * Declares a ClickHouse database. Encore provisions the database, runs its
240
+ * migrations, and returns this handle. Methods called directly on `Database`
241
+ * run with write access; call `read()`, `write()`, or `admin()` to obtain a
242
+ * handle with a specific access level.
246
243
  *
247
- * If you want to reference an existing database, use `Database.named(name)`,
248
- * as it is a compile error to create duplicate databases.
244
+ * To reference an existing database without declaring a duplicate, use
245
+ * {@link Database.named}.
249
246
  *
250
247
  * @example
251
248
  * import { Database } from "@encore.dev/sdk/storage/clickhouse";
@@ -266,21 +263,21 @@ export class Database extends BaseQueryExecutor {
266
263
  this.handles = handle;
267
264
  }
268
265
  /**
269
- * Reference an existing database by name. If the database doesn't exist
270
- * yet, use `new Database(name)` instead.
266
+ * References an existing ClickHouse database by name. Use
267
+ * `new Database(name)` to declare a new database.
271
268
  */
272
269
  static named(name) {
273
270
  return new Database(name);
274
271
  }
275
- /** Select read access: `SELECT` and `SHOW`. */
272
+ /** Returns a read-only handle (`SELECT` and `SHOW`). */
276
273
  read() {
277
274
  return this.ref(runtime.ClickHouseAccess.Read);
278
275
  }
279
- /** Select read and write access: also `INSERT` and mutations. */
276
+ /** Returns a read-write handle (`SELECT`, `INSERT`, and mutations). */
280
277
  write() {
281
278
  return this.ref(runtime.ClickHouseAccess.Write);
282
279
  }
283
- /** Select read, write and admin access: anything on the database. */
280
+ /** Returns an admin handle with full access (including DDL). */
284
281
  admin() {
285
282
  return this.ref(runtime.ClickHouseAccess.Admin);
286
283
  }
@@ -293,21 +290,13 @@ export class Database extends BaseQueryExecutor {
293
290
  return ref;
294
291
  }
295
292
  }
296
- /**
297
- * The handle of the database `name` in test mode, for each call: the current
298
- * test's instance of it, or the process's own outside any test, made on
299
- * first use.
300
- */
293
+ /** Resolves the ClickHouse handle for `name` in test mode (per-test or process fallback). */
301
294
  function testHandle(name) {
302
295
  let own;
303
296
  return () => currentScope()?.clickhouseDatabase(name) ??
304
297
  (own ??= runtime.RT.clickhouseDatabase(name));
305
298
  }
306
- /**
307
- * A tagged template's SQL, each `${value}` a `{pN:Type}` placeholder, and its
308
- * parameters. The types are the native module's: the ones it infers from the
309
- * values it converts, or those {@link typed} gave them.
310
- */
299
+ /** Compiles a tagged template into SQL with `{pN:Type}` placeholders and bound native params. */
311
300
  function buildQuery(strings, params) {
312
301
  const names = params.map((_, i) => `p${i}`);
313
302
  const args = nativeSync(() => new runtime.ClickHouseParams(names, params.map(prepare)));
@@ -324,10 +313,7 @@ function namedParams(params) {
324
313
  const entries = Object.entries(params ?? {});
325
314
  return nativeSync(() => new runtime.ClickHouseParams(entries.map(([name]) => name), entries.map(([, value]) => prepare(value))));
326
315
  }
327
- /**
328
- * `value` as the native module takes it: a `Decimal` as its text, bound as
329
- * `Decimal(76, s)`, in an array too.
330
- */
316
+ /** Converts `Decimal` values (including inside arrays) into explicit `Typed` values for the native layer. */
331
317
  function prepare(value) {
332
318
  if (value instanceof Decimal) {
333
319
  const text = value.toString();
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../../storage/clickhouse/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAwG9D;iFACiF;AACjF,MAAM,YAAY,GAAG,0BAA0B,CAA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AAiC;IAEjC,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;IACnC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC;YACP,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,CAA4B;IAC9C,OAAO;QACL,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,YAAY,EAAE,CAAC,CAAC,YAAY;QAC5B,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,CAAC,CAAC,OAAO;KACnB,CAAC;AACJ,CAAC"}
@@ -1,28 +1,28 @@
1
1
  /**
2
- * What kind of error a ClickHouse call failed with.
2
+ * Category of failure for a {@link DatabaseError}.
3
3
  *
4
- * - `server`: the server refused or failed the query; `code` and `codeName`
5
- * say why.
6
- * - `unavailable`: the server can't be reached, or the database isn't
7
- * configured for this process; the message says which.
4
+ * - `server`: ClickHouse rejected or failed the query (`code` and `codeName`
5
+ * contain the ClickHouse exception details).
6
+ * - `unavailable`: the server could not be reached, or the database is not
7
+ * configured for this process.
8
8
  * - `canceled`: the call was canceled.
9
- * - `decode`: a response the SDK couldn't decode, such as a column of a type
10
- * it doesn't read (`Dynamic`, `AggregateFunction`: cast it in the query).
11
- * - `invalid_argument`: an argument the call can't use, such as a parameter
12
- * value of no ClickHouse type or a bad table name.
13
- * - `too_many_rows`: `queryRow` or `rawQueryRow` got more than one row
9
+ * - `decode`: the SDK could not decode a response column (for example,
10
+ * unsupported types like `Dynamic` or `AggregateFunction` — cast them in SQL).
11
+ * - `invalid_argument`: invalid call argument, such as an unsupported parameter
12
+ * type or invalid table name.
13
+ * - `too_many_rows`: `queryRow` or `rawQueryRow` returned more than one row
14
14
  * ({@link TooManyRowsError}).
15
- * - `no_rows`: reserved for the other SDKs' one-row forms; `queryRow`
16
- * returns `null` for no rows instead.
15
+ * - `no_rows`: reserved for parity with other Encore SDKs (`queryRow` returns
16
+ * `null` when no rows match).
17
17
  */
18
18
  export type ErrorKind = 'server' | 'unavailable' | 'canceled' | 'decode' | 'invalid_argument' | 'no_rows' | 'too_many_rows';
19
19
  /**
20
- * An error of a ClickHouse call: the server's, or the SDK's own.
20
+ * Error returned when a ClickHouse operation fails (either on the server or in
21
+ * the SDK).
21
22
  *
22
- * A server error has ClickHouse's exception `code` (such as `60`) and its
23
- * name, `codeName` (such as `'UNKNOWN_TABLE'`); every other kind has `code`
24
- * `0` and `codeName` `''`. The name is `codeName` rather than `name`, which
25
- * every `Error` has for its class: `'DatabaseError'`.
23
+ * For `kind === 'server'`, `code` (e.g. `60`) and `codeName` (e.g.
24
+ * `'UNKNOWN_TABLE'`) hold the ClickHouse exception code and name; for all other
25
+ * kinds, `code` is `0` and `codeName` is `''`.
26
26
  *
27
27
  * @example
28
28
  * try {
@@ -36,11 +36,11 @@ export type ErrorKind = 'server' | 'unavailable' | 'canceled' | 'decode' | 'inva
36
36
  */
37
37
  export declare class DatabaseError extends Error {
38
38
  readonly name: 'DatabaseError' | 'TooManyRowsError';
39
- /** What kind of error it is. */
39
+ /** Category of error. */
40
40
  readonly kind: ErrorKind;
41
- /** ClickHouse's exception code, such as `60`: `0` for other kinds. */
41
+ /** ClickHouse exception code (e.g. `60`), or `0` for non-server errors. */
42
42
  readonly code: number;
43
- /** The exception code's name, such as `'UNKNOWN_TABLE'`: `''` for other kinds. */
43
+ /** ClickHouse exception name (e.g. `'UNKNOWN_TABLE'`), or `''` for non-server errors. */
44
44
  readonly codeName: string;
45
45
  constructor(fields: {
46
46
  message: string;
@@ -50,18 +50,17 @@ export declare class DatabaseError extends Error {
50
50
  });
51
51
  }
52
52
  /**
53
- * Thrown by `queryRow` and `rawQueryRow` for a query that returns more than
54
- * one row: a {@link DatabaseError} of kind `too_many_rows`.
53
+ * Thrown by `queryRow` and `rawQueryRow` when a query returns more than one
54
+ * row. Subclass of {@link DatabaseError} with `kind === 'too_many_rows'`.
55
55
  */
56
56
  export declare class TooManyRowsError extends DatabaseError {
57
57
  readonly name: 'TooManyRowsError';
58
58
  constructor();
59
59
  }
60
- /** Awaits a native call, throwing the error it rejects with as a
61
- * `DatabaseError` if it is one. */
60
+ /** Awaits a native call and converts encoded native errors into {@link DatabaseError}. */
62
61
  export declare function native<T>(call: Promise<T>): Promise<T>;
63
- /** Runs a synchronous native call, as {@link native} does an async one. */
62
+ /** Runs a synchronous native call and converts encoded native errors into {@link DatabaseError}. */
64
63
  export declare function nativeSync<T>(call: () => T): T;
65
- /** `err`, a native call's, as a `DatabaseError` if it is one. */
64
+ /** Converts an encoded native error into a {@link DatabaseError}, passing other errors through. */
66
65
  export declare function fromNative(err: unknown): unknown;
67
66
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../storage/clickhouse/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,aAAa,GACb,UAAU,GACV,QAAQ,GACR,kBAAkB,GAClB,SAAS,GACT,eAAe,CAAC;AAEpB;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAiB,IAAI,EAAE,eAAe,GAAG,kBAAkB,CAAC;IAC5D,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CA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EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;CAWF;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,SAAiB,IAAI,EAAE,kBAAkB,CAAC;;CAU3C;AAQD,0FAA0F;AAC1F,wBAAsB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM5D;AAED,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAM9C;AAED,mGAAmG;AACnG,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAchD"}
@@ -1,10 +1,10 @@
1
1
  /**
2
- * An error of a ClickHouse call: the server's, or the SDK's own.
2
+ * Error returned when a ClickHouse operation fails (either on the server or in
3
+ * the SDK).
3
4
  *
4
- * A server error has ClickHouse's exception `code` (such as `60`) and its
5
- * name, `codeName` (such as `'UNKNOWN_TABLE'`); every other kind has `code`
6
- * `0` and `codeName` `''`. The name is `codeName` rather than `name`, which
7
- * every `Error` has for its class: `'DatabaseError'`.
5
+ * For `kind === 'server'`, `code` (e.g. `60`) and `codeName` (e.g.
6
+ * `'UNKNOWN_TABLE'`) hold the ClickHouse exception code and name; for all other
7
+ * kinds, `code` is `0` and `codeName` is `''`.
8
8
  *
9
9
  * @example
10
10
  * try {
@@ -17,11 +17,11 @@
17
17
  * }
18
18
  */
19
19
  export class DatabaseError extends Error {
20
- /** What kind of error it is. */
20
+ /** Category of error. */
21
21
  kind;
22
- /** ClickHouse's exception code, such as `60`: `0` for other kinds. */
22
+ /** ClickHouse exception code (e.g. `60`), or `0` for non-server errors. */
23
23
  code;
24
- /** The exception code's name, such as `'UNKNOWN_TABLE'`: `''` for other kinds. */
24
+ /** ClickHouse exception name (e.g. `'UNKNOWN_TABLE'`), or `''` for non-server errors. */
25
25
  codeName;
26
26
  constructor(fields) {
27
27
  super(fields.message);
@@ -36,8 +36,8 @@ export class DatabaseError extends Error {
36
36
  }
37
37
  }
38
38
  /**
39
- * Thrown by `queryRow` and `rawQueryRow` for a query that returns more than
40
- * one row: a {@link DatabaseError} of kind `too_many_rows`.
39
+ * Thrown by `queryRow` and `rawQueryRow` when a query returns more than one
40
+ * row. Subclass of {@link DatabaseError} with `kind === 'too_many_rows'`.
41
41
  */
42
42
  export class TooManyRowsError extends DatabaseError {
43
43
  constructor() {
@@ -50,13 +50,11 @@ export class TooManyRowsError extends DatabaseError {
50
50
  }
51
51
  }
52
52
  /**
53
- * Begins the message of an error the native module fails with for a
54
- * `DatabaseError`, which the rest of the message holds as JSON. The same as
55
- * `DATABASE_ERROR_PREFIX` in `sdk/ts/src/clickhouse.rs`.
53
+ * Prefix for JSON-encoded `DatabaseError` messages from the native module.
54
+ * Must match `DATABASE_ERROR_PREFIX` in `sdk/ts/src/clickhouse.rs`.
56
55
  */
57
56
  const DATABASE_ERROR_PREFIX = 'encore:clickhouse.DatabaseError:';
58
- /** Awaits a native call, throwing the error it rejects with as a
59
- * `DatabaseError` if it is one. */
57
+ /** Awaits a native call and converts encoded native errors into {@link DatabaseError}. */
60
58
  export async function native(call) {
61
59
  try {
62
60
  return await call;
@@ -65,7 +63,7 @@ export async function native(call) {
65
63
  throw fromNative(err);
66
64
  }
67
65
  }
68
- /** Runs a synchronous native call, as {@link native} does an async one. */
66
+ /** Runs a synchronous native call and converts encoded native errors into {@link DatabaseError}. */
69
67
  export function nativeSync(call) {
70
68
  try {
71
69
  return call();
@@ -74,7 +72,7 @@ export function nativeSync(call) {
74
72
  throw fromNative(err);
75
73
  }
76
74
  }
77
- /** `err`, a native call's, as a `DatabaseError` if it is one. */
75
+ /** Converts an encoded native error into a {@link DatabaseError}, passing other errors through. */
78
76
  export function fromNative(err) {
79
77
  if (!(err instanceof Error) ||
80
78
  !err.message.startsWith(DATABASE_ERROR_PREFIX)) {
@@ -1 +1 @@
1
- {"version":3,"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AC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,OAAO,IAAI,aAAa,CAAC;QACvB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;KACrB,CAAC,CAAC;AACL,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
- * ClickHouse databases. A database is declared at module scope, with the
3
- * directory of its migrations; Encore provisions it, runs them, and gives
4
- * each service the access its code uses.
2
+ * ClickHouse databases. Declare a database at module scope with its migrations
3
+ * directory; Encore provisions it, runs migrations, and grants each service
4
+ * the access level its code uses.
5
5
  *
6
6
  * ```ts
7
7
  * import { Database } from "@encore.dev/sdk/storage/clickhouse";
@@ -13,14 +13,14 @@
13
13
  * SELECT name, count() AS n FROM events WHERE at > ${since} GROUP BY name`;
14
14
  * ```
15
15
  *
16
- * Parameters are bound on the server, never spliced into the SQL: a tagged
17
- * template's `${value}` becomes `{p0:Type}` with the type inferred from the
18
- * value (or given with {@link typed}), and the `raw` forms take SQL that names
19
- * its parameters and their types, `{id:UInt64}`, with the values by name.
16
+ * Parameters are always bound on the server rather than interpolated into SQL:
17
+ * tagged-template `${value}` placeholders become `{p0:Type}` using the inferred
18
+ * ClickHouse type (override with {@link typed}), while the `raw*` methods take
19
+ * SQL with named typed placeholders (e.g. `{id:UInt64}`) and a params object.
20
20
  *
21
- * There are no transactions, and no sessions: each call is a request of its
22
- * own, so temporary tables and `SET` don't carry over to the next one. Use
23
- * the per-call `settings` option instead.
21
+ * ClickHouse calls are stateless — there are no transactions or sessions, so
22
+ * temporary tables and `SET` do not persist across calls. Pass per-query
23
+ * settings via {@link QueryOptions.settings} instead.
24
24
  *
25
25
  * @module
26
26
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
- * ClickHouse databases. A database is declared at module scope, with the
3
- * directory of its migrations; Encore provisions it, runs them, and gives
4
- * each service the access its code uses.
2
+ * ClickHouse databases. Declare a database at module scope with its migrations
3
+ * directory; Encore provisions it, runs migrations, and grants each service
4
+ * the access level its code uses.
5
5
  *
6
6
  * ```ts
7
7
  * import { Database } from "@encore.dev/sdk/storage/clickhouse";
@@ -13,14 +13,14 @@
13
13
  * SELECT name, count() AS n FROM events WHERE at > ${since} GROUP BY name`;
14
14
  * ```
15
15
  *
16
- * Parameters are bound on the server, never spliced into the SQL: a tagged
17
- * template's `${value}` becomes `{p0:Type}` with the type inferred from the
18
- * value (or given with {@link typed}), and the `raw` forms take SQL that names
19
- * its parameters and their types, `{id:UInt64}`, with the values by name.
16
+ * Parameters are always bound on the server rather than interpolated into SQL:
17
+ * tagged-template `${value}` placeholders become `{p0:Type}` using the inferred
18
+ * ClickHouse type (override with {@link typed}), while the `raw*` methods take
19
+ * SQL with named typed placeholders (e.g. `{id:UInt64}`) and a params object.
20
20
  *
21
- * There are no transactions, and no sessions: each call is a request of its
22
- * own, so temporary tables and `SET` don't carry over to the next one. Use
23
- * the per-call `settings` option instead.
21
+ * ClickHouse calls are stateless — there are no transactions or sessions, so
22
+ * temporary tables and `SET` do not persist across calls. Pass per-query
23
+ * settings via {@link QueryOptions.settings} instead.
24
24
  *
25
25
  * @module
26
26
  */