@pol-studios/db 1.0.55 → 1.0.57

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 (55) hide show
  1. package/dist/{DataLayerContext-C7cJtiO8.d.ts → DataLayerContext-BYZtDD0g.d.ts} +1 -1
  2. package/dist/auth/context.js +4 -2
  3. package/dist/auth/hooks.js +5 -3
  4. package/dist/auth/index.js +5 -3
  5. package/dist/{chunk-7YGDT46S.js → chunk-4EO55YV2.js} +10 -7
  6. package/dist/chunk-4EO55YV2.js.map +1 -0
  7. package/dist/{chunk-WILXD5X3.js → chunk-6SDH7M7J.js} +25 -9
  8. package/dist/chunk-6SDH7M7J.js.map +1 -0
  9. package/dist/{chunk-OC6S4XFL.js → chunk-DDL63KLQ.js} +385 -104
  10. package/dist/chunk-DDL63KLQ.js.map +1 -0
  11. package/dist/{chunk-WSKBZIEI.js → chunk-GWYTROSD.js} +95 -1
  12. package/dist/chunk-GWYTROSD.js.map +1 -0
  13. package/dist/{chunk-BRFFTGVJ.js → chunk-MEBT5YHA.js} +2 -2
  14. package/dist/chunk-QYAFI34Q.js +64 -0
  15. package/dist/chunk-QYAFI34Q.js.map +1 -0
  16. package/dist/{chunk-AA3VUWTP.js → chunk-VSJKGPRI.js} +12 -8
  17. package/dist/chunk-VSJKGPRI.js.map +1 -0
  18. package/dist/{chunk-AKCNWHXV.js → chunk-VYFAMTHI.js} +2 -2
  19. package/dist/chunk-W7PERM66.js +215 -0
  20. package/dist/chunk-W7PERM66.js.map +1 -0
  21. package/dist/{chunk-HZIVE5AZ.js → chunk-YRIPM2AN.js} +253 -338
  22. package/dist/chunk-YRIPM2AN.js.map +1 -0
  23. package/dist/core/index.d.ts +24 -1
  24. package/dist/{executor-YJw4m7Q7.d.ts → executor-D15yjeMo.d.ts} +20 -0
  25. package/dist/hooks/index.d.ts +3 -3
  26. package/dist/hooks/index.js +4 -2
  27. package/dist/{index-jVYdTeWx.d.ts → index-CFUuTzXO.d.ts} +1 -1
  28. package/dist/index.d.ts +5 -5
  29. package/dist/index.js +10 -8
  30. package/dist/index.native.d.ts +6 -6
  31. package/dist/index.native.js +10 -8
  32. package/dist/index.web.d.ts +10 -9
  33. package/dist/index.web.js +23 -12
  34. package/dist/index.web.js.map +1 -1
  35. package/dist/powersync-bridge/index.d.ts +1 -1
  36. package/dist/query/index.d.ts +4 -83
  37. package/dist/query/index.js +13 -3
  38. package/dist/realtime/index.d.ts +80 -1
  39. package/dist/realtime/index.js +11 -9
  40. package/dist/realtime/index.js.map +1 -1
  41. package/dist/select-parser-BAV7fOaM.d.ts +144 -0
  42. package/dist/types/index.d.ts +3 -3
  43. package/dist/{useDbCount-DHLJzmkO.d.ts → useDbCount-Ckb-FhZk.d.ts} +1 -1
  44. package/dist/{useResolveFeedback-B0UcYWVI.d.ts → useResolveFeedback-CuUkdHoR.d.ts} +13 -29
  45. package/dist/with-auth/index.js +7 -5
  46. package/dist/with-auth/index.js.map +1 -1
  47. package/package.json +5 -2
  48. package/dist/chunk-7YGDT46S.js.map +0 -1
  49. package/dist/chunk-AA3VUWTP.js.map +0 -1
  50. package/dist/chunk-HZIVE5AZ.js.map +0 -1
  51. package/dist/chunk-OC6S4XFL.js.map +0 -1
  52. package/dist/chunk-WILXD5X3.js.map +0 -1
  53. package/dist/chunk-WSKBZIEI.js.map +0 -1
  54. /package/dist/{chunk-BRFFTGVJ.js.map → chunk-MEBT5YHA.js.map} +0 -0
  55. /package/dist/{chunk-AKCNWHXV.js.map → chunk-VYFAMTHI.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/query/result-joiner.ts","../src/query/relationship-resolver.ts","../src/query/sql-builder.ts","../src/query/executor.ts"],"sourcesContent":["/**\n * Result Joiner\n *\n * After querying the base table and related tables separately,\n * this module joins them into a nested structure matching Supabase's format.\n */\n\nimport type { ResolvedRelationship } from \"../core/types\";\n\n/**\n * Data about a relation to be joined onto base records.\n */\nexport interface RelationJoinData {\n records: Record<string, unknown>[];\n relationship: ResolvedRelationship;\n nestedRelations: Map<string, RelationJoinData>;\n}\n\n/**\n * Result joiner for combining base records with related data.\n *\n * This class handles joining related data onto base records after\n * separate queries have been executed. It supports:\n * - One-to-many relationships (base gets array of related)\n * - Many-to-one relationships (base gets single related object or null)\n * - Nested relationships (recursive joining)\n */\nexport class ResultJoiner {\n /**\n * Join related data onto base records.\n *\n * @param baseRecords - The base table records\n * @param relatedRecords - Records from the related table\n * @param relationship - The relationship definition\n * @param relationName - The property name to use for the relation\n * @returns Base records with related data attached\n *\n * @example\n * // One-to-many: EquipmentUnit -> EquipmentFixture[]\n * const joiner = new ResultJoiner();\n * const result = joiner.join(\n * equipmentUnits,\n * equipmentFixtures,\n * { type: \"one-to-many\", foreignKey: \"equipmentUnitId\", referencedColumn: \"id\", ... },\n * \"EquipmentFixture\"\n * );\n * // Each equipmentUnit now has EquipmentFixture: [...]\n *\n * @example\n * // Many-to-one: EquipmentUnit -> ProjectDatabase\n * const result = joiner.join(\n * equipmentUnits,\n * projectDatabases,\n * { type: \"many-to-one\", foreignKey: \"projectDatabaseId\", referencedColumn: \"id\", ... },\n * \"ProjectDatabase\"\n * );\n * // Each equipmentUnit now has ProjectDatabase: {...} or null\n */\n join<T extends Record<string, unknown>>(baseRecords: T[], relatedRecords: Record<string, unknown>[], relationship: ResolvedRelationship, relationName: string): T[] {\n if (baseRecords.length === 0) {\n return baseRecords;\n }\n if (relationship.type === \"one-to-many\") {\n // Each base record gets an array of related records\n // The related table has a FK pointing to the base table\n // e.g., EquipmentFixture.equipmentUnitId -> EquipmentUnit.id\n\n // Pre-index related records by FK - O(m)\n const groupedByFK = new Map<unknown, Record<string, unknown>[]>();\n for (const r of relatedRecords) {\n const fkValue = r[relationship.foreignKey];\n if (!groupedByFK.has(fkValue)) groupedByFK.set(fkValue, []);\n groupedByFK.get(fkValue)!.push(r);\n }\n\n // Join in O(n) - mutate in place since records are already copies\n for (const base of baseRecords) {\n const baseId = base[relationship.referencedColumn];\n (base as Record<string, unknown>)[relationName] = groupedByFK.get(baseId) ?? [];\n }\n return baseRecords;\n } else {\n // Many-to-one: Each base record gets a single related object or null\n // The base table has a FK pointing to the related table\n // e.g., EquipmentUnit.projectDatabaseId -> ProjectDatabase.id\n\n // Build a lookup map for faster joining\n const relatedMap = new Map<unknown, Record<string, unknown>>();\n for (const r of relatedRecords) {\n const refValue = r[relationship.referencedColumn];\n if (refValue !== null && refValue !== undefined) {\n relatedMap.set(refValue, r);\n }\n }\n\n // Join in O(n) - mutate in place since records are already copies\n for (const base of baseRecords) {\n const fkValue = base[relationship.foreignKey];\n (base as Record<string, unknown>)[relationName] = fkValue != null ? relatedMap.get(fkValue) ?? null : null;\n }\n return baseRecords;\n }\n }\n\n /**\n * Recursively join nested relations onto records.\n *\n * @param baseRecords - The base records\n * @param relationData - Map of relation names to join data\n * @returns Base records with all nested relations attached\n *\n * @example\n * // Join EquipmentFixture and ProjectDatabase onto EquipmentUnit\n * // where EquipmentFixture has its own nested Organization relation\n * const result = joiner.joinNested(equipmentUnits, new Map([\n * [\"EquipmentFixture\", {\n * records: fixtures,\n * relationship: { type: \"one-to-many\", ... },\n * nestedRelations: new Map()\n * }],\n * [\"ProjectDatabase\", {\n * records: projects,\n * relationship: { type: \"many-to-one\", ... },\n * nestedRelations: new Map([\n * [\"Organization\", { records: orgs, relationship: ..., nestedRelations: new Map() }]\n * ])\n * }]\n * ]));\n */\n joinNested<T extends Record<string, unknown>>(baseRecords: T[], relationData: Map<string, RelationJoinData>): T[] {\n let result = [...baseRecords];\n const entries = Array.from(relationData.entries());\n for (const [relationName, data] of entries) {\n // First, recursively join nested relations onto the related records\n let relatedRecords = data.records;\n if (data.nestedRelations.size > 0) {\n relatedRecords = this.joinNested(relatedRecords, data.nestedRelations);\n }\n\n // Then join the related records onto the base records\n result = this.join(result, relatedRecords, data.relationship, relationName);\n }\n return result;\n }\n\n /**\n * Group records by a key field.\n * Useful for preparing data before joining.\n *\n * @param records - Records to group\n * @param keyField - Field to group by\n * @returns Map of key values to arrays of records\n */\n groupBy<T extends Record<string, unknown>>(records: T[], keyField: string): Map<unknown, T[]> {\n const groups = new Map<unknown, T[]>();\n for (const record of records) {\n const key = record[keyField];\n if (!groups.has(key)) {\n groups.set(key, []);\n }\n groups.get(key)!.push(record);\n }\n return groups;\n }\n\n /**\n * Index records by a unique key field.\n * Useful for many-to-one lookups.\n *\n * @param records - Records to index\n * @param keyField - Field to index by (should be unique)\n * @returns Map of key values to single records\n */\n indexBy<T extends Record<string, unknown>>(records: T[], keyField: string): Map<unknown, T> {\n const index = new Map<unknown, T>();\n for (const record of records) {\n const key = record[keyField];\n if (key !== null && key !== undefined) {\n index.set(key, record);\n }\n }\n return index;\n }\n\n /**\n * Extract unique values for a field from records.\n * Useful for building IN clauses for related queries.\n *\n * @param records - Records to extract from\n * @param field - Field to extract\n * @returns Array of unique non-null values\n */\n extractUniqueValues<T extends Record<string, unknown>>(records: T[], field: string): (string | number)[] {\n const values = new Set<string | number>();\n for (const record of records) {\n const value = record[field];\n if (value !== null && value !== undefined) {\n values.add(value as string | number);\n }\n }\n return Array.from(values);\n }\n\n /**\n * Remove a relation property from records (for cleanup).\n *\n * @param records - Records to process\n * @param relationName - Relation property to remove\n * @returns Records without the specified property\n */\n removeRelation<T extends Record<string, unknown>>(records: T[], relationName: string): Omit<T, typeof relationName>[] {\n return records.map(record => {\n const {\n [relationName]: _removed,\n ...rest\n } = record;\n return rest as Omit<T, typeof relationName>;\n });\n }\n\n /**\n * Flatten a nested relation into the parent record.\n * Useful for flattening many-to-one relations.\n *\n * @param records - Records with nested relation\n * @param relationName - Name of the relation to flatten\n * @param prefix - Prefix for flattened field names\n * @returns Records with flattened relation fields\n */\n flattenRelation<T extends Record<string, unknown>>(records: T[], relationName: string, prefix: string = \"\"): Record<string, unknown>[] {\n return records.map(record => {\n const relation = record[relationName] as Record<string, unknown> | null;\n const {\n [relationName]: _removed,\n ...rest\n } = record;\n if (!relation) {\n return rest;\n }\n const flattenedRelation: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(relation)) {\n const fieldName = prefix ? `${prefix}_${key}` : `${relationName}_${key}`;\n flattenedRelation[fieldName] = value;\n }\n return {\n ...rest,\n ...flattenedRelation\n };\n });\n }\n}\n\n/**\n * Create a new result joiner instance.\n */\nexport function createResultJoiner(): ResultJoiner {\n return new ResultJoiner();\n}","/**\n * Relationship Resolver\n *\n * Looks up relationships between tables from the database schema.\n * Used to determine how to join related data in queries.\n */\n\nimport type { DatabaseSchema, TableSchema, RelationshipInfo, RelationshipType, ResolvedRelationship } from \"../core/types\";\n\n/**\n * Resolves relationships between tables using the database schema.\n *\n * Given a table and a relation name (which could be another table),\n * this class determines:\n * 1. Whether a relationship exists\n * 2. The type of relationship (one-to-many or many-to-one)\n * 3. Which columns are used for the join\n */\nexport class RelationshipResolver {\n constructor(private schema: DatabaseSchema) {}\n\n /**\n * Resolve a relationship from one table to another.\n *\n * This handles both:\n * - Forward relationships: This table has a FK to the related table (many-to-one)\n * - Reverse relationships: Related table has a FK to this table (one-to-many)\n *\n * @param fromTable - The table we're querying from\n * @param relationName - The name of the related table\n * @returns The resolved relationship or null if not found\n *\n * @example\n * // Forward relationship (many-to-one)\n * // EquipmentUnit.projectDatabaseId -> ProjectDatabase.id\n * resolver.resolve(\"EquipmentUnit\", \"ProjectDatabase\")\n * // Returns: {\n * // type: \"many-to-one\",\n * // fromTable: \"EquipmentUnit\",\n * // toTable: \"ProjectDatabase\",\n * // foreignKey: \"projectDatabaseId\",\n * // referencedColumn: \"id\"\n * // }\n *\n * @example\n * // Reverse relationship (one-to-many)\n * // EquipmentUnit <- EquipmentFixture.equipmentUnitId\n * resolver.resolve(\"EquipmentUnit\", \"EquipmentFixture\")\n * // Returns: {\n * // type: \"one-to-many\",\n * // fromTable: \"EquipmentUnit\",\n * // toTable: \"EquipmentFixture\",\n * // foreignKey: \"equipmentUnitId\",\n * // referencedColumn: \"id\"\n * // }\n */\n resolve(fromTable: string, relationName: string): ResolvedRelationship | null {\n const tableSchema = this.getTableSchema(fromTable);\n if (!tableSchema) {\n return null;\n }\n\n // Check forward relationships (this table has the FK)\n // e.g., EquipmentUnit.projectDatabaseId -> ProjectDatabase\n for (const rel of tableSchema.relationships) {\n if (rel.referencedTable === relationName) {\n return {\n type: \"many-to-one\",\n fromTable,\n toTable: relationName,\n foreignKey: rel.foreignKey,\n referencedColumn: rel.referencedColumn\n };\n }\n }\n\n // Check reverse relationships (other table has FK to this table)\n // e.g., EquipmentUnit <- EquipmentFixture.equipmentUnitId\n const relatedTableSchema = this.getTableSchema(relationName);\n if (relatedTableSchema) {\n for (const rel of relatedTableSchema.relationships) {\n if (rel.referencedTable === fromTable) {\n return {\n type: \"one-to-many\",\n fromTable,\n toTable: relationName,\n foreignKey: rel.foreignKey,\n referencedColumn: rel.referencedColumn\n };\n }\n }\n }\n return null;\n }\n\n /**\n * Get all forward relationships for a table (many-to-one).\n * These are relationships where this table has a foreign key.\n */\n getForwardRelationships(tableName: string): ResolvedRelationship[] {\n const tableSchema = this.getTableSchema(tableName);\n if (!tableSchema) {\n return [];\n }\n return tableSchema.relationships.map(rel => ({\n type: \"many-to-one\" as RelationshipType,\n fromTable: tableName,\n toTable: rel.referencedTable,\n foreignKey: rel.foreignKey,\n referencedColumn: rel.referencedColumn\n }));\n }\n\n /**\n * Get all reverse relationships for a table (one-to-many).\n * These are relationships where other tables have FKs pointing to this table.\n */\n getReverseRelationships(tableName: string): ResolvedRelationship[] {\n const results: ResolvedRelationship[] = [];\n\n // Search all tables for FKs pointing to this table\n for (const schemaName of Object.keys(this.schema.schemas)) {\n const schemaDefinition = this.schema.schemas[schemaName];\n if (!schemaDefinition) continue;\n for (const [otherTableName, otherTableSchema] of Object.entries(schemaDefinition.tables)) {\n if (otherTableName === tableName) continue;\n for (const rel of otherTableSchema.relationships) {\n if (rel.referencedTable === tableName) {\n results.push({\n type: \"one-to-many\",\n fromTable: tableName,\n toTable: otherTableName,\n foreignKey: rel.foreignKey,\n referencedColumn: rel.referencedColumn\n });\n }\n }\n }\n }\n return results;\n }\n\n /**\n * Get all relationships for a table (both directions).\n */\n getAllRelationships(tableName: string): ResolvedRelationship[] {\n return [...this.getForwardRelationships(tableName), ...this.getReverseRelationships(tableName)];\n }\n\n /**\n * Check if a relationship exists between two tables.\n */\n hasRelationship(fromTable: string, toTable: string): boolean {\n return this.resolve(fromTable, toTable) !== null;\n }\n\n /**\n * Get the table schema from the database schema.\n * Searches across all schema namespaces (public, core, etc.).\n */\n getTableSchema(tableName: string): TableSchema | null {\n // Check each schema namespace\n for (const schemaName of Object.keys(this.schema.schemas)) {\n const schemaDefinition = this.schema.schemas[schemaName];\n if (!schemaDefinition) continue;\n\n // Check tables\n if (schemaDefinition.tables[tableName]) {\n return schemaDefinition.tables[tableName];\n }\n\n // Check views\n if (schemaDefinition.views && schemaDefinition.views[tableName]) {\n return schemaDefinition.views[tableName];\n }\n }\n return null;\n }\n\n /**\n * Get the primary key column for a table.\n * Defaults to \"id\" if not explicitly found.\n */\n getPrimaryKey(tableName: string): string {\n const tableSchema = this.getTableSchema(tableName);\n if (!tableSchema) {\n return \"id\";\n }\n\n // Look for an 'id' column (most common case)\n const idColumn = tableSchema.columns.find(col => col.name === \"id\");\n if (idColumn) {\n return \"id\";\n }\n\n // Fall back to first column (usually the primary key)\n if (tableSchema.columns.length > 0) {\n return tableSchema.columns[0].name;\n }\n return \"id\";\n }\n\n /**\n * Get all column names for a table.\n */\n getColumnNames(tableName: string): string[] {\n const tableSchema = this.getTableSchema(tableName);\n if (!tableSchema) {\n return [];\n }\n return tableSchema.columns.map(col => col.name);\n }\n\n /**\n * Check if a table exists in the schema.\n */\n hasTable(tableName: string): boolean {\n return this.getTableSchema(tableName) !== null;\n }\n\n /**\n * Get all table names in the schema.\n */\n getAllTableNames(): string[] {\n const tables: string[] = [];\n for (const schemaName of Object.keys(this.schema.schemas)) {\n const schemaDefinition = this.schema.schemas[schemaName];\n if (!schemaDefinition) continue;\n tables.push(...Object.keys(schemaDefinition.tables));\n }\n return tables;\n }\n}\n\n/**\n * Create a relationship resolver instance.\n * Convenience function for creating a resolver.\n */\nexport function createRelationshipResolver(schema: DatabaseSchema): RelationshipResolver {\n return new RelationshipResolver(schema);\n}","/**\n * SQL Builder\n *\n * Builds SQLite queries from parsed select statements and query options.\n * Produces parameterized queries for safe execution against PowerSync's local SQLite.\n *\n * Note: SQLite uses double quotes for identifiers (table/column names).\n * This builder only creates queries for single tables - relations are queried\n * separately and joined in code.\n */\n\nimport type { BuiltQuery, SelectColumn, WhereClause, WhereOperators, OrderBy } from \"../core/types\";\n\n/**\n * Check if a value is a where operator object\n */\nfunction isWhereOperator(value: unknown): value is WhereOperators {\n if (value === null || typeof value !== \"object\") {\n return false;\n }\n const obj = value as Record<string, unknown>;\n return \"in\" in obj || \"gt\" in obj || \"gte\" in obj || \"lt\" in obj || \"lte\" in obj || \"like\" in obj || \"is\" in obj || \"neq\" in obj || \"notIn\" in obj;\n}\n\n/**\n * SQLite query builder.\n * Creates parameterized SQL queries for local SQLite execution.\n */\nexport class SQLBuilder {\n /**\n * Build a SELECT query for a single table.\n *\n * @param table - Table name\n * @param columns - Columns to select (\"*\" or array of column definitions)\n * @param options - Query options (where, orderBy, limit, offset)\n * @returns Built query with SQL and parameters\n *\n * @example\n * const builder = new SQLBuilder();\n * const query = builder.build(\"EquipmentUnit\", \"*\", {\n * where: { status: \"active\", projectDatabaseId: 123 },\n * orderBy: [{ field: \"name\", direction: \"asc\" }],\n * limit: 10\n * });\n * // query.sql: SELECT * FROM \"EquipmentUnit\" WHERE \"status\" = ? AND \"projectDatabaseId\" = ? ORDER BY \"name\" ASC LIMIT ?\n * // query.params: [\"active\", 123, 10]\n */\n build(table: string, columns: \"*\" | SelectColumn[], options: {\n where?: WhereClause;\n orderBy?: OrderBy[];\n limit?: number;\n offset?: number;\n } = {}): BuiltQuery {\n const params: (string | number | boolean | null)[] = [];\n\n // Build SELECT clause\n let columnList: string;\n if (columns === \"*\") {\n columnList = \"*\";\n } else if (columns.length === 0) {\n columnList = \"*\";\n } else {\n columnList = columns.map(c => {\n if (c.alias) {\n return `\"${c.name}\" AS \"${c.alias}\"`;\n }\n return `\"${c.name}\"`;\n }).join(\", \");\n }\n let sql = `SELECT ${columnList} FROM \"${table}\"`;\n\n // Build WHERE clause\n if (options.where && Object.keys(options.where).length > 0) {\n const whereClauses: string[] = [];\n for (const [field, value] of Object.entries(options.where)) {\n if (value === null) {\n // Direct null check\n whereClauses.push(`\"${field}\" IS NULL`);\n } else if (isWhereOperator(value)) {\n // Handle operator objects\n const operatorClauses = this.buildOperatorClauses(field, value, params);\n whereClauses.push(...operatorClauses);\n } else {\n // Simple equality\n whereClauses.push(`\"${field}\" = ?`);\n params.push(value as string | number | boolean);\n }\n }\n if (whereClauses.length > 0) {\n sql += ` WHERE ${whereClauses.join(\" AND \")}`;\n }\n }\n\n // Build ORDER BY clause\n if (options.orderBy && options.orderBy.length > 0) {\n const orderClauses = options.orderBy.map(o => `\"${o.field}\" ${o.direction.toUpperCase()}`);\n sql += ` ORDER BY ${orderClauses.join(\", \")}`;\n }\n\n // Build LIMIT clause\n if (options.limit !== undefined) {\n sql += ` LIMIT ?`;\n params.push(options.limit);\n }\n\n // Build OFFSET clause\n if (options.offset !== undefined) {\n sql += ` OFFSET ?`;\n params.push(options.offset);\n }\n return {\n sql,\n params\n };\n }\n\n /**\n * Build WHERE clauses from operator objects.\n */\n private buildOperatorClauses(field: string, operators: WhereOperators, params: (string | number | boolean | null)[]): string[] {\n const clauses: string[] = [];\n if (\"in\" in operators && operators.in !== undefined) {\n if (operators.in.length === 0) {\n // Empty IN clause - always false\n clauses.push(\"1 = 0\");\n } else {\n const placeholders = operators.in.map(() => \"?\").join(\", \");\n clauses.push(`\"${field}\" IN (${placeholders})`);\n params.push(...operators.in);\n }\n }\n if (\"notIn\" in operators && operators.notIn !== undefined) {\n if (operators.notIn.length === 0) {\n // Empty NOT IN clause - always true, skip\n } else {\n const placeholders = operators.notIn.map(() => \"?\").join(\", \");\n clauses.push(`\"${field}\" NOT IN (${placeholders})`);\n params.push(...operators.notIn);\n }\n }\n if (\"gt\" in operators && operators.gt !== undefined) {\n clauses.push(`\"${field}\" > ?`);\n params.push(operators.gt);\n }\n if (\"gte\" in operators && operators.gte !== undefined) {\n clauses.push(`\"${field}\" >= ?`);\n params.push(operators.gte);\n }\n if (\"lt\" in operators && operators.lt !== undefined) {\n clauses.push(`\"${field}\" < ?`);\n params.push(operators.lt);\n }\n if (\"lte\" in operators && operators.lte !== undefined) {\n clauses.push(`\"${field}\" <= ?`);\n params.push(operators.lte);\n }\n if (\"like\" in operators && operators.like !== undefined) {\n clauses.push(`\"${field}\" LIKE ?`);\n // Add wildcards if not already present\n const pattern = operators.like.includes(\"%\") ? operators.like : `%${operators.like}%`;\n params.push(pattern);\n }\n if (\"is\" in operators && operators.is === null) {\n clauses.push(`\"${field}\" IS NULL`);\n }\n if (\"neq\" in operators && operators.neq !== undefined) {\n if (operators.neq === null) {\n clauses.push(`\"${field}\" IS NOT NULL`);\n } else {\n clauses.push(`\"${field}\" != ?`);\n params.push(operators.neq);\n }\n }\n return clauses;\n }\n\n /**\n * Build a query to fetch related records by foreign key.\n *\n * @param table - The related table name\n * @param foreignKey - The FK column to match against\n * @param parentIds - Array of parent IDs to fetch related records for\n * @param columns - Columns to select\n * @returns Built query\n *\n * @example\n * // Fetch all EquipmentFixtures for given EquipmentUnit IDs\n * const query = builder.buildRelationQuery(\n * \"EquipmentFixture\",\n * \"equipmentUnitId\",\n * [\"uuid-1\", \"uuid-2\"],\n * \"*\"\n * );\n * // query.sql: SELECT * FROM \"EquipmentFixture\" WHERE \"equipmentUnitId\" IN (?, ?)\n * // query.params: [\"uuid-1\", \"uuid-2\"]\n */\n buildRelationQuery(table: string, foreignKey: string, parentIds: (string | number)[], columns: \"*\" | SelectColumn[]): BuiltQuery {\n // Handle empty parent IDs\n if (parentIds.length === 0) {\n return {\n sql: `SELECT ${columns === \"*\" ? \"*\" : this.buildColumnList(columns, foreignKey)} FROM \"${table}\" WHERE 1 = 0`,\n params: []\n };\n }\n\n // Build column list, ensuring FK is included for joining\n let columnList: string;\n if (columns === \"*\") {\n columnList = \"*\";\n } else {\n columnList = this.buildColumnList(columns, foreignKey);\n }\n const placeholders = parentIds.map(() => \"?\").join(\", \");\n const sql = `SELECT ${columnList} FROM \"${table}\" WHERE \"${foreignKey}\" IN (${placeholders})`;\n return {\n sql,\n params: [...parentIds]\n };\n }\n\n /**\n * Build column list ensuring the foreign key is included.\n */\n private buildColumnList(columns: SelectColumn[], foreignKey: string): string {\n const colNames = columns.map(c => c.name);\n\n // Always include the foreign key for joining\n const columnList = columns.map(c => {\n if (c.alias) {\n return `\"${c.name}\" AS \"${c.alias}\"`;\n }\n return `\"${c.name}\"`;\n });\n\n // Add FK if not already present\n if (!colNames.includes(foreignKey)) {\n columnList.unshift(`\"${foreignKey}\"`);\n }\n return columnList.join(\", \");\n }\n\n /**\n * Build a SELECT query for a single record by ID.\n *\n * @param table - Table name\n * @param id - Record ID\n * @param columns - Columns to select\n * @param idColumn - Name of the ID column (defaults to \"id\")\n * @returns Built query\n */\n buildByIdQuery(table: string, id: string | number, columns: \"*\" | SelectColumn[] = \"*\", idColumn: string = \"id\"): BuiltQuery {\n let columnList: string;\n if (columns === \"*\") {\n columnList = \"*\";\n } else if (columns.length === 0) {\n columnList = \"*\";\n } else {\n columnList = columns.map(c => c.alias ? `\"${c.name}\" AS \"${c.alias}\"` : `\"${c.name}\"`).join(\", \");\n }\n const sql = `SELECT ${columnList} FROM \"${table}\" WHERE \"${idColumn}\" = ? LIMIT 1`;\n return {\n sql,\n params: [id]\n };\n }\n\n /**\n * Build an INSERT query.\n *\n * @param table - Table name\n * @param data - Record data to insert\n * @returns Built query\n */\n buildInsertQuery(table: string, data: Record<string, unknown>): BuiltQuery {\n const columns = Object.keys(data).filter(k => data[k] !== undefined);\n const values = columns.map(k => data[k]);\n if (columns.length === 0) {\n throw new Error(\"Cannot insert empty record\");\n }\n const columnList = columns.map(c => `\"${c}\"`).join(\", \");\n const placeholders = columns.map(() => \"?\").join(\", \");\n const sql = `INSERT INTO \"${table}\" (${columnList}) VALUES (${placeholders})`;\n return {\n sql,\n params: values as (string | number | boolean | null)[]\n };\n }\n\n /**\n * Build an UPDATE query.\n *\n * @param table - Table name\n * @param id - Record ID\n * @param data - Fields to update\n * @param idColumn - Name of the ID column (defaults to \"id\")\n * @returns Built query\n */\n buildUpdateQuery(table: string, id: string | number, data: Record<string, unknown>, idColumn: string = \"id\"): BuiltQuery {\n const columns = Object.keys(data).filter(k => k !== idColumn && data[k] !== undefined);\n if (columns.length === 0) {\n throw new Error(\"No fields to update\");\n }\n const setClauses = columns.map(c => `\"${c}\" = ?`).join(\", \");\n const values = columns.map(k => data[k]);\n const sql = `UPDATE \"${table}\" SET ${setClauses} WHERE \"${idColumn}\" = ?`;\n return {\n sql,\n params: [...(values as (string | number | boolean | null)[]), id]\n };\n }\n\n /**\n * Build a DELETE query.\n *\n * @param table - Table name\n * @param id - Record ID\n * @param idColumn - Name of the ID column (defaults to \"id\")\n * @returns Built query\n */\n buildDeleteQuery(table: string, id: string | number, idColumn: string = \"id\"): BuiltQuery {\n const sql = `DELETE FROM \"${table}\" WHERE \"${idColumn}\" = ?`;\n return {\n sql,\n params: [id]\n };\n }\n\n /**\n * Build an UPSERT query (INSERT OR REPLACE).\n *\n * @param table - Table name\n * @param data - Record data to upsert\n * @param idColumn - Name of the ID column (defaults to \"id\")\n * @returns Built query\n */\n buildUpsertQuery(table: string, data: Record<string, unknown>, idColumn: string = \"id\"): BuiltQuery {\n const columns = Object.keys(data).filter(k => data[k] !== undefined);\n const values = columns.map(k => data[k]);\n if (columns.length === 0) {\n throw new Error(\"Cannot upsert empty record\");\n }\n const columnList = columns.map(c => `\"${c}\"`).join(\", \");\n const placeholders = columns.map(() => \"?\").join(\", \");\n\n // SQLite INSERT OR REPLACE - replaces entire row on primary key conflict\n const sql = `INSERT OR REPLACE INTO \"${table}\" (${columnList}) VALUES (${placeholders})`;\n return {\n sql,\n params: values as (string | number | boolean | null)[]\n };\n }\n\n /**\n * Build a COUNT query.\n *\n * @param table - Table name\n * @param where - Optional where clause\n * @returns Built query\n */\n buildCountQuery(table: string, where?: WhereClause): BuiltQuery {\n const params: (string | number | boolean | null)[] = [];\n let sql = `SELECT COUNT(*) as count FROM \"${table}\"`;\n if (where && Object.keys(where).length > 0) {\n const whereClauses: string[] = [];\n for (const [field, value] of Object.entries(where)) {\n if (value === null) {\n whereClauses.push(`\"${field}\" IS NULL`);\n } else if (isWhereOperator(value)) {\n const operatorClauses = this.buildOperatorClauses(field, value, params);\n whereClauses.push(...operatorClauses);\n } else {\n whereClauses.push(`\"${field}\" = ?`);\n params.push(value as string | number | boolean);\n }\n }\n if (whereClauses.length > 0) {\n sql += ` WHERE ${whereClauses.join(\" AND \")}`;\n }\n }\n return {\n sql,\n params\n };\n }\n}\n\n/**\n * Create a new SQL builder instance.\n */\nexport function createSQLBuilder(): SQLBuilder {\n return new SQLBuilder();\n}","/**\n * Query Executor\n *\n * Orchestrates the full query execution pipeline:\n * 1. Parse select string\n * 2. Build SQL queries\n * 3. Execute against PowerSync database\n * 4. Join related data\n *\n * This provides a unified interface for executing Supabase-style queries\n * against the local SQLite database via PowerSync.\n */\n\nimport type { DatabaseSchema, QueryOptions, ResolvedRelationship, SelectRelation } from \"../core/types\";\nimport { parseSelect } from \"./select-parser\";\nimport { RelationshipResolver } from \"./relationship-resolver\";\nimport { SQLBuilder } from \"./sql-builder\";\nimport { RelationJoinData, ResultJoiner } from \"./result-joiner\";\n\n/**\n * Maximum number of entries in the relation cache.\n * Uses Map's insertion order for simple LRU eviction.\n */\nconst MAX_RELATION_CACHE_SIZE = 100;\n\n/**\n * Interface for PowerSync database.\n * This matches the getAll method signature from @powersync/react-native.\n */\nexport interface PowerSyncDatabase {\n getAll<T>(sql: string, params?: unknown[]): Promise<T[]>;\n get<T>(sql: string, params?: unknown[]): Promise<T | null>;\n execute(sql: string, params?: unknown[]): Promise<{\n rowsAffected: number;\n }>;\n}\n\n/**\n * Query executor that handles the full query lifecycle.\n *\n * @example\n * const executor = new QueryExecutor(db, databaseSchema);\n *\n * // Simple query\n * const units = await executor.execute<EquipmentUnit>(\"EquipmentUnit\", {\n * where: { status: \"active\" },\n * orderBy: [{ field: \"name\", direction: \"asc\" }],\n * limit: 10\n * });\n *\n * // Query with relations\n * const unitsWithRelations = await executor.execute<EquipmentUnitWithRelations>(\n * \"EquipmentUnit\",\n * {\n * select: \"*, EquipmentFixture(*), ProjectDatabase(name, Organization(*))\",\n * where: { status: \"active\" }\n * }\n * );\n */\nexport class QueryExecutor {\n private resolver: RelationshipResolver;\n private builder: SQLBuilder;\n private joiner: ResultJoiner;\n\n /**\n * Cache for resolved relationships to avoid repeated schema lookups\n */\n private relationCache = new Map<string, ResolvedRelationship | null>();\n constructor(private db: PowerSyncDatabase, private schema: DatabaseSchema) {\n this.resolver = new RelationshipResolver(schema);\n this.builder = new SQLBuilder();\n this.joiner = new ResultJoiner();\n }\n\n /**\n * Execute a query and return results.\n *\n * @param table - The table to query\n * @param options - Query options including select, where, orderBy, limit, offset\n * @returns Array of records with relations attached\n */\n async execute<T>(table: string, options: QueryOptions = {}): Promise<T[]> {\n // Parse the select string\n const parsed = parseSelect(options.select ?? \"*\");\n\n // Build and execute base query\n const baseQuery = this.builder.build(table, parsed.columns, {\n where: options.where,\n orderBy: options.orderBy,\n limit: options.limit,\n offset: options.offset\n });\n const baseRecords = await this.db.getAll<Record<string, unknown>>(baseQuery.sql, baseQuery.params);\n\n // If no records or no relations, return early\n if (baseRecords.length === 0 || parsed.relations.length === 0) {\n return baseRecords as T[];\n }\n\n // Query and join relations\n const result = await this.queryAndJoinRelations(table, baseRecords, parsed.relations);\n return result as T[];\n }\n\n /**\n * Execute a query for a single record by ID.\n *\n * @param table - The table to query\n * @param id - The record ID\n * @param options - Query options (only select is used)\n * @returns Single record or null\n */\n async executeById<T>(table: string, id: string | number, options: Pick<QueryOptions, \"select\"> = {}): Promise<T | null> {\n const parsed = parseSelect(options.select ?? \"*\");\n const idColumn = this.resolver.getPrimaryKey(table);\n\n // Build and execute base query\n const baseQuery = this.builder.buildByIdQuery(table, id, parsed.columns, idColumn);\n const records = await this.db.getAll<Record<string, unknown>>(baseQuery.sql, baseQuery.params);\n if (records.length === 0) {\n return null;\n }\n\n // If no relations, return early\n if (parsed.relations.length === 0) {\n return records[0] as T;\n }\n\n // Query and join relations\n const result = await this.queryAndJoinRelations(table, records, parsed.relations);\n return result[0] as T;\n }\n\n /**\n * Execute a count query.\n *\n * @param table - The table to count\n * @param options - Query options (only where is used)\n * @returns Count of matching records\n */\n async count(table: string, options: Pick<QueryOptions, \"where\"> = {}): Promise<number> {\n const query = this.builder.buildCountQuery(table, options.where);\n const result = await this.db.getAll<{\n count: number;\n }>(query.sql, query.params);\n return result[0]?.count ?? 0;\n }\n\n /**\n * Insert a record.\n *\n * @param table - The table to insert into\n * @param data - The record data\n * @returns The inserted record\n */\n async insert<T>(table: string, data: Record<string, unknown>): Promise<T> {\n if (__DEV__) {\n console.log(`[QueryExecutor] insert called:`, {\n table,\n dataKeys: Object.keys(data),\n hasId: \"id\" in data\n });\n }\n const idColumn = this.resolver.getPrimaryKey(table);\n\n // Generate UUID client-side if not provided\n // PowerSync provides uuid() function in SQLite\n if (!data[idColumn]) {\n const [{\n id\n }] = await this.db.getAll<{\n id: string;\n }>(\"SELECT uuid() as id\");\n data = {\n ...data,\n [idColumn]: id\n };\n if (__DEV__) {\n console.log(`[QueryExecutor] insert generated UUID:`, {\n table,\n id\n });\n }\n }\n const query = this.builder.buildInsertQuery(table, data);\n if (__DEV__) {\n // Find the index of the id column in the params\n const columns = Object.keys(data).filter(k => data[k] !== undefined);\n const idIndex = columns.indexOf(idColumn);\n console.log(`[QueryExecutor] insert executing SQL:`, {\n table,\n sql: query.sql,\n paramCount: query.params.length,\n idColumn,\n idValue: data[idColumn],\n idParamIndex: idIndex,\n idParamValue: idIndex >= 0 ? query.params[idIndex] : \"NOT_FOUND\"\n });\n }\n await this.db.execute(query.sql, query.params);\n if (__DEV__) {\n console.log(`[QueryExecutor] insert completed:`, {\n table,\n operation: \"insert\",\n id: data[idColumn]\n });\n }\n\n // Re-fetch to get complete record with DB defaults\n const result = await this.executeById<T>(table, data[idColumn] as string);\n if (!result) {\n // Fallback to input data if re-fetch fails (shouldn't happen)\n return data as T;\n }\n return result;\n }\n\n /**\n * Update a record.\n *\n * @param table - The table to update\n * @param id - The record ID\n * @param data - The fields to update\n * @returns The updated record\n */\n async update<T>(table: string, id: string | number, data: Record<string, unknown>): Promise<T> {\n if (__DEV__) {\n console.log(`[QueryExecutor] update called:`, {\n table,\n id,\n dataKeys: Object.keys(data)\n });\n }\n const idColumn = this.resolver.getPrimaryKey(table);\n const query = this.builder.buildUpdateQuery(table, id, data, idColumn);\n if (__DEV__) {\n console.log(`[QueryExecutor] update executing SQL:`, {\n table,\n id,\n sql: query.sql,\n paramCount: query.params.length\n });\n }\n await this.db.execute(query.sql, query.params);\n if (__DEV__) {\n console.log(`[QueryExecutor] update completed:`, {\n table,\n operation: \"update\",\n id\n });\n }\n\n // Re-fetch to get complete record\n const result = await this.executeById<T>(table, id);\n if (!result) {\n // Fallback to merged data if re-fetch fails\n return {\n ...data,\n [idColumn]: id\n } as T;\n }\n return result;\n }\n\n /**\n * Upsert a record (insert or update).\n *\n * PowerSync tables are SQLite VIEWs with INSTEAD OF INSERT triggers.\n * Using INSERT OR REPLACE causes the native extension to bypass provided UUIDs\n * and generate timestamp-based IDs (e.g., \"1772167324515-7xufitksy\").\n *\n * Logic:\n * - No ID provided → generate UUID → INSERT directly\n * - ID provided → try UPDATE first, if 0 rows affected → INSERT\n *\n * @param table - The table to upsert into\n * @param data - The record data (ID optional for new records)\n * @returns The upserted record\n */\n async upsert<T>(table: string, data: Record<string, unknown>): Promise<T> {\n if (__DEV__) {\n console.log(`[QueryExecutor] upsert called:`, {\n table,\n dataKeys: Object.keys(data),\n hasId: \"id\" in data,\n idValue: data.id ?? \"none\"\n });\n }\n const idColumn = this.resolver.getPrimaryKey(table);\n let id = data[idColumn];\n\n // No ID provided → generate UUID and INSERT directly\n if (!id) {\n // NOTE: Use getAll() for consistency - db.get() throws on empty results\n const [result] = await this.db.getAll<{\n id: string;\n }>(\"SELECT uuid() as id\");\n if (!result?.id) {\n throw new Error(`Failed to generate UUID for table \"${table}\"`);\n }\n id = result.id;\n data = {\n ...data,\n [idColumn]: id\n };\n if (__DEV__) {\n console.log(`[QueryExecutor] upsert: no ID, inserting with generated UUID:`, {\n table,\n id\n });\n }\n return this.insert<T>(table, data);\n }\n\n // ID provided → check if record exists first\n // This is more reliable than checking rowsAffected for PowerSync VIEWs\n // NOTE: Use getAll() instead of get() because PowerSync SDK's get() throws on empty results\n const existsQuery = this.builder.buildByIdQuery(table, id as string | number, \"*\", idColumn);\n const existingRows = await this.db.getAll<Record<string, unknown>>(existsQuery.sql, existsQuery.params);\n const existing = existingRows.length > 0 ? existingRows[0] : null;\n if (existing) {\n // Record exists → UPDATE (creates PATCH in ps_crud)\n if (__DEV__) {\n console.log(`[QueryExecutor] upsert: record exists, performing update:`, {\n table,\n id\n });\n }\n return this.update<T>(table, id as string | number, data);\n }\n\n // Record doesn't exist → INSERT (creates PUT in ps_crud)\n // Ensure the ID is explicitly set in data\n if (!data[idColumn]) {\n data = {\n ...data,\n [idColumn]: id\n };\n }\n if (__DEV__) {\n console.log(`[QueryExecutor] upsert: record does not exist, inserting:`, {\n table,\n id\n });\n }\n return this.insert<T>(table, data);\n }\n\n /**\n * Delete a record.\n *\n * @param table - The table to delete from\n * @param id - The record ID\n */\n async delete(table: string, id: string | number): Promise<void> {\n const idColumn = this.resolver.getPrimaryKey(table);\n const query = this.builder.buildDeleteQuery(table, id, idColumn);\n await this.db.execute(query.sql, query.params);\n }\n\n /**\n * Query and join relations onto parent records.\n *\n * @param parentTable - The parent table name\n * @param parentRecords - Parent records to add relations to\n * @param relations - Relations to query and join\n * @returns Parent records with relations attached\n */\n private async queryAndJoinRelations(parentTable: string, parentRecords: Record<string, unknown>[], relations: SelectRelation[]): Promise<Record<string, unknown>[]> {\n // Pre-extract unique IDs for each column to avoid duplicate iteration\n const idCache = new Map<string, (string | number)[]>();\n const getIdsForColumn = (column: string): (string | number)[] => {\n if (!idCache.has(column)) {\n idCache.set(column, this.joiner.extractUniqueValues(parentRecords, column));\n }\n return idCache.get(column)!;\n };\n\n // Execute all sibling relation queries in parallel\n const relationResults = await Promise.all(relations.map(async relation => {\n // Check for explicit FK specification first\n const resolved = relation.explicitFk ? this.buildExplicitFkRelationship(parentTable, relation) : this.resolveRelationCached(parentTable, relation.name);\n if (!resolved) {\n console.warn(`Could not resolve relationship: ${parentTable} -> ${relation.name}`);\n return {\n relation,\n resolved: null,\n records: []\n };\n }\n const idColumn = resolved.type === \"one-to-many\" ? resolved.referencedColumn : resolved.foreignKey;\n const parentIds = getIdsForColumn(idColumn);\n if (parentIds.length === 0) {\n return {\n relation,\n resolved,\n records: []\n };\n }\n const relQuery = this.buildRelatedQuery(relation, resolved, parentIds);\n let records = await this.db.getAll<Record<string, unknown>>(relQuery.sql, relQuery.params);\n\n // Recursively handle nested relations (still parallel within each branch)\n // For explicit FK, use the target table as the parent for nested relations\n const nestedParentTable = relation.explicitFk ? this.getTableNameFromQualified(relation.explicitFk.targetTable) : relation.name;\n if (relation.relations.length > 0 && records.length > 0) {\n records = await this.queryAndJoinRelations(nestedParentTable, records, relation.relations);\n }\n return {\n relation,\n resolved,\n records\n };\n }));\n\n // Join all results onto parent records\n let result = [...parentRecords];\n for (const {\n relation,\n resolved,\n records\n } of relationResults) {\n if (!resolved) {\n result = result.map(r => ({\n ...r,\n [relation.alias ?? relation.name]: null\n }));\n continue;\n }\n if (records.length === 0) {\n result = result.map(r => ({\n ...r,\n [relation.alias ?? relation.name]: resolved.type === \"one-to-many\" ? [] : null\n }));\n continue;\n }\n result = this.joiner.join(result, records, resolved, relation.alias ?? relation.name);\n }\n return result;\n }\n\n /**\n * Build a ResolvedRelationship from an explicit FK specification.\n * This bypasses schema lookup and constructs the relationship directly.\n *\n * @param parentTable - The parent table name\n * @param relation - The relation with explicitFk specification\n * @returns ResolvedRelationship for the explicit FK\n */\n private buildExplicitFkRelationship(parentTable: string, relation: SelectRelation): ResolvedRelationship {\n const explicitFk = relation.explicitFk!;\n const targetTable = this.getTableNameFromQualified(explicitFk.targetTable);\n\n // Explicit FK relations are always many-to-one:\n // The parent table has a FK column pointing to the target table\n return {\n type: \"many-to-one\",\n fromTable: parentTable,\n toTable: targetTable,\n foreignKey: explicitFk.sourceField,\n referencedColumn: explicitFk.targetColumn ?? \"id\"\n };\n }\n\n /**\n * Extract the table name from a potentially schema-qualified identifier.\n * For PowerSync, tables are flattened to a single namespace, so we need\n * to handle both \"core.Profile\" -> \"CoreProfile\" (PowerSync alias) and\n * simple table names.\n *\n * @param qualifiedName - Table name, optionally schema-qualified (e.g., \"core.Profile\")\n * @returns The table name to use in queries\n */\n private getTableNameFromQualified(qualifiedName: string): string {\n if (!qualifiedName.includes(\".\")) {\n return qualifiedName;\n }\n\n // For schema-qualified names like \"core.Profile\", convert to PowerSync alias\n // Convention: schema.Table -> SchemaTable (PascalCase)\n const [schema, ...tableParts] = qualifiedName.split(\".\");\n const tableName = tableParts.join(\".\");\n\n // Convert to PascalCase: core.Profile -> CoreProfile\n const pascalSchema = schema.charAt(0).toUpperCase() + schema.slice(1);\n return `${pascalSchema}${tableName}`;\n }\n\n /**\n * Get parent IDs needed for a relation query.\n */\n private getParentIdsForRelation(parentRecords: Record<string, unknown>[], resolved: ResolvedRelationship): (string | number)[] {\n let parentIds: (string | number)[];\n if (resolved.type === \"one-to-many\") {\n // For one-to-many, we need the parent's referenced column (usually id)\n parentIds = this.joiner.extractUniqueValues(parentRecords, resolved.referencedColumn);\n } else {\n // For many-to-one, we need the parent's foreign key values\n parentIds = this.joiner.extractUniqueValues(parentRecords, resolved.foreignKey);\n }\n return parentIds;\n }\n\n /**\n * Build a query for related records.\n */\n private buildRelatedQuery(relation: SelectRelation, resolved: ResolvedRelationship, parentIds: (string | number)[]): {\n sql: string;\n params: (string | number | boolean | null)[];\n } {\n // Determine which column to filter on\n const filterColumn = resolved.type === \"one-to-many\" ? resolved.foreignKey // Filter by FK in the related table\n : resolved.referencedColumn; // Filter by PK in the related table\n\n // Dedupe parent IDs\n const uniqueIds = Array.from(new Set(parentIds));\n\n // For explicit FK relations, use the resolved toTable (which has been\n // converted from schema.Table to PowerSync alias format)\n const tableName = relation.explicitFk ? resolved.toTable : relation.name;\n return this.builder.buildRelationQuery(tableName, filterColumn, uniqueIds, relation.columns);\n }\n\n /**\n * Get the relationship resolver (for advanced use).\n */\n getResolver(): RelationshipResolver {\n return this.resolver;\n }\n\n /**\n * Get the SQL builder (for advanced use).\n */\n getBuilder(): SQLBuilder {\n return this.builder;\n }\n\n /**\n * Get the result joiner (for advanced use).\n */\n getJoiner(): ResultJoiner {\n return this.joiner;\n }\n\n /**\n * Resolve a relationship with caching.\n * Uses true LRU eviction: accessed items are moved to the end of the Map.\n *\n * @param fromTable - The source table\n * @param toTable - The target table/relation name\n * @returns Resolved relationship or null\n */\n private resolveRelationCached(fromTable: string, toTable: string): ResolvedRelationship | null {\n const key = `${fromTable}:${toTable}`;\n if (this.relationCache.has(key)) {\n // Move to end for LRU (delete + re-insert)\n const value = this.relationCache.get(key)!;\n this.relationCache.delete(key);\n this.relationCache.set(key, value);\n return value;\n }\n\n // Evict oldest entry if cache is at capacity\n if (this.relationCache.size >= MAX_RELATION_CACHE_SIZE) {\n const firstKey = this.relationCache.keys().next().value;\n if (firstKey) this.relationCache.delete(firstKey);\n }\n const resolved = this.resolver.resolve(fromTable, toTable);\n this.relationCache.set(key, resolved);\n return resolved;\n }\n}\n\n/**\n * Create a query executor instance.\n *\n * @param db - PowerSync database instance\n * @param schema - Database schema\n * @returns QueryExecutor instance\n */\nexport function createQueryExecutor(db: PowerSyncDatabase, schema: DatabaseSchema): QueryExecutor {\n return new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,IAAI,OAAO;AACnC,QAAI,KAAK,cAAc,IAAI,GAAG,GAAG;AAE/B,YAAM,QAAQ,KAAK,cAAc,IAAI,GAAG;AACxC,WAAK,cAAc,OAAO,GAAG;AAC7B,WAAK,cAAc,IAAI,KAAK,KAAK;AACjC,aAAO;AAAA,IACT;AAGA,QAAI,KAAK,cAAc,QAAQ,yBAAyB;AACtD,YAAM,WAAW,KAAK,cAAc,KAAK,EAAE,KAAK,EAAE;AAClD,UAAI,SAAU,MAAK,cAAc,OAAO,QAAQ;AAAA,IAClD;AACA,UAAM,WAAW,KAAK,SAAS,QAAQ,WAAW,OAAO;AACzD,SAAK,cAAc,IAAI,KAAK,QAAQ;AACpC,WAAO;AAAA,EACT;AACF;AASO,SAAS,oBAAoB,IAAuB,QAAuC;AAChG,SAAO,IAAI,cAAc,IAAI,MAAM;AACrC;","names":[]}
