@aotter/mantle 0.2.0-alpha.5 → 0.2.0-alpha.6

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 (169) hide show
  1. package/README.md +2 -2
  2. package/dist/admin/createAdminSurface.d.ts +3 -0
  3. package/dist/admin/createAdminSurface.d.ts.map +1 -1
  4. package/dist/admin/createAdminSurface.js +51 -8
  5. package/dist/admin/createAdminSurface.js.map +1 -1
  6. package/dist/admin/extensions.d.ts +290 -0
  7. package/dist/admin/extensions.d.ts.map +1 -0
  8. package/dist/admin/extensions.js +532 -0
  9. package/dist/admin/extensions.js.map +1 -0
  10. package/dist/admin/index.d.ts +1 -0
  11. package/dist/admin/index.d.ts.map +1 -1
  12. package/dist/admin/index.js +1 -0
  13. package/dist/admin/index.js.map +1 -1
  14. package/dist/auth/buildAuth.d.ts +3 -1
  15. package/dist/auth/buildAuth.d.ts.map +1 -1
  16. package/dist/auth/buildAuth.js +3 -2
  17. package/dist/auth/buildAuth.js.map +1 -1
  18. package/dist/auth/callerResolver.d.ts +4 -0
  19. package/dist/auth/callerResolver.d.ts.map +1 -1
  20. package/dist/auth/callerResolver.js +4 -1
  21. package/dist/auth/callerResolver.js.map +1 -1
  22. package/dist/auth/createMantleAuth.d.ts.map +1 -1
  23. package/dist/auth/createMantleAuth.js +3 -2
  24. package/dist/auth/createMantleAuth.js.map +1 -1
  25. package/dist/auth/db.d.ts +1 -0
  26. package/dist/auth/db.d.ts.map +1 -1
  27. package/dist/auth/db.js +6 -3
  28. package/dist/auth/db.js.map +1 -1
  29. package/dist/bun/index.d.ts +0 -44
  30. package/dist/bun/index.d.ts.map +1 -1
  31. package/dist/bun/index.js +0 -84
  32. package/dist/bun/index.js.map +1 -1
  33. package/dist/cli/generate.js +3 -3
  34. package/dist/cli/generate.js.map +1 -1
  35. package/dist/cli/preset.d.ts.map +1 -1
  36. package/dist/cli/preset.js +80 -28
  37. package/dist/cli/preset.js.map +1 -1
  38. package/dist/cloudflare/index.d.ts +4 -0
  39. package/dist/cloudflare/index.d.ts.map +1 -1
  40. package/dist/cloudflare/index.js +2 -0
  41. package/dist/cloudflare/index.js.map +1 -1
  42. package/dist/core/dialect.d.ts +13 -1
  43. package/dist/core/dialect.d.ts.map +1 -1
  44. package/dist/core/driver.d.ts +7 -0
  45. package/dist/core/driver.d.ts.map +1 -1
  46. package/dist/core/runtime/createRuntime.js +1 -1
  47. package/dist/core/runtime/createRuntime.js.map +1 -1
  48. package/dist/core/sessionUser.d.ts +14 -0
  49. package/dist/core/sessionUser.d.ts.map +1 -0
  50. package/dist/core/sessionUser.js +4 -0
  51. package/dist/core/sessionUser.js.map +1 -0
  52. package/dist/core/sql/allowlist.d.ts +2 -0
  53. package/dist/core/sql/allowlist.d.ts.map +1 -1
  54. package/dist/core/sql/allowlist.js +43 -11
  55. package/dist/core/sql/allowlist.js.map +1 -1
  56. package/dist/core/sql/ast.js +1 -1
  57. package/dist/core/sql/ast.js.map +1 -1
  58. package/dist/core/sql/compile.js +1 -1
  59. package/dist/core/sql/compile.js.map +1 -1
  60. package/dist/core/sql/policy.d.ts +2 -0
  61. package/dist/core/sql/policy.d.ts.map +1 -1
  62. package/dist/core/sql/policy.js +25 -6
  63. package/dist/core/sql/policy.js.map +1 -1
  64. package/dist/core/sql/run.d.ts +0 -8
  65. package/dist/core/sql/run.d.ts.map +1 -1
  66. package/dist/core/sql/run.js +152 -35
  67. package/dist/core/sql/run.js.map +1 -1
  68. package/dist/d1/executor.d.ts +2 -0
  69. package/dist/d1/executor.d.ts.map +1 -1
  70. package/dist/d1/executor.js +6 -1
  71. package/dist/d1/executor.js.map +1 -1
  72. package/dist/postgres/adapter.d.ts +5 -2
  73. package/dist/postgres/adapter.d.ts.map +1 -1
  74. package/dist/postgres/adapter.js +7 -1
  75. package/dist/postgres/adapter.js.map +1 -1
  76. package/dist/postgres/compile/index.d.ts +1 -1
  77. package/dist/postgres/compile/index.js +1 -1
  78. package/dist/postgres/driver.d.ts +38 -21
  79. package/dist/postgres/driver.d.ts.map +1 -1
  80. package/dist/postgres/driver.js +100 -24
  81. package/dist/postgres/driver.js.map +1 -1
  82. package/dist/postgres/executor.d.ts +8 -0
  83. package/dist/postgres/executor.d.ts.map +1 -1
  84. package/dist/postgres/executor.js +40 -13
  85. package/dist/postgres/executor.js.map +1 -1
  86. package/dist/postgres/index.d.ts +2 -1
  87. package/dist/postgres/index.d.ts.map +1 -1
  88. package/dist/postgres/index.js +1 -0
  89. package/dist/postgres/index.js.map +1 -1
  90. package/dist/postgres/lower.d.ts.map +1 -1
  91. package/dist/postgres/lower.js +3 -8
  92. package/dist/postgres/lower.js.map +1 -1
  93. package/dist/postgres/print.d.ts.map +1 -1
  94. package/dist/postgres/print.js +2 -15
  95. package/dist/postgres/print.js.map +1 -1
  96. package/dist/postgres/session.d.ts +9 -0
  97. package/dist/postgres/session.d.ts.map +1 -0
  98. package/dist/postgres/session.js +111 -0
  99. package/dist/postgres/session.js.map +1 -0
  100. package/dist/postgres/storage.d.ts +14 -1
  101. package/dist/postgres/storage.d.ts.map +1 -1
  102. package/dist/postgres/storage.js +136 -54
  103. package/dist/postgres/storage.js.map +1 -1
  104. package/dist/postgres/validator.d.ts +4 -3
  105. package/dist/postgres/validator.d.ts.map +1 -1
  106. package/dist/postgres/validator.js +13 -6
  107. package/dist/postgres/validator.js.map +1 -1
  108. package/dist/spec/domain/model/ManifestGrammar.d.ts +4 -0
  109. package/dist/spec/domain/model/ManifestGrammar.d.ts.map +1 -1
  110. package/dist/spec/domain/model/ManifestGrammar.js +4 -0
  111. package/dist/spec/domain/model/ManifestGrammar.js.map +1 -1
  112. package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts +2 -0
  113. package/dist/spec/domain/service/SchemaAdminUiChecker.d.ts.map +1 -1
  114. package/dist/spec/domain/service/SchemaAdminUiChecker.js +50 -6
  115. package/dist/spec/domain/service/SchemaAdminUiChecker.js.map +1 -1
  116. package/dist/spec/domain/service/ViewAdminUiChecker.d.ts +1 -1
  117. package/dist/spec/domain/service/ViewAdminUiChecker.d.ts.map +1 -1
  118. package/dist/spec/domain/service/ViewAdminUiChecker.js +7 -2
  119. package/dist/spec/domain/service/ViewAdminUiChecker.js.map +1 -1
  120. package/dist/spec/infrastructure/sql/compilePlan.d.ts.map +1 -1
  121. package/dist/spec/infrastructure/sql/compilePlan.js +5 -0
  122. package/dist/spec/infrastructure/sql/compilePlan.js.map +1 -1
  123. package/dist/spec/kernel/diagnostic.d.ts +1 -1
  124. package/dist/spec/kernel/diagnostic.d.ts.map +1 -1
  125. package/dist/spec/kernel/diagnostic.js +5 -0
  126. package/dist/spec/kernel/diagnostic.js.map +1 -1
  127. package/dist/testing/cases/corpus.d.ts +2 -0
  128. package/dist/testing/cases/corpus.d.ts.map +1 -1
  129. package/dist/testing/cases/corpus.js +7 -5
  130. package/dist/testing/cases/corpus.js.map +1 -1
  131. package/dist/testing/cases/policy.d.ts +14 -1
  132. package/dist/testing/cases/policy.d.ts.map +1 -1
  133. package/dist/testing/cases/policy.js +3 -2
  134. package/dist/testing/cases/policy.js.map +1 -1
  135. package/dist/testing/cases/printer.d.ts.map +1 -1
  136. package/dist/testing/cases/printer.js +3 -1
  137. package/dist/testing/cases/printer.js.map +1 -1
  138. package/dist/testing/cases/report-view.d.ts.map +1 -1
  139. package/dist/testing/cases/report-view.js +18 -0
  140. package/dist/testing/cases/report-view.js.map +1 -1
  141. package/docs/adr/0037-postgresql-is-the-reference-dialect.md +2 -1
  142. package/docs/adr/0039-postgresql-is-native.md +130 -0
  143. package/docs/adr/README.md +2 -0
  144. package/docs/adr/adr-lite-1376-admin-extensions.md +330 -0
  145. package/docs/examples/commerce-inventory.md +18 -1
  146. package/docs/examples/reference-service/package.json +2 -2
  147. package/docs/handbook/cloudflare/authentication.md +3 -3
  148. package/docs/handbook/cloudflare/deploy-and-operate.md +4 -1
  149. package/docs/handbook/concepts/runtime-and-adapters.md +74 -33
  150. package/docs/handbook/concepts/views.md +1 -1
  151. package/docs/handbook/guides/admin-extensions.md +191 -0
  152. package/docs/handbook/guides/admin-ui.md +2 -1
  153. package/docs/handbook/navigation.json +2 -1
  154. package/docs/handbook/reference/diagnostics.md +1 -0
  155. package/docs/handbook/reference/procedure.md +2 -1
  156. package/docs/handbook/reference/schema.md +6 -3
  157. package/docs/handbook/reference/surface.md +6 -2
  158. package/docs/handbook/reference/view.md +7 -5
  159. package/docs/handbook/releases/index.md +78 -4
  160. package/docs/handbook/start/project-and-cli.md +20 -12
  161. package/docs/skills/develop/SKILL.md +8 -2
  162. package/docs/skills/provision/SKILL.md +4 -1
  163. package/docs/skills/update/SKILL.md +3 -0
  164. package/docs/upgrade-0.1-to-0.2.md +1 -1
  165. package/package.json +6 -5
  166. package/dist/postgres/textRows.d.ts +0 -10
  167. package/dist/postgres/textRows.d.ts.map +0 -1
  168. package/dist/postgres/textRows.js +0 -44
  169. package/dist/postgres/textRows.js.map +0 -1
