@nuxodin/item 0.6.11 → 0.6.13

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/item.d.ts CHANGED
@@ -100,6 +100,9 @@ export interface ItemProxyChildren { [key: string]: ItemProxy<unknown, Item>; }
100
100
 
101
101
  export interface ItemProxyMethods<T = ItemValue,TRaw extends Item = Item> {
102
102
  readonly [$item]: TRaw;
103
+ // the proxy is callable, so TS would type these as Function members; at runtime they are children
104
+ readonly name: ItemProxy<unknown, Item>;
105
+ readonly length: ItemProxy<unknown, Item>;
103
106
  <TValue = T>(): TValue;
104
107
  (value: unknown): Promise<any> | undefined;
105
108
  then<TResult1 = T, TResult2 = never>(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxodin/item",
3
- "version": "0.6.11",
3
+ "version": "0.6.13",
4
4
  "description": "Reactive state library",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,10 +30,12 @@ function emittable(prop, isSoloPk) {
30
30
  return out
31
31
  }
32
32
 
33
- function createBody(fields, primaries) {
33
+ function createBody(table, fields, primaries) {
34
34
  const solo = soloIntPrimary(fields, primaries)
35
35
  const cols = fields.map(([n, f]) => {
36
36
  const isPk = n === solo
37
+ if (f['x-autoincrement'] && !isPk)
38
+ console.warn(`Skip AUTOINCREMENT ${table}.${n}: SQLite auto-increments only a sole INTEGER PRIMARY KEY — nothing fills this column`)
37
39
  // Only `INTEGER PRIMARY KEY` is the rowid alias, and AUTOINCREMENT is legal nowhere else —
38
40
  // so a boolean key keeps the integer spelling, which SQLite would otherwise reject.
39
41
  let def = toFieldDef(n, isPk ? { ...f, type: 'integer' } : f)
@@ -99,7 +101,7 @@ export async function schemaToDb(schema, query, { force = false, patch = false }
99
101
  const primaries = fields.filter(([, f]) => f['x-index'] === 'primary').map(([n]) => n)
100
102
 
101
103
  if (!currTables.includes(table)) {
102
- stmts.push(`CREATE TABLE ${quoteId(table)} (\n${createBody(fields, primaries)}\n);`)
104
+ stmts.push(`CREATE TABLE ${quoteId(table)} (\n${createBody(table, fields, primaries)}\n);`)
103
105
  stmts.push(...indexStatements(table, fields, primaries))
104
106
  } else {
105
107
  const currFields = new Map(tableFields(current.properties[table]))
@@ -116,7 +118,7 @@ export async function schemaToDb(schema, query, { force = false, patch = false }
116
118
  const keep = fields.map(([n]) => n).filter(n => currFields.has(n))
117
119
  const colsList = keep.map(quoteId).join(', ')
118
120
 
119
- stmts.push(`CREATE TABLE ${quoteId(tmp)} (\n${createBody(fields, primaries)}\n);`)
121
+ stmts.push(`CREATE TABLE ${quoteId(tmp)} (\n${createBody(table, fields, primaries)}\n);`)
120
122
  if (keep.length) stmts.push(`INSERT INTO ${quoteId(tmp)} (${colsList}) SELECT ${colsList} FROM ${quoteId(table)};`)
121
123
  stmts.push(`DROP TABLE ${quoteId(table)};`)
122
124
  stmts.push(`ALTER TABLE ${quoteId(tmp)} RENAME TO ${quoteId(table)};`)