supastash 0.1.31 → 0.1.32

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/schemaManager/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,qBAAqB,EAC7B,oBAAoB,UAAQ,iBAiF7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/schemaManager/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,qBAAqB,EAC7B,oBAAoB,UAAQ,iBAoF7B"}
@@ -38,7 +38,7 @@ export async function defineLocalSchema(tableName, schema, deletePreviousSchema
38
38
  throw new Error(`'id' of type UUID column is required for table ${tableName}`);
39
39
  }
40
40
  const db = await getSupastashDb();
41
- const { __indices, ...columnSchema } = schema;
41
+ const { __indices, __constraints, ...columnSchema } = schema;
42
42
  const indexNotInSchema = __indices?.filter((i) => !columnSchema[i]) ?? [];
43
43
  if (indexNotInSchema.length > 0) {
44
44
  throw new Error(`Index columns ${indexNotInSchema.join(", ")} not found in schema. Please ensure all columns are defined in the schema.`);
@@ -54,7 +54,7 @@ export async function defineLocalSchema(tableName, schema, deletePreviousSchema
54
54
  // Build column definitions
55
55
  const schemaParts = Object.entries(safeSchema).map(([key, value]) => `${key} ${value}`);
56
56
  const schemaString = schemaParts.join(", ");
57
- const sql = `CREATE TABLE IF NOT EXISTS ${tableName} (${schemaString});`;
57
+ const sql = `CREATE TABLE IF NOT EXISTS ${tableName} (${schemaString}) ${__constraints ? ` ${__constraints}` : ""};`;
58
58
  if (deletePreviousSchema) {
59
59
  const dropSql = `DROP TABLE IF EXISTS ${tableName}`;
60
60
  const clearSyncStatusSql = `DELETE FROM supastash_sync_status WHERE table_name = '${tableName}'`;
@@ -39,6 +39,7 @@ export type LocalSchemaDefinition = {
39
39
  [key: string]: ColumnDefinition | string[];
40
40
  } & {
41
41
  __indices?: string[];
42
+ __constraints?: string;
42
43
  };
43
44
 
44
45
  export type DefineLocalSchema = (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supastash",
3
- "version": "0.1.31",
3
+ "version": "0.1.32",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",