tina4-nodejs 3.13.137 → 3.13.138

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 (242) hide show
  1. package/CLAUDE.md +33 -3
  2. package/COMMERCIAL-LICENSE.md +8 -0
  3. package/LICENSE +373 -0
  4. package/NOTICE +11 -0
  5. package/README.md +24 -2
  6. package/package.json +44 -6
  7. package/packages/cli/dist/bin.js +19466 -18048
  8. package/packages/cli/src/bin.ts +8 -0
  9. package/packages/cli/src/commands/build.ts +8 -0
  10. package/packages/cli/src/commands/generate.ts +8 -0
  11. package/packages/cli/src/commands/init.ts +8 -0
  12. package/packages/cli/src/commands/lint.ts +8 -0
  13. package/packages/cli/src/commands/migrate.ts +8 -0
  14. package/packages/cli/src/commands/migrateCreate.ts +8 -0
  15. package/packages/cli/src/commands/migrateRollback.ts +8 -0
  16. package/packages/cli/src/commands/migrateStatus.ts +8 -0
  17. package/packages/cli/src/commands/queue.ts +8 -0
  18. package/packages/cli/src/commands/routes.ts +8 -0
  19. package/packages/cli/src/commands/seed.ts +8 -0
  20. package/packages/cli/src/commands/serve.ts +11 -0
  21. package/packages/cli/src/commands/test.ts +8 -0
  22. package/packages/core/dist/index.js +19458 -18043
  23. package/packages/core/gallery/auth/src/routes/api/gallery/auth/login/post.ts +8 -0
  24. package/packages/core/gallery/auth/src/routes/api/gallery/auth/verify/get.ts +8 -0
  25. package/packages/core/gallery/auth/src/routes/gallery/auth/get.ts +8 -0
  26. package/packages/core/gallery/database/src/routes/api/gallery/db/notes/get.ts +8 -0
  27. package/packages/core/gallery/database/src/routes/api/gallery/db/notes/post.ts +8 -0
  28. package/packages/core/gallery/database/src/routes/api/gallery/db/tables/get.ts +8 -0
  29. package/packages/core/gallery/error-overlay/src/routes/api/gallery/crash/get.ts +8 -0
  30. package/packages/core/gallery/orm/src/routes/api/gallery/products/get.ts +8 -0
  31. package/packages/core/gallery/orm/src/routes/api/gallery/products/post.ts +8 -0
  32. package/packages/core/gallery/queue/src/lib/queueDb.ts +8 -0
  33. package/packages/core/gallery/queue/src/routes/api/gallery/queue/consume/post.ts +8 -0
  34. package/packages/core/gallery/queue/src/routes/api/gallery/queue/fail/post.ts +8 -0
  35. package/packages/core/gallery/queue/src/routes/api/gallery/queue/produce/post.ts +8 -0
  36. package/packages/core/gallery/queue/src/routes/api/gallery/queue/retry/post.ts +8 -0
  37. package/packages/core/gallery/queue/src/routes/api/gallery/queue/status/get.ts +8 -0
  38. package/packages/core/gallery/queue/src/routes/gallery/queue/get.ts +8 -0
  39. package/packages/core/gallery/rest-api/src/routes/api/gallery/hello/get.ts +8 -0
  40. package/packages/core/gallery/rest-api/src/routes/api/gallery/hello/post.ts +8 -0
  41. package/packages/core/gallery/templates/src/routes/gallery/page/get.ts +8 -0
  42. package/packages/core/gallery/templates/src/templates/gallery_page.twig +8 -0
  43. package/packages/core/public/THIRD-PARTY-NOTICES.md +55 -0
  44. package/packages/core/public/bundled-component-provenance.json +48 -0
  45. package/packages/core/public/js/tina4js.min.js +13 -3
  46. package/packages/core/public/licenses/swagger-ui-3.10.0-original-notice.txt +11 -0
  47. package/packages/core/public/licenses/swagger-ui-5.17.14-NOTICE.txt +2 -0
  48. package/packages/core/public/licenses/swagger-ui-Apache-2.0.txt +202 -0
  49. package/packages/core/public/licenses/tina4-css-MIT.txt +21 -0
  50. package/packages/core/public/licenses/tina4-dev-admin-components.json +240 -0
  51. package/packages/core/public/licenses/tina4-dev-admin-third-party.txt +919 -0
  52. package/packages/core/public/licenses/tina4-js-MIT.txt +20 -0
  53. package/packages/core/src/__feedback/widget.js +8 -0
  54. package/packages/core/src/_missing.ts +8 -0
  55. package/packages/core/src/ai.ts +8 -0
  56. package/packages/core/src/aiClient.ts +8 -0
  57. package/packages/core/src/api.ts +15 -3
  58. package/packages/core/src/auth.ts +21 -8
  59. package/packages/core/src/authGate.ts +8 -0
  60. package/packages/core/src/background.ts +8 -0
  61. package/packages/core/src/cache.ts +43 -4
  62. package/packages/core/src/constants.ts +8 -0
  63. package/packages/core/src/container.ts +8 -0
  64. package/packages/core/src/context/chunker.ts +8 -0
  65. package/packages/core/src/context/index.ts +8 -0
  66. package/packages/core/src/devAdmin.ts +185 -59
  67. package/packages/core/src/devMailbox.ts +8 -0
  68. package/packages/core/src/dispatchPipeline.ts +8 -0
  69. package/packages/core/src/docs.ts +8 -0
  70. package/packages/core/src/docsAutoDiscovery.ts +8 -0
  71. package/packages/core/src/docsParser.ts +8 -0
  72. package/packages/core/src/docsScanner.ts +44 -0
  73. package/packages/core/src/docsSignatures.ts +8 -0
  74. package/packages/core/src/dotenv.ts +8 -0
  75. package/packages/core/src/env.ts +8 -0
  76. package/packages/core/src/errorOverlay.ts +8 -0
  77. package/packages/core/src/events.ts +8 -0
  78. package/packages/core/src/fakeData.ts +8 -0
  79. package/packages/core/src/feedback.ts +8 -0
  80. package/packages/core/src/graphql.ts +16 -5
  81. package/packages/core/src/health.ts +8 -0
  82. package/packages/core/src/htmlElement.ts +8 -0
  83. package/packages/core/src/i18n.ts +8 -0
  84. package/packages/core/src/index.ts +8 -0
  85. package/packages/core/src/job.ts +8 -0
  86. package/packages/core/src/logger.ts +8 -0
  87. package/packages/core/src/mcp.test.ts +8 -0
  88. package/packages/core/src/mcp.ts +8 -0
  89. package/packages/core/src/messenger.ts +143 -86
  90. package/packages/core/src/metrics.ts +13 -0
  91. package/packages/core/src/middleware.ts +1178 -1096
  92. package/packages/core/src/mqtt.ts +8 -0
  93. package/packages/core/src/mqttMessage.ts +8 -0
  94. package/packages/core/src/optionalPackage.ts +48 -0
  95. package/packages/core/src/plan.ts +8 -0
  96. package/packages/core/src/portTakeover.ts +8 -0
  97. package/packages/core/src/projectIndex.ts +8 -0
  98. package/packages/core/src/projectIndexExtractors.ts +8 -0
  99. package/packages/core/src/projectIndexStorage.ts +8 -0
  100. package/packages/core/src/push.ts +8 -0
  101. package/packages/core/src/queue.ts +8 -0
  102. package/packages/core/src/queueBackends/kafkaBackend.ts +8 -0
  103. package/packages/core/src/queueBackends/liteBackend.ts +8 -0
  104. package/packages/core/src/queueBackends/mongoBackend.ts +21 -8
  105. package/packages/core/src/queueBackends/rabbitmqBackend.ts +8 -0
  106. package/packages/core/src/rateLimiter.ts +8 -0
  107. package/packages/core/src/request.ts +59 -10
  108. package/packages/core/src/response.ts +79 -5
  109. package/packages/core/src/routeDiscovery.ts +8 -0
  110. package/packages/core/src/router.ts +8 -0
  111. package/packages/core/src/server.ts +73 -24
  112. package/packages/core/src/service.ts +8 -0
  113. package/packages/core/src/session.ts +8 -0
  114. package/packages/core/src/sessionHandlers/childError.ts +8 -0
  115. package/packages/core/src/sessionHandlers/databaseHandler.ts +8 -0
  116. package/packages/core/src/sessionHandlers/memcachedHandler.ts +8 -0
  117. package/packages/core/src/sessionHandlers/mongoClient.ts +8 -0
  118. package/packages/core/src/sessionHandlers/mongoHandler.ts +8 -0
  119. package/packages/core/src/sessionHandlers/respClient.ts +8 -0
  120. package/packages/core/src/sessionHandlers/sqlClient.ts +8 -0
  121. package/packages/core/src/sessionHandlers/syncBridge.ts +8 -0
  122. package/packages/core/src/sessionHandlers/syncSocket.ts +8 -0
  123. package/packages/core/src/sessionHandlers/valkeyHandler.ts +8 -0
  124. package/packages/core/src/sso.ts +8 -0
  125. package/packages/core/src/static.ts +8 -0
  126. package/packages/core/src/test.ts +8 -0
  127. package/packages/core/src/testClient.ts +8 -0
  128. package/packages/core/src/testing.ts +8 -0
  129. package/packages/core/src/transport.ts +369 -0
  130. package/packages/core/src/trustedProxy.ts +8 -0
  131. package/packages/core/src/types.ts +13 -0
  132. package/packages/core/src/validator.ts +8 -0
  133. package/packages/core/src/version.ts +8 -0
  134. package/packages/core/src/websocket.ts +8 -0
  135. package/packages/core/src/websocketBackplane.ts +49 -32
  136. package/packages/core/src/websocketConnection.ts +8 -0
  137. package/packages/core/src/wsdl.ts +197 -115
  138. package/packages/core/templates/errors/302.twig +8 -0
  139. package/packages/core/templates/errors/401.twig +8 -0
  140. package/packages/core/templates/errors/403.twig +8 -0
  141. package/packages/core/templates/errors/404.twig +8 -0
  142. package/packages/core/templates/errors/500.twig +8 -0
  143. package/packages/core/templates/errors/502.twig +8 -0
  144. package/packages/core/templates/errors/503.twig +8 -0
  145. package/packages/core/templates/errors/base.twig +8 -0
  146. package/packages/frond/dist/index.js +151 -17
  147. package/packages/frond/src/engine.ts +177 -17
  148. package/packages/frond/src/index.ts +8 -0
  149. package/packages/orm/dist/index.js +8125 -6708
  150. package/packages/orm/src/adapters/firebird.ts +50 -3
  151. package/packages/orm/src/adapters/mongodb.ts +8 -0
  152. package/packages/orm/src/adapters/mssql.ts +29 -7
  153. package/packages/orm/src/adapters/mysql.ts +17 -1
  154. package/packages/orm/src/adapters/odbc.ts +11 -0
  155. package/packages/orm/src/adapters/pg-types.d.ts +8 -0
  156. package/packages/orm/src/adapters/postgres.ts +34 -8
  157. package/packages/orm/src/adapters/sqlDialect.ts +57 -0
  158. package/packages/orm/src/adapters/sqlite.ts +26 -0
  159. package/packages/orm/src/autoCrud.ts +78 -36
  160. package/packages/orm/src/baseModel.ts +61 -29
  161. package/packages/orm/src/cachedDatabase.ts +67 -1
  162. package/packages/orm/src/connectTimeout.ts +8 -0
  163. package/packages/orm/src/database.ts +649 -401
  164. package/packages/orm/src/databaseResult.ts +8 -0
  165. package/packages/orm/src/databaseUrl.ts +8 -0
  166. package/packages/orm/src/docstore.ts +23 -1
  167. package/packages/orm/src/fakeData.ts +8 -0
  168. package/packages/orm/src/graph/adapters/arango.ts +8 -0
  169. package/packages/orm/src/graph/adapters/bolt.ts +8 -0
  170. package/packages/orm/src/graph/adapters/ultipa.ts +8 -0
  171. package/packages/orm/src/graph/connectTimeout.ts +8 -0
  172. package/packages/orm/src/graph/errors.ts +8 -0
  173. package/packages/orm/src/graph/graphAdapter.ts +8 -0
  174. package/packages/orm/src/graph/graphDatabase.ts +8 -0
  175. package/packages/orm/src/graph/graphUrl.ts +10 -1
  176. package/packages/orm/src/graph/shapes.ts +8 -0
  177. package/packages/orm/src/index.ts +147 -139
  178. package/packages/orm/src/migration.ts +8 -0
  179. package/packages/orm/src/model.ts +8 -0
  180. package/packages/orm/src/modelCollection.ts +8 -0
  181. package/packages/orm/src/point.ts +8 -0
  182. package/packages/orm/src/query.ts +149 -33
  183. package/packages/orm/src/queryBuilder.ts +8 -0
  184. package/packages/orm/src/realtime/index.ts +8 -0
  185. package/packages/orm/src/realtime/models/attachment.ts +8 -0
  186. package/packages/orm/src/realtime/models/channel.ts +8 -0
  187. package/packages/orm/src/realtime/models/channelMember.ts +8 -0
  188. package/packages/orm/src/realtime/models/message.ts +8 -0
  189. package/packages/orm/src/realtime/models/workspace.ts +8 -0
  190. package/packages/orm/src/realtime/realtime.ts +8 -0
  191. package/packages/orm/src/realtime/storage.ts +43 -12
  192. package/packages/orm/src/seeder.ts +8 -0
  193. package/packages/orm/src/seederTable.ts +8 -0
  194. package/packages/orm/src/seederTypes.ts +8 -0
  195. package/packages/orm/src/sqlTranslator.ts +185 -8
  196. package/packages/orm/src/types.ts +15 -0
  197. package/packages/orm/src/validation.ts +8 -0
  198. package/packages/swagger/src/generator.ts +8 -0
  199. package/packages/swagger/src/index.ts +8 -0
  200. package/packages/swagger/src/ui.ts +8 -0
  201. package/types/core/src/background.d.ts +0 -16
  202. package/types/core/src/cache.d.ts +6 -0
  203. package/types/core/src/devAdmin.d.ts +18 -12
  204. package/types/core/src/docs.d.ts +0 -17
  205. package/types/core/src/errorOverlay.d.ts +0 -24
  206. package/types/core/src/events.d.ts +0 -12
  207. package/types/core/src/feedback.d.ts +0 -23
  208. package/types/core/src/graphql.d.ts +0 -21
  209. package/types/core/src/htmlElement.d.ts +0 -15
  210. package/types/core/src/messenger.d.ts +12 -1
  211. package/types/core/src/metrics.d.ts +2 -0
  212. package/types/core/src/middleware.d.ts +45 -1
  213. package/types/core/src/mqtt.d.ts +0 -33
  214. package/types/core/src/optionalPackage.d.ts +25 -0
  215. package/types/core/src/plan.d.ts +0 -10
  216. package/types/core/src/projectIndex.d.ts +0 -10
  217. package/types/core/src/queueBackends/mongoBackend.d.ts +2 -0
  218. package/types/core/src/request.d.ts +12 -0
  219. package/types/core/src/response.d.ts +13 -0
  220. package/types/core/src/server.d.ts +19 -0
  221. package/types/core/src/sessionHandlers/childError.d.ts +0 -15
  222. package/types/core/src/transport.d.ts +28 -0
  223. package/types/core/src/trustedProxy.d.ts +0 -16
  224. package/types/core/src/types.d.ts +5 -0
  225. package/types/core/src/websocketBackplane.d.ts +1 -0
  226. package/types/core/src/wsdl.d.ts +8 -22
  227. package/types/frond/src/engine.d.ts +7 -1
  228. package/types/orm/src/adapters/firebird.d.ts +12 -0
  229. package/types/orm/src/adapters/mssql.d.ts +11 -0
  230. package/types/orm/src/adapters/mysql.d.ts +2 -0
  231. package/types/orm/src/adapters/postgres.d.ts +11 -0
  232. package/types/orm/src/adapters/sqlDialect.d.ts +25 -0
  233. package/types/orm/src/adapters/sqlite.d.ts +7 -0
  234. package/types/orm/src/baseModel.d.ts +5 -0
  235. package/types/orm/src/cachedDatabase.d.ts +27 -0
  236. package/types/orm/src/database.d.ts +46 -7
  237. package/types/orm/src/graph/graphUrl.d.ts +0 -8
  238. package/types/orm/src/index.d.ts +1 -1
  239. package/types/orm/src/query.d.ts +48 -2
  240. package/types/orm/src/realtime/storage.d.ts +2 -1
  241. package/types/orm/src/sqlTranslator.d.ts +70 -18
  242. package/types/orm/src/types.d.ts +6 -0