@@ -51,7 +51,7 @@ refused (exit 2), so switching never drops tables or orphans data. Change
51
51
  | | `cloudflare` | `bun` | `none` |
52
52
  |---|---|---|---|
53
53
  | `sqlite` | preset over D1 (the default) | native bun:sqlite | plan and types only |
54
- | `postgres` | preset over Hyperdrive and `pg` | native Bun.SQL PostgreSQL pool | plan and types only |
54
+ | `postgres` | preset over Hyperdrive and `pg` | preset over a `pg.Pool` (node-postgres) | plan and types only |
55
55
  | a dialect package | plan and types only; compose `src/service.ts` with its storage adapter | plan and types only | plan and types only |
56
56
 
57
57
  Each selection needs packages in the project. `mantle generate` checks them
@@ -72,13 +72,14 @@ it a supported combination; inspect peer warnings before starting the service.
72
72
  | identity `mantle` | `better-auth`, `@better-auth/oauth-provider`, `@better-auth/mcp`, `@better-auth/cimd` |
73
73
  | feature `mcp` | `@modelcontextprotocol/server`, `@modelcontextprotocol/ext-apps` |
74
74
  | feature `admin` | `@aotter/mantle-ui` (its `dist/admin` is the console, bound as `ASSETS` in `wrangler.jsonc`) |
