@syncular/typegen 0.15.7 → 0.15.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -236,12 +236,14 @@ and Rust clients create a contentful FTS table with a private stable source-ID
236
236
  column and deterministic maintenance triggers. FTS is local-only: it is not a
237
237
  wire/server table, cannot be subscribed or mutated, and maps back to its owner
238
238
  for named-query invalidation. Columns must precede options, be distinct
239
- non-encrypted strings, and number 1–32. `content` is required. Supported
240
- tokenizers are `unicode61` (default), its `remove_diacritics 0|1|2` variants,
241
- `porter unicode61`, and `trigram`. Other modules/options/tokenizers, encrypted
242
- columns, or schema-object name collisions fail generation. There is no
243
- automatic `LIKE` fallback when FTS5 is unavailable; local schema creation
244
- fails loudly.
239
+ declared strings, and number 1–32. Encrypted declared-string columns are
240
+ allowed because the projection is built only from the decrypted local mirror;
241
+ ciphertext remains the only wire and server representation. `content` is
242
+ required. Supported tokenizers are `unicode61` (default), its
243
+ `remove_diacritics 0|1|2` variants, `porter unicode61`, and `trigram`. Other
244
+ modules/options/tokenizers or schema-object name collisions fail generation.
245
+ There is no automatic `LIKE` fallback when FTS5 is unavailable; local schema
246
+ creation fails loudly.
245
247
 
246
248
  **Hard errors** (each names the construct and source file): any other
247
249
  statement (`CREATE TRIGGER/VIEW`, `DROP INDEX`, DML, `ALTER … RENAME`, …); unknown
@@ -252,7 +254,7 @@ or parameterized types (`VARCHAR(36)`); quoted identifiers
252
254
  or missing primary keys; `PRIMARY KEY` on `ADD COLUMN`; duplicate
253
255
  tables/columns; ASC/DESC, expression, or partial (`WHERE`) index columns; a
254
256
  duplicate or unknown-column index; unsupported virtual-table modules or FTS5
255
- options; an FTS projection without an owner or with invalid/encrypted columns;
257
+ options; an FTS projection without an owner or with invalid columns;
256
258
  trailing clauses (`STRICT`).
257
259
 
258
260
  **`DEFAULT` literals are accepted and ignored**: typegen extracts the
package/dist/generate.js CHANGED
@@ -50,14 +50,6 @@ function buildTable(manifestTable, parsed) {
50
50
  }
51
51
  }
52
52
  const columns = applyEncryption(parsed, scopes, manifestTable.encryptedColumns);
53
- for (const ftsIndex of parsed.ftsIndexes) {
54
- for (const columnName of ftsIndex.columns) {
55
- const column = columns.find((candidate) => candidate.name === columnName);
56
- if (column?.encrypted === true) {
57
- throw new TypegenError(MANIFEST_FILENAME, `table ${parsed.name}: FTS index ${JSON.stringify(ftsIndex.name)} cannot index encrypted column ${JSON.stringify(columnName)}`);
58
- }
59
- }
60
- }
61
53
  return {
62
54
  name: parsed.name,
63
55
  primaryKey: parsed.primaryKey,
package/dist/query.js CHANGED
@@ -949,12 +949,17 @@ export function analyzeStatement(name, location, statementText, ir, db, naming =
949
949
  };
950
950
  }
951
951
  if (source !== null) {
952
- // Exact: IR column type + IR nullability. (decltype agrees; we prefer
953
- // the IR type so blob_ref/crdt/json semantic types survive.)
952
+ // Exact: app-facing queries read the decrypted local mirror. Encrypted
953
+ // columns therefore expose their pre-wire declaredType, while the schema
954
+ // IR and mutation codec continue to carry the bytes wire type.
955
+ const sourceType = source.column.encrypted === true &&
956
+ source.column.declaredType !== undefined
957
+ ? source.column.declaredType
958
+ : source.column.type;
954
959
  return {
955
960
  name: sqlName,
956
961
  langName,
957
- type: source.column.type,
962
+ type: sourceType,
958
963
  nullable: source.column.nullable,
959
964
  fidelity: 'exact',
960
965
  origin: { table: source.table, column: source.column.name },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/typegen",
3
- "version": "0.15.7",
3
+ "version": "0.15.9",
4
4
  "description": "Syncular schema-to-TypeScript type generator and the `syncular` CLI",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -48,7 +48,7 @@
48
48
  "!dist/**/*.test.d.ts"
49
49
  ],
50
50
  "devDependencies": {
51
- "@syncular/core": "0.15.7",
52
- "@syncular/server": "0.15.7"
51
+ "@syncular/core": "0.15.9",
52
+ "@syncular/server": "0.15.9"
53
53
  }
54
54
  }
package/src/generate.ts CHANGED
@@ -113,17 +113,6 @@ function buildTable(
113
113
  scopes,
114
114
  manifestTable.encryptedColumns,
115
115
  );
116
- for (const ftsIndex of parsed.ftsIndexes) {
117
- for (const columnName of ftsIndex.columns) {
118
- const column = columns.find((candidate) => candidate.name === columnName);
119
- if (column?.encrypted === true) {
120
- throw new TypegenError(
121
- MANIFEST_FILENAME,
122
- `table ${parsed.name}: FTS index ${JSON.stringify(ftsIndex.name)} cannot index encrypted column ${JSON.stringify(columnName)}`,
123
- );
124
- }
125
- }
126
- }
127
116
  return {
128
117
  name: parsed.name,
129
118
  primaryKey: parsed.primaryKey,
package/src/query.ts CHANGED
@@ -1378,12 +1378,18 @@ export function analyzeStatement(
1378
1378
  };
1379
1379
  }
1380
1380
  if (source !== null) {
1381
- // Exact: IR column type + IR nullability. (decltype agrees; we prefer
1382
- // the IR type so blob_ref/crdt/json semantic types survive.)
1381
+ // Exact: app-facing queries read the decrypted local mirror. Encrypted
1382
+ // columns therefore expose their pre-wire declaredType, while the schema
1383
+ // IR and mutation codec continue to carry the bytes wire type.
1384
+ const sourceType =
1385
+ source.column.encrypted === true &&
1386
+ source.column.declaredType !== undefined
1387
+ ? source.column.declaredType
1388
+ : source.column.type;
1383
1389
  return {
1384
1390
  name: sqlName,
1385
1391
  langName,
1386
- type: source.column.type,
1392
+ type: sourceType,
1387
1393
  nullable: source.column.nullable,
1388
1394
  fidelity: 'exact',
1389
1395
  origin: { table: source.table, column: source.column.name },