@@ -535,6 +535,23 @@ interface SelectColumn {
535
535
  /** Optional alias for the column */
536
536
  alias?: string;
537
537
  }
538
+ /**
539
+ * Explicit FK specification for cross-schema relations without database FK constraints.
540
+ * Allows specifying the join relationship directly in the select string.
541
+ *
542
+ * @example
543
+ * // Syntax: Alias!sourceField:targetTable(columns)
544
+ * "Sender!senderId:core.Profile(*)"
545
+ * // explicitFk: { sourceField: "senderId", targetTable: "core.Profile", targetColumn: "id" }
546
+ */
547
+ interface ExplicitFkSpec {
548
+ /** FK column on the parent table (e.g., "senderId") */
549
+ sourceField: string;
550
+ /** Table to query, optionally schema-qualified (e.g., "core.Profile") */
551
+ targetTable: string;
552
+ /** Column to match in target table, defaults to "id" */
553
+ targetColumn?: string;
554
+ }
538
555
  /**
539
556
  * A relation in a parsed select statement (e.g., RelatedTable(*))
540
557
  */
@@ -547,6 +564,12 @@ interface SelectRelation {
547
564
  columns: "*" | SelectColumn[];
548
565
  /** Nested relations within this relation */
549
566
  relations: SelectRelation[];
567
+ /**
568
+ * Explicit FK specification for cross-schema relations.
569
+ * When present, the relationship is built directly from this spec
570
+ * instead of looking it up in the database schema.
571
+ */
572
+ explicitFk?: ExplicitFkSpec;
550
573
  }