@@ -1,4 +1,4 @@
1
- import type { QueryOptions } from "./types.js";
1
+ import type { FieldDefinition, QueryOptions } from "./types.js";
2
2
  export interface ParsedQuery {
3
3
  where: string;
4
4
  orderBy: string;
@@ -6,12 +6,58 @@ export interface ParsedQuery {
6
6
  offset: number;
7
7
  params: unknown[];
8
8
  }
9
- export declare function buildQuery(tableName: string, options: QueryOptions, extraConditions?: string[]): {
9
+ /**
10
+ * Resolve a caller-supplied key to the model's DB column, or null when the key
11
+ * is not a declared field.
12
+ *
13
+ * tina4: ADR-0069 - identifiers that reach SQL come from the model, never the
14
+ * request. The key may be a declared field (property) name or that field's
15
+ * column name; either way the column returned is the model's own, so nothing
16
+ * but a declared column can be emitted. `columnOf` is the caller's existing
17
+ * property->column mapping (BaseModel.getDbColumn / AutoCrud's getDbCol), so
18
+ * the mapping rule lives in one place. Own keys only, so an inherited Object
19
+ * property can never resolve. Used by AutoCrud (filter + sort) and by
20
+ * BaseModel.find(object).
21
+ */
22
+ export declare function resolveFieldColumn(fields: Record<string, FieldDefinition>, columnOf: (field: string) => string, key: string): string | null;
23
+ /**
24
+ * The declared FIELD (property) name a key names - by the field name itself or
25
+ * by its column - or null. The write-side twin of resolveFieldColumn(): AutoCrud
26
+ * writes need the field, to validate the body and then map it to its column.
27
+ */
28
+ export declare function resolveField(fields: Record<string, FieldDefinition>, columnOf: (field: string) => string, key: string): string | null;
29
+ /** A filter or sort key that does not resolve to a declared model field. */
30
+ export declare class UnknownFieldError extends Error {
31
+ readonly kind: "filter" | "sort";
32
+ readonly field: string;
33
+ constructor(kind: "filter" | "sort", field: string);
34
+ }
35
+ /** A query parameter whose SHAPE is wrong (a list or map where one value belongs). */
36
+ export declare class InvalidQueryParameterError extends Error {
37
+ constructor(message: string);
38
+ }
39
+ /**
40
+ * Build the list SQL from parsed query options.
41
+ *
42
+ * `quote` renders every table/column name the builder emits - pass the bound
43
+ * adapter's dialect (`(name) => quoteIdentifier(adapter, name)`); the default is
44
+ * the ANSI `"name"`.
45
+ *
46
+ * Every filter key and sort field is passed through `resolveColumn` (see
47
+ * resolveFieldColumn) and only the column it returns is emitted; a key it does
48
+ * not resolve throws UnknownFieldError before any SQL exists. With no
49
+ * resolver, no filter or sort key resolves (ADR-0069).
50
+ */
51
+ export declare function buildQuery(tableName: string, options: QueryOptions, extraConditions?: string[], quote?: (name: string) => string, resolveColumn?: (key: string) => string | null): {
10
52
  sql: string;
11
53
  countSql: string;
12
54
  params: unknown[];
13
55
  limit: number;
14
56
  offset: number;
15
57
  page: number;
58
+ /** The same SELECT without LIMIT/OFFSET, for adapterFetch to page in the engine's own syntax. */
59
+ pageSql: string;
60
+ /** The filter parameters alone (params minus the trailing limit/offset). */
61
+ filterParams: unknown[];
16
62
  };
17
63
  export declare function parseQueryString(query: Record<string, string>): QueryOptions;
@@ -33,7 +33,8 @@ export declare class LocalStorage implements StorageBackend {
33
33
  exists(key: string): boolean;
34
34
  }
35
35
  /**
36
- * S3-compatible store (AWS S3, MinIO, ...). Opt-in; needs @aws-sdk/client-s3.
36
+ * S3-compatible store (AWS S3, MinIO, ...). Opt-in; the app installs the SDK:
37
+ * `npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner`.
37
38
  * Presigned GET URLs let clients fetch large blobs straight from object
38
39
  * storage instead of streaming through the app.
39
40
  */
@@ -1,21 +1,3 @@
1
- /**
2
- * Tina4 SQL Translation — Cross-engine SQL translator.
3
- *
4
- * Translates SQL dialect differences between engines so that application
5
- * code can use a single SQL style and have it adapted at runtime.
6
- *
7
- * import { SQLTranslator } from "@tina4/orm";
8
- *
9
- * // Firebird: LIMIT/OFFSET → ROWS X TO Y
10
- * SQLTranslator.limitToRows("SELECT * FROM users LIMIT 10 OFFSET 5");
11
- * // → "SELECT * FROM users ROWS 6 TO 15"
12
- *
13
- * // MSSQL: LIMIT → TOP N
14
- * SQLTranslator.limitToTop("SELECT * FROM users LIMIT 10");
15
- * // → "SELECT TOP 10 * FROM users"
16
- *
17
- * Also includes a query cache with TTL support.
18
- */
19
1
  export declare class SQLTranslator {
20
2
  private static readonly SPATIAL_ENGINES;
21
3
  private static readonly SPATIAL_IDENTIFIER;
@@ -101,6 +83,29 @@ export declare class SQLTranslator {
101
83
  * ? → :1, :2, :3 (Oracle, Firebird)
102
84
  */
103
85
  static placeholderStyle(sql: string, style: string): string;
86
+ /**
87
+ * Offsets of the REAL `?` placeholders in a statement: every `?` that is not
88
+ * inside a string literal ('...', Postgres E'...', dollar-quoted $$...$$ /
89
+ * $tag$...$tag$), a quoted identifier ("..." or `...`), or a comment (-- to
90
+ * end of line, /* ... *\/). A plain text replace turned the `?` in
91
+ * `SELECT 'why?' AS v, ? AS n` into a placeholder and shifted every binding
92
+ * after it (tina4-python#138).
93
+ *
94
+ * @param sql Raw SQL, exactly as the caller wrote it.
95
+ * @param options.backslashEscapes Treat `\` as an escape inside '...' and
96
+ * "..." as well (MySQL's default string syntax). E'...' always does.
97
+ */
98
+ static placeholderPositions(sql: string, options?: {
99
+ backslashEscapes?: boolean;
100
+ }): number[];
101
+ /**
102
+ * Replace each REAL `?` placeholder (see placeholderPositions) with
103
+ * `marker(index)`, index counting from 0. Literals, quoted identifiers and
104
+ * comments are copied through untouched.
105
+ */
106
+ static replacePlaceholders(sql: string, marker: (index: number) => string, options?: {
107
+ backslashEscapes?: boolean;
108
+ }): string;
104
109
  /**
105
110
  * Detect and strip RETURNING clause from INSERT/UPDATE statements.
106
111
  * Returns the cleaned SQL and the list of RETURNING columns.
@@ -204,6 +209,53 @@ export declare class SQLTranslator {
204
209
  * @param sql Raw SQL; literals and comments are scrubbed before matching.
205
210
  */
206
211
  static hasTrailingLimit(sql: string): boolean;
212
+ /**
213
+ * Strip a trailing TOP-LEVEL `ORDER BY` so the statement can be wrapped in
214
+ * `SELECT COUNT(*) FROM (<sql>) AS _count_query` for the row-count probe.
215
+ *
216
+ * SQL Server rejects an ORDER BY inside a derived table unless it carries
217
+ * TOP/OFFSET/FETCH (error 1033), so the probe failed - and the total fell
218
+ * back to the page length - for any read ending in ORDER BY. ORDER BY cannot
219
+ * change a COUNT, so dropping it for the probe ONLY is safe; the paginated
220
+ * query keeps it. An ORDER BY nested in a subquery, or one already legalised
221
+ * by a following OFFSET/FETCH/FOR, is left intact. Positions are found on the
222
+ * scrubbed text, so an `ORDER BY` inside a literal or comment is ignored.
223
+ * Parity with Python `_strip_trailing_order_by` / PHP `stripTrailingOrderBy`.
224
+ *
225
+ * @param sql The read statement the probe is about to wrap.
226
+ */
227
+ static stripTrailingOrderBy(sql: string): string;
228
+ /**
229
+ * True when the statement CHANGES data, even though it may return rows.
230
+ *
231
+ * fetch()/fetchOne() are the natural way to run a write that RETURNS rows
232
+ * (`INSERT ... RETURNING id`, SQL Server's `OUTPUT inserted.id`), so they
233
+ * cannot treat every statement as a read (tina4-python#133). A write is one
234
+ * whose first word is a DML verb, or a `WITH` whose body holds one (a
235
+ * data-modifying CTE ends in SELECT). The shared cross-framework contract:
236
+ * a write through fetch/fetchOne runs exactly once, with no COUNT probe and
237
+ * no LIMIT/OFFSET/ROWS/TOP pagination, is never cached, and commits like
238
+ * execute(). Python's `_is_write_statement` answers identically.
239
+ *
240
+ * Literals and comments are scrubbed first, so `WHERE note = 'DELETE'` stays
241
+ * a read. Erring towards "write" is the safe direction: a read misread as a
242
+ * write only loses its pagination and cache for that one call.
243
+ *
244
+ * @param sql Raw SQL, exactly as the caller wrote it.
245
+ */
246
+ static isWriteStatement(sql: string): boolean;
247
+ /**
248
+ * Which kind of rows a statement produces, for execute() (cross-framework
249
+ * contract): "read" (SELECT, WITH ... SELECT, VALUES, SHOW, EXPLAIN,
250
+ * DESCRIBE), "returning" (a write with RETURNING, or SQL Server's OUTPUT
251
+ * inserted./deleted.), "procedure" (CALL / EXEC / EXECUTE, which may return a
252
+ * result set), or null for a statement that produces none. A data-modifying
253
+ * CTE (WITH ... INSERT ... SELECT) produces rows too, so it is "read" here and
254
+ * a write for isWriteStatement(). Literals and comments are scrubbed first.
255
+ *
256
+ * @param sql Raw SQL, exactly as the caller wrote it.
257
+ */
258
+ static rowsKind(sql: string): "read" | "returning" | "procedure" | null;
207
259
  /**
208
260
  * Append `LIMIT`/`OFFSET` to a statement unless it already carries its own.
209
261
  *
@@ -99,6 +99,12 @@ export interface DatabaseAdapter {
99
99
  connect(): void | Promise<void>;
100
100
  /** Return the canonical, credential-free engine name ("sqlite", "postgres", ...). */
101
101
  getDatabaseType(): string;
102
+ /**
103
+ * Quote a table/column name the ORM emits, in this engine's dialect
104
+ * (Python master: `quote_identifier`). Optional: an adapter without it gets
105
+ * the ANSI `"name"` default through `quoteIdentifier(adapter, name)`.
106
+ */
107
+ quoteIdentifier?(name: string): string;
102
108
  /** Execute a statement (INSERT, UPDATE, DELETE, DDL). */
103
109
  execute(sql: string, params?: unknown[]): unknown;
104
110
  /**