@pol-studios/powersync 1.0.7 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +933 -0
- package/dist/CacheSettingsManager-uz-kbnRH.d.ts +461 -0
- package/dist/attachments/index.d.ts +709 -6
- package/dist/attachments/index.js +133 -5
- package/dist/chunk-24RDMMCL.js +44 -0
- package/dist/chunk-24RDMMCL.js.map +1 -0
- package/dist/chunk-4TXTAEF2.js +2060 -0
- package/dist/chunk-4TXTAEF2.js.map +1 -0
- package/dist/chunk-63PXSPIN.js +358 -0
- package/dist/chunk-63PXSPIN.js.map +1 -0
- package/dist/chunk-654ERHA7.js +1 -0
- package/dist/{chunk-BREGB4WL.js → chunk-BRXQNASY.js} +287 -335
- package/dist/chunk-BRXQNASY.js.map +1 -0
- package/dist/{chunk-DHYUBVP7.js → chunk-CAB26E6F.js} +20 -9
- package/dist/chunk-CAB26E6F.js.map +1 -0
- package/dist/{chunk-H772V6XQ.js → chunk-CUCAYK7Z.js} +7 -43
- package/dist/chunk-CUCAYK7Z.js.map +1 -0
- package/dist/{chunk-4C3RY5SU.js → chunk-HWSNV45P.js} +76 -1
- package/dist/chunk-HWSNV45P.js.map +1 -0
- package/dist/{chunk-HFOFLW5F.js → chunk-KN2IZERF.js} +139 -6
- package/dist/chunk-KN2IZERF.js.map +1 -0
- package/dist/{chunk-UEYRTLKE.js → chunk-P4HZA6ZT.js} +20 -9
- package/dist/chunk-P4HZA6ZT.js.map +1 -0
- package/dist/chunk-T4AO7JIG.js +1 -0
- package/dist/{chunk-XQAJM2MW.js → chunk-VACPAAQZ.js} +33 -2
- package/dist/{chunk-XQAJM2MW.js.map → chunk-VACPAAQZ.js.map} +1 -1
- package/dist/{chunk-53WH2JJV.js → chunk-WN5ZJ3E2.js} +5 -8
- package/dist/chunk-WN5ZJ3E2.js.map +1 -0
- package/dist/chunk-XAEII4ZX.js +456 -0
- package/dist/chunk-XAEII4ZX.js.map +1 -0
- package/dist/chunk-XOY2CJ67.js +289 -0
- package/dist/chunk-XOY2CJ67.js.map +1 -0
- package/dist/chunk-YHTZ7VMV.js +1 -0
- package/dist/{chunk-MKD2VCX3.js → chunk-Z6VOBGTU.js} +8 -8
- package/dist/chunk-Z6VOBGTU.js.map +1 -0
- package/dist/chunk-ZM4ENYMF.js +230 -0
- package/dist/chunk-ZM4ENYMF.js.map +1 -0
- package/dist/connector/index.d.ts +56 -3
- package/dist/connector/index.js +8 -5
- package/dist/core/index.d.ts +12 -1
- package/dist/core/index.js +3 -2
- package/dist/error/index.js +0 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.js +191 -29
- package/dist/index.native.d.ts +11 -9
- package/dist/index.native.js +191 -29
- package/dist/index.web.d.ts +11 -9
- package/dist/index.web.js +191 -29
- package/dist/maintenance/index.js +0 -1
- package/dist/platform/index.js +0 -2
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.native.js +1 -2
- package/dist/platform/index.web.js +0 -1
- package/dist/pol-attachment-queue-BVAIueoP.d.ts +817 -0
- package/dist/provider/index.d.ts +38 -34
- package/dist/provider/index.js +11 -12
- package/dist/react/index.d.ts +372 -0
- package/dist/react/index.js +25 -0
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +22 -8
- package/dist/storage/index.native.d.ts +3 -3
- package/dist/storage/index.native.js +21 -7
- package/dist/storage/index.web.d.ts +3 -3
- package/dist/storage/index.web.js +21 -7
- package/dist/storage/upload/index.d.ts +7 -8
- package/dist/storage/upload/index.js +3 -3
- package/dist/storage/upload/index.native.d.ts +7 -8
- package/dist/storage/upload/index.native.js +4 -3
- package/dist/storage/upload/index.web.d.ts +1 -4
- package/dist/storage/upload/index.web.js +3 -3
- package/dist/supabase-connector-T9vHq_3i.d.ts +202 -0
- package/dist/sync/index.js +3 -3
- package/dist/{supabase-connector-qLm-WHkM.d.ts → types-B212hgfA.d.ts} +48 -170
- package/dist/{types-BVacP54t.d.ts → types-CyvBaAl8.d.ts} +12 -4
- package/dist/types-D0WcHrq6.d.ts +234 -0
- package/package.json +18 -4
- package/dist/CacheSettingsManager-1exbOC6S.d.ts +0 -261
- package/dist/chunk-4C3RY5SU.js.map +0 -1
- package/dist/chunk-53WH2JJV.js.map +0 -1
- package/dist/chunk-BREGB4WL.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DHYUBVP7.js.map +0 -1
- package/dist/chunk-GKF7TOMT.js +0 -1
- package/dist/chunk-H772V6XQ.js.map +0 -1
- package/dist/chunk-HFOFLW5F.js.map +0 -1
- package/dist/chunk-KGSFAE5B.js +0 -1
- package/dist/chunk-LNL64IJZ.js +0 -1
- package/dist/chunk-MKD2VCX3.js.map +0 -1
- package/dist/chunk-UEYRTLKE.js.map +0 -1
- package/dist/chunk-WQ5MPAVC.js +0 -449
- package/dist/chunk-WQ5MPAVC.js.map +0 -1
- package/dist/chunk-ZEOKPWUC.js +0 -1165
- package/dist/chunk-ZEOKPWUC.js.map +0 -1
- package/dist/pol-attachment-queue-C7YNXXhK.d.ts +0 -676
- package/dist/types-Bgvx7-E8.d.ts +0 -187
- /package/dist/{chunk-DGUM43GV.js.map → chunk-654ERHA7.js.map} +0 -0
- /package/dist/{chunk-GKF7TOMT.js.map → chunk-T4AO7JIG.js.map} +0 -0
- /package/dist/{chunk-KGSFAE5B.js.map → chunk-YHTZ7VMV.js.map} +0 -0
- /package/dist/{chunk-LNL64IJZ.js.map → react/index.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/attachments/query-builder.ts","../src/attachments/migration.ts"],"sourcesContent":["/**\n * Query Builder for Attachment Watch Queries\n *\n * Generates SQL queries from WatchConfig objects.\n * Provides type-safe query generation without raw SQL strings.\n */\n\nimport type { WatchConfig } from './types';\n\n// ─── SQL Identifier Validation ────────────────────────────────────────────────\n\n/**\n * Valid SQL identifier pattern.\n * Allows alphanumeric characters and underscores, must start with letter or underscore.\n */\nconst VALID_IDENTIFIER_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * SQL reserved words that cannot be used as identifiers (subset of common ones).\n */\nconst SQL_RESERVED_WORDS = new Set(['SELECT', 'FROM', 'WHERE', 'ORDER', 'BY', 'AND', 'OR', 'NOT', 'NULL', 'INSERT', 'UPDATE', 'DELETE', 'DROP', 'CREATE', 'TABLE', 'INDEX', 'JOIN', 'LEFT', 'RIGHT', 'INNER', 'OUTER', 'ON', 'AS', 'DISTINCT', 'GROUP', 'HAVING', 'LIMIT', 'OFFSET', 'UNION', 'EXCEPT', 'INTERSECT', 'IN', 'BETWEEN', 'LIKE', 'IS', 'TRUE', 'FALSE', 'CASE', 'WHEN', 'THEN', 'ELSE', 'END', 'ASC', 'DESC', 'NULLS', 'FIRST', 'LAST']);\n\n/**\n * Validates that a string is a safe SQL identifier.\n * Throws an error if the identifier is invalid or potentially dangerous.\n *\n * @param identifier - The identifier to validate\n * @param context - Description of where this identifier is used (for error messages)\n * @throws Error if identifier is invalid\n */\nexport function validateSqlIdentifier(identifier: string, context: string): void {\n if (!identifier || typeof identifier !== 'string') {\n throw new Error(`Invalid ${context}: must be a non-empty string`);\n }\n if (!VALID_IDENTIFIER_PATTERN.test(identifier)) {\n throw new Error(`Invalid ${context}: \"${identifier}\" contains invalid characters. ` + `Identifiers must start with a letter or underscore and contain only alphanumeric characters and underscores.`);\n }\n if (SQL_RESERVED_WORDS.has(identifier.toUpperCase())) {\n throw new Error(`Invalid ${context}: \"${identifier}\" is a SQL reserved word. ` + `Use a different name or quote the identifier.`);\n }\n\n // Additional safety: check for SQL injection patterns\n const dangerousPatterns = [/--/,\n // SQL comment\n /;/,\n // Statement terminator\n /'/,\n // String delimiter\n /\"/,\n // Quote\n /\\\\/ // Escape character\n ];\n for (const pattern of dangerousPatterns) {\n if (pattern.test(identifier)) {\n throw new Error(`Invalid ${context}: \"${identifier}\" contains potentially dangerous characters.`);\n }\n }\n}\n\n/**\n * Validates a WHERE clause fragment for basic safety.\n * Note: This is a best-effort validation. Complex WHERE clauses should be reviewed.\n *\n * @param whereClause - The WHERE clause fragment to validate\n * @throws Error if the clause contains dangerous patterns\n */\nexport function validateWhereClause(whereClause: string): void {\n if (!whereClause || typeof whereClause !== 'string') {\n throw new Error('Invalid WHERE clause: must be a non-empty string');\n }\n\n // Check for dangerous patterns\n const dangerousPatterns = [{\n pattern: /;\\s*(SELECT|INSERT|UPDATE|DELETE|DROP|CREATE)/i,\n name: 'SQL injection (statement)'\n }, {\n pattern: /UNION\\s+(ALL\\s+)?SELECT/i,\n name: 'UNION injection'\n }, {\n pattern: /--/,\n name: 'SQL comment'\n }, {\n pattern: /\\/\\*/,\n name: 'block comment'\n }, {\n pattern: /xp_|sp_|exec\\s*\\(/i,\n name: 'stored procedure'\n }];\n for (const {\n pattern,\n name\n } of dangerousPatterns) {\n if (pattern.test(whereClause)) {\n throw new Error(`Invalid WHERE clause: contains ${name}`);\n }\n }\n}\n\n// ─── Query Builder ────────────────────────────────────────────────────────────\n\n/**\n * Build a SQL watch query from a WatchConfig.\n *\n * Generates a SELECT statement that:\n * - Selects the ID column (aliased as `id`)\n * - Optionally selects additional columns\n * - Applies an optional WHERE clause\n * - Optionally orders by a column\n *\n * @param config - The WatchConfig to build a query from\n * @returns SQL query string\n *\n * @example\n * ```typescript\n * const query = buildWatchQuery({\n * table: 'EquipmentUnitMediaContent',\n * idColumn: 'storagePath',\n * selectColumns: ['equipmentUnitId', 'takenOn'],\n * where: 'storagePath IS NOT NULL',\n * orderBy: { column: 'takenOn', direction: 'DESC' },\n * });\n *\n * // Result:\n * // SELECT storagePath AS id, equipmentUnitId, takenOn\n * // FROM EquipmentUnitMediaContent\n * // WHERE storagePath IS NOT NULL\n * // ORDER BY takenOn DESC\n * ```\n */\nexport function buildWatchQuery(config: WatchConfig): string {\n // Validate all identifiers\n validateSqlIdentifier(config.table, 'table');\n validateSqlIdentifier(config.idColumn, 'idColumn');\n if (config.selectColumns) {\n for (const col of config.selectColumns) {\n validateSqlIdentifier(col, 'selectColumns');\n }\n }\n if (config.orderBy) {\n validateSqlIdentifier(config.orderBy.column, 'orderBy.column');\n if (config.orderBy.direction !== 'ASC' && config.orderBy.direction !== 'DESC') {\n throw new Error(`Invalid orderBy.direction: must be \"ASC\" or \"DESC\"`);\n }\n }\n if (config.where) {\n validateWhereClause(config.where);\n }\n\n // Build SELECT clause\n const selectParts: string[] = [`${config.idColumn} AS id`];\n if (config.selectColumns && config.selectColumns.length > 0) {\n selectParts.push(...config.selectColumns);\n }\n const selectClause = selectParts.join(', ');\n\n // Build FROM clause\n const fromClause = config.table;\n\n // Build WHERE clause\n let whereClause = `${config.idColumn} IS NOT NULL AND ${config.idColumn} != ''`;\n if (config.where) {\n whereClause = `${whereClause} AND (${config.where})`;\n }\n\n // Build ORDER BY clause\n let orderByClause = '';\n if (config.orderBy) {\n orderByClause = `ORDER BY ${config.orderBy.column} ${config.orderBy.direction}`;\n }\n\n // Assemble query\n const parts = [`SELECT ${selectClause}`, `FROM ${fromClause}`, `WHERE ${whereClause}`];\n if (orderByClause) {\n parts.push(orderByClause);\n }\n return parts.join('\\n');\n}\n\n/**\n * Build a simpler ID-only watch query.\n * Use this when you only need IDs without additional columns.\n *\n * @param config - The WatchConfig to build a query from\n * @returns SQL query string that selects only IDs\n *\n * @example\n * ```typescript\n * const query = buildIdOnlyWatchQuery({\n * table: 'EquipmentUnitMediaContent',\n * idColumn: 'storagePath',\n * where: 'storagePath IS NOT NULL',\n * });\n *\n * // Result:\n * // SELECT storagePath AS id\n * // FROM EquipmentUnitMediaContent\n * // WHERE storagePath IS NOT NULL AND storagePath != ''\n * ```\n */\nexport function buildIdOnlyWatchQuery(config: WatchConfig): string {\n // Use the full builder but ignore selectColumns\n return buildWatchQuery({\n ...config,\n selectColumns: undefined\n });\n}\n\n/**\n * Build a query to fetch records with their IDs and additional columns.\n * Used for populating the BatchFilterContext.records map.\n *\n * @param config - The WatchConfig to build a query from\n * @param ids - Optional list of IDs to filter to (for efficiency)\n * @returns SQL query string and parameters\n *\n * @example\n * ```typescript\n * const { query, params } = buildRecordFetchQuery(\n * {\n * table: 'EquipmentUnitMediaContent',\n * idColumn: 'storagePath',\n * selectColumns: ['equipmentUnitId'],\n * },\n * ['path/to/file1.jpg', 'path/to/file2.jpg']\n * );\n * ```\n */\nexport function buildRecordFetchQuery(config: WatchConfig, ids?: string[]): {\n query: string;\n params: unknown[];\n} {\n // Validate identifiers\n validateSqlIdentifier(config.table, 'table');\n validateSqlIdentifier(config.idColumn, 'idColumn');\n if (config.selectColumns) {\n for (const col of config.selectColumns) {\n validateSqlIdentifier(col, 'selectColumns');\n }\n }\n\n // Build SELECT clause - always include the ID column\n const selectParts: string[] = [`${config.idColumn} AS id`];\n if (config.selectColumns && config.selectColumns.length > 0) {\n selectParts.push(...config.selectColumns);\n }\n const selectClause = selectParts.join(', ');\n\n // Build query\n let query = `SELECT ${selectClause} FROM ${config.table}`;\n const params: unknown[] = [];\n\n // Add WHERE clause for IDs if provided\n if (ids && ids.length > 0) {\n const placeholders = ids.map(() => '?').join(', ');\n query += ` WHERE ${config.idColumn} IN (${placeholders})`;\n params.push(...ids);\n }\n return {\n query,\n params\n };\n}\n\n/**\n * Convert WatchConfig to the legacy AttachmentSourceConfig format.\n * Useful during migration to maintain backwards compatibility.\n *\n * @param watchConfig - The new WatchConfig\n * @returns Legacy AttachmentSourceConfig\n */\nexport function watchConfigToSourceConfig(watchConfig: WatchConfig): {\n table: string;\n idColumn: string;\n orderByColumn?: string | null;\n} {\n return {\n table: watchConfig.table,\n idColumn: watchConfig.idColumn,\n orderByColumn: watchConfig.orderBy?.column ?? null\n };\n}","/**\n * Migration Utilities for @pol-studios/powersync Attachments\n *\n * This module provides utilities for migrating from the old attachment API\n * to the new callback-based API. It includes:\n *\n * - State mapping constants for old → new state transitions\n * - `migrateAttachmentState()` for converting state values\n * - Validation helpers for migration safety\n *\n * @example\n * ```typescript\n * import { migrateAttachmentState, isValidAttachmentState } from '@pol-studios/powersync/attachments';\n *\n * // Migrate a single state value\n * const newState = migrateAttachmentState(oldState);\n *\n * // Validate before migration\n * if (isValidAttachmentState(value)) {\n * const migrated = migrateAttachmentState(value);\n * }\n * ```\n */\n\nimport { AttachmentState } from '@powersync/attachments';\nimport { PolAttachmentState } from './types';\n\n// ─── State Mapping Constants ──────────────────────────────────────────────────\n\n/**\n * Maps old state values to new state values.\n *\n * The official @powersync/attachments AttachmentState enum has values 0-4:\n * QUEUED_SYNC=0, QUEUED_UPLOAD=1, QUEUED_DOWNLOAD=2, SYNCED=3, ARCHIVED=4\n *\n * POL extensions add:\n * FAILED_PERMANENT=5, DOWNLOAD_SKIPPED=6\n *\n * For migration purposes, most states map 1:1. The mapping exists to:\n * 1. Document the relationship between old and new states\n * 2. Provide a clear upgrade path for custom state handling code\n * 3. Allow future state reorganization if needed\n */\nexport const STATE_MAPPING: ReadonlyMap<number, number> = new Map<number, number>([\n// Official states (1:1 mapping)\n[AttachmentState.QUEUED_SYNC as number, PolAttachmentState.QUEUED_SYNC], [AttachmentState.QUEUED_UPLOAD as number, PolAttachmentState.QUEUED_UPLOAD], [AttachmentState.QUEUED_DOWNLOAD as number, PolAttachmentState.QUEUED_DOWNLOAD], [AttachmentState.SYNCED as number, PolAttachmentState.SYNCED], [AttachmentState.ARCHIVED as number, PolAttachmentState.ARCHIVED],\n// POL extension states (identity mapping)\n[PolAttachmentState.FAILED_PERMANENT, PolAttachmentState.FAILED_PERMANENT], [PolAttachmentState.DOWNLOAD_SKIPPED, PolAttachmentState.DOWNLOAD_SKIPPED]]);\n\n/**\n * Human-readable names for attachment states.\n * Useful for logging and debugging during migration.\n */\nexport const STATE_NAMES: ReadonlyMap<number, string> = new Map([[PolAttachmentState.QUEUED_SYNC, 'QUEUED_SYNC'], [PolAttachmentState.QUEUED_UPLOAD, 'QUEUED_UPLOAD'], [PolAttachmentState.QUEUED_DOWNLOAD, 'QUEUED_DOWNLOAD'], [PolAttachmentState.SYNCED, 'SYNCED'], [PolAttachmentState.ARCHIVED, 'ARCHIVED'], [PolAttachmentState.FAILED_PERMANENT, 'FAILED_PERMANENT'], [PolAttachmentState.DOWNLOAD_SKIPPED, 'DOWNLOAD_SKIPPED']]);\n\n/**\n * All valid state values (official + POL extensions).\n */\nexport const VALID_STATES: ReadonlySet<number> = new Set([PolAttachmentState.QUEUED_SYNC, PolAttachmentState.QUEUED_UPLOAD, PolAttachmentState.QUEUED_DOWNLOAD, PolAttachmentState.SYNCED, PolAttachmentState.ARCHIVED, PolAttachmentState.FAILED_PERMANENT, PolAttachmentState.DOWNLOAD_SKIPPED]);\n\n/**\n * States that indicate an active upload workflow.\n * Records in these states should not be migrated to download states.\n */\nexport const UPLOAD_WORKFLOW_STATES: ReadonlySet<number> = new Set([PolAttachmentState.QUEUED_UPLOAD, PolAttachmentState.FAILED_PERMANENT]);\n\n/**\n * States that indicate an active download workflow.\n */\nexport const DOWNLOAD_WORKFLOW_STATES: ReadonlySet<number> = new Set([PolAttachmentState.QUEUED_DOWNLOAD, PolAttachmentState.QUEUED_SYNC]);\n\n/**\n * Terminal states (no further processing needed).\n */\nexport const TERMINAL_STATES: ReadonlySet<number> = new Set([PolAttachmentState.SYNCED, PolAttachmentState.ARCHIVED, PolAttachmentState.DOWNLOAD_SKIPPED]);\n\n// ─── Migration Functions ──────────────────────────────────────────────────────\n\n/**\n * Migrates an attachment state from the old API to the new API.\n *\n * Currently, this is a 1:1 mapping since the state values haven't changed.\n * This function exists to:\n * 1. Provide a clear migration path for apps using custom state handling\n * 2. Document the state relationship\n * 3. Allow future state reorganization without breaking existing code\n *\n * @param oldState - The state value from the old API\n * @returns The corresponding state value in the new API\n * @throws Error if the state value is invalid\n *\n * @example\n * ```typescript\n * import { migrateAttachmentState } from '@pol-studios/powersync/attachments';\n *\n * // Migrate a record's state\n * const newState = migrateAttachmentState(record.state);\n *\n * // Migrate with fallback for unknown states\n * const safeState = isValidAttachmentState(record.state)\n * ? migrateAttachmentState(record.state)\n * : PolAttachmentState.QUEUED_SYNC;\n * ```\n */\nexport function migrateAttachmentState(oldState: number): number {\n const newState = STATE_MAPPING.get(oldState);\n if (newState === undefined) {\n throw new Error(`Invalid attachment state: ${oldState}. ` + `Valid states are: ${Array.from(STATE_NAMES.entries()).map(([v, n]) => `${n}(${v})`).join(', ')}`);\n }\n return newState;\n}\n\n/**\n * Safely migrates an attachment state with a fallback.\n *\n * Unlike `migrateAttachmentState`, this function never throws.\n * Invalid states are mapped to the provided fallback.\n *\n * @param oldState - The state value from the old API\n * @param fallback - State to use if oldState is invalid (default: QUEUED_SYNC)\n * @returns The corresponding state value in the new API, or the fallback\n *\n * @example\n * ```typescript\n * // Safely migrate with QUEUED_SYNC as fallback\n * const state = migrateAttachmentStateSafe(unknownValue);\n *\n * // Use custom fallback\n * const state = migrateAttachmentStateSafe(unknownValue, PolAttachmentState.ARCHIVED);\n * ```\n */\nexport function migrateAttachmentStateSafe(oldState: number, fallback: number = PolAttachmentState.QUEUED_SYNC): number {\n const newState = STATE_MAPPING.get(oldState);\n return newState !== undefined ? newState : fallback;\n}\n\n// ─── Validation Helpers ───────────────────────────────────────────────────────\n\n/**\n * Checks if a value is a valid attachment state.\n *\n * @param value - The value to check\n * @returns true if the value is a valid attachment state\n *\n * @example\n * ```typescript\n * if (isValidAttachmentState(record.state)) {\n * // Safe to use record.state\n * } else {\n * console.warn(`Invalid state: ${record.state}`);\n * }\n * ```\n */\nexport function isValidAttachmentState(value: unknown): value is number {\n return typeof value === 'number' && VALID_STATES.has(value);\n}\n\n/**\n * Checks if a state represents an upload workflow.\n *\n * Records in upload workflow states should not be demoted to download states.\n *\n * @param state - The state to check\n * @returns true if the state is part of an upload workflow\n */\nexport function isUploadWorkflowState(state: number): boolean {\n return UPLOAD_WORKFLOW_STATES.has(state);\n}\n\n/**\n * Checks if a state represents a download workflow.\n *\n * @param state - The state to check\n * @returns true if the state is part of a download workflow\n */\nexport function isDownloadWorkflowState(state: number): boolean {\n return DOWNLOAD_WORKFLOW_STATES.has(state);\n}\n\n/**\n * Checks if a state is terminal (no further processing needed).\n *\n * @param state - The state to check\n * @returns true if the state is terminal\n */\nexport function isTerminalState(state: number): boolean {\n return TERMINAL_STATES.has(state);\n}\n\n/**\n * Gets the human-readable name of a state.\n *\n * @param state - The state value\n * @returns The state name, or \"UNKNOWN\" for invalid states\n *\n * @example\n * ```typescript\n * console.log(`State: ${getStateName(record.state)}`); // \"State: SYNCED\"\n * ```\n */\nexport function getStateName(state: number): string {\n return STATE_NAMES.get(state) ?? 'UNKNOWN';\n}\n\n// ─── Migration Report ─────────────────────────────────────────────────────────\n\n/**\n * Statistics about a batch migration.\n */\nexport interface MigrationStats {\n /** Total records processed */\n total: number;\n /** Records successfully migrated */\n migrated: number;\n /** Records with invalid states (used fallback) */\n invalid: number;\n /** Breakdown by state */\n byState: Map<number, number>;\n}\n\n/**\n * Creates empty migration stats.\n */\nexport function createMigrationStats(): MigrationStats {\n return {\n total: 0,\n migrated: 0,\n invalid: 0,\n byState: new Map()\n };\n}\n\n/**\n * Records a migration result in the stats.\n *\n * @param stats - The stats object to update\n * @param oldState - The original state\n * @param newState - The migrated state\n * @param wasValid - Whether the original state was valid\n */\nexport function recordMigration(stats: MigrationStats, oldState: number, newState: number, wasValid: boolean): void {\n stats.total++;\n if (wasValid) {\n stats.migrated++;\n } else {\n stats.invalid++;\n }\n stats.byState.set(newState, (stats.byState.get(newState) ?? 0) + 1);\n}\n\n/**\n * Formats migration stats as a human-readable summary.\n *\n * @param stats - The stats to format\n * @returns A formatted string summary\n *\n * @example\n * ```typescript\n * const stats = createMigrationStats();\n * // ... process records ...\n * console.log(formatMigrationStats(stats));\n * // Output:\n * // Migration Summary:\n * // Total: 100\n * // Migrated: 98\n * // Invalid (used fallback): 2\n * // By State:\n * // SYNCED: 50\n * // QUEUED_DOWNLOAD: 30\n * // QUEUED_UPLOAD: 18\n * // QUEUED_SYNC: 2\n * ```\n */\nexport function formatMigrationStats(stats: MigrationStats): string {\n const lines = ['Migration Summary:', ` Total: ${stats.total}`, ` Migrated: ${stats.migrated}`, ` Invalid (used fallback): ${stats.invalid}`, ' By State:'];\n for (const [state, count] of stats.byState.entries()) {\n lines.push(` ${getStateName(state)}: ${count}`);\n }\n return lines.join('\\n');\n}"],"mappings":"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","names":[]}
|
|
@@ -1,8 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
import { A as AuthProvider } from '../types-B212hgfA.js';
|
|
2
|
+
export { g as ConflictBus, C as ConnectorCircuitBreakerConfig, a as ConnectorConfig, c as CrudHandler, D as DEFAULT_RETRY_CONFIG, P as PowerSyncCredentials, e as RetryConfig, R as RetryStrategyConfig, b as SchemaRouter, f as Session, S as SupabaseConnectorOptions, d as defaultSchemaRouter } from '../types-B212hgfA.js';
|
|
3
|
+
export { S as SupabaseConnector } from '../supabase-connector-T9vHq_3i.js';
|
|
4
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
2
5
|
export { P as PowerSyncBackendConnector } from '../types-CDqWh56B.js';
|
|
3
|
-
import '@supabase/supabase-js';
|
|
4
6
|
import '../platform/index.js';
|
|
5
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Supabase Auth Provider for @pol-studios/powersync
|
|
10
|
+
*
|
|
11
|
+
* Factory function that wraps a Supabase client's auth methods
|
|
12
|
+
* to implement the AuthProvider interface.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Options for createSupabaseAuth
|
|
17
|
+
*/
|
|
18
|
+
interface SupabaseAuthOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Called when a session refresh fails.
|
|
21
|
+
* Use this to trigger logout flows or show error UI.
|
|
22
|
+
*/
|
|
23
|
+
onRefreshError?: (error: Error) => void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an AuthProvider that wraps Supabase auth.
|
|
27
|
+
*
|
|
28
|
+
* @param supabase - Supabase client instance
|
|
29
|
+
* @param options - Optional configuration
|
|
30
|
+
* @returns AuthProvider implementation
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { createSupabaseAuth } from '@pol-studios/powersync';
|
|
35
|
+
*
|
|
36
|
+
* const auth = createSupabaseAuth(supabaseClient, {
|
|
37
|
+
* onRefreshError: (error) => {
|
|
38
|
+
* console.error('Session refresh failed:', error);
|
|
39
|
+
* // Navigate to login screen
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Use with PowerSyncProvider
|
|
44
|
+
* <PowerSyncProvider auth={auth} ... />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
declare function createSupabaseAuth(supabase: SupabaseClient, options?: SupabaseAuthOptions): AuthProvider;
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when session refresh fails.
|
|
50
|
+
*/
|
|
51
|
+
declare class AuthRefreshError extends Error {
|
|
52
|
+
readonly name = "AuthRefreshError";
|
|
53
|
+
readonly cause?: Error;
|
|
54
|
+
constructor(message: string, options?: {
|
|
55
|
+
cause?: Error;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
6
59
|
/**
|
|
7
60
|
* Circuit Breaker Pattern for PowerSync Connector
|
|
8
61
|
*
|
|
@@ -181,4 +234,4 @@ declare class CircuitBreaker {
|
|
|
181
234
|
private log;
|
|
182
235
|
}
|
|
183
236
|
|
|
184
|
-
export { CircuitBreaker, type CircuitBreakerConfig, type CircuitBreakerStats, CircuitOpenError, type CircuitState, DEFAULT_CIRCUIT_BREAKER_CONFIG };
|
|
237
|
+
export { AuthProvider, AuthRefreshError, CircuitBreaker, type CircuitBreakerConfig, type CircuitBreakerStats, CircuitOpenError, type CircuitState, DEFAULT_CIRCUIT_BREAKER_CONFIG, type SupabaseAuthOptions, createSupabaseAuth };
|
package/dist/connector/index.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AuthRefreshError,
|
|
2
3
|
CircuitBreaker,
|
|
3
4
|
CircuitOpenError,
|
|
4
|
-
DEFAULT_CIRCUIT_BREAKER_CONFIG
|
|
5
|
-
|
|
5
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
6
|
+
createSupabaseAuth
|
|
7
|
+
} from "../chunk-HWSNV45P.js";
|
|
6
8
|
import {
|
|
7
9
|
DEFAULT_RETRY_CONFIG,
|
|
8
10
|
SupabaseConnector,
|
|
9
11
|
defaultSchemaRouter
|
|
10
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-KN2IZERF.js";
|
|
11
13
|
import "../chunk-FV2HXEIY.js";
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-DGUM43GV.js";
|
|
14
|
+
import "../chunk-VACPAAQZ.js";
|
|
14
15
|
export {
|
|
16
|
+
AuthRefreshError,
|
|
15
17
|
CircuitBreaker,
|
|
16
18
|
CircuitOpenError,
|
|
17
19
|
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
18
20
|
DEFAULT_RETRY_CONFIG,
|
|
19
21
|
SupabaseConnector,
|
|
22
|
+
createSupabaseAuth,
|
|
20
23
|
defaultSchemaRouter
|
|
21
24
|
};
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.d.ts
CHANGED
|
@@ -195,5 +195,16 @@ declare function extractEntityIds(entries: CrudEntry[]): string[];
|
|
|
195
195
|
* Extract unique table names from CRUD entries.
|
|
196
196
|
*/
|
|
197
197
|
declare function extractTableNames(entries: CrudEntry[]): string[];
|
|
198
|
+
/**
|
|
199
|
+
* Check if an error is an RLS/permission error (PostgreSQL 42501 - insufficient_privilege).
|
|
200
|
+
*
|
|
201
|
+
* RLS errors are special because they may resolve when parent data syncs.
|
|
202
|
+
* For example, inserting a child record may fail until the parent record syncs
|
|
203
|
+
* and satisfies the RLS policy conditions.
|
|
204
|
+
*
|
|
205
|
+
* @param error - The error to check
|
|
206
|
+
* @returns true if the error is an RLS/permission error
|
|
207
|
+
*/
|
|
208
|
+
declare function isRlsError(error: unknown): boolean;
|
|
198
209
|
|
|
199
|
-
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ClassifiedError, ConfigurationError, ConnectorError, CrudEntry, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_AUTO_OFFLINE, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncError, SyncErrorType, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError };
|
|
210
|
+
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ClassifiedError, ConfigurationError, ConnectorError, CrudEntry, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_AUTO_OFFLINE, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncError, SyncErrorType, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, isRlsError, toSyncOperationError };
|
package/dist/core/index.js
CHANGED
|
@@ -46,9 +46,9 @@ import {
|
|
|
46
46
|
extractEntityIds,
|
|
47
47
|
extractTableNames,
|
|
48
48
|
generateFailureId,
|
|
49
|
+
isRlsError,
|
|
49
50
|
toSyncOperationError
|
|
50
|
-
} from "../chunk-
|
|
51
|
-
import "../chunk-DGUM43GV.js";
|
|
51
|
+
} from "../chunk-VACPAAQZ.js";
|
|
52
52
|
export {
|
|
53
53
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
54
54
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
@@ -94,6 +94,7 @@ export {
|
|
|
94
94
|
extractEntityIds,
|
|
95
95
|
extractTableNames,
|
|
96
96
|
generateFailureId,
|
|
97
|
+
isRlsError,
|
|
97
98
|
toSyncOperationError
|
|
98
99
|
};
|
|
99
100
|
//# sourceMappingURL=index.js.map
|
package/dist/error/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { A as AbstractPowerSyncDatabase } from './types-CDqWh56B.js';
|
|
2
2
|
export { k as CacheStats, i as ClassifiedError, j as CompactResult, h as CompletedTransaction, b as ConnectionHealth, o as CountRow, C as CrudEntry, l as CrudTransaction, n as DbStatRow, D as DownloadProgress, E as EntitySyncState, F as FailedTransaction, r as FreelistCountRow, s as IntegrityCheckRow, I as IntegrityResult, q as PageCountRow, p as PageSizeRow, P as PowerSyncBackendConnector, m as SqliteTableRow, c as StorageInfo, d as StorageQuota, f as SyncError, g as SyncErrorType, e as SyncMetrics, S as SyncMode, a as SyncStatus, T as TableCacheStats } from './types-CDqWh56B.js';
|
|
3
|
-
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_AUTO_OFFLINE, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, toSyncOperationError } from './core/index.js';
|
|
4
|
-
import { k as ConflictDetectionConfig, h as ConflictCheckResult } from './
|
|
5
|
-
export { g as ConflictBus, j as ConflictHandler, l as ConflictListener, i as ConflictResolution, C as ConnectorCircuitBreakerConfig,
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
3
|
+
export { ATTACHMENT_DOWNLOAD_TIMEOUT_MS, ATTACHMENT_RETRY_DELAY_MS, AttachmentError, COMPRESSION_MAX_WIDTH, COMPRESSION_SKIP_SIZE_BYTES, COMPRESSION_TARGET_SIZE_BYTES, ConfigurationError, ConnectorError, DEFAULT_ATTACHMENT_CACHE_SIZE, DEFAULT_ATTACHMENT_CONCURRENCY, DEFAULT_COMPRESSION_QUALITY, DEFAULT_MAX_RETRY_ATTEMPTS, DEFAULT_RETRY_BACKOFF_MULTIPLIER, DEFAULT_RETRY_BASE_DELAY_MS, DEFAULT_RETRY_MAX_DELAY_MS, DEFAULT_SYNC_INTERVAL_MS, DEFAULT_SYNC_MODE, DOWNLOAD_STOP_THRESHOLD, EVICTION_TRIGGER_THRESHOLD, HEALTH_CHECK_INTERVAL_MS, HEALTH_CHECK_TIMEOUT_MS, InitializationError, LATENCY_DEGRADED_THRESHOLD_MS, MAX_CONSECUTIVE_FAILURES, PlatformAdapterError, PowerSyncError, STATS_CACHE_TTL_MS, STATUS_NOTIFY_THROTTLE_MS, STORAGE_CRITICAL_THRESHOLD, STORAGE_KEY_ATTACHMENT_SETTINGS, STORAGE_KEY_AUTO_OFFLINE, STORAGE_KEY_ENABLED, STORAGE_KEY_METRICS, STORAGE_KEY_PAUSED, STORAGE_KEY_PREFIX, STORAGE_KEY_SYNC_MODE, STORAGE_WARNING_THRESHOLD, SyncOperationError, classifyError, classifySupabaseError, createSyncError, extractEntityIds, extractTableNames, generateFailureId, isRlsError, toSyncOperationError } from './core/index.js';
|
|
4
|
+
import { k as ConflictDetectionConfig, h as ConflictCheckResult } from './types-B212hgfA.js';
|
|
5
|
+
export { A as AuthProvider, g as ConflictBus, j as ConflictHandler, l as ConflictListener, i as ConflictResolution, C as ConnectorCircuitBreakerConfig, a as ConnectorConfig, c as CrudHandler, D as DEFAULT_RETRY_CONFIG, F as FieldConflict, P as PowerSyncCredentials, m as ResolutionListener, e as RetryConfig, R as RetryStrategyConfig, b as SchemaRouter, f as Session, S as SupabaseConnectorOptions, d as defaultSchemaRouter } from './types-B212hgfA.js';
|
|
6
|
+
export { S as SupabaseConnector } from './supabase-connector-T9vHq_3i.js';
|
|
7
|
+
export { AuthRefreshError, CircuitBreaker, CircuitBreakerConfig, CircuitBreakerStats, CircuitOpenError, CircuitState, DEFAULT_CIRCUIT_BREAKER_CONFIG, SupabaseAuthOptions, createSupabaseAuth } from './connector/index.js';
|
|
8
|
+
export { e as AttachmentConfig, z as AttachmentRecord, A as AttachmentSourceConfig, w as AttachmentStatsRow, f as AttachmentStorageAdapter, v as AttachmentSyncStats, u as AttachmentSyncStatus, B as BatchFilterContext, m as CACHE_SIZE_PRESETS, k as CacheConfig, x as CacheFileRow, n as CacheSizePreset, o as CacheSizeValue, y as CachedSizeRow, C as CompressionConfig, l as DEFAULT_CACHE_CONFIG, D as DEFAULT_COMPRESSION_CONFIG, j as DEFAULT_DOWNLOAD_CONFIG, g as DEFAULT_UPLOAD_CONFIG, i as DownloadConfig, q as DownloadPhase, r as DownloadStatus, E as EvictRow, I as IdRow, P as PolAttachmentQueue, a as PolAttachmentQueueOptions, d as PolAttachmentRecord, b as PolAttachmentState, S as SkipDownloadContext, U as UploadConfig, h as UploadHandler, s as UploadPhase, t as UploadStatus, W as WatchConfig, c as createPolAttachmentQueue, p as formatCacheSize } from './pol-attachment-queue-BVAIueoP.js';
|
|
9
|
+
export { CacheManagerDeps, DOWNLOAD_WORKFLOW_STATES, DownloadManagerDeps, LOCALLY_AVAILABLE_STATES, MigrationStats, PENDING_DOWNLOAD_STATES, PROTECTED_UPLOAD_STATES, PolStorageAdapter, PolStorageAdapterOptions, STATE_MAPPING, STATE_NAMES, TERMINAL_STATES, UPLOAD_WORKFLOW_STATES, UploadManagerDeps, UploadManagerState, VALID_STATES, blobToArrayBuffer, buildIdOnlyWatchQuery, buildRecordFetchQuery, buildWatchQuery, cacheLocalFile, clearCache, clearUploadCallback, copyToManagedCache, createCacheManagerDeps, createMigrationStats, createUploadManagerDeps, createUploadManagerState, determineAttachmentState, downloadRecord, enforceCacheLimit, ensureFileUri, extractErrorCode, formatMigrationStats, getCachedSize, getEvictionCandidates, getExcludeProtectedStatesCondition, getFailedPermanentUploads, getLocalUriForStoragePath, getPendingUploads, getProtectedStatesInClause, getSoonestRetryTime, getStaleUploads, getStateName, getSyncedUploadsWithPendingCallback, isCacheNearCapacity, isDownloadWorkflowState, isLocallyAvailable, isPendingDownloadState, isPermanentError, isProtectedUploadState, isStateTransitionAllowed, isTerminalState, isUploadWorkflowState, isValidAttachmentState, markUploadPermanentFailure, markUploadSynced, migrateAttachmentState, migrateAttachmentStateSafe, recordMigration, scheduleUploadRetry, startUploadProcessing, stripFileUri, uploadOne, validateSqlIdentifier, validateSqlIdentifierFromStateMachine, validateWhereClause, watchConfigToSourceConfig } from './attachments/index.js';
|
|
9
10
|
export { B as BackgroundSyncOptions, h as BackgroundSyncSystem, e as HealthCheckResult, H as HealthMonitorOptions, M as MetricsCollectorOptions, P as PowerSyncRawStatus, c as SyncControlActions, f as SyncEvent, g as SyncEventListener, d as SyncOperationData, S as SyncScope, a as SyncStatusState, b as SyncStatusTrackerOptions, U as Unsubscribe, i as defineBackgroundSyncTask, j as initializeBackgroundSync, k as isBackgroundSyncRegistered, r as registerBackgroundSync, u as unregisterBackgroundSync } from './background-sync-ChCXW-EV.js';
|
|
10
11
|
export { DeadLetterEntry, DeadLetterQueue, DeadLetterQueueListener, DeadLetterQueueOptions, DeadLetterReason, HealthMonitor, MetricsCollector, SyncStatusTracker, createDeadLetterEntry, generateDLQEntryId } from './sync/index.js';
|
|
11
12
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
12
13
|
export { DatabaseMaintenanceUtils, checkIntegrityImpl, checkStorageQuotaImpl, compactDatabaseImpl, getCacheStatsImpl, useDatabaseMaintenance } from './maintenance/index.js';
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from './types-
|
|
14
|
+
export { D as DownloadResult, a as StorageBackend, b as StorageUploadOptions, d as SupabaseClient, S as SupabaseStorage, c as SupabaseStorageOptions, e as SupabaseTransformOptions, U as UploadProgress, r as resolveBucket } from './types-D0WcHrq6.js';
|
|
15
|
+
export { f as CacheSettings, C as CacheSettingsManager, h as CacheSettingsManagerOptions, D as DEFAULT_CACHE_SETTINGS, I as ImageTransformOptions, S as SupabaseStorageAdapter, e as SupabaseStorageAdapterOptions, c as createSupabaseStorage, d as createSupabaseStorageAdapter, g as getStorageErrorMessage, a as isBlobResult, i as isFileResult, b as isStorageAuthError, n as normalizeStoragePath } from './CacheSettingsManager-uz-kbnRH.js';
|
|
16
|
+
export { D as DEFAULT_UPLOAD_NOTIFICATION, S as SupabaseUploadHandlerOptions, U as UploadEventHandlers, a as UploadNotificationConfig } from './types-CyvBaAl8.js';
|
|
16
17
|
export { SupabaseUploadHandler, createSupabaseUploadHandler } from './storage/upload/index.js';
|
|
17
18
|
export { PowerSyncErrorBoundary } from './error/index.js';
|
|
18
19
|
export { AttachmentQueueContext, BackgroundSyncCallbacks, BackgroundSyncConfig, BackgroundSyncStatus, CompletedTransactionsContext, CompletedTransactionsContextValue, ConnectionHealthContext, ConnectionHealthContextValue, ConnectionStatusContext, ConnectionStatusContextValue, DEFAULT_CONNECTION_HEALTH, DEFAULT_SYNC_CONFIG, DEFAULT_SYNC_METRICS, DEFAULT_SYNC_STATUS, DataLayerConfig, DataLayerIntegration, EntitySyncStatusResult, FailedTransactionsContext, FailedTransactionsContextValue, OfflineDataAttachmentConfig, OfflineDataProvider, OfflineDataProviderConfig, OfflineDataProviderProps, PendingMutationsContext, PendingMutationsContextValue, PowerSyncConfig, PowerSyncContext, PowerSyncContextValue, PowerSyncProvider, PowerSyncProviderProps, PowerSyncSyncStatusSnapshot, ProviderBridge, ProviderBridgeProps, SyncActivityContext, SyncActivityContextValue, SyncActivityResult, SyncConfig, SyncMetricsContext, SyncMetricsContextValue, SyncModeContext, SyncModeContextValue, SyncStatusContext, SyncStatusContextValue, UploadStatusResult, useAttachmentQueue, useAttachmentQueueReady, useCompletedTransactions, useCompletedTransactionsContext, useConnectionHealth, useConnectionStatus, useDatabase, useDownloadProgress, useEntitySyncStatus, useFailedTransactions, useFailedTransactionsContext, useIsSyncing, useOnlineStatus, usePendingMutations, usePendingMutationsContext, usePlatform, usePowerSync, useSyncActivity, useSyncActivityContext, useSyncControl, useSyncMetrics, useSyncMode, useSyncModeContext, useSyncStatus, useUploadStatus } from './provider/index.js';
|
|
20
|
+
export { AttachmentQueueContextValue, SlimPowerSyncProvider, useAttachmentQueueContext, usePowerSyncContext, useSyncStatusContext } from './react/index.js';
|
|
19
21
|
export { AsyncStorageAdapter, CompressedImage, CompressionOptions, ConnectionType, DatabaseOptions, FileInfo, FileSystemAdapter, ImageProcessorAdapter, LoggerAdapter, NetworkAdapter, PlatformAdapter, PlatformType, detectPlatform } from './platform/index.js';
|
|
20
22
|
export { ATTACHMENT_TABLE, AbstractAttachmentQueue, AttachmentState, AttachmentTable, AttachmentTableOptions, AttachmentQueueOptions as BaseAttachmentQueueOptions, DEFAULT_ATTACHMENT_QUEUE_OPTIONS, EncodingType, AttachmentRecord as OfficialAttachmentRecord, StorageAdapter } from '@powersync/attachments';
|
|
21
|
-
|
|
23
|
+
export { AbstractPowerSyncDatabase as PowerSyncDBInterface } from '@powersync/common';
|
|
22
24
|
import 'react';
|
|
23
25
|
import '@tanstack/react-query';
|
|
24
26
|
import '@powersync/react-native';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import "./chunk-
|
|
2
|
-
import
|
|
1
|
+
import "./chunk-654ERHA7.js";
|
|
2
|
+
import {
|
|
3
|
+
SlimPowerSyncProvider,
|
|
4
|
+
useAttachmentQueueContext,
|
|
5
|
+
usePowerSyncContext,
|
|
6
|
+
useSyncStatusContext
|
|
7
|
+
} from "./chunk-63PXSPIN.js";
|
|
8
|
+
import {
|
|
9
|
+
DOWNLOAD_WORKFLOW_STATES,
|
|
10
|
+
STATE_MAPPING,
|
|
11
|
+
STATE_NAMES,
|
|
12
|
+
TERMINAL_STATES,
|
|
13
|
+
UPLOAD_WORKFLOW_STATES,
|
|
14
|
+
VALID_STATES,
|
|
15
|
+
buildIdOnlyWatchQuery,
|
|
16
|
+
buildRecordFetchQuery,
|
|
17
|
+
buildWatchQuery,
|
|
18
|
+
createMigrationStats,
|
|
19
|
+
formatMigrationStats,
|
|
20
|
+
getStateName,
|
|
21
|
+
isDownloadWorkflowState,
|
|
22
|
+
isTerminalState,
|
|
23
|
+
isUploadWorkflowState,
|
|
24
|
+
isValidAttachmentState,
|
|
25
|
+
migrateAttachmentState,
|
|
26
|
+
migrateAttachmentStateSafe,
|
|
27
|
+
recordMigration,
|
|
28
|
+
validateSqlIdentifier as validateSqlIdentifier2,
|
|
29
|
+
validateWhereClause,
|
|
30
|
+
watchConfigToSourceConfig
|
|
31
|
+
} from "./chunk-ZM4ENYMF.js";
|
|
3
32
|
import {
|
|
4
33
|
ConflictBus,
|
|
5
34
|
OfflineDataProvider,
|
|
6
35
|
PowerSyncProvider,
|
|
7
36
|
ProviderBridge
|
|
8
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-BRXQNASY.js";
|
|
38
|
+
import "./chunk-YHTZ7VMV.js";
|
|
9
39
|
import {
|
|
10
40
|
PowerSyncErrorBoundary
|
|
11
41
|
} from "./chunk-P6WOZO7H.js";
|
|
@@ -14,16 +44,65 @@ import {
|
|
|
14
44
|
AbstractAttachmentQueue,
|
|
15
45
|
AttachmentState,
|
|
16
46
|
AttachmentTable,
|
|
47
|
+
CACHE_SIZE_PRESETS,
|
|
17
48
|
DEFAULT_ATTACHMENT_QUEUE_OPTIONS,
|
|
18
49
|
DEFAULT_CACHE_CONFIG,
|
|
19
50
|
DEFAULT_COMPRESSION_CONFIG,
|
|
51
|
+
DEFAULT_DOWNLOAD_CONFIG,
|
|
20
52
|
DEFAULT_UPLOAD_CONFIG,
|
|
21
53
|
EncodingType,
|
|
54
|
+
LOCALLY_AVAILABLE_STATES,
|
|
55
|
+
PENDING_DOWNLOAD_STATES,
|
|
56
|
+
PROTECTED_UPLOAD_STATES,
|
|
22
57
|
PolAttachmentQueue,
|
|
23
58
|
PolAttachmentState,
|
|
24
59
|
PolStorageAdapter,
|
|
25
|
-
|
|
26
|
-
|
|
60
|
+
blobToArrayBuffer,
|
|
61
|
+
cacheLocalFile,
|
|
62
|
+
clearCache,
|
|
63
|
+
clearUploadCallback,
|
|
64
|
+
copyToManagedCache,
|
|
65
|
+
createCacheManagerDeps,
|
|
66
|
+
createPolAttachmentQueue,
|
|
67
|
+
createUploadManagerDeps,
|
|
68
|
+
createUploadManagerState,
|
|
69
|
+
determineAttachmentState,
|
|
70
|
+
downloadRecord,
|
|
71
|
+
enforceCacheLimit,
|
|
72
|
+
ensureFileUri,
|
|
73
|
+
extractErrorCode,
|
|
74
|
+
formatCacheSize,
|
|
75
|
+
getCachedSize,
|
|
76
|
+
getEvictionCandidates,
|
|
77
|
+
getExcludeProtectedStatesCondition,
|
|
78
|
+
getExtensionFromMimeType,
|
|
79
|
+
getFailedPermanentUploads,
|
|
80
|
+
getLocalUriForStoragePath,
|
|
81
|
+
getMimeType,
|
|
82
|
+
getMimeTypeFromPath,
|
|
83
|
+
getPendingUploads,
|
|
84
|
+
getProtectedStatesInClause,
|
|
85
|
+
getSoonestRetryTime,
|
|
86
|
+
getStaleUploads,
|
|
87
|
+
getSyncedUploadsWithPendingCallback,
|
|
88
|
+
isAudioMimeType,
|
|
89
|
+
isCacheNearCapacity,
|
|
90
|
+
isDocumentMimeType,
|
|
91
|
+
isImageMimeType,
|
|
92
|
+
isLocallyAvailable,
|
|
93
|
+
isPendingDownloadState,
|
|
94
|
+
isPermanentError,
|
|
95
|
+
isProtectedUploadState,
|
|
96
|
+
isStateTransitionAllowed,
|
|
97
|
+
isVideoMimeType,
|
|
98
|
+
markUploadPermanentFailure,
|
|
99
|
+
markUploadSynced,
|
|
100
|
+
scheduleUploadRetry,
|
|
101
|
+
startUploadProcessing,
|
|
102
|
+
stripFileUri,
|
|
103
|
+
uploadOne,
|
|
104
|
+
validateSqlIdentifier
|
|
105
|
+
} from "./chunk-4TXTAEF2.js";
|
|
27
106
|
import {
|
|
28
107
|
DeadLetterQueue,
|
|
29
108
|
createDeadLetterEntry,
|
|
@@ -35,14 +114,16 @@ import {
|
|
|
35
114
|
unregisterBackgroundSync
|
|
36
115
|
} from "./chunk-A4IBBWGO.js";
|
|
37
116
|
import {
|
|
38
|
-
DEFAULT_CONNECTION_HEALTH,
|
|
39
|
-
DEFAULT_SYNC_CONFIG,
|
|
40
|
-
DEFAULT_SYNC_METRICS,
|
|
41
|
-
DEFAULT_SYNC_STATUS,
|
|
42
117
|
HealthMonitor,
|
|
43
118
|
MetricsCollector,
|
|
44
119
|
SyncStatusTracker
|
|
45
|
-
} from "./chunk-
|
|
120
|
+
} from "./chunk-CUCAYK7Z.js";
|
|
121
|
+
import {
|
|
122
|
+
DEFAULT_CONNECTION_HEALTH,
|
|
123
|
+
DEFAULT_SYNC_CONFIG,
|
|
124
|
+
DEFAULT_SYNC_METRICS,
|
|
125
|
+
DEFAULT_SYNC_STATUS
|
|
126
|
+
} from "./chunk-24RDMMCL.js";
|
|
46
127
|
import {
|
|
47
128
|
checkIntegrityImpl,
|
|
48
129
|
checkStorageQuotaImpl,
|
|
@@ -89,29 +170,31 @@ import {
|
|
|
89
170
|
useSyncStatus,
|
|
90
171
|
useUploadStatus
|
|
91
172
|
} from "./chunk-YSTEESEG.js";
|
|
92
|
-
import "./chunk-
|
|
173
|
+
import "./chunk-T4AO7JIG.js";
|
|
174
|
+
import "./chunk-CAB26E6F.js";
|
|
93
175
|
import {
|
|
94
176
|
CacheSettingsManager,
|
|
95
177
|
DEFAULT_CACHE_SETTINGS,
|
|
178
|
+
createSupabaseStorage,
|
|
179
|
+
isBlobResult,
|
|
180
|
+
isFileResult
|
|
181
|
+
} from "./chunk-XOY2CJ67.js";
|
|
182
|
+
import {
|
|
96
183
|
SupabaseStorageAdapter,
|
|
97
184
|
createSupabaseStorageAdapter,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
isDocumentMimeType,
|
|
103
|
-
isImageMimeType,
|
|
104
|
-
isVideoMimeType
|
|
105
|
-
} from "./chunk-WQ5MPAVC.js";
|
|
185
|
+
getStorageErrorMessage,
|
|
186
|
+
isStorageAuthError,
|
|
187
|
+
normalizeStoragePath
|
|
188
|
+
} from "./chunk-XAEII4ZX.js";
|
|
106
189
|
import "./chunk-TGBT5XBE.js";
|
|
107
190
|
import {
|
|
108
191
|
SupabaseUploadHandler,
|
|
109
192
|
createSupabaseUploadHandler
|
|
110
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-P4HZA6ZT.js";
|
|
111
194
|
import {
|
|
112
195
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
113
|
-
|
|
114
|
-
} from "./chunk-
|
|
196
|
+
resolveBucket
|
|
197
|
+
} from "./chunk-Z6VOBGTU.js";
|
|
115
198
|
import "./chunk-W7HSR35B.js";
|
|
116
199
|
import {
|
|
117
200
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
@@ -146,12 +229,14 @@ import {
|
|
|
146
229
|
STORAGE_KEY_SYNC_MODE,
|
|
147
230
|
STORAGE_WARNING_THRESHOLD
|
|
148
231
|
} from "./chunk-CGL33PL4.js";
|
|
149
|
-
import "./chunk-
|
|
232
|
+
import "./chunk-WN5ZJ3E2.js";
|
|
150
233
|
import {
|
|
234
|
+
AuthRefreshError,
|
|
151
235
|
CircuitBreaker,
|
|
152
236
|
CircuitOpenError,
|
|
153
|
-
DEFAULT_CIRCUIT_BREAKER_CONFIG
|
|
154
|
-
|
|
237
|
+
DEFAULT_CIRCUIT_BREAKER_CONFIG,
|
|
238
|
+
createSupabaseAuth
|
|
239
|
+
} from "./chunk-HWSNV45P.js";
|
|
155
240
|
import {
|
|
156
241
|
ConflictDetectionError,
|
|
157
242
|
DEFAULT_RETRY_CONFIG,
|
|
@@ -161,7 +246,7 @@ import {
|
|
|
161
246
|
fetchServerVersion,
|
|
162
247
|
getLocalVersion,
|
|
163
248
|
hasVersionColumn
|
|
164
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-KN2IZERF.js";
|
|
165
250
|
import {
|
|
166
251
|
AbortError,
|
|
167
252
|
DEFAULT_BACKOFF_CONFIG,
|
|
@@ -185,9 +270,9 @@ import {
|
|
|
185
270
|
extractEntityIds,
|
|
186
271
|
extractTableNames,
|
|
187
272
|
generateFailureId,
|
|
273
|
+
isRlsError,
|
|
188
274
|
toSyncOperationError
|
|
189
|
-
} from "./chunk-
|
|
190
|
-
import "./chunk-DGUM43GV.js";
|
|
275
|
+
} from "./chunk-VACPAAQZ.js";
|
|
191
276
|
export {
|
|
192
277
|
ATTACHMENT_DOWNLOAD_TIMEOUT_MS,
|
|
193
278
|
ATTACHMENT_RETRY_DELAY_MS,
|
|
@@ -198,6 +283,8 @@ export {
|
|
|
198
283
|
AttachmentQueueContext,
|
|
199
284
|
AttachmentState,
|
|
200
285
|
AttachmentTable,
|
|
286
|
+
AuthRefreshError,
|
|
287
|
+
CACHE_SIZE_PRESETS,
|
|
201
288
|
COMPRESSION_MAX_WIDTH,
|
|
202
289
|
COMPRESSION_SKIP_SIZE_BYTES,
|
|
203
290
|
COMPRESSION_TARGET_SIZE_BYTES,
|
|
@@ -221,6 +308,7 @@ export {
|
|
|
221
308
|
DEFAULT_COMPRESSION_CONFIG,
|
|
222
309
|
DEFAULT_COMPRESSION_QUALITY,
|
|
223
310
|
DEFAULT_CONNECTION_HEALTH,
|
|
311
|
+
DEFAULT_DOWNLOAD_CONFIG,
|
|
224
312
|
DEFAULT_MAX_RETRY_ATTEMPTS,
|
|
225
313
|
DEFAULT_RETRY_BACKOFF_MULTIPLIER,
|
|
226
314
|
DEFAULT_RETRY_BASE_DELAY_MS,
|
|
@@ -234,6 +322,7 @@ export {
|
|
|
234
322
|
DEFAULT_UPLOAD_CONFIG,
|
|
235
323
|
DEFAULT_UPLOAD_NOTIFICATION,
|
|
236
324
|
DOWNLOAD_STOP_THRESHOLD,
|
|
325
|
+
DOWNLOAD_WORKFLOW_STATES,
|
|
237
326
|
DeadLetterQueue,
|
|
238
327
|
EVICTION_TRIGGER_THRESHOLD,
|
|
239
328
|
EncodingType,
|
|
@@ -243,9 +332,12 @@ export {
|
|
|
243
332
|
HealthMonitor,
|
|
244
333
|
InitializationError,
|
|
245
334
|
LATENCY_DEGRADED_THRESHOLD_MS,
|
|
335
|
+
LOCALLY_AVAILABLE_STATES,
|
|
246
336
|
MAX_CONSECUTIVE_FAILURES,
|
|
247
337
|
MetricsCollector,
|
|
248
338
|
OfflineDataProvider,
|
|
339
|
+
PENDING_DOWNLOAD_STATES,
|
|
340
|
+
PROTECTED_UPLOAD_STATES,
|
|
249
341
|
PendingMutationsContext,
|
|
250
342
|
PlatformAdapterError,
|
|
251
343
|
PolAttachmentQueue,
|
|
@@ -257,6 +349,8 @@ export {
|
|
|
257
349
|
PowerSyncProvider,
|
|
258
350
|
ProviderBridge,
|
|
259
351
|
RetryExhaustedError,
|
|
352
|
+
STATE_MAPPING,
|
|
353
|
+
STATE_NAMES,
|
|
260
354
|
STATS_CACHE_TTL_MS,
|
|
261
355
|
STATUS_NOTIFY_THROTTLE_MS,
|
|
262
356
|
STORAGE_CRITICAL_THRESHOLD,
|
|
@@ -268,6 +362,7 @@ export {
|
|
|
268
362
|
STORAGE_KEY_PREFIX,
|
|
269
363
|
STORAGE_KEY_SYNC_MODE,
|
|
270
364
|
STORAGE_WARNING_THRESHOLD,
|
|
365
|
+
SlimPowerSyncProvider,
|
|
271
366
|
SupabaseConnector,
|
|
272
367
|
SupabaseStorageAdapter,
|
|
273
368
|
SupabaseUploadHandler,
|
|
@@ -277,45 +372,106 @@ export {
|
|
|
277
372
|
SyncOperationError,
|
|
278
373
|
SyncStatusContext,
|
|
279
374
|
SyncStatusTracker,
|
|
375
|
+
TERMINAL_STATES,
|
|
376
|
+
UPLOAD_WORKFLOW_STATES,
|
|
377
|
+
VALID_STATES,
|
|
280
378
|
addJitter,
|
|
379
|
+
blobToArrayBuffer,
|
|
380
|
+
buildIdOnlyWatchQuery,
|
|
381
|
+
buildRecordFetchQuery,
|
|
382
|
+
buildWatchQuery,
|
|
383
|
+
cacheLocalFile,
|
|
281
384
|
calculateBackoffDelay,
|
|
282
385
|
checkIntegrityImpl,
|
|
283
386
|
checkStorageQuotaImpl,
|
|
284
387
|
classifyError,
|
|
285
388
|
classifySupabaseError,
|
|
389
|
+
clearCache,
|
|
390
|
+
clearUploadCallback,
|
|
286
391
|
compactDatabaseImpl,
|
|
392
|
+
copyToManagedCache,
|
|
393
|
+
createCacheManagerDeps,
|
|
287
394
|
createDeadLetterEntry,
|
|
395
|
+
createMigrationStats,
|
|
288
396
|
createPolAttachmentQueue,
|
|
397
|
+
createSupabaseAuth,
|
|
398
|
+
createSupabaseStorage,
|
|
289
399
|
createSupabaseStorageAdapter,
|
|
290
400
|
createSupabaseUploadHandler,
|
|
291
401
|
createSyncError,
|
|
402
|
+
createUploadManagerDeps,
|
|
403
|
+
createUploadManagerState,
|
|
292
404
|
defaultSchemaRouter,
|
|
293
405
|
defineBackgroundSyncTask,
|
|
294
406
|
detectConflicts,
|
|
407
|
+
determineAttachmentState,
|
|
408
|
+
downloadRecord,
|
|
409
|
+
enforceCacheLimit,
|
|
410
|
+
ensureFileUri,
|
|
295
411
|
extractEntityIds,
|
|
412
|
+
extractErrorCode,
|
|
296
413
|
extractTableNames,
|
|
297
414
|
fetchServerVersion,
|
|
298
415
|
formatBytes,
|
|
416
|
+
formatCacheSize,
|
|
417
|
+
formatMigrationStats,
|
|
299
418
|
generateDLQEntryId,
|
|
300
419
|
generateFailureId,
|
|
301
420
|
getCacheStatsImpl,
|
|
421
|
+
getCachedSize,
|
|
422
|
+
getEvictionCandidates,
|
|
423
|
+
getExcludeProtectedStatesCondition,
|
|
302
424
|
getExtensionFromMimeType,
|
|
425
|
+
getFailedPermanentUploads,
|
|
426
|
+
getLocalUriForStoragePath,
|
|
303
427
|
getLocalVersion,
|
|
304
428
|
getMimeType,
|
|
305
429
|
getMimeTypeFromPath,
|
|
430
|
+
getPendingUploads,
|
|
431
|
+
getProtectedStatesInClause,
|
|
432
|
+
getSoonestRetryTime,
|
|
433
|
+
getStaleUploads,
|
|
434
|
+
getStateName,
|
|
435
|
+
getStorageErrorMessage,
|
|
436
|
+
getSyncedUploadsWithPendingCallback,
|
|
306
437
|
hasVersionColumn,
|
|
307
438
|
initializeBackgroundSync,
|
|
308
439
|
isAudioMimeType,
|
|
309
440
|
isBackgroundSyncRegistered,
|
|
441
|
+
isBlobResult,
|
|
442
|
+
isCacheNearCapacity,
|
|
310
443
|
isDocumentMimeType,
|
|
444
|
+
isDownloadWorkflowState,
|
|
445
|
+
isFileResult,
|
|
311
446
|
isImageMimeType,
|
|
447
|
+
isLocallyAvailable,
|
|
448
|
+
isPendingDownloadState,
|
|
449
|
+
isPermanentError,
|
|
450
|
+
isProtectedUploadState,
|
|
451
|
+
isRlsError,
|
|
452
|
+
isStateTransitionAllowed,
|
|
453
|
+
isStorageAuthError,
|
|
454
|
+
isTerminalState,
|
|
455
|
+
isUploadWorkflowState,
|
|
456
|
+
isValidAttachmentState,
|
|
312
457
|
isVideoMimeType,
|
|
458
|
+
markUploadPermanentFailure,
|
|
459
|
+
markUploadSynced,
|
|
460
|
+
migrateAttachmentState,
|
|
461
|
+
migrateAttachmentStateSafe,
|
|
462
|
+
normalizeStoragePath,
|
|
463
|
+
recordMigration,
|
|
313
464
|
registerBackgroundSync,
|
|
314
|
-
|
|
465
|
+
resolveBucket,
|
|
466
|
+
scheduleUploadRetry,
|
|
315
467
|
sleep,
|
|
468
|
+
startUploadProcessing,
|
|
469
|
+
stripFileUri,
|
|
316
470
|
toSyncOperationError,
|
|
317
471
|
unregisterBackgroundSync,
|
|
472
|
+
uploadOne,
|
|
318
473
|
useAttachmentQueue,
|
|
474
|
+
useAttachmentQueueContext,
|
|
319
475
|
useAttachmentQueueReady,
|
|
320
476
|
useCompletedTransactions,
|
|
321
477
|
useCompletedTransactionsContext,
|
|
@@ -333,6 +489,7 @@ export {
|
|
|
333
489
|
usePendingMutationsContext,
|
|
334
490
|
usePlatform,
|
|
335
491
|
usePowerSync,
|
|
492
|
+
usePowerSyncContext,
|
|
336
493
|
useSyncActivity,
|
|
337
494
|
useSyncActivityContext,
|
|
338
495
|
useSyncControl,
|
|
@@ -340,7 +497,12 @@ export {
|
|
|
340
497
|
useSyncMode,
|
|
341
498
|
useSyncModeContext,
|
|
342
499
|
useSyncStatus,
|
|
500
|
+
useSyncStatusContext,
|
|
343
501
|
useUploadStatus,
|
|
502
|
+
validateSqlIdentifier2 as validateSqlIdentifier,
|
|
503
|
+
validateSqlIdentifier as validateSqlIdentifierFromStateMachine,
|
|
504
|
+
validateWhereClause,
|
|
505
|
+
watchConfigToSourceConfig,
|
|
344
506
|
withExponentialBackoff
|
|
345
507
|
};
|
|
346
508
|
//# sourceMappingURL=index.js.map
|