551
574
  /**
552
575
  * Complete parsed select statement AST
@@ -588,4 +611,4 @@ interface BuiltQuery {
588
611
  params: (string | number | boolean | null)[];
589
612
  }
590
613
 
591
- export type { AdapterRegistry, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerConfig, DataLayerHooks, DatabaseSchema, DeleteMutationResult, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryOptions, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncControl, SyncSchedule, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators };
614
+ export type { AdapterRegistry, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerConfig, DataLayerHooks, DatabaseSchema, DeleteMutationResult, ExplicitFkSpec, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryOptions, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncControl, SyncSchedule, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators };
@@ -495,6 +495,25 @@ declare class QueryExecutor {
495
495
  * @returns Parent records with relations attached
496
496
  */
497
497
  private queryAndJoinRelations;
498
+ /**
499
+ * Build a ResolvedRelationship from an explicit FK specification.
500
+ * This bypasses schema lookup and constructs the relationship directly.
501
+ *
502
+ * @param parentTable - The parent table name
503
+ * @param relation - The relation with explicitFk specification
504
+ * @returns ResolvedRelationship for the explicit FK
505
+ */
506
+ private buildExplicitFkRelationship;
507
+ /**
508
+ * Extract the table name from a potentially schema-qualified identifier.
509
+ * For PowerSync, tables are flattened to a single namespace, so we need
510
+ * to handle both "core.Profile" -> "CoreProfile" (PowerSync alias) and
511
+ * simple table names.
512
+ *
513
+ * @param qualifiedName - Table name, optionally schema-qualified (e.g., "core.Profile")
514
+ * @returns The table name to use in queries
515
+ */
516
+ private getTableNameFromQualified;
498
517
  /**
499
518
  * Get parent IDs needed for a relation query.
500
519
  */
@@ -517,6 +536,7 @@ declare class QueryExecutor {
517
536
  getJoiner(): ResultJoiner;
518
537
  /**
519
538
  * Resolve a relationship with caching.
539
+ * Uses true LRU eviction: accessed items are moved to the end of the Map.
520
540
  *
521
541
  * @param fromTable - The source table
522
542
  * @param toTable - The target table/relation name
@@ -1,10 +1,10 @@
1
- export { C as ClarificationQuestion, D as DatabaseTypes, F as Filter, x as FilterGroup, y as FilterOperator, z as Pagination, P as PublicTableNames, Q as QueryState, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, A as Sort, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, K as UseDbDeleteOptions, L as UseDbDeleteResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, B as UseDbInsertOptions, E as UseDbInsertResult, v as UseDbQueryByIdOptions, w as UseDbQueryByIdResult, s as UseDbQueryOptions, t as UseDbQueryResult, G as UseDbUpdateOptions, H as UseDbUpdateResult, I as UseDbUpsertOptions, J as UseDbUpsertResult, u as useAdvanceQuery, a as useDataLayer, b as useDataLayerCore, M as useDataLayerCoreOptional, c as useDataLayerOptional, d as useDataLayerStatus, e as useDbCount, f as useDbDelete, g as useDbInfiniteQuery, h as useDbInsert, i as useDbQuery, j as useDbQueryById, k as useDbUpdate, l as useDbUpsert } from '../useDbCount-DHLJzmkO.js';
1
+ export { C as ClarificationQuestion, D as DatabaseTypes, F as Filter, x as FilterGroup, y as FilterOperator, z as Pagination, P as PublicTableNames, Q as QueryState, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, A as Sort, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, K as UseDbDeleteOptions, L as UseDbDeleteResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, B as UseDbInsertOptions, E as UseDbInsertResult, v as UseDbQueryByIdOptions, w as UseDbQueryByIdResult, s as UseDbQueryOptions, t as UseDbQueryResult, G as UseDbUpdateOptions, H as UseDbUpdateResult, I as UseDbUpsertOptions, J as UseDbUpsertResult, u as useAdvanceQuery, a as useDataLayer, b as useDataLayerCore, M as useDataLayerCoreOptional, c as useDataLayerOptional, d as useDataLayerStatus, e as useDbCount, f as useDbDelete, g as useDbInfiniteQuery, h as useDbInsert, i as useDbQuery, j as useDbQueryById, k as useDbUpdate, l as useDbUpsert } from '../useDbCount-Ckb-FhZk.js';
2
2
  import { SyncStatus, SyncControl } from '../core/index.js';
3
- import '../DataLayerContext-C7cJtiO8.js';
3
+ import '../DataLayerContext-BYZtDD0g.js';
4
4
  import 'react';
5
5
  import '@supabase/supabase-js';
6
6
  import '@tanstack/react-query';
7
- import '../executor-YJw4m7Q7.js';
7
+ import '../executor-D15yjeMo.js';
8
8
 
9
9
  /**
10
10
  * V3 useSyncStatus Hook
@@ -9,7 +9,7 @@ import {
9
9
  useOnlineStatus,
10
10
  useSyncControl,
11
11
  useSyncStatus
12
- } from "../chunk-AKCNWHXV.js";
12
+ } from "../chunk-VYFAMTHI.js";
13
13
  import {
14
14
  useDataLayer,
15
15
  useDataLayerCore,
@@ -18,8 +18,10 @@ import {
18
18
  useDataLayerStatus,
19
19
  useDbQuery,
20
20
  useDbQueryById
21
- } from "../chunk-WSKBZIEI.js";
21
+ } from "../chunk-GWYTROSD.js";
22
22
  import "../chunk-GC3TBUWE.js";
23
+ import "../chunk-W7PERM66.js";
24
+ import "../chunk-QYAFI34Q.js";
23
25
  import "../chunk-J4ZVCXZ4.js";
24
26
  import "../chunk-DMVUEJG2.js";
25
27
  import "../chunk-7D4SUZUM.js";
@@ -5,7 +5,7 @@ import { PostgrestSingleResponse, SupabaseClient } from '@supabase/supabase-js';
5
5
  import { Dispatch, SetStateAction } from 'react';
6
6
  import { UseQueryOptions, DefinedUseQueryResult, QueryClient } from '@tanstack/react-query';
7
7
  import { SyncControl, SyncStatus, DataLayerConfig } from './core/index.js';
8
- import { u as DataLayerStatus, r as DataLayerContextValue } from './DataLayerContext-C7cJtiO8.js';
8
+ import { u as DataLayerStatus, r as DataLayerContextValue } from './DataLayerContext-BYZtDD0g.js';
9
9
 
10
10
  /**
11
11
  * Represents a change log entry for database records.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { C as CompositeTypes, c as Constants, D as Database, E as Enums, J as Json, T as Tables, a as TablesInsert, b as TablesUpdate } from './database.types-ChFCG-4M.js';
2
2
  export { a as FilterConfig, F as FilterConfigOption, G as Group, P as PropertyType, S as SortConfig, T as TableInfo, V as ValueForPropertyType, W as WhereFilter } from './FilterConfig-Bt2Ek74z.js';
3
- export { r as BackendSelectionResult, B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, E as EnhancedSyncControl, a as EnhancedSyncStatus, e as Filter, d as FilterConditionType, m as FilterContextType, f as FilterGroup, g as FilterInput, F as FilterOperator, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, i as Pagination, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, Q as QueryState, S as Sort, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus } from './index-jVYdTeWx.js';
4
- export { y as AIOptions, z as AIResponse, P as AlertProps, A as AttachmentQueueProvider, I as BUCKETS, J as BucketName, H as CustomPageQueryResult, L as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, C as ServerAvailabilityState, k as StorageQueueContext, m as StorageQueueContextValue, S as StorageQueueProvider, j as StorageQueueProviderProps, ac as SubmitFeedbackParams, v as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, F as UpdateOptions, U as UseAutosaveOptions, d as UseAutosaveResult, N as UseDbRealtimeQueryResult, q as UseMutationSuccessOptions, h as UseStorageSourceOptions, i as UseStorageSourceResult, O as convertFilterToRealtimeQuery, K as createInCondition, w as createSupabaseAdapter, G as executeAdvanceQuery, x as getErrorBody, g as getStorageUrl, p as getSupabaseUrl, M as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, B as useAI, ad as useApplyFeedback, c as useAutosave, b as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, o as useDbRealtimeQuery, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useLatestOperationLog, u as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, r as useMutationSuccess, t as useMutationSuccessRN, a3 as usePublishedChangelogs, o as useRealtimeQuery, ae as useResolveFeedback, E as useSearchQuery, D as useServerAvailability, l as useStorageQueueContext, f as useStorageSource, ab as useSubmitFeedback, e as useToastError, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-B0UcYWVI.js';
3
+ export { r as BackendSelectionResult, B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, E as EnhancedSyncControl, a as EnhancedSyncStatus, e as Filter, d as FilterConditionType, m as FilterContextType, f as FilterGroup, g as FilterInput, F as FilterOperator, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, i as Pagination, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, Q as QueryState, S as Sort, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus } from './index-CFUuTzXO.js';
4
+ export { y as AIOptions, z as AIResponse, P as AlertProps, A as AttachmentQueueProvider, I as BUCKETS, J as BucketName, H as CustomPageQueryResult, L as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, C as ServerAvailabilityState, k as StorageQueueContext, m as StorageQueueContextValue, S as StorageQueueProvider, j as StorageQueueProviderProps, ac as SubmitFeedbackParams, v as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, F as UpdateOptions, U as UseAutosaveOptions, d as UseAutosaveResult, N as UseDbRealtimeQueryResult, q as UseMutationSuccessOptions, h as UseStorageSourceOptions, i as UseStorageSourceResult, O as convertFilterToRealtimeQuery, K as createInCondition, w as createSupabaseAdapter, G as executeAdvanceQuery, x as getErrorBody, g as getStorageUrl, p as getSupabaseUrl, M as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, B as useAI, ad as useApplyFeedback, c as useAutosave, b as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, o as useDbRealtimeQuery, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useLatestOperationLog, u as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, r as useMutationSuccess, t as useMutationSuccessRN, a3 as usePublishedChangelogs, o as useRealtimeQuery, ae as useResolveFeedback, E as useSearchQuery, D as useServerAvailability, l as useStorageQueueContext, f as useStorageSource, ab as useSubmitFeedback, e as useToastError, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-CuUkdHoR.js';
5
5
  export { u as useBatchDelete, a as useBatchUpsert } from './useBatchUpsert-DAkiCNo3.js';
6
6
  export { AdapterRegistry as AdapterRegistryInterface, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerConfig, DataLayerHooks, DatabaseSchema, DeleteMutationResult, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryOptions, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncControl, SyncSchedule, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators } from './core/index.js';
7
- export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, c as AdapterCapabilities, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, A as AdapterQueryResult, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, C as CapableDataAdapter, D as DataLayerContext, r as DataLayerContextValue, p as DataLayerCoreContext, s as DataLayerCoreContextValue, u as DataLayerStatus, q as DataLayerStatusContext, t as DataLayerStatusContextValue, S as SyncStatusInfo, o as SyncTracker, n as SyncTrackingAdapter, T as TableDataAdapter, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-C7cJtiO8.js';
7
+ export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, c as AdapterCapabilities, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, A as AdapterQueryResult, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, C as CapableDataAdapter, D as DataLayerContext, r as DataLayerContextValue, p as DataLayerCoreContext, s as DataLayerCoreContextValue, u as DataLayerStatus, q as DataLayerStatusContext, t as DataLayerStatusContextValue, S as SyncStatusInfo, o as SyncTracker, n as SyncTrackingAdapter, T as TableDataAdapter, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-BYZtDD0g.js';
8
8
  export { ConflictCheckResult, ConflictContext, ConflictContextValue, ConflictProvider, ConflictProviderProps, ConflictResolution, DataLayerProvider, DataLayerProviderProps, FieldConflict, PowerSyncAdapter, UseConflictResolutionReturn, UseSupabaseUploadOptions, UseSupabaseUploadReturn, createPowerSyncAdapter, useBulkConflictResolution, useConflictCountByTable, useConflictForRecord, useConflictResolution, useConflictState, useConflictsForTable, useHasConflicts, usePendingConflicts, useSupabaseUpload } from './index.native.js';
9
- export { D as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, s as UseDbQueryOptions, t as UseDbQueryResult, u as useAdvanceQuery, a as useDataLayer, b as useDataLayerCore, c as useDataLayerOptional, d as useDataLayerStatus, e as useDbCount, e as useDbCountV3, f as useDbDelete, g as useDbInfiniteQuery, g as useDbInfiniteQueryV3, h as useDbInsert, i as useDbQuery, j as useDbQueryById, k as useDbUpdate, l as useDbUpsert } from './useDbCount-DHLJzmkO.js';
9
+ export { D as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, s as UseDbQueryOptions, t as UseDbQueryResult, u as useAdvanceQuery, a as useDataLayer, b as useDataLayerCore, c as useDataLayerOptional, d as useDataLayerStatus, e as useDbCount, e as useDbCountV3, f as useDbDelete, g as useDbInfiniteQuery, g as useDbInfiniteQueryV3, h as useDbInsert, i as useDbQuery, j as useDbQueryById, k as useDbUpdate, l as useDbUpsert } from './useDbCount-Ckb-FhZk.js';
10
10
  export { useOnlineStatus, useSyncControl, useSyncStatus } from './hooks/index.js';
11
11
  export { C as ClientInstanceId, S as SupabaseDatabaseTypes, a as SupabaseProvider, T as TypedSupabaseClient, U as UserSessionId, c as createNewSupabaseClient, u as default, o as onSupabaseInitialized, s as setDefaultOptions, t as typedSupabase, u as useSupabase } from './useSupabase-DSZNeXnF.js';
12
12
  export { B as BatchAnalysisProgress, E as ExtractedReceipt, P as PendingExpense, a as useReceiptAI, u as useSupabaseFunction } from './useReceiptAI-6HkRpRml.js';
@@ -27,7 +27,7 @@ import '@pol-studios/utils';
27
27
  import '@supabase-cache-helpers/postgrest-react-query';
28
28
  import 'react/jsx-runtime';
29
29
  import '@supabase/storage-js';
30
- import './executor-YJw4m7Q7.js';
30
+ import './executor-D15yjeMo.js';
31
31
  import 'react-dropzone';
32
32
  import '@supabase/supabase-js/dist/module/lib/types.js';
33
33
 
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  useHasConflicts,
25
25
  usePendingConflicts,
26
26
  useSupabaseUpload
27
- } from "./chunk-AA3VUWTP.js";
27
+ } from "./chunk-VSJKGPRI.js";
28
28
  import {
29
29
  ADAPTER_STRATEGIES,
30
30
  AdapterAutoDetector,
@@ -77,7 +77,7 @@ import {
77
77
  useUpsertChangelog,
78
78
  useUpsertChangelogEntry,
79
79
  useUpsertChangelogMedia
80
- } from "./chunk-OC6S4XFL.js";
80
+ } from "./chunk-DDL63KLQ.js";
81
81
  import {
82
82
  LiveChangeContext,
83
83
  LiveChangeContextProvider,
@@ -88,7 +88,7 @@ import {
88
88
  useUserMetadataState,
89
89
  useUserMetadataValue,
90
90
  userMetadataContext
91
- } from "./chunk-7YGDT46S.js";
91
+ } from "./chunk-4EO55YV2.js";
92
92
  import {
93
93
  PostgrestFilter,
94
94
  binarySearch,
@@ -128,7 +128,7 @@ import {
128
128
  useOnlineStatus,
129
129
  useSyncControl,
130
130
  useSyncStatus
131
- } from "./chunk-AKCNWHXV.js";
131
+ } from "./chunk-VYFAMTHI.js";
132
132
  import {
133
133
  Constants,
134
134
  createCombinedStatus
@@ -321,12 +321,12 @@ import {
321
321
  UserMetadata
322
322
  } from "./chunk-SM73S2DY.js";
323
323
  import "./chunk-NSIAAYW3.js";
324
- import "./chunk-BRFFTGVJ.js";
324
+ import "./chunk-MEBT5YHA.js";
325
325
  import {
326
326
  DEFAULT_QUERY_TIMEOUT,
327
327
  TIMEOUT_ERROR_MESSAGE,
328
328
  isTimeoutError
329
- } from "./chunk-WILXD5X3.js";
329
+ } from "./chunk-6SDH7M7J.js";
330
330
  import {
331
331
  DataLayerContext,
332
332
  DataLayerCoreContext,
@@ -337,17 +337,19 @@ import {
337
337
  useDataLayerStatus,
338
338
  useDbQuery,
339
339
  useDbQueryById
340
- } from "./chunk-WSKBZIEI.js";
340
+ } from "./chunk-GWYTROSD.js";
341
341
  import "./chunk-RT4O5H2E.js";
342
- import "./chunk-HZIVE5AZ.js";
342
+ import "./chunk-YRIPM2AN.js";
343
343
  import {
344
344
  getSupabaseUrl,
345
345
  setSupabaseUrl
346
346
  } from "./chunk-GC3TBUWE.js";
347
+ import "./chunk-W7PERM66.js";
347
348
  import {
348
349
  useBatchDelete,
349
350
  useBatchUpsert
350
351
  } from "./chunk-WM25QE7E.js";
352
+ import "./chunk-QYAFI34Q.js";
351
353
  import {
352
354
  OPERATOR_MAP,
353
355
  PostgrestParser,
@@ -1,15 +1,15 @@
1
1
  export { C as CompositeTypes, c as Constants, D as Database, E as Enums, J as Json, T as Tables, a as TablesInsert, b as TablesUpdate } from './database.types-ChFCG-4M.js';
2
2
  export { a as FilterConfig, F as FilterConfigOption, G as Group, P as PropertyType, S as SortConfig, T as TableInfo, V as ValueForPropertyType, W as WhereFilter } from './FilterConfig-Bt2Ek74z.js';
3
- export { r as BackendSelectionResult, B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, E as EnhancedSyncControl, a as EnhancedSyncStatus, e as Filter, d as FilterConditionType, m as FilterContextType, f as FilterGroup, g as FilterInput, F as FilterOperator, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, i as Pagination, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, Q as QueryState, S as Sort, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus, u as useDbAdvanceFilterQuery } from './index-jVYdTeWx.js';
4
- export { y as AIOptions, z as AIResponse, P as AlertProps, A as AttachmentQueueProvider, I as BUCKETS, J as BucketName, H as CustomPageQueryResult, L as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, C as ServerAvailabilityState, k as StorageQueueContext, m as StorageQueueContextValue, S as StorageQueueProvider, j as StorageQueueProviderProps, ac as SubmitFeedbackParams, v as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, F as UpdateOptions, U as UseAutosaveOptions, d as UseAutosaveResult, N as UseDbRealtimeQueryResult, q as UseMutationSuccessOptions, h as UseStorageSourceOptions, i as UseStorageSourceResult, O as convertFilterToRealtimeQuery, K as createInCondition, w as createSupabaseAdapter, G as executeAdvanceQuery, x as getErrorBody, g as getStorageUrl, p as getSupabaseUrl, M as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, B as useAI, ad as useApplyFeedback, c as useAutosave, b as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, o as useDbRealtimeQuery, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useLatestOperationLog, u as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, r as useMutationSuccess, t as useMutationSuccessRN, a3 as usePublishedChangelogs, o as useRealtimeQuery, ae as useResolveFeedback, E as useSearchQuery, D as useServerAvailability, l as useStorageQueueContext, f as useStorageSource, ab as useSubmitFeedback, e as useToastError, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-B0UcYWVI.js';
5
- export { D as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, s as UseDbQueryOptions, t as UseDbQueryResult, u as useAdvanceQuery, a as useDataLayer, b as useDataLayerCore, c as useDataLayerOptional, d as useDataLayerStatus, e as useDbCount, e as useDbCountV3, f as useDbDelete, f as useDbDeleteV3, g as useDbInfiniteQuery, g as useDbInfiniteQueryV3, h as useDbInsert, h as useDbInsertV3, i as useDbQuery, j as useDbQueryById, i as useDbQueryV3, k as useDbUpdate, k as useDbUpdateV3, l as useDbUpsert, l as useDbUpsertV3, l as useUpsert } from './useDbCount-DHLJzmkO.js';
3
+ export { r as BackendSelectionResult, B as BooleanOperator, l as ClarificationQuestion, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, E as EnhancedSyncControl, a as EnhancedSyncStatus, e as Filter, d as FilterConditionType, m as FilterContextType, f as FilterGroup, g as FilterInput, F as FilterOperator, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, i as Pagination, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, Q as QueryState, S as Sort, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus, u as useDbAdvanceFilterQuery } from './index-CFUuTzXO.js';
4
+ export { y as AIOptions, z as AIResponse, P as AlertProps, A as AttachmentQueueProvider, I as BUCKETS, J as BucketName, H as CustomPageQueryResult, L as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, C as ServerAvailabilityState, k as StorageQueueContext, m as StorageQueueContextValue, S as StorageQueueProvider, j as StorageQueueProviderProps, ac as SubmitFeedbackParams, v as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, F as UpdateOptions, U as UseAutosaveOptions, d as UseAutosaveResult, N as UseDbRealtimeQueryResult, q as UseMutationSuccessOptions, h as UseStorageSourceOptions, i as UseStorageSourceResult, O as convertFilterToRealtimeQuery, K as createInCondition, w as createSupabaseAdapter, G as executeAdvanceQuery, x as getErrorBody, g as getStorageUrl, p as getSupabaseUrl, M as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, B as useAI, ad as useApplyFeedback, c as useAutosave, b as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, o as useDbRealtimeQuery, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useLatestOperationLog, u as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, r as useMutationSuccess, t as useMutationSuccessRN, a3 as usePublishedChangelogs, o as useRealtimeQuery, ae as useResolveFeedback, E as useSearchQuery, D as useServerAvailability, l as useStorageQueueContext, f as useStorageSource, ab as useSubmitFeedback, e as useToastError, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-CuUkdHoR.js';
5
+ export { D as DatabaseTypes, P as PublicTableNames, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, s as UseDbQueryOptions, t as UseDbQueryResult, u as useAdvanceQuery, a as useDataLayer, b as useDataLayerCore, c as useDataLayerOptional, d as useDataLayerStatus, e as useDbCount, e as useDbCountV3, f as useDbDelete, f as useDbDeleteV3, g as useDbInfiniteQuery, g as useDbInfiniteQueryV3, h as useDbInsert, h as useDbInsertV3, i as useDbQuery, j as useDbQueryById, i as useDbQueryV3, k as useDbUpdate, k as useDbUpdateV3, l as useDbUpsert, l as useDbUpsertV3, l as useUpsert } from './useDbCount-Ckb-FhZk.js';
6
6
  export { useOnlineStatus, useSyncControl, useSyncStatus } from './hooks/index.js';
7
7
  export { u as useBatchDelete, a as useBatchUpsert } from './useBatchUpsert-DAkiCNo3.js';
8
8
  import { DatabaseSchema, QueryOptions, DataLayerConfig, SyncControl } from './core/index.js';
9
9
  export { AdapterRegistry as AdapterRegistryInterface, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerHooks, DeleteMutationResult, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncSchedule, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators } from './core/index.js';
10
- import { T as TableDataAdapter, C as CapableDataAdapter, c as AdapterCapabilities, A as AdapterQueryResult, r as DataLayerContextValue, S as SyncStatusInfo } from './DataLayerContext-C7cJtiO8.js';
11
- export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, D as DataLayerContext, p as DataLayerCoreContext, s as DataLayerCoreContextValue, u as DataLayerStatus, q as DataLayerStatusContext, t as DataLayerStatusContextValue, o as SyncTracker, n as SyncTrackingAdapter, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-C7cJtiO8.js';
12
- import { Q as QueryExecutor, P as PowerSyncDatabase$1 } from './executor-YJw4m7Q7.js';
10
+ import { T as TableDataAdapter, C as CapableDataAdapter, c as AdapterCapabilities, A as AdapterQueryResult, r as DataLayerContextValue, S as SyncStatusInfo } from './DataLayerContext-BYZtDD0g.js';
11
+ export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, D as DataLayerContext, p as DataLayerCoreContext, s as DataLayerCoreContextValue, u as DataLayerStatus, q as DataLayerStatusContext, t as DataLayerStatusContextValue, o as SyncTracker, n as SyncTrackingAdapter, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-BYZtDD0g.js';
12
+ import { Q as QueryExecutor, P as PowerSyncDatabase$1 } from './executor-D15yjeMo.js';
13
13
  import * as react from 'react';
14
14
  import react__default, { ReactNode, JSX } from 'react';
15
15
  import { SupabaseClient } from '@supabase/supabase-js';
@@ -13,7 +13,7 @@ import {
13
13
  useHasConflicts,
14
14
  usePendingConflicts,
15
15
  useSupabaseUpload
16
- } from "./chunk-AA3VUWTP.js";
16
+ } from "./chunk-VSJKGPRI.js";
17
17
  import {
18
18
  ADAPTER_STRATEGIES,
19
19
  AdapterAutoDetector,
@@ -65,7 +65,7 @@ import {
65
65
  useUpsertChangelog,
66
66
  useUpsertChangelogEntry,
67
67
  useUpsertChangelogMedia
68
- } from "./chunk-OC6S4XFL.js";
68
+ } from "./chunk-DDL63KLQ.js";
69
69
  import {
70
70
  LiveChangeContext,
71
71
  LiveChangeContextProvider,
@@ -76,7 +76,7 @@ import {
76
76
  useUserMetadataState,
77
77
  useUserMetadataValue,
78
78
  userMetadataContext
79
- } from "./chunk-7YGDT46S.js";
79
+ } from "./chunk-4EO55YV2.js";
80
80
  import {
81
81
  PostgrestFilter,
82
82
  binarySearch,
@@ -116,7 +116,7 @@ import {
116
116
  useOnlineStatus,
117
117
  useSyncControl,
118
118
  useSyncStatus
119
- } from "./chunk-AKCNWHXV.js";
119
+ } from "./chunk-VYFAMTHI.js";
120
120
  import {
121
121
  Constants,
122
122
  createCombinedStatus,
@@ -310,12 +310,12 @@ import {
310
310
  UserMetadata
311
311
  } from "./chunk-SM73S2DY.js";
312
312
  import "./chunk-NSIAAYW3.js";
313
- import "./chunk-BRFFTGVJ.js";
313
+ import "./chunk-MEBT5YHA.js";
314
314
  import {
315
315
  DEFAULT_QUERY_TIMEOUT,
316
316
  TIMEOUT_ERROR_MESSAGE,
317
317
  isTimeoutError
318
- } from "./chunk-WILXD5X3.js";
318
+ } from "./chunk-6SDH7M7J.js";
319
319
  import {
320
320
  DataLayerContext,
321
321
  DataLayerCoreContext,
@@ -326,17 +326,19 @@ import {
326
326
  useDataLayerStatus,
327
327
  useDbQuery,
328
328
  useDbQueryById
329
- } from "./chunk-WSKBZIEI.js";
329
+ } from "./chunk-GWYTROSD.js";
330
330
  import "./chunk-RT4O5H2E.js";
331
- import "./chunk-HZIVE5AZ.js";
331
+ import "./chunk-YRIPM2AN.js";
332
332
  import {
333
333
  getSupabaseUrl,
334
334
  setSupabaseUrl
335
335
  } from "./chunk-GC3TBUWE.js";
336
+ import "./chunk-W7PERM66.js";
336
337
  import {
337
338
  useBatchDelete,
338
339
  useBatchUpsert
339
340
  } from "./chunk-WM25QE7E.js";
341
+ import "./chunk-QYAFI34Q.js";
340
342
  import {
341
343
  OPERATOR_MAP,
342
344
  PostgrestParser,
@@ -1,8 +1,8 @@
1
1
  export { C as CompositeTypes, c as Constants, D as Database, E as Enums, J as Json, T as Tables, a as TablesInsert, b as TablesUpdate } from './database.types-ChFCG-4M.js';
2
2
  export { a as FilterConfig, F as FilterConfigOption, G as Group, P as PropertyType, S as SortConfig, T as TableInfo, V as ValueForPropertyType, W as WhereFilter } from './FilterConfig-Bt2Ek74z.js';
3
- import { u as useDbAdvanceFilterQuery, Q as QueryState } from './index-jVYdTeWx.js';
4
- export { r as BackendSelectionResult, B as BooleanOperator, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, E as EnhancedSyncControl, a as EnhancedSyncStatus, d as FilterConditionType, m as FilterContextType, g as FilterInput, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus, s as normalizeFilter } from './index-jVYdTeWx.js';
5
- export { y as AIOptions, z as AIResponse, P as AlertProps, A as AttachmentQueueProvider, I as BUCKETS, J as BucketName, H as CustomPageQueryResult, L as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, C as ServerAvailabilityState, k as StorageQueueContext, m as StorageQueueContextValue, S as StorageQueueProvider, j as StorageQueueProviderProps, ac as SubmitFeedbackParams, v as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, F as UpdateOptions, U as UseAutosaveOptions, d as UseAutosaveResult, af as UseDbPartialQueryResult, N as UseDbRealtimeQueryResult, q as UseMutationSuccessOptions, h as UseStorageSourceOptions, i as UseStorageSourceResult, O as convertFilterToRealtimeQuery, K as createInCondition, w as createSupabaseAdapter, G as executeAdvanceQuery, x as getErrorBody, g as getStorageUrl, p as getSupabaseUrl, M as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, B as useAI, ad as useApplyFeedback, c as useAutosave, b as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, ag as useDbPartialQuery, o as useDbRealtimeQuery, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useLatestOperationLog, u as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, r as useMutationSuccess, t as useMutationSuccessRN, a3 as usePublishedChangelogs, o as useRealtimeQuery, ae as useResolveFeedback, E as useSearchQuery, D as useServerAvailability, l as useStorageQueueContext, f as useStorageSource, ab as useSubmitFeedback, e as useToastError, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-B0UcYWVI.js';
3
+ import { u as useDbAdvanceFilterQuery, Q as QueryState } from './index-CFUuTzXO.js';
4
+ export { r as BackendSelectionResult, B as BooleanOperator, k as ClarificationSuggestion, C as CombinedProviderStatus, j as ComputedSortConfig, n as DataLayerWithPowerSyncProps, D as DbChangeLog, E as EnhancedSyncControl, a as EnhancedSyncStatus, d as FilterConditionType, m as FilterContextType, g as FilterInput, h as FilterState, H as HasPowerSyncConfig, O as OrderColumn, P as PowerSyncEnabledConfig, b as PowerSyncEnabledContextValue, q as PowerSyncTables, U as UseDataLayerWithPowerSync, p as UseSyncControlWithPowerSync, o as UseSyncStatusWithPowerSync, V as ValueOrArrayForPropertyType, c as createCombinedStatus, s as normalizeFilter } from './index-CFUuTzXO.js';
5
+ export { y as AIOptions, z as AIResponse, P as AlertProps, A as AttachmentQueueProvider, I as BUCKETS, J as BucketName, H as CustomPageQueryResult, L as DEFAULT_QUERY_TIMEOUT, a9 as FeedbackListItem, aa as FeedbackListParams, Q as LiveChangeContext, R as LiveChangeContextProvider, C as ServerAvailabilityState, k as StorageQueueContext, m as StorageQueueContextValue, S as StorageQueueProvider, j as StorageQueueProviderProps, ac as SubmitFeedbackParams, v as SupabaseAdapter, T as TIMEOUT_ERROR_MESSAGE, F as UpdateOptions, U as UseAutosaveOptions, d as UseAutosaveResult, af as UseDbPartialQueryResult, N as UseDbRealtimeQueryResult, q as UseMutationSuccessOptions, h as UseStorageSourceOptions, i as UseStorageSourceResult, O as convertFilterToRealtimeQuery, K as createInCondition, w as createSupabaseAdapter, G as executeAdvanceQuery, x as getErrorBody, g as getStorageUrl, p as getSupabaseUrl, M as isTimeoutError, n as newTimeActivity, s as setSupabaseUrl, B as useAI, ad as useApplyFeedback, c as useAutosave, b as useAutosaveState, a4 as useChangelogById, a5 as useChangelogBySlug, a6 as useChangelogEntries, a7 as useChangelogMedia, a2 as useChangelogs, ag as useDbPartialQuery, o as useDbRealtimeQuery, W as useDeleteChangelog, Z as useDeleteChangelogEntry, a0 as useDeleteChangelogMedia, a8 as useFeedbackList, a as useLatestOperationLog, u as useLiveChangeTracking, _ as useMultiDeleteChangelogEntries, Y as useMultiUpsertChangelogEntries, r as useMutationSuccess, t as useMutationSuccessRN, a3 as usePublishedChangelogs, o as useRealtimeQuery, ae as useResolveFeedback, E as useSearchQuery, D as useServerAvailability, l as useStorageQueueContext, f as useStorageSource, ab as useSubmitFeedback, e as useToastError, a1 as useUploadChangelogMedia, V as useUpsertChangelog, X as useUpsertChangelogEntry, $ as useUpsertChangelogMedia } from './useResolveFeedback-CuUkdHoR.js';
6
6
  import * as _tanstack_react_query from '@tanstack/react-query';
7
7
  import { UseInfiniteQueryOptions, InfiniteData, UseQueryOptions, QueryClient } from '@tanstack/react-query';
8
8
  import { D as Database } from './useSupabase-DSZNeXnF.js';
@@ -14,14 +14,15 @@ export { F as Fetch, i as GenericFunction, g as GenericNonUpdatableView, f as Ge
14
14
  import { PostgrestSingleResponse, RealtimePostgresChangesPayload, SupabaseClient } from '@supabase/supabase-js';
15
15
  import { useInsertMutation, useUpdateMutation } from '@supabase-cache-helpers/postgrest-react-query';
16
16
  export { U as UseDbQuerySingleReturn, u as useDbQuery } from './useDbQuery-C-TL8jY1.js';
17
- export { C as ClarificationQuestion, D as DatabaseTypes, F as Filter, x as FilterGroup, y as FilterOperator, z as Pagination, P as PublicTableNames, Q as QueryState, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, A as Sort, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, K as UseDbDeleteOptions, L as UseDbDeleteResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, B as UseDbInsertOptions, E as UseDbInsertResult, v as UseDbQueryByIdOptions, w as UseDbQueryByIdResult, s as UseDbQueryOptions, t as UseDbQueryResult, G as UseDbUpdateOptions, H as UseDbUpdateResult, I as UseDbUpsertOptions, J as UseDbUpsertResult, u as useAdvanceQuery, a as useDataLayer, c as useDataLayerOptional, e as useDbCount, e as useDbCountV3, f as useDbDeleteV3, g as useDbInfiniteQueryV3, h as useDbInsertV3, j as useDbQueryById, i as useDbQueryV3, k as useDbUpdateV3, l as useDbUpsert, l as useDbUpsertV3, l as useUpsert } from './useDbCount-DHLJzmkO.js';
17
+ export { C as ClarificationQuestion, D as DatabaseTypes, F as Filter, x as FilterGroup, y as FilterOperator, z as Pagination, P as PublicTableNames, Q as QueryState, R as ResolveRowType, S as SchemaNames, m as SchemaTableNames, A as Sort, T as TableIdentifier, U as UseAdvanceQueryOptions, n as UseAdvanceQueryResult, o as UseDbCountOptions, p as UseDbCountResult, K as UseDbDeleteOptions, L as UseDbDeleteResult, q as UseDbInfiniteQueryOptions, r as UseDbInfiniteQueryResult, B as UseDbInsertOptions, E as UseDbInsertResult, v as UseDbQueryByIdOptions, w as UseDbQueryByIdResult, s as UseDbQueryOptions, t as UseDbQueryResult, G as UseDbUpdateOptions, H as UseDbUpdateResult, I as UseDbUpsertOptions, J as UseDbUpsertResult, u as useAdvanceQuery, a as useDataLayer, c as useDataLayerOptional, e as useDbCount, e as useDbCountV3, f as useDbDeleteV3, g as useDbInfiniteQueryV3, h as useDbInsertV3, j as useDbQueryById, i as useDbQueryV3, k as useDbUpdateV3, l as useDbUpsert, l as useDbUpsertV3, l as useUpsert } from './useDbCount-Ckb-FhZk.js';
18
18
  import { DataLayerConfig } from './core/index.js';
19
- export { AdapterRegistry as AdapterRegistryInterface, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerHooks, DatabaseSchema, DeleteMutationResult, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryOptions, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncControl, SyncSchedule, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators } from './core/index.js';
19
+ export { AdapterRegistry as AdapterRegistryInterface, AutoStrategy, BuiltQuery, CachedStrategy, ColumnInfo, ColumnType, ConnectionConfig, DataAdapter, DataLayerHooks, DatabaseSchema, DeleteMutationResult, ExplicitFkSpec, ExtractInsert, ExtractRow, ExtractUpdate, HybridStrategy, MutationHookResult, MutationResult, OrderBy, ParsedSelect, PowerSyncStrategy, QueryOptions, QueryResult, QuerySingleResult, RelationshipInfo, RelationshipType, ResolvedRelationship, ScopeDefinition, SelectColumn, SelectRelation, SupabaseStrategy, SyncControl, SyncSchedule, SyncScope, SyncStatus, TableNames, TableSchema, TableStrategy, UseDbMutationHook, UseDbQueryByIdHook, UseDbQueryHook, WhereClause, WhereOperators } from './core/index.js';
20
20
  export { u as useBatchDelete, a as useBatchUpsert } from './useBatchUpsert-DAkiCNo3.js';
21
- export { UsePartialAdvancedQueryResult, UsePartialQueryResult, UseQuerySingleReturn, extractColumnNames, extractRelationNames, getRelationSelect, hasRelation, parseSelect, stringifySelect, tokenizeTopLevel, useAdvancedFilterQuery, useAdvancedQuery, useInfiniteQuery, usePartialAdvancedQuery, usePartialQuery, useQuery } from './query/index.js';
22
- export { P as PowerSyncDatabase, Q as QueryExecutor, e as RelationJoinData, R as RelationshipResolver, b as ResultJoiner, S as SQLBuilder, f as createQueryExecutor, c as createRelationshipResolver, d as createResultJoiner, a as createSQLBuilder } from './executor-YJw4m7Q7.js';
23
- import { r as DataLayerContextValue } from './DataLayerContext-C7cJtiO8.js';
24
- export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, c as AdapterCapabilities, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, A as AdapterQueryResult, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, C as CapableDataAdapter, D as DataLayerContext, u as DataLayerStatus, T as TableDataAdapter, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-C7cJtiO8.js';
21
+ export { E as ExtractedExplicitFk, e as extractColumnNames, d as extractExplicitFkRelations, f as extractExplicitFkTables, a as extractRelationNames, g as getRelationSelect, b as hasExplicitFk, h as hasRelation, p as parseSelect, c as selectHasExplicitFkSyntax, s as stringifySelect, t as tokenizeTopLevel } from './select-parser-BAV7fOaM.js';
22
+ export { P as PowerSyncDatabase, Q as QueryExecutor, e as RelationJoinData, R as RelationshipResolver, b as ResultJoiner, S as SQLBuilder, f as createQueryExecutor, c as createRelationshipResolver, d as createResultJoiner, a as createSQLBuilder } from './executor-D15yjeMo.js';
23
+ export { UsePartialAdvancedQueryResult, UsePartialQueryResult, UseQuerySingleReturn, useAdvancedFilterQuery, useAdvancedQuery, useInfiniteQuery, usePartialAdvancedQuery, usePartialQuery, useQuery } from './query/index.js';
24
+ import { r as DataLayerContextValue } from './DataLayerContext-BYZtDD0g.js';
25
+ export { f as ADAPTER_STRATEGIES, i as AdapterAutoDetector, c as AdapterCapabilities, a as AdapterConfig, d as AdapterDependencies, b as AdapterFactory, A as AdapterQueryResult, g as AdapterRegistry, e as AdapterStrategyType, k as AutoDetectionResult, l as AutoDetectorOptions, m as BackendChangeListener, B as BackendStatus, C as CapableDataAdapter, D as DataLayerContext, u as DataLayerStatus, T as TableDataAdapter, j as createAdapterAutoDetector, h as createAdapterRegistry } from './DataLayerContext-BYZtDD0g.js';
25
26
  import { ReactNode, JSX } from 'react';
26
27
  export { B as BatchAnalysisProgress, E as ExtractedReceipt, P as PendingExpense, a as useReceiptAI, u as useSupabaseFunction } from './useReceiptAI-6HkRpRml.js';
27
28
  export { e as UserMetadataContextProvider, c as UserMetadataContextType, a as UserMetadataInsert, U as UserMetadataRow, b as UserMetadataUpdate, u as useLiveChangesIndicator, h as useSetUserMetadata, f as useUserMetadata, i as useUserMetadataState, g as useUserMetadataValue, d as userMetadataContext } from './UserMetadataContext-pQb3A8_Q.js';