75
- | dialect `postgres` on `cloudflare` | `pg` |
75
+ | dialect `postgres` (host `cloudflare` or `bun`) | `pg` |
76
76
  | host `bun` | `bun-types` |
77
77
  | feature `mcp` with an identity, without `admin` | `@aotter/mantle-ui` (the staff MCP App) |
78
78
 
79
79
  On Cloudflare the project also installs `wrangler`, `@cloudflare/workers-types` and
80
- `@types/node` itself. A TypeScript Cloudflare/PostgreSQL project also installs
81
- `@types/pg` as a dev dependency for the generated `pg` import.
80
+ `@types/node` itself. A TypeScript PostgreSQL project, on Cloudflare or Bun, also installs
81
+ `@types/pg` as a dev dependency for the generated `pg` import; node-postgres is
82
+ the PostgreSQL driver on every host.
82
83
 
83
84
  ## `mantle generate`
84
85
 
@@ -121,7 +122,7 @@ diff without applying it, for the `sqlite` dialect; see [Deploy and operate](../
121
122
  ### PostgreSQL on Cloudflare
122
123
 
123
124
  `mantle generate --dialect postgres` writes the same preset over Hyperdrive:
124
- `src/service.ts` opens a `pg` client per operation from `env.HYPERDRIVE`, and
125
+ `src/service.ts` opens one `pg` client per request from `env.HYPERDRIVE`, and
125
126
  `wrangler.jsonc` binds `HYPERDRIVE` with a placeholder id and a
126
127
  `localConnectionString` for `wrangler dev`. Before deploying, create the config
127
128
  with caching off and put its id in place of the placeholder; generate warns
@@ -131,6 +132,14 @@ until you do:
131
132
  wrangler hyperdrive create my-app --caching-disabled --connection-string="postgres://user:pass@host:5432/db"
132
133
  ```
133
134
 
135
+ Reads run under the role's own statement limit, so give it one, and UTC, before
136
+ the first boot (locally too); the boot error names any other setting:
137
+
138
+ ```sql
139
+ ALTER ROLE app SET statement_timeout = '10s';
140
+ ALTER ROLE app SET TimeZone = 'UTC';
141
+ ```
142
+
134
143
  ## 0.1.x projects
135
144
 
136
145
  `apiVersion: cms.mantle.aotter.net/v1` manifests, a `version: 1` config, `mantle validate`,
@@ -143,16 +152,15 @@ wrangler hyperdrive create my-app --caching-disabled --connection-string="postgr
143
152
  for the generated project's typecheck, the selected feature/identity packages,
144
153
  then set DATABASE_URL in `.env` and run `bun src/index.ts`. For SQLite pass
145
154
  `--dialect sqlite` and optionally DATABASE_FILE (default mantle.sqlite).
146
- The preset is written once, uses native drivers from `@aotter/mantle/bun`, and
155
+ The preset is written once, uses `pg` for PostgreSQL and bun:sqlite for SQLite (`@aotter/mantle/bun`), and
147
156
  owns Bun.serve, trusted socket IP and shutdown/background work. Admin binds the
148
157
  installed UI bundle. Enabled schedule Triggers fail generation; use `host: none`
149
158
  with an explicit scheduler when schedules are required. Behind a reverse proxy,
150
159
  set TRUSTED_PROXIES to its addresses: otherwise every client shares the proxy's
151
160
  address, and with it one sign-in rate limit.
152
161
 
153
- PostgreSQL pools must set `prepare: false`: Bun otherwise re-encodes JSON strings,
154
- and the role needs TEMPORARY on the database (`GRANT TEMPORARY ON DATABASE app TO
155
- app_role`), which describing a result takes.
156
- Mantle refuses another setting. Native raw result metadata comes from PostgreSQL
157
- with three extra round trips per result, preserving microseconds and exact numeric
158
- scale. No pg dependency or PostgreSQL clone is added. See ADR-0038.
162
+ PostgreSQL on Bun is node-postgres, as on Workers (ADR-0039): the entry builds a
163
+ `pg.Pool` with `pipeline: true`, and each request borrows one pooled client
164
+ (`requestScoped`). Install `pg`. The role needs no privilege beyond converging its
165
+ tables (no `TEMPORARY`); set `statement_timeout` and `TimeZone` UTC on the role,
166
+ which boot checks.
@@ -47,7 +47,11 @@ Choose in this order, stopping at the first that works:
47
47
 
48
48
  ## SQL rules that trip agents
49
49
 
50
- - PostgreSQL syntax over declared Schemas only. References: `input.<name>`,
50
+ - SQL over declared Schemas only, in the project's own dialect: PostgreSQL's
51
+ syntax on PostgreSQL, a SQLite subset on D1. Each dialect is its own target:
52
+ a manifest need not compile for the other, and a SQLite spelling such as
53
+ `json_each` or `->> '$.a'` is refused on PostgreSQL with the PostgreSQL one
54
+ (rewrite table: `docs/handbook/concepts/runtime-and-adapters.md`). References: `input.<name>`,
51
55
  `auth.uid()`, `auth.role()`, `now()`; search is `mantle.search(t, q)`.
52
56
  - Native columns are snake_case in SQL (`created_at`, `author_id`) and
53
57
  camelCase in `ctx.store` JSON and in `indexes`.
@@ -60,7 +64,9 @@ Choose in this order, stopping at the first that works:
60
64
  - `LIMIT` needs `ORDER BY`. No `OFFSET`, `RIGHT JOIN` or `CURRENT_TIMESTAMP`
61
65
  on any dialect. On SQLite (D1) also no `WITH`, `UNION`, `ILIKE` or jsonb
62
66
  operators, and `CAST(x AS int)` only on an integer literal: use `round(x)`.
63
- PostgreSQL accepts these (`docs/handbook/reference/view.md`).
67
+ PostgreSQL accepts these (`docs/handbook/reference/view.md`). On PostgreSQL
68
+ unnest with `jsonb_array_elements_text(t.col) WITH ORDINALITY AS j(value, n)`,
69
+ not `json_each`; unstated `NULLS` follow PostgreSQL (last ascending).
64
70
  - Unquoted aliases fold to lower case: `AS "orderCount"` keeps the case.
65
71
  - The runtime injects scope and TTL into every Schema reference, and
66
72
  published-only into public Views. Never repeat them.
@@ -47,7 +47,10 @@ Confirm the active Cloudflare account with the user before creating anything.
47
47
  `pnpm exec wrangler hyperdrive create <name> --caching-disabled --connection-string=...`
48
48
  (the connection string by hidden input) and replace the placeholder id in
49
49
  `hyperdrive[0]`, keeping the binding `HYPERDRIVE`. An existing 0.1.x
50
- database is never reused: 0.2 starts on a new one.
50
+ database is never reused: 0.2 starts on a new one. PostgreSQL uses
51
+ node-postgres on every host (Hyperdrive on Cloudflare, a `pg.Pool` on Bun);
52
+ set `statement_timeout` (10s or less) and `TimeZone` `UTC` on the database
53
+ role, which boot checks on both.
51
54
  2. **Origin.** Set `PUBLIC_ORIGIN` in `vars` to the deployed HTTPS origin.
52
55
  Update it together with any OAuth callback when a custom domain is added.
53
56
  3. **Sign-in (identity `mantle`).** Choose one production method and edit
@@ -41,6 +41,9 @@ pnpm exec mantle generate --check
41
41
  pnpm exec tsc --noEmit
42
42
  ```
43
43
 
44
+ An existing PostgreSQL service also follows the upgrade notes in
45
+ `docs/handbook/releases/index.md` (SQL rewrites, `mantle generate` for the
46
+ new dialect version, the regenerated `src/service.ts`).
44
47
  6. The preset (`src/service.ts`, `src/index.ts`, `src/handlers.ts`,
45
48
  `wrangler.jsonc`) is never
46
49
  rewritten. Generate into a scratch directory with the same manifests and
@@ -50,7 +50,7 @@ command; it never installs anything.
50
50
  - `features` is a subset of `mcp`, `admin`, `web`, in that order. The 0.1.x
51
51
  features `spec`, `runtime` and `api` are dropped: REST is always mounted.
52
52
  - `dialect` is `sqlite` (alias `d1`, the default, left out) or `postgres`
53
- (PostgreSQL through Hyperdrive on `cloudflare`; Bun.SQL on `bun`, where it
53
+ (PostgreSQL through Hyperdrive on `cloudflare`; node-postgres on `bun`, where it
54
54
  is the default). A 0.1.x project was SQLite: keep `sqlite` (with
55
55
  `--host bun`, pass `--dialect sqlite`) unless the data also moves to
56
56
  PostgreSQL.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aotter/mantle",
3
- "version": "0.2.0-alpha.5",
3
+ "version": "0.2.0-alpha.6",
4
4
  "description": "Mantle: a manifest-driven service core. Store authored as SQL, surfaces as Fetch functions, and the mantle CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://mantle.tools/",
@@ -84,8 +84,8 @@
84
84
  "@pgsql/types": "18.0.0",
85
85
  "libpg-query": "18.1.5",
86
86
  "pgsql-deparser": "18.3.8",
87
- "yaml": "^2.9.0",
88
- "zod": "^4.5.4",
87
+ "yaml": "^2.9.1",
88
+ "zod": "^4.6.5",
89
89
  "semver": "^7.8.5"
90
90
  },
91
91
  "devDependencies": {
@@ -103,8 +103,9 @@
103
103
  "bun-types": "1.3.14",
104
104
  "pg": "8.23.1",
105
105
  "typescript": "^6.0.3",
106
- "vitest": "^4.1.11",
107
- "wrangler": "4.126.0",
106
+ "vitest": "^5.0.1",
107
+ "@cloudflare/workers-types": "^5.20261008.1",
108
+ "wrangler": "4.137.0",
108
109
  "@types/semver": "^7.7.1"
109
110
  },
110
111
  "peerDependencies": {
@@ -1,10 +0,0 @@
1
- /** Result description for transports without RowDescription (Bun.SQL).
2
- * PostgreSQL describes an unexecuted query through CREATE TEMP TABLE AS ... WITH NO DATA.
3
- * It owns OIDs/typmods, including CASE, COALESCE, CTEs and planner-folded expressions.
4
- */
5
- import type { SqlNode as N } from '../spec/domain/index.js';
6
- export declare function describeResult(ast: N): {
7
- query: string;
8
- names: string[] | undefined;
9
- } | undefined;
10
- //# sourceMappingURL=textRows.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"textRows.d.ts","sourceRoot":"","sources":["../../src/postgres/textRows.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,yBAAyB,CAAC;AAgB5D,wBAAgB,cAAc,CAAC,GAAG,EAAE,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAUjG"}
@@ -1,44 +0,0 @@
1
- import { print } from './print.js';
2
- /** PostgreSQL parse_target.c FigureColname rules for the closed Mantle expression grammar. */
3
- function outputName(n) {
4
- if (!n)
5
- return ['?column?', 0];
6
- if (n.ColumnRef)
7
- return [n.ColumnRef.fields.filter((f) => f.String).at(-1)?.String.sval ?? '?column?', 2];
8
- if (n.FuncCall)
9
- return [n.FuncCall.funcname.at(-1).String.sval, 2];
10
- if (n.CoalesceExpr)
11
- return ['coalesce', 2];
12
- if (n.MinMaxExpr)
13
- return [n.MinMaxExpr.op === 'IS_GREATEST' ? 'greatest' : 'least', 2];
14
- if (n.A_Expr?.kind === 'AEXPR_NULLIF')
15
- return ['nullif', 2];
16
- if (n.TypeCast) {
17
- const inner = outputName(n.TypeCast.arg);
18
- return inner[1] > 1 ? inner : [n.TypeCast.typeName.names.at(-1).String.sval, 1];
19
- }
20
- if (n.CaseExpr) {
21
- const inner = outputName(n.CaseExpr.defresult);
22
- return inner[1] > 1 ? inner : ['case', 1];
23
- }
24
- if (n.SubLink?.subLinkType === 'EXISTS_SUBLINK')
25
- return ['exists', 2];
26
- if (n.SubLink?.subLinkType === 'EXPR_SUBLINK') {
27
- const t = n.SubLink.subselect?.SelectStmt?.targetList?.[0]?.ResTarget;
28
- return t?.name ? [t.name, 2] : outputName(t?.val);
29
- }
30
- return ['?column?', 0];
31
- }
32
- export function describeResult(ast) {
33
- const body = ast.SelectStmt ?? ast.InsertStmt ?? ast.UpdateStmt ?? ast.DeleteStmt;
34
- const targets = ast.SelectStmt ? body.targetList : body?.returningClause?.exprs;
35
- if (!targets?.length)
36
- return undefined;
37
- // `*` and `t.*` expand to columns only PostgreSQL knows: name none, so each column keeps its own name
38
- const star = targets.some((t) => t.ResTarget.val?.ColumnRef?.fields?.at(-1)?.A_Star);
39
- return {
40
- query: ast.SelectStmt ? print(ast) : `WITH _mantle_result AS (${print(ast)}) SELECT * FROM _mantle_result`,
41
- names: star ? undefined : targets.map((t) => t.ResTarget.name ?? outputName(t.ResTarget.val)[0]),
42
- };
43
- }
44
- //# sourceMappingURL=textRows.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"textRows.js","sourceRoot":"","sources":["../../src/postgres/textRows.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,8FAA8F;AAC9F,SAAS,UAAU,CAAC,CAAgB;IAClC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC/B,IAAI,CAAC,CAAC,SAAS;QAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC;IAC7G,IAAI,CAAC,CAAC,QAAQ;QAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